nylas 6.0.0-canary.2 → 6.0.0

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 (65) hide show
  1. package/lib/config.d.ts +12 -0
  2. package/lib/config.js +0 -1
  3. package/lib/models/access-token.d.ts +16 -0
  4. package/lib/models/access-token.js +56 -0
  5. package/lib/models/account.d.ts +1 -1
  6. package/lib/models/account.js +1 -0
  7. package/lib/models/application-details.d.ts +12 -0
  8. package/lib/models/application-details.js +47 -0
  9. package/lib/models/attributes.d.ts +5 -2
  10. package/lib/models/attributes.js +28 -5
  11. package/lib/models/calendar-availability.d.ts +34 -7
  12. package/lib/models/calendar-availability.js +33 -3
  13. package/lib/models/calendar-restful-model-collection.d.ts +5 -28
  14. package/lib/models/calendar-restful-model-collection.js +31 -6
  15. package/lib/models/calendar.d.ts +3 -0
  16. package/lib/models/calendar.js +12 -0
  17. package/lib/models/component.d.ts +3 -0
  18. package/lib/models/component.js +13 -0
  19. package/lib/models/connect.d.ts +21 -24
  20. package/lib/models/connect.js +26 -24
  21. package/lib/models/contact-restful-model-collection.js +2 -14
  22. package/lib/models/contact.d.ts +2 -2
  23. package/lib/models/contact.js +5 -1
  24. package/lib/models/event-conferencing.d.ts +2 -3
  25. package/lib/models/event-conferencing.js +2 -2
  26. package/lib/models/event-notification.d.ts +25 -0
  27. package/lib/models/event-notification.js +62 -0
  28. package/lib/models/event-participant.js +1 -0
  29. package/lib/models/event.d.ts +5 -1
  30. package/lib/models/event.js +18 -4
  31. package/lib/models/file.d.ts +0 -1
  32. package/lib/models/file.js +0 -19
  33. package/lib/models/folder.d.ts +2 -1
  34. package/lib/models/folder.js +5 -2
  35. package/lib/models/free-busy.d.ts +5 -0
  36. package/lib/models/free-busy.js +0 -1
  37. package/lib/models/job-status.d.ts +4 -0
  38. package/lib/models/job-status.js +12 -0
  39. package/lib/models/management-account.d.ts +6 -0
  40. package/lib/models/management-account.js +14 -1
  41. package/lib/models/message.d.ts +5 -1
  42. package/lib/models/message.js +16 -2
  43. package/lib/models/model.js +6 -4
  44. package/lib/models/neural-categorizer.js +0 -1
  45. package/lib/models/neural-signature-contact.js +5 -18
  46. package/lib/models/neural.js +0 -1
  47. package/lib/models/restful-model-collection.d.ts +1 -0
  48. package/lib/models/restful-model-collection.js +2 -0
  49. package/lib/models/restful-model.d.ts +1 -0
  50. package/lib/models/restful-model.js +2 -1
  51. package/lib/models/scheduler-booking-request.d.ts +61 -0
  52. package/lib/models/scheduler-booking-request.js +148 -0
  53. package/lib/models/scheduler-restful-model-collection.d.ts +25 -0
  54. package/lib/models/scheduler-restful-model-collection.js +133 -0
  55. package/lib/models/scheduler-time-slot.d.ts +18 -0
  56. package/lib/models/scheduler-time-slot.js +53 -0
  57. package/lib/models/scheduler.d.ts +25 -2
  58. package/lib/models/scheduler.js +56 -3
  59. package/lib/models/thread.d.ts +1 -1
  60. package/lib/models/thread.js +9 -2
  61. package/lib/nylas-connection.d.ts +3 -4
  62. package/lib/nylas-connection.js +7 -19
  63. package/lib/nylas.d.ts +10 -21
  64. package/lib/nylas.js +28 -35
  65. package/package.json +1 -1
package/lib/config.d.ts CHANGED
@@ -2,3 +2,15 @@ export declare let apiServer: string | null;
2
2
  export declare function setApiServer(newApiServer: string | null): void;
3
3
  export declare let clientSecret: string;
4
4
  export declare function setClientSecret(newClientSecret: string): void;
