Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nylas

Package Overview
Dependencies
Maintainers
2
Versions
98
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nylas - npm Package Compare versions

Comparing version 4.0.0 to 4.1.0

112

__tests__/restful-model-collection-spec.js

@@ -76,3 +76,4 @@ import Promise from 'bluebird';

0,
100
100,
'/threads'
);

@@ -83,18 +84,21 @@ });

const params = { from: 'ben@nylas.com' };
testContext.collection.forEach(params, () => {}, () => {});
setTimeout(() => {
expect(
testContext.collection._getModelCollection.mock.calls[0]
).toEqual([{ from: 'ben@nylas.com' }, 0, 100]);
expect(
testContext.collection._getModelCollection.mock.calls[1]
).toEqual([{ from: 'ben@nylas.com' }, 100, 100]);
expect(
testContext.collection._getModelCollection.mock.calls[2]
).toEqual([{ from: 'ben@nylas.com' }, 200, 100]);
expect(
testContext.collection._getModelCollection.mock.calls[3]
).toEqual([{ from: 'ben@nylas.com' }, 300, 100]);
done();
}, 5);
testContext.collection.forEach(
params,
() => {},
() => {
expect(
testContext.collection._getModelCollection.mock.calls[0]
).toEqual([{ from: 'ben@nylas.com' }, 0, 100, '/threads']);
expect(
testContext.collection._getModelCollection.mock.calls[1]
).toEqual([{ from: 'ben@nylas.com' }, 100, 100, '/threads']);
expect(
testContext.collection._getModelCollection.mock.calls[2]
).toEqual([{ from: 'ben@nylas.com' }, 200, 100, '/threads']);
expect(
testContext.collection._getModelCollection.mock.calls[3]
).toEqual([{ from: 'ben@nylas.com' }, 300, 100, '/threads']);
done();
}
);
});

@@ -108,8 +112,7 @@

() => (eachCallCount += 1),
() => {}
() => {
expect(eachCallCount).toBe(313);
done();
}
);
setTimeout(() => {
expect(eachCallCount).toBe(313);
done();
}, 5);
});

@@ -123,8 +126,8 @@

() => {},
() => (doneCallCount += 1)
() => {
doneCallCount += 1;
expect(doneCallCount).toBe(1);
done();
}
);
setTimeout(() => {
expect(doneCallCount).toBe(1);
done();
}, 5);
});

@@ -227,3 +230,4 @@ });

0,
1
1,
'/threads'
);

@@ -606,3 +610,3 @@ expect(msg).toBe(testContext.item);

50,
null
'/threads'
);

@@ -620,14 +624,19 @@ });

];
testContext.collection._range({ params, offset: 0, limit: 300 });
setTimeout(() => {
const callback = () => {
expect(
testContext.collection._getModelCollection.calls[0].args
).toEqual([{ from: 'ben@nylas.com' }, 0, 100]);
testContext.collection._getModelCollection.mock.calls[0]
).toEqual([{ from: 'ben@nylas.com' }, 0, 100, '/threads']);
expect(
testContext.collection._getModelCollection.calls[1].args
).toEqual([{ from: 'ben@nylas.com' }, 100, 100]);
testContext.collection._getModelCollection.mock.calls[1]
).toEqual([{ from: 'ben@nylas.com' }, 100, 100, '/threads']);
expect(
testContext.collection._getModelCollection.calls[2].args
).toEqual([{ from: 'ben@nylas.com' }, 200, 100]);
}, 5);
testContext.collection._getModelCollection.mock.calls[2]
).toEqual([{ from: 'ben@nylas.com' }, 200, 100, '/threads']);
};
testContext.collection._range({
params,
callback,
offset: 0,
limit: 300,
});
});

@@ -637,17 +646,22 @@

const params = { from: 'ben@nylas.com' };
testContext.collection._range({ params, offset: 0, limit: 10000 });
setTimeout(() => {
const callback = () => {
expect(
testContext.collection._getModelCollection.calls[0].args
).toEqual([{ from: 'ben@nylas.com' }, 0, 100]);
testContext.collection._getModelCollection.mock.calls[0]
).toEqual([{ from: 'ben@nylas.com' }, 0, 100, '/threads']);
expect(
testContext.collection._getModelCollection.calls[1].args
).toEqual([{ from: 'ben@nylas.com' }, 100, 100]);
testContext.collection._getModelCollection.mock.calls[1]
).toEqual([{ from: 'ben@nylas.com' }, 100, 100, '/threads']);
expect(
testContext.collection._getModelCollection.calls[2].args
).toEqual([{ from: 'ben@nylas.com' }, 200, 100]);
testContext.collection._getModelCollection.mock.calls[2]
).toEqual([{ from: 'ben@nylas.com' }, 200, 100, '/threads']);
expect(
testContext.collection._getModelCollection.calls[3].args
).toEqual([{ from: 'ben@nylas.com' }, 300, 100]);
}, 5);
testContext.collection._getModelCollection.mock.calls[3]
).toEqual([{ from: 'ben@nylas.com' }, 300, 100, '/threads']);
};
testContext.collection._range({
params,
callback,
offset: 0,
limit: 10000,
});
});

