nylas 6.3.0 → 6.4.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.
@@ -64,10 +64,12 @@ export declare class CalendarConsecutiveAvailability extends Model implements Ca
64
64
  }
65
65
  export declare type CalendarAvailabilityProperties = {
66
66
  timeSlots: TimeSlotProperties[];
67
+ order?: string[];
67
68
  };
68
69
  export default class CalendarAvailability extends Model implements CalendarAvailabilityProperties {
69
70
  object: string;
70
71
  timeSlots: TimeSlot[];
72
+ order?: string[];
71
73
  static attributes: Record<string, Attribute>;
72
74
  constructor(props?: CalendarAvailabilityProperties);
73
75
  }
@@ -112,6 +112,9 @@ var CalendarAvailability = /** @class */ (function (_super) {
112
112
  jsonKey: 'time_slots',
113
113
  itemClass: free_busy_1.TimeSlot,
114
114
  }),
115
+ order: attributes_1.default.StringList({
116
+ modelKey: 'order',
117
+ }),
115
118
  };
116
119
  return CalendarAvailability;
117
120
  }(model_1.default));
@@ -67,8 +67,8 @@ var CalendarRestfulModelCollection = /** @class */ (function (_super) {
67
67
  callback(null, json);
68
68
  }
69
69
  var freeBusy = [];
70
- for (var _i = 0, _a = JSON.parse(json); _i < _a.length; _i++) {
71
- var fb = _a[_i];
70
+ for (var _i = 0, json_1 = json; _i < json_1.length; _i++) {
71
+ var fb = json_1[_i];
72
72
  freeBusy.push(new free_busy_1.default().fromJSON(fb));
73
73
  }
74
74
  return Promise.resolve(freeBusy);
@@ -7,6 +7,7 @@ export declare type DraftProperties = MessageProperties & {
7
7
  rawMime?: string;
8
8
  replyToMessageId?: string;
9
9
  version?: number;
10
+ fileIdsToAttach?: string[];
10
11
  };
11
12
  export default class Draft extends Message implements DraftProperties {
12
13
  rawMime?: string;
@@ -147,6 +147,9 @@ var Draft = /** @class */ (function (_super) {
147
147
  }), rawMime: attributes_1.default.String({
148
148
  modelKey: 'rawMime',
149
149
  readOnly: true,
150
+ }), fileIdsToAttach: attributes_1.default.StringList({
151
+ modelKey: 'fileIdsToAttach',
152
+ readOnly: true,
150
153
  }) });
151
154
  return Draft;
152
155
  }(message_1.default));
@@ -23,6 +23,7 @@ export declare type EventProperties = {
23
23
  when: WhenProperties;
24
24
  iCalUID?: string;
25
25
  messageId?: string;
26
+ eventCollectionId?: string | number;
26
27
  title?: string;
27
28
  description?: string;
28
29
  owner?: string;
@@ -37,8 +38,10 @@ export declare type EventProperties = {
37
38
  };
38
39
  masterEventId?: string;
39
40
  originalStartTime?: number;
41
+ capacity?: number;
40
42
  conferencing?: EventConferencingProperties;
41
43
  notifications?: EventNotificationProperties[];
44
+ roundRobinOrder?: string[];
42
45
  metadata?: object;
43
46
  jobStatusId?: string;
44
47
  };
