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.
Files changed (204) hide show
  1. package/README.md +27 -19
  2. package/lib/cjs/apiClient.js +114 -0
  3. package/lib/cjs/config.js +32 -0
  4. package/lib/cjs/models/applicationDetails.js +2 -0
  5. package/lib/cjs/models/auth.js +2 -0
  6. package/lib/cjs/models/availability.js +11 -0
  7. package/lib/cjs/models/calendars.js +2 -0
  8. package/lib/cjs/models/error.js +53 -0
  9. package/lib/cjs/models/events.js +2 -0
  10. package/lib/cjs/models/grants.js +2 -0
  11. package/lib/cjs/models/listQueryParams.js +2 -0
  12. package/lib/cjs/models/redirectUri.js +2 -0
  13. package/lib/cjs/models/response.js +2 -0
  14. package/lib/cjs/models/webhooks.js +18 -0
  15. package/lib/cjs/nylas.js +34 -0
  16. package/lib/cjs/package.json +3 -0
  17. package/lib/cjs/resources/applications.js +30 -0
  18. package/lib/cjs/resources/auth.js +153 -0
  19. package/lib/cjs/resources/calendars.js +78 -0
  20. package/lib/cjs/resources/events.js +69 -0
  21. package/lib/cjs/resources/grants.js +65 -0
  22. package/lib/cjs/resources/redirectUris.js +64 -0
  23. package/lib/cjs/resources/resource.js +111 -0
  24. package/lib/cjs/resources/webhooks.js +98 -0
  25. package/lib/cjs/utils.js +58 -0
  26. package/lib/cjs/version.js +5 -0
  27. package/lib/esm/apiClient.js +111 -0
  28. package/lib/esm/config.js +29 -0
  29. package/lib/esm/models/applicationDetails.js +1 -0
  30. package/lib/esm/models/auth.js +1 -0
  31. package/lib/esm/models/availability.js +8 -0
  32. package/lib/esm/models/calendars.js +1 -0
  33. package/lib/esm/models/error.js +45 -0
  34. package/lib/esm/models/events.js +1 -0
  35. package/lib/esm/models/grants.js +1 -0
  36. package/lib/esm/models/listQueryParams.js +1 -0
  37. package/lib/esm/models/redirectUri.js +1 -0
  38. package/lib/esm/models/response.js +1 -0
  39. package/lib/esm/models/webhooks.js +15 -0
  40. package/lib/esm/nylas.js +31 -0
  41. package/lib/esm/package.json +3 -0
  42. package/lib/esm/resources/applications.js +26 -0
  43. package/lib/esm/resources/auth.js +149 -0
  44. package/lib/esm/resources/calendars.js +74 -0
  45. package/lib/esm/resources/events.js +65 -0
  46. package/lib/esm/resources/grants.js +61 -0
  47. package/lib/esm/resources/redirectUris.js +60 -0
  48. package/lib/esm/resources/resource.js +107 -0
  49. package/lib/esm/resources/webhooks.js +94 -0
  50. package/lib/esm/utils.js +53 -0
  51. package/lib/esm/version.js +2 -0
  52. package/lib/types/apiClient.d.ts +65 -0
  53. package/lib/types/config.d.ts +50 -0
  54. package/lib/types/models/applicationDetails.d.ts +93 -0
  55. package/lib/types/models/auth.d.ts +196 -0
  56. package/lib/types/models/availability.d.ts +159 -0
  57. package/lib/types/models/calendars.d.ts +121 -0
  58. package/lib/types/models/error.d.ts +104 -0
  59. package/lib/types/models/events.d.ts +494 -0
  60. package/lib/types/models/grants.d.ts +134 -0
  61. package/lib/types/models/listQueryParams.d.ts +4 -0
  62. package/lib/types/models/redirectUri.d.ts +71 -0
  63. package/lib/types/models/response.d.ts +40 -0
  64. package/lib/types/models/webhooks.d.ts +45 -0
  65. package/lib/types/nylas.d.ts +44 -0
  66. package/lib/types/resources/applications.d.ts +26 -0
  67. package/lib/types/resources/auth.d.ts +66 -0
  68. package/lib/types/resources/calendars.d.ts +97 -0
  69. package/lib/types/resources/events.d.ts +87 -0
  70. package/lib/types/resources/grants.d.ts +63 -0
  71. package/lib/types/resources/redirectUris.d.ts +63 -0
  72. package/lib/types/resources/resource.d.ts +55 -0
  73. package/lib/types/resources/webhooks.d.ts +79 -0
  74. package/lib/types/utils.d.ts +22 -0
  75. package/lib/types/version.d.ts +1 -0
  76. package/package.json +33 -42
  77. package/lib/config.d.ts +0 -70
  78. package/lib/config.js +0 -68
  79. package/lib/models/access-token.d.ts +0 -18
  80. package/lib/models/access-token.js +0 -56
  81. package/lib/models/account.d.ts +0 -27
  82. package/lib/models/account.js +0 -73
  83. package/lib/models/application-details.d.ts +0 -14
  84. package/lib/models/application-details.js +0 -47
  85. package/lib/models/attributes.d.ts +0 -151
  86. package/lib/models/attributes.js +0 -382
  87. package/lib/models/calendar-availability.d.ts +0 -76
  88. package/lib/models/calendar-availability.js +0 -121
  89. package/lib/models/calendar-restful-model-collection.d.ts +0 -17
  90. package/lib/models/calendar-restful-model-collection.js +0 -181
  91. package/lib/models/calendar.d.ts +0 -31
  92. package/lib/models/calendar.js +0 -93
  93. package/lib/models/component-restful-model-collection.d.ts +0 -9
  94. package/lib/models/component-restful-model-collection.js +0 -34
  95. package/lib/models/component.d.ts +0 -37
  96. package/lib/models/component.js +0 -91
  97. package/lib/models/connect.d.ts +0 -73
  98. package/lib/models/connect.js +0 -193
  99. package/lib/models/contact-restful-model-collection.d.ts +0 -9
  100. package/lib/models/contact-restful-model-collection.js +0 -60
  101. package/lib/models/contact.d.ts +0 -129
  102. package/lib/models/contact.js +0 -289
  103. package/lib/models/delta-collection.d.ts +0 -17
  104. package/lib/models/delta-collection.js +0 -139
  105. package/lib/models/delta-stream.d.ts +0 -32
  106. package/lib/models/delta-stream.js +0 -250
  107. package/lib/models/delta.d.ts +0 -28
  108. package/lib/models/delta.js +0 -88
  109. package/lib/models/deltas.d.ts +0 -17
  110. package/lib/models/deltas.js +0 -49
  111. package/lib/models/draft.d.ts +0 -27
  112. package/lib/models/draft.js +0 -156
  113. package/lib/models/email-participant.d.ts +0 -13
  114. package/lib/models/email-participant.js +0 -46
  115. package/lib/models/event-conferencing.d.ts +0 -34
  116. package/lib/models/event-conferencing.js +0 -71
  117. package/lib/models/event-notification.d.ts +0 -27
  118. package/lib/models/event-notification.js +0 -62
  119. package/lib/models/event-participant.d.ts +0 -19
  120. package/lib/models/event-participant.js +0 -56
  121. package/lib/models/event.d.ts +0 -96
  122. package/lib/models/event.js +0 -297
  123. package/lib/models/file.d.ts +0 -29
  124. package/lib/models/file.js +0 -136
  125. package/lib/models/folder.d.ts +0 -21
  126. package/lib/models/folder.js +0 -69
  127. package/lib/models/free-busy.d.ts +0 -58
  128. package/lib/models/free-busy.js +0 -132
  129. package/lib/models/job-status-restful-model-collection.d.ts +0 -9
  130. package/lib/models/job-status-restful-model-collection.js +0 -38
  131. package/lib/models/job-status.d.ts +0 -24
  132. package/lib/models/job-status.js +0 -68
  133. package/lib/models/management-account.d.ts +0 -63
  134. package/lib/models/management-account.js +0 -187
  135. package/lib/models/management-model-collection.d.ts +0 -10
  136. package/lib/models/management-model-collection.js +0 -39
  137. package/lib/models/management-model.d.ts +0 -6
  138. package/lib/models/management-model.js +0 -29
  139. package/lib/models/message-restful-model-collection.d.ts +0 -26
  140. package/lib/models/message-restful-model-collection.js +0 -80
  141. package/lib/models/message.d.ts +0 -57
  142. package/lib/models/message.js +0 -173
  143. package/lib/models/model-collection.d.ts +0 -25
  144. package/lib/models/model-collection.js +0 -201
  145. package/lib/models/model.d.ts +0 -12
  146. package/lib/models/model.js +0 -64
  147. package/lib/models/neural-categorizer.d.ts +0 -28
  148. package/lib/models/neural-categorizer.js +0 -139
  149. package/lib/models/neural-clean-conversation.d.ts +0 -16
  150. package/lib/models/neural-clean-conversation.js +0 -114
  151. package/lib/models/neural-ocr.d.ts +0 -14
  152. package/lib/models/neural-ocr.js +0 -50
  153. package/lib/models/neural-sentiment-analysis.d.ts +0 -20
  154. package/lib/models/neural-sentiment-analysis.js +0 -56
  155. package/lib/models/neural-signature-contact.d.ts +0 -43
  156. package/lib/models/neural-signature-contact.js +0 -142
  157. package/lib/models/neural-signature-extraction.d.ts +0 -17
  158. package/lib/models/neural-signature-extraction.js +0 -54
  159. package/lib/models/neural.d.ts +0 -36
  160. package/lib/models/neural.js +0 -163
  161. package/lib/models/nylas-api-error.d.ts +0 -26
  162. package/lib/models/nylas-api-error.js +0 -61
  163. package/lib/models/outbox-job-status.d.ts +0 -20
  164. package/lib/models/outbox-job-status.js +0 -64
  165. package/lib/models/outbox-message.d.ts +0 -16
  166. package/lib/models/outbox-message.js +0 -54
  167. package/lib/models/outbox.d.ts +0 -35
  168. package/lib/models/outbox.js +0 -158
  169. package/lib/models/resource.d.ts +0 -22
  170. package/lib/models/resource.js +0 -66
  171. package/lib/models/restful-model-collection.d.ts +0 -15
  172. package/lib/models/restful-model-collection.js +0 -169
  173. package/lib/models/restful-model-instance.d.ts +0 -9
  174. package/lib/models/restful-model-instance.js +0 -37
  175. package/lib/models/restful-model.d.ts +0 -36
  176. package/lib/models/restful-model.js +0 -146
  177. package/lib/models/scheduler-booking-request.d.ts +0 -64
  178. package/lib/models/scheduler-booking-request.js +0 -148
  179. package/lib/models/scheduler-restful-model-collection.d.ts +0 -26
  180. package/lib/models/scheduler-restful-model-collection.js +0 -133
  181. package/lib/models/scheduler-time-slot.d.ts +0 -20
  182. package/lib/models/scheduler-time-slot.js +0 -53
  183. package/lib/models/scheduler.d.ts +0 -226
  184. package/lib/models/scheduler.js +0 -446
  185. package/lib/models/thread.d.ts +0 -49
  186. package/lib/models/thread.js +0 -127
  187. package/lib/models/webhook-notification.d.ts +0 -108
  188. package/lib/models/webhook-notification.js +0 -239
  189. package/lib/models/webhook.d.ts +0 -50
  190. package/lib/models/webhook.js +0 -101
  191. package/lib/models/when.d.ts +0 -23
  192. package/lib/models/when.js +0 -65
  193. package/lib/nylas-connection.d.ts +0 -71
  194. package/lib/nylas-connection.js +0 -258
  195. package/lib/nylas.d.ts +0 -57
  196. package/lib/nylas.js +0 -210
  197. package/lib/server-bindings/express-binding.d.ts +0 -18
  198. package/lib/server-bindings/express-binding.js +0 -163
  199. package/lib/server-bindings/server-binding.d.ts +0 -65
  200. package/lib/server-bindings/server-binding.js +0 -87
  201. package/lib/services/routes.d.ts +0 -26
  202. package/lib/services/routes.js +0 -95
  203. package/lib/services/tunnel.d.ts +0 -29
  204. package/lib/services/tunnel.js +0 -112
@@ -1,250 +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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
27
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
28
- return new (P || (P = Promise))(function (resolve, reject) {
29
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
30
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
31
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
32
- step((generator = generator.apply(thisArg, _arguments || [])).next());
33
- });
34
- };
35
- var __generator = (this && this.__generator) || function (thisArg, body) {
36
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
37
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
38
- function verb(n) { return function (v) { return step([n, v]); }; }
39
- function step(op) {
40
- if (f) throw new TypeError("Generator is already executing.");
41
- while (_) try {
42
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
43
- if (y = 0, t) op = [op[0] & 2, t.value];
44
- switch (op[0]) {
45
- case 0: case 1: t = op; break;
46
- case 4: _.label++; return { value: op[1], done: false };
47
- case 5: _.label++; y = op[1]; op = [0]; continue;
48
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
49
- default:
50
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
51
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
52
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
53
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
54
- if (t[2]) _.ops.pop();
55
- _.trys.pop(); continue;
56
- }
57
- op = body.call(thisArg, _);
58
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
59
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
60
- }
61
- };
62
- var __rest = (this && this.__rest) || function (s, e) {
63
- var t = {};
64
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
65
- t[p] = s[p];
66
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
67
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
68
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
69
- t[p[i]] = s[p[i]];
70
- }
71
- return t;
72
- };
73
- var __importDefault = (this && this.__importDefault) || function (mod) {
74
- return (mod && mod.__esModule) ? mod : { "default": mod };
75
- };
76
- Object.defineProperty(exports, "__esModule", { value: true });
77
- /*
78
- A connection to the Nylas delta streaming API.
79
-
80
- Emits the following events:
81
- - `response` when the connection is established, with one argument, a `http.IncomingMessage`
82
- - `delta` for each delta received
83
- - `error` when an error occurs in the connection
84
- - `info` when the connection status changes
85
- */
86
- var events_1 = require("events");
87
- var nylas_connection_1 = __importDefault(require("../nylas-connection"));
88
- var node_fetch_1 = __importDefault(require("node-fetch"));
89
- var abort_controller_1 = __importDefault(require("abort-controller"));
90
- var backoff_1 = __importDefault(require("backoff"));
91
- var JSONStream_1 = __importDefault(require("JSONStream"));
92
- var delta_1 = __importDefault(require("./delta"));
93
- var deltas_1 = require("./deltas");
94
- var DeltaStream = /** @class */ (function (_super) {
95
- __extends(DeltaStream, _super);
96
- // @param {string} cursor Nylas delta API cursor
97
- // @param {Object} params object contianing query string params to be passed to the request
98
- // @param {Array<string>} params.excludeTypes object types to not return deltas for (e.g., {excludeTypes: ['thread']})
99
- // @param {Array<string>} params.includeTypes object types to exclusively return deltas for (e.g., {includeTypes: ['thread']})
100
- // @param {boolean} params.expanded boolean to specify wether to request the expanded view
101
- function DeltaStream(connection, cursor, params) {
102
- if (params === void 0) { params = {}; }
103
- var _this = _super.call(this) || this;
104
- _this.restartBackoff = backoff_1.default.exponential({
105
- randomisationFactor: 0.5,
106
- initialDelay: 250,
107
- maxDelay: 30000,
108
- factor: 4,
109
- });
110
- _this.connection = connection;
111
- _this.cursor = cursor;
112
- _this.params = params;
113
- _this.path = '/delta/streaming';
114
- _this.modelClass = delta_1.default;
115
- if (!(_this.connection instanceof nylas_connection_1.default)) {
116
- throw new Error('Connection object not provided');
117
- }
118
- _this.restartBackoff.failAfter(DeltaStream.MAX_RESTART_RETRIES);
119
- _this.restartBackoff
120
- .on('backoff', _this.restartConnection.bind(_this))
121
- .on('fail', function () {
122
- return _this.emit('error', "Nylas DeltaStream failed to reconnect after\n " + DeltaStream.MAX_RESTART_RETRIES + "\n retries.");
123
- });
124
- return _this;
125
- }
126
- DeltaStream.prototype.close = function () {
127
- clearTimeout(this.timeoutId);
128
- delete this.timeoutId;
129
- this.restartBackoff.reset();
130
- if (this.requestInfo) {
131
- this.requestInfo.controller.abort();
132
- }
133
- delete this.requestInfo;
134
- };
135
- DeltaStream.prototype.open = function (emitAsModel) {
136
- return __awaiter(this, void 0, void 0, function () {
137
- var _a, _b, excludeTypes, _c, includeTypes, params, queryObj, request, controller, response, error_1;
138
- var _this = this;
139
- return __generator(this, function (_d) {
140
- switch (_d.label) {
141
- case 0:
142
- this.close();
143
- _a = this.params, _b = _a.excludeTypes, excludeTypes = _b === void 0 ? [] : _b, _c = _a.includeTypes, includeTypes = _c === void 0 ? [] : _c, params = __rest(_a, ["excludeTypes", "includeTypes"]);
144
- queryObj = __assign(__assign({}, params), { cursor: this.cursor });
145
- if (excludeTypes.length > 0) {
146
- queryObj.exclude_types = excludeTypes.join(',');
147
- }
148
- if (includeTypes.length > 0) {
149
- queryObj.include_types = includeTypes.join(',');
150
- }
151
- request = this.connection.newRequest({
152
- method: 'GET',
153
- path: this.path,
154
- qs: queryObj,
155
- });
156
- _d.label = 1;
157
- case 1:
158
- _d.trys.push([1, 3, , 4]);
159
- controller = new abort_controller_1.default();
160
- this.requestInfo = {
161
- request: request,
162
- controller: controller,
163
- };
164
- return [4 /*yield*/, node_fetch_1.default(request, { signal: controller.signal })];
165
- case 2:
166
- response = _d.sent();
167
- if (response.status !== 200) {
168
- response.body.on('data', function (data) {
169
- var err = data;
170
- try {
171
- err = JSON.parse(err);
172
- }
173
- catch (e) {
174
- // Do nothing
175
- }
176
- // Do nothing, keep err as string.
177
- return _this.onError(err);
178
- });
179
- return [2 /*return*/];
180
- }
181
- // Successfully established connection
182
- this.emit('response', response);
183
- this.onDataReceived();
184
- return [2 /*return*/, (response.body
185
- .on('data', this.onDataReceived.bind(this))
186
- // Each data block received may not be a complete JSON object. Pipe through
187
- // JSONStream.parse(), which handles converting data blocks to JSON objects.
188
- .pipe(JSONStream_1.default.parse())
189
- .on('data', function (obj) {
190
- if (emitAsModel === true) {
191
- obj = new _this.modelClass(_this.connection).fromJSON(obj);
192
- }
193
- if (obj.cursor) {
194
- _this.cursor = obj.cursor;
195
- }
196
- return _this.emit('delta', obj);
197
- }))];
198
- case 3:
199
- error_1 = _d.sent();
200
- this.onError(error_1);
201
- return [3 /*break*/, 4];
202
- case 4: return [2 /*return*/];
203
- }
204
- });
205
- });
206
- };
207
- DeltaStream.prototype.onDataReceived = function () {
208
- // Nylas sends a newline heartbeat in the raw data stream once every 5 seconds.
209
- // Automatically restart the connection if we haven't gotten any data in
210
- // Delta.streamingTimeoutMs. The connection will restart with the last
211
- // received cursor.
212
- clearTimeout(this.timeoutId);
213
- this.restartBackoff.reset();
214
- this.timeoutId = setTimeout(this.restartBackoff.backoff.bind(this.restartBackoff), delta_1.default.streamingTimeoutMs);
215
- };
216
- DeltaStream.prototype.onError = function (err) {
217
- this.emit('error', err);
218
- return this.restartBackoff.reset();
219
- };
220
- DeltaStream.prototype.restartConnection = function (n) {
221
- this.emit('info', "Restarting Nylas DeltaStream connection (attempt " + (n + 1) + "): " + (this.requestInfo != null ? this.requestInfo.request.url : undefined));
222
- this.close();
223
- return this.open();
224
- };
225
- // Max number of times to retry a connection if we receive no data heartbeats
226
- // from the Nylas server.
227
- DeltaStream.MAX_RESTART_RETRIES = 5;
228
- return DeltaStream;
229
- }(events_1.EventEmitter));
230
- exports.default = DeltaStream;
231
- var DeltaLongPoll = /** @class */ (function (_super) {
232
- __extends(DeltaLongPoll, _super);
233
- function DeltaLongPoll(connection, cursor, timeout, params) {
234
- if (params === void 0) { params = {}; }
235
- var _this = _super.call(this, connection, cursor, params) || this;
236
- params['timeout'] = timeout;
237
- _this.params = params;
238
- _this.path = '/delta/longpoll';
239
- _this.modelClass = deltas_1.Deltas;
240
- return _this;
241
- }
242
- DeltaLongPoll.prototype.onDataReceived = function () {
243
- // For streaming we restart the connection on every data received in order
244
- // to keep the connection alive. For long polling this is not needed as the
245
- // server terminates the connection when data is sent
246
- return;
247
- };
248
- return DeltaLongPoll;
249
- }(DeltaStream));
250
- exports.DeltaLongPoll = DeltaLongPoll;
@@ -1,28 +0,0 @@
1
- import NylasConnection from '../nylas-connection';
2
- import { Attribute } from './attributes';
3
- import RestfulModel from './restful-model';
4
- export declare type DeltaParams = {
5
- view?: string;
6
- includeTypes?: string[];
7
- excludeTypes?: string[];
8
- expanded?: boolean;
9
- };
10
- export declare type DeltaProperties = {
11
- id: string;
12
- cursor: string;
13
- event: string;
14
- object: string;
15
- objectAttributes?: unknown;
16
- };
17
- export default class Delta extends RestfulModel implements DeltaProperties {
18
- id: string;
19
- cursor: string;
20
- event: string;
21
- object: string;
22
- connection: NylasConnection;
23
- objectAttributes?: RestfulModel;
24
- static streamingTimeoutMs: number;
25
- static attributes: Record<string, Attribute>;
26
- constructor(connection: NylasConnection, props?: DeltaProperties);
27
- fromJSON(json: Record<string, unknown>): this;
28
- }
@@ -1,88 +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
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
22
- result["default"] = mod;
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- var attributes_1 = __importDefault(require("./attributes"));
27
- var restful_model_1 = __importDefault(require("./restful-model"));
28
- var contact_1 = __importDefault(require("./contact"));
29
- var file_1 = __importDefault(require("./file"));
30
- var message_1 = __importDefault(require("./message"));
31
- var draft_1 = __importDefault(require("./draft"));
32
- var thread_1 = __importDefault(require("./thread"));
33
- var event_1 = __importDefault(require("./event"));
34
- var folder_1 = __importStar(require("./folder"));
35
- var DeltaClassMap = Object.freeze({
36
- contact: contact_1.default,
37
- file: file_1.default,
38
- message: message_1.default,
39
- draft: draft_1.default,
40
- thread: thread_1.default,
41
- event: event_1.default,
42
- folder: folder_1.default,
43
- label: folder_1.Label,
44
- });
45
- var Delta = /** @class */ (function (_super) {
46
- __extends(Delta, _super);
47
- function Delta(connection, props) {
48
- var _this = _super.call(this, connection) || this;
49
- _this.id = '';
50
- _this.cursor = '';
51
- _this.event = '';
52
- _this.object = '';
53
- _this.connection = connection;
54
- _this.initAttributes(props);
55
- if (_this.objectAttributes && DeltaClassMap[_this.object]) {
56
- _this.objectAttributes = new DeltaClassMap[_this.object](connection, _this.objectAttributes);
57
- }
58
- return _this;
59
- }
60
- Delta.prototype.fromJSON = function (json) {
61
- _super.prototype.fromJSON.call(this, json);
62
- if (this.objectAttributes && DeltaClassMap[this.object]) {
63
- this.objectAttributes = new DeltaClassMap[this.object](this.connection).fromJSON(this.objectAttributes);
64
- }
65
- return this;
66
- };
67
- Delta.streamingTimeoutMs = 15000;
68
- Delta.attributes = {
69
- id: attributes_1.default.String({
70
- modelKey: 'id',
71
- }),
72
- cursor: attributes_1.default.String({
73
- modelKey: 'cursor',
74
- }),
75
- event: attributes_1.default.String({
76
- modelKey: 'event',
77
- }),
78
- object: attributes_1.default.String({
79
- modelKey: 'object',
80
- }),
81
- objectAttributes: attributes_1.default.Object({
82
- modelKey: 'objectAttributes',
83
- jsonKey: 'attributes',
84
- }),
85
- };
86
- return Delta;
87
- }(restful_model_1.default));
88
- exports.default = Delta;
@@ -1,17 +0,0 @@
1
- import Model from './model';
2
- import NylasConnection from '../nylas-connection';
3
- import { Attribute } from './attributes';
4
- import Delta, { DeltaProperties } from './delta';
5
- export declare type DeltasProperties = {
6
- cursorStart: string;
7
- cursorEnd: string;
8
- deltas: DeltaProperties[];
9
- };
10
- export declare class Deltas extends Model implements DeltasProperties {
11
- cursorStart: string;
12
- cursorEnd: string;
13
- deltas: Delta[];
14
- connection: NylasConnection;
15
- static attributes: Record<string, Attribute>;
16
- constructor(connection: NylasConnection, props?: DeltasProperties);
17
- }
@@ -1,49 +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 delta_1 = __importDefault(require("./delta"));
22
- var Deltas = /** @class */ (function (_super) {
23
- __extends(Deltas, _super);
24
- function Deltas(connection, props) {
25
- var _this = _super.call(this) || this;
26
- _this.cursorStart = '';
27
- _this.cursorEnd = '';
28
- _this.deltas = [];
29
- _this.connection = connection;
30
- _this.initAttributes(props);
31
- return _this;
32
- }
33
- Deltas.attributes = {
34
- cursorStart: attributes_1.default.String({
35
- modelKey: 'cursorStart',
36
- jsonKey: 'cursor_start',
37
- }),
38
- cursorEnd: attributes_1.default.String({
39
- modelKey: 'cursorEnd',
40
- jsonKey: 'cursor_end',
41
- }),
42
- deltas: attributes_1.default.Collection({
43
- modelKey: 'deltas',
44
- itemClass: delta_1.default,
45
- }),
46
- };
47
- return Deltas;
48
- }(model_1.default));
49
- exports.Deltas = Deltas;
@@ -1,27 +0,0 @@
1
- import Message, { MessageProperties } from './message';
2
- import { Attribute } from './attributes';
3
- import { SaveCallback } from './restful-model';
4
- import NylasConnection from '../nylas-connection';
5
- export declare type SendCallback = (err: Error | null, json?: Record<string, any>) => void;
6
- export declare type DraftProperties = MessageProperties & {
7
- rawMime?: string;
8
- replyToMessageId?: string;
9
- version?: number;
10
- fileIdsToAttach?: string[];
11
- };
12
- export default class Draft extends Message implements DraftProperties {
13
- rawMime?: string;
14
- replyToMessageId?: string;
15
- version?: number;
16
- fileIdsToAttach?: string[];
17
- static collectionName: string;
18
- static attributes: Record<string, Attribute>;
19
- constructor(connection: NylasConnection, props?: DraftProperties);
20
- fileIds(): (string | undefined)[];
21
- toJSON(enforceReadOnly?: boolean): Record<string, any>;
22
- save(params?: {} | SaveCallback, callback?: SaveCallback): Promise<this>;
23
- saveRequestBody(): Record<string, unknown>;
24
- deleteRequestBody(params?: Record<string, unknown>): Record<string, unknown>;
25
- toString(): string;
26
- send(trackingArg?: Record<string, any> | SendCallback | null, callbackArg?: SendCallback | Record<string, any> | null): Promise<Message>;
27
- }
@@ -1,156 +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 attributes_1 = __importDefault(require("./attributes"));
32
- var Draft = /** @class */ (function (_super) {
33
- __extends(Draft, _super);
34
- function Draft(connection, props) {
35
- var _this = _super.call(this, connection, props) || this;
36
- _this.initAttributes(props);
37
- return _this;
38
- }
39
- Draft.prototype.fileIds = function () {
40
- var fileIds = _super.prototype.fileIds.call(this);
41
- if (this.fileIdsToAttach) {
42
- fileIds = Array.from(new Set(fileIds.concat(this.fileIdsToAttach)));
43
- }
44
- return fileIds;
45
- };
46
- Draft.prototype.toJSON = function (enforceReadOnly) {
47
- if (this.rawMime) {
48
- throw Error('toJSON() cannot be called for raw MIME drafts');
49
- }
50
- var json = _super.prototype.toJSON.call(this, enforceReadOnly);
51
- json.file_ids = this.fileIds();
52
- return json;
53
- };
54
- Draft.prototype.save = function (params, callback) {
55
- if (params === void 0) { params = {}; }
56
- if (this.rawMime) {
57
- var err = new Error('save() cannot be called for raw MIME drafts');
58
- if (callback) {
59
- callback(err);
60
- }
61
- return Promise.reject(err);
62
- }
63
- return _super.prototype.save.call(this, params, callback);
64
- };
65
- Draft.prototype.saveRequestBody = function () {
66
- if (this.rawMime) {
67
- throw Error('saveRequestBody() cannot be called for raw MIME drafts');
68
- }
69
- return _super.prototype.saveRequestBody.call(this);
70
- };
71
- Draft.prototype.deleteRequestBody = function (params) {
72
- if (params === void 0) { params = {}; }
73
- var body = {};
74
- body.version = params.hasOwnProperty('version')
75
- ? params.version
76
- : this.version;
77
- return body;
78
- };
79
- Draft.prototype.toString = function () {
80
- if (this.rawMime) {
81
- throw Error('toString() cannot be called for raw MIME drafts');
82
- }
83
- return _super.prototype.toString.call(this);
84
- };
85
- Draft.prototype.send = function (trackingArg, callbackArg) {
86
- var _this = this;
87
- // callback used to be the first argument, and tracking was the second
88
- var callback;
89
- if (typeof callbackArg === 'function') {
90
- callback = callbackArg;
91
- }
92
- else if (typeof trackingArg === 'function') {
93
- callback = trackingArg;
94
- }
95
- var tracking;
96
- if (trackingArg && typeof trackingArg === 'object') {
97
- tracking = trackingArg;
98
- }
99
- else if (callbackArg && typeof callbackArg === 'object') {
100
- tracking = callbackArg;
101
- }
102
- var body = this.rawMime, headers = { 'Content-Type': 'message/rfc822' }, json = false;
103
- if (!this.rawMime) {
104
- headers = {};
105
- json = true;
106
- if (this.id) {
107
- body = {
108
- draft_id: this.id,
109
- version: this.version,
110
- };
111
- }
112
- else {
113
- body = this.saveRequestBody();
114
- }
115
- if (tracking) {
116
- body['tracking'] = tracking;
117
- }
118
- }
119
- return this.connection
120
- .request({
121
- method: 'POST',
122
- path: '/send',
123
- headers: headers,
124
- body: body,
125
- json: json,
126
- })
127
- .then(function (json) {
128
- var message = new message_1.default(_this.connection).fromJSON(json);
129
- if (callback) {
130
- callback(null, message);
131
- }
132
- return Promise.resolve(message);
133
- })
134
- .catch(function (err) {
135
- if (callback) {
136
- callback(err);
137
- }
138
- return Promise.reject(err);
139
- });
140
- };
141
- Draft.collectionName = 'drafts';
142
- Draft.attributes = __assign(__assign({}, message_1.default.attributes), { version: attributes_1.default.Number({
143
- modelKey: 'version',
144
- }), replyToMessageId: attributes_1.default.String({
145
- modelKey: 'replyToMessageId',
146
- jsonKey: 'reply_to_message_id',
147
- }), rawMime: attributes_1.default.String({
148
- modelKey: 'rawMime',
149
- readOnly: true,
150
- }), fileIdsToAttach: attributes_1.default.StringList({
151
- modelKey: 'fileIdsToAttach',
152
- readOnly: true,
153
- }) });
154
- return Draft;
155
- }(message_1.default));
156
- exports.default = Draft;
@@ -1,13 +0,0 @@
1
- import { Attribute } from './attributes';
2
- import Model from './model';
3
- export declare type EmailParticipantProperties = {
4
- email: string;
5
- name?: string;
6
- };
7
- export default class EmailParticipant extends Model implements EmailParticipantProperties {
8
- email: string;
9
- name?: string;
10
- static attributes: Record<string, Attribute>;
11
- constructor(props?: EmailParticipantProperties);
12
- toJSON(): Record<string, unknown>;
13
- }
@@ -1,46 +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 EmailParticipant = /** @class */ (function (_super) {
22
- __extends(EmailParticipant, _super);
23
- function EmailParticipant(props) {
24
- var _this = _super.call(this) || this;
25
- _this.email = '';
26
- _this.initAttributes(props);
27
- return _this;
28
- }
29
- EmailParticipant.prototype.toJSON = function () {
30
- var json = _super.prototype.toJSON.call(this);
31
- if (!json['name']) {
32
- json['name'] = json['email'];
33
- }
34
- return json;
35
- };
36
- EmailParticipant.attributes = {
37
- name: attributes_1.default.String({
38
- modelKey: 'name',
39
- }),
40
- email: attributes_1.default.String({
41
- modelKey: 'email',
42
- }),
43
- };
44
- return EmailParticipant;
45
- }(model_1.default));
46
- exports.default = EmailParticipant;