nylas 6.2.0 → 6.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/config.d.ts +1 -0
- package/lib/models/attributes.d.ts +8 -8
- package/lib/models/attributes.js +8 -12
- package/lib/models/job-status-restful-model-collection.d.ts +9 -0
- package/lib/models/job-status-restful-model-collection.js +38 -0
- package/lib/models/management-account.d.ts +2 -0
- package/lib/models/management-account.js +4 -0
- package/lib/models/message-restful-model-collection.d.ts +6 -0
- package/lib/models/message-restful-model-collection.js +16 -0
- package/lib/models/outbox-job-status.d.ts +20 -0
- package/lib/models/outbox-job-status.js +64 -0
- package/lib/models/outbox-message.d.ts +16 -0
- package/lib/models/outbox-message.js +54 -0
- package/lib/models/outbox.d.ts +35 -0
- package/lib/models/outbox.js +158 -0
- package/lib/models/scheduler.d.ts +7 -2
- package/lib/models/scheduler.js +13 -1
- package/lib/nylas-connection.d.ts +9 -2
- package/lib/nylas-connection.js +43 -7
- package/lib/nylas.d.ts +5 -0
- package/lib/nylas.js +15 -0
- package/package.json +1 -1
package/lib/config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Model from './model';
|
|
2
|
-
|
|
2
|
+
declare type AnyModel = new (...args: any[]) => Model;
|
|
3
3
|
export declare abstract class Attribute {
|
|
4
4
|
modelKey: string;
|
|
5
5
|
jsonKey: string;
|
|
@@ -18,7 +18,7 @@ declare class AttributeObject extends Attribute {
|
|
|
18
18
|
constructor({ modelKey, jsonKey, itemClass, readOnly, }: {
|
|
19
19
|
modelKey: string;
|
|
20
20
|
jsonKey?: string;
|
|
21
|
-
itemClass?:
|
|
21
|
+
itemClass?: AnyModel;
|
|
22
22
|
readOnly?: boolean;
|
|
23
23
|
});
|
|
24
24
|
toJSON(val: any, saveRequestBody?: boolean): unknown;
|
|
@@ -58,12 +58,12 @@ declare class AttributeCollection extends Attribute {
|
|
|
58
58
|
constructor({ modelKey, jsonKey, itemClass, readOnly, }: {
|
|
59
59
|
modelKey: string;
|
|
60
60
|
jsonKey?: string;
|
|
61
|
-
itemClass:
|
|
61
|
+
itemClass: AnyModel;
|
|
62
62
|
readOnly?: boolean;
|
|
63
63
|
});
|
|
64
|
-
toJSON(vals: any, saveRequestBody?: boolean):
|
|
65
|
-
fromJSON(json: unknown[], _parent: any):
|
|
66
|
-
saveRequestBody(val: any):
|
|
64
|
+
toJSON(vals: any, saveRequestBody?: boolean): AnyModel[];
|
|
65
|
+
fromJSON(json: unknown[], _parent: any): AnyModel[];
|
|
66
|
+
saveRequestBody(val: any): AnyModel[] | undefined;
|
|
67
67
|
}
|
|
68
68
|
declare class AttributeEnum extends Attribute {
|
|
69
69
|
itemClass: any;
|
|
@@ -121,7 +121,7 @@ declare const Attributes: {
|
|
|
121
121
|
Collection(__0: {
|
|
122
122
|
modelKey: string;
|
|
123
123
|
jsonKey?: string | undefined;
|
|
124
|
-
itemClass:
|
|
124
|
+
itemClass: AnyModel;
|
|
125
125
|
readOnly?: boolean | undefined;
|
|
126
126
|
}): AttributeCollection;
|
|
127
127
|
Boolean(__0: {
|
|
@@ -132,7 +132,7 @@ declare const Attributes: {
|
|
|
132
132
|
Object(__0: {
|
|
133
133
|
modelKey: string;
|
|
134
134
|
jsonKey?: string | undefined;
|
|
135
|
-
itemClass?:
|
|
135
|
+
itemClass?: AnyModel | undefined;
|
|
136
136
|
readOnly?: boolean | undefined;
|
|
137
137
|
}): AttributeObject;
|
|
138
138
|
Enum(__0: {
|
package/lib/models/attributes.js
CHANGED
|
@@ -19,15 +19,11 @@ var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
|
19
19
|
r[k] = a[j];
|
|
20
20
|
return r;
|
|
21
21
|
};
|
|
22
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
23
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
|
-
};
|
|
25
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
|
|
27
|
-
//
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
// The Attribute class also exposes convenience methods for generating Matchers.
|
|
23
|
+
function isRestfulModel(cls) {
|
|
24
|
+
// A 'RestfulModel' has 'endpointName' and 'collectionName' unlike 'Model'
|
|
25
|
+
return cls.endpointName !== undefined && cls.collectionName !== undefined;
|
|
26
|
+
}
|
|
31
27
|
var Attribute = /** @class */ (function () {
|
|
32
28
|
function Attribute(_a) {
|
|
33
29
|
var modelKey = _a.modelKey, jsonKey = _a.jsonKey, readOnly = _a.readOnly;
|
|
@@ -68,8 +64,8 @@ var AttributeObject = /** @class */ (function (_super) {
|
|
|
68
64
|
if (!val || !this.itemClass) {
|
|
69
65
|
return val;
|
|
70
66
|
}
|
|
71
|
-
if (this.itemClass
|
|
72
|
-
return new this.itemClass(_parent.connection).fromJSON(val);
|
|
67
|
+
if (isRestfulModel(this.itemClass)) {
|
|
68
|
+
return new this.itemClass(_parent.connection, val).fromJSON(val);
|
|
73
69
|
}
|
|
74
70
|
return new this.itemClass(val).fromJSON(val);
|
|
75
71
|
};
|
|
@@ -239,8 +235,8 @@ var AttributeCollection = /** @class */ (function (_super) {
|
|
|
239
235
|
for (var _i = 0, json_1 = json; _i < json_1.length; _i++) {
|
|
240
236
|
var objJSON = json_1[_i];
|
|
241
237
|
var obj = void 0;
|
|
242
|
-
if (this.itemClass
|
|
243
|
-
obj = new this.itemClass(_parent.connection).fromJSON(objJSON);
|
|
238
|
+
if (isRestfulModel(this.itemClass)) {
|
|
239
|
+
obj = new this.itemClass(_parent.connection, objJSON).fromJSON(objJSON);
|
|
244
240
|
}
|
|
245
241
|
else {
|
|
246
242
|
obj = new this.itemClass(objJSON).fromJSON(objJSON);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import RestfulModelCollection from './restful-model-collection';
|
|
2
|
+
import JobStatus from './job-status';
|
|
3
|
+
import NylasConnection from '../nylas-connection';
|
|
4
|
+
export default class JobStatusRestfulModelCollection extends RestfulModelCollection<JobStatus> {
|
|
5
|
+
connection: NylasConnection;
|
|
6
|
+
modelClass: typeof JobStatus;
|
|
7
|
+
constructor(connection: NylasConnection);
|
|
8
|
+
protected createModel(json: Record<string, unknown>): JobStatus;
|
|
9
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
extendStatics(d, b);
|
|
11
|
+
function __() { this.constructor = d; }
|
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
16
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
var restful_model_collection_1 = __importDefault(require("./restful-model-collection"));
|
|
20
|
+
var job_status_1 = __importDefault(require("./job-status"));
|
|
21
|
+
var outbox_job_status_1 = __importDefault(require("./outbox-job-status"));
|
|
22
|
+
var JobStatusRestfulModelCollection = /** @class */ (function (_super) {
|
|
23
|
+
__extends(JobStatusRestfulModelCollection, _super);
|
|
24
|
+
function JobStatusRestfulModelCollection(connection) {
|
|
25
|
+
var _this = _super.call(this, job_status_1.default, connection) || this;
|
|
26
|
+
_this.connection = connection;
|
|
27
|
+
_this.modelClass = job_status_1.default;
|
|
28
|
+
return _this;
|
|
29
|
+
}
|
|
30
|
+
JobStatusRestfulModelCollection.prototype.createModel = function (json) {
|
|
31
|
+
if (json['object'] && json['object'] === 'message') {
|
|
32
|
+
return new outbox_job_status_1.default(this.connection).fromJSON(json);
|
|
33
|
+
}
|
|
34
|
+
return new this.modelClass(this.connection).fromJSON(json);
|
|
35
|
+
};
|
|
36
|
+
return JobStatusRestfulModelCollection;
|
|
37
|
+
}(restful_model_collection_1.default));
|
|
38
|
+
exports.default = JobStatusRestfulModelCollection;
|
|
@@ -33,6 +33,7 @@ export declare type ManagementAccountProperties = {
|
|
|
33
33
|
namespaceId: string;
|
|
34
34
|
provider: string;
|
|
35
35
|
syncState: string;
|
|
36
|
+
authenticationType: string;
|
|
36
37
|
trial: boolean;
|
|
37
38
|
metadata?: object;
|
|
38
39
|
};
|
|
@@ -45,6 +46,7 @@ export default class ManagementAccount extends ManagementModel implements Manage
|
|
|
45
46
|
namespaceId: string;
|
|
46
47
|
provider: string;
|
|
47
48
|
syncState: string;
|
|
49
|
+
authenticationType: string;
|
|
48
50
|
trial: boolean;
|
|
49
51
|
metadata?: object;
|
|
50
52
|
static collectionName: string;
|
|
@@ -91,6 +91,7 @@ var ManagementAccount = /** @class */ (function (_super) {
|
|
|
91
91
|
_this.namespaceId = '';
|
|
92
92
|
_this.provider = '';
|
|
93
93
|
_this.syncState = '';
|
|
94
|
+
_this.authenticationType = '';
|
|
94
95
|
_this.trial = false;
|
|
95
96
|
_this.initAttributes(props);
|
|
96
97
|
return _this;
|
|
@@ -173,6 +174,9 @@ var ManagementAccount = /** @class */ (function (_super) {
|
|
|
173
174
|
}), syncState: attributes_1.default.String({
|
|
174
175
|
modelKey: 'syncState',
|
|
175
176
|
jsonKey: 'sync_state',
|
|
177
|
+
}), authenticationType: attributes_1.default.String({
|
|
178
|
+
modelKey: 'authenticationType',
|
|
179
|
+
jsonKey: 'authentication_type',
|
|
176
180
|
}), trial: attributes_1.default.Boolean({
|
|
177
181
|
modelKey: 'trial',
|
|
178
182
|
}), metadata: attributes_1.default.Object({
|
|
@@ -17,4 +17,10 @@ export default class MessageRestfulModelCollection extends RestfulModelCollectio
|
|
|
17
17
|
limit?: number;
|
|
18
18
|
callback?: (error: Error | null, results?: Message[]) => void;
|
|
19
19
|
}): Promise<Message[]>;
|
|
20
|
+
/**
|
|
21
|
+
* Return raw message contents
|
|
22
|
+
* @param messageId The message to fetch content of
|
|
23
|
+
* @returns The raw message contents
|
|
24
|
+
*/
|
|
25
|
+
findRaw(messageId: string): Promise<string>;
|
|
20
26
|
}
|
|
@@ -53,6 +53,22 @@ var MessageRestfulModelCollection = /** @class */ (function (_super) {
|
|
|
53
53
|
}
|
|
54
54
|
return this.range(__assign({ path: this.path() + "/" + messageIds.join() }, options));
|
|
55
55
|
};
|
|
56
|
+
/**
|
|
57
|
+
* Return raw message contents
|
|
58
|
+
* @param messageId The message to fetch content of
|
|
59
|
+
* @returns The raw message contents
|
|
60
|
+
*/
|
|
61
|
+
MessageRestfulModelCollection.prototype.findRaw = function (messageId) {
|
|
62
|
+
return this.connection
|
|
63
|
+
.request({
|
|
64
|
+
method: 'GET',
|
|
65
|
+
headers: {
|
|
66
|
+
Accept: 'message/rfc822',
|
|
67
|
+
},
|
|
68
|
+
path: this.path() + "/" + messageId,
|
|
69
|
+
})
|
|
70
|
+
.catch(function (err) { return Promise.reject(err); });
|
|
71
|
+
};
|
|
56
72
|
return MessageRestfulModelCollection;
|
|
57
73
|
}(restful_model_collection_1.default));
|
|
58
74
|
exports.default = MessageRestfulModelCollection;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import OutboxMessage, { OutboxMessageProperties } from './outbox-message';
|
|
2
|
+
import { Attribute } from './attributes';
|
|
3
|
+
import NylasConnection from '../nylas-connection';
|
|
4
|
+
import JobStatus, { JobStatusProperties } from './job-status';
|
|
5
|
+
export declare type OutboxJobStatusProperties = JobStatusProperties & {
|
|
6
|
+
messageId?: string;
|
|
7
|
+
threadId?: string;
|
|
8
|
+
sendAt?: Date;
|
|
9
|
+
originalSendAt?: Date;
|
|
10
|
+
originalData?: OutboxMessageProperties;
|
|
11
|
+
};
|
|
12
|
+
export default class OutboxJobStatus extends JobStatus implements OutboxJobStatusProperties {
|
|
13
|
+
messageId?: string;
|
|
14
|
+
threadId?: string;
|
|
15
|
+
sendAt?: Date;
|
|
16
|
+
originalSendAt?: Date;
|
|
17
|
+
originalData?: OutboxMessage;
|
|
18
|
+
static attributes: Record<string, Attribute>;
|
|
19
|
+
constructor(connection: NylasConnection, props?: OutboxJobStatusProperties);
|
|
20
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
extendStatics(d, b);
|
|
11
|
+
function __() { this.constructor = d; }
|
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
var __assign = (this && this.__assign) || function () {
|
|
16
|
+
__assign = Object.assign || function(t) {
|
|
17
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
18
|
+
s = arguments[i];
|
|
19
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
20
|
+
t[p] = s[p];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
return __assign.apply(this, arguments);
|
|
25
|
+
};
|
|
26
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
var outbox_message_1 = __importDefault(require("./outbox-message"));
|
|
31
|
+
var attributes_1 = __importDefault(require("./attributes"));
|
|
32
|
+
var job_status_1 = __importDefault(require("./job-status"));
|
|
33
|
+
var OutboxJobStatus = /** @class */ (function (_super) {
|
|
34
|
+
__extends(OutboxJobStatus, _super);
|
|
35
|
+
function OutboxJobStatus(connection, props) {
|
|
36
|
+
var _this = _super.call(this, connection, props) || this;
|
|
37
|
+
_this.initAttributes(props);
|
|
38
|
+
return _this;
|
|
39
|
+
}
|
|
40
|
+
OutboxJobStatus.attributes = __assign(__assign({}, job_status_1.default.attributes), { messageId: attributes_1.default.String({
|
|
41
|
+
modelKey: 'messageId',
|
|
42
|
+
jsonKey: 'message_id',
|
|
43
|
+
readOnly: true,
|
|
44
|
+
}), threadId: attributes_1.default.String({
|
|
45
|
+
modelKey: 'threadId',
|
|
46
|
+
jsonKey: 'thread_id',
|
|
47
|
+
readOnly: true,
|
|
48
|
+
}), sendAt: attributes_1.default.DateTime({
|
|
49
|
+
modelKey: 'sendAt',
|
|
50
|
+
jsonKey: 'send_at',
|
|
51
|
+
readOnly: true,
|
|
52
|
+
}), originalSendAt: attributes_1.default.DateTime({
|
|
53
|
+
modelKey: 'originalSendAt',
|
|
54
|
+
jsonKey: 'original_send_at',
|
|
55
|
+
readOnly: true,
|
|
56
|
+
}), originalData: attributes_1.default.Object({
|
|
57
|
+
modelKey: 'originalData',
|
|
58
|
+
jsonKey: 'original_data',
|
|
59
|
+
itemClass: outbox_message_1.default,
|
|
60
|
+
readOnly: true,
|
|
61
|
+
}) });
|
|
62
|
+
return OutboxJobStatus;
|
|
63
|
+
}(job_status_1.default));
|
|
64
|
+
exports.default = OutboxJobStatus;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Draft, { DraftProperties } from './draft';
|
|
2
|
+
import { Attribute } from './attributes';
|
|
3
|
+
import NylasConnection from '../nylas-connection';
|
|
4
|
+
export declare type OutboxMessageProperties = DraftProperties & {
|
|
5
|
+
sendAt: Date;
|
|
6
|
+
retryLimitDatetime?: Date;
|
|
7
|
+
originalSendAt?: Date;
|
|
8
|
+
};
|
|
9
|
+
export default class OutboxMessage extends Draft implements OutboxMessageProperties {
|
|
10
|
+
sendAt: Date;
|
|
11
|
+
retryLimitDatetime?: Date;
|
|
12
|
+
originalSendAt?: Date;
|
|
13
|
+
static collectionName: string;
|
|
14
|
+
static attributes: Record<string, Attribute>;
|
|
15
|
+
constructor(connection: NylasConnection, props?: OutboxMessageProperties);
|
|
16
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
extendStatics(d, b);
|
|
11
|
+
function __() { this.constructor = d; }
|
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
var __assign = (this && this.__assign) || function () {
|
|
16
|
+
__assign = Object.assign || function(t) {
|
|
17
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
18
|
+
s = arguments[i];
|
|
19
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
20
|
+
t[p] = s[p];
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
return __assign.apply(this, arguments);
|
|
25
|
+
};
|
|
26
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
var draft_1 = __importDefault(require("./draft"));
|
|
31
|
+
var attributes_1 = __importDefault(require("./attributes"));
|
|
32
|
+
var OutboxMessage = /** @class */ (function (_super) {
|
|
33
|
+
__extends(OutboxMessage, _super);
|
|
34
|
+
function OutboxMessage(connection, props) {
|
|
35
|
+
var _this = _super.call(this, connection, props) || this;
|
|
36
|
+
_this.sendAt = new Date();
|
|
37
|
+
_this.initAttributes(props);
|
|
38
|
+
return _this;
|
|
39
|
+
}
|
|
40
|
+
OutboxMessage.collectionName = '/v2/outbox';
|
|
41
|
+
OutboxMessage.attributes = __assign(__assign({}, draft_1.default.attributes), { sendAt: attributes_1.default.DateTime({
|
|
42
|
+
modelKey: 'sendAt',
|
|
43
|
+
jsonKey: 'send_at',
|
|
44
|
+
}), retryLimitDatetime: attributes_1.default.DateTime({
|
|
45
|
+
modelKey: 'retryLimitDatetime',
|
|
46
|
+
jsonKey: 'retry_limit_datetime',
|
|
47
|
+
}), originalSendAt: attributes_1.default.DateTime({
|
|
48
|
+
modelKey: 'originalSendAt',
|
|
49
|
+
jsonKey: 'original_send_at',
|
|
50
|
+
readOnly: true,
|
|
51
|
+
}) });
|
|
52
|
+
return OutboxMessage;
|
|
53
|
+
}(draft_1.default));
|
|
54
|
+
exports.default = OutboxMessage;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import NylasConnection from '../nylas-connection';
|
|
2
|
+
import Draft, { SendCallback } from './draft';
|
|
3
|
+
import OutboxJobStatus from './outbox-job-status';
|
|
4
|
+
import Model from './model';
|
|
5
|
+
import { Attribute } from './attributes';
|
|
6
|
+
declare type SendParams = {
|
|
7
|
+
sendAt: Date | number;
|
|
8
|
+
retryLimitDatetime?: Date | number;
|
|
9
|
+
tracking?: Record<string, any>;
|
|
10
|
+
callback?: SendCallback;
|
|
11
|
+
};
|
|
12
|
+
declare type UpdateParams = {
|
|
13
|
+
updatedMessage?: Draft;
|
|
14
|
+
sendAt?: Date | number;
|
|
15
|
+
retryLimitDatetime?: Date | number;
|
|
16
|
+
};
|
|
17
|
+
export declare class SendGridVerifiedStatus extends Model {
|
|
18
|
+
domainVerified?: boolean;
|
|
19
|
+
senderVerified?: boolean;
|
|
20
|
+
static attributes: Record<string, Attribute>;
|
|
21
|
+
}
|
|
22
|
+
export default class Outbox {
|
|
23
|
+
connection: NylasConnection;
|
|
24
|
+
private path;
|
|
25
|
+
constructor(connection: NylasConnection);
|
|
26
|
+
send(draft: Draft, options: SendParams): Promise<OutboxJobStatus>;
|
|
27
|
+
update(jobStatusId: string, options: UpdateParams): Promise<OutboxJobStatus>;
|
|
28
|
+
delete(jobStatusId: string): Promise<void>;
|
|
29
|
+
sendGridVerificationStatus(): Promise<SendGridVerifiedStatus>;
|
|
30
|
+
deleteSendGridSubUser(email: string): Promise<void>;
|
|
31
|
+
private request;
|
|
32
|
+
private static validateAndFormatDateTime;
|
|
33
|
+
private static dateToEpoch;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
extendStatics(d, b);
|
|
11
|
+
function __() { this.constructor = d; }
|
|
12
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
+
};
|
|
14
|
+
})();
|
|
15
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
16
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
var nylas_connection_1 = require("../nylas-connection");
|
|
20
|
+
var outbox_job_status_1 = __importDefault(require("./outbox-job-status"));
|
|
21
|
+
var model_1 = __importDefault(require("./model"));
|
|
22
|
+
var attributes_1 = __importDefault(require("./attributes"));
|
|
23
|
+
var SendGridVerifiedStatus = /** @class */ (function (_super) {
|
|
24
|
+
__extends(SendGridVerifiedStatus, _super);
|
|
25
|
+
function SendGridVerifiedStatus() {
|
|
26
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
27
|
+
}
|
|
28
|
+
SendGridVerifiedStatus.attributes = {
|
|
29
|
+
domainVerified: attributes_1.default.Boolean({
|
|
30
|
+
modelKey: 'domainVerified',
|
|
31
|
+
jsonKey: 'domain_verified',
|
|
32
|
+
}),
|
|
33
|
+
senderVerified: attributes_1.default.Boolean({
|
|
34
|
+
modelKey: 'senderVerified',
|
|
35
|
+
jsonKey: 'sender_verified',
|
|
36
|
+
}),
|
|
37
|
+
};
|
|
38
|
+
return SendGridVerifiedStatus;
|
|
39
|
+
}(model_1.default));
|
|
40
|
+
exports.SendGridVerifiedStatus = SendGridVerifiedStatus;
|
|
41
|
+
var Outbox = /** @class */ (function () {
|
|
42
|
+
function Outbox(connection) {
|
|
43
|
+
this.path = '/v2/outbox';
|
|
44
|
+
this.connection = connection;
|
|
45
|
+
}
|
|
46
|
+
Outbox.prototype.send = function (draft, options) {
|
|
47
|
+
var _this = this;
|
|
48
|
+
var body = draft.saveRequestBody();
|
|
49
|
+
if (options.tracking) {
|
|
50
|
+
body['tracking'] = options.tracking;
|
|
51
|
+
}
|
|
52
|
+
var _a = Outbox.validateAndFormatDateTime(options.sendAt, options.retryLimitDatetime), sendAt = _a[0], retryLimitDatetime = _a[1];
|
|
53
|
+
body['send_at'] = sendAt;
|
|
54
|
+
body['retry_limit_datetime'] = retryLimitDatetime;
|
|
55
|
+
return this.request({
|
|
56
|
+
method: 'POST',
|
|
57
|
+
path: '',
|
|
58
|
+
body: body,
|
|
59
|
+
})
|
|
60
|
+
.then(function (json) {
|
|
61
|
+
var message = new outbox_job_status_1.default(_this.connection).fromJSON(json);
|
|
62
|
+
if (options.callback) {
|
|
63
|
+
options.callback(null, message);
|
|
64
|
+
}
|
|
65
|
+
return Promise.resolve(message);
|
|
66
|
+
})
|
|
67
|
+
.catch(function (err) {
|
|
68
|
+
if (options.callback) {
|
|
69
|
+
options.callback(err);
|
|
70
|
+
}
|
|
71
|
+
return Promise.reject(err);
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
Outbox.prototype.update = function (jobStatusId, options) {
|
|
75
|
+
var _this = this;
|
|
76
|
+
var body = {};
|
|
77
|
+
if (options.updatedMessage) {
|
|
78
|
+
body = options.updatedMessage.saveRequestBody();
|
|
79
|
+
}
|
|
80
|
+
var _a = Outbox.validateAndFormatDateTime(options.sendAt, options.retryLimitDatetime), sendAt = _a[0], retryLimitDatetime = _a[1];
|
|
81
|
+
body['send_at'] = sendAt;
|
|
82
|
+
body['retry_limit_datetime'] = retryLimitDatetime;
|
|
83
|
+
return this.request({
|
|
84
|
+
method: 'PATCH',
|
|
85
|
+
path: "/" + jobStatusId,
|
|
86
|
+
body: body,
|
|
87
|
+
}).then(function (json) {
|
|
88
|
+
var message = new outbox_job_status_1.default(_this.connection).fromJSON(json);
|
|
89
|
+
return Promise.resolve(message);
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
Outbox.prototype.delete = function (jobStatusId) {
|
|
93
|
+
return this.request({
|
|
94
|
+
method: 'DELETE',
|
|
95
|
+
path: "/" + jobStatusId,
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
Outbox.prototype.sendGridVerificationStatus = function () {
|
|
99
|
+
return this.request({
|
|
100
|
+
method: 'GET',
|
|
101
|
+
path: "/onboard/verified_status",
|
|
102
|
+
}).then(function (json) {
|
|
103
|
+
if (json.results) {
|
|
104
|
+
json = json.results;
|
|
105
|
+
}
|
|
106
|
+
var verifiedStatus = new SendGridVerifiedStatus().fromJSON(json);
|
|
107
|
+
return Promise.resolve(verifiedStatus);
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
Outbox.prototype.deleteSendGridSubUser = function (email) {
|
|
111
|
+
return this.request({
|
|
112
|
+
method: 'DELETE',
|
|
113
|
+
path: "/onboard/subuser",
|
|
114
|
+
body: { email: email },
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
Outbox.prototype.request = function (options) {
|
|
118
|
+
var header;
|
|
119
|
+
if (options.body) {
|
|
120
|
+
header = {
|
|
121
|
+
'Content-Type': 'application/json',
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
return this.connection.request({
|
|
125
|
+
method: options.method,
|
|
126
|
+
path: "" + this.path + options.path,
|
|
127
|
+
body: options.body,
|
|
128
|
+
headers: header,
|
|
129
|
+
authMethod: nylas_connection_1.AuthMethod.BEARER,
|
|
130
|
+
});
|
|
131
|
+
};
|
|
132
|
+
Outbox.validateAndFormatDateTime = function (sendAt, retryLimitDatetime) {
|
|
133
|
+
var sendAtEpoch = sendAt instanceof Date ? Outbox.dateToEpoch(sendAt) : sendAt;
|
|
134
|
+
var retryLimitDatetimeEpoch = retryLimitDatetime instanceof Date
|
|
135
|
+
? Outbox.dateToEpoch(retryLimitDatetime)
|
|
136
|
+
: retryLimitDatetime;
|
|
137
|
+
if (sendAtEpoch && sendAtEpoch !== 0) {
|
|
138
|
+
if (sendAtEpoch < Outbox.dateToEpoch(new Date())) {
|
|
139
|
+
throw new Error('Cannot set message to be sent at a time before the current time.');
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (retryLimitDatetimeEpoch && retryLimitDatetimeEpoch !== 0) {
|
|
143
|
+
var validSendAt = sendAtEpoch;
|
|
144
|
+
if (!validSendAt || validSendAt === 0) {
|
|
145
|
+
validSendAt = Outbox.dateToEpoch(new Date());
|
|
146
|
+
}
|
|
147
|
+
if (retryLimitDatetimeEpoch < validSendAt) {
|
|
148
|
+
throw new Error('Cannot set message to stop retrying before time to send at.');
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return [sendAtEpoch, retryLimitDatetimeEpoch];
|
|
152
|
+
};
|
|
153
|
+
Outbox.dateToEpoch = function (date) {
|
|
154
|
+
return Math.floor(date.getTime() / 1000.0);
|
|
155
|
+
};
|
|
156
|
+
return Outbox;
|
|
157
|
+
}());
|
|
158
|
+
exports.default = Outbox;
|
|
@@ -34,6 +34,7 @@ export declare type SchedulerAppearanceProperties = {
|
|
|
34
34
|
showAutoschedule?: boolean;
|
|
35
35
|
showNylasBranding?: boolean;
|
|
36
36
|
showTimezoneOptions?: boolean;
|
|
37
|
+
showWeekView?: boolean;
|
|
37
38
|
submitText?: string;
|
|
38
39
|
thankYouRedirect?: string;
|
|
39
40
|
thankYouText?: string;
|
|
@@ -47,6 +48,7 @@ export declare class SchedulerAppearance extends Model implements SchedulerAppea
|
|
|
47
48
|
showAutoschedule?: boolean;
|
|
48
49
|
showNylasBranding?: boolean;
|
|
49
50
|
showTimezoneOptions?: boolean;
|
|
51
|
+
showWeekView?: boolean;
|
|
50
52
|
submitText?: string;
|
|
51
53
|
thankYouRedirect?: string;
|
|
52
54
|
thankYouText?: string;
|
|
@@ -78,13 +80,13 @@ export declare class SchedulerBookingAdditionalFields extends Model implements S
|
|
|
78
80
|
}
|
|
79
81
|
export declare type SchedulerBookingOpeningHoursProperties = {
|
|
80
82
|
accountId?: string;
|
|
81
|
-
days?: string;
|
|
83
|
+
days?: string[];
|
|
82
84
|
end?: string;
|
|
83
85
|
start?: string;
|
|
84
86
|
};
|
|
85
87
|
export declare class SchedulerBookingOpeningHours extends Model implements SchedulerBookingOpeningHoursProperties {
|
|
86
88
|
accountId?: string;
|
|
87
|
-
days?: string;
|
|
89
|
+
days?: string[];
|
|
88
90
|
end?: string;
|
|
89
91
|
start?: string;
|
|
90
92
|
static attributes: Record<string, Attribute>;
|
|
@@ -92,6 +94,7 @@ export declare class SchedulerBookingOpeningHours extends Model implements Sched
|
|
|
92
94
|
}
|
|
93
95
|
export declare type SchedulerBookingProperties = {
|
|
94
96
|
additionalFields?: SchedulerBookingAdditionalFieldsProperties[];
|
|
97
|
+
additionalGuestsHidden?: boolean;
|
|
95
98
|
availableDaysInFuture?: number;
|
|
96
99
|
calendarInviteToGuests?: boolean;
|
|
97
100
|
cancellationPolicy?: string;
|
|
@@ -107,6 +110,7 @@ export declare type SchedulerBookingProperties = {
|
|
|
107
110
|
};
|
|
108
111
|
export declare class SchedulerBooking extends Model implements SchedulerBookingProperties {
|
|
109
112
|
additionalFields?: SchedulerBookingAdditionalFields[];
|
|
113
|
+
additionalGuestsHidden?: boolean;
|
|
110
114
|
availableDaysInFuture?: number;
|
|
111
115
|
calendarInviteToGuests?: boolean;
|
|
112
116
|
cancellationPolicy?: string;
|
|
@@ -179,6 +183,7 @@ export declare class SchedulerConfig extends Model implements SchedulerConfigPro
|
|
|
179
183
|
date?: number;
|
|
180
184
|
uses?: number;
|
|
181
185
|
};
|
|
186
|
+
disableEmails?: boolean;
|
|
182
187
|
locale?: string;
|
|
183
188
|
localeForGuests?: string;
|
|
184
189
|
reminders?: SchedulerRemindersProperties[];
|
package/lib/models/scheduler.js
CHANGED
|
@@ -108,6 +108,10 @@ var SchedulerAppearance = /** @class */ (function (_super) {
|
|
|
108
108
|
modelKey: 'showTimezoneOptions',
|
|
109
109
|
jsonKey: 'show_timezone_options',
|
|
110
110
|
}),
|
|
111
|
+
showWeekView: attributes_1.default.Boolean({
|
|
112
|
+
modelKey: 'showWeekView',
|
|
113
|
+
jsonKey: 'show_week_view',
|
|
114
|
+
}),
|
|
111
115
|
submitText: attributes_1.default.String({
|
|
112
116
|
modelKey: 'submitText',
|
|
113
117
|
jsonKey: 'submit_text',
|
|
@@ -178,7 +182,7 @@ var SchedulerBookingOpeningHours = /** @class */ (function (_super) {
|
|
|
178
182
|
modelKey: 'accountId',
|
|
179
183
|
jsonKey: 'account_id',
|
|
180
184
|
}),
|
|
181
|
-
days: attributes_1.default.
|
|
185
|
+
days: attributes_1.default.StringList({
|
|
182
186
|
modelKey: 'days',
|
|
183
187
|
}),
|
|
184
188
|
end: attributes_1.default.String({
|
|
@@ -204,6 +208,10 @@ var SchedulerBooking = /** @class */ (function (_super) {
|
|
|
204
208
|
jsonKey: 'additional_fields',
|
|
205
209
|
itemClass: SchedulerBookingAdditionalFields,
|
|
206
210
|
}),
|
|
211
|
+
additionalGuestsHidden: attributes_1.default.Boolean({
|
|
212
|
+
modelKey: 'additionalGuestsHidden',
|
|
213
|
+
jsonKey: 'additional_guests_hidden',
|
|
214
|
+
}),
|
|
207
215
|
availableDaysInFuture: attributes_1.default.Number({
|
|
208
216
|
modelKey: 'availableDaysInFuture',
|
|
209
217
|
jsonKey: 'available_days_in_future',
|
|
@@ -316,6 +324,10 @@ var SchedulerConfig = /** @class */ (function (_super) {
|
|
|
316
324
|
modelKey: 'expireAfter',
|
|
317
325
|
jsonKey: 'expire_after',
|
|
318
326
|
}),
|
|
327
|
+
disableEmails: attributes_1.default.Boolean({
|
|
328
|
+
modelKey: 'disableEmails',
|
|
329
|
+
jsonKey: 'disable_emails',
|
|
330
|
+
}),
|
|
319
331
|
locale: attributes_1.default.String({
|
|
320
332
|
modelKey: 'locale',
|
|
321
333
|
}),
|
|
@@ -10,7 +10,6 @@ import Thread from './models/thread';
|
|
|
10
10
|
import Draft from './models/draft';
|
|
11
11
|
import File from './models/file';
|
|
12
12
|
import Event from './models/event';
|
|
13
|
-
import JobStatus from './models/job-status';
|
|
14
13
|
import Resource from './models/resource';
|
|
15
14
|
import Folder, { Label } from './models/folder';
|
|
16
15
|
import { AppendOptions } from 'form-data';
|
|
@@ -19,6 +18,12 @@ import ComponentRestfulModelCollection from './models/component-restful-model-co
|
|
|
19
18
|
import SchedulerRestfulModelCollection from './models/scheduler-restful-model-collection';
|
|
20
19
|
import MessageRestfulModelCollection from './models/message-restful-model-collection';
|
|
21
20
|
import DeltaCollection from './models/delta-collection';
|
|
21
|
+
import Outbox from './models/outbox';
|
|
22
|
+
import JobStatusRestfulModelCollection from './models/job-status-restful-model-collection';
|
|
23
|
+
export declare enum AuthMethod {
|
|
24
|
+
BASIC = 0,
|
|
25
|
+
BEARER = 1
|
|
26
|
+
}
|
|
22
27
|
export declare type RequestOptions = {
|
|
23
28
|
path: string;
|
|
24
29
|
method?: string;
|
|
@@ -30,6 +35,7 @@ export declare type RequestOptions = {
|
|
|
30
35
|
body?: any;
|
|
31
36
|
baseUrl?: string;
|
|
32
37
|
url?: URL;
|
|
38
|
+
authMethod?: AuthMethod;
|
|
33
39
|
};
|
|
34
40
|
export declare type FormDataType = {
|
|
35
41
|
value: unknown;
|
|
@@ -44,7 +50,7 @@ export default class NylasConnection {
|
|
|
44
50
|
drafts: RestfulModelCollection<Draft>;
|
|
45
51
|
files: RestfulModelCollection<File>;
|
|
46
52
|
calendars: CalendarRestfulModelCollection;
|
|
47
|
-
jobStatuses:
|
|
53
|
+
jobStatuses: JobStatusRestfulModelCollection;
|
|
48
54
|
events: RestfulModelCollection<Event>;
|
|
49
55
|
resources: RestfulModelCollection<Resource>;
|
|
50
56
|
deltas: DeltaCollection;
|
|
@@ -53,6 +59,7 @@ export default class NylasConnection {
|
|
|
53
59
|
account: RestfulModelInstance<Account>;
|
|
54
60
|
component: ComponentRestfulModelCollection;
|
|
55
61
|
scheduler: SchedulerRestfulModelCollection;
|
|
62
|
+
outbox: Outbox;
|
|
56
63
|
neural: Neural;
|
|
57
64
|
constructor(accessToken: string | null | undefined, { clientId }: {
|
|
58
65
|
clientId: string | null | undefined;
|
package/lib/nylas-connection.js
CHANGED
|
@@ -34,7 +34,6 @@ var thread_1 = __importDefault(require("./models/thread"));
|
|
|
34
34
|
var draft_1 = __importDefault(require("./models/draft"));
|
|
35
35
|
var file_1 = __importDefault(require("./models/file"));
|
|
36
36
|
var event_1 = __importDefault(require("./models/event"));
|
|
37
|
-
var job_status_1 = __importDefault(require("./models/job-status"));
|
|
38
37
|
var resource_1 = __importDefault(require("./models/resource"));
|
|
39
38
|
var folder_1 = __importStar(require("./models/folder"));
|
|
40
39
|
var form_data_1 = __importDefault(require("form-data"));
|
|
@@ -44,9 +43,16 @@ var component_restful_model_collection_1 = __importDefault(require("./models/com
|
|
|
44
43
|
var scheduler_restful_model_collection_1 = __importDefault(require("./models/scheduler-restful-model-collection"));
|
|
45
44
|
var message_restful_model_collection_1 = __importDefault(require("./models/message-restful-model-collection"));
|
|
46
45
|
var delta_collection_1 = __importDefault(require("./models/delta-collection"));
|
|
46
|
+
var outbox_1 = __importDefault(require("./models/outbox"));
|
|
47
|
+
var job_status_restful_model_collection_1 = __importDefault(require("./models/job-status-restful-model-collection"));
|
|
47
48
|
var PACKAGE_JSON = require('../package.json');
|
|
48
49
|
var SDK_VERSION = PACKAGE_JSON.version;
|
|
49
|
-
var SUPPORTED_API_VERSION = '2.
|
|
50
|
+
var SUPPORTED_API_VERSION = '2.5';
|
|
51
|
+
var AuthMethod;
|
|
52
|
+
(function (AuthMethod) {
|
|
53
|
+
AuthMethod[AuthMethod["BASIC"] = 0] = "BASIC";
|
|
54
|
+
AuthMethod[AuthMethod["BEARER"] = 1] = "BEARER";
|
|
55
|
+
})(AuthMethod = exports.AuthMethod || (exports.AuthMethod = {}));
|
|
50
56
|
var NylasConnection = /** @class */ (function () {
|
|
51
57
|
function NylasConnection(accessToken, _a) {
|
|
52
58
|
var clientId = _a.clientId;
|
|
@@ -56,7 +62,7 @@ var NylasConnection = /** @class */ (function () {
|
|
|
56
62
|
this.drafts = new restful_model_collection_1.default(draft_1.default, this);
|
|
57
63
|
this.files = new restful_model_collection_1.default(file_1.default, this);
|
|
58
64
|
this.calendars = new calendar_restful_model_collection_1.default(this);
|
|
59
|
-
this.jobStatuses = new
|
|
65
|
+
this.jobStatuses = new job_status_restful_model_collection_1.default(this);
|
|
60
66
|
this.events = new restful_model_collection_1.default(event_1.default, this);
|
|
61
67
|
this.resources = new restful_model_collection_1.default(resource_1.default, this);
|
|
62
68
|
this.deltas = new delta_collection_1.default(this);
|
|
@@ -65,6 +71,7 @@ var NylasConnection = /** @class */ (function () {
|
|
|
65
71
|
this.account = new restful_model_instance_1.default(account_1.default, this);
|
|
66
72
|
this.component = new component_restful_model_collection_1.default(this);
|
|
67
73
|
this.scheduler = new scheduler_restful_model_collection_1.default(this);
|
|
74
|
+
this.outbox = new outbox_1.default(this);
|
|
68
75
|
this.neural = new neural_1.default(this);
|
|
69
76
|
this.accessToken = accessToken;
|
|
70
77
|
this.clientId = clientId;
|
|
@@ -107,8 +114,13 @@ var NylasConnection = /** @class */ (function () {
|
|
|
107
114
|
? config.clientSecret
|
|
108
115
|
: this.accessToken;
|
|
109
116
|
if (user) {
|
|
110
|
-
|
|
111
|
-
'
|
|
117
|
+
if (options.authMethod === AuthMethod.BEARER) {
|
|
118
|
+
headers['authorization'] = "Bearer " + user;
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
headers['authorization'] =
|
|
122
|
+
'Basic ' + Buffer.from(user + ":", 'utf8').toString('base64');
|
|
123
|
+
}
|
|
112
124
|
}
|
|
113
125
|
if (!headers['User-Agent']) {
|
|
114
126
|
headers['User-Agent'] = "Nylas Node SDK v" + SDK_VERSION;
|
|
@@ -181,7 +193,10 @@ var NylasConnection = /** @class */ (function () {
|
|
|
181
193
|
console.warn(warning);
|
|
182
194
|
}
|
|
183
195
|
if (response.status > 299) {
|
|
184
|
-
return response
|
|
196
|
+
return response
|
|
197
|
+
.clone()
|
|
198
|
+
.json()
|
|
199
|
+
.then(function (body) {
|
|
185
200
|
var error = new nylas_api_error_1.default(response.status, body.type, body.message);
|
|
186
201
|
if (body.missing_fields) {
|
|
187
202
|
error.missingFields = body.missing_fields;
|
|
@@ -190,6 +205,18 @@ var NylasConnection = /** @class */ (function () {
|
|
|
190
205
|
error.serverError = body.server_error;
|
|
191
206
|
}
|
|
192
207
|
return reject(error);
|
|
208
|
+
})
|
|
209
|
+
.catch(function () {
|
|
210
|
+
return response
|
|
211
|
+
.text()
|
|
212
|
+
.then(function (text) {
|
|
213
|
+
var error = new nylas_api_error_1.default(response.status, response.statusText, text);
|
|
214
|
+
return reject(error);
|
|
215
|
+
})
|
|
216
|
+
.catch(function () {
|
|
217
|
+
var error = new nylas_api_error_1.default(response.status, response.statusText, 'Error encountered during request, unable to extract error message.');
|
|
218
|
+
return reject(error);
|
|
219
|
+
});
|
|
193
220
|
});
|
|
194
221
|
}
|
|
195
222
|
else {
|
|
@@ -209,11 +236,20 @@ var NylasConnection = /** @class */ (function () {
|
|
|
209
236
|
return reject(e);
|
|
210
237
|
});
|
|
211
238
|
}
|
|
239
|
+
else if (response.headers.get('content-length') &&
|
|
240
|
+
Number(response.headers.get('content-length')) == 0) {
|
|
241
|
+
return resolve(undefined);
|
|
242
|
+
}
|
|
212
243
|
else if (response.headers.get('Content-Type') === 'message/rfc822') {
|
|
213
244
|
return resolve(response.text());
|
|
214
245
|
}
|
|
215
246
|
else {
|
|
216
|
-
return
|
|
247
|
+
return response
|
|
248
|
+
.clone()
|
|
249
|
+
.json()
|
|
250
|
+
.catch(function () { return response.text(); })
|
|
251
|
+
.then(function (data) { return resolve(data); })
|
|
252
|
+
.catch(function () { return resolve(undefined); });
|
|
217
253
|
}
|
|
218
254
|
}
|
|
219
255
|
})
|
package/lib/nylas.d.ts
CHANGED
|
@@ -23,5 +23,10 @@ declare class Nylas {
|
|
|
23
23
|
static application(options?: ApplicationDetailsProperties): Promise<ApplicationDetails>;
|
|
24
24
|
static exchangeCodeForToken(code: string, callback?: (error: Error | null, accessToken?: string) => void): Promise<AccessToken>;
|
|
25
25
|
static urlForAuthentication(options: AuthenticateUrlConfig): string;
|
|
26
|
+
/**
|
|
27
|
+
* Revoke a single access token
|
|
28
|
+
* @param accessToken The access token to revoke
|
|
29
|
+
*/
|
|
30
|
+
static revoke(accessToken: string): Promise<void>;
|
|
26
31
|
}
|
|
27
32
|
export = Nylas;
|
package/lib/nylas.js
CHANGED
|
@@ -163,8 +163,23 @@ var Nylas = /** @class */ (function () {
|
|
|
163
163
|
if (options.provider != null) {
|
|
164
164
|
url += "&provider=" + options.provider;
|
|
165
165
|
}
|
|
166
|
+
if (options.redirectOnError) {
|
|
167
|
+
url += '&redirect_on_error=true';
|
|
168
|
+
}
|
|
166
169
|
return url;
|
|
167
170
|
};
|
|
171
|
+
/**
|
|
172
|
+
* Revoke a single access token
|
|
173
|
+
* @param accessToken The access token to revoke
|
|
174
|
+
*/
|
|
175
|
+
Nylas.revoke = function (accessToken) {
|
|
176
|
+
return Nylas.with(accessToken)
|
|
177
|
+
.request({
|
|
178
|
+
method: 'POST',
|
|
179
|
+
path: '/oauth/revoke',
|
|
180
|
+
})
|
|
181
|
+
.catch(function (err) { return Promise.reject(err); });
|
|
182
|
+
};
|
|
168
183
|
Nylas.clientId = '';
|
|
169
184
|
return Nylas;
|
|
170
185
|
}());
|