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,201 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- var REQUEST_CHUNK_SIZE = 100;
15
- var ModelCollection = /** @class */ (function () {
16
- function ModelCollection(modelClass, connection, path) {
17
- this.modelClass = modelClass;
18
- this.connection = connection;
19
- this._path = path;
20
- if (!this.connection) {
21
- throw new Error('Connection object not provided');
22
- }
23
- if (!this.modelClass) {
24
- throw new Error('Model class not provided');
25
- }
26
- }
27
- ModelCollection.prototype.forEach = function (params, eachCallback, completeCallback) {
28
- var _this = this;
29
- if (params === void 0) { params = {}; }
30
- if (params.view == 'count') {
31
- var err = new Error('forEach() cannot be called with the count view');
32
- if (completeCallback) {
33
- completeCallback(err);
34
- }
35
- throw err;
36
- }
37
- var offset = 0;
38
- var iteratee = function () {
39
- return _this.getItems(params, offset, REQUEST_CHUNK_SIZE).then(function (items) {
40
- for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
41
- var item = items_1[_i];
42
- eachCallback(item);
43
- }
44
- offset += items.length;
45
- var finished = items.length < REQUEST_CHUNK_SIZE;
46
- if (!finished) {
47
- return iteratee();
48
- }
49
- });
50
- };
51
- iteratee().then(function () {
52
- if (completeCallback) {
53
- completeCallback();
54
- }
55
- }, function (err) {
56
- if (completeCallback) {
57
- return completeCallback(err);
58
- }
59
- });
60
- };
61
- ModelCollection.prototype.list = function (params, callback) {
62
- if (params === void 0) { params = {}; }
63
- if (params.view == 'count') {
64
- var err = new Error('list() cannot be called with the count view');
65
- if (callback) {
66
- callback(err);
67
- }
68
- return Promise.reject(err);
69
- }
70
- var limit = params.limit || Infinity;
71
- var offset = params.offset;
72
- return this.range({ params: params, offset: offset, limit: limit, callback: callback });
73
- };
74
- ModelCollection.prototype.find = function (id, paramsArg, callbackArg) {
75
- // callback used to be the second argument, and params was the third
76
- var callback;
77
- if (typeof callbackArg === 'function') {
78
- callback = callbackArg;
79
- }
80
- else if (typeof paramsArg === 'function') {
81
- callback = paramsArg;
82
- }
83
- var params = {};
84
- if (paramsArg && typeof paramsArg === 'object') {
85
- params = paramsArg;
86
- }
87
- else if (callbackArg && typeof callbackArg === 'object') {
88
- params = callbackArg;
89
- }
90
- if (!id) {
91
- var err = new Error('find() must be called with an item id');
92
- if (callback) {
93
- callback(err);
94
- }
95
- return Promise.reject(err);
96
- }
97
- if (params.view == 'count' || params.view == 'ids') {
98
- var err = new Error('find() cannot be called with the count or ids view');
99
- if (callback) {
100
- callback(err);
101
- }
102
- return Promise.reject(err);
103
- }
104
- return this.getModel(id, params)
105
- .then(function (model) {
106
- if (callback) {
107
- callback(null, model);
108
- }
109
- return Promise.resolve(model);
110
- })
111
- .catch(function (err) {
112
- if (callback) {
113
- callback(err);
114
- }
115
- return Promise.reject(err);
116
- });
117
- };
118
- ModelCollection.prototype.path = function () {
119
- return this._path;
120
- };
121
- ModelCollection.prototype.range = function (_a) {
122
- var _this = this;
123
- var _b = _a.params, params = _b === void 0 ? {} : _b, _c = _a.offset, offset = _c === void 0 ? 0 : _c, _d = _a.limit, limit = _d === void 0 ? 100 : _d, callback = _a.callback, path = _a.path;
124
- var accumulated = [];
125
- var iteratee = function () {
126
- var chunkOffset = offset + accumulated.length;
127
- var chunkLimit = Math.min(REQUEST_CHUNK_SIZE, limit - accumulated.length);
128
- return _this.getItems(params, chunkOffset, chunkLimit, path).then(function (items) {
129
- accumulated = accumulated.concat(items);
130
- var finished = items.length < REQUEST_CHUNK_SIZE || accumulated.length >= limit;
131
- if (!finished) {
132
- return iteratee();
133
- }
134
- });
135
- };
136
- // do not return rejected promise when callback is provided
137
- // to prevent unhandled rejection warning
138
- return iteratee().then(function () {
139
- if (callback) {
140
- callback(null, accumulated);
141
- }
142
- return accumulated;
143
- }, function (err) {
144
- if (callback) {
145
- callback(err);
146
- }
147
- throw err;
148
- });
149
- };
150
- ModelCollection.prototype.getItems = function (params, offset, limit, path) {
151
- // Items can be either models or ids
152
- if (!path) {
153
- path = this.path();
154
- }
155
- if (params.view == 'ids') {
156
- return this.connection.request({
157
- method: 'GET',
158
- path: path,
159
- qs: __assign(__assign({}, params), { offset: offset, limit: limit }),
160
- baseUrl: this.baseUrl,
161
- });
162
- }
163
- return this.getModelCollection(params, offset, limit, path);
164
- };
165
- ModelCollection.prototype.createModel = function (json) {
166
- return new this.modelClass().fromJSON(json);
167
- };
168
- ModelCollection.prototype.getModel = function (id, params) {
169
- var _this = this;
170
- if (params === void 0) { params = {}; }
171
- return this.connection
172
- .request({
173
- method: 'GET',
174
- path: this.path() + "/" + id,
175
- qs: params,
176
- baseUrl: this.baseUrl,
177
- })
178
- .then(function (json) {
179
- var model = _this.createModel(json);
180
- return Promise.resolve(model);
181
- });
182
- };
183
- ModelCollection.prototype.getModelCollection = function (params, offset, limit, path) {
184
- var _this = this;
185
- return this.connection
186
- .request({
187
- method: 'GET',
188
- path: path,
189
- qs: __assign(__assign({}, params), { offset: offset, limit: limit }),
190
- baseUrl: this.baseUrl,
191
- })
192
- .then(function (jsonArray) {
193
- var models = jsonArray.map(function (json) {
194
- return _this.createModel(json);
195
- });
196
- return Promise.resolve(models);
197
- });
198
- };
199
- return ModelCollection;
200
- }());
201
- exports.default = ModelCollection;
@@ -1,12 +0,0 @@
1
- import { Attribute } from './attributes';
2
- export declare type SaveCallback = (error: Error | null, result?: any) => void;
3
- export default class Model {
4
- static attributes: Record<string, Attribute>;
5
- static propsFromJSON(json: Record<string, unknown>, parent: unknown): Record<string, unknown>;
6
- attributes(): Record<string, Attribute>;
7
- initAttributes(props?: Record<string, unknown>): void;
8
- fromJSON(json: Record<string, unknown>): this;
9
- toJSON(enforceReadOnly?: boolean): Record<string, unknown>;
10
- saveRequestBody(): Record<string, unknown>;
11
- toString(): string;
12
- }
@@ -1,64 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var Model = /** @class */ (function () {
4
- function Model() {
5
- }
6
- Model.propsFromJSON = function (json, parent) {
7
- var props = {};
8
- for (var attrName in this.attributes) {
9
- var attr = this.attributes[attrName];
10
- if (json[attr.jsonKey] !== undefined) {
11
- props[attrName] = attr.fromJSON(json[attr.jsonKey], parent);
12
- }
13
- }
14
- return props;
15
- };
16
- Model.prototype.attributes = function () {
17
- return this.constructor.attributes;
18
- };
19
- Model.prototype.initAttributes = function (props) {
20
- var attributes = this.attributes();
21
- for (var prop in props) {
22
- if (props.hasOwnProperty(prop)) {
23
- var attr = attributes[prop];
24
- if (attr) {
25
- this[prop] = attr.fromJSON(props[prop], this);
26
- }
27
- }
28
- }
29
- };
30
- Model.prototype.fromJSON = function (json) {
31
- var attributes = this.attributes();
32
- for (var attrName in attributes) {
33
- var attr = attributes[attrName];
34
- if (json[attr.jsonKey] !== undefined) {
35
- this[attrName] = attr.fromJSON(json[attr.jsonKey], this);
36
- }
37
- }
38
- return this;
39
- };
40
- Model.prototype.toJSON = function (enforceReadOnly) {
41
- var json = {};
42
- var attributes = this.attributes();
43
- for (var attrName in attributes) {
44
- var attr = attributes[attrName];
45
- if (enforceReadOnly === true) {
46
- json[attr.jsonKey] = attr.saveRequestBody(this[attrName]);
47
- }
48
- else {
49
- json[attr.jsonKey] = attr.toJSON(this[attrName]);
50
- }
51
- }
52
- return json;
53
- };
54
- // saveRequestBody is used by save(). It returns a JSON dict containing only the
55
- // fields the API allows updating. Subclasses should override this method.
56
- Model.prototype.saveRequestBody = function () {
57
- return this.toJSON(true);
58
- };
59
- Model.prototype.toString = function () {
60
- return JSON.stringify(this.toJSON());
61
- };
62
- return Model;
63
- }());
64
- exports.default = Model;
@@ -1,28 +0,0 @@
1
- import { Attribute } from './attributes';
2
- import Message, { MessageProperties } from './message';
3
- import Model from './model';
4
- import NylasConnection from '../nylas-connection';
5
- export declare type CategorizeProperties = {
6
- category: string;
7
- categorizedAt: Date;
8
- modelVersion: string;
9
- subcategories: string[];
10
- };
11
- export declare class Categorize extends Model implements CategorizeProperties {
12
- category: string;
13
- categorizedAt: Date;
14
- modelVersion: string;
15
- subcategories: string[];
16
- static attributes: Record<string, Attribute>;
17
- constructor(props?: CategorizeProperties);
18
- }
19
- export declare type NeuralCategorizerProperties = MessageProperties & {
20
- categorizer: Categorize;
21
- };
22
- export default class NeuralCategorizer extends Message implements NeuralCategorizerProperties {
23
- categorizer: Categorize;
24
- static collectionName: string;
25
- static attributes: Record<string, Attribute>;
26
- constructor(connection: NylasConnection, props?: NeuralCategorizerProperties);
27
- reCategorize(category: string): Promise<NeuralCategorizer>;
28
- }
@@ -1,139 +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 __importDefault = (this && this.__importDefault) || function (mod) {
63
- return (mod && mod.__esModule) ? mod : { "default": mod };
64
- };
65
- Object.defineProperty(exports, "__esModule", { value: true });
66
- var attributes_1 = __importDefault(require("./attributes"));
67
- var message_1 = __importDefault(require("./message"));
68
- var model_1 = __importDefault(require("./model"));
69
- var Categorize = /** @class */ (function (_super) {
70
- __extends(Categorize, _super);
71
- function Categorize(props) {
72
- var _this = _super.call(this) || this;
73
- _this.category = '';
74
- _this.categorizedAt = new Date();
75
- _this.modelVersion = '';
76
- _this.subcategories = [];
77
- _this.initAttributes(props);
78
- return _this;
79
- }
80
- Categorize.attributes = {
81
- category: attributes_1.default.String({
82
- modelKey: 'category',
83
- }),
84
- categorizedAt: attributes_1.default.DateTime({
85
- modelKey: 'categorizedAt',
86
- jsonKey: 'categorized_at',
87
- }),
88
- modelVersion: attributes_1.default.String({
89
- modelKey: 'modelVersion',
90
- jsonKey: 'model_version',
91
- }),
92
- subcategories: attributes_1.default.StringList({
93
- modelKey: 'subcategories',
94
- }),
95
- };
96
- return Categorize;
97
- }(model_1.default));
98
- exports.Categorize = Categorize;
99
- var NeuralCategorizer = /** @class */ (function (_super) {
100
- __extends(NeuralCategorizer, _super);
101
- function NeuralCategorizer(connection, props) {
102
- var _this = _super.call(this, connection, props) || this;
103
- _this.categorizer = new Categorize();
104
- _this.initAttributes(props);
105
- return _this;
106
- }
107
- NeuralCategorizer.prototype.reCategorize = function (category) {
108
- var _this = this;
109
- return this.connection
110
- .request({
111
- method: 'POST',
112
- path: '/neural/categorize/feedback',
113
- body: { message_id: this.id, category: category },
114
- headers: {
115
- 'Content-Type': 'application/json',
116
- },
117
- })
118
- .then(function (json) { return __awaiter(_this, void 0, void 0, function () {
119
- var categorizeResponse;
120
- return __generator(this, function (_a) {
121
- switch (_a.label) {
122
- case 0: return [4 /*yield*/, this.connection.neural.categorize([
123
- json['message_id'],
124
- ])];
125
- case 1:
126
- categorizeResponse = _a.sent();
127
- return [2 /*return*/, categorizeResponse[0]];
128
- }
129
- });
130
- }); });
131
- };
132
- NeuralCategorizer.collectionName = 'categorizer';
133
- NeuralCategorizer.attributes = __assign(__assign({}, message_1.default.attributes), { categorizer: attributes_1.default.Object({
134
- modelKey: 'categorizer',
135
- itemClass: Categorize,
136
- }) });
137
- return NeuralCategorizer;
138
- }(message_1.default));
139
- exports.default = NeuralCategorizer;
@@ -1,16 +0,0 @@
1
- import Message, { MessageProperties } from './message';
2
- import { Attribute } from './attributes';
3
- import File from './file';
4
- import NylasConnection from '../nylas-connection';
5
- export declare type NeuralCleanConversationProperties = MessageProperties & {
6
- conversation: string;
7
- modelVersion: string;
8
- };
9
- export default class NeuralCleanConversation extends Message implements NeuralCleanConversationProperties {
10
- conversation: string;
11
- modelVersion: string;
12
- static collectionName: string;
13
- static attributes: Record<string, Attribute>;
14
- constructor(connection: NylasConnection, props?: NeuralCleanConversationProperties);
15
- extractImages(): Promise<File[]>;
16
- }
@@ -1,114 +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 __importDefault = (this && this.__importDefault) || function (mod) {
63
- return (mod && mod.__esModule) ? mod : { "default": mod };
64
- };
65
- Object.defineProperty(exports, "__esModule", { value: true });
66
- var message_1 = __importDefault(require("./message"));
67
- var attributes_1 = __importDefault(require("./attributes"));
68
- var IMAGE_REGEX = /[(']cid:(.)*[)']/g;
69
- var NeuralCleanConversation = /** @class */ (function (_super) {
70
- __extends(NeuralCleanConversation, _super);
71
- function NeuralCleanConversation(connection, props) {
72
- var _this = _super.call(this, connection, props) || this;
73
- _this.conversation = '';
74
- _this.modelVersion = '';
75
- _this.initAttributes(props);
76
- return _this;
77
- }
78
- NeuralCleanConversation.prototype.extractImages = function () {
79
- var _this = this;
80
- var f = [];
81
- if (this.conversation) {
82
- var fileIds = this.conversation.match(IMAGE_REGEX);
83
- if (fileIds) {
84
- // After applying the regex, if there are IDs found they would be
85
- // in the form of => 'cid:xxxx' (including apostrophes), so we discard
86
- // everything before and after the file ID (denoted as xxxx above)
87
- fileIds.forEach(function (id) { return __awaiter(_this, void 0, void 0, function () {
88
- var parsedId, file;
89
- return __generator(this, function (_a) {
90
- switch (_a.label) {
91
- case 0:
92
- parsedId = id.substring(5, id.length - 1);
93
- return [4 /*yield*/, this.connection.files.find(parsedId)];
94
- case 1:
95
- file = _a.sent();
96
- f.push(file);
97
- return [2 /*return*/];
98
- }
99
- });
100
- }); });
101
- }
102
- }
103
- return Promise.resolve(f);
104
- };
105
- NeuralCleanConversation.collectionName = 'conversation';
106
- NeuralCleanConversation.attributes = __assign(__assign({}, message_1.default.attributes), { conversation: attributes_1.default.String({
107
- modelKey: 'conversation',
108
- }), modelVersion: attributes_1.default.String({
109
- modelKey: 'modelVersion',
110
- jsonKey: 'model_version',
111
- }) });
112
- return NeuralCleanConversation;
113
- }(message_1.default));
114
- exports.default = NeuralCleanConversation;
@@ -1,14 +0,0 @@
1
- import { Attribute } from './attributes';
2
- import File, { FileProperties } from './file';
3
- import NylasConnection from '../nylas-connection';
4
- export declare type NeuralOcrProperties = FileProperties & {
5
- ocr: string[];
6
- processedPages: number;
7
- };
8
- export default class NeuralOcr extends File implements NeuralOcrProperties {
9
- ocr: string[];
10
- processedPages: number;
11
- static collectionName: string;
12
- static attributes: Record<string, Attribute>;
13
- constructor(connection: NylasConnection, props?: NeuralOcrProperties);
14
- }
@@ -1,50 +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 attributes_1 = __importDefault(require("./attributes"));
31
- var file_1 = __importDefault(require("./file"));
32
- var NeuralOcr = /** @class */ (function (_super) {
33
- __extends(NeuralOcr, _super);
34
- function NeuralOcr(connection, props) {
35
- var _this = _super.call(this, connection, props) || this;
36
- _this.ocr = [];
37
- _this.processedPages = 0;
38
- _this.initAttributes(props);
39
- return _this;
40
- }
41
- NeuralOcr.collectionName = 'ocr';
42
- NeuralOcr.attributes = __assign(__assign({}, file_1.default.attributes), { ocr: attributes_1.default.StringList({
43
- modelKey: 'ocr',
44
- }), processedPages: attributes_1.default.Number({
45
- modelKey: 'processedPages',
46
- jsonKey: 'processed_pages',
47
- }) });
48
- return NeuralOcr;
49
- }(file_1.default));
50
- exports.default = NeuralOcr;
@@ -1,20 +0,0 @@
1
- import { Attribute } from './attributes';
2
- import RestfulModel from './restful-model';
3
- import NylasConnection from '../nylas-connection';
4
- export declare type NeuralSentimentAnalysisProperties = {
5
- accountId: string;
6
- sentiment: string;
7
- sentimentScore: number;
8
- processedLength: number;
9
- text: string;
10
- };
11
- export default class NeuralSentimentAnalysis extends RestfulModel implements NeuralSentimentAnalysisProperties {
12
- accountId: string;
13
- sentiment: string;
14
- sentimentScore: number;
15
- processedLength: number;
16
- text: string;
17
- static collectionName: string;
18
- static attributes: Record<string, Attribute>;
19
- constructor(connection: NylasConnection, props?: NeuralSentimentAnalysisProperties);
20
- }