5
+ export declare type NylasConfig = {
6
+ clientId: string;
7
+ clientSecret: string;
8
+ apiServer?: string;
9
+ };
10
+ export declare type AuthenticateUrlConfig = {
11
+ redirectURI: string;
12
+ loginHint?: string;
13
+ state?: string;
14
+ provider?: string;
15
+ scopes?: string[];
16
+ };
package/lib/config.js CHANGED
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setClientSecret = exports.clientSecret = exports.setApiServer = exports.apiServer = void 0;
4
3
  exports.apiServer = null;
5
4
  function setApiServer(newApiServer) {
6
5
  exports.apiServer = newApiServer;
@@ -0,0 +1,16 @@
1
+ import Model from './model';
2
+ export declare type AccessTokenProperties = {
3
+ accessToken: string;
4
+ accountId: string;
5
+ emailAddress: string;
6
+ provider: string;
7
+ tokenType: string;
8
+ };
9
+ export default class AccessToken extends Model implements AccessTokenProperties {
10
+ accessToken: string;
11
+ accountId: string;
12
+ emailAddress: string;
13
+ provider: string;
14
+ tokenType: string;
15
+ constructor(props?: AccessTokenProperties);
16
+ }
@@ -0,0 +1,56 @@
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 AccessToken = /** @class */ (function (_super) {
22
+ __extends(AccessToken, _super);
23
+ function AccessToken(props) {
24
+ var _this = _super.call(this) || this;
25
+ _this.accessToken = '';
26
+ _this.accountId = '';
27
+ _this.emailAddress = '';
28
+ _this.provider = '';
29
+ _this.tokenType = 'bearer';
30
+ _this.initAttributes(props);
31
+ return _this;
32
+ }
33
+ return AccessToken;
34
+ }(model_1.default));
35
+ exports.default = AccessToken;
36
+ AccessToken.attributes = {
37
+ accessToken: attributes_1.default.String({
38
+ modelKey: 'accessToken',
39
+ jsonKey: 'access_token',
40
+ }),
41
+ accountId: attributes_1.default.String({
42
+ modelKey: 'accountId',
43
+ jsonKey: 'account_id',
44
+ }),
45
+ emailAddress: attributes_1.default.String({
46
+ modelKey: 'emailAddress',
47
+ jsonKey: 'email_address',
48
+ }),
49
+ provider: attributes_1.default.String({
50
+ modelKey: 'provider',
51
+ }),
52
+ tokenType: attributes_1.default.String({
53
+ modelKey: 'tokenType',
54
+ jsonKey: 'token_type',
55
+ }),
56
+ };
@@ -17,7 +17,7 @@ export default class Account extends RestfulModel implements AccountProperties {
17
17
  organizationUnit: string;
18
18
  syncState: string;
19
19
  linkedAt: Date;
20
+ accessToken: string;
20
21
  billingState?: string;
21
- accessToken?: string;
22
22
  constructor(connection: NylasConnection, props?: AccountProperties);
23
23
  }
@@ -39,6 +39,7 @@ var Account = /** @class */ (function (_super) {
39
39
  _this.organizationUnit = '';
40
40
  _this.syncState = '';
41
41
  _this.linkedAt = new Date();
42
+ _this.accessToken = '';
42
43
  _this.initAttributes(props);
43
44
  return _this;
44
45
  }
@@ -0,0 +1,12 @@
1
+ import Model from './model';
2
+ export declare type ApplicationDetailsProperties = {
3
+ applicationName?: string;
4
+ iconUrl?: string;
5
+ redirectUris?: string[];
6
+ };
7
+ export default class ApplicationDetails extends Model implements ApplicationDetailsProperties {
8
+ applicationName: string;
9
+ iconUrl: string;
10
+ redirectUris: string[];
11
+ constructor(props?: ApplicationDetailsProperties);
12
+ }
@@ -0,0 +1,47 @@
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 ApplicationDetails = /** @class */ (function (_super) {
22
+ __extends(ApplicationDetails, _super);
23
+ function ApplicationDetails(props) {
24
+ var _this = _super.call(this) || this;
25
+ _this.applicationName = '';
26
+ _this.iconUrl = '';
27
+ _this.redirectUris = [];
28
+ _this.initAttributes(props);
29
+ return _this;
30
+ }
31
+ return ApplicationDetails;
32
+ }(model_1.default));
33
+ exports.default = ApplicationDetails;
34
+ ApplicationDetails.attributes = {
35
+ applicationName: attributes_1.default.String({
36
+ modelKey: 'applicationName',
37
+ jsonKey: 'application_name',
38
+ }),
39
+ iconUrl: attributes_1.default.String({
40
+ modelKey: 'iconUrl',
41
+ jsonKey: 'icon_url',
42
+ }),
43
+ redirectUris: attributes_1.default.StringList({
44
+ modelKey: 'redirectUris',
45
+ jsonKey: 'redirect_uris',
46
+ }),
47
+ };
@@ -11,6 +11,7 @@ export declare abstract class Attribute {
11
11
  });
12
12
  abstract toJSON(val: any, _parent?: any): any;
13
13
  abstract fromJSON(val: any, _parent: any): any;
14
+ saveRequestBody(val: any): any;
14
15
  }
