nylas 6.10.0 → 7.0.0-beta.1
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/README.md +26 -14
- package/lib/cjs/apiClient.js +115 -0
- package/lib/cjs/config.js +32 -0
- package/lib/cjs/models/applicationDetails.js +2 -0
- package/lib/cjs/models/auth.js +2 -0
- package/lib/cjs/models/availability.js +11 -0
- package/lib/cjs/models/calendars.js +2 -0
- package/lib/cjs/models/error.js +53 -0
- package/lib/cjs/models/events.js +2 -0
- package/lib/cjs/models/grants.js +2 -0
- package/lib/cjs/models/listQueryParams.js +2 -0
- package/lib/cjs/models/redirectUri.js +2 -0
- package/lib/cjs/models/response.js +2 -0
- package/lib/cjs/models/webhooks.js +18 -0
- package/lib/cjs/nylas.js +34 -0
- package/lib/cjs/resources/applications.js +30 -0
- package/lib/cjs/resources/auth.js +153 -0
- package/lib/cjs/resources/calendars.js +78 -0
- package/lib/cjs/resources/events.js +69 -0
- package/lib/cjs/resources/grants.js +65 -0
- package/lib/cjs/resources/redirectUris.js +64 -0
- package/lib/cjs/resources/resource.js +111 -0
- package/lib/cjs/resources/webhooks.js +98 -0
- package/lib/cjs/utils.js +58 -0
- package/lib/esm/apiClient.js +112 -0
- package/lib/esm/config.js +29 -0
- package/lib/esm/models/applicationDetails.js +1 -0
- package/lib/esm/models/auth.js +1 -0
- package/lib/esm/models/availability.js +8 -0
- package/lib/esm/models/calendars.js +1 -0
- package/lib/esm/models/error.js +45 -0
- package/lib/esm/models/events.js +1 -0
- package/lib/esm/models/grants.js +1 -0
- package/lib/esm/models/listQueryParams.js +1 -0
- package/lib/esm/models/redirectUri.js +1 -0
- package/lib/esm/models/response.js +1 -0
- package/lib/esm/models/webhooks.js +15 -0
- package/lib/esm/nylas.js +31 -0
- package/lib/esm/resources/applications.js +26 -0
- package/lib/esm/resources/auth.js +149 -0
- package/lib/esm/resources/calendars.js +74 -0
- package/lib/esm/resources/events.js +65 -0
- package/lib/esm/resources/grants.js +61 -0
- package/lib/esm/resources/redirectUris.js +60 -0
- package/lib/esm/resources/resource.js +107 -0
- package/lib/esm/resources/webhooks.js +94 -0
- package/lib/esm/utils.js +53 -0
- package/lib/types/apiClient.d.ts +65 -0
- package/lib/types/config.d.ts +50 -0
- package/lib/types/models/applicationDetails.d.ts +93 -0
- package/lib/types/models/auth.d.ts +196 -0
- package/lib/types/models/availability.d.ts +159 -0
- package/lib/types/models/calendars.d.ts +121 -0
- package/lib/types/models/error.d.ts +104 -0
- package/lib/types/models/events.d.ts +494 -0
- package/lib/types/models/grants.d.ts +134 -0
- package/lib/types/models/listQueryParams.d.ts +4 -0
- package/lib/types/models/redirectUri.d.ts +71 -0
- package/lib/types/models/response.d.ts +40 -0
- package/lib/types/models/webhooks.d.ts +45 -0
- package/lib/types/nylas.d.ts +44 -0
- package/lib/types/resources/applications.d.ts +26 -0
- package/lib/types/resources/auth.d.ts +66 -0
- package/lib/types/resources/calendars.d.ts +97 -0
- package/lib/types/resources/events.d.ts +87 -0
- package/lib/types/resources/grants.d.ts +63 -0
- package/lib/types/resources/redirectUris.d.ts +63 -0
- package/lib/types/resources/resource.d.ts +55 -0
- package/lib/types/resources/webhooks.d.ts +79 -0
- package/lib/types/utils.d.ts +22 -0
- package/package.json +28 -39
- package/lib/config.d.ts +0 -52
- package/lib/config.js +0 -47
- package/lib/models/access-token.d.ts +0 -18
- package/lib/models/access-token.js +0 -56
- package/lib/models/account.d.ts +0 -27
- package/lib/models/account.js +0 -73
- package/lib/models/application-details.d.ts +0 -14
- package/lib/models/application-details.js +0 -47
- package/lib/models/attributes.d.ts +0 -151
- package/lib/models/attributes.js +0 -382
- package/lib/models/calendar-availability.d.ts +0 -76
- package/lib/models/calendar-availability.js +0 -121
- package/lib/models/calendar-restful-model-collection.d.ts +0 -17
- package/lib/models/calendar-restful-model-collection.js +0 -181
- package/lib/models/calendar.d.ts +0 -33
- package/lib/models/calendar.js +0 -97
- package/lib/models/component-restful-model-collection.d.ts +0 -9
- package/lib/models/component-restful-model-collection.js +0 -34
- package/lib/models/component.d.ts +0 -37
- package/lib/models/component.js +0 -91
- package/lib/models/connect.d.ts +0 -73
- package/lib/models/connect.js +0 -193
- package/lib/models/contact-restful-model-collection.d.ts +0 -9
- package/lib/models/contact-restful-model-collection.js +0 -60
- package/lib/models/contact.d.ts +0 -129
- package/lib/models/contact.js +0 -289
- package/lib/models/delta-collection.d.ts +0 -17
- package/lib/models/delta-collection.js +0 -139
- package/lib/models/delta-stream.d.ts +0 -32
- package/lib/models/delta-stream.js +0 -250
- package/lib/models/delta.d.ts +0 -28
- package/lib/models/delta.js +0 -88
- package/lib/models/deltas.d.ts +0 -17
- package/lib/models/deltas.js +0 -49
- package/lib/models/draft.d.ts +0 -27
- package/lib/models/draft.js +0 -156
- package/lib/models/email-participant.d.ts +0 -13
- package/lib/models/email-participant.js +0 -46
- package/lib/models/event-conferencing.d.ts +0 -34
- package/lib/models/event-conferencing.js +0 -71
- package/lib/models/event-notification.d.ts +0 -27
- package/lib/models/event-notification.js +0 -62
- package/lib/models/event-participant.d.ts +0 -19
- package/lib/models/event-participant.js +0 -56
- package/lib/models/event-reminder-method.d.ts +0 -18
- package/lib/models/event-reminder-method.js +0 -47
- package/lib/models/event.d.ts +0 -104
- package/lib/models/event.js +0 -308
- package/lib/models/file.d.ts +0 -29
- package/lib/models/file.js +0 -136
- package/lib/models/folder.d.ts +0 -21
- package/lib/models/folder.js +0 -69
- package/lib/models/free-busy.d.ts +0 -58
- package/lib/models/free-busy.js +0 -132
- package/lib/models/job-status-restful-model-collection.d.ts +0 -9
- package/lib/models/job-status-restful-model-collection.js +0 -38
- package/lib/models/job-status.d.ts +0 -24
- package/lib/models/job-status.js +0 -68
- package/lib/models/management-account.d.ts +0 -63
- package/lib/models/management-account.js +0 -187
- package/lib/models/management-model-collection.d.ts +0 -10
- package/lib/models/management-model-collection.js +0 -39
- package/lib/models/management-model.d.ts +0 -6
- package/lib/models/management-model.js +0 -29
- package/lib/models/message-restful-model-collection.d.ts +0 -26
- package/lib/models/message-restful-model-collection.js +0 -80
- package/lib/models/message.d.ts +0 -57
- package/lib/models/message.js +0 -173
- package/lib/models/model-collection.d.ts +0 -25
- package/lib/models/model-collection.js +0 -201
- package/lib/models/model.d.ts +0 -12
- package/lib/models/model.js +0 -64
- package/lib/models/neural-categorizer.d.ts +0 -28
- package/lib/models/neural-categorizer.js +0 -139
- package/lib/models/neural-clean-conversation.d.ts +0 -16
- package/lib/models/neural-clean-conversation.js +0 -114
- package/lib/models/neural-ocr.d.ts +0 -14
- package/lib/models/neural-ocr.js +0 -50
- package/lib/models/neural-sentiment-analysis.d.ts +0 -20
- package/lib/models/neural-sentiment-analysis.js +0 -56
- package/lib/models/neural-signature-contact.d.ts +0 -43
- package/lib/models/neural-signature-contact.js +0 -142
- package/lib/models/neural-signature-extraction.d.ts +0 -17
- package/lib/models/neural-signature-extraction.js +0 -54
- package/lib/models/neural.d.ts +0 -36
- package/lib/models/neural.js +0 -163
- package/lib/models/nylas-api-error.d.ts +0 -26
- package/lib/models/nylas-api-error.js +0 -62
- package/lib/models/outbox-job-status.d.ts +0 -20
- package/lib/models/outbox-job-status.js +0 -64
- package/lib/models/outbox-message.d.ts +0 -16
- package/lib/models/outbox-message.js +0 -54
- package/lib/models/outbox.d.ts +0 -35
- package/lib/models/outbox.js +0 -158
- package/lib/models/rate-limit-error.d.ts +0 -26
- package/lib/models/rate-limit-error.js +0 -47
- package/lib/models/resource.d.ts +0 -22
- package/lib/models/resource.js +0 -66
- package/lib/models/restful-model-collection.d.ts +0 -15
- package/lib/models/restful-model-collection.js +0 -169
- package/lib/models/restful-model-instance.d.ts +0 -9
- package/lib/models/restful-model-instance.js +0 -37
- package/lib/models/restful-model.d.ts +0 -36
- package/lib/models/restful-model.js +0 -146
- package/lib/models/scheduler-booking-request.d.ts +0 -64
- package/lib/models/scheduler-booking-request.js +0 -148
- package/lib/models/scheduler-restful-model-collection.d.ts +0 -26
- package/lib/models/scheduler-restful-model-collection.js +0 -133
- package/lib/models/scheduler-time-slot.d.ts +0 -20
- package/lib/models/scheduler-time-slot.js +0 -53
- package/lib/models/scheduler.d.ts +0 -226
- package/lib/models/scheduler.js +0 -446
- package/lib/models/thread.d.ts +0 -49
- package/lib/models/thread.js +0 -127
- package/lib/models/webhook-notification.d.ts +0 -133
- package/lib/models/webhook-notification.js +0 -314
- package/lib/models/webhook.d.ts +0 -50
- package/lib/models/webhook.js +0 -101
- package/lib/models/when.d.ts +0 -29
- package/lib/models/when.js +0 -76
- package/lib/nylas-connection.d.ts +0 -71
- package/lib/nylas-connection.js +0 -282
- package/lib/nylas.d.ts +0 -34
- package/lib/nylas.js +0 -199
- package/lib/services/tunnel.d.ts +0 -28
- package/lib/services/tunnel.js +0 -89
|
@@ -1,80 +0,0 @@
|
|
|
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 restful_model_collection_1 = __importDefault(require("./restful-model-collection"));
|
|
31
|
-
var message_1 = __importDefault(require("./message"));
|
|
32
|
-
var MessageRestfulModelCollection = /** @class */ (function (_super) {
|
|
33
|
-
__extends(MessageRestfulModelCollection, _super);
|
|
34
|
-
function MessageRestfulModelCollection(connection) {
|
|
35
|
-
var _this = _super.call(this, message_1.default, connection) || this;
|
|
36
|
-
_this.connection = connection;
|
|
37
|
-
_this.modelClass = message_1.default;
|
|
38
|
-
return _this;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Return Multiple Messages by a list of Message IDs.
|
|
42
|
-
* @param messageIds The list of message ids to find.
|
|
43
|
-
* @param options Additional options including: view, offset, limit, and callback
|
|
44
|
-
* @returns The list of messages.
|
|
45
|
-
*/
|
|
46
|
-
MessageRestfulModelCollection.prototype.findMultiple = function (messageIds, options) {
|
|
47
|
-
if (options && options.view) {
|
|
48
|
-
// view is a parameter, so move it into a params object
|
|
49
|
-
options.params = {
|
|
50
|
-
view: options.view,
|
|
51
|
-
};
|
|
52
|
-
delete options.view;
|
|
53
|
-
}
|
|
54
|
-
// If only one message ID was passed in, use the normal find function
|
|
55
|
-
if (messageIds.length == 1) {
|
|
56
|
-
return this.find(messageIds[0], options).then(function (message) {
|
|
57
|
-
return [message];
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
return this.range(__assign({ path: this.path() + "/" + messageIds.join() }, options));
|
|
61
|
-
};
|
|
62
|
-
/**
|
|
63
|
-
* Return raw message contents
|
|
64
|
-
* @param messageId The message to fetch content of
|
|
65
|
-
* @returns The raw message contents
|
|
66
|
-
*/
|
|
67
|
-
MessageRestfulModelCollection.prototype.findRaw = function (messageId) {
|
|
68
|
-
return this.connection
|
|
69
|
-
.request({
|
|
70
|
-
method: 'GET',
|
|
71
|
-
headers: {
|
|
72
|
-
Accept: 'message/rfc822',
|
|
73
|
-
},
|
|
74
|
-
path: this.path() + "/" + messageId,
|
|
75
|
-
})
|
|
76
|
-
.catch(function (err) { return Promise.reject(err); });
|
|
77
|
-
};
|
|
78
|
-
return MessageRestfulModelCollection;
|
|
79
|
-
}(restful_model_collection_1.default));
|
|
80
|
-
exports.default = MessageRestfulModelCollection;
|
package/lib/models/message.d.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import RestfulModel, { SaveCallback } from './restful-model';
|
|
2
|
-
import { Attribute } from './attributes';
|
|
3
|
-
import File, { FileProperties } from './file';
|
|
4
|
-
import Event, { EventProperties } from './event';
|
|
5
|
-
import EmailParticipant, { EmailParticipantProperties } from './email-participant';
|
|
6
|
-
import Folder, { Label, FolderProperties } from './folder';
|
|
7
|
-
import NylasConnection from '../nylas-connection';
|
|
8
|
-
export declare type MessageProperties = {
|
|
9
|
-
to: EmailParticipantProperties[];
|
|
10
|
-
subject?: string;
|
|
11
|
-
from?: EmailParticipantProperties[];
|
|
12
|
-
replyTo?: EmailParticipantProperties[];
|
|
13
|
-
cc?: EmailParticipantProperties[];
|
|
14
|
-
bcc?: EmailParticipantProperties[];
|
|
15
|
-
date?: Date;
|
|
16
|
-
threadId?: string;
|
|
17
|
-
snippet?: string;
|
|
18
|
-
body?: string;
|
|
19
|
-
unread?: boolean;
|
|
20
|
-
starred?: boolean;
|
|
21
|
-
files?: FileProperties[];
|
|
22
|
-
events?: EventProperties[];
|
|
23
|
-
folder?: Folder;
|
|
24
|
-
labels?: FolderProperties[];
|
|
25
|
-
headers?: Record<string, string>;
|
|
26
|
-
metadata?: object;
|
|
27
|
-
jobStatusId?: string;
|
|
28
|
-
};
|
|
29
|
-
export default class Message extends RestfulModel implements MessageProperties {
|
|
30
|
-
to: EmailParticipant[];
|
|
31
|
-
subject?: string;
|
|
32
|
-
from?: EmailParticipant[];
|
|
33
|
-
replyTo?: EmailParticipant[];
|
|
34
|
-
cc?: EmailParticipant[];
|
|
35
|
-
bcc?: EmailParticipant[];
|
|
36
|
-
date?: Date;
|
|
37
|
-
threadId?: string;
|
|
38
|
-
snippet?: string;
|
|
39
|
-
body?: string;
|
|
40
|
-
unread?: boolean;
|
|
41
|
-
starred?: boolean;
|
|
42
|
-
files?: File[];
|
|
43
|
-
events?: Event[];
|
|
44
|
-
folder?: Folder;
|
|
45
|
-
labels?: Label[];
|
|
46
|
-
headers?: Record<string, string>;
|
|
47
|
-
metadata?: object;
|
|
48
|
-
jobStatusId?: string;
|
|
49
|
-
static collectionName: string;
|
|
50
|
-
static attributes: Record<string, Attribute>;
|
|
51
|
-
constructor(connection: NylasConnection, props?: MessageProperties);
|
|
52
|
-
participants(): EmailParticipant[];
|
|
53
|
-
fileIds(): (string | undefined)[];
|
|
54
|
-
getRaw(): Promise<string>;
|
|
55
|
-
saveRequestBody(): Record<string, unknown>;
|
|
56
|
-
save(params?: {} | SaveCallback, callback?: SaveCallback): Promise<this>;
|
|
57
|
-
}
|
package/lib/models/message.js
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
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 __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
27
|
-
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
28
|
-
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
29
|
-
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
30
|
-
r[k] = a[j];
|
|
31
|
-
return r;
|
|
32
|
-
};
|
|
33
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
34
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
35
|
-
};
|
|
36
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
37
|
-
if (mod && mod.__esModule) return mod;
|
|
38
|
-
var result = {};
|
|
39
|
-
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
40
|
-
result["default"] = mod;
|
|
41
|
-
return result;
|
|
42
|
-
};
|
|
43
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44
|
-
var restful_model_1 = __importDefault(require("./restful-model"));
|
|
45
|
-
var attributes_1 = __importDefault(require("./attributes"));
|
|
46
|
-
var file_1 = __importDefault(require("./file"));
|
|
47
|
-
var event_1 = __importDefault(require("./event"));
|
|
48
|
-
var email_participant_1 = __importDefault(require("./email-participant"));
|
|
49
|
-
var folder_1 = __importStar(require("./folder"));
|
|
50
|
-
var Message = /** @class */ (function (_super) {
|
|
51
|
-
__extends(Message, _super);
|
|
52
|
-
function Message(connection, props) {
|
|
53
|
-
var _this = _super.call(this, connection, props) || this;
|
|
54
|
-
_this.to = [];
|
|
55
|
-
_this.initAttributes(props);
|
|
56
|
-
return _this;
|
|
57
|
-
}
|
|
58
|
-
// We calculate the list of participants instead of grabbing it from
|
|
59
|
-
// a parent because it is a better source of ground truth, and saves us
|
|
60
|
-
// from more dependencies.
|
|
61
|
-
Message.prototype.participants = function () {
|
|
62
|
-
var participants = {};
|
|
63
|
-
var to = this.to || [];
|
|
64
|
-
var cc = this.cc || [];
|
|
65
|
-
var from = this.from || [];
|
|
66
|
-
var contacts = Array.from(new Set(__spreadArrays(to, cc, from)));
|
|
67
|
-
for (var _i = 0, contacts_1 = contacts; _i < contacts_1.length; _i++) {
|
|
68
|
-
var contact = contacts_1[_i];
|
|
69
|
-
if (contact && (contact.email ? contact.email.length : '') > 0) {
|
|
70
|
-
participants[(contact.email || ''.toLowerCase().trim()) + " " + (contact.name || '')
|
|
71
|
-
.toLowerCase()
|
|
72
|
-
.trim()] = new email_participant_1.default(contact);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return Object.values(participants);
|
|
76
|
-
};
|
|
77
|
-
Message.prototype.fileIds = function () {
|
|
78
|
-
return this.files ? this.files.map(function (file) { return file.id; }) : [];
|
|
79
|
-
};
|
|
80
|
-
Message.prototype.getRaw = function () {
|
|
81
|
-
return this.connection
|
|
82
|
-
.request({
|
|
83
|
-
method: 'GET',
|
|
84
|
-
headers: {
|
|
85
|
-
Accept: 'message/rfc822',
|
|
86
|
-
},
|
|
87
|
-
path: "/" + Message.collectionName + "/" + this.id,
|
|
88
|
-
})
|
|
89
|
-
.catch(function (err) { return Promise.reject(err); });
|
|
90
|
-
};
|
|
91
|
-
Message.prototype.saveRequestBody = function () {
|
|
92
|
-
// It's possible to update most of the fields of a draft.
|
|
93
|
-
if (this.constructor.name === 'Draft') {
|
|
94
|
-
return _super.prototype.saveRequestBody.call(this);
|
|
95
|
-
}
|
|
96
|
-
// Messages are more limited, though.
|
|
97
|
-
var json = {};
|
|
98
|
-
if (this.labels) {
|
|
99
|
-
json['label_ids'] = Array.from(this.labels).map(function (label) { return label.id; });
|
|
100
|
-
}
|
|
101
|
-
else if (this.folder) {
|
|
102
|
-
json['folder_id'] = this.folder.id;
|
|
103
|
-
}
|
|
104
|
-
json['starred'] = this.starred;
|
|
105
|
-
json['unread'] = this.unread;
|
|
106
|
-
json['metadata'] = this.metadata;
|
|
107
|
-
return json;
|
|
108
|
-
};
|
|
109
|
-
Message.prototype.save = function (params, callback) {
|
|
110
|
-
if (params === void 0) { params = {}; }
|
|
111
|
-
// A Message can only be updated
|
|
112
|
-
if (this.constructor.name === 'Message' && !this.id) {
|
|
113
|
-
throw new Error('Cannot create a message. Please create and send a draft instead.');
|
|
114
|
-
}
|
|
115
|
-
return _super.prototype.save.call(this, params, callback);
|
|
116
|
-
};
|
|
117
|
-
Message.collectionName = 'messages';
|
|
118
|
-
Message.attributes = __assign(__assign({}, restful_model_1.default.attributes), { subject: attributes_1.default.String({
|
|
119
|
-
modelKey: 'subject',
|
|
120
|
-
}), from: attributes_1.default.Collection({
|
|
121
|
-
modelKey: 'from',
|
|
122
|
-
itemClass: email_participant_1.default,
|
|
123
|
-
}), replyTo: attributes_1.default.Collection({
|
|
124
|
-
modelKey: 'replyTo',
|
|
125
|
-
jsonKey: 'reply_to',
|
|
126
|
-
itemClass: email_participant_1.default,
|
|
127
|
-
}), to: attributes_1.default.Collection({
|
|
128
|
-
modelKey: 'to',
|
|
129
|
-
itemClass: email_participant_1.default,
|
|
130
|
-
}), cc: attributes_1.default.Collection({
|
|
131
|
-
modelKey: 'cc',
|
|
132
|
-
itemClass: email_participant_1.default,
|
|
133
|
-
}), bcc: attributes_1.default.Collection({
|
|
134
|
-
modelKey: 'bcc',
|
|
135
|
-
itemClass: email_participant_1.default,
|
|
136
|
-
}), date: attributes_1.default.DateTime({
|
|
137
|
-
modelKey: 'date',
|
|
138
|
-
}), threadId: attributes_1.default.String({
|
|
139
|
-
modelKey: 'threadId',
|
|
140
|
-
jsonKey: 'thread_id',
|
|
141
|
-
}), snippet: attributes_1.default.String({
|
|
142
|
-
modelKey: 'snippet',
|
|
143
|
-
}), body: attributes_1.default.String({
|
|
144
|
-
modelKey: 'body',
|
|
145
|
-
}), unread: attributes_1.default.Boolean({
|
|
146
|
-
modelKey: 'unread',
|
|
147
|
-
}), starred: attributes_1.default.Boolean({
|
|
148
|
-
modelKey: 'starred',
|
|
149
|
-
}), files: attributes_1.default.Collection({
|
|
150
|
-
modelKey: 'files',
|
|
151
|
-
itemClass: file_1.default,
|
|
152
|
-
readOnly: true,
|
|
153
|
-
}), events: attributes_1.default.Collection({
|
|
154
|
-
modelKey: 'events',
|
|
155
|
-
itemClass: event_1.default,
|
|
156
|
-
}), folder: attributes_1.default.Object({
|
|
157
|
-
modelKey: 'folder',
|
|
158
|
-
itemClass: folder_1.default,
|
|
159
|
-
}), labels: attributes_1.default.Collection({
|
|
160
|
-
modelKey: 'labels',
|
|
161
|
-
itemClass: folder_1.Label,
|
|
162
|
-
}), metadata: attributes_1.default.Object({
|
|
163
|
-
modelKey: 'metadata',
|
|
164
|
-
}), headers: attributes_1.default.Object({
|
|
165
|
-
modelKey: 'headers',
|
|
166
|
-
}), jobStatusId: attributes_1.default.String({
|
|
167
|
-
modelKey: 'jobStatusId',
|
|
168
|
-
jsonKey: 'job_status_id',
|
|
169
|
-
readOnly: true,
|
|
170
|
-
}) });
|
|
171
|
-
return Message;
|
|
172
|
-
}(restful_model_1.default));
|
|
173
|
-
exports.default = Message;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import NylasConnection from '../nylas-connection';
|
|
2
|
-
import Model from './model';
|
|
3
|
-
export declare type GetCallback = (error: Error | null, result?: Model) => void;
|
|
4
|
-
export default class ModelCollection<T extends Model> {
|
|
5
|
-
connection: NylasConnection;
|
|
6
|
-
modelClass: any;
|
|
7
|
-
_path: string;
|
|
8
|
-
baseUrl?: string;
|
|
9
|
-
constructor(modelClass: any, connection: NylasConnection, path: string);
|
|
10
|
-
forEach(params: Record<string, unknown> | undefined, eachCallback: (item: T) => void, completeCallback?: (err?: Error | null | undefined) => void): void;
|
|
11
|
-
list(params?: Record<string, unknown>, callback?: (error: Error | null, obj?: T[]) => void): Promise<T[]>;
|
|
12
|
-
find(id: string, paramsArg?: Record<string, unknown> | GetCallback | null, callbackArg?: GetCallback | Record<string, unknown> | null): Promise<T>;
|
|
13
|
-
path(): string;
|
|
14
|
-
protected range({ params, offset, limit, callback, path, }: {
|
|
15
|
-
params?: Record<string, unknown>;
|
|
16
|
-
offset?: number;
|
|
17
|
-
limit?: number;
|
|
18
|
-
callback?: (error: Error | null, results?: T[]) => void;
|
|
19
|
-
path?: string;
|
|
20
|
-
}): Promise<T[]>;
|
|
21
|
-
protected getItems(params: Record<string, unknown>, offset: number, limit: number, path?: string): Promise<T[]>;
|
|
22
|
-
protected createModel(json: Record<string, unknown>): T;
|
|
23
|
-
private getModel;
|
|
24
|
-
private getModelCollection;
|
|
25
|
-
}
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
var REQUEST_CHUNK_SIZE = 100;
|
|
15
|
-
var ModelCollection = /** @class */ (function () {
|
|
16
|
-
function ModelCollection(modelClass, connection, path) {
|
|
17
|
-
this.modelClass = modelClass;
|
|
18
|
-
this.connection = connection;
|
|
19
|
-
this._path = path;
|
|
20
|
-
if (!this.connection) {
|
|
21
|
-
throw new Error('Connection object not provided');
|
|
22
|
-
}
|
|
23
|
-
if (!this.modelClass) {
|
|
24
|
-
throw new Error('Model class not provided');
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
ModelCollection.prototype.forEach = function (params, eachCallback, completeCallback) {
|
|
28
|
-
var _this = this;
|
|
29
|
-
if (params === void 0) { params = {}; }
|
|
30
|
-
if (params.view == 'count') {
|
|
31
|
-
var err = new Error('forEach() cannot be called with the count view');
|
|
32
|
-
if (completeCallback) {
|
|
33
|
-
completeCallback(err);
|
|
34
|
-
}
|
|
35
|
-
throw err;
|
|
36
|
-
}
|
|
37
|
-
var offset = 0;
|
|
38
|
-
var iteratee = function () {
|
|
39
|
-
return _this.getItems(params, offset, REQUEST_CHUNK_SIZE).then(function (items) {
|
|
40
|
-
for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
|
|
41
|
-
var item = items_1[_i];
|
|
42
|
-
eachCallback(item);
|
|
43
|
-
}
|
|
44
|
-
offset += items.length;
|
|
45
|
-
var finished = items.length < REQUEST_CHUNK_SIZE;
|
|
46
|
-
if (!finished) {
|
|
47
|
-
return iteratee();
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
|
-
iteratee().then(function () {
|
|
52
|
-
if (completeCallback) {
|
|
53
|
-
completeCallback();
|
|
54
|
-
}
|
|
55
|
-
}, function (err) {
|
|
56
|
-
if (completeCallback) {
|
|
57
|
-
return completeCallback(err);
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
ModelCollection.prototype.list = function (params, callback) {
|
|
62
|
-
if (params === void 0) { params = {}; }
|
|
63
|
-
if (params.view == 'count') {
|
|
64
|
-
var err = new Error('list() cannot be called with the count view');
|
|
65
|
-
if (callback) {
|
|
66
|
-
callback(err);
|
|
67
|
-
}
|
|
68
|
-
return Promise.reject(err);
|
|
69
|
-
}
|
|
70
|
-
var limit = params.limit || Infinity;
|
|
71
|
-
var offset = params.offset;
|
|
72
|
-
return this.range({ params: params, offset: offset, limit: limit, callback: callback });
|
|
73
|
-
};
|
|
74
|
-
ModelCollection.prototype.find = function (id, paramsArg, callbackArg) {
|
|
75
|
-
// callback used to be the second argument, and params was the third
|
|
76
|
-
var callback;
|
|
77
|
-
if (typeof callbackArg === 'function') {
|
|
78
|
-
callback = callbackArg;
|
|
79
|
-
}
|
|
80
|
-
else if (typeof paramsArg === 'function') {
|
|
81
|
-
callback = paramsArg;
|
|
82
|
-
}
|
|
83
|
-
var params = {};
|
|
84
|
-
if (paramsArg && typeof paramsArg === 'object') {
|
|
85
|
-
params = paramsArg;
|
|
86
|
-
}
|
|
87
|
-
else if (callbackArg && typeof callbackArg === 'object') {
|
|
88
|
-
params = callbackArg;
|
|
89
|
-
}
|
|
90
|
-
if (!id) {
|
|
91
|
-
var err = new Error('find() must be called with an item id');
|
|
92
|
-
if (callback) {
|
|
93
|
-
callback(err);
|
|
94
|
-
}
|
|
95
|
-
return Promise.reject(err);
|
|
96
|
-
}
|
|
97
|
-
if (params.view == 'count' || params.view == 'ids') {
|
|
98
|
-
var err = new Error('find() cannot be called with the count or ids view');
|
|
99
|
-
if (callback) {
|
|
100
|
-
callback(err);
|
|
101
|
-
}
|
|
102
|
-
return Promise.reject(err);
|
|
103
|
-
}
|
|
104
|
-
return this.getModel(id, params)
|
|
105
|
-
.then(function (model) {
|
|
106
|
-
if (callback) {
|
|
107
|
-
callback(null, model);
|
|
108
|
-
}
|
|
109
|
-
return Promise.resolve(model);
|
|
110
|
-
})
|
|
111
|
-
.catch(function (err) {
|
|
112
|
-
if (callback) {
|
|
113
|
-
callback(err);
|
|
114
|
-
}
|
|
115
|
-
return Promise.reject(err);
|
|
116
|
-
});
|
|
117
|
-
};
|
|
118
|
-
ModelCollection.prototype.path = function () {
|
|
119
|
-
return this._path;
|
|
120
|
-
};
|
|
121
|
-
ModelCollection.prototype.range = function (_a) {
|
|
122
|
-
var _this = this;
|
|
123
|
-
var _b = _a.params, params = _b === void 0 ? {} : _b, _c = _a.offset, offset = _c === void 0 ? 0 : _c, _d = _a.limit, limit = _d === void 0 ? 100 : _d, callback = _a.callback, path = _a.path;
|
|
124
|
-
var accumulated = [];
|
|
125
|
-
var iteratee = function () {
|
|
126
|
-
var chunkOffset = offset + accumulated.length;
|
|
127
|
-
var chunkLimit = Math.min(REQUEST_CHUNK_SIZE, limit - accumulated.length);
|
|
128
|
-
return _this.getItems(params, chunkOffset, chunkLimit, path).then(function (items) {
|
|
129
|
-
accumulated = accumulated.concat(items);
|
|
130
|
-
var finished = items.length < REQUEST_CHUNK_SIZE || accumulated.length >= limit;
|
|
131
|
-
if (!finished) {
|
|
132
|
-
return iteratee();
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
};
|
|
136
|
-
// do not return rejected promise when callback is provided
|
|
137
|
-
// to prevent unhandled rejection warning
|
|
138
|
-
return iteratee().then(function () {
|
|
139
|
-
if (callback) {
|
|
140
|
-
callback(null, accumulated);
|
|
141
|
-
}
|
|
142
|
-
return accumulated;
|
|
143
|
-
}, function (err) {
|
|
144
|
-
if (callback) {
|
|
145
|
-
callback(err);
|
|
146
|
-
}
|
|
147
|
-
throw err;
|
|
148
|
-
});
|
|
149
|
-
};
|
|
150
|
-
ModelCollection.prototype.getItems = function (params, offset, limit, path) {
|
|
151
|
-
// Items can be either models or ids
|
|
152
|
-
if (!path) {
|
|
153
|
-
path = this.path();
|
|
154
|
-
}
|
|
155
|
-
if (params.view == 'ids') {
|
|
156
|
-
return this.connection.request({
|
|
157
|
-
method: 'GET',
|
|
158
|
-
path: path,
|
|
159
|
-
qs: __assign(__assign({}, params), { offset: offset, limit: limit }),
|
|
160
|
-
baseUrl: this.baseUrl,
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
return this.getModelCollection(params, offset, limit, path);
|
|
164
|
-
};
|
|
165
|
-
ModelCollection.prototype.createModel = function (json) {
|
|
166
|
-
return new this.modelClass().fromJSON(json);
|
|
167
|
-
};
|
|
168
|
-
ModelCollection.prototype.getModel = function (id, params) {
|
|
169
|
-
var _this = this;
|
|
170
|
-
if (params === void 0) { params = {}; }
|
|
171
|
-
return this.connection
|
|
172
|
-
.request({
|
|
173
|
-
method: 'GET',
|
|
174
|
-
path: this.path() + "/" + id,
|
|
175
|
-
qs: params,
|
|
176
|
-
baseUrl: this.baseUrl,
|
|
177
|
-
})
|
|
178
|
-
.then(function (json) {
|
|
179
|
-
var model = _this.createModel(json);
|
|
180
|
-
return Promise.resolve(model);
|
|
181
|
-
});
|
|
182
|
-
};
|
|
183
|
-
ModelCollection.prototype.getModelCollection = function (params, offset, limit, path) {
|
|
184
|
-
var _this = this;
|
|
185
|
-
return this.connection
|
|
186
|
-
.request({
|
|
187
|
-
method: 'GET',
|
|
188
|
-
path: path,
|
|
189
|
-
qs: __assign(__assign({}, params), { offset: offset, limit: limit }),
|
|
190
|
-
baseUrl: this.baseUrl,
|
|
191
|
-
})
|
|
192
|
-
.then(function (jsonArray) {
|
|
193
|
-
var models = jsonArray.map(function (json) {
|
|
194
|
-
return _this.createModel(json);
|
|
195
|
-
});
|
|
196
|
-
return Promise.resolve(models);
|
|
197
|
-
});
|
|
198
|
-
};
|
|
199
|
-
return ModelCollection;
|
|
200
|
-
}());
|
|
201
|
-
exports.default = ModelCollection;
|
package/lib/models/model.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Attribute } from './attributes';
|
|
2
|
-
export declare type SaveCallback = (error: Error | null, result?: any) => void;
|
|
3
|
-
export default class Model {
|
|
4
|
-
static attributes: Record<string, Attribute>;
|
|
5
|
-
static propsFromJSON(json: Record<string, unknown>, parent: unknown): Record<string, unknown>;
|
|
6
|
-
attributes(): Record<string, Attribute>;
|
|
7
|
-
initAttributes(props?: Record<string, unknown>): void;
|
|
8
|
-
fromJSON(json: Record<string, unknown>): this;
|
|
9
|
-
toJSON(enforceReadOnly?: boolean): Record<string, unknown>;
|
|
10
|
-
saveRequestBody(): Record<string, unknown>;
|
|
11
|
-
toString(): string;
|
|
12
|
-
}
|
package/lib/models/model.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var Model = /** @class */ (function () {
|
|
4
|
-
function Model() {
|
|
5
|
-
}
|
|
6
|
-
Model.propsFromJSON = function (json, parent) {
|
|
7
|
-
var props = {};
|
|
8
|
-
for (var attrName in this.attributes) {
|
|
9
|
-
var attr = this.attributes[attrName];
|
|
10
|
-
if (json[attr.jsonKey] !== undefined) {
|
|
11
|
-
props[attrName] = attr.fromJSON(json[attr.jsonKey], parent);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
return props;
|
|
15
|
-
};
|
|
16
|
-
Model.prototype.attributes = function () {
|
|
17
|
-
return this.constructor.attributes;
|
|
18
|
-
};
|
|
19
|
-
Model.prototype.initAttributes = function (props) {
|
|
20
|
-
var attributes = this.attributes();
|
|
21
|
-
for (var prop in props) {
|
|
22
|
-
if (props.hasOwnProperty(prop)) {
|
|
23
|
-
var attr = attributes[prop];
|
|
24
|
-
if (attr) {
|
|
25
|
-
this[prop] = attr.fromJSON(props[prop], this);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
Model.prototype.fromJSON = function (json) {
|
|
31
|
-
var attributes = this.attributes();
|
|
32
|
-
for (var attrName in attributes) {
|
|
33
|
-
var attr = attributes[attrName];
|
|
34
|
-
if (json[attr.jsonKey] !== undefined) {
|
|
35
|
-
this[attrName] = attr.fromJSON(json[attr.jsonKey], this);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return this;
|
|
39
|
-
};
|
|
40
|
-
Model.prototype.toJSON = function (enforceReadOnly) {
|
|
41
|
-
var json = {};
|
|
42
|
-
var attributes = this.attributes();
|
|
43
|
-
for (var attrName in attributes) {
|
|
44
|
-
var attr = attributes[attrName];
|
|
45
|
-
if (enforceReadOnly === true) {
|
|
46
|
-
json[attr.jsonKey] = attr.saveRequestBody(this[attrName]);
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
json[attr.jsonKey] = attr.toJSON(this[attrName]);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return json;
|
|
53
|
-
};
|
|
54
|
-
// saveRequestBody is used by save(). It returns a JSON dict containing only the
|
|
55
|
-
// fields the API allows updating. Subclasses should override this method.
|
|
56
|
-
Model.prototype.saveRequestBody = function () {
|
|
57
|
-
return this.toJSON(true);
|
|
58
|
-
};
|
|
59
|
-
Model.prototype.toString = function () {
|
|
60
|
-
return JSON.stringify(this.toJSON());
|
|
61
|
-
};
|
|
62
|
-
return Model;
|
|
63
|
-
}());
|
|
64
|
-
exports.default = Model;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Attribute } from './attributes';
|
|
2
|
-
import Message, { MessageProperties } from './message';
|
|
3
|
-
import Model from './model';
|
|
4
|
-
import NylasConnection from '../nylas-connection';
|
|
5
|
-
export declare type CategorizeProperties = {
|
|
6
|
-
category: string;
|
|
7
|
-
categorizedAt: Date;
|
|
8
|
-
modelVersion: string;
|
|
9
|
-
subcategories: string[];
|
|
10
|
-
};
|
|
11
|
-
export declare class Categorize extends Model implements CategorizeProperties {
|
|
12
|
-
category: string;
|
|
13
|
-
categorizedAt: Date;
|
|
14
|
-
modelVersion: string;
|
|
15
|
-
subcategories: string[];
|
|
16
|
-
static attributes: Record<string, Attribute>;
|
|
17
|
-
constructor(props?: CategorizeProperties);
|
|
18
|
-
}
|
|
19
|
-
export declare type NeuralCategorizerProperties = MessageProperties & {
|
|
20
|
-
categorizer: Categorize;
|
|
21
|
-
};
|
|
22
|
-
export default class NeuralCategorizer extends Message implements NeuralCategorizerProperties {
|
|
23
|
-
categorizer: Categorize;
|
|
24
|
-
static collectionName: string;
|
|
25
|
-
static attributes: Record<string, Attribute>;
|
|
26
|
-
constructor(connection: NylasConnection, props?: NeuralCategorizerProperties);
|
|
27
|
-
reCategorize(category: string): Promise<NeuralCategorizer>;
|
|
28
|
-
}
|