nylas 5.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/LICENSE.txt +22 -0
  2. package/README.md +65 -0
  3. package/lib/config.d.ts +4 -0
  4. package/lib/config.js +13 -0
  5. package/lib/models/account.d.ts +10 -0
  6. package/lib/models/account.js +61 -0
  7. package/lib/models/attributes.d.ts +104 -0
  8. package/lib/models/attributes.js +266 -0
  9. package/lib/models/calendar-restful-model-collection.d.ts +76 -0
  10. package/lib/models/calendar-restful-model-collection.js +128 -0
  11. package/lib/models/calendar.d.ts +19 -0
  12. package/lib/models/calendar.js +81 -0
  13. package/lib/models/connect.d.ts +12 -0
  14. package/lib/models/connect.js +51 -0
  15. package/lib/models/contact-restful-model-collection.d.ts +11 -0
  16. package/lib/models/contact-restful-model-collection.js +54 -0
  17. package/lib/models/contact.d.ts +75 -0
  18. package/lib/models/contact.js +245 -0
  19. package/lib/models/delta-stream.d.ts +30 -0
  20. package/lib/models/delta-stream.js +225 -0
  21. package/lib/models/delta.d.ts +11 -0
  22. package/lib/models/delta.js +91 -0
  23. package/lib/models/draft.d.ts +24 -0
  24. package/lib/models/draft.js +145 -0
  25. package/lib/models/email-participant.d.ts +6 -0
  26. package/lib/models/email-participant.js +44 -0
  27. package/lib/models/event-conferencing.d.ts +24 -0
  28. package/lib/models/event-conferencing.js +84 -0
  29. package/lib/models/event-participant.d.ts +7 -0
  30. package/lib/models/event-participant.js +47 -0
  31. package/lib/models/event.d.ts +45 -0
  32. package/lib/models/event.js +206 -0
  33. package/lib/models/file.d.ts +18 -0
  34. package/lib/models/file.js +151 -0
  35. package/lib/models/folder.d.ts +14 -0
  36. package/lib/models/folder.js +70 -0
  37. package/lib/models/job-status.d.ts +7 -0
  38. package/lib/models/job-status.js +51 -0
  39. package/lib/models/management-account.d.ts +14 -0
  40. package/lib/models/management-account.js +101 -0
  41. package/lib/models/management-model-collection.d.ts +11 -0
  42. package/lib/models/management-model-collection.js +35 -0
  43. package/lib/models/management-model.d.ts +8 -0
  44. package/lib/models/management-model.js +29 -0
  45. package/lib/models/message.d.ts +32 -0
  46. package/lib/models/message.js +154 -0
  47. package/lib/models/neural-categorizer.d.ts +18 -0
  48. package/lib/models/neural-categorizer.js +140 -0
  49. package/lib/models/neural-clean-conversation.d.ts +7 -0
  50. package/lib/models/neural-clean-conversation.js +110 -0
  51. package/lib/models/neural-ocr.d.ts +5 -0
  52. package/lib/models/neural-ocr.js +46 -0
  53. package/lib/models/neural-sentiment-analysis.d.ts +8 -0
  54. package/lib/models/neural-sentiment-analysis.js +49 -0
  55. package/lib/models/neural-signature-contact.d.ts +37 -0
  56. package/lib/models/neural-signature-contact.js +141 -0
  57. package/lib/models/neural-signature-extraction.d.ts +7 -0
  58. package/lib/models/neural-signature-extraction.js +50 -0
  59. package/lib/models/neural.d.ts +22 -0
  60. package/lib/models/neural.js +124 -0
  61. package/lib/models/nylas-api-error.d.ts +28 -0
  62. package/lib/models/nylas-api-error.js +61 -0
  63. package/lib/models/resource.d.ts +9 -0
  64. package/lib/models/resource.js +59 -0
  65. package/lib/models/restful-model-collection.d.ts +59 -0
  66. package/lib/models/restful-model-collection.js +325 -0
  67. package/lib/models/restful-model-instance.d.ts +11 -0
  68. package/lib/models/restful-model-instance.js +37 -0
  69. package/lib/models/restful-model.d.ts +48 -0
  70. package/lib/models/restful-model.js +153 -0
  71. package/lib/models/thread.d.ts +30 -0
  72. package/lib/models/thread.js +112 -0
  73. package/lib/models/webhook.d.ts +15 -0
  74. package/lib/models/webhook.js +71 -0
  75. package/lib/nylas-connection.d.ts +67 -0
  76. package/lib/nylas-connection.js +235 -0
  77. package/lib/nylas.d.ts +38 -0
  78. package/lib/nylas.js +178 -0
  79. package/package.json +76 -0