15
16
  declare class AttributeObject extends Attribute {
16
17
  itemClass?: any;
@@ -20,8 +21,9 @@ declare class AttributeObject extends Attribute {
20
21
  itemClass?: typeof Model | typeof RestfulModel;
21
22
  readOnly?: boolean;
22
23
  });
23
- toJSON(val: any): unknown;
24
+ toJSON(val: any, saveRequestBody?: boolean): unknown;
24
25
  fromJSON(val: any, _parent: any): any;
26
+ saveRequestBody(val: any): unknown;
25
27
  }
26
28
  declare class AttributeNumber extends Attribute {
27
29
  toJSON(val: number): number;
@@ -59,8 +61,9 @@ declare class AttributeCollection extends Attribute {
59
61
  itemClass: typeof Model | typeof RestfulModel;
60
62
  readOnly?: boolean;
61
63
  });
62
- toJSON(vals: any[]): unknown[];
64
+ toJSON(vals: any, saveRequestBody?: boolean): unknown[];
63
65
  fromJSON(json: unknown[], _parent: any): typeof Model[] | typeof RestfulModel[] | unknown[];
66
+ saveRequestBody(val: any): unknown;
64
67
  }
65
68
  declare class AttributeEnum extends Attribute {
66
69
  itemClass: any;
@@ -23,7 +23,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
23
23
  return (mod && mod.__esModule) ? mod : { "default": mod };
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.Attribute = void 0;
27
26
  var restful_model_1 = __importDefault(require("./restful-model"));
28
27
  // The Attribute class represents a single model attribute, like 'namespace_id'
29
28
  // Subclasses of Attribute like AttributeDateTime know how to covert between
@@ -36,6 +35,12 @@ var Attribute = /** @class */ (function () {
36
35
  this.jsonKey = jsonKey || modelKey;
37
36
  this.readOnly = readOnly || false;
38
37
  }
38
+ Attribute.prototype.saveRequestBody = function (val) {
39
+ if (this.readOnly) {
40
+ return undefined;
41
+ }
42
+ return this.toJSON(val);
43
+ };
39
44
  return Attribute;
40
45
  }());
41
46
  exports.Attribute = Attribute;
