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,187 +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 management_model_1 = __importDefault(require("./management-model"));
31
- var attributes_1 = __importDefault(require("./attributes"));
32
- var model_1 = __importDefault(require("./model"));
33
- var ApplicationIPAddresses = /** @class */ (function (_super) {
34
- __extends(ApplicationIPAddresses, _super);
35
- function ApplicationIPAddresses(props) {
36
- var _this = _super.call(this) || this;
37
- _this.ipAddresses = [];
38
- _this.updatedAt = 0;
39
- _this.initAttributes(props);
40
- return _this;
41
- }
42
- ApplicationIPAddresses.attributes = {
43
- ipAddresses: attributes_1.default.StringList({
44
- modelKey: 'ipAddresses',
45
- jsonKey: 'ip_addresses',
46
- }),
47
- updatedAt: attributes_1.default.Number({
48
- modelKey: 'updatedAt',
49
- jsonKey: 'updated_at',
50
- }),
51
- };
52
- return ApplicationIPAddresses;
53
- }(model_1.default));
54
- exports.ApplicationIPAddresses = ApplicationIPAddresses;
55
- var AccountTokenInfo = /** @class */ (function (_super) {
56
- __extends(AccountTokenInfo, _super);
57
- function AccountTokenInfo(props) {
58
- var _this = _super.call(this) || this;
59
- _this.scopes = '';
60
- _this.state = '';
61
- _this.createdAt = 0;
62
- _this.updatedAt = 0;
63
- _this.initAttributes(props);
64
- return _this;
65
- }
66
- AccountTokenInfo.attributes = {
67
- scopes: attributes_1.default.String({
68
- modelKey: 'scopes',
69
- }),
70
- state: attributes_1.default.String({
71
- modelKey: 'state',
72
- }),
73
- createdAt: attributes_1.default.Number({
74
- modelKey: 'createdAt',
75
- jsonKey: 'created_at',
76
- }),
77
- updatedAt: attributes_1.default.Number({
78
- modelKey: 'updatedAt',
79
- jsonKey: 'updated_at',
80
- }),
81
- };
82
- return AccountTokenInfo;
83
- }(model_1.default));
84
- exports.AccountTokenInfo = AccountTokenInfo;
85
- var ManagementAccount = /** @class */ (function (_super) {
86
- __extends(ManagementAccount, _super);
87
- function ManagementAccount(connection, clientId, props) {
88
- var _this = _super.call(this, connection, clientId, props) || this;
89
- _this.billingState = '';
90
- _this.emailAddress = '';
91
- _this.namespaceId = '';
92
- _this.provider = '';
93
- _this.syncState = '';
94
- _this.authenticationType = '';
95
- _this.trial = false;
96
- _this.initAttributes(props);
97
- return _this;
98
- }
99
- ManagementAccount.prototype.upgrade = function () {
100
- return this.connection
101
- .request({
102
- method: 'POST',
103
- path: "/a/" + this.clientId + "/" + this.constructor.collectionName + "/" + this.id + "/upgrade",
104
- })
105
- .then(function (json) { return Promise.resolve(json); })
106
- .catch(function (err) { return Promise.reject(err); });
107
- };
108
- ManagementAccount.prototype.downgrade = function () {
109
- return this.connection
110
- .request({
111
- method: 'POST',
112
- path: "/a/" + this.clientId + "/" + this.constructor.collectionName + "/" + this.id + "/downgrade",
113
- })
114
- .then(function (json) { return Promise.resolve(json); })
115
- .catch(function (err) { return Promise.reject(err); });
116
- };
117
- ManagementAccount.prototype.revokeAll = function (keepAccessToken) {
118
- return this.connection
119
- .request({
120
- method: 'POST',
121
- path: "/a/" + this.clientId + "/" + this.constructor.collectionName + "/" + this.id + "/revoke-all",
122
- body: { keep_access_token: keepAccessToken },
123
- })
124
- .then(function (json) { return Promise.resolve(json); })
125
- .catch(function (err) { return Promise.reject(err); });
126
- };
127
- ManagementAccount.prototype.ipAddresses = function () {
128
- return this.connection
129
- .request({
130
- method: 'GET',
131
- path: "/a/" + this.clientId + "/ip_addresses",
132
- })
133
- .then(function (json) {
134
- return Promise.resolve(new ApplicationIPAddresses().fromJSON(json));
135
- })
136
- .catch(function (err) { return Promise.reject(err); });
137
- };
138
- ManagementAccount.prototype.tokenInfo = function (accessToken) {
139
- return this.connection
140
- .request({
141
- method: 'POST',
142
- path: "/a/" + this.clientId + "/" + this.constructor.collectionName + "/" + this.id + "/token-info",
143
- body: {
144
- access_token: accessToken,
145
- },
146
- })
147
- .then(function (json) { return Promise.resolve(new AccountTokenInfo().fromJSON(json)); })
148
- .catch(function (err) { return Promise.reject(err); });
149
- };
150
- ManagementAccount.prototype.save = function (params, callback) {
151
- if (params === void 0) { params = {}; }
152
- return _super.prototype.save.call(this, params, callback);
153
- };
154
- ManagementAccount.prototype.saveRequestBody = function () {
155
- return {
156
- metadata: this.metadata,
157
- };
158
- };
159
- ManagementAccount.prototype.saveEndpoint = function () {
160
- return "/a/" + this.connection.clientId + "/accounts";
161
- };
162
- ManagementAccount.collectionName = 'accounts';
163
- ManagementAccount.attributes = __assign(__assign({}, management_model_1.default.attributes), { billingState: attributes_1.default.String({
164
- modelKey: 'billingState',
165
- jsonKey: 'billing_state',
166
- }), emailAddress: attributes_1.default.String({
167
- modelKey: 'emailAddress',
168
- jsonKey: 'email',
169
- }), namespaceId: attributes_1.default.String({
170
- modelKey: 'namespaceId',
171
- jsonKey: 'namespace_id',
172
- }), provider: attributes_1.default.String({
173
- modelKey: 'provider',
174
- }), syncState: attributes_1.default.String({
175
- modelKey: 'syncState',
176
- jsonKey: 'sync_state',
177
- }), authenticationType: attributes_1.default.String({
178
- modelKey: 'authenticationType',
179
- jsonKey: 'authentication_type',
180
- }), trial: attributes_1.default.Boolean({
181
- modelKey: 'trial',
182
- }), metadata: attributes_1.default.Object({
183
- modelKey: 'metadata',
184
- }) });
185
- return ManagementAccount;
186
- }(management_model_1.default));
187
- exports.default = ManagementAccount;
@@ -1,10 +0,0 @@
1
- import ManagementModel from './management-model';
2
- import NylasConnection from '../nylas-connection';
3
- import RestfulModelCollection from './restful-model-collection';
4
- export default class ManagementModelCollection<T extends ManagementModel> extends RestfulModelCollection<T> {
5
- clientId: string;
6
- constructor(modelClass: typeof ManagementModel, connection: NylasConnection, clientId: string);
7
- build(args: Record<string, unknown>): T;
8
- path(): string;
9
- protected createModel(json: Record<string, unknown>): T;
10
- }
@@ -1,39 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- extendStatics(d, b);
11
- function __() { this.constructor = d; }
12
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
- };
14
- })();
15
- var __importDefault = (this && this.__importDefault) || function (mod) {
16
- return (mod && mod.__esModule) ? mod : { "default": mod };
17
- };
18
- Object.defineProperty(exports, "__esModule", { value: true });
19
- var restful_model_collection_1 = __importDefault(require("./restful-model-collection"));
20
- var ManagementModelCollection = /** @class */ (function (_super) {
21
- __extends(ManagementModelCollection, _super);
22
- function ManagementModelCollection(modelClass, connection, clientId) {
23
- var _this = _super.call(this, modelClass, connection) || this;
24
- _this.clientId = clientId;
25
- return _this;
26
- }
27
- ManagementModelCollection.prototype.build = function (args) {
28
- return _super.prototype.build.call(this, args);
29
- };
30
- ManagementModelCollection.prototype.path = function () {
31
- return "/a/" + this.clientId + "/" + this.modelClass.collectionName;
32
- };
33
- ManagementModelCollection.prototype.createModel = function (json) {
34
- var props = this.modelClass.propsFromJSON(json, this);
35
- return new this.modelClass(this.connection, this.clientId, props);
36
- };
37
- return ManagementModelCollection;
38
- }(restful_model_collection_1.default));
39
- exports.default = ManagementModelCollection;
@@ -1,6 +0,0 @@
1
- import RestfulModel from './restful-model';
2
- import NylasConnection from '../nylas-connection';
3
- export default class ManagementModel extends RestfulModel {
4
- clientId: string;
5
- constructor(connection: NylasConnection, clientId: string, props: Record<string, unknown>);
6
- }
@@ -1,29 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- extendStatics(d, b);
11
- function __() { this.constructor = d; }
12
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
- };
14
- })();
15
- var __importDefault = (this && this.__importDefault) || function (mod) {
16
- return (mod && mod.__esModule) ? mod : { "default": mod };
17
- };
18
- Object.defineProperty(exports, "__esModule", { value: true });
19
- var restful_model_1 = __importDefault(require("./restful-model"));
20
- var ManagementModel = /** @class */ (function (_super) {
21
- __extends(ManagementModel, _super);
22
- function ManagementModel(connection, clientId, props) {
23
- var _this = _super.call(this, connection, props) || this;
24
- _this.clientId = clientId;
25
- return _this;
26
- }
27
- return ManagementModel;
28
- }(restful_model_1.default));
29
- exports.default = ManagementModel;
@@ -1,26 +0,0 @@
1
- import RestfulModelCollection from './restful-model-collection';
2
- import Message from './message';
3
- import NylasConnection from '../nylas-connection';
4
- export default class MessageRestfulModelCollection extends RestfulModelCollection<Message> {
5
- connection: NylasConnection;
6
- modelClass: typeof Message;
7
- constructor(connection: NylasConnection);
8
- /**
9
- * Return Multiple Messages by a list of Message IDs.
10
- * @param messageIds The list of message ids to find.
11
- * @param options Additional options including: view, offset, limit, and callback
12
- * @returns The list of messages.
13
- */
14
- findMultiple(messageIds: string[], options?: {
15
- view?: string;
16
- offset?: number;
17
- limit?: number;
18
- callback?: (error: Error | null, results?: Message[]) => void;
19
- }): Promise<Message[]>;
20
- /**
21
- * Return raw message contents
22
- * @param messageId The message to fetch content of
23
- * @returns The raw message contents
24
- */
25
- findRaw(messageId: string): Promise<string>;
26
- }
@@ -1,80 +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_collection_1 = __importDefault(require("./restful-model-collection"));
31
- var message_1 = __importDefault(require("./message"));
32
- var MessageRestfulModelCollection = /** @class */ (function (_super) {
33
- __extends(MessageRestfulModelCollection, _super);
34
- function MessageRestfulModelCollection(connection) {
35
- var _this = _super.call(this, message_1.default, connection) || this;
36
- _this.connection = connection;
37
- _this.modelClass = message_1.default;
38
- return _this;
39
- }
40
- /**
41
- * Return Multiple Messages by a list of Message IDs.
42
- * @param messageIds The list of message ids to find.
43
- * @param options Additional options including: view, offset, limit, and callback
44
- * @returns The list of messages.
45
- */
46
- MessageRestfulModelCollection.prototype.findMultiple = function (messageIds, options) {
47
- if (options && options.view) {
48
- // view is a parameter, so move it into a params object
49
- options.params = {
50
- view: options.view,
51
- };
52
- delete options.view;
53
- }
54
- // If only one message ID was passed in, use the normal find function
55
- if (messageIds.length == 1) {
56
- return this.find(messageIds[0], options).then(function (message) {
57
- return [message];
58
- });
59
- }
60
- return this.range(__assign({ path: this.path() + "/" + messageIds.join() }, options));
61
- };
62
- /**
63
- * Return raw message contents
64
- * @param messageId The message to fetch content of
65
- * @returns The raw message contents
66
- */
67
- MessageRestfulModelCollection.prototype.findRaw = function (messageId) {
68
- return this.connection
69
- .request({
70
- method: 'GET',
71
- headers: {
72
- Accept: 'message/rfc822',
73
- },
74
- path: this.path() + "/" + messageId,
75
- })
76
- .catch(function (err) { return Promise.reject(err); });
77
- };
78
- return MessageRestfulModelCollection;
79
- }(restful_model_collection_1.default));
80
- exports.default = MessageRestfulModelCollection;
@@ -1,57 +0,0 @@
1
- import RestfulModel, { SaveCallback } from './restful-model';
2
- import { Attribute } from './attributes';
3
- import File, { FileProperties } from './file';
4
- import Event, { EventProperties } from './event';
5
- import EmailParticipant, { EmailParticipantProperties } from './email-participant';
6
- import Folder, { Label, FolderProperties } from './folder';
7
- import NylasConnection from '../nylas-connection';
8
- export declare type MessageProperties = {
9
- to: EmailParticipantProperties[];
10
- subject?: string;
11
- from?: EmailParticipantProperties[];
12
- replyTo?: EmailParticipantProperties[];
13
- cc?: EmailParticipantProperties[];
14
- bcc?: EmailParticipantProperties[];
15
- date?: Date;
16
- threadId?: string;
17
- snippet?: string;
18
- body?: string;
19
- unread?: boolean;
20
- starred?: boolean;
21
- files?: FileProperties[];
22
- events?: EventProperties[];
23
- folder?: Folder;
24
- labels?: FolderProperties[];
25
- headers?: Record<string, string>;
26
- metadata?: object;
27
- jobStatusId?: string;
28
- };
29
- export default class Message extends RestfulModel implements MessageProperties {
30
- to: EmailParticipant[];
31
- subject?: string;
32
- from?: EmailParticipant[];
33
- replyTo?: EmailParticipant[];
34
- cc?: EmailParticipant[];
35
- bcc?: EmailParticipant[];
36
- date?: Date;
37
- threadId?: string;
38
- snippet?: string;
39
- body?: string;
40
- unread?: boolean;
41
- starred?: boolean;
42
- files?: File[];
43
- events?: Event[];
44
- folder?: Folder;
45
- labels?: Label[];
46
- headers?: Record<string, string>;
47
- metadata?: object;
48
- jobStatusId?: string;
49
- static collectionName: string;
50
- static attributes: Record<string, Attribute>;
51
- constructor(connection: NylasConnection, props?: MessageProperties);
52
- participants(): EmailParticipant[];
53
- fileIds(): (string | undefined)[];
54
- getRaw(): Promise<string>;
55
- saveRequestBody(): Record<string, unknown>;
56
- save(params?: {} | SaveCallback, callback?: SaveCallback): Promise<this>;
57
- }
@@ -1,173 +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 __spreadArrays = (this && this.__spreadArrays) || function () {
27
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
28
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
29
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
30
- r[k] = a[j];
31
- return r;
32
- };
33
- var __importDefault = (this && this.__importDefault) || function (mod) {
34
- return (mod && mod.__esModule) ? mod : { "default": mod };
35
- };
36
- var __importStar = (this && this.__importStar) || function (mod) {
37
- if (mod && mod.__esModule) return mod;
38
- var result = {};
39
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
40
- result["default"] = mod;
41
- return result;
42
- };
43
- Object.defineProperty(exports, "__esModule", { value: true });
44
- var restful_model_1 = __importDefault(require("./restful-model"));
45
- var attributes_1 = __importDefault(require("./attributes"));
46
- var file_1 = __importDefault(require("./file"));
47
- var event_1 = __importDefault(require("./event"));
48
- var email_participant_1 = __importDefault(require("./email-participant"));
49
- var folder_1 = __importStar(require("./folder"));
50
- var Message = /** @class */ (function (_super) {
51
- __extends(Message, _super);
52
- function Message(connection, props) {
53
- var _this = _super.call(this, connection, props) || this;
54
- _this.to = [];
55
- _this.initAttributes(props);
56
- return _this;
57
- }
58
- // We calculate the list of participants instead of grabbing it from
59
- // a parent because it is a better source of ground truth, and saves us
60
- // from more dependencies.
61
- Message.prototype.participants = function () {
62
- var participants = {};
63
- var to = this.to || [];
64
- var cc = this.cc || [];
65
- var from = this.from || [];
66
- var contacts = Array.from(new Set(__spreadArrays(to, cc, from)));
67
- for (var _i = 0, contacts_1 = contacts; _i < contacts_1.length; _i++) {
68
- var contact = contacts_1[_i];
69
- if (contact && (contact.email ? contact.email.length : '') > 0) {
70
- participants[(contact.email || ''.toLowerCase().trim()) + " " + (contact.name || '')
71
- .toLowerCase()
72
- .trim()] = new email_participant_1.default(contact);
73
- }
74
- }
75
- return Object.values(participants);
76
- };
77
- Message.prototype.fileIds = function () {
78
- return this.files ? this.files.map(function (file) { return file.id; }) : [];
79
- };
80
- Message.prototype.getRaw = function () {
81
- return this.connection
82
- .request({
83
- method: 'GET',
84
- headers: {
85
- Accept: 'message/rfc822',
86
- },
87
- path: "/" + Message.collectionName + "/" + this.id,
88
- })
89
- .catch(function (err) { return Promise.reject(err); });
90
- };
91
- Message.prototype.saveRequestBody = function () {
92
- // It's possible to update most of the fields of a draft.
93
- if (this.constructor.name === 'Draft') {
94
- return _super.prototype.saveRequestBody.call(this);
95
- }
96
- // Messages are more limited, though.
97
- var json = {};
98
- if (this.labels) {
99
- json['label_ids'] = Array.from(this.labels).map(function (label) { return label.id; });
100
- }
101
- else if (this.folder) {
102
- json['folder_id'] = this.folder.id;
103
- }
104
- json['starred'] = this.starred;
105
- json['unread'] = this.unread;
106
- json['metadata'] = this.metadata;
107
- return json;
108
- };
109
- Message.prototype.save = function (params, callback) {
110
- if (params === void 0) { params = {}; }
111
- // A Message can only be updated
112
- if (this.constructor.name === 'Message' && !this.id) {
113
- throw new Error('Cannot create a message. Please create and send a draft instead.');
114
- }
115
- return _super.prototype.save.call(this, params, callback);
116
- };
117
- Message.collectionName = 'messages';
118
- Message.attributes = __assign(__assign({}, restful_model_1.default.attributes), { subject: attributes_1.default.String({
119
- modelKey: 'subject',
120
- }), from: attributes_1.default.Collection({
121
- modelKey: 'from',
122
- itemClass: email_participant_1.default,
123
- }), replyTo: attributes_1.default.Collection({
124
- modelKey: 'replyTo',
125
- jsonKey: 'reply_to',
126
- itemClass: email_participant_1.default,
127
- }), to: attributes_1.default.Collection({
128
- modelKey: 'to',
129
- itemClass: email_participant_1.default,
130
- }), cc: attributes_1.default.Collection({
131
- modelKey: 'cc',
132
- itemClass: email_participant_1.default,
133
- }), bcc: attributes_1.default.Collection({
134
- modelKey: 'bcc',
135
- itemClass: email_participant_1.default,
136
- }), date: attributes_1.default.DateTime({
137
- modelKey: 'date',
138
- }), threadId: attributes_1.default.String({
139
- modelKey: 'threadId',
140
- jsonKey: 'thread_id',
141
- }), snippet: attributes_1.default.String({
142
- modelKey: 'snippet',
143
- }), body: attributes_1.default.String({
144
- modelKey: 'body',
145
- }), unread: attributes_1.default.Boolean({
146
- modelKey: 'unread',
147
- }), starred: attributes_1.default.Boolean({
148
- modelKey: 'starred',
149
- }), files: attributes_1.default.Collection({
150
- modelKey: 'files',
151
- itemClass: file_1.default,
152
- readOnly: true,
153
- }), events: attributes_1.default.Collection({
154
- modelKey: 'events',
155
- itemClass: event_1.default,
156
- }), folder: attributes_1.default.Object({
157
- modelKey: 'folder',
158
- itemClass: folder_1.default,
159
- }), labels: attributes_1.default.Collection({
160
- modelKey: 'labels',
161
- itemClass: folder_1.Label,
162
- }), metadata: attributes_1.default.Object({
163
- modelKey: 'metadata',
164
- }), headers: attributes_1.default.Object({
165
- modelKey: 'headers',
166
- }), jobStatusId: attributes_1.default.String({
167
- modelKey: 'jobStatusId',
168
- jsonKey: 'job_status_id',
169
- readOnly: true,
170
- }) });
171
- return Message;
172
- }(restful_model_1.default));
173
- exports.default = Message;
@@ -1,25 +0,0 @@
1
- import NylasConnection from '../nylas-connection';
2
- import Model from './model';
3
- export declare type GetCallback = (error: Error | null, result?: Model) => void;
4
- export default class ModelCollection<T extends Model> {
5
- connection: NylasConnection;
6
- modelClass: any;
7
- _path: string;
8
- baseUrl?: string;
9
- constructor(modelClass: any, connection: NylasConnection, path: string);
10
- forEach(params: Record<string, unknown> | undefined, eachCallback: (item: T) => void, completeCallback?: (err?: Error | null | undefined) => void): void;
11
- list(params?: Record<string, unknown>, callback?: (error: Error | null, obj?: T[]) => void): Promise<T[]>;
12
- find(id: string, paramsArg?: Record<string, unknown> | GetCallback | null, callbackArg?: GetCallback | Record<string, unknown> | null): Promise<T>;
13
- path(): string;
14
- protected range({ params, offset, limit, callback, path, }: {
15
- params?: Record<string, unknown>;
16
- offset?: number;
17
- limit?: number;
18
- callback?: (error: Error | null, results?: T[]) => void;
19
- path?: string;
20
- }): Promise<T[]>;
21
- protected getItems(params: Record<string, unknown>, offset: number, limit: number, path?: string): Promise<T[]>;
22
- protected createModel(json: Record<string, unknown>): T;
23
- private getModel;
24
- private getModelCollection;
25
- }