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,47 +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 nylas_api_error_1 = __importDefault(require("./nylas-api-error"));
|
|
20
|
-
/**
|
|
21
|
-
* This error class represents a 429 error response, with details on the rate limit
|
|
22
|
-
*/
|
|
23
|
-
var RateLimitError = /** @class */ (function (_super) {
|
|
24
|
-
__extends(RateLimitError, _super);
|
|
25
|
-
function RateLimitError(type, message, rateLimit, rateLimitReset) {
|
|
26
|
-
var _this = _super.call(this, RateLimitError.RATE_LIMIT_STATUS_CODE, type, message) || this;
|
|
27
|
-
_this.rateLimit = rateLimit;
|
|
28
|
-
_this.rateLimitReset = rateLimitReset;
|
|
29
|
-
return _this;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Parses an API response and generates a 429 error with details filled in
|
|
33
|
-
* @param parsedApiError The response parsed as a JSON
|
|
34
|
-
* @param headers The response headers
|
|
35
|
-
* @return The error with the rate limit details filled in
|
|
36
|
-
*/
|
|
37
|
-
RateLimitError.parseErrorResponse = function (parsedApiError, headers) {
|
|
38
|
-
var rateLimit = Number(headers.get(this.RATE_LIMIT_LIMIT_HEADER)) || undefined;
|
|
39
|
-
var rateLimitReset = Number(headers.get(this.RATE_LIMIT_RESET_HEADER)) || undefined;
|
|
40
|
-
return new RateLimitError(parsedApiError.type, parsedApiError.message, rateLimit, rateLimitReset);
|
|
41
|
-
};
|
|
42
|
-
RateLimitError.RATE_LIMIT_STATUS_CODE = 429;
|
|
43
|
-
RateLimitError.RATE_LIMIT_LIMIT_HEADER = 'X-RateLimit-Limit';
|
|
44
|
-
RateLimitError.RATE_LIMIT_RESET_HEADER = 'X-RateLimit-Reset';
|
|
45
|
-
return RateLimitError;
|
|
46
|
-
}(nylas_api_error_1.default));
|
|
47
|
-
exports.default = RateLimitError;
|
package/lib/models/resource.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import RestfulModel from './restful-model';
|
|
2
|
-
import { Attribute } from './attributes';
|
|
3
|
-
import NylasConnection from '../nylas-connection';
|
|
4
|
-
export declare type ResourceProperties = {
|
|
5
|
-
email: string;
|
|
6
|
-
name: string;
|
|
7
|
-
capacity: string;
|
|
8
|
-
building: string;
|
|
9
|
-
floorNumber: string;
|
|
10
|
-
floorName?: string;
|
|
11
|
-
};
|
|
12
|
-
export default class Resource extends RestfulModel {
|
|
13
|
-
email: string;
|
|
14
|
-
name: string;
|
|
15
|
-
capacity: string;
|
|
16
|
-
building: string;
|
|
17
|
-
floorNumber: string;
|
|
18
|
-
floorName?: string;
|
|
19
|
-
static collectionName: string;
|
|
20
|
-
static attributes: Record<string, Attribute>;
|
|
21
|
-
constructor(connection: NylasConnection, props?: ResourceProperties);
|
|
22
|
-
}
|
package/lib/models/resource.js
DELETED
|
@@ -1,66 +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 restful_model_1 = __importDefault(require("./restful-model"));
|
|
20
|
-
var attributes_1 = __importDefault(require("./attributes"));
|
|
21
|
-
var Resource = /** @class */ (function (_super) {
|
|
22
|
-
__extends(Resource, _super);
|
|
23
|
-
function Resource(connection, props) {
|
|
24
|
-
var _this = _super.call(this, connection, props) || this;
|
|
25
|
-
_this.email = '';
|
|
26
|
-
_this.name = '';
|
|
27
|
-
_this.capacity = '';
|
|
28
|
-
_this.building = '';
|
|
29
|
-
_this.floorNumber = '';
|
|
30
|
-
_this.initAttributes(props);
|
|
31
|
-
return _this;
|
|
32
|
-
}
|
|
33
|
-
Resource.collectionName = 'resources';
|
|
34
|
-
Resource.attributes = {
|
|
35
|
-
object: attributes_1.default.String({
|
|
36
|
-
modelKey: 'object',
|
|
37
|
-
readOnly: true,
|
|
38
|
-
}),
|
|
39
|
-
email: attributes_1.default.String({
|
|
40
|
-
modelKey: 'email',
|
|
41
|
-
}),
|
|
42
|
-
name: attributes_1.default.String({
|
|
43
|
-
modelKey: 'name',
|
|
44
|
-
}),
|
|
45
|
-
capacity: attributes_1.default.String({
|
|
46
|
-
modelKey: 'capacity',
|
|
47
|
-
readOnly: true,
|
|
48
|
-
}),
|
|
49
|
-
building: attributes_1.default.String({
|
|
50
|
-
modelKey: 'building',
|
|
51
|
-
readOnly: true,
|
|
52
|
-
}),
|
|
53
|
-
floorName: attributes_1.default.String({
|
|
54
|
-
modelKey: 'floorName',
|
|
55
|
-
jsonKey: 'floor_name',
|
|
56
|
-
readOnly: true,
|
|
57
|
-
}),
|
|
58
|
-
floorNumber: attributes_1.default.String({
|
|
59
|
-
modelKey: 'floorNumber',
|
|
60
|
-
jsonKey: 'floor_number',
|
|
61
|
-
readOnly: true,
|
|
62
|
-
}),
|
|
63
|
-
};
|
|
64
|
-
return Resource;
|
|
65
|
-
}(restful_model_1.default));
|
|
66
|
-
exports.default = Resource;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import NylasConnection from '../nylas-connection';
|
|
2
|
-
import RestfulModel from './restful-model';
|
|
3
|
-
import ModelCollection from './model-collection';
|
|
4
|
-
export declare type GetCallback = (error: Error | null, result?: RestfulModel) => void;
|
|
5
|
-
export default class RestfulModelCollection<T extends RestfulModel> extends ModelCollection<T> {
|
|
6
|
-
modelClass: typeof RestfulModel;
|
|
7
|
-
constructor(modelClass: typeof RestfulModel, connection: NylasConnection);
|
|
8
|
-
count(params?: Record<string, unknown>, callback?: (err: Error | null, num?: number) => void): Promise<number>;
|
|
9
|
-
first(params?: Record<string, unknown>, callback?: (error: Error | null, model?: T) => void): Promise<T>;
|
|
10
|
-
search(query: string, params?: Record<string, unknown>, callback?: (error: Error | null) => void): Promise<T[]>;
|
|
11
|
-
delete(itemOrId: T | string, params?: Record<string, unknown>, callback?: (error: Error | null) => void): any;
|
|
12
|
-
deleteItem(options: Record<string, any>, callbackArg?: (error: Error | null) => void): any;
|
|
13
|
-
protected build(args: Record<string, unknown>): T;
|
|
14
|
-
protected createModel(json: Record<string, unknown>): T;
|
|
15
|
-
}
|
|
@@ -1,169 +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 message_1 = __importDefault(require("./message"));
|
|
31
|
-
var thread_1 = __importDefault(require("./thread"));
|
|
32
|
-
var model_collection_1 = __importDefault(require("./model-collection"));
|
|
33
|
-
var RestfulModelCollection = /** @class */ (function (_super) {
|
|
34
|
-
__extends(RestfulModelCollection, _super);
|
|
35
|
-
function RestfulModelCollection(modelClass, connection) {
|
|
36
|
-
var _this = _super.call(this, modelClass, connection, modelClass.collectionName) || this;
|
|
37
|
-
_this.modelClass = modelClass;
|
|
38
|
-
_this._path = "/" + _this.modelClass.collectionName;
|
|
39
|
-
return _this;
|
|
40
|
-
}
|
|
41
|
-
RestfulModelCollection.prototype.count = function (params, callback) {
|
|
42
|
-
if (params === void 0) { params = {}; }
|
|
43
|
-
return this.connection
|
|
44
|
-
.request({
|
|
45
|
-
method: 'GET',
|
|
46
|
-
path: this.path(),
|
|
47
|
-
qs: __assign({ view: 'count' }, params),
|
|
48
|
-
baseUrl: this.baseUrl,
|
|
49
|
-
})
|
|
50
|
-
.then(function (json) {
|
|
51
|
-
if (callback) {
|
|
52
|
-
callback(null, json.count);
|
|
53
|
-
}
|
|
54
|
-
return Promise.resolve(json.count);
|
|
55
|
-
})
|
|
56
|
-
.catch(function (err) {
|
|
57
|
-
if (callback) {
|
|
58
|
-
callback(err);
|
|
59
|
-
}
|
|
60
|
-
return Promise.reject(err);
|
|
61
|
-
});
|
|
62
|
-
};
|
|
63
|
-
RestfulModelCollection.prototype.first = function (params, callback) {
|
|
64
|
-
if (params === void 0) { params = {}; }
|
|
65
|
-
if (params.view == 'count') {
|
|
66
|
-
var err = new Error('first() cannot be called with the count view');
|
|
67
|
-
if (callback) {
|
|
68
|
-
callback(err);
|
|
69
|
-
}
|
|
70
|
-
return Promise.reject(err);
|
|
71
|
-
}
|
|
72
|
-
return this.getItems(params, 0, 1)
|
|
73
|
-
.then(function (items) {
|
|
74
|
-
if (callback) {
|
|
75
|
-
callback(null, items[0]);
|
|
76
|
-
}
|
|
77
|
-
return Promise.resolve(items[0]);
|
|
78
|
-
})
|
|
79
|
-
.catch(function (err) {
|
|
80
|
-
if (callback) {
|
|
81
|
-
callback(err);
|
|
82
|
-
}
|
|
83
|
-
return Promise.reject(err);
|
|
84
|
-
});
|
|
85
|
-
};
|
|
86
|
-
RestfulModelCollection.prototype.search = function (query, params, callback) {
|
|
87
|
-
if (params === void 0) { params = {}; }
|
|
88
|
-
if (this.modelClass != message_1.default && this.modelClass != thread_1.default) {
|
|
89
|
-
var err = new Error('search() can only be called for messages and threads');
|
|
90
|
-
if (callback) {
|
|
91
|
-
callback(err);
|
|
92
|
-
}
|
|
93
|
-
return Promise.reject(err);
|
|
94
|
-
}
|
|
95
|
-
if (!query) {
|
|
96
|
-
var err = new Error('search() requires a query string');
|
|
97
|
-
if (callback) {
|
|
98
|
-
callback(err);
|
|
99
|
-
}
|
|
100
|
-
return Promise.reject(err);
|
|
101
|
-
}
|
|
102
|
-
params.q = query;
|
|
103
|
-
var limit = params.limit || 40;
|
|
104
|
-
var offset = params.offset;
|
|
105
|
-
var path = this.path() + "/search";
|
|
106
|
-
return this.range({ params: params, offset: offset, limit: limit, path: path });
|
|
107
|
-
};
|
|
108
|
-
RestfulModelCollection.prototype.delete = function (itemOrId, params, callback) {
|
|
109
|
-
if (params === void 0) { params = {}; }
|
|
110
|
-
if (!itemOrId) {
|
|
111
|
-
var err = new Error('delete() requires an item or an id');
|
|
112
|
-
if (callback) {
|
|
113
|
-
callback(err);
|
|
114
|
-
}
|
|
115
|
-
return Promise.reject(err);
|
|
116
|
-
}
|
|
117
|
-
if (typeof params === 'function') {
|
|
118
|
-
callback = params;
|
|
119
|
-
params = {};
|
|
120
|
-
}
|
|
121
|
-
var item = typeof itemOrId === 'string' ? this.build({ id: itemOrId }) : itemOrId;
|
|
122
|
-
var options = item.deleteRequestOptions(params);
|
|
123
|
-
options.item = item;
|
|
124
|
-
return this.deleteItem(options, callback);
|
|
125
|
-
};
|
|
126
|
-
RestfulModelCollection.prototype.deleteItem = function (options, callbackArg) {
|
|
127
|
-
var item = options.item;
|
|
128
|
-
// callback used to be in the options object
|
|
129
|
-
var callback = options.callback ? options.callback : callbackArg;
|
|
130
|
-
var body = options.hasOwnProperty('body')
|
|
131
|
-
? options.body
|
|
132
|
-
: item.deleteRequestBody({});
|
|
133
|
-
var qs = options.hasOwnProperty('qs')
|
|
134
|
-
? options.qs
|
|
135
|
-
: item.deleteRequestQueryString({});
|
|
136
|
-
return this.connection
|
|
137
|
-
.request({
|
|
138
|
-
method: 'DELETE',
|
|
139
|
-
qs: qs,
|
|
140
|
-
body: body,
|
|
141
|
-
path: this.path() + "/" + item.id,
|
|
142
|
-
baseUrl: this.baseUrl,
|
|
143
|
-
})
|
|
144
|
-
.then(function (data) {
|
|
145
|
-
if (callback) {
|
|
146
|
-
callback(null, data);
|
|
147
|
-
}
|
|
148
|
-
return Promise.resolve(data);
|
|
149
|
-
})
|
|
150
|
-
.catch(function (err) {
|
|
151
|
-
if (callback) {
|
|
152
|
-
callback(err);
|
|
153
|
-
}
|
|
154
|
-
return Promise.reject(err);
|
|
155
|
-
});
|
|
156
|
-
};
|
|
157
|
-
RestfulModelCollection.prototype.build = function (args) {
|
|
158
|
-
var model = this.createModel({});
|
|
159
|
-
for (var key in args) {
|
|
160
|
-
model[key] = args[key];
|
|
161
|
-
}
|
|
162
|
-
return model;
|
|
163
|
-
};
|
|
164
|
-
RestfulModelCollection.prototype.createModel = function (json) {
|
|
165
|
-
return new this.modelClass(this.connection).fromJSON(json);
|
|
166
|
-
};
|
|
167
|
-
return RestfulModelCollection;
|
|
168
|
-
}(model_collection_1.default));
|
|
169
|
-
exports.default = RestfulModelCollection;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import NylasConnection from '../nylas-connection';
|
|
2
|
-
import RestfulModel from './restful-model';
|
|
3
|
-
export default class RestfulModelInstance<T extends RestfulModel> {
|
|
4
|
-
connection: NylasConnection;
|
|
5
|
-
modelClass: typeof RestfulModel;
|
|
6
|
-
constructor(modelClass: typeof RestfulModel, connection: NylasConnection);
|
|
7
|
-
path(): string;
|
|
8
|
-
get(params?: Record<string, unknown>): Promise<T>;
|
|
9
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
var nylas_connection_1 = __importDefault(require("../nylas-connection"));
|
|
7
|
-
var RestfulModelInstance = /** @class */ (function () {
|
|
8
|
-
function RestfulModelInstance(modelClass, connection) {
|
|
9
|
-
this.modelClass = modelClass;
|
|
10
|
-
this.connection = connection;
|
|
11
|
-
if (!(this.connection instanceof nylas_connection_1.default)) {
|
|
12
|
-
throw new Error('Connection object not provided');
|
|
13
|
-
}
|
|
14
|
-
if (!this.modelClass) {
|
|
15
|
-
throw new Error('Model class not provided');
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
RestfulModelInstance.prototype.path = function () {
|
|
19
|
-
return "/" + this.modelClass.endpointName;
|
|
20
|
-
};
|
|
21
|
-
RestfulModelInstance.prototype.get = function (params) {
|
|
22
|
-
var _this = this;
|
|
23
|
-
if (params === void 0) { params = {}; }
|
|
24
|
-
return this.connection
|
|
25
|
-
.request({
|
|
26
|
-
method: 'GET',
|
|
27
|
-
path: this.path(),
|
|
28
|
-
qs: params,
|
|
29
|
-
})
|
|
30
|
-
.then(function (json) {
|
|
31
|
-
var model = new _this.modelClass(_this.connection).fromJSON(json);
|
|
32
|
-
return Promise.resolve(model);
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
return RestfulModelInstance;
|
|
36
|
-
}());
|
|
37
|
-
exports.default = RestfulModelInstance;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Attribute } from './attributes';
|
|
2
|
-
import NylasConnection from '../nylas-connection';
|
|
3
|
-
import Model from './model';
|
|
4
|
-
export declare type SaveCallback = (error: Error | null, result?: RestfulModel) => void;
|
|
5
|
-
interface RestfulModelJSON {
|
|
6
|
-
id: string;
|
|
7
|
-
object: string;
|
|
8
|
-
accountId: string;
|
|
9
|
-
[key: string]: any;
|
|
10
|
-
}
|
|
11
|
-
declare type requestOptions = {
|
|
12
|
-
body: Record<string, unknown>;
|
|
13
|
-
qs: Record<string, unknown>;
|
|
14
|
-
};
|
|
15
|
-
export default class RestfulModel extends Model {
|
|
16
|
-
static endpointName: string;
|
|
17
|
-
static collectionName: string;
|
|
18
|
-
accountId?: string;
|
|
19
|
-
connection: NylasConnection;
|
|
20
|
-
id?: string;
|
|
21
|
-
object?: string;
|
|
22
|
-
baseUrl?: string;
|
|
23
|
-
static attributes: Record<string, Attribute>;
|
|
24
|
-
constructor(connection: NylasConnection, props?: Partial<RestfulModelJSON>);
|
|
25
|
-
static propsFromJSON(json: Partial<RestfulModelJSON> | undefined, parent: unknown): Partial<RestfulModelJSON>;
|
|
26
|
-
isEqual(other: RestfulModel): boolean;
|
|
27
|
-
fromJSON(json?: Partial<RestfulModelJSON>): this;
|
|
28
|
-
pathPrefix(): string;
|
|
29
|
-
saveEndpoint(): string;
|
|
30
|
-
deleteRequestQueryString(_params: Record<string, unknown>): Record<string, unknown>;
|
|
31
|
-
deleteRequestBody(_params: Record<string, unknown>): Record<string, unknown>;
|
|
32
|
-
deleteRequestOptions(params: Record<string, unknown>): requestOptions;
|
|
33
|
-
protected save(params?: {} | SaveCallback, callback?: SaveCallback): Promise<this>;
|
|
34
|
-
protected get(params?: Record<string, any>, callback?: (error: Error | null, result?: any) => void, pathSuffix?: string): Promise<any>;
|
|
35
|
-
}
|
|
36
|
-
export {};
|
|
@@ -1,146 +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 attributes_1 = __importDefault(require("./attributes"));
|
|
20
|
-
var model_1 = __importDefault(require("./model"));
|
|
21
|
-
var RestfulModel = /** @class */ (function (_super) {
|
|
22
|
-
__extends(RestfulModel, _super);
|
|
23
|
-
function RestfulModel(connection, props) {
|
|
24
|
-
var _this = _super.call(this) || this;
|
|
25
|
-
_this.connection = connection;
|
|
26
|
-
if (!_this.connection) {
|
|
27
|
-
throw new Error('Connection object not provided');
|
|
28
|
-
}
|
|
29
|
-
_this.id = (props === null || props === void 0 ? void 0 : props.id) ? props.id : undefined;
|
|
30
|
-
_this.accountId = (props === null || props === void 0 ? void 0 : props.accountId) ? props.accountId : undefined;
|
|
31
|
-
_this.object = (props === null || props === void 0 ? void 0 : props.object) ? props.object : undefined;
|
|
32
|
-
return _this;
|
|
33
|
-
}
|
|
34
|
-
RestfulModel.propsFromJSON = function (json, parent) {
|
|
35
|
-
if (json === void 0) { json = {}; }
|
|
36
|
-
return _super.propsFromJSON.call(this, json, parent);
|
|
37
|
-
};
|
|
38
|
-
RestfulModel.prototype.isEqual = function (other) {
|
|
39
|
-
return ((other ? other.id : undefined) === this.id &&
|
|
40
|
-
(other ? other.constructor : undefined) === this.constructor);
|
|
41
|
-
};
|
|
42
|
-
RestfulModel.prototype.fromJSON = function (json) {
|
|
43
|
-
if (json === void 0) { json = {}; }
|
|
44
|
-
return _super.prototype.fromJSON.call(this, json);
|
|
45
|
-
};
|
|
46
|
-
// Subclasses should override this method.
|
|
47
|
-
RestfulModel.prototype.pathPrefix = function () {
|
|
48
|
-
return '';
|
|
49
|
-
};
|
|
50
|
-
RestfulModel.prototype.saveEndpoint = function () {
|
|
51
|
-
var collectionName = this.constructor.collectionName;
|
|
52
|
-
return this.pathPrefix() + "/" + collectionName;
|
|
53
|
-
};
|
|
54
|
-
// deleteRequestQueryString is used by delete(). Subclasses should override this method.
|
|
55
|
-
RestfulModel.prototype.deleteRequestQueryString = function (_params) {
|
|
56
|
-
return {};
|
|
57
|
-
};
|
|
58
|
-
// deleteRequestBody is used by delete(). Subclasses should override this method.
|
|
59
|
-
RestfulModel.prototype.deleteRequestBody = function (_params) {
|
|
60
|
-
return {};
|
|
61
|
-
};
|
|
62
|
-
// deleteRequestOptions is used by delete(). Subclasses should override this method.
|
|
63
|
-
RestfulModel.prototype.deleteRequestOptions = function (params) {
|
|
64
|
-
return {
|
|
65
|
-
body: this.deleteRequestBody(params),
|
|
66
|
-
qs: this.deleteRequestQueryString(params),
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
// Not every model needs to have a save function, but those who
|
|
70
|
-
// do shouldn't have to reimplement the same boilerplate.
|
|
71
|
-
// They should instead define a save() function which calls _save.
|
|
72
|
-
RestfulModel.prototype.save = function (params, callback) {
|
|
73
|
-
var _this = this;
|
|
74
|
-
if (params === void 0) { params = {}; }
|
|
75
|
-
if (typeof params === 'function') {
|
|
76
|
-
callback = params;
|
|
77
|
-
params = {};
|
|
78
|
-
}
|
|
79
|
-
return this.connection
|
|
80
|
-
.request({
|
|
81
|
-
method: this.id ? 'PUT' : 'POST',
|
|
82
|
-
body: this.saveRequestBody(),
|
|
83
|
-
qs: params,
|
|
84
|
-
path: this.id
|
|
85
|
-
? this.saveEndpoint() + "/" + this.id
|
|
86
|
-
: "" + this.saveEndpoint(),
|
|
87
|
-
baseUrl: this.baseUrl,
|
|
88
|
-
})
|
|
89
|
-
.then(function (json) {
|
|
90
|
-
var newModel = _this.fromJSON(json);
|
|
91
|
-
if (callback) {
|
|
92
|
-
callback(null, _this);
|
|
93
|
-
}
|
|
94
|
-
return Promise.resolve(newModel);
|
|
95
|
-
})
|
|
96
|
-
.catch(function (err) {
|
|
97
|
-
if (callback) {
|
|
98
|
-
callback(err);
|
|
99
|
-
}
|
|
100
|
-
return Promise.reject(err);
|
|
101
|
-
});
|
|
102
|
-
};
|
|
103
|
-
RestfulModel.prototype.get = function (params, callback, pathSuffix) {
|
|
104
|
-
if (params === void 0) { params = {}; }
|
|
105
|
-
if (pathSuffix === void 0) { pathSuffix = ''; }
|
|
106
|
-
var collectionName = this.constructor.collectionName;
|
|
107
|
-
return this.connection
|
|
108
|
-
.request({
|
|
109
|
-
method: 'GET',
|
|
110
|
-
path: "/" + collectionName + "/" + this.id + pathSuffix,
|
|
111
|
-
qs: params,
|
|
112
|
-
baseUrl: this.baseUrl,
|
|
113
|
-
})
|
|
114
|
-
.then(function (response) {
|
|
115
|
-
if (callback) {
|
|
116
|
-
callback(null, response);
|
|
117
|
-
}
|
|
118
|
-
return Promise.resolve(response);
|
|
119
|
-
})
|
|
120
|
-
.catch(function (err) {
|
|
121
|
-
if (callback) {
|
|
122
|
-
callback(err);
|
|
123
|
-
}
|
|
124
|
-
return Promise.reject(err);
|
|
125
|
-
});
|
|
126
|
-
};
|
|
127
|
-
RestfulModel.endpointName = ''; // overrridden in subclasses
|
|
128
|
-
RestfulModel.collectionName = ''; // overrridden in subclasses
|
|
129
|
-
RestfulModel.attributes = {
|
|
130
|
-
id: attributes_1.default.String({
|
|
131
|
-
modelKey: 'id',
|
|
132
|
-
readOnly: true,
|
|
133
|
-
}),
|
|
134
|
-
object: attributes_1.default.String({
|
|
135
|
-
modelKey: 'object',
|
|
136
|
-
readOnly: true,
|
|
137
|
-
}),
|
|
138
|
-
accountId: attributes_1.default.String({
|
|
139
|
-
modelKey: 'accountId',
|
|
140
|
-
jsonKey: 'account_id',
|
|
141
|
-
readOnly: true,
|
|
142
|
-
}),
|
|
143
|
-
};
|
|
144
|
-
return RestfulModel;
|
|
145
|
-
}(model_1.default));
|
|
146
|
-
exports.default = RestfulModel;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { Attribute } from './attributes';
|
|
2
|
-
import SchedulerTimeSlot from './scheduler-time-slot';
|
|
3
|
-
import Model from './model';
|
|
4
|
-
export declare type SchedulerBookingConfirmationProperties = {
|
|
5
|
-
id?: string;
|
|
6
|
-
accountId?: string;
|
|
7
|
-
additionalFieldValues?: object;
|
|
8
|
-
calendarEventId?: string;
|
|
9
|
-
calendarId?: string;
|
|
10
|
-
editHash?: string;
|
|
11
|
-
startTime?: Date;
|
|
12
|
-
endTime?: Date;
|
|
13
|
-
isConfirmed?: boolean;
|
|
14
|
-
location?: string;
|
|
15
|
-
recipientEmail?: string;
|
|
16
|
-
recipientLocale?: string;
|
|
17
|
-
recipientName?: string;
|
|
18
|
-
recipientTz?: string;
|
|
19
|
-
title?: string;
|
|
20
|
-
};
|
|
21
|
-
export declare class SchedulerBookingConfirmation extends Model implements SchedulerBookingConfirmationProperties {
|
|
22
|
-
id?: string;
|
|
23
|
-
accountId?: string;
|
|
24
|
-
additionalFieldValues?: object;
|
|
25
|
-
calendarEventId?: string;
|
|
26
|
-
calendarId?: string;
|
|
27
|
-
editHash?: string;
|
|
28
|
-
startTime?: Date;
|
|
29
|
-
endTime?: Date;
|
|
30
|
-
isConfirmed?: boolean;
|
|
31
|
-
location?: string;
|
|
32
|
-
recipientEmail?: string;
|
|
33
|
-
recipientLocale?: string;
|
|
34
|
-
recipientName?: string;
|
|
35
|
-
recipientTz?: string;
|
|
36
|
-
title?: string;
|
|
37
|
-
static attributes: Record<string, Attribute>;
|
|
38
|
-
constructor(props?: SchedulerBookingConfirmationProperties);
|
|
39
|
-
}
|
|
40
|
-
export declare type SchedulerBookingRequestProperties = {
|
|
41
|
-
additionalEmails?: string[];
|
|
42
|
-
additionalValues?: object;
|
|
43
|
-
email?: string;
|
|
44
|
-
locale?: string;
|
|
45
|
-
name?: string;
|
|
46
|
-
pageHostname?: string;
|
|
47
|
-
replacesBookingHash?: string;
|
|
48
|
-
slot?: SchedulerTimeSlot;
|
|
49
|
-
timezone?: string;
|
|
50
|
-
};
|
|
51
|
-
export default class SchedulerBookingRequest extends Model implements SchedulerBookingRequestProperties {
|
|
52
|
-
additionalEmails?: string[];
|
|
53
|
-
additionalValues?: object;
|
|
54
|
-
email?: string;
|
|
55
|
-
locale?: string;
|
|
56
|
-
name?: string;
|
|
57
|
-
pageHostname?: string;
|
|
58
|
-
replacesBookingHash?: string;
|
|
59
|
-
slot?: SchedulerTimeSlot;
|
|
60
|
-
timezone?: string;
|
|
61
|
-
static attributes: Record<string, Attribute>;
|
|
62
|
-
constructor(props?: SchedulerBookingRequestProperties);
|
|
63
|
-
toJSON(enforceReadOnly?: boolean): Record<string, any>;
|
|
64
|
-
}
|