@@ -47,11 +52,14 @@ var AttributeObject = /** @class */ (function (_super) {
47
52
  _this.itemClass = itemClass;
48
53
  return _this;
49
54
  }
50
- AttributeObject.prototype.toJSON = function (val) {
55
+ AttributeObject.prototype.toJSON = function (val, saveRequestBody) {
51
56
  if (!val) {
52
57
  return val;
53
58
  }
54
- if (val.toJSON != null) {
59
+ if (saveRequestBody === true && val.saveRequestBody != null) {
60
+ return val.saveRequestBody();
61
+ }
62
+ else if (val.toJSON != null) {
55
63
  return val.toJSON();
56
64
  }
57
65
  return val;
@@ -65,6 +73,12 @@ var AttributeObject = /** @class */ (function (_super) {
65
73
  }
66
74
  return new this.itemClass(val).fromJSON(val);
67
75
  };
76
+ AttributeObject.prototype.saveRequestBody = function (val) {
77
+ if (this.readOnly) {
78
+ return;
79
+ }
80
+ return this.toJSON(val, true);
81
+ };
68
82
  return AttributeObject;
69
83
  }(Attribute));
70
84
  var AttributeNumber = /** @class */ (function (_super) {
@@ -198,14 +212,17 @@ var AttributeCollection = /** @class */ (function (_super) {
198
212
  _this.itemClass = itemClass;
199
213
  return _this;
200
214
  }
201
- AttributeCollection.prototype.toJSON = function (vals) {
215
+ AttributeCollection.prototype.toJSON = function (vals, saveRequestBody) {
202
216
  if (!vals) {
203
217
  return [];
204
218
  }
205
219
  var json = [];
206
220
  for (var _i = 0, vals_1 = vals; _i < vals_1.length; _i++) {
207
221
  var val = vals_1[_i];
208
- if (val.toJSON != null) {
222
+ if (saveRequestBody === true && val.saveRequestBody != null) {
223
+ json.push(val.saveRequestBody());
224
+ }
225
+ else if (val.toJSON != null) {
209
226
  json.push(val.toJSON());
210
227
  }
211
228
  else {
@@ -232,6 +249,12 @@ var AttributeCollection = /** @class */ (function (_super) {
232
249
  }
233
250
  return objs;
234
251
  };
252
+ AttributeCollection.prototype.saveRequestBody = function (val) {
253
+ if (this.readOnly) {
254
+ return;
255
+ }
256
+ return this.toJSON(val, true);
257
+ };
235
258
  return AttributeCollection;
236
259
  }(Attribute));
237
260
  var AttributeEnum = /** @class */ (function (_super) {
@@ -1,12 +1,38 @@
1
1
  import Model from './model';
2
- import { TimeSlot, TimeSlotProperties } from './free-busy';
2
+ import { FreeBusyProperties, TimeSlot, TimeSlotProperties } from './free-busy';
3
3
  export declare enum RoundRobin {
4
4
  MaxAvailability = "max-availability",
5
5
  MaxFairness = "max-fairness"
6
6
  }
7
+ export declare enum Days {
8
+ Monday = 0,
9
+ Tuesday = 1,
10
+ Wednesday = 2,
11
+ Thursday = 3,
12
+ Friday = 4,
13
+ Saturday = 5,
14
+ Sunday = 6
15
+ }
16
+ declare type AvailabilityQuery = {
17
+ duration: number;
18
+ interval: number;
19
+ startTime: number;
20
+ endTime: number;
21
+ buffer?: number;
22
+ tentativeBusy?: boolean;
23
+ freeBusy?: FreeBusyProperties[];
24
+ openHours?: OpenHoursProperties[];
25
+ };
26
+ export declare type SingleAvailabilityQuery = AvailabilityQuery & {
27
+ emails: string[];
28
+ roundRobin?: RoundRobin;
29
+ };
30
+ export declare type ConsecutiveAvailabilityQuery = AvailabilityQuery & {
31
+ emails: Array<string[]>;
32
+ };
7
33
  export declare type OpenHoursProperties = {
8
34
  emails: string[];
9
- days: number[];
35
+ days: Days[];
10
36
  timezone: string;
11
37
  start: string;
12
38
  end: string;
@@ -14,7 +40,7 @@ export declare type OpenHoursProperties = {
14
40
  export declare class OpenHours extends Model implements OpenHoursProperties {
15
41
  objectType: string;
16
42
  emails: string[];
17
- days: number[];
43
+ days: Days[];
18
44
  timezone: string;
19
45
  start: string;
20
46
  end: string;
@@ -22,13 +48,13 @@ export declare class OpenHours extends Model implements OpenHoursProperties {
22
48
  }
23
49
  export declare type CalendarConsecutiveAvailabilityProperties = {
24
50
  emails: string[];
25
- start_time: number;
26
- end_time: number;
51
+ startTime: number;
52
+ endTime: number;
27
53
  };
28
54
  export declare class CalendarConsecutiveAvailability extends Model implements CalendarConsecutiveAvailabilityProperties {
29
55
  emails: string[];
30
- start_time: number;
31
- end_time: number;
56
+ startTime: number;
57
+ endTime: number;
32
58
  constructor(props?: CalendarConsecutiveAvailabilityProperties);
33
59
  }
34
60
  export declare type CalendarAvailabilityProperties = {
@@ -39,3 +65,4 @@ export default class CalendarAvailability extends Model implements CalendarAvail
39
65
  timeSlots: TimeSlot[];
40
66
  constructor(props?: CalendarAvailabilityProperties);
41
67
  }
68
+ export {};
@@ -16,14 +16,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
16
16
  return (mod && mod.__esModule) ? mod : { "default": mod };
17
17
  };
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.CalendarConsecutiveAvailability = exports.OpenHours = exports.RoundRobin = void 0;
20
19
  var model_1 = __importDefault(require("./model"));
21
20
  var attributes_1 = __importDefault(require("./attributes"));
21
+ var free_busy_1 = require("./free-busy");
22
22
  var RoundRobin;
23
23
  (function (RoundRobin) {
24
24
  RoundRobin["MaxAvailability"] = "max-availability";
25
25
  RoundRobin["MaxFairness"] = "max-fairness";
26
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 = {}));
27
37
  var OpenHours = /** @class */ (function (_super) {
28
38
  __extends(OpenHours, _super);
29
39
  function OpenHours(props) {
@@ -66,14 +76,27 @@ var CalendarConsecutiveAvailability = /** @class */ (function (_super) {
66
76
  function CalendarConsecutiveAvailability(props) {
67
77
  var _this = _super.call(this) || this;
68
78
  _this.emails = [];
69
- _this.start_time = 0;
70
- _this.end_time = 0;
79
+ _this.startTime = 0;
80
+ _this.endTime = 0;
71
81
  _this.initAttributes(props);
72
82
  return _this;
73
83
  }
74
84
  return CalendarConsecutiveAvailability;
75
85
  }(model_1.default));
76
86
  exports.CalendarConsecutiveAvailability = CalendarConsecutiveAvailability;
87
+ CalendarConsecutiveAvailability.attributes = {
88
+ emails: attributes_1.default.StringList({
89
+ modelKey: 'emails',
90
+ }),
91
+ startTime: attributes_1.default.Number({
92
+ modelKey: 'startTime',
93
+ jsonKey: 'start_time',
94
+ }),
95
+ endTime: attributes_1.default.Number({
96
+ modelKey: 'endTime',
97
+ jsonKey: 'end_time',
98
+ }),
99
+ };
77
100
  var CalendarAvailability = /** @class */ (function (_super) {
78
101
  __extends(CalendarAvailability, _super);
79
102
  function CalendarAvailability(props) {
@@ -86,3 +109,10 @@ var CalendarAvailability = /** @class */ (function (_super) {
86
109
  return CalendarAvailability;
87
110
  }(model_1.default));
88
111
  exports.default = CalendarAvailability;
112
+ CalendarAvailability.attributes = {
113
+ timeSlots: attributes_1.default.Collection({
114
+ modelKey: 'timeSlots',
115
+ jsonKey: 'time_slots',
116
+ itemClass: free_busy_1.TimeSlot,
117
+ }),
118
+ };
@@ -1,38 +1,15 @@
1
1
  import Calendar from './calendar';
2
2
  import NylasConnection from '../nylas-connection';
3
3
  import RestfulModelCollection from './restful-model-collection';
4
- import FreeBusy, { FreeBusyProperties } from './free-busy';
5
- import CalendarAvailability, { CalendarConsecutiveAvailability, OpenHoursProperties, RoundRobin } from './calendar-availability';
4
+ import FreeBusy, { FreeBusyQuery } from './free-busy';
5
+ import CalendarAvailability, { CalendarConsecutiveAvailability, ConsecutiveAvailabilityQuery, SingleAvailabilityQuery } from './calendar-availability';
6
6
  export default class CalendarRestfulModelCollection extends RestfulModelCollection<Calendar> {
7
7
  connection: NylasConnection;
8
8
  modelClass: typeof Calendar;
9
9
  constructor(connection: NylasConnection);
10
- freeBusy(options: {
11
- startTime: number;
12
- endTime: number;
13
- emails: string[];
14
- }, callback?: (error: Error | null, data?: Record<string, unknown>) => void): Promise<FreeBusy[]>;
15
- availability(options: {
16
- emails: string[];
17
- duration: number;
18
- interval: number;
19
- startTime: number;
20
- endTime: number;
21
- buffer?: number;
22
- roundRobin?: RoundRobin;
23
- freeBusy?: FreeBusyProperties[];
24
- openHours?: OpenHoursProperties[];
25
- }, callback?: (error: Error | null, data?: Record<string, any>) => void): Promise<CalendarAvailability>;
26
- consecutiveAvailability(options: {
27
- emails: Array<string[]>;
28
- duration: number;
29
- interval: number;
30
- startTime: number;
31
- endTime: number;
32
- buffer?: number;
33
- freeBusy?: FreeBusyProperties[];
34
- openHours?: OpenHoursProperties[];
35
- }, callback?: (error: Error | null, data?: {
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?: {
36
13
  [key: string]: any;
37
14
  }) => void): Promise<CalendarConsecutiveAvailability>;
38
15
  }
@@ -15,11 +15,18 @@ var __extends = (this && this.__extends) || (function () {
15
15
  var __importDefault = (this && this.__importDefault) || function (mod) {
16
16
  return (mod && mod.__esModule) ? mod : { "default": mod };
17
17
  };
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
22
+ result["default"] = mod;
23
+ return result;
24
+ };
18
25
  Object.defineProperty(exports, "__esModule", { value: true });
19
26
  var calendar_1 = __importDefault(require("./calendar"));
20
27
  var restful_model_collection_1 = __importDefault(require("./restful-model-collection"));
21
28
  var free_busy_1 = __importDefault(require("./free-busy"));
22
- var calendar_availability_1 = __importDefault(require("./calendar-availability"));
29
+ var calendar_availability_1 = __importStar(require("./calendar-availability"));
23
30
  var CalendarRestfulModelCollection = /** @class */ (function (_super) {
24
31
  __extends(CalendarRestfulModelCollection, _super);
25
32
  function CalendarRestfulModelCollection(connection) {
@@ -58,6 +65,13 @@ var CalendarRestfulModelCollection = /** @class */ (function (_super) {
58
65
  });
59
66
  };
60
67
  CalendarRestfulModelCollection.prototype.availability = function (options, callback) {
68
+ // Instantiate objects from properties to get JSON formatted for the API call
69
+ var freeBusyJson = options.freeBusy
70
+ ? options.freeBusy.map(function (fb) { return new free_busy_1.default(fb).toJSON(true); })
71
+ : [];
72
+ var openHoursJson = options.openHours
73
+ ? options.openHours.map(function (oh) { return new calendar_availability_1.OpenHours(oh).toJSON(true); })
74
+ : [];
61
75
  return this.connection
62
76
  .request({
63
77
  method: 'POST',
@@ -69,9 +83,10 @@ var CalendarRestfulModelCollection = /** @class */ (function (_super) {
69
83
  start_time: options.startTime,
70
84
  end_time: options.endTime,
71
85
  buffer: options.buffer,
86
+ tentative_busy: options.tentativeBusy,
72
87
  round_robin: options.roundRobin,
73
- free_busy: options.freeBusy || [],
74
- open_hours: options.openHours || [],
88
+ free_busy: freeBusyJson,
89
+ open_hours: openHoursJson,
75
90
  },
76
91
  })
77
92
  .then(function (json) {
@@ -88,6 +103,8 @@ var CalendarRestfulModelCollection = /** @class */ (function (_super) {
88
103
  });
89
104
  };
90
105
  CalendarRestfulModelCollection.prototype.consecutiveAvailability = function (options, callback) {
106
+ // If open hours contains any emails not present in the main emails key
107
+ // or in the free busy email list as this would raise an error on the API side
91
108
  var freeBusyEmails = options.freeBusy
92
109
  ? options.freeBusy.map(function (fb) { return fb.email; })
93
110
  : [];
@@ -106,6 +123,13 @@ var CalendarRestfulModelCollection = /** @class */ (function (_super) {
106
123
  }
107
124
  }
108
125
  }
126
+ // Instantiate objects from properties to get JSON formatted for the API call
127
+ var freeBusyJson = options.freeBusy
128
+ ? options.freeBusy.map(function (fb) { return new free_busy_1.default(fb).toJSON(true); })
129
+ : [];
130
+ var openHoursJson = options.openHours
131
+ ? options.openHours.map(function (oh) { return new calendar_availability_1.OpenHours(oh).toJSON(true); })
132
+ : [];
109
133
  return this.connection
110
134
  .request({
111
135
  method: 'POST',
@@ -117,15 +141,16 @@ var CalendarRestfulModelCollection = /** @class */ (function (_super) {
117
141
  start_time: options.startTime,
118
142
  end_time: options.endTime,
119
143
  buffer: options.buffer,
120
- free_busy: options.freeBusy || [],
121
- open_hours: options.openHours || [],
144
+ tentative_busy: options.tentativeBusy,
145
+ free_busy: freeBusyJson,
146
+ open_hours: openHoursJson,
122
147
  },
123
148
  })
124
149
  .then(function (json) {
125
150
  if (callback) {
126
151
  callback(null, json);
127
152
  }
128
- return Promise.resolve(json);
153
+ return Promise.resolve(new calendar_availability_1.CalendarConsecutiveAvailability().fromJSON(json));
129
154
  })
130
155
  .catch(function (err) {
131
156
  if (callback) {
@@ -10,6 +10,7 @@ export declare type CalendarProperties = {
10
10
  readOnly?: boolean;
11
11
  isPrimary?: boolean;
12
12
  jobStatusId?: string;
13
+ metadata?: object;
13
14
  };
14
15
  export default class Calendar extends RestfulModel implements CalendarProperties {
15
16
  name: string;
@@ -19,7 +20,9 @@ export default class Calendar extends RestfulModel implements CalendarProperties
19
20
  readOnly?: boolean;
20
21
  isPrimary?: boolean;
21
22
  jobStatusId?: string;
23
+ metadata?: object;
22
24
  constructor(connection: NylasConnection, props?: CalendarProperties);
23
25
  save(params?: {} | SaveCallback, callback?: SaveCallback): Promise<this>;
26
+ saveRequestBody(): Record<string, unknown>;
24
27
  getJobStatus(callback?: GetCallback): Promise<JobStatus>;
25
28
  }
@@ -44,6 +44,16 @@ var Calendar = /** @class */ (function (_super) {
44
44
  if (params === void 0) { params = {}; }
45
45
  return _super.prototype.save.call(this, params, callback);
46
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
+ };
47
57
  Calendar.prototype.getJobStatus = function (callback) {
48
58
  if (typeof this.jobStatusId === 'undefined') {
49
59
  var err = new Error('jobStatusId must be defined');
@@ -78,4 +88,6 @@ Calendar.attributes = __assign(__assign({}, restful_model_1.default.attributes),
78
88
  modelKey: 'jobStatusId',
79
89
  jsonKey: 'job_status_id',
80
90
  readOnly: true,
91
+ }), metadata: attributes_1.default.Object({
92
+ modelKey: 'metadata',
81
93
  }) });
@@ -10,6 +10,7 @@ export declare type ComponentProperties = {
10
10
  publicAccountId?: string;
11
11
  publicTokenId?: string;
12
12
  publicApplicationId?: string;
13
+ accessToken?: string;
13
14
  createdAt?: Date;
14
15
  updatedAt?: Date;
15
16
  };
@@ -23,9 +24,11 @@ export default class Component extends RestfulModel implements ComponentProperti
23
24
  publicAccountId?: string;
24
25
  publicTokenId?: string;
25
26
  publicApplicationId?: string;
27
+ accessToken?: string;
26
28
  createdAt?: Date;
27
29
  updatedAt?: Date;
28
30
  constructor(connection: NylasConnection, props?: ComponentProperties);
29
31
  saveEndpoint(): string;
30
32
  save(params?: {} | SaveCallback, callback?: SaveCallback): Promise<this>;
33
+ saveRequestBody(): Record<string, unknown>;
31
34
  }
@@ -43,6 +43,16 @@ var Component = /** @class */ (function (_super) {
43
43
  if (params === void 0) { params = {}; }
44
44
  return _super.prototype.save.call(this, params, callback);
45
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
+ };
46
56
  return Component;
47
57
  }(restful_model_1.default));
48
58
  exports.default = Component;
@@ -69,6 +79,9 @@ Component.attributes = __assign(__assign({}, restful_model_1.default.attributes)
69
79
  }), publicApplicationId: attributes_1.default.String({
70
80
  modelKey: 'publicApplicationId',
71
81
  jsonKey: 'public_application_id',
82
+ }), accessToken: attributes_1.default.String({
83
+ modelKey: 'accessToken',
84
+ jsonKey: 'access_token',
72
85
  }), createdAt: attributes_1.default.Date({
73
86
  modelKey: 'createdAt',
74
87
  jsonKey: 'created_at',