@@ -654,0 +668,0 @@

@@ -0,10 +1,39 @@

# Changelog
### 4.1.0 / 2017-12-27
* Added variable for supported version of Nylas API - set to `1.0` and will be updated when the SDK supports later versions of the API
* Added warnings when the version of the API that the SDK supports differs from the version of the API that the application is using
### 4.0.0 / 2017-11-06
* Converted Coffeescript to ES6
* Added ESLint and Prettier for linting
* Updated test framework from Jasmine 1.0 to Jest
* Changed Travis to run Node 8 and lint, build, and test code in CI
* Updated docs and example code
* Added `search()` for messages and threads
* Added `upgrade()` and `downgrade()` for account management
* Added `getRaw()` for retrieving raw messages
* **BREAKING CHANGE**: Changed API for sending raw messages to use `draft.send()` instead of `Message.sendRaw()`
* Changed `list()` to override default `offset` with user’s
* **BREAKING CHANGE**: Changed models for `Contact`, `Draft`, `Event`, `File`, `Folder`, `Message`, and `Thread` to accurately reflect the attribute that the API returns
* Return headers correctly for `expanded` view for `Message` objects
* **BREAKING CHANGE**: Return `Message` object instead of `Draft` object after send
* Return sending failures for partial sends
* Return server errors for SMTP exceptions on send
* **BREAKING CHANGE**: Privatized `_range()`, `_getModel()`, and `_getModelCollection()` (not documented)
* **BREAKING CHANGE**: Removed `draft` attribute on `Message` and `Draft` objects, since the object type is already distinguished
* **BREAKING CHANGE**: Removed support for `Tag` objects, which has been deprecated, and instance methods on `Thread` for `Tag` changes
* **BREAKING CHANGE**: Removed support for `generateCursor()`, which has been deprecated
* **BREAKING CHANGE**: Removed support for the `trial` option for auth, which has been deprecated
### 3.1.1 / 2017-10-06
* No longer throw an error after successful calls to Message.sendRaw
* No longer throw an error after successful calls to `Message.sendRaw()`
* Add status to event model
* Don't require secret for urlForAuthentication, allowing client-side usage
without leaking or faking the app secret
* Don't require secret for `urlForAuthentication()`, allowing client-side usage without leaking or faking the app secret
* Catch rejected promises in some missing cases
* Emit DeltaStream retry status as an event
* Don't console.log, ever (callers should instrument desired logging)
* Emit `DeltaStream` retry status as an event
* Don't `console.log()`, ever (callers should instrument desired logging)
* Fix missing fields and typos in message and thread models

@@ -14,8 +43,3 @@

* Add support for `view=expanded` option. Now all methods on that hit the api
can take querystring params as objects. Additionaly, you can pass in
`{expanded: true}` for convenience.
* **BREAKING CHANGE**: Delta stream now also supports `view=expanded`, `exclude_types`, and
`include_types`, as well as any arbitrary querystring param.
`Delta::startStream` now takes an object as a second argument for querystring
params, instead of an `exclude_types` array.
* Add support for `view=expanded` option. Now all methods on that hit the API can take querystring params as objects. Additionally, you can pass in `{expanded: true}` for convenience.
* **BREAKING CHANGE**: `DeltaStream` now also supports `view=expanded`, `exclude_types`, and `include_types`, as well as any arbitrary query string param. `Delta::startStream` now takes an object as a second argument for query string params, instead of an `exclude_types` array.

@@ -59,2 +59,10 @@ 'use strict';

if (params.view == 'count') {
var err = new Error('forEach() cannot be called with the count view');
if (callback) {
callback(err);
}
return _bluebird2.default.reject(err);
}
var offset = 0;

