nylas 7.0.0-beta.0 → 7.0.0-beta.2
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 +27 -19
- package/lib/cjs/apiClient.js +114 -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/package.json +3 -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/cjs/version.js +5 -0
- package/lib/esm/apiClient.js +111 -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/package.json +3 -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/esm/version.js +2 -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/lib/types/version.d.ts +1 -0
- package/package.json +33 -42
- package/lib/config.d.ts +0 -70
- package/lib/config.js +0 -68
- 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 -31
- package/lib/models/calendar.js +0 -93
- 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.d.ts +0 -96
- package/lib/models/event.js +0 -297
- 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 -61
- 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/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 -108
- package/lib/models/webhook-notification.js +0 -239
- package/lib/models/webhook.d.ts +0 -50
- package/lib/models/webhook.js +0 -101
- package/lib/models/when.d.ts +0 -23
- package/lib/models/when.js +0 -65
- package/lib/nylas-connection.d.ts +0 -71
- package/lib/nylas-connection.js +0 -258
- package/lib/nylas.d.ts +0 -57
- package/lib/nylas.js +0 -210
- package/lib/server-bindings/express-binding.d.ts +0 -18
- package/lib/server-bindings/express-binding.js +0 -163
- package/lib/server-bindings/server-binding.d.ts +0 -65
- package/lib/server-bindings/server-binding.js +0 -87
- package/lib/services/routes.d.ts +0 -26
- package/lib/services/routes.js +0 -95
- package/lib/services/tunnel.d.ts +0 -29
- package/lib/services/tunnel.js +0 -112
package/lib/models/when.d.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import Model from './model';
|
|
2
|
-
import { Attribute } from './attributes';
|
|
3
|
-
export declare type WhenProperties = {
|
|
4
|
-
startTime?: number;
|
|
5
|
-
endTime?: number;
|
|
6
|
-
time?: number;
|
|
7
|
-
startDate?: string;
|
|
8
|
-
endDate?: string;
|
|
9
|
-
date?: string;
|
|
10
|
-
object?: string;
|
|
11
|
-
};
|
|
12
|
-
export default class When extends Model implements WhenProperties {
|
|
13
|
-
startTime?: number;
|
|
14
|
-
endTime?: number;
|
|
15
|
-
time?: number;
|
|
16
|
-
startDate?: string;
|
|
17
|
-
endDate?: string;
|
|
18
|
-
date?: string;
|
|
19
|
-
object?: string;
|
|
20
|
-
static attributes: Record<string, Attribute>;
|
|
21
|
-
constructor(props?: WhenProperties);
|
|
22
|
-
isSet(): boolean;
|
|
23
|
-
}
|
package/lib/models/when.js
DELETED
|
@@ -1,65 +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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
16
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
17
|
-
};
|
|
18
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
var model_1 = __importDefault(require("./model"));
|
|
20
|
-
var attributes_1 = __importDefault(require("./attributes"));
|
|
21
|
-
var When = /** @class */ (function (_super) {
|
|
22
|
-
__extends(When, _super);
|
|
23
|
-
function When(props) {
|
|
24
|
-
var _this = _super.call(this) || this;
|
|
25
|
-
_this.initAttributes(props);
|
|
26
|
-
return _this;
|
|
27
|
-
}
|
|
28
|
-
// Helper method to check if the When object is actually set properly or not
|
|
29
|
-
When.prototype.isSet = function () {
|
|
30
|
-
return ((this.startTime != undefined && this.endTime != undefined) ||
|
|
31
|
-
this.time != undefined ||
|
|
32
|
-
(this.startDate != undefined && this.endDate != undefined) ||
|
|
33
|
-
this.date != undefined);
|
|
34
|
-
};
|
|
35
|
-
When.attributes = {
|
|
36
|
-
startTime: attributes_1.default.Number({
|
|
37
|
-
modelKey: 'startTime',
|
|
38
|
-
jsonKey: 'start_time',
|
|
39
|
-
}),
|
|
40
|
-
endTime: attributes_1.default.Number({
|
|
41
|
-
modelKey: 'endTime',
|
|
42
|
-
jsonKey: 'end_time',
|
|
43
|
-
}),
|
|
44
|
-
time: attributes_1.default.Number({
|
|
45
|
-
modelKey: 'time',
|
|
46
|
-
}),
|
|
47
|
-
startDate: attributes_1.default.String({
|
|
48
|
-
modelKey: 'startDate',
|
|
49
|
-
jsonKey: 'start_date',
|
|
50
|
-
}),
|
|
51
|
-
endDate: attributes_1.default.String({
|
|
52
|
-
modelKey: 'endDate',
|
|
53
|
-
jsonKey: 'end_date',
|
|
54
|
-
}),
|
|
55
|
-
date: attributes_1.default.String({
|
|
56
|
-
modelKey: 'date',
|
|
57
|
-
}),
|
|
58
|
-
object: attributes_1.default.String({
|
|
59
|
-
modelKey: 'object',
|
|
60
|
-
readOnly: true,
|
|
61
|
-
}),
|
|
62
|
-
};
|
|
63
|
-
return When;
|
|
64
|
-
}(model_1.default));
|
|
65
|
-
exports.default = When;
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { URL } from 'url';
|
|
3
|
-
import { Request } from 'node-fetch';
|
|
4
|
-
import RestfulModelCollection from './models/restful-model-collection';
|
|
5
|
-
import CalendarRestfulModelCollection from './models/calendar-restful-model-collection';
|
|
6
|
-
import ContactRestfulModelCollection from './models/contact-restful-model-collection';
|
|
7
|
-
import RestfulModelInstance from './models/restful-model-instance';
|
|
8
|
-
import Account from './models/account';
|
|
9
|
-
import Thread from './models/thread';
|
|
10
|
-
import Draft from './models/draft';
|
|
11
|
-
import File from './models/file';
|
|
12
|
-
import Event from './models/event';
|
|
13
|
-
import Resource from './models/resource';
|
|
14
|
-
import Folder, { Label } from './models/folder';
|
|
15
|
-
import { AppendOptions } from 'form-data';
|
|
16
|
-
import Neural from './models/neural';
|
|
17
|
-
import ComponentRestfulModelCollection from './models/component-restful-model-collection';
|
|
18
|
-
import SchedulerRestfulModelCollection from './models/scheduler-restful-model-collection';
|
|
19
|
-
import MessageRestfulModelCollection from './models/message-restful-model-collection';
|
|
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
|
-
}
|
|
27
|
-
export declare type RequestOptions = {
|
|
28
|
-
path: string;
|
|
29
|
-
method?: string;
|
|
30
|
-
headers?: Record<string, string>;
|
|
31
|
-
qs?: Record<string, unknown>;
|
|
32
|
-
downloadRequest?: boolean;
|
|
33
|
-
json?: boolean;
|
|
34
|
-
formData?: Record<string, FormDataType>;
|
|
35
|
-
body?: any;
|
|
36
|
-
baseUrl?: string;
|
|
37
|
-
url?: URL;
|
|
38
|
-
authMethod?: AuthMethod;
|
|
39
|
-
};
|
|
40
|
-
export declare type FormDataType = {
|
|
41
|
-
value: unknown;
|
|
42
|
-
options?: Record<string, unknown> | AppendOptions;
|
|
43
|
-
};
|
|
44
|
-
export default class NylasConnection {
|
|
45
|
-
accessToken: string | null | undefined;
|
|
46
|
-
clientId: string | null | undefined;
|
|
47
|
-
threads: RestfulModelCollection<Thread>;
|
|
48
|
-
contacts: ContactRestfulModelCollection;
|
|
49
|
-
messages: MessageRestfulModelCollection;
|
|
50
|
-
drafts: RestfulModelCollection<Draft>;
|
|
51
|
-
files: RestfulModelCollection<File>;
|
|
52
|
-
calendars: CalendarRestfulModelCollection;
|
|
53
|
-
jobStatuses: JobStatusRestfulModelCollection;
|
|
54
|
-
events: RestfulModelCollection<Event>;
|
|
55
|
-
resources: RestfulModelCollection<Resource>;
|
|
56
|
-
deltas: DeltaCollection;
|
|
57
|
-
labels: RestfulModelCollection<Label>;
|
|
58
|
-
folders: RestfulModelCollection<Folder>;
|
|
59
|
-
account: RestfulModelInstance<Account>;
|
|
60
|
-
component: ComponentRestfulModelCollection;
|
|
61
|
-
scheduler: SchedulerRestfulModelCollection;
|
|
62
|
-
outbox: Outbox;
|
|
63
|
-
neural: Neural;
|
|
64
|
-
constructor(accessToken: string | null | undefined, { clientId }: {
|
|
65
|
-
clientId: string | null | undefined;
|
|
66
|
-
});
|
|
67
|
-
requestOptions(options: RequestOptions): RequestOptions;
|
|
68
|
-
newRequest(options: RequestOptions): Request;
|
|
69
|
-
private getWarningForVersion;
|
|
70
|
-
request(options: RequestOptions): Promise<any>;
|
|
71
|
-
}
|
package/lib/nylas-connection.js
DELETED
|
@@ -1,258 +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
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
14
|
-
if (mod && mod.__esModule) return mod;
|
|
15
|
-
var result = {};
|
|
16
|
-
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
17
|
-
result["default"] = mod;
|
|
18
|
-
return result;
|
|
19
|
-
};
|
|
20
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
21
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
22
|
-
};
|
|
23
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
-
// TODO since node 10 URL is global
|
|
25
|
-
var url_1 = require("url");
|
|
26
|
-
var node_fetch_1 = __importStar(require("node-fetch"));
|
|
27
|
-
var config = __importStar(require("./config"));
|
|
28
|
-
var restful_model_collection_1 = __importDefault(require("./models/restful-model-collection"));
|
|
29
|
-
var calendar_restful_model_collection_1 = __importDefault(require("./models/calendar-restful-model-collection"));
|
|
30
|
-
var contact_restful_model_collection_1 = __importDefault(require("./models/contact-restful-model-collection"));
|
|
31
|
-
var restful_model_instance_1 = __importDefault(require("./models/restful-model-instance"));
|
|
32
|
-
var account_1 = __importDefault(require("./models/account"));
|
|
33
|
-
var thread_1 = __importDefault(require("./models/thread"));
|
|
34
|
-
var draft_1 = __importDefault(require("./models/draft"));
|
|
35
|
-
var file_1 = __importDefault(require("./models/file"));
|
|
36
|
-
var event_1 = __importDefault(require("./models/event"));
|
|
37
|
-
var resource_1 = __importDefault(require("./models/resource"));
|
|
38
|
-
var folder_1 = __importStar(require("./models/folder"));
|
|
39
|
-
var form_data_1 = __importDefault(require("form-data"));
|
|
40
|
-
var neural_1 = __importDefault(require("./models/neural"));
|
|
41
|
-
var nylas_api_error_1 = __importDefault(require("./models/nylas-api-error"));
|
|
42
|
-
var component_restful_model_collection_1 = __importDefault(require("./models/component-restful-model-collection"));
|
|
43
|
-
var scheduler_restful_model_collection_1 = __importDefault(require("./models/scheduler-restful-model-collection"));
|
|
44
|
-
var message_restful_model_collection_1 = __importDefault(require("./models/message-restful-model-collection"));
|
|
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"));
|
|
48
|
-
var PACKAGE_JSON = require('../package.json');
|
|
49
|
-
var SDK_VERSION = PACKAGE_JSON.version;
|
|
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 = {}));
|
|
56
|
-
var NylasConnection = /** @class */ (function () {
|
|
57
|
-
function NylasConnection(accessToken, _a) {
|
|
58
|
-
var clientId = _a.clientId;
|
|
59
|
-
this.threads = new restful_model_collection_1.default(thread_1.default, this);
|
|
60
|
-
this.contacts = new contact_restful_model_collection_1.default(this);
|
|
61
|
-
this.messages = new message_restful_model_collection_1.default(this);
|
|
62
|
-
this.drafts = new restful_model_collection_1.default(draft_1.default, this);
|
|
63
|
-
this.files = new restful_model_collection_1.default(file_1.default, this);
|
|
64
|
-
this.calendars = new calendar_restful_model_collection_1.default(this);
|
|
65
|
-
this.jobStatuses = new job_status_restful_model_collection_1.default(this);
|
|
66
|
-
this.events = new restful_model_collection_1.default(event_1.default, this);
|
|
67
|
-
this.resources = new restful_model_collection_1.default(resource_1.default, this);
|
|
68
|
-
this.deltas = new delta_collection_1.default(this);
|
|
69
|
-
this.labels = new restful_model_collection_1.default(folder_1.Label, this);
|
|
70
|
-
this.folders = new restful_model_collection_1.default(folder_1.default, this);
|
|
71
|
-
this.account = new restful_model_instance_1.default(account_1.default, this);
|
|
72
|
-
this.component = new component_restful_model_collection_1.default(this);
|
|
73
|
-
this.scheduler = new scheduler_restful_model_collection_1.default(this);
|
|
74
|
-
this.outbox = new outbox_1.default(this);
|
|
75
|
-
this.neural = new neural_1.default(this);
|
|
76
|
-
this.accessToken = accessToken;
|
|
77
|
-
this.clientId = clientId;
|
|
78
|
-
}
|
|
79
|
-
NylasConnection.prototype.requestOptions = function (options) {
|
|
80
|
-
var baseUrl = options.baseUrl ? options.baseUrl : config.apiServer;
|
|
81
|
-
var url = new url_1.URL("" + baseUrl + options.path);
|
|
82
|
-
// map querystring to search params
|
|
83
|
-
if (options.qs) {
|
|
84
|
-
for (var _i = 0, _a = Object.entries(options.qs); _i < _a.length; _i++) {
|
|
85
|
-
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
86
|
-
// For convenience, If `expanded` param is provided, convert to view:
|
|
87
|
-
// 'expanded' api option
|
|
88
|
-
if (key === 'expanded') {
|
|
89
|
-
if (value === true) {
|
|
90
|
-
url.searchParams.set('view', 'expanded');
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
else if (key == 'metadata_pair') {
|
|
94
|
-
// The API understands a metadata_pair filter in the form of:
|
|
95
|
-
// <key>:<value>
|
|
96
|
-
for (var item in value) {
|
|
97
|
-
url.searchParams.set('metadata_pair', item + ":" + value[item]);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
else if (Array.isArray(value)) {
|
|
101
|
-
for (var _c = 0, value_1 = value; _c < value_1.length; _c++) {
|
|
102
|
-
var item = value_1[_c];
|
|
103
|
-
url.searchParams.append(key, item);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
url.searchParams.set(key, value);
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
options.url = url;
|
|
112
|
-
var headers = __assign({}, options.headers);
|
|
113
|
-
var user = options.path.substr(0, 3) === '/a/' || options.path.includes('/component')
|
|
114
|
-
? config.clientSecret
|
|
115
|
-
: this.accessToken;
|
|
116
|
-
if (user) {
|
|
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
|
-
}
|
|
124
|
-
}
|
|
125
|
-
if (!headers['User-Agent']) {
|
|
126
|
-
headers['User-Agent'] = "Nylas Node SDK v" + SDK_VERSION;
|
|
127
|
-
}
|
|
128
|
-
headers['Nylas-API-Version'] = SUPPORTED_API_VERSION;
|
|
129
|
-
headers['Nylas-SDK-API-Version'] = SUPPORTED_API_VERSION;
|
|
130
|
-
if (this.clientId != null) {
|
|
131
|
-
headers['X-Nylas-Client-Id'] = this.clientId;
|
|
132
|
-
}
|
|
133
|
-
options.headers = headers;
|
|
134
|
-
if (options.formData) {
|
|
135
|
-
var fd = new form_data_1.default();
|
|
136
|
-
for (var _d = 0, _e = Object.entries(options.formData); _d < _e.length; _d++) {
|
|
137
|
-
var _f = _e[_d], key = _f[0], obj = _f[1];
|
|
138
|
-
if (obj.options) {
|
|
139
|
-
fd.append(key, obj.value, obj.options);
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
fd.append(key, obj.value);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
options.body = fd;
|
|
146
|
-
}
|
|
147
|
-
else if (options.body && options.json !== false) {
|
|
148
|
-
options.body = JSON.stringify(options.body);
|
|
149
|
-
}
|
|
150
|
-
return options;
|
|
151
|
-
};
|
|
152
|
-
NylasConnection.prototype.newRequest = function (options) {
|
|
153
|
-
var newOptions = this.requestOptions(options);
|
|
154
|
-
return new node_fetch_1.Request(newOptions.url || '', {
|
|
155
|
-
method: newOptions.method || 'GET',
|
|
156
|
-
headers: newOptions.headers,
|
|
157
|
-
body: newOptions.body,
|
|
158
|
-
});
|
|
159
|
-
};
|
|
160
|
-
NylasConnection.prototype.getWarningForVersion = function (sdkApiVersion, apiVersion) {
|
|
161
|
-
var warning = '';
|
|
162
|
-
if (sdkApiVersion != apiVersion) {
|
|
163
|
-
if (sdkApiVersion && apiVersion) {
|
|
164
|
-
warning +=
|
|
165
|
-
"WARNING: SDK version may not support your Nylas API version." +
|
|
166
|
-
(" SDK supports version " + sdkApiVersion + " of the API and your application") +
|
|
167
|
-
(" is currently running on version " + apiVersion + " of the API.");
|
|
168
|
-
var apiNum = parseInt(apiVersion.split('-')[0]);
|
|
169
|
-
var sdkNum = parseInt(sdkApiVersion.split('-')[0]);
|
|
170
|
-
if (sdkNum > apiNum) {
|
|
171
|
-
warning += " Please update the version of the API that your application is using through the developer dashboard.";
|
|
172
|
-
}
|
|
173
|
-
else if (apiNum > sdkNum) {
|
|
174
|
-
warning += " Please update the sdk to ensure it works properly.";
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
return warning;
|
|
179
|
-
};
|
|
180
|
-
NylasConnection.prototype.request = function (options) {
|
|
181
|
-
var _this = this;
|
|
182
|
-
var req = this.newRequest(options);
|
|
183
|
-
return new Promise(function (resolve, reject) {
|
|
184
|
-
return node_fetch_1.default(req)
|
|
185
|
-
.then(function (response) {
|
|
186
|
-
if (typeof response === 'undefined') {
|
|
187
|
-
return reject(new Error('No response'));
|
|
188
|
-
}
|
|
189
|
-
// node headers are lowercaser so this refers to `Nylas-Api-Version`
|
|
190
|
-
var apiVersion = response.headers.get('nylas-api-version');
|
|
191
|
-
var warning = _this.getWarningForVersion(SUPPORTED_API_VERSION, apiVersion);
|
|
192
|
-
if (warning) {
|
|
193
|
-
console.warn(warning);
|
|
194
|
-
}
|
|
195
|
-
if (response.status > 299) {
|
|
196
|
-
return response.text().then(function (body) {
|
|
197
|
-
try {
|
|
198
|
-
var parsedApiError = JSON.parse(body);
|
|
199
|
-
var error = new nylas_api_error_1.default(response.status, parsedApiError.type, parsedApiError.message);
|
|
200
|
-
if (parsedApiError.missing_fields) {
|
|
201
|
-
error.missingFields = parsedApiError.missing_fields;
|
|
202
|
-
}
|
|
203
|
-
if (parsedApiError.server_error) {
|
|
204
|
-
error.serverError = parsedApiError.server_error;
|
|
205
|
-
}
|
|
206
|
-
return reject(error);
|
|
207
|
-
}
|
|
208
|
-
catch (e) {
|
|
209
|
-
var error = new nylas_api_error_1.default(response.status, response.statusText, body);
|
|
210
|
-
return reject(error);
|
|
211
|
-
}
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
else {
|
|
215
|
-
if (options.downloadRequest) {
|
|
216
|
-
response
|
|
217
|
-
.buffer()
|
|
218
|
-
.then(function (buffer) {
|
|
219
|
-
// Return an object with the headers and the body as a buffer
|
|
220
|
-
var fileDetails = {};
|
|
221
|
-
response.headers.forEach(function (v, k) {
|
|
222
|
-
fileDetails[k] = v;
|
|
223
|
-
});
|
|
224
|
-
fileDetails['body'] = buffer;
|
|
225
|
-
return resolve(fileDetails);
|
|
226
|
-
})
|
|
227
|
-
.catch(function (e) {
|
|
228
|
-
return reject(e);
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
else if (response.headers.get('content-length') &&
|
|
232
|
-
Number(response.headers.get('content-length')) == 0) {
|
|
233
|
-
return resolve(undefined);
|
|
234
|
-
}
|
|
235
|
-
else if (response.headers.get('Content-Type') === 'message/rfc822') {
|
|
236
|
-
return resolve(response.text());
|
|
237
|
-
}
|
|
238
|
-
else {
|
|
239
|
-
return response.text().then(function (text) {
|
|
240
|
-
try {
|
|
241
|
-
return resolve(JSON.parse(text));
|
|
242
|
-
}
|
|
243
|
-
catch (e) {
|
|
244
|
-
return resolve(text);
|
|
245
|
-
}
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
})
|
|
250
|
-
.catch(function (err) {
|
|
251
|
-
console.error("Error encountered during request:\n" + err.stack);
|
|
252
|
-
return reject(err);
|
|
253
|
-
});
|
|
254
|
-
});
|
|
255
|
-
};
|
|
256
|
-
return NylasConnection;
|
|
257
|
-
}());
|
|
258
|
-
exports.default = NylasConnection;
|
package/lib/nylas.d.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import NylasConnection from './nylas-connection';
|
|
2
|
-
import ManagementAccount from './models/management-account';
|
|
3
|
-
import Account from './models/account';
|
|
4
|
-
import Connect from './models/connect';
|
|
5
|
-
import RestfulModelCollection from './models/restful-model-collection';
|
|
6
|
-
import ManagementModelCollection from './models/management-model-collection';
|
|
7
|
-
import Webhook from './models/webhook';
|
|
8
|
-
import { AuthenticateUrlConfig, ExchangeCodeForTokenCallback, NylasConfig } from './config';
|
|
9
|
-
import AccessToken from './models/access-token';
|
|
10
|
-
import ApplicationDetails, { ApplicationDetailsProperties } from './models/application-details';
|
|
11
|
-
declare class Nylas {
|
|
12
|
-
clientId: string;
|
|
13
|
-
get clientSecret(): string;
|
|
14
|
-
set clientSecret(newClientSecret: string);
|
|
15
|
-
get apiServer(): string | null;
|
|
16
|
-
set apiServer(newApiServer: string | null);
|
|
17
|
-
accounts: ManagementModelCollection<ManagementAccount> | RestfulModelCollection<Account>;
|
|
18
|
-
connect: Connect;
|
|
19
|
-
webhooks: ManagementModelCollection<Webhook>;
|
|
20
|
-
constructor(config: NylasConfig);
|
|
21
|
-
/**
|
|
22
|
-
* Checks if the Nylas instance has been configured with credentials
|
|
23
|
-
* @return True if the Nylas instance has been configured with credentials
|
|
24
|
-
*/
|
|
25
|
-
clientCredentials(): boolean;
|
|
26
|
-
/**
|
|
27
|
-
* Configure a NylasConnection instance to access a user's resources
|
|
28
|
-
* @param accessToken The access token to access the user's resources
|
|
29
|
-
* @return The configured NylasConnection instance
|
|
30
|
-
*/
|
|
31
|
-
with(accessToken: string): NylasConnection;
|
|
32
|
-
/**
|
|
33
|
-
* Return information about a Nylas application
|
|
34
|
-
* @param options Application details to overwrite
|
|
35
|
-
* @return Information about the Nylas application
|
|
36
|
-
*/
|
|
37
|
-
application(options?: ApplicationDetailsProperties): Promise<ApplicationDetails>;
|
|
38
|
-
/**
|
|
39
|
-
* Exchange an authorization code for an access token
|
|
40
|
-
* @param code One-time authorization code from Nylas
|
|
41
|
-
* @param callback Callback before returning the access token
|
|
42
|
-
* @return The {@link AccessToken} object containing the access token and other information
|
|
43
|
-
*/
|
|
44
|
-
exchangeCodeForToken(code: string, callback?: ExchangeCodeForTokenCallback): Promise<AccessToken>;
|
|
45
|
-
/**
|
|
46
|
-
* Build the URL for authenticating users to your application via Hosted Authentication
|
|
47
|
-
* @param options Configuration for the authentication process
|
|
48
|
-
* @return The URL for hosted authentication
|
|
49
|
-
*/
|
|
50
|
-
urlForAuthentication(options: AuthenticateUrlConfig): string;
|
|
51
|
-
/**
|
|
52
|
-
* Revoke a single access token
|
|
53
|
-
* @param accessToken The access token to revoke
|
|
54
|
-
*/
|
|
55
|
-
revoke(accessToken: string): Promise<void>;
|
|
56
|
-
}
|
|
57
|
-
export = Nylas;
|