nylas 5.10.0 → 5.10.4
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/models/attributes.d.ts +5 -2
- package/lib/models/attributes.js +28 -4
- package/lib/models/calendar.js +1 -0
- package/lib/models/component.d.ts +2 -0
- package/lib/models/component.js +13 -0
- package/lib/models/contact.d.ts +1 -0
- package/lib/models/contact.js +4 -0
- package/lib/models/event-participant.js +1 -0
- package/lib/models/event.d.ts +1 -0
- package/lib/models/event.js +10 -0
- package/lib/models/folder.d.ts +1 -0
- package/lib/models/folder.js +4 -0
- package/lib/models/job-status.d.ts +3 -0
- package/lib/models/job-status.js +12 -0
- package/lib/models/message.d.ts +1 -0
- package/lib/models/message.js +4 -0
- package/lib/models/restful-model.js +5 -2
- package/lib/models/scheduler-booking-request.d.ts +1 -0
- package/lib/models/scheduler-booking-request.js +14 -0
- package/lib/models/scheduler.d.ts +2 -2
- package/lib/nylas.d.ts +1 -0
- package/lib/nylas.js +3 -0
- package/package.json +1 -1
|
@@ -10,6 +10,7 @@ export declare class Attribute {
|
|
|
10
10
|
});
|
|
11
11
|
toJSON(val: any): any;
|
|
12
12
|
fromJSON(val: any, _parent: any): any;
|
|
13
|
+
saveRequestBody(val: any): any;
|
|
13
14
|
}
|
|
14
15
|
declare class AttributeObject extends Attribute {
|
|
15
16
|
itemClass?: typeof RestfulModel;
|
|
@@ -19,8 +20,9 @@ declare class AttributeObject extends Attribute {
|
|
|
19
20
|
itemClass?: typeof RestfulModel;
|
|
20
21
|
readOnly?: boolean;
|
|
21
22
|
});
|
|
22
|
-
toJSON(val: any): any;
|
|
23
|
+
toJSON(val: any, saveRequestBody?: boolean): any;
|
|
23
24
|
fromJSON(val: any, _parent: any): any;
|
|
25
|
+
saveRequestBody(val: any): any;
|
|
24
26
|
}
|
|
25
27
|
declare class AttributeNumber extends Attribute {
|
|
26
28
|
toJSON(val: any): any;
|
|
@@ -54,8 +56,9 @@ declare class AttributeCollection extends Attribute {
|
|
|
54
56
|
itemClass: typeof RestfulModel;
|
|
55
57
|
readOnly?: boolean;
|
|
56
58
|
});
|
|
57
|
-
toJSON(vals: any): any[];
|
|
59
|
+
toJSON(vals: any, saveRequestBody?: boolean): any[];
|
|
58
60
|
fromJSON(json: any, _parent: any): RestfulModel[];
|
|
61
|
+
saveRequestBody(val: any): any[] | undefined;
|
|
59
62
|
}
|
|
60
63
|
declare const Attributes: {
|
|
61
64
|
Number(__0: {
|
package/lib/models/attributes.js
CHANGED
|
@@ -38,6 +38,12 @@ var Attribute = /** @class */ (function () {
|
|
|
38
38
|
Attribute.prototype.fromJSON = function (val, _parent) {
|
|
39
39
|
return val || null;
|
|
40
40
|
};
|
|
41
|
+
Attribute.prototype.saveRequestBody = function (val) {
|
|
42
|
+
if (this.readOnly) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
return this.toJSON(val);
|
|
46
|
+
};
|
|
41
47
|
return Attribute;
|
|
42
48
|
}());
|
|
43
49
|
exports.Attribute = Attribute;
|
|
@@ -49,11 +55,14 @@ var AttributeObject = /** @class */ (function (_super) {
|
|
|
49
55
|
_this.itemClass = itemClass;
|
|
50
56
|
return _this;
|
|
51
57
|
}
|
|
52
|
-
AttributeObject.prototype.toJSON = function (val) {
|
|
58
|
+
AttributeObject.prototype.toJSON = function (val, saveRequestBody) {
|
|
53
59
|
if (!val) {
|
|
54
60
|
return val;
|
|
55
61
|
}
|
|
56
|
-
if (val.
|
|
62
|
+
if (saveRequestBody === true && val.saveRequestBody != null) {
|
|
63
|
+
return val.saveRequestBody();
|
|
64
|
+
}
|
|
65
|
+
else if (val.toJSON != null) {
|
|
57
66
|
return val.toJSON();
|
|
58
67
|
}
|
|
59
68
|
return val;
|
|
@@ -64,6 +73,12 @@ var AttributeObject = /** @class */ (function (_super) {
|
|
|
64
73
|
}
|
|
65
74
|
return new this.itemClass(_parent.connection, val);
|
|
66
75
|
};
|
|
76
|
+
AttributeObject.prototype.saveRequestBody = function (val) {
|
|
77
|
+
if (this.readOnly) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
return this.toJSON(val, true);
|
|
81
|
+
};
|
|
67
82
|
return AttributeObject;
|
|
68
83
|
}(Attribute));
|
|
69
84
|
var AttributeNumber = /** @class */ (function (_super) {
|
|
@@ -175,14 +190,17 @@ var AttributeCollection = /** @class */ (function (_super) {
|
|
|
175
190
|
_this.itemClass = itemClass;
|
|
176
191
|
return _this;
|
|
177
192
|
}
|
|
178
|
-
AttributeCollection.prototype.toJSON = function (vals) {
|
|
193
|
+
AttributeCollection.prototype.toJSON = function (vals, saveRequestBody) {
|
|
179
194
|
if (!vals) {
|
|
180
195
|
return [];
|
|
181
196
|
}
|
|
182
197
|
var json = [];
|
|
183
198
|
for (var _i = 0, vals_1 = vals; _i < vals_1.length; _i++) {
|
|
184
199
|
var val = vals_1[_i];
|
|
185
|
-
if (val.
|
|
200
|
+
if (saveRequestBody === true && val.saveRequestBody != null) {
|
|
201
|
+
json.push(val.saveRequestBody());
|
|
202
|
+
}
|
|
203
|
+
else if (val.toJSON != null) {
|
|
186
204
|
json.push(val.toJSON());
|
|
187
205
|
}
|
|
188
206
|
else {
|
|
@@ -203,6 +221,12 @@ var AttributeCollection = /** @class */ (function (_super) {
|
|
|
203
221
|
}
|
|
204
222
|
return objs;
|
|
205
223
|
};
|
|
224
|
+
AttributeCollection.prototype.saveRequestBody = function (val) {
|
|
225
|
+
if (this.readOnly) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
return this.toJSON(val, true);
|
|
229
|
+
};
|
|
206
230
|
return AttributeCollection;
|
|
207
231
|
}(Attribute));
|
|
208
232
|
var Attributes = {
|
package/lib/models/calendar.js
CHANGED
|
@@ -79,6 +79,7 @@ Calendar.attributes = __assign(__assign({}, restful_model_1.default.attributes),
|
|
|
79
79
|
}), jobStatusId: attributes_1.default.String({
|
|
80
80
|
modelKey: 'jobStatusId',
|
|
81
81
|
jsonKey: 'job_status_id',
|
|
82
|
+
readOnly: true,
|
|
82
83
|
}), metadata: attributes_1.default.Object({
|
|
83
84
|
modelKey: 'metadata',
|
|
84
85
|
}) });
|
|
@@ -9,8 +9,10 @@ export default class Component extends RestfulModel {
|
|
|
9
9
|
publicAccountId?: string;
|
|
10
10
|
publicTokenId?: string;
|
|
11
11
|
publicApplicationId?: string;
|
|
12
|
+
accessToken?: string;
|
|
12
13
|
createdAt?: Date;
|
|
13
14
|
updatedAt?: Date;
|
|
14
15
|
saveEndpoint(): string;
|
|
15
16
|
save(params?: {} | SaveCallback, callback?: SaveCallback): Promise<this>;
|
|
17
|
+
saveRequestBody(): any;
|
|
16
18
|
}
|
package/lib/models/component.js
CHANGED
|
@@ -41,6 +41,16 @@ var Component = /** @class */ (function (_super) {
|
|
|
41
41
|
if (params === void 0) { params = {}; }
|
|
42
42
|
return this._save(params, callback);
|
|
43
43
|
};
|
|
44
|
+
Component.prototype.saveRequestBody = function () {
|
|
45
|
+
var json = _super.prototype.saveRequestBody.call(this);
|
|
46
|
+
if (this.id) {
|
|
47
|
+
// Cannot cannot send these values after creation
|
|
48
|
+
delete json.access_token;
|
|
49
|
+
delete json.public_application_id;
|
|
50
|
+
delete json.type;
|
|
51
|
+
}
|
|
52
|
+
return json;
|
|
53
|
+
};
|
|
44
54
|
return Component;
|
|
45
55
|
}(restful_model_1.default));
|
|
46
56
|
exports.default = Component;
|
|
@@ -67,6 +77,9 @@ Component.attributes = __assign(__assign({}, restful_model_1.default.attributes)
|
|
|
67
77
|
}), publicApplicationId: attributes_1.default.String({
|
|
68
78
|
modelKey: 'publicApplicationId',
|
|
69
79
|
jsonKey: 'public_application_id',
|
|
80
|
+
}), accessToken: attributes_1.default.String({
|
|
81
|
+
modelKey: 'accessToken',
|
|
82
|
+
jsonKey: 'access_token',
|
|
70
83
|
}), createdAt: attributes_1.default.Date({
|
|
71
84
|
modelKey: 'createdAt',
|
|
72
85
|
jsonKey: 'created_at',
|
package/lib/models/contact.d.ts
CHANGED
|
@@ -67,6 +67,7 @@ export declare class Contact extends RestfulModel {
|
|
|
67
67
|
webPages?: WebPage[];
|
|
68
68
|
groups?: Group[];
|
|
69
69
|
source?: string;
|
|
70
|
+
jobStatusId?: string;
|
|
70
71
|
save(params?: {} | SaveCallback, callback?: SaveCallback): Promise<this>;
|
|
71
72
|
getPicture(params?: {
|
|
72
73
|
[key: string]: any;
|
package/lib/models/contact.js
CHANGED
|
@@ -242,4 +242,8 @@ Contact.attributes = __assign(__assign({}, restful_model_1.default.attributes),
|
|
|
242
242
|
itemClass: Group,
|
|
243
243
|
}), source: attributes_1.default.String({
|
|
244
244
|
modelKey: 'source',
|
|
245
|
+
}), jobStatusId: attributes_1.default.String({
|
|
246
|
+
modelKey: 'jobStatusId',
|
|
247
|
+
jsonKey: 'job_status_id',
|
|
248
|
+
readOnly: true,
|
|
245
249
|
}) });
|
package/lib/models/event.d.ts
CHANGED
|
@@ -43,5 +43,6 @@ export default class Event extends RestfulModel {
|
|
|
43
43
|
[key: string]: any;
|
|
44
44
|
};
|
|
45
45
|
save(params?: {} | SaveCallback, callback?: SaveCallback): Promise<this>;
|
|
46
|
+
saveRequestBody(): any;
|
|
46
47
|
rsvp(status: string, comment: string, callback?: (error: Error | null, data?: Event) => void): Promise<this>;
|
|
47
48
|
}
|
package/lib/models/event.js
CHANGED
|
@@ -126,6 +126,16 @@ var Event = /** @class */ (function (_super) {
|
|
|
126
126
|
}
|
|
127
127
|
return this._save(params, callback);
|
|
128
128
|
};
|
|
129
|
+
Event.prototype.saveRequestBody = function () {
|
|
130
|
+
var json = _super.prototype.saveRequestBody.call(this);
|
|
131
|
+
if (json.when && json.when.object) {
|
|
132
|
+
delete json.when.object;
|
|
133
|
+
}
|
|
134
|
+
if (!this.notifications) {
|
|
135
|
+
delete json.notifications;
|
|
136
|
+
}
|
|
137
|
+
return json;
|
|
138
|
+
};
|
|
129
139
|
Event.prototype.rsvp = function (status, comment, callback) {
|
|
130
140
|
var _this = this;
|
|
131
141
|
return this.connection
|
package/lib/models/folder.d.ts
CHANGED
package/lib/models/folder.js
CHANGED
|
@@ -55,6 +55,10 @@ Folder.attributes = __assign(__assign({}, restful_model_1.default.attributes), {
|
|
|
55
55
|
}), displayName: attributes_1.default.String({
|
|
56
56
|
modelKey: 'displayName',
|
|
57
57
|
jsonKey: 'display_name',
|
|
58
|
+
}), jobStatusId: attributes_1.default.String({
|
|
59
|
+
modelKey: 'jobStatusId',
|
|
60
|
+
jsonKey: 'job_status_id',
|
|
61
|
+
readOnly: true,
|
|
58
62
|
}) });
|
|
59
63
|
var Label = /** @class */ (function (_super) {
|
|
60
64
|
__extends(Label, _super);
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import RestfulModel from './restful-model';
|
|
2
|
+
import Message from './message';
|
|
2
3
|
export default class JobStatus extends RestfulModel {
|
|
3
4
|
action?: string;
|
|
4
5
|
createdAt?: Date;
|
|
5
6
|
jobStatusId?: string;
|
|
6
7
|
status?: string;
|
|
8
|
+
originalData?: Message;
|
|
9
|
+
isSuccessful(): boolean;
|
|
7
10
|
}
|
package/lib/models/job-status.js
CHANGED
|
@@ -34,18 +34,30 @@ var JobStatus = /** @class */ (function (_super) {
|
|
|
34
34
|
function JobStatus() {
|
|
35
35
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
36
36
|
}
|
|
37
|
+
// Returns the status of a job as a boolean
|
|
38
|
+
JobStatus.prototype.isSuccessful = function () {
|
|
39
|
+
return this.status === 'successful';
|
|
40
|
+
};
|
|
37
41
|
return JobStatus;
|
|
38
42
|
}(restful_model_1.default));
|
|
39
43
|
exports.default = JobStatus;
|
|
40
44
|
JobStatus.collectionName = 'job-statuses';
|
|
41
45
|
JobStatus.attributes = __assign(__assign({}, restful_model_1.default.attributes), { action: attributes_1.default.String({
|
|
42
46
|
modelKey: 'action',
|
|
47
|
+
readOnly: true,
|
|
43
48
|
}), createdAt: attributes_1.default.DateTime({
|
|
44
49
|
modelKey: 'createdAt',
|
|
45
50
|
jsonKey: 'created_at',
|
|
51
|
+
readOnly: true,
|
|
46
52
|
}), jobStatusId: attributes_1.default.String({
|
|
47
53
|
modelKey: 'jobStatusId',
|
|
48
54
|
jsonKey: 'job_status_id',
|
|
55
|
+
readOnly: true,
|
|
49
56
|
}), status: attributes_1.default.String({
|
|
50
57
|
modelKey: 'status',
|
|
58
|
+
readOnly: true,
|
|
59
|
+
}), originalData: attributes_1.default.Object({
|
|
60
|
+
modelKey: 'originalData',
|
|
61
|
+
jsonKey: 'original_data',
|
|
62
|
+
readOnly: true,
|
|
51
63
|
}) });
|
package/lib/models/message.d.ts
CHANGED
package/lib/models/message.js
CHANGED
|
@@ -154,4 +154,8 @@ Message.attributes = __assign(__assign({}, restful_model_1.default.attributes),
|
|
|
154
154
|
modelKey: 'metadata',
|
|
155
155
|
}), headers: attributes_1.default.Object({
|
|
156
156
|
modelKey: 'headers',
|
|
157
|
+
}), jobStatusId: attributes_1.default.String({
|
|
158
|
+
modelKey: 'jobStatusId',
|
|
159
|
+
jsonKey: 'job_status_id',
|
|
160
|
+
readOnly: true,
|
|
157
161
|
}) });
|
|
@@ -37,8 +37,11 @@ var RestfulModel = /** @class */ (function () {
|
|
|
37
37
|
var json = {};
|
|
38
38
|
var attributes = this.attributes();
|
|
39
39
|
for (var attrName in attributes) {
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
var attr = attributes[attrName];
|
|
41
|
+
if (enforceReadOnly === true) {
|
|
42
|
+
json[attr.jsonKey] = attr.saveRequestBody(this[attrName]);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
42
45
|
json[attr.jsonKey] = attr.toJSON(this[attrName]);
|
|
43
46
|
}
|
|
44
47
|
}
|
|
@@ -93,6 +93,20 @@ var SchedulerBookingRequest = /** @class */ (function (_super) {
|
|
|
93
93
|
function SchedulerBookingRequest() {
|
|
94
94
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
95
95
|
}
|
|
96
|
+
/*
|
|
97
|
+
* The booking endpoint requires additional_values and additional_emails
|
|
98
|
+
to exist regardless if they are empty or not
|
|
99
|
+
*/
|
|
100
|
+
SchedulerBookingRequest.prototype.toJSON = function (enforceReadOnly) {
|
|
101
|
+
var json = _super.prototype.toJSON.call(this, enforceReadOnly);
|
|
102
|
+
if (!this.additionalEmails) {
|
|
103
|
+
json['additional_emails'] = [];
|
|
104
|
+
}
|
|
105
|
+
if (!this.additionalValues) {
|
|
106
|
+
json['additional_values'] = {};
|
|
107
|
+
}
|
|
108
|
+
return json;
|
|
109
|
+
};
|
|
96
110
|
return SchedulerBookingRequest;
|
|
97
111
|
}(restful_model_1.default));
|
|
98
112
|
exports.default = SchedulerBookingRequest;
|
|
@@ -54,7 +54,7 @@ export default class Scheduler extends RestfulModel {
|
|
|
54
54
|
name_field_hidden: boolean;
|
|
55
55
|
opening_hours: Array<{
|
|
56
56
|
account_id?: string;
|
|
57
|
-
days?: string;
|
|
57
|
+
days?: string[];
|
|
58
58
|
end?: string;
|
|
59
59
|
start?: string;
|
|
60
60
|
}>;
|
|
@@ -72,7 +72,7 @@ export default class Scheduler extends RestfulModel {
|
|
|
72
72
|
title?: string;
|
|
73
73
|
};
|
|
74
74
|
expire_after?: {
|
|
75
|
-
date?:
|
|
75
|
+
date?: Date;
|
|
76
76
|
uses?: number;
|
|
77
77
|
};
|
|
78
78
|
locale?: string;
|
package/lib/nylas.d.ts
CHANGED
package/lib/nylas.js
CHANGED
|
@@ -170,6 +170,9 @@ var Nylas = /** @class */ (function () {
|
|
|
170
170
|
if (options.scopes != null) {
|
|
171
171
|
url += "&scopes=" + options.scopes.join(',');
|
|
172
172
|
}
|
|
173
|
+
if (options.provider != null) {
|
|
174
|
+
url += "&provider=" + options.provider;
|
|
175
|
+
}
|
|
173
176
|
return url;
|
|
174
177
|
};
|
|
175
178
|
Nylas.clientId = '';
|