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,121 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- extendStatics(d, b);
11
- function __() { this.constructor = d; }
12
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
- };
14
- })();
15
- var __importDefault = (this && this.__importDefault) || function (mod) {
16
- return (mod && mod.__esModule) ? mod : { "default": mod };
17
- };
18
- Object.defineProperty(exports, "__esModule", { value: true });
19
- var model_1 = __importDefault(require("./model"));
20
- var attributes_1 = __importDefault(require("./attributes"));
21
- var free_busy_1 = require("./free-busy");
22
- var RoundRobin;
23
- (function (RoundRobin) {
24
- RoundRobin["MaxAvailability"] = "max-availability";
25
- RoundRobin["MaxFairness"] = "max-fairness";
26
- })(RoundRobin = exports.RoundRobin || (exports.RoundRobin = {}));
27
- var Days;
28
- (function (Days) {
29
- Days[Days["Monday"] = 0] = "Monday";
30
- Days[Days["Tuesday"] = 1] = "Tuesday";
31
- Days[Days["Wednesday"] = 2] = "Wednesday";
32
- Days[Days["Thursday"] = 3] = "Thursday";
33
- Days[Days["Friday"] = 4] = "Friday";
34
- Days[Days["Saturday"] = 5] = "Saturday";
35
- Days[Days["Sunday"] = 6] = "Sunday";
36
- })(Days = exports.Days || (exports.Days = {}));
37
- var OpenHours = /** @class */ (function (_super) {
38
- __extends(OpenHours, _super);
39
- function OpenHours(props) {
40
- var _this = _super.call(this) || this;
41
- _this.objectType = 'open_hours';
42
- _this.emails = [];
43
- _this.days = [];
44
- _this.timezone = '';
45
- _this.start = '';
46
- _this.end = '';
47
- _this.initAttributes(props);
48
- return _this;
49
- }
50
- OpenHours.attributes = {
51
- objectType: attributes_1.default.String({
52
- modelKey: 'objectType',
53
- jsonKey: 'object_type',
54
- }),
55
- emails: attributes_1.default.StringList({
56
- modelKey: 'emails',
57
- }),
58
- days: attributes_1.default.NumberList({
59
- modelKey: 'days',
60
- }),
61
- timezone: attributes_1.default.String({
62
- modelKey: 'timezone',
63
- }),
64
- start: attributes_1.default.String({
65
- modelKey: 'start',
66
- }),
67
- end: attributes_1.default.String({
68
- modelKey: 'end',
69
- }),
70
- };
71
- return OpenHours;
72
- }(model_1.default));
73
- exports.OpenHours = OpenHours;
74
- var CalendarConsecutiveAvailability = /** @class */ (function (_super) {
75
- __extends(CalendarConsecutiveAvailability, _super);
76
- function CalendarConsecutiveAvailability(props) {
77
- var _this = _super.call(this) || this;
78
- _this.emails = [];
79
- _this.startTime = 0;
80
- _this.endTime = 0;
81
- _this.initAttributes(props);
82
- return _this;
83
- }
84
- CalendarConsecutiveAvailability.attributes = {
85
- emails: attributes_1.default.StringList({
86
- modelKey: 'emails',
87
- }),
88
- startTime: attributes_1.default.Number({
89
- modelKey: 'startTime',
90
- jsonKey: 'start_time',
91
- }),
92
- endTime: attributes_1.default.Number({
93
- modelKey: 'endTime',
94
- jsonKey: 'end_time',
95
- }),
96
- };
97
- return CalendarConsecutiveAvailability;
98
- }(model_1.default));
99
- exports.CalendarConsecutiveAvailability = CalendarConsecutiveAvailability;
100
- var CalendarAvailability = /** @class */ (function (_super) {
101
- __extends(CalendarAvailability, _super);
102
- function CalendarAvailability(props) {
103
- var _this = _super.call(this) || this;
104
- _this.object = 'availability';
105
- _this.timeSlots = [];
106
- _this.initAttributes(props);
107
- return _this;
108
- }
109
- CalendarAvailability.attributes = {
110
- timeSlots: attributes_1.default.Collection({
111
- modelKey: 'timeSlots',
112
- jsonKey: 'time_slots',
113
- itemClass: free_busy_1.TimeSlot,
114
- }),
115
- order: attributes_1.default.StringList({
116
- modelKey: 'order',
117
- }),
118
- };
119
- return CalendarAvailability;
120
- }(model_1.default));
121
- exports.default = CalendarAvailability;
@@ -1,17 +0,0 @@
1
- import Calendar from './calendar';
2
- import NylasConnection from '../nylas-connection';
3
- import RestfulModelCollection from './restful-model-collection';
4
- import FreeBusy, { FreeBusyQuery } from './free-busy';
5
- import CalendarAvailability, { CalendarConsecutiveAvailability, ConsecutiveAvailabilityQuery, SingleAvailabilityQuery } from './calendar-availability';
6
- export default class CalendarRestfulModelCollection extends RestfulModelCollection<Calendar> {
7
- connection: NylasConnection;
8
- modelClass: typeof Calendar;
9
- constructor(connection: NylasConnection);
10
- freeBusy(options: FreeBusyQuery, callback?: (error: Error | null, data?: Record<string, unknown>) => void): Promise<FreeBusy[]>;
11
- availability(options: SingleAvailabilityQuery, callback?: (error: Error | null, data?: Record<string, any>) => void): Promise<CalendarAvailability>;
12
- consecutiveAvailability(options: ConsecutiveAvailabilityQuery, callback?: (error: Error | null, data?: {
13
- [key: string]: any;
14
- }) => void): Promise<CalendarConsecutiveAvailability>;
15
- private buildAvailabilityPayload;
16
- private queryIsValid;
17
- }
@@ -1,181 +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
- var __importStar = (this && this.__importStar) || function (mod) {
30
- if (mod && mod.__esModule) return mod;
31
- var result = {};
32
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
33
- result["default"] = mod;
34
- return result;
35
- };
36
- Object.defineProperty(exports, "__esModule", { value: true });
37
- var calendar_1 = __importDefault(require("./calendar"));
38
- var restful_model_collection_1 = __importDefault(require("./restful-model-collection"));
39
- var free_busy_1 = __importStar(require("./free-busy"));
40
- var calendar_availability_1 = __importStar(require("./calendar-availability"));
41
- var CalendarRestfulModelCollection = /** @class */ (function (_super) {
42
- __extends(CalendarRestfulModelCollection, _super);
43
- function CalendarRestfulModelCollection(connection) {
44
- var _this = _super.call(this, calendar_1.default, connection) || this;
45
- _this.connection = connection;
46
- _this.modelClass = calendar_1.default;
47
- return _this;
48
- }
49
- CalendarRestfulModelCollection.prototype.freeBusy = function (options, callback) {
50
- this.queryIsValid(options);
51
- var calendarsJson = options.calendars
52
- ? options.calendars.map(function (cal) { return new free_busy_1.FreeBusyCalendar(cal).toJSON(true); })
53
- : [];
54
- return this.connection
55
- .request({
56
- method: 'POST',
57
- path: "/calendars/free-busy",
58
- body: {
59
- start_time: options.startTime.toString(),
60
- end_time: options.endTime.toString(),
61
- emails: options.emails || [],
62
- calendars: calendarsJson,
63
- },
64
- })
65
- .then(function (json) {
66
- if (callback) {
67
- callback(null, json);
68
- }
69
- var freeBusy = [];
70
- for (var _i = 0, json_1 = json; _i < json_1.length; _i++) {
71
- var fb = json_1[_i];
72
- freeBusy.push(new free_busy_1.default().fromJSON(fb));
73
- }
74
- return Promise.resolve(freeBusy);
75
- })
76
- .catch(function (err) {
77
- if (callback) {
78
- callback(err);
79
- }
80
- return Promise.reject(err);
81
- });
82
- };
83
- CalendarRestfulModelCollection.prototype.availability = function (options, callback) {
84
- this.queryIsValid(options);
85
- return this.connection
86
- .request({
87
- method: 'POST',
88
- path: "/calendars/availability",
89
- body: __assign(__assign({}, this.buildAvailabilityPayload(options)), { event_collection_id: options.eventCollectionId, round_robin: options.roundRobin }),
90
- })
91
- .then(function (json) {
92
- if (callback) {
93
- callback(null, json);
94
- }
95
- return Promise.resolve(new calendar_availability_1.default().fromJSON(json));
96
- })
97
- .catch(function (err) {
98
- if (callback) {
99
- callback(err);
100
- }
101
- return Promise.reject(err);
102
- });
103
- };
104
- CalendarRestfulModelCollection.prototype.consecutiveAvailability = function (options, callback) {
105
- this.queryIsValid(options);
106
- if (options.emails) {
107
- // If open hours contains any emails not present in the main emails key
108
- // or in the free busy email list as this would raise an error on the API side
109
- var freeBusyEmails = options.freeBusy
110
- ? options.freeBusy.map(function (fb) { return fb.email; })
111
- : [];
112
- if (options.openHours) {
113
- for (var _i = 0, _a = options.openHours; _i < _a.length; _i++) {
114
- var openHour = _a[_i];
115
- var _loop_1 = function (email) {
116
- if (!options.emails.some(function (row) { return row.includes(email); }) &&
117
- !freeBusyEmails.includes(email)) {
118
- throw new Error('Open Hours cannot contain an email not present in the main email list or the free busy email list.');
119
- }
120
- };
121
- for (var _b = 0, _c = openHour.emails; _b < _c.length; _b++) {
122
- var email = _c[_b];
123
- _loop_1(email);
124
- }
125
- }
126
- }
127
- }
128
- return this.connection
129
- .request({
130
- method: 'POST',
131
- path: "/calendars/availability/consecutive",
132
- body: this.buildAvailabilityPayload(options),
133
- })
134
- .then(function (json) {
135
- if (callback) {
136
- callback(null, json);
137
- }
138
- return Promise.resolve(new calendar_availability_1.CalendarConsecutiveAvailability().fromJSON(json));
139
- })
140
- .catch(function (err) {
141
- if (callback) {
142
- callback(err);
143
- }
144
- return Promise.reject(err);
145
- });
146
- };
147
- CalendarRestfulModelCollection.prototype.buildAvailabilityPayload = function (options) {
148
- // Instantiate objects from properties to get JSON formatted for the API call
149
- var freeBusyJson = options.freeBusy
150
- ? options.freeBusy.map(function (fb) { return new free_busy_1.default(fb).toJSON(true); })
151
- : [];
152
- var openHoursJson = options.openHours
153
- ? options.openHours.map(function (oh) { return new calendar_availability_1.OpenHours(oh).toJSON(true); })
154
- : [];
155
- var calendarsJson = options.calendars
156
- ? options.calendars.map(function (cal) { return new free_busy_1.FreeBusyCalendar(cal).toJSON(true); })
157
- : [];
158
- return {
159
- emails: options.emails,
160
- duration_minutes: options.duration,
161
- interval_minutes: options.interval,
162
- start_time: options.startTime,
163
- end_time: options.endTime,
164
- buffer: options.buffer,
165
- tentative_busy: options.tentativeBusy,
166
- free_busy: freeBusyJson,
167
- open_hours: openHoursJson,
168
- calendars: calendarsJson,
169
- };
170
- };
171
- // Helper function to check if a query is valid
172
- CalendarRestfulModelCollection.prototype.queryIsValid = function (query) {
173
- if ((!query.emails || query.emails.length == 0) &&
174
- (!query.calendars || query.calendars.length == 0)) {
175
- throw new Error("Must set either 'emails' or 'calendars' in the query.");
176
- }
177
- return true;
178
- };
179
- return CalendarRestfulModelCollection;
180
- }(restful_model_collection_1.default));
181
- exports.default = CalendarRestfulModelCollection;
@@ -1,33 +0,0 @@
1
- import RestfulModel, { SaveCallback } from './restful-model';
2
- import { GetCallback } from './model-collection';
3
- import { Attribute } from './attributes';
4
- import NylasConnection from '../nylas-connection';
5
- import JobStatus from './job-status';
6
- export declare type CalendarProperties = {
7
- name: string;
8
- description: string;
9
- location: string;
10
- timezone: string;
11
- readOnly?: boolean;
12
- isPrimary?: boolean;
13
- jobStatusId?: string;
14
- metadata?: object;
15
- hexColor?: string;
16
- };
17
- export default class Calendar extends RestfulModel implements CalendarProperties {
18
- name: string;
19
- description: string;
20
- location: string;
21
- timezone: string;
22
- readOnly?: boolean;
23
- isPrimary?: boolean;
24
- jobStatusId?: string;
25
- metadata?: object;
26
- hexColor?: string;
27
- static collectionName: string;
28
- static attributes: Record<string, Attribute>;
29
- constructor(connection: NylasConnection, props?: CalendarProperties);
30
- save(params?: {} | SaveCallback, callback?: SaveCallback): Promise<this>;
31
- saveRequestBody(): Record<string, unknown>;
32
- getJobStatus(callback?: GetCallback): Promise<JobStatus>;
33
- }
@@ -1,97 +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 attributes_1 = __importDefault(require("./attributes"));
32
- var Calendar = /** @class */ (function (_super) {
33
- __extends(Calendar, _super);
34
- function Calendar(connection, props) {
35
- var _this = _super.call(this, connection, props) || this;
36
- _this.name = '';
37
- _this.description = '';
38
- _this.location = '';
39
- _this.timezone = '';
40
- _this.initAttributes(props);
41
- return _this;
42
- }
43
- Calendar.prototype.save = function (params, callback) {
44
- if (params === void 0) { params = {}; }
45
- return _super.prototype.save.call(this, params, callback);
46
- };
47
- Calendar.prototype.saveRequestBody = function () {
48
- var calendarJSON = _super.prototype.saveRequestBody.call(this);
49
- return {
50
- name: calendarJSON.name,
51
- description: calendarJSON.description,
52
- location: calendarJSON.location,
53
- timezone: calendarJSON.timezone,
54
- metadata: calendarJSON.metadata,
55
- };
56
- };
57
- Calendar.prototype.getJobStatus = function (callback) {
58
- if (typeof this.jobStatusId === 'undefined') {
59
- var err = new Error('jobStatusId must be defined');
60
- if (callback) {
61
- callback(err);
62
- }
63
- return Promise.reject(err);
64
- }
65
- return this.connection.jobStatuses.find(this.jobStatusId, callback);
66
- };
67
- Calendar.collectionName = 'calendars';
68
- Calendar.attributes = __assign(__assign({}, restful_model_1.default.attributes), { name: attributes_1.default.String({
69
- modelKey: 'name',
70
- }), description: attributes_1.default.String({
71
- modelKey: 'description',
72
- }), readOnly: attributes_1.default.Boolean({
73
- modelKey: 'readOnly',
74
- jsonKey: 'read_only',
75
- readOnly: true,
76
- }), location: attributes_1.default.String({
77
- modelKey: 'location',
78
- }), timezone: attributes_1.default.String({
79
- modelKey: 'timezone',
80
- }), isPrimary: attributes_1.default.Boolean({
81
- modelKey: 'isPrimary',
82
- jsonKey: 'is_primary',
83
- readOnly: true,
84
- }), jobStatusId: attributes_1.default.String({
85
- modelKey: 'jobStatusId',
86
- jsonKey: 'job_status_id',
87
- readOnly: true,
88
- }), metadata: attributes_1.default.Object({
89
- modelKey: 'metadata',
90
- }), hexColor: attributes_1.default.String({
91
- modelKey: 'hexColor',
92
- jsonKey: 'hex_color',
93
- readOnly: true,
94
- }) });
95
- return Calendar;
96
- }(restful_model_1.default));
97
- exports.default = Calendar;
@@ -1,9 +0,0 @@
1
- import RestfulModelCollection from './restful-model-collection';
2
- import NylasConnection from '../nylas-connection';
3
- import Component from './component';
4
- export default class ComponentRestfulModelCollection extends RestfulModelCollection<Component> {
5
- connection: NylasConnection;
6
- modelClass: typeof Component;
7
- constructor(connection: NylasConnection);
8
- path(): string;
9
- }
@@ -1,34 +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 component_1 = __importDefault(require("./component"));
21
- var ComponentRestfulModelCollection = /** @class */ (function (_super) {
22
- __extends(ComponentRestfulModelCollection, _super);
23
- function ComponentRestfulModelCollection(connection) {
24
- var _this = _super.call(this, component_1.default, connection) || this;
25
- _this.connection = connection;
26
- _this.modelClass = component_1.default;
27
- return _this;
28
- }
29
- ComponentRestfulModelCollection.prototype.path = function () {
30
- return "/component/" + this.connection.clientId;
31
- };
32
- return ComponentRestfulModelCollection;
33
- }(restful_model_collection_1.default));
34
- exports.default = ComponentRestfulModelCollection;
@@ -1,37 +0,0 @@
1
- import RestfulModel, { SaveCallback } from './restful-model';
2
- import { Attribute } from './attributes';
3
- import NylasConnection from '../nylas-connection';
4
- export declare type ComponentProperties = {
5
- name?: string;
6
- type?: string;
7
- action?: number;
8
- active?: boolean;
9
- settings?: object;
10
- allowedDomains?: string[];
11
- publicAccountId?: string;
12
- publicTokenId?: string;
13
- publicApplicationId?: string;
14
- accessToken?: string;
15
- createdAt?: Date;
16
- updatedAt?: Date;
17
- };
18
- export default class Component extends RestfulModel implements ComponentProperties {
19
- name?: string;
20
- type?: string;
21
- action?: number;
22
- active?: boolean;
23
- settings?: object;
24
- allowedDomains?: string[];
25
- publicAccountId?: string;
26
- publicTokenId?: string;
27
- publicApplicationId?: string;
28
- accessToken?: string;
29
- createdAt?: Date;
30
- updatedAt?: Date;
31
- static collectionName: string;
32
- static attributes: Record<string, Attribute>;
33
- constructor(connection: NylasConnection, props?: ComponentProperties);
34
- saveEndpoint(): string;
35
- save(params?: {} | SaveCallback, callback?: SaveCallback): Promise<this>;
36
- saveRequestBody(): Record<string, unknown>;
37
- }
@@ -1,91 +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 attributes_1 = __importDefault(require("./attributes"));
32
- var Component = /** @class */ (function (_super) {
33
- __extends(Component, _super);
34
- function Component(connection, props) {
35
- var _this = _super.call(this, connection, props) || this;
36
- _this.initAttributes(props);
37
- return _this;
38
- }
39
- Component.prototype.saveEndpoint = function () {
40
- return "/component/" + this.connection.clientId;
41
- };
42
- Component.prototype.save = function (params, callback) {
43
- if (params === void 0) { params = {}; }
44
- return _super.prototype.save.call(this, params, callback);
45
- };
46
- Component.prototype.saveRequestBody = function () {
47
- var json = _super.prototype.saveRequestBody.call(this);
48
- if (this.id) {
49
- // Cannot cannot send these values after creation
50
- delete json.access_token;
51
- delete json.public_application_id;
52
- delete json.type;
53
- }
54
- return json;
55
- };
56
- Component.collectionName = 'component';
57
- Component.attributes = __assign(__assign({}, restful_model_1.default.attributes), { name: attributes_1.default.String({
58
- modelKey: 'name',
59
- }), type: attributes_1.default.String({
60
- modelKey: 'type',
61
- }), action: attributes_1.default.Number({
62
- modelKey: 'action',
63
- }), active: attributes_1.default.Boolean({
64
- modelKey: 'active',
65
- }), settings: attributes_1.default.Object({
66
- modelKey: 'settings',
67
- }), allowedDomains: attributes_1.default.StringList({
68
- modelKey: 'allowedDomains',
69
- jsonKey: 'allowed_domains',
70
- }), publicAccountId: attributes_1.default.String({
71
- modelKey: 'publicAccountId',
72
- jsonKey: 'public_account_id',
73
- }), publicTokenId: attributes_1.default.String({
74
- modelKey: 'publicTokenId',
75
- jsonKey: 'public_token_id',
76
- }), publicApplicationId: attributes_1.default.String({
77
- modelKey: 'publicApplicationId',
78
- jsonKey: 'public_application_id',
79
- }), accessToken: attributes_1.default.String({
80
- modelKey: 'accessToken',
81
- jsonKey: 'access_token',
82
- }), createdAt: attributes_1.default.Date({
83
- modelKey: 'createdAt',
84
- jsonKey: 'created_at',
85
- }), updatedAt: attributes_1.default.Date({
86
- modelKey: 'updatedAt',
87
- jsonKey: 'updated_at',
88
- }) });
89
- return Component;
90
- }(restful_model_1.default));
91
- exports.default = Component;