@@ -0,0 +1,47 @@
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 EventParticipant = /** @class */ (function (_super) {
22
+ __extends(EventParticipant, _super);
23
+ function EventParticipant() {
24
+ return _super !== null && _super.apply(this, arguments) || this;
25
+ }
26
+ EventParticipant.prototype.toJSON = function (enforceReadOnly) {
27
+ var json = _super.prototype.toJSON.call(this, enforceReadOnly);
28
+ if (!json['name']) {
29
+ json['name'] = json['email'];
30
+ }
31
+ return json;
32
+ };
33
+ return EventParticipant;
34
+ }(restful_model_1.default));
35
+ exports.default = EventParticipant;
36
+ EventParticipant.collectionName = 'event-participants';
37
+ EventParticipant.attributes = {
38
+ name: attributes_1.default.String({
39
+ modelKey: 'name',
40
+ }),
41
+ email: attributes_1.default.String({
42
+ modelKey: 'email',
43
+ }),
44
+ status: attributes_1.default.String({
45
+ modelKey: 'status',
46
+ }),
47
+ };
@@ -0,0 +1,45 @@
1
+ import RestfulModel, { SaveCallback } from './restful-model';
2
+ import EventParticipant from './event-participant';
3
+ import { EventConferencing } from './event-conferencing';
4
+ export default class Event extends RestfulModel {
5
+ calendarId?: string;
6
+ iCalUID?: string;
7
+ messageId?: string;
8
+ title?: string;
9
+ description?: string;
10
+ owner?: string;
11
+ participants?: EventParticipant[];
12
+ readOnly?: boolean;
13
+ location?: string;
14
+ when?: {
15
+ start_time?: number;
16
+ end_time?: number;
17
+ time?: number;
18
+ start_date?: string;
19
+ end_date?: string;
20
+ date?: string;
21
+ object?: string;
22
+ };
23
+ busy?: boolean;
24
+ status?: string;
25
+ recurrence?: {
26
+ rrule: string[];
27
+ timezone: string;
28
+ };
29
+ masterEventId?: string;
30
+ originalStartTime?: number;
31
+ conferencing?: EventConferencing;
32
+ metadata?: object;
33
+ jobStatusId?: string;
34
+ get start(): string | number | undefined;
35
+ set start(val: string | number | undefined);
36
+ get end(): string | number | undefined;
37
+ set end(val: string | number | undefined);
38
+ deleteRequestQueryString(params?: {
39
+ [key: string]: any;
40
+ }): {
41
+ [key: string]: any;
42
+ };
43
+ save(params?: {} | SaveCallback, callback?: SaveCallback): Promise<this>;
44
+ rsvp(status: string, comment: string, callback?: (error: Error | null, data?: Event) => void): Promise<this>;
45
+ }
@@ -0,0 +1,206 @@
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_1 = __importDefault(require("./restful-model"));
31
+ var attributes_1 = __importDefault(require("./attributes"));
32
+ var event_participant_1 = __importDefault(require("./event-participant"));
33
+ var event_conferencing_1 = require("./event-conferencing");
34
+ var Event = /** @class */ (function (_super) {
35
+ __extends(Event, _super);
36
+ function Event() {
37
+ return _super !== null && _super.apply(this, arguments) || this;
38
+ }
39
+ Object.defineProperty(Event.prototype, "start", {
40
+ get: function () {
41
+ var _a, _b, _c, _d;
42
+ var start = ((_a = this.when) === null || _a === void 0 ? void 0 : _a.start_time) || ((_b = this.when) === null || _b === void 0 ? void 0 : _b.start_date) || ((_c = this.when) === null || _c === void 0 ? void 0 : _c.time) || ((_d = this.when) === null || _d === void 0 ? void 0 : _d.date);
43
+ return start;
44
+ },
45
+ set: function (val) {
46
+ if (!this.when) {
47
+ this.when = {};
48
+ }
49
+ if (typeof val === 'number') {
50
+ if (val === this.when.end_time) {
51
+ this.when = { time: val };
52
+ }
53
+ else {
54
+ delete this.when.time;
55
+ delete this.when.start_date;
56
+ delete this.when.date;
57
+ this.when.start_time = val;
58
+ }
59
+ }
60
+ if (typeof val === 'string') {
61
+ if (val === this.when.end_date) {
62
+ this.when = { date: val };
63
+ }
64
+ else {
65
+ delete this.when.date;
66
+ delete this.when.start_time;
67
+ delete this.when.time;
68
+ this.when.start_date = val;
69
+ }
70
+ }
71
+ },
72
+ enumerable: false,
73
+ configurable: true
74
+ });
75
+ Object.defineProperty(Event.prototype, "end", {
76
+ get: function () {
77
+ var _a, _b, _c, _d;
78
+ var end = ((_a = this.when) === null || _a === void 0 ? void 0 : _a.end_time) || ((_b = this.when) === null || _b === void 0 ? void 0 : _b.end_date) || ((_c = this.when) === null || _c === void 0 ? void 0 : _c.time) || ((_d = this.when) === null || _d === void 0 ? void 0 : _d.date);
79
+ return end;
80
+ },
81
+ set: function (val) {
82
+ if (!this.when) {
83
+ this.when = {};
84
+ }
85
+ if (typeof val === 'number') {
86
+ if (val === this.when.start_time) {
87
+ this.when = { time: val };
88
+ }
89
+ else {
90
+ delete this.when.time;
91
+ delete this.when.end_date;
92
+ delete this.when.date;
93
+ this.when.end_time = val;
94
+ }
95
+ }
96
+ if (typeof val === 'string') {
97
+ if (val === this.when.start_date) {
98
+ this.when = { date: val };
99
+ }
100
+ else {
101
+ delete this.when.date;
102
+ delete this.when.time;
103
+ delete this.when.end_time;
104
+ this.when.end_date = val;
105
+ }
106
+ }
107
+ },
108
+ enumerable: false,
109
+ configurable: true
110
+ });
111
+ Event.prototype.deleteRequestQueryString = function (params) {
112
+ if (params === void 0) { params = {}; }
113
+ var qs = {};
114
+ if (params.hasOwnProperty('notify_participants')) {
115
+ qs.notify_participants = params.notify_participants;
116
+ }
117
+ return qs;
118
+ };
119
+ Event.prototype.save = function (params, callback) {
120
+ if (params === void 0) { params = {}; }
121
+ if (this.conferencing &&
122
+ this.conferencing.details &&
123
+ this.conferencing.autocreate) {
124
+ return Promise.reject(new Error("Cannot set both 'details' and 'autocreate' in conferencing object."));
125
+ }
126
+ return this._save(params, callback);
127
+ };
128
+ Event.prototype.rsvp = function (status, comment, callback) {
129
+ var _this = this;
130
+ return this.connection
131
+ .request({
132
+ method: 'POST',
133
+ body: { event_id: this.id, status: status, comment: comment },
134
+ path: '/send-rsvp',
135
+ })
136
+ .then(function (json) {
137
+ _this.fromJSON(json);
138
+ if (callback) {
139
+ callback(null, _this);
140
+ }
141
+ return Promise.resolve(_this);
142
+ })
143
+ .catch(function (err) {
144
+ if (callback) {
145
+ callback(err);
146
+ }
147
+ return Promise.reject(err);
148
+ });
149
+ };
150
+ return Event;
151
+ }(restful_model_1.default));
152
+ exports.default = Event;
153
+ Event.collectionName = 'events';
154
+ Event.attributes = __assign(__assign({}, restful_model_1.default.attributes), { calendarId: attributes_1.default.String({
155
+ modelKey: 'calendarId',
156
+ jsonKey: 'calendar_id',
157
+ }), iCalUID: attributes_1.default.String({
158
+ modelKey: 'iCalUID',
159
+ jsonKey: 'ical_uid',
160
+ readOnly: true,
161
+ }), messageId: attributes_1.default.String({
162
+ modelKey: 'messageId',
163
+ jsonKey: 'message_id',
164
+ readOnly: true,
165
+ }), title: attributes_1.default.String({
166
+ modelKey: 'title',
167
+ }), description: attributes_1.default.String({
168
+ modelKey: 'description',
169
+ }), owner: attributes_1.default.String({
170
+ modelKey: 'owner',
171
+ readOnly: true,
172
+ }), participants: attributes_1.default.Collection({
173
+ modelKey: 'participants',
174
+ itemClass: event_participant_1.default,
175
+ }), readOnly: attributes_1.default.Boolean({
176
+ modelKey: 'readOnly',
177
+ jsonKey: 'read_only',
178
+ }), location: attributes_1.default.String({
179
+ modelKey: 'location',
180
+ }), when: attributes_1.default.Object({
181
+ modelKey: 'when',
182
+ }), busy: attributes_1.default.Boolean({
183
+ modelKey: 'busy',
184
+ }), status: attributes_1.default.String({
185
+ modelKey: 'status',
186
+ readOnly: true,
187
+ }), recurrence: attributes_1.default.Object({
188
+ modelKey: 'recurrence',
189
+ }), masterEventId: attributes_1.default.String({
190
+ modelKey: 'masterEventId',
191
+ jsonKey: 'master_event_id',
192
+ readOnly: true,
193
+ }), originalStartTime: attributes_1.default.DateTime({
194
+ modelKey: 'originalStartTime',
195
+ jsonKey: 'original_start_time',
196
+ readOnly: true,
197
+ }), conferencing: attributes_1.default.Object({
198
+ modelKey: 'conferencing',
199
+ itemClass: event_conferencing_1.EventConferencing,
200
+ }), metadata: attributes_1.default.Object({
201
+ modelKey: 'metadata',
202
+ }), jobStatusId: attributes_1.default.String({
203
+ modelKey: 'jobStatusId',
204
+ jsonKey: 'job_status_id',
205
+ readOnly: true,
206
+ }) });
@@ -0,0 +1,18 @@
1
+ import RestfulModel from './restful-model';
2
+ export default class File extends RestfulModel {
3
+ contentType?: string;
4
+ size?: number;
5
+ filename?: string;
6
+ messageIds?: string[];
7
+ contentId?: string;
8
+ contentDisposition?: string;
9
+ data?: any;
10
+ upload(callback?: (error: Error | null, model?: File) => void): Promise<this>;
11
+ download(callback?: (error: Error | null, file?: {
12
+ body: any;
13
+ [key: string]: any;
14
+ }) => void): Promise<any>;
15
+ metadata(callback?: (error: Error | null, data?: {
16
+ [key: string]: any;
17
+ }) => void): Promise<any>;
18
+ }
@@ -0,0 +1,151 @@
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 attributes_1 = __importDefault(require("./attributes"));
31
+ var restful_model_1 = __importDefault(require("./restful-model"));
32
+ var File = /** @class */ (function (_super) {
33
+ __extends(File, _super);
34
+ function File() {
35
+ return _super !== null && _super.apply(this, arguments) || this;
36
+ }
37
+ File.prototype.upload = function (callback) {
38
+ var _this = this;
39
+ if (!this.filename) {
40
+ throw new Error('Please define a filename');
41
+ }
42
+ if (!this.data) {
43
+ throw new Error('Please add some data to the file');
44
+ }
45
+ if (!this.contentType) {
46
+ throw new Error('Please define a content-type');
47
+ }
48
+ var formOptions = {
49
+ filename: this.filename,
50
+ contentType: this.contentType,
51
+ };
52
+ if (this.size) {
53
+ formOptions.knownLength = this.size;
54
+ }
55
+ return this.connection
56
+ .request({
57
+ method: 'POST',
58
+ path: "/" + File.collectionName,
59
+ json: true,
60
+ formData: {
61
+ file: {
62
+ value: this.data,
63
+ options: formOptions,
64
+ },
65
+ },
66
+ })
67
+ .then(function (json) {
68
+ // The API returns a list of files. It should
69
+ // always have a length of 1 since we only
70
+ // upload file-by-file.
71
+ if (json.length > 0) {
72
+ _this.fromJSON(json[0]);
73
+ if (callback) {
74
+ callback(null, _this);
75
+ }
76
+ return Promise.resolve(_this);
77
+ }
78
+ else {
79
+ return Promise.reject(null);
80
+ }
81
+ })
82
+ .catch(function (err) {
83
+ if (callback) {
84
+ callback(err);
85
+ }
86
+ return Promise.reject(err);
87
+ });
88
+ };
89
+ File.prototype.download = function (callback) {
90
+ if (!this.id) {
91
+ throw new Error('Please provide a File id');
92
+ }
93
+ return this.connection
94
+ .request({
95
+ path: "/files/" + this.id + "/download",
96
+ downloadRequest: true,
97
+ })
98
+ .then(function (file) {
99
+ if (callback) {
100
+ callback(null, file);
101
+ }
102
+ return Promise.resolve(file);
103
+ })
104
+ .catch(function (err) {
105
+ if (callback) {
106
+ callback(err);
107
+ }
108
+ return Promise.reject(err);
109
+ });
110
+ };
111
+ File.prototype.metadata = function (callback) {
112
+ return this.connection
113
+ .request({
114
+ path: "/files/" + this.id,
115
+ })
116
+ .then(function (response) {
117
+ if (callback) {
118
+ callback(null, response);
119
+ }
120
+ return Promise.resolve(response);
121
+ })
122
+ .catch(function (err) {
123
+ if (callback) {
124
+ callback(err);
125
+ }
126
+ return Promise.reject(err);
127
+ });
128
+ };
129
+ return File;
130
+ }(restful_model_1.default));
131
+ exports.default = File;
132
+ File.collectionName = 'files';
133
+ File.attributes = __assign(__assign({}, restful_model_1.default.attributes), { contentType: attributes_1.default.String({
134
+ modelKey: 'contentType',
135
+ jsonKey: 'content_type',
136
+ }), size: attributes_1.default.Number({
137
+ modelKey: 'size',
138
+ jsonKey: 'size',
139
+ }), filename: attributes_1.default.String({
140
+ modelKey: 'filename',
141
+ jsonKey: 'filename',
142
+ }), messageIds: attributes_1.default.StringList({
143
+ modelKey: 'messageIds',
144
+ jsonKey: 'message_ids',
145
+ }), contentId: attributes_1.default.String({
146
+ modelKey: 'contentId',
147
+ jsonKey: 'content_id',
148
+ }), contentDisposition: attributes_1.default.String({
149
+ modelKey: 'contentDisposition',
150
+ jsonKey: 'content_disposition',
151
+ }) });