@@ -66,3 +74,3 @@ var finished = false;

}, function (callback) {
return _this._getModelCollection(params, offset, REQUEST_CHUNK_SIZE).then(function (models) {
return _this._getItems(params, offset, REQUEST_CHUNK_SIZE).then(function (items) {
var _iteratorNormalCompletion = true;

@@ -73,6 +81,6 @@ var _didIteratorError = false;

try {
for (var _iterator = models[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var model = _step.value;
for (var _iterator = items[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var item = _step.value;
eachCallback(model);
eachCallback(item);
}

@@ -94,4 +102,4 @@ } catch (err) {

offset += models.length;
finished = models.length < REQUEST_CHUNK_SIZE;
offset += items.length;
finished = items.length < REQUEST_CHUNK_SIZE;
return callback();

@@ -101,3 +109,3 @@ });

if (completeCallback) {
return completeCallback();
return completeCallback(err);
}

@@ -134,4 +142,12 @@ });

return this._getModelCollection(params, 0, 1).then(function (items) {
if (params.view == 'count') {
var err = new Error('first() cannot be called with the count view');
if (callback) {
callback(err);
}
return _bluebird2.default.reject(err);
}
return this._getItems(params, 0, 1).then(function (items) {
if (callback) {
callback(null, items[0]);

@@ -153,2 +169,10 @@ }

if (params.view == 'count') {
var err = new Error('list() cannot be called with the count view');
if (callback) {
callback(err);
}
return _bluebird2.default.reject(err);
}
var limit = params.limit || Infinity;

@@ -172,2 +196,10 @@ var offset = params.offset;

if (params.view == 'count' || params.view == 'ids') {
var _err = new Error('find() cannot be called with the count or ids view');
if (callback) {
callback(_err);
}
return _bluebird2.default.reject(_err);
}
return this._getModel(id, params).then(function (model) {

@@ -198,8 +230,9 @@ if (callback) {

}
if (!query) {
var _err = new Error('search() requires a query string');
var _err2 = new Error('search() requires a query string');
if (callback) {
callback(_err);
callback(_err2);
}
return _bluebird2.default.reject(_err);
return _bluebird2.default.reject(_err2);
}

@@ -220,3 +253,12 @@

var id = (itemOrId != null ? itemOrId.id : undefined) != null ? itemOrId.id : itemOrId;
if (!itemOrId) {
var err = new Error('delete() requires an item or an id');
if (callback) {
callback(err);
}
return _bluebird2.default.reject(err);
}
var id = itemOrId.id ? itemOrId.id : itemOrId;
if (_underscore2.default.isFunction(params)) {

@@ -282,5 +324,5 @@ callback = params;

var chunkLimit = Math.min(REQUEST_CHUNK_SIZE, limit - accumulated.length);
return _this2._getModelCollection(params, chunkOffset, chunkLimit, path).then(function (models) {
accumulated = accumulated.concat(models);
finished = models.length < REQUEST_CHUNK_SIZE || accumulated.length >= limit;
return _this2._getItems(params, chunkOffset, chunkLimit, path).then(function (items) {
accumulated = accumulated.concat(items);
finished = items.length < REQUEST_CHUNK_SIZE || accumulated.length >= limit;
return chunkCallback();

@@ -306,2 +348,21 @@ }).catch(function (err) {

}, {
key: '_getItems',
value: function _getItems(params, offset, limit, path) {
// Items can be either models or ids
if (!path) {
path = this.path();
}
if (params.view == 'ids') {
return this.connection.request({
method: 'GET',
path: path,
qs: _underscore2.default.extend({}, params, { offset: offset, limit: limit })
});
}
return this._getModelCollection(params, offset, limit, path);
}
}, {
key: '_createModel',

@@ -332,5 +393,2 @@ value: function _createModel(json) {

if (!path) {
path = this.path();
}
return this.connection.request({

@@ -337,0 +395,0 @@ method: 'GET',

@@ -85,2 +85,3 @@ 'use strict';

var SDK_VERSION = PACKAGE_JSON.version;
var SUPPORTED_API_VERSION = '1.0';

@@ -159,2 +160,4 @@ module.exports = function () {

options.headers['Nylas-SDK-API-Version'] = SUPPORTED_API_VERSION;
return options;

@@ -174,2 +177,8 @@ }

var apiVersion = response.headers['nylas-api-version'];
if (SUPPORTED_API_VERSION != apiVersion) {
console.warn('WARNING: ' + SDK_VERSION + ' may not support Nylas API v' + apiVersion + '.');
console.warn('Upgrade package to ensure that it works properly.');
}
if (error || response.statusCode > 299) {

@@ -176,0 +185,0 @@ if (!error) {

{
"name": "nylas",
"version": "4.0.0",
"description":
"A NodeJS wrapper for the Nylas REST API for email, contacts, and calendar.",
"version": "4.1.0",
"description": "A NodeJS wrapper for the Nylas REST API for email, contacts, and calendar.",
"main": "lib/nylas.js",

@@ -10,10 +9,13 @@ "scripts": {

"lint": "eslint \"./!(lib)/**/*.js\"",
"prettier":
"prettier --single-quote --trailing-comma es5 --write \"./!(lib)/**/*.js\"",
"prettier": "prettier --single-quote --trailing-comma es5 --write \"./!(lib)/**/*.js\"",
"build": "babel src --presets babel-preset-env --out-dir lib",
"prepublish": "yarn build"
},
"keywords": ["email", "contacts", "calendar", "nylas"],
"author":
"Ben Gotow <ben@nylas.com>, Karim Hamidou <karim@nylas.com> (https://nylas.com/)",
"keywords": [
"email",
"contacts",
"calendar",
"nylas"
],
"author": "Ben Gotow <ben@nylas.com>, Karim Hamidou <karim@nylas.com> (https://nylas.com/)",
"license": "MIT",

@@ -20,0 +22,0 @@ "dependencies": {

@@ -523,1 +523,6 @@ Nylas Node.js SDK [![Travis build status](https://travis-ci.org/nylas/nylas-nodejs.svg?branch=master)](https://travis-ci.org/nylas/nylas-nodejs)

`npm run lint` or `yarn lint`
To use the package during local development, symlink the directory:
`npm link` or `yarn link` in the `nylas-nodejs` directory
`npm link nylas` or `yarn link nylas` in the directory with your code that uses the package
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc