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.
Files changed (197) hide show
  1. package/README.md +26 -14
  2. package/lib/cjs/apiClient.js +115 -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/resources/applications.js +30 -0
  17. package/lib/cjs/resources/auth.js +153 -0
  18. package/lib/cjs/resources/calendars.js +78 -0
  19. package/lib/cjs/resources/events.js +69 -0
  20. package/lib/cjs/resources/grants.js +65 -0
  21. package/lib/cjs/resources/redirectUris.js +64 -0
  22. package/lib/cjs/resources/resource.js +111 -0
  23. package/lib/cjs/resources/webhooks.js +98 -0
  24. package/lib/cjs/utils.js +58 -0
  25. package/lib/esm/apiClient.js +112 -0
  26. package/lib/esm/config.js +29 -0
  27. package/lib/esm/models/applicationDetails.js +1 -0
  28. package/lib/esm/models/auth.js +1 -0
  29. package/lib/esm/models/availability.js +8 -0
  30. package/lib/esm/models/calendars.js +1 -0
  31. package/lib/esm/models/error.js +45 -0
  32. package/lib/esm/models/events.js +1 -0
  33. package/lib/esm/models/grants.js +1 -0
  34. package/lib/esm/models/listQueryParams.js +1 -0
  35. package/lib/esm/models/redirectUri.js +1 -0
  36. package/lib/esm/models/response.js +1 -0
  37. package/lib/esm/models/webhooks.js +15 -0
  38. package/lib/esm/nylas.js +31 -0
  39. package/lib/esm/resources/applications.js +26 -0
  40. package/lib/esm/resources/auth.js +149 -0
  41. package/lib/esm/resources/calendars.js +74 -0
  42. package/lib/esm/resources/events.js +65 -0
  43. package/lib/esm/resources/grants.js +61 -0
  44. package/lib/esm/resources/redirectUris.js +60 -0
  45. package/lib/esm/resources/resource.js +107 -0
  46. package/lib/esm/resources/webhooks.js +94 -0
  47. package/lib/esm/utils.js +53 -0
  48. package/lib/types/apiClient.d.ts +65 -0
  49. package/lib/types/config.d.ts +50 -0
  50. package/lib/types/models/applicationDetails.d.ts +93 -0
  51. package/lib/types/models/auth.d.ts +196 -0
  52. package/lib/types/models/availability.d.ts +159 -0
  53. package/lib/types/models/calendars.d.ts +121 -0
  54. package/lib/types/models/error.d.ts +104 -0
  55. package/lib/types/models/events.d.ts +494 -0
  56. package/lib/types/models/grants.d.ts +134 -0
  57. package/lib/types/models/listQueryParams.d.ts +4 -0
  58. package/lib/types/models/redirectUri.d.ts +71 -0
  59. package/lib/types/models/response.d.ts +40 -0
  60. package/lib/types/models/webhooks.d.ts +45 -0
  61. package/lib/types/nylas.d.ts +44 -0
  62. package/lib/types/resources/applications.d.ts +26 -0
  63. package/lib/types/resources/auth.d.ts +66 -0
  64. package/lib/types/resources/calendars.d.ts +97 -0
  65. package/lib/types/resources/events.d.ts +87 -0
  66. package/lib/types/resources/grants.d.ts +63 -0
  67. package/lib/types/resources/redirectUris.d.ts +63 -0
  68. package/lib/types/resources/resource.d.ts +55 -0
  69. package/lib/types/resources/webhooks.d.ts +79 -0
  70. package/lib/types/utils.d.ts +22 -0
  71. package/package.json +28 -39
  72. package/lib/config.d.ts +0 -52
  73. package/lib/config.js +0 -47
  74. package/lib/models/access-token.d.ts +0 -18
  75. package/lib/models/access-token.js +0 -56
  76. package/lib/models/account.d.ts +0 -27
  77. package/lib/models/account.js +0 -73
  78. package/lib/models/application-details.d.ts +0 -14
  79. package/lib/models/application-details.js +0 -47
  80. package/lib/models/attributes.d.ts +0 -151
  81. package/lib/models/attributes.js +0 -382
  82. package/lib/models/calendar-availability.d.ts +0 -76
  83. package/lib/models/calendar-availability.js +0 -121
  84. package/lib/models/calendar-restful-model-collection.d.ts +0 -17
  85. package/lib/models/calendar-restful-model-collection.js +0 -181
  86. package/lib/models/calendar.d.ts +0 -33
  87. package/lib/models/calendar.js +0 -97
  88. package/lib/models/component-restful-model-collection.d.ts +0 -9
  89. package/lib/models/component-restful-model-collection.js +0 -34
  90. package/lib/models/component.d.ts +0 -37
  91. package/lib/models/component.js +0 -91
  92. package/lib/models/connect.d.ts +0 -73
  93. package/lib/models/connect.js +0 -193
  94. package/lib/models/contact-restful-model-collection.d.ts +0 -9
  95. package/lib/models/contact-restful-model-collection.js +0 -60
  96. package/lib/models/contact.d.ts +0 -129
  97. package/lib/models/contact.js +0 -289
  98. package/lib/models/delta-collection.d.ts +0 -17
  99. package/lib/models/delta-collection.js +0 -139
  100. package/lib/models/delta-stream.d.ts +0 -32
  101. package/lib/models/delta-stream.js +0 -250
  102. package/lib/models/delta.d.ts +0 -28
  103. package/lib/models/delta.js +0 -88
  104. package/lib/models/deltas.d.ts +0 -17
  105. package/lib/models/deltas.js +0 -49
  106. package/lib/models/draft.d.ts +0 -27
  107. package/lib/models/draft.js +0 -156
  108. package/lib/models/email-participant.d.ts +0 -13
  109. package/lib/models/email-participant.js +0 -46
  110. package/lib/models/event-conferencing.d.ts +0 -34
  111. package/lib/models/event-conferencing.js +0 -71
  112. package/lib/models/event-notification.d.ts +0 -27
  113. package/lib/models/event-notification.js +0 -62
  114. package/lib/models/event-participant.d.ts +0 -19
  115. package/lib/models/event-participant.js +0 -56
  116. package/lib/models/event-reminder-method.d.ts +0 -18
  117. package/lib/models/event-reminder-method.js +0 -47
  118. package/lib/models/event.d.ts +0 -104
  119. package/lib/models/event.js +0 -308
  120. package/lib/models/file.d.ts +0 -29
  121. package/lib/models/file.js +0 -136
  122. package/lib/models/folder.d.ts +0 -21
  123. package/lib/models/folder.js +0 -69
  124. package/lib/models/free-busy.d.ts +0 -58
  125. package/lib/models/free-busy.js +0 -132
  126. package/lib/models/job-status-restful-model-collection.d.ts +0 -9
  127. package/lib/models/job-status-restful-model-collection.js +0 -38
  128. package/lib/models/job-status.d.ts +0 -24
  129. package/lib/models/job-status.js +0 -68
  130. package/lib/models/management-account.d.ts +0 -63
  131. package/lib/models/management-account.js +0 -187
  132. package/lib/models/management-model-collection.d.ts +0 -10
  133. package/lib/models/management-model-collection.js +0 -39
  134. package/lib/models/management-model.d.ts +0 -6
  135. package/lib/models/management-model.js +0 -29
  136. package/lib/models/message-restful-model-collection.d.ts +0 -26
  137. package/lib/models/message-restful-model-collection.js +0 -80
  138. package/lib/models/message.d.ts +0 -57
  139. package/lib/models/message.js +0 -173
  140. package/lib/models/model-collection.d.ts +0 -25
  141. package/lib/models/model-collection.js +0 -201
  142. package/lib/models/model.d.ts +0 -12
  143. package/lib/models/model.js +0 -64
  144. package/lib/models/neural-categorizer.d.ts +0 -28
  145. package/lib/models/neural-categorizer.js +0 -139
  146. package/lib/models/neural-clean-conversation.d.ts +0 -16
  147. package/lib/models/neural-clean-conversation.js +0 -114
  148. package/lib/models/neural-ocr.d.ts +0 -14
  149. package/lib/models/neural-ocr.js +0 -50
  150. package/lib/models/neural-sentiment-analysis.d.ts +0 -20
  151. package/lib/models/neural-sentiment-analysis.js +0 -56
  152. package/lib/models/neural-signature-contact.d.ts +0 -43
  153. package/lib/models/neural-signature-contact.js +0 -142
  154. package/lib/models/neural-signature-extraction.d.ts +0 -17
  155. package/lib/models/neural-signature-extraction.js +0 -54
  156. package/lib/models/neural.d.ts +0 -36
  157. package/lib/models/neural.js +0 -163
  158. package/lib/models/nylas-api-error.d.ts +0 -26
  159. package/lib/models/nylas-api-error.js +0 -62
  160. package/lib/models/outbox-job-status.d.ts +0 -20
  161. package/lib/models/outbox-job-status.js +0 -64
  162. package/lib/models/outbox-message.d.ts +0 -16
  163. package/lib/models/outbox-message.js +0 -54
  164. package/lib/models/outbox.d.ts +0 -35
  165. package/lib/models/outbox.js +0 -158
  166. package/lib/models/rate-limit-error.d.ts +0 -26
  167. package/lib/models/rate-limit-error.js +0 -47
  168. package/lib/models/resource.d.ts +0 -22
  169. package/lib/models/resource.js +0 -66
  170. package/lib/models/restful-model-collection.d.ts +0 -15
  171. package/lib/models/restful-model-collection.js +0 -169
  172. package/lib/models/restful-model-instance.d.ts +0 -9
  173. package/lib/models/restful-model-instance.js +0 -37
  174. package/lib/models/restful-model.d.ts +0 -36
  175. package/lib/models/restful-model.js +0 -146
  176. package/lib/models/scheduler-booking-request.d.ts +0 -64
  177. package/lib/models/scheduler-booking-request.js +0 -148
  178. package/lib/models/scheduler-restful-model-collection.d.ts +0 -26
  179. package/lib/models/scheduler-restful-model-collection.js +0 -133
  180. package/lib/models/scheduler-time-slot.d.ts +0 -20
  181. package/lib/models/scheduler-time-slot.js +0 -53
  182. package/lib/models/scheduler.d.ts +0 -226
  183. package/lib/models/scheduler.js +0 -446
  184. package/lib/models/thread.d.ts +0 -49
  185. package/lib/models/thread.js +0 -127
  186. package/lib/models/webhook-notification.d.ts +0 -133
  187. package/lib/models/webhook-notification.js +0 -314
  188. package/lib/models/webhook.d.ts +0 -50
  189. package/lib/models/webhook.js +0 -101
  190. package/lib/models/when.d.ts +0 -29
  191. package/lib/models/when.js +0 -76
  192. package/lib/nylas-connection.d.ts +0 -71
  193. package/lib/nylas-connection.js +0 -282
  194. package/lib/nylas.d.ts +0 -34
  195. package/lib/nylas.js +0 -199
  196. package/lib/services/tunnel.d.ts +0 -28
  197. package/lib/services/tunnel.js +0 -89
@@ -1,36 +0,0 @@
1
- import RestfulModel from './restful-model';
2
- import NeuralSentimentAnalysis from './neural-sentiment-analysis';
3
- import NeuralSignatureExtraction from './neural-signature-extraction';
4
- import NeuralOcr from './neural-ocr';
5
- import NeuralCategorizer from './neural-categorizer';
6
- import NeuralCleanConversation from './neural-clean-conversation';
7
- import Model from './model';
8
- import { Attribute } from './attributes';
9
- export declare type NeuralMessageOptionsProperties = {
10
- ignoreLinks?: boolean;
11
- ignoreImages?: boolean;
12
- ignoreTables?: boolean;
13
- removeConclusionPhrases?: boolean;
14
- imagesAsMarkdown?: boolean;
15
- parseContacts?: boolean;
16
- };
17
- export declare class NeuralMessageOptions extends Model implements NeuralMessageOptionsProperties {
18
- ignoreLinks?: boolean;
19
- ignoreImages?: boolean;
20
- ignoreTables?: boolean;
21
- removeConclusionPhrases?: boolean;
22
- imagesAsMarkdown?: boolean;
23
- parseContacts?: boolean;
24
- static attributes: Record<string, Attribute>;
25
- constructor(props?: NeuralMessageOptionsProperties);
26
- toJSON(writeParseContact?: boolean): Record<string, boolean>;
27
- }
28
- export default class Neural extends RestfulModel {
29
- sentimentAnalysisMessage(messageIds: string[]): Promise<NeuralSentimentAnalysis[]>;
30
- sentimentAnalysisText(text: string): Promise<NeuralSentimentAnalysis>;
31
- extractSignature(messageIds: string[], options?: NeuralMessageOptionsProperties): Promise<NeuralSignatureExtraction[]>;
32
- ocrRequest(fileId: string, pages?: number[]): Promise<NeuralOcr>;
33
- categorize(messageIds: string[]): Promise<NeuralCategorizer[]>;
34
- cleanConversation(messageIds: string[], options?: NeuralMessageOptionsProperties): Promise<NeuralCleanConversation[]>;
35
- private request;
36
- }
@@ -1,163 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- extendStatics(d, b);
11
- function __() { this.constructor = d; }
12
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
- };
14
- })();
15
- var __assign = (this && this.__assign) || function () {
16
- __assign = Object.assign || function(t) {
17
- for (var s, i = 1, n = arguments.length; i < n; i++) {
18
- s = arguments[i];
19
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
20
- t[p] = s[p];
21
- }
22
- return t;
23
- };
24
- return __assign.apply(this, arguments);
25
- };
26
- var __importDefault = (this && this.__importDefault) || function (mod) {
27
- return (mod && mod.__esModule) ? mod : { "default": mod };
28
- };
29
- Object.defineProperty(exports, "__esModule", { value: true });
30
- var restful_model_1 = __importDefault(require("./restful-model"));
31
- var neural_sentiment_analysis_1 = __importDefault(require("./neural-sentiment-analysis"));
32
- var neural_signature_extraction_1 = __importDefault(require("./neural-signature-extraction"));
33
- var neural_ocr_1 = __importDefault(require("./neural-ocr"));
34
- var neural_categorizer_1 = __importDefault(require("./neural-categorizer"));
35
- var neural_clean_conversation_1 = __importDefault(require("./neural-clean-conversation"));
36
- var model_1 = __importDefault(require("./model"));
37
- var attributes_1 = __importDefault(require("./attributes"));
38
- var NeuralMessageOptions = /** @class */ (function (_super) {
39
- __extends(NeuralMessageOptions, _super);
40
- function NeuralMessageOptions(props) {
41
- var _this = _super.call(this) || this;
42
- _this.initAttributes(props);
43
- return _this;
44
- }
45
- NeuralMessageOptions.prototype.toJSON = function (writeParseContact) {
46
- var body = _super.prototype.toJSON.call(this);
47
- if (writeParseContact !== true) {
48
- delete body['parse_contacts'];
49
- }
50
- return body;
51
- };
52
- NeuralMessageOptions.attributes = {
53
- ignoreLinks: attributes_1.default.Boolean({
54
- modelKey: 'ignoreLinks',
55
- jsonKey: 'ignore_links',
56
- }),
57
- ignoreImages: attributes_1.default.Boolean({
58
- modelKey: 'ignoreImages',
59
- jsonKey: 'ignore_images',
60
- }),
61
- ignoreTables: attributes_1.default.Boolean({
62
- modelKey: 'ignoreTables',
63
- jsonKey: 'ignore_tables',
64
- }),
65
- removeConclusionPhrases: attributes_1.default.Boolean({
66
- modelKey: 'removeConclusionPhrases',
67
- jsonKey: 'remove_conclusion_phrases',
68
- }),
69
- imagesAsMarkdown: attributes_1.default.Boolean({
70
- modelKey: 'imagesAsMarkdown',
71
- jsonKey: 'images_as_markdown',
72
- }),
73
- parseContacts: attributes_1.default.Boolean({
74
- modelKey: 'parseContacts',
75
- jsonKey: 'parse_contacts',
76
- }),
77
- };
78
- return NeuralMessageOptions;
79
- }(model_1.default));
80
- exports.NeuralMessageOptions = NeuralMessageOptions;
81
- var Neural = /** @class */ (function (_super) {
82
- __extends(Neural, _super);
83
- function Neural() {
84
- return _super !== null && _super.apply(this, arguments) || this;
85
- }
86
- Neural.prototype.sentimentAnalysisMessage = function (messageIds) {
87
- var _this = this;
88
- var body = { message_id: messageIds };
89
- var path = 'sentiment';
90
- return this.request(path, body).then(function (jsonArray) {
91
- return jsonArray.map(function (json) {
92
- return new neural_sentiment_analysis_1.default(_this.connection).fromJSON(json);
93
- });
94
- });
95
- };
96
- Neural.prototype.sentimentAnalysisText = function (text) {
97
- var _this = this;
98
- var body = { text: text };
99
- var path = 'sentiment';
100
- return this.request(path, body).then(function (json) {
101
- return new neural_sentiment_analysis_1.default(_this.connection).fromJSON(json);
102
- });
103
- };
104
- Neural.prototype.extractSignature = function (messageIds, options) {
105
- var _this = this;
106
- var body = { message_id: messageIds };
107
- var path = 'signature';
108
- if (options) {
109
- body = __assign(__assign({}, body), new NeuralMessageOptions(options).toJSON(true));
110
- }
111
- return this.request(path, body).then(function (jsonArray) {
112
- return jsonArray.map(function (json) {
113
- return new neural_signature_extraction_1.default(_this.connection).fromJSON(json);
114
- });
115
- });
116
- };
117
- Neural.prototype.ocrRequest = function (fileId, pages) {
118
- var _this = this;
119
- var body = { file_id: fileId };
120
- var path = 'ocr';
121
- if (pages) {
122
- body['pages'] = pages;
123
- }
124
- return this.request(path, body).then(function (json) {
125
- return new neural_ocr_1.default(_this.connection).fromJSON(json);
126
- });
127
- };
128
- Neural.prototype.categorize = function (messageIds) {
129
- var _this = this;
130
- var body = { message_id: messageIds };
131
- var path = 'categorize';
132
- return this.request(path, body).then(function (jsonArray) {
133
- return jsonArray.map(function (json) {
134
- return new neural_categorizer_1.default(_this.connection).fromJSON(json);
135
- });
136
- });
137
- };
138
- Neural.prototype.cleanConversation = function (messageIds, options) {
139
- var _this = this;
140
- var body = { message_id: messageIds };
141
- var path = 'conversation';
142
- if (options) {
143
- body = __assign(__assign({}, body), options);
144
- }
145
- return this.request(path, body).then(function (jsonArray) {
146
- return jsonArray.map(function (json) {
147
- return new neural_clean_conversation_1.default(_this.connection).fromJSON(json);
148
- });
149
- });
150
- };
151
- Neural.prototype.request = function (path, body) {
152
- return this.connection.request({
153
- method: 'PUT',
154
- path: "/neural/" + path,
155
- body: body,
156
- headers: {
157
- 'Content-Type': 'application/json',
158
- },
159
- });
160
- };
161
- return Neural;
162
- }(restful_model_1.default));
163
- exports.default = Neural;
@@ -1,26 +0,0 @@
1
- /**
2
- * Extended Error class for errors returned from the Nylas API
3
- *
4
- * Properties:
5
- * name - The description of the HTTP status code
6
- * message - The error message returned from the Nylas API payload
7
- * statusCode - The status code returned from the API call
8
- * type - The type of error returned from the Nylas API payload
9
- * stack - The Error stacktrace
10
- * missingFields (optional) - The fields that were missing in the call returned from the Nylas API payload
11
- * serverError (optional) - The error returned by the provider returned from the Nylas API payload
12
- */
13
- export default class NylasApiError extends Error {
14
- statusCode: number;
15
- type: string;
16
- missingFields?: string[];
17
- serverError?: string;
18
- /**
19
- * Mapping of HTTP status codes to error descriptions
20
- *
21
- * For more details on what each status code means head to
22
- * https://developer.nylas.com/docs/developer-tools/api/errors/
23
- */
24
- errorMapping: Record<number, string>;
25
- constructor(statusCode: number, type: string, message: string);
26
- }
@@ -1,62 +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
- Object.defineProperty(exports, "__esModule", { value: true });
16
- /**
17
- * Extended Error class for errors returned from the Nylas API
18
- *
19
- * Properties:
20
- * name - The description of the HTTP status code
21
- * message - The error message returned from the Nylas API payload
22
- * statusCode - The status code returned from the API call
23
- * type - The type of error returned from the Nylas API payload
24
- * stack - The Error stacktrace
25
- * missingFields (optional) - The fields that were missing in the call returned from the Nylas API payload
26
- * serverError (optional) - The error returned by the provider returned from the Nylas API payload
27
- */
28
- var NylasApiError = /** @class */ (function (_super) {
29
- __extends(NylasApiError, _super);
30
- function NylasApiError(statusCode, type, message) {
31
- var _this = _super.call(this, message) || this;
32
- /**
33
- * Mapping of HTTP status codes to error descriptions
34
- *
35
- * For more details on what each status code means head to
36
- * https://developer.nylas.com/docs/developer-tools/api/errors/
37
- */
38
- _this.errorMapping = {
39
- 400: 'Bad Request',
40
- 401: 'Unauthorized',
41
- 402: 'Request Failed or Payment Required',
42
- 403: 'Forbidden',
43
- 404: 'Not Found',
44
- 405: 'Method Not Allowed',
45
- 409: 'Conflict',
46
- 410: 'Gone',
47
- 418: "I'm a Teapot",
48
- 422: 'Sending Error',
49
- 429: 'Too Many Requests',
50
- 500: 'Server Error',
51
- 502: 'Server Error',
52
- 503: 'Server Error',
53
- 504: 'Server Error',
54
- };
55
- _this.statusCode = statusCode;
56
- _this.name = _this.errorMapping[statusCode];
57
- _this.type = type;
58
- return _this;
59
- }
60
- return NylasApiError;
61
- }(Error));
62
- exports.default = NylasApiError;
@@ -1,20 +0,0 @@
1
- import OutboxMessage, { OutboxMessageProperties } from './outbox-message';
2
- import { Attribute } from './attributes';
3
- import NylasConnection from '../nylas-connection';
4
- import JobStatus, { JobStatusProperties } from './job-status';
5
- export declare type OutboxJobStatusProperties = JobStatusProperties & {
6
- messageId?: string;
7
- threadId?: string;
8
- sendAt?: Date;
9
- originalSendAt?: Date;
10
- originalData?: OutboxMessageProperties;
11
- };
12
- export default class OutboxJobStatus extends JobStatus implements OutboxJobStatusProperties {
13
- messageId?: string;
14
- threadId?: string;
15
- sendAt?: Date;
16
- originalSendAt?: Date;
17
- originalData?: OutboxMessage;
18
- static attributes: Record<string, Attribute>;
19
- constructor(connection: NylasConnection, props?: OutboxJobStatusProperties);
20
- }
@@ -1,64 +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 outbox_message_1 = __importDefault(require("./outbox-message"));
31
- var attributes_1 = __importDefault(require("./attributes"));
32
- var job_status_1 = __importDefault(require("./job-status"));
33
- var OutboxJobStatus = /** @class */ (function (_super) {
34
- __extends(OutboxJobStatus, _super);
35
- function OutboxJobStatus(connection, props) {
36
- var _this = _super.call(this, connection, props) || this;
37
- _this.initAttributes(props);
38
- return _this;
39
- }
40
- OutboxJobStatus.attributes = __assign(__assign({}, job_status_1.default.attributes), { messageId: attributes_1.default.String({
41
- modelKey: 'messageId',
42
- jsonKey: 'message_id',
43
- readOnly: true,
44
- }), threadId: attributes_1.default.String({
45
- modelKey: 'threadId',
46
- jsonKey: 'thread_id',
47
- readOnly: true,
48
- }), sendAt: attributes_1.default.DateTime({
49
- modelKey: 'sendAt',
50
- jsonKey: 'send_at',
51
- readOnly: true,
52
- }), originalSendAt: attributes_1.default.DateTime({
53
- modelKey: 'originalSendAt',
54
- jsonKey: 'original_send_at',
55
- readOnly: true,
56
- }), originalData: attributes_1.default.Object({
57
- modelKey: 'originalData',
58
- jsonKey: 'original_data',
59
- itemClass: outbox_message_1.default,
60
- readOnly: true,
61
- }) });
62
- return OutboxJobStatus;
63
- }(job_status_1.default));
64
- exports.default = OutboxJobStatus;
@@ -1,16 +0,0 @@
1
- import Draft, { DraftProperties } from './draft';
2
- import { Attribute } from './attributes';
3
- import NylasConnection from '../nylas-connection';
4
- export declare type OutboxMessageProperties = DraftProperties & {
5
- sendAt: Date;
6
- retryLimitDatetime?: Date;
7
- originalSendAt?: Date;
8
- };
9
- export default class OutboxMessage extends Draft implements OutboxMessageProperties {
10
- sendAt: Date;
11
- retryLimitDatetime?: Date;
12
- originalSendAt?: Date;
13
- static collectionName: string;
14
- static attributes: Record<string, Attribute>;
15
- constructor(connection: NylasConnection, props?: OutboxMessageProperties);
16
- }
@@ -1,54 +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 draft_1 = __importDefault(require("./draft"));
31
- var attributes_1 = __importDefault(require("./attributes"));
32
- var OutboxMessage = /** @class */ (function (_super) {
33
- __extends(OutboxMessage, _super);
34
- function OutboxMessage(connection, props) {
35
- var _this = _super.call(this, connection, props) || this;
36
- _this.sendAt = new Date();
37
- _this.initAttributes(props);
38
- return _this;
39
- }
40
- OutboxMessage.collectionName = '/v2/outbox';
41
- OutboxMessage.attributes = __assign(__assign({}, draft_1.default.attributes), { sendAt: attributes_1.default.DateTime({
42
- modelKey: 'sendAt',
43
- jsonKey: 'send_at',
44
- }), retryLimitDatetime: attributes_1.default.DateTime({
45
- modelKey: 'retryLimitDatetime',
46
- jsonKey: 'retry_limit_datetime',
47
- }), originalSendAt: attributes_1.default.DateTime({
48
- modelKey: 'originalSendAt',
49
- jsonKey: 'original_send_at',
50
- readOnly: true,
51
- }) });
52
- return OutboxMessage;
53
- }(draft_1.default));
54
- exports.default = OutboxMessage;
@@ -1,35 +0,0 @@
1
- import NylasConnection from '../nylas-connection';
2
- import Draft, { SendCallback } from './draft';
3
- import OutboxJobStatus from './outbox-job-status';
4
- import Model from './model';
5
- import { Attribute } from './attributes';
6
- declare type SendParams = {
7
- sendAt: Date | number;
8
- retryLimitDatetime?: Date | number;
9
- tracking?: Record<string, any>;
10
- callback?: SendCallback;
11
- };
12
- declare type UpdateParams = {
13
- updatedMessage?: Draft;
14
- sendAt?: Date | number;
15
- retryLimitDatetime?: Date | number;
16
- };
17
- export declare class SendGridVerifiedStatus extends Model {
18
- domainVerified?: boolean;
19
- senderVerified?: boolean;
20
- static attributes: Record<string, Attribute>;
21
- }
22
- export default class Outbox {
23
- connection: NylasConnection;
24
- private path;
25
- constructor(connection: NylasConnection);
26
- send(draft: Draft, options: SendParams): Promise<OutboxJobStatus>;
27
- update(jobStatusId: string, options: UpdateParams): Promise<OutboxJobStatus>;
28
- delete(jobStatusId: string): Promise<void>;
29
- sendGridVerificationStatus(): Promise<SendGridVerifiedStatus>;
30
- deleteSendGridSubUser(email: string): Promise<void>;
31
- private request;
32
- private static validateAndFormatDateTime;
33
- private static dateToEpoch;
34
- }
35
- export {};
@@ -1,158 +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_connection_1 = require("../nylas-connection");
20
- var outbox_job_status_1 = __importDefault(require("./outbox-job-status"));
21
- var model_1 = __importDefault(require("./model"));
22
- var attributes_1 = __importDefault(require("./attributes"));
23
- var SendGridVerifiedStatus = /** @class */ (function (_super) {
24
- __extends(SendGridVerifiedStatus, _super);
25
- function SendGridVerifiedStatus() {
26
- return _super !== null && _super.apply(this, arguments) || this;
27
- }
28
- SendGridVerifiedStatus.attributes = {
29
- domainVerified: attributes_1.default.Boolean({
30
- modelKey: 'domainVerified',
31
- jsonKey: 'domain_verified',
32
- }),
33
- senderVerified: attributes_1.default.Boolean({
34
- modelKey: 'senderVerified',
35
- jsonKey: 'sender_verified',
36
- }),
37
- };
38
- return SendGridVerifiedStatus;
39
- }(model_1.default));
40
- exports.SendGridVerifiedStatus = SendGridVerifiedStatus;
41
- var Outbox = /** @class */ (function () {
42
- function Outbox(connection) {
43
- this.path = '/v2/outbox';
44
- this.connection = connection;
45
- }
46
- Outbox.prototype.send = function (draft, options) {
47
- var _this = this;
48
- var body = draft.saveRequestBody();
49
- if (options.tracking) {
50
- body['tracking'] = options.tracking;
51
- }
52
- var _a = Outbox.validateAndFormatDateTime(options.sendAt, options.retryLimitDatetime), sendAt = _a[0], retryLimitDatetime = _a[1];
53
- body['send_at'] = sendAt;
54
- body['retry_limit_datetime'] = retryLimitDatetime;
55
- return this.request({
56
- method: 'POST',
57
- path: '',
58
- body: body,
59
- })
60
- .then(function (json) {
61
- var message = new outbox_job_status_1.default(_this.connection).fromJSON(json);
62
- if (options.callback) {
63
- options.callback(null, message);
64
- }
65
- return Promise.resolve(message);
66
- })
67
- .catch(function (err) {
68
- if (options.callback) {
69
- options.callback(err);
70
- }
71
- return Promise.reject(err);
72
- });
73
- };
74
- Outbox.prototype.update = function (jobStatusId, options) {
75
- var _this = this;
76
- var body = {};
77
- if (options.updatedMessage) {
78
- body = options.updatedMessage.saveRequestBody();
79
- }
80
- var _a = Outbox.validateAndFormatDateTime(options.sendAt, options.retryLimitDatetime), sendAt = _a[0], retryLimitDatetime = _a[1];
81
- body['send_at'] = sendAt;
82
- body['retry_limit_datetime'] = retryLimitDatetime;
83
- return this.request({
84
- method: 'PATCH',
85
- path: "/" + jobStatusId,
86
- body: body,
87
- }).then(function (json) {
88
- var message = new outbox_job_status_1.default(_this.connection).fromJSON(json);
89
- return Promise.resolve(message);
90
- });
91
- };
92
- Outbox.prototype.delete = function (jobStatusId) {
93
- return this.request({
94
- method: 'DELETE',
95
- path: "/" + jobStatusId,
96
- });
97
- };
98
- Outbox.prototype.sendGridVerificationStatus = function () {
99
- return this.request({
100
- method: 'GET',
101
- path: "/onboard/verified_status",
102
- }).then(function (json) {
103
- if (json.results) {
104
- json = json.results;
105
- }
106
- var verifiedStatus = new SendGridVerifiedStatus().fromJSON(json);
107
- return Promise.resolve(verifiedStatus);
108
- });
109
- };
110
- Outbox.prototype.deleteSendGridSubUser = function (email) {
111
- return this.request({
112
- method: 'DELETE',
113
- path: "/onboard/subuser",
114
- body: { email: email },
115
- });
116
- };
117
- Outbox.prototype.request = function (options) {
118
- var header;
119
- if (options.body) {
120
- header = {
121
- 'Content-Type': 'application/json',
122
- };
123
- }
124
- return this.connection.request({
125
- method: options.method,
126
- path: "" + this.path + options.path,
127
- body: options.body,
128
- headers: header,
129
- authMethod: nylas_connection_1.AuthMethod.BEARER,
130
- });
131
- };
132
- Outbox.validateAndFormatDateTime = function (sendAt, retryLimitDatetime) {
133
- var sendAtEpoch = sendAt instanceof Date ? Outbox.dateToEpoch(sendAt) : sendAt;
134
- var retryLimitDatetimeEpoch = retryLimitDatetime instanceof Date
135
- ? Outbox.dateToEpoch(retryLimitDatetime)
136
- : retryLimitDatetime;
137
- if (sendAtEpoch && sendAtEpoch !== 0) {
138
- if (sendAtEpoch < Outbox.dateToEpoch(new Date())) {
139
- throw new Error('Cannot set message to be sent at a time before the current time.');
140
- }
141
- }
142
- if (retryLimitDatetimeEpoch && retryLimitDatetimeEpoch !== 0) {
143
- var validSendAt = sendAtEpoch;
144
- if (!validSendAt || validSendAt === 0) {
145
- validSendAt = Outbox.dateToEpoch(new Date());
146
- }
147
- if (retryLimitDatetimeEpoch < validSendAt) {
148
- throw new Error('Cannot set message to stop retrying before time to send at.');
149
- }
150
- }
151
- return [sendAtEpoch, retryLimitDatetimeEpoch];
152
- };
153
- Outbox.dateToEpoch = function (date) {
154
- return Math.floor(date.getTime() / 1000.0);
155
- };
156
- return Outbox;
157
- }());
158
- exports.default = Outbox;
@@ -1,26 +0,0 @@
1
- import NylasApiError from './nylas-api-error';
2
- import { Headers } from 'node-fetch';
3
- /**
4
- * This error class represents a 429 error response, with details on the rate limit
5
- */
6
- export default class RateLimitError extends NylasApiError {
7
- static RATE_LIMIT_STATUS_CODE: number;
8
- static RATE_LIMIT_LIMIT_HEADER: string;
9
- static RATE_LIMIT_RESET_HEADER: string;
10
- /**
11
- * The rate limit
12
- */
13
- rateLimit?: number;
14
- /**
15
- * The rate limit expiration time, in seconds
16
- */
17
- rateLimitReset?: number;
18
- constructor(type: string, message: string, rateLimit?: number, rateLimitReset?: number);
19
- /**
20
- * Parses an API response and generates a 429 error with details filled in
21
- * @param parsedApiError The response parsed as a JSON
22
- * @param headers The response headers
23
- * @return The error with the rate limit details filled in
24
- */
25
- static parseErrorResponse(parsedApiError: Record<string, string>, headers: Headers): RateLimitError;
26
- }