@@ -47,6 +50,7 @@ export default class Event extends RestfulModel {
47
50
  when: When;
48
51
  iCalUID?: string;
49
52
  messageId?: string;
53
+ eventCollectionId?: string | number;
50
54
  title?: string;
51
55
  description?: string;
52
56
  owner?: string;
@@ -61,8 +65,10 @@ export default class Event extends RestfulModel {
61
65
  };
62
66
  masterEventId?: string;
63
67
  originalStartTime?: number;
68
+ capacity?: number;
64
69
  conferencing?: EventConferencing;
65
70
  notifications?: EventNotification[];
71
+ roundRobinOrder?: string[];
66
72
  metadata?: object;
67
73
  jobStatusId?: string;
68
74
  static collectionName: string;
@@ -77,4 +83,5 @@ export default class Event extends RestfulModel {
77
83
  saveRequestBody(): Record<string, unknown>;
78
84
  rsvp(status: string, comment: string, callback?: (error: Error | null, data?: Event) => void): Promise<Event>;
79
85
  generateICS(options?: ICSOptions): Promise<string>;
86
+ private validate;
80
87
  }
@@ -135,11 +135,7 @@ var Event = /** @class */ (function (_super) {
135
135
  };
136
136
  Event.prototype.save = function (params, callback) {
137
137
  if (params === void 0) { params = {}; }
138
- if (this.conferencing &&
139
- this.conferencing.details &&
140
- this.conferencing.autocreate) {
141
- return Promise.reject(new Error("Cannot set both 'details' and 'autocreate' in conferencing object."));
142
- }
138
+ this.validate();
143
139
  return _super.prototype.save.call(this, params, callback);
144
140
  };
145
141
  Event.prototype.saveRequestBody = function () {
@@ -196,6 +192,19 @@ var Event = /** @class */ (function (_super) {
196
192
  return response.ics;
197
193
  });
198
194
  };
195
+ Event.prototype.validate = function () {
196
+ if (this.conferencing &&
197
+ this.conferencing.details &&
198
+ this.conferencing.autocreate) {
199
+ throw new Error("Cannot set both 'details' and 'autocreate' in conferencing object.");
200
+ }
201
+ if (this.capacity &&
202
+ this.capacity != -1 &&
203
+ this.participants &&
204
+ this.participants.length > this.capacity) {
205
+ throw new Error('The number of participants in the event exceeds the set capacity.');
206
+ }
207
+ };
199
208
  Event.collectionName = 'events';
200
209
  Event.attributes = __assign(__assign({}, restful_model_1.default.attributes), { calendarId: attributes_1.default.String({
201
210
  modelKey: 'calendarId',
@@ -208,6 +217,9 @@ var Event = /** @class */ (function (_super) {
208
217
  modelKey: 'messageId',
209
218
  jsonKey: 'message_id',
210
219
  readOnly: true,
220
+ }), eventCollectionId: attributes_1.default.String({
221
+ modelKey: 'eventCollectionId',
222
+ jsonKey: 'event_collection_id',
211
223
  }), title: attributes_1.default.String({
212
224
  modelKey: 'title',
213
225
  }), description: attributes_1.default.String({
@@ -241,12 +253,17 @@ var Event = /** @class */ (function (_super) {
241
253
  modelKey: 'originalStartTime',
242
254
  jsonKey: 'original_start_time',
243
255
  readOnly: true,
256
+ }), capacity: attributes_1.default.Number({
257
+ modelKey: 'capacity',
244
258
  }), conferencing: attributes_1.default.Object({
245
259
  modelKey: 'conferencing',
246
260
  itemClass: event_conferencing_1.default,
247
261
  }), notifications: attributes_1.default.Collection({
248
262
  modelKey: 'notifications',
249
263
  itemClass: event_notification_1.default,
264
+ }), roundRobinOrder: attributes_1.default.StringList({
265
+ modelKey: 'roundRobinOrder',
266
+ jsonKey: 'round_robin_order',
250
267
  }), metadata: attributes_1.default.Object({
251
268
  modelKey: 'metadata',
252
269
  }), jobStatusId: attributes_1.default.String({
@@ -16,16 +16,32 @@ export declare class FreeBusyCalendar extends Model implements FreeBusyCalendarP
16
16
  static attributes: Record<string, Attribute>;
17
17
  constructor(props?: FreeBusyCalendarProperties);
18
18
  }
19
+ export declare type TimeSlotCapacityProperties = {
20
+ eventId: string;
21
+ currentCapacity: number;
22
+ maxCapacity: number;
23
+ };
24
+ export declare class TimeSlotCapacity extends Model implements TimeSlotCapacityProperties {
25
+ eventId: string;
26
+ currentCapacity: number;
27
+ maxCapacity: number;
28
+ static attributes: Record<string, Attribute>;
29
+ constructor(props?: TimeSlotCapacityProperties);
30
+ }
19
31
  export declare type TimeSlotProperties = {
20
32
  status: string;
21
33
  startTime: number;
22
34
  endTime: number;
35
+ emails?: string[];
36
+ capacity?: TimeSlotCapacityProperties;
23
37
  };
24
38
  export declare class TimeSlot extends Model implements TimeSlotProperties {
25
39
  object: string;
26
40
  status: string;
27
41
  startTime: number;
28
42
  endTime: number;
43
+ emails?: string[];
44
+ capacity?: TimeSlotCapacity;
29
45
  static attributes: Record<string, Attribute>;
30
46
  constructor(props?: TimeSlotProperties);
31
47
  }
@@ -40,6 +40,33 @@ var FreeBusyCalendar = /** @class */ (function (_super) {
40
40
  return FreeBusyCalendar;
41
41
  }(model_1.default));
42
42
  exports.FreeBusyCalendar = FreeBusyCalendar;
43
+ var TimeSlotCapacity = /** @class */ (function (_super) {
44
+ __extends(TimeSlotCapacity, _super);
45
+ function TimeSlotCapacity(props) {
46
+ var _this = _super.call(this) || this;
47
+ _this.eventId = '';
48
+ _this.currentCapacity = 0;
49
+ _this.maxCapacity = 0;
50
+ _this.initAttributes(props);
51
+ return _this;
52
+ }
53
+ TimeSlotCapacity.attributes = {
54
+ eventId: attributes_1.default.String({
55
+ modelKey: 'eventId',
56
+ jsonKey: 'event_id',
57
+ }),
58
+ currentCapacity: attributes_1.default.Number({
59
+ modelKey: 'currentCapacity',
60
+ jsonKey: 'current_capacity',
61
+ }),
62
+ maxCapacity: attributes_1.default.Number({
63
+ modelKey: 'maxCapacity',
64
+ jsonKey: 'max_capacity',
65
+ }),
66
+ };
67
+ return TimeSlotCapacity;
68
+ }(model_1.default));
69
+ exports.TimeSlotCapacity = TimeSlotCapacity;
43
70
  var TimeSlot = /** @class */ (function (_super) {
44
71
  __extends(TimeSlot, _super);
45
72
  function TimeSlot(props) {
@@ -66,6 +93,13 @@ var TimeSlot = /** @class */ (function (_super) {
66
93
  modelKey: 'endTime',
67
94
  jsonKey: 'end_time',
68
95
  }),
96
+ emails: attributes_1.default.StringList({
97
+ modelKey: 'emails',
98
+ }),
99
+ capacity: attributes_1.default.Object({
100
+ modelKey: 'capacity',
101
+ itemClass: TimeSlotCapacity,
102
+ }),
69
103
  };
70
104
  return TimeSlot;
71
105
  }(model_1.default));
@@ -51,6 +51,12 @@ var MessageRestfulModelCollection = /** @class */ (function (_super) {
51
51
  };
52
52
  delete options.view;
53
53
  }
54
+ // If only one message ID was passed in, use the normal find function
55
+ if (messageIds.length == 1) {
56
+ return this.find(messageIds[0], options).then(function (message) {
57
+ return [message];
58
+ });
59
+ }
54
60
  return this.range(__assign({ path: this.path() + "/" + messageIds.join() }, options));
55
61
  };
56
62
  /**
@@ -5,6 +5,7 @@ export default class ModelCollection<T extends Model> {
5
5
  connection: NylasConnection;
6
6
  modelClass: any;
7
7
  _path: string;
8
+ baseUrl?: string;
8
9
  constructor(modelClass: any, connection: NylasConnection, path: string);
9
10
  forEach(params: Record<string, unknown> | undefined, eachCallback: (item: T) => void, completeCallback?: (err?: Error | null | undefined) => void): void;
10
11
  list(params?: Record<string, unknown>, callback?: (error: Error | null, obj?: T[]) => void): Promise<T[]>;
@@ -157,6 +157,7 @@ var ModelCollection = /** @class */ (function () {
157
157
  method: 'GET',
158
158
  path: path,
159
159
  qs: __assign(__assign({}, params), { offset: offset, limit: limit }),
160
+ baseUrl: this.baseUrl,
160
161
  });
161
162
  }
162
163
  return this.getModelCollection(params, offset, limit, path);
@@ -172,6 +173,7 @@ var ModelCollection = /** @class */ (function () {
172
173
  method: 'GET',
173
174
  path: this.path() + "/" + id,
174
175
  qs: params,
176
+ baseUrl: this.baseUrl,
175
177
  })
176
178
  .then(function (json) {
177
179
  var model = _this.createModel(json);
@@ -185,6 +187,7 @@ var ModelCollection = /** @class */ (function () {
185
187
  method: 'GET',
186
188
  path: path,
187
189
  qs: __assign(__assign({}, params), { offset: offset, limit: limit }),
190
+ baseUrl: this.baseUrl,
188
191
  })
189
192
  .then(function (jsonArray) {
190
193
  var models = jsonArray.map(function (json) {
@@ -4,7 +4,6 @@ import ModelCollection from './model-collection';
4
4
  export declare type GetCallback = (error: Error | null, result?: RestfulModel) => void;
5
5
  export default class RestfulModelCollection<T extends RestfulModel> extends ModelCollection<any> {
6
6
  modelClass: typeof RestfulModel;
7
- baseUrl?: string;
8
7
  constructor(modelClass: typeof RestfulModel, connection: NylasConnection);
9
8
  count(params?: Record<string, unknown>, callback?: (err: Error | null, num?: number) => void): Promise<number>;
10
9
  first(params?: Record<string, unknown>, callback?: (error: Error | null, model?: T) => void): Promise<T>;
@@ -14,6 +14,7 @@ export declare type ProviderAvailability = {
14
14
  export default class SchedulerRestfulModelCollection extends RestfulModelCollection<Scheduler> {
15
15
  connection: NylasConnection;
16
16
  modelClass: typeof Scheduler;
17
+ baseUrl: string;
17
18
  constructor(connection: NylasConnection);
18
19
  getGoogleAvailability(): Promise<ProviderAvailability>;
19
20
  getOffice365Availability(): Promise<ProviderAvailability>;
@@ -153,6 +153,7 @@ export declare type SchedulerConfigProperties = {
153
153
  };
154
154
  event?: {
155
155
  duration?: number;
156
+ capacity?: number;
156
157
  location?: string;
157
158
  title?: string;
158
159
  };
@@ -176,6 +177,7 @@ export declare class SchedulerConfig extends Model implements SchedulerConfigPro
176
177
  };
177
178
  event?: {
178
179
  duration?: number;
180
+ capacity?: number;
179
181
  location?: string;
180
182
  title?: string;
181
183
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nylas",
3
- "version": "6.3.0",
3
+ "version": "6.4.0",
4
4
  "description": "A NodeJS wrapper for the Nylas REST API for email, contacts, and calendar.",
5
5
  "main": "lib/nylas.js",
6
6
  "types": "lib/nylas.d.ts",