files.com 1.2.258 → 1.2.259

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.
@@ -0,0 +1,676 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ exports.__esModule = true;
6
+ exports.default = void 0;
7
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
8
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+ var _Api = _interopRequireDefault(require("../Api"));
14
+ var errors = _interopRequireWildcard(require("../Errors"));
15
+ var _utils = require("../utils");
16
+ var _Sync;
17
+ /* eslint-disable no-unused-vars */
18
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
19
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
20
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
21
+ /* eslint-enable no-unused-vars */
22
+ /**
23
+ * Class Sync
24
+ */
25
+ var Sync = /*#__PURE__*/(0, _createClass2.default)(function Sync() {
26
+ var _this = this;
27
+ var attributes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
28
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
29
+ (0, _classCallCheck2.default)(this, Sync);
30
+ (0, _defineProperty2.default)(this, "attributes", {});
31
+ (0, _defineProperty2.default)(this, "options", {});
32
+ (0, _defineProperty2.default)(this, "isLoaded", function () {
33
+ return !!_this.attributes.id;
34
+ });
35
+ // int64 # Sync ID
36
+ (0, _defineProperty2.default)(this, "getId", function () {
37
+ return _this.attributes.id;
38
+ });
39
+ (0, _defineProperty2.default)(this, "setId", function (value) {
40
+ _this.attributes.id = value;
41
+ });
42
+ // string # Name for this sync job
43
+ (0, _defineProperty2.default)(this, "getName", function () {
44
+ return _this.attributes.name;
45
+ });
46
+ (0, _defineProperty2.default)(this, "setName", function (value) {
47
+ _this.attributes.name = value;
48
+ });
49
+ // string # Description for this sync job
50
+ (0, _defineProperty2.default)(this, "getDescription", function () {
51
+ return _this.attributes.description;
52
+ });
53
+ (0, _defineProperty2.default)(this, "setDescription", function (value) {
54
+ _this.attributes.description = value;
55
+ });
56
+ // int64 # Site ID this sync belongs to
57
+ (0, _defineProperty2.default)(this, "getSiteId", function () {
58
+ return _this.attributes.site_id;
59
+ });
60
+ (0, _defineProperty2.default)(this, "setSiteId", function (value) {
61
+ _this.attributes.site_id = value;
62
+ });
63
+ // int64 # User who created or owns this sync
64
+ (0, _defineProperty2.default)(this, "getUserId", function () {
65
+ return _this.attributes.user_id;
66
+ });
67
+ (0, _defineProperty2.default)(this, "setUserId", function (value) {
68
+ _this.attributes.user_id = value;
69
+ });
70
+ // string # Absolute source path for the sync
71
+ (0, _defineProperty2.default)(this, "getSrcPath", function () {
72
+ return _this.attributes.src_path;
73
+ });
74
+ (0, _defineProperty2.default)(this, "setSrcPath", function (value) {
75
+ _this.attributes.src_path = value;
76
+ });
77
+ // string # Absolute destination path for the sync
78
+ (0, _defineProperty2.default)(this, "getDestPath", function () {
79
+ return _this.attributes.dest_path;
80
+ });
81
+ (0, _defineProperty2.default)(this, "setDestPath", function (value) {
82
+ _this.attributes.dest_path = value;
83
+ });
84
+ // int64 # Remote server ID for the source (if remote)
85
+ (0, _defineProperty2.default)(this, "getSrcRemoteServerId", function () {
86
+ return _this.attributes.src_remote_server_id;
87
+ });
88
+ (0, _defineProperty2.default)(this, "setSrcRemoteServerId", function (value) {
89
+ _this.attributes.src_remote_server_id = value;
90
+ });
91
+ // int64 # Remote server ID for the destination (if remote)
92
+ (0, _defineProperty2.default)(this, "getDestRemoteServerId", function () {
93
+ return _this.attributes.dest_remote_server_id;
94
+ });
95
+ (0, _defineProperty2.default)(this, "setDestRemoteServerId", function (value) {
96
+ _this.attributes.dest_remote_server_id = value;
97
+ });
98
+ // boolean # Is this a two-way sync?
99
+ (0, _defineProperty2.default)(this, "getTwoWay", function () {
100
+ return _this.attributes.two_way;
101
+ });
102
+ (0, _defineProperty2.default)(this, "setTwoWay", function (value) {
103
+ _this.attributes.two_way = value;
104
+ });
105
+ // boolean # Keep files after copying?
106
+ (0, _defineProperty2.default)(this, "getKeepAfterCopy", function () {
107
+ return _this.attributes.keep_after_copy;
108
+ });
109
+ (0, _defineProperty2.default)(this, "setKeepAfterCopy", function (value) {
110
+ _this.attributes.keep_after_copy = value;
111
+ });
112
+ // boolean # Delete empty folders after sync?
113
+ (0, _defineProperty2.default)(this, "getDeleteEmptyFolders", function () {
114
+ return _this.attributes.delete_empty_folders;
115
+ });
116
+ (0, _defineProperty2.default)(this, "setDeleteEmptyFolders", function (value) {
117
+ _this.attributes.delete_empty_folders = value;
118
+ });
119
+ // boolean # Is this sync disabled?
120
+ (0, _defineProperty2.default)(this, "getDisabled", function () {
121
+ return _this.attributes.disabled;
122
+ });
123
+ (0, _defineProperty2.default)(this, "setDisabled", function (value) {
124
+ _this.attributes.disabled = value;
125
+ });
126
+ // string # If trigger is `daily`, this specifies how often to run this sync. One of: `day`, `week`, `week_end`, `month`, `month_end`, `quarter`, `quarter_end`, `year`, `year_end`
127
+ (0, _defineProperty2.default)(this, "getInterval", function () {
128
+ return _this.attributes.interval;
129
+ });
130
+ (0, _defineProperty2.default)(this, "setInterval", function (value) {
131
+ _this.attributes.interval = value;
132
+ });
133
+ // string # Trigger type: daily, custom_schedule, or manual
134
+ (0, _defineProperty2.default)(this, "getTrigger", function () {
135
+ return _this.attributes.trigger;
136
+ });
137
+ (0, _defineProperty2.default)(this, "setTrigger", function (value) {
138
+ _this.attributes.trigger = value;
139
+ });
140
+ // string # Some MFT services request an empty file (known as a trigger file) to signal the sync is complete and they can begin further processing. If trigger_file is set, a zero-byte file will be sent at the end of the sync.
141
+ (0, _defineProperty2.default)(this, "getTriggerFile", function () {
142
+ return _this.attributes.trigger_file;
143
+ });
144
+ (0, _defineProperty2.default)(this, "setTriggerFile", function (value) {
145
+ _this.attributes.trigger_file = value;
146
+ });
147
+ // array(array) # Array of glob patterns to include
148
+ (0, _defineProperty2.default)(this, "getIncludePatterns", function () {
149
+ return _this.attributes.include_patterns;
150
+ });
151
+ (0, _defineProperty2.default)(this, "setIncludePatterns", function (value) {
152
+ _this.attributes.include_patterns = value;
153
+ });
154
+ // array(array) # Array of glob patterns to exclude
155
+ (0, _defineProperty2.default)(this, "getExcludePatterns", function () {
156
+ return _this.attributes.exclude_patterns;
157
+ });
158
+ (0, _defineProperty2.default)(this, "setExcludePatterns", function (value) {
159
+ _this.attributes.exclude_patterns = value;
160
+ });
161
+ // date-time # When this sync was created
162
+ (0, _defineProperty2.default)(this, "getCreatedAt", function () {
163
+ return _this.attributes.created_at;
164
+ });
165
+ // date-time # When this sync was last updated
166
+ (0, _defineProperty2.default)(this, "getUpdatedAt", function () {
167
+ return _this.attributes.updated_at;
168
+ });
169
+ // int64 # Frequency in minutes between syncs. If set, this value must be greater than or equal to the `remote_sync_interval` value for the site's plan. If left blank, the plan's `remote_sync_interval` will be used. This setting is only used if `trigger` is empty.
170
+ (0, _defineProperty2.default)(this, "getSyncIntervalMinutes", function () {
171
+ return _this.attributes.sync_interval_minutes;
172
+ });
173
+ (0, _defineProperty2.default)(this, "setSyncIntervalMinutes", function (value) {
174
+ _this.attributes.sync_interval_minutes = value;
175
+ });
176
+ // int64 # If trigger type is `daily`, this specifies a day number to run in one of the supported intervals: `week`, `month`, `quarter`, `year`.
177
+ (0, _defineProperty2.default)(this, "getRecurringDay", function () {
178
+ return _this.attributes.recurring_day;
179
+ });
180
+ (0, _defineProperty2.default)(this, "setRecurringDay", function (value) {
181
+ _this.attributes.recurring_day = value;
182
+ });
183
+ // array(int64) # If trigger is `custom_schedule`, Custom schedule description for when the sync should be run. 0-based days of the week. 0 is Sunday, 1 is Monday, etc.
184
+ (0, _defineProperty2.default)(this, "getScheduleDaysOfWeek", function () {
185
+ return _this.attributes.schedule_days_of_week;
186
+ });
187
+ (0, _defineProperty2.default)(this, "setScheduleDaysOfWeek", function (value) {
188
+ _this.attributes.schedule_days_of_week = value;
189
+ });
190
+ // array(string) # If trigger is `custom_schedule`, Custom schedule description for when the sync should be run. Times of day in HH:MM format.
191
+ (0, _defineProperty2.default)(this, "getScheduleTimesOfDay", function () {
192
+ return _this.attributes.schedule_times_of_day;
193
+ });
194
+ (0, _defineProperty2.default)(this, "setScheduleTimesOfDay", function (value) {
195
+ _this.attributes.schedule_times_of_day = value;
196
+ });
197
+ // string # If trigger is `custom_schedule`, Custom schedule Time Zone for when the sync should be run.
198
+ (0, _defineProperty2.default)(this, "getScheduleTimeZone", function () {
199
+ return _this.attributes.schedule_time_zone;
200
+ });
201
+ (0, _defineProperty2.default)(this, "setScheduleTimeZone", function (value) {
202
+ _this.attributes.schedule_time_zone = value;
203
+ });
204
+ // Parameters:
205
+ // name - string - Name for this sync job
206
+ // description - string - Description for this sync job
207
+ // src_path - string - Absolute source path
208
+ // dest_path - string - Absolute destination path
209
+ // src_remote_server_id - int64 - Remote server ID for the source
210
+ // dest_remote_server_id - int64 - Remote server ID for the destination
211
+ // two_way - boolean - Is this a two-way sync?
212
+ // keep_after_copy - boolean - Keep files after copying?
213
+ // delete_empty_folders - boolean - Delete empty folders after sync?
214
+ // disabled - boolean - Is this sync disabled?
215
+ // interval - int64 - Interval in minutes for sync (if scheduled)
216
+ // trigger - string - Trigger type: daily, custom_schedule, or manual
217
+ // trigger_file - string - Some MFT services request an empty file (known as a trigger file) to signal the sync is complete and they can begin further processing. If trigger_file is set, a zero-byte file will be sent at the end of the sync.
218
+ // recurring_day - int64 - If trigger type is `daily`, this specifies a day number to run in one of the supported intervals: `week`, `month`, `quarter`, `year`.
219
+ // schedule_time_zone - string - If trigger is `custom_schedule`, Custom schedule Time Zone for when the sync should be run.
220
+ // schedule_days_of_week - array(int64) - If trigger is `custom_schedule`, Custom schedule description for when the sync should be run. 0-based days of the week. 0 is Sunday, 1 is Monday, etc.
221
+ // schedule_times_of_day - array(string) - If trigger is `custom_schedule`, Custom schedule description for when the sync should be run. Times of day in HH:MM format.
222
+ (0, _defineProperty2.default)(this, "update", /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee() {
223
+ var params,
224
+ response,
225
+ _args = arguments;
226
+ return _regenerator.default.wrap(function (_context) {
227
+ while (1) switch (_context.prev = _context.next) {
228
+ case 0:
229
+ params = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
230
+ if (_this.attributes.id) {
231
+ _context.next = 1;
232
+ break;
233
+ }
234
+ throw new errors.EmptyPropertyError('Current object has no id');
235
+ case 1:
236
+ if ((0, _utils.isObject)(params)) {
237
+ _context.next = 2;
238
+ break;
239
+ }
240
+ throw new errors.InvalidParameterError("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
241
+ case 2:
242
+ params.id = _this.attributes.id;
243
+ if (!(params.id && !(0, _utils.isInt)(params.id))) {
244
+ _context.next = 3;
245
+ break;
246
+ }
247
+ throw new errors.InvalidParameterError("Bad parameter: id must be of type Int, received ".concat((0, _utils.getType)(params.id)));
248
+ case 3:
249
+ if (!(params.name && !(0, _utils.isString)(params.name))) {
250
+ _context.next = 4;
251
+ break;
252
+ }
253
+ throw new errors.InvalidParameterError("Bad parameter: name must be of type String, received ".concat((0, _utils.getType)(params.name)));
254
+ case 4:
255
+ if (!(params.description && !(0, _utils.isString)(params.description))) {
256
+ _context.next = 5;
257
+ break;
258
+ }
259
+ throw new errors.InvalidParameterError("Bad parameter: description must be of type String, received ".concat((0, _utils.getType)(params.description)));
260
+ case 5:
261
+ if (!(params.src_path && !(0, _utils.isString)(params.src_path))) {
262
+ _context.next = 6;
263
+ break;
264
+ }
265
+ throw new errors.InvalidParameterError("Bad parameter: src_path must be of type String, received ".concat((0, _utils.getType)(params.src_path)));
266
+ case 6:
267
+ if (!(params.dest_path && !(0, _utils.isString)(params.dest_path))) {
268
+ _context.next = 7;
269
+ break;
270
+ }
271
+ throw new errors.InvalidParameterError("Bad parameter: dest_path must be of type String, received ".concat((0, _utils.getType)(params.dest_path)));
272
+ case 7:
273
+ if (!(params.src_remote_server_id && !(0, _utils.isInt)(params.src_remote_server_id))) {
274
+ _context.next = 8;
275
+ break;
276
+ }
277
+ throw new errors.InvalidParameterError("Bad parameter: src_remote_server_id must be of type Int, received ".concat((0, _utils.getType)(params.src_remote_server_id)));
278
+ case 8:
279
+ if (!(params.dest_remote_server_id && !(0, _utils.isInt)(params.dest_remote_server_id))) {
280
+ _context.next = 9;
281
+ break;
282
+ }
283
+ throw new errors.InvalidParameterError("Bad parameter: dest_remote_server_id must be of type Int, received ".concat((0, _utils.getType)(params.dest_remote_server_id)));
284
+ case 9:
285
+ if (!(params.interval && !(0, _utils.isInt)(params.interval))) {
286
+ _context.next = 10;
287
+ break;
288
+ }
289
+ throw new errors.InvalidParameterError("Bad parameter: interval must be of type Int, received ".concat((0, _utils.getType)(params.interval)));
290
+ case 10:
291
+ if (!(params.trigger && !(0, _utils.isString)(params.trigger))) {
292
+ _context.next = 11;
293
+ break;
294
+ }
295
+ throw new errors.InvalidParameterError("Bad parameter: trigger must be of type String, received ".concat((0, _utils.getType)(params.trigger)));
296
+ case 11:
297
+ if (!(params.trigger_file && !(0, _utils.isString)(params.trigger_file))) {
298
+ _context.next = 12;
299
+ break;
300
+ }
301
+ throw new errors.InvalidParameterError("Bad parameter: trigger_file must be of type String, received ".concat((0, _utils.getType)(params.trigger_file)));
302
+ case 12:
303
+ if (!(params.recurring_day && !(0, _utils.isInt)(params.recurring_day))) {
304
+ _context.next = 13;
305
+ break;
306
+ }
307
+ throw new errors.InvalidParameterError("Bad parameter: recurring_day must be of type Int, received ".concat((0, _utils.getType)(params.recurring_day)));
308
+ case 13:
309
+ if (!(params.schedule_time_zone && !(0, _utils.isString)(params.schedule_time_zone))) {
310
+ _context.next = 14;
311
+ break;
312
+ }
313
+ throw new errors.InvalidParameterError("Bad parameter: schedule_time_zone must be of type String, received ".concat((0, _utils.getType)(params.schedule_time_zone)));
314
+ case 14:
315
+ if (!(params.schedule_days_of_week && !(0, _utils.isArray)(params.schedule_days_of_week))) {
316
+ _context.next = 15;
317
+ break;
318
+ }
319
+ throw new errors.InvalidParameterError("Bad parameter: schedule_days_of_week must be of type Array, received ".concat((0, _utils.getType)(params.schedule_days_of_week)));
320
+ case 15:
321
+ if (!(params.schedule_times_of_day && !(0, _utils.isArray)(params.schedule_times_of_day))) {
322
+ _context.next = 16;
323
+ break;
324
+ }
325
+ throw new errors.InvalidParameterError("Bad parameter: schedule_times_of_day must be of type Array, received ".concat((0, _utils.getType)(params.schedule_times_of_day)));
326
+ case 16:
327
+ if (params.id) {
328
+ _context.next = 18;
329
+ break;
330
+ }
331
+ if (!_this.attributes.id) {
332
+ _context.next = 17;
333
+ break;
334
+ }
335
+ params.id = _this.id;
336
+ _context.next = 18;
337
+ break;
338
+ case 17:
339
+ throw new errors.MissingParameterError('Parameter missing: id');
340
+ case 18:
341
+ _context.next = 19;
342
+ return _Api.default.sendRequest("/syncs/".concat(encodeURIComponent(params.id)), 'PATCH', params, _this.options);
343
+ case 19:
344
+ response = _context.sent;
345
+ return _context.abrupt("return", new Sync(response === null || response === void 0 ? void 0 : response.data, _this.options));
346
+ case 20:
347
+ case "end":
348
+ return _context.stop();
349
+ }
350
+ }, _callee);
351
+ })));
352
+ (0, _defineProperty2.default)(this, "delete", /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee2() {
353
+ var params,
354
+ _args2 = arguments;
355
+ return _regenerator.default.wrap(function (_context2) {
356
+ while (1) switch (_context2.prev = _context2.next) {
357
+ case 0:
358
+ params = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
359
+ if (_this.attributes.id) {
360
+ _context2.next = 1;
361
+ break;
362
+ }
363
+ throw new errors.EmptyPropertyError('Current object has no id');
364
+ case 1:
365
+ if ((0, _utils.isObject)(params)) {
366
+ _context2.next = 2;
367
+ break;
368
+ }
369
+ throw new errors.InvalidParameterError("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
370
+ case 2:
371
+ params.id = _this.attributes.id;
372
+ if (!(params.id && !(0, _utils.isInt)(params.id))) {
373
+ _context2.next = 3;
374
+ break;
375
+ }
376
+ throw new errors.InvalidParameterError("Bad parameter: id must be of type Int, received ".concat((0, _utils.getType)(params.id)));
377
+ case 3:
378
+ if (params.id) {
379
+ _context2.next = 5;
380
+ break;
381
+ }
382
+ if (!_this.attributes.id) {
383
+ _context2.next = 4;
384
+ break;
385
+ }
386
+ params.id = _this.id;
387
+ _context2.next = 5;
388
+ break;
389
+ case 4:
390
+ throw new errors.MissingParameterError('Parameter missing: id');
391
+ case 5:
392
+ _context2.next = 6;
393
+ return _Api.default.sendRequest("/syncs/".concat(encodeURIComponent(params.id)), 'DELETE', params, _this.options);
394
+ case 6:
395
+ case "end":
396
+ return _context2.stop();
397
+ }
398
+ }, _callee2);
399
+ })));
400
+ (0, _defineProperty2.default)(this, "destroy", function () {
401
+ var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
402
+ return _this.delete(params);
403
+ });
404
+ (0, _defineProperty2.default)(this, "save", /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee3() {
405
+ var _newObject, newObject;
406
+ return _regenerator.default.wrap(function (_context3) {
407
+ while (1) switch (_context3.prev = _context3.next) {
408
+ case 0:
409
+ if (!_this.attributes.id) {
410
+ _context3.next = 2;
411
+ break;
412
+ }
413
+ _context3.next = 1;
414
+ return _this.update(_this.attributes);
415
+ case 1:
416
+ _newObject = _context3.sent;
417
+ _this.attributes = _objectSpread({}, _newObject.attributes);
418
+ return _context3.abrupt("return", true);
419
+ case 2:
420
+ _context3.next = 3;
421
+ return Sync.create(_this.attributes, _this.options);
422
+ case 3:
423
+ newObject = _context3.sent;
424
+ _this.attributes = _objectSpread({}, newObject.attributes);
425
+ return _context3.abrupt("return", true);
426
+ case 4:
427
+ case "end":
428
+ return _context3.stop();
429
+ }
430
+ }, _callee3);
431
+ })));
432
+ Object.entries(attributes).forEach(function (_ref4) {
433
+ var _ref5 = (0, _slicedToArray2.default)(_ref4, 2),
434
+ key = _ref5[0],
435
+ value = _ref5[1];
436
+ var normalizedKey = key.replace('?', '');
437
+ _this.attributes[normalizedKey] = value;
438
+ Object.defineProperty(_this, normalizedKey, {
439
+ value: value,
440
+ writable: false
441
+ });
442
+ });
443
+ this.options = _objectSpread({}, options);
444
+ });
445
+ _Sync = Sync;
446
+ // Parameters:
447
+ // cursor - string - Used for pagination. When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`. Send one of those cursor value here to resume an existing list from the next available record. Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
448
+ // per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
449
+ (0, _defineProperty2.default)(Sync, "list", /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee4() {
450
+ var _response$data;
451
+ var params,
452
+ options,
453
+ response,
454
+ _args4 = arguments;
455
+ return _regenerator.default.wrap(function (_context4) {
456
+ while (1) switch (_context4.prev = _context4.next) {
457
+ case 0:
458
+ params = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {};
459
+ options = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
460
+ if (!(params.cursor && !(0, _utils.isString)(params.cursor))) {
461
+ _context4.next = 1;
462
+ break;
463
+ }
464
+ throw new errors.InvalidParameterError("Bad parameter: cursor must be of type String, received ".concat((0, _utils.getType)(params.cursor)));
465
+ case 1:
466
+ if (!(params.per_page && !(0, _utils.isInt)(params.per_page))) {
467
+ _context4.next = 2;
468
+ break;
469
+ }
470
+ throw new errors.InvalidParameterError("Bad parameter: per_page must be of type Int, received ".concat((0, _utils.getType)(params.per_page)));
471
+ case 2:
472
+ _context4.next = 3;
473
+ return _Api.default.sendRequest('/syncs', 'GET', params, options);
474
+ case 3:
475
+ response = _context4.sent;
476
+ return _context4.abrupt("return", (response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.map(function (obj) {
477
+ return new _Sync(obj, options);
478
+ })) || []);
479
+ case 4:
480
+ case "end":
481
+ return _context4.stop();
482
+ }
483
+ }, _callee4);
484
+ })));
485
+ (0, _defineProperty2.default)(Sync, "all", function () {
486
+ var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
487
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
488
+ return _Sync.list(params, options);
489
+ });
490
+ // Parameters:
491
+ // id (required) - int64 - Sync ID.
492
+ (0, _defineProperty2.default)(Sync, "find", /*#__PURE__*/function () {
493
+ var _ref7 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee5(id) {
494
+ var params,
495
+ options,
496
+ response,
497
+ _args5 = arguments;
498
+ return _regenerator.default.wrap(function (_context5) {
499
+ while (1) switch (_context5.prev = _context5.next) {
500
+ case 0:
501
+ params = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {};
502
+ options = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : {};
503
+ if ((0, _utils.isObject)(params)) {
504
+ _context5.next = 1;
505
+ break;
506
+ }
507
+ throw new errors.InvalidParameterError("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
508
+ case 1:
509
+ params.id = id;
510
+ if (params.id) {
511
+ _context5.next = 2;
512
+ break;
513
+ }
514
+ throw new errors.MissingParameterError('Parameter missing: id');
515
+ case 2:
516
+ if (!(params.id && !(0, _utils.isInt)(params.id))) {
517
+ _context5.next = 3;
518
+ break;
519
+ }
520
+ throw new errors.InvalidParameterError("Bad parameter: id must be of type Int, received ".concat((0, _utils.getType)(params.id)));
521
+ case 3:
522
+ _context5.next = 4;
523
+ return _Api.default.sendRequest("/syncs/".concat(encodeURIComponent(params.id)), 'GET', params, options);
524
+ case 4:
525
+ response = _context5.sent;
526
+ return _context5.abrupt("return", new _Sync(response === null || response === void 0 ? void 0 : response.data, options));
527
+ case 5:
528
+ case "end":
529
+ return _context5.stop();
530
+ }
531
+ }, _callee5);
532
+ }));
533
+ return function (_x) {
534
+ return _ref7.apply(this, arguments);
535
+ };
536
+ }());
537
+ (0, _defineProperty2.default)(Sync, "get", function (id) {
538
+ var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
539
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
540
+ return _Sync.find(id, params, options);
541
+ });
542
+ // Parameters:
543
+ // name - string - Name for this sync job
544
+ // description - string - Description for this sync job
545
+ // src_path - string - Absolute source path
546
+ // dest_path - string - Absolute destination path
547
+ // src_remote_server_id - int64 - Remote server ID for the source
548
+ // dest_remote_server_id - int64 - Remote server ID for the destination
549
+ // two_way - boolean - Is this a two-way sync?
550
+ // keep_after_copy - boolean - Keep files after copying?
551
+ // delete_empty_folders - boolean - Delete empty folders after sync?
552
+ // disabled - boolean - Is this sync disabled?
553
+ // interval - int64 - Interval in minutes for sync (if scheduled)
554
+ // trigger - string - Trigger type: daily, custom_schedule, or manual
555
+ // trigger_file - string - Some MFT services request an empty file (known as a trigger file) to signal the sync is complete and they can begin further processing. If trigger_file is set, a zero-byte file will be sent at the end of the sync.
556
+ // recurring_day - int64 - If trigger type is `daily`, this specifies a day number to run in one of the supported intervals: `week`, `month`, `quarter`, `year`.
557
+ // schedule_time_zone - string - If trigger is `custom_schedule`, Custom schedule Time Zone for when the sync should be run.
558
+ // schedule_days_of_week - array(int64) - If trigger is `custom_schedule`, Custom schedule description for when the sync should be run. 0-based days of the week. 0 is Sunday, 1 is Monday, etc.
559
+ // schedule_times_of_day - array(string) - If trigger is `custom_schedule`, Custom schedule description for when the sync should be run. Times of day in HH:MM format.
560
+ (0, _defineProperty2.default)(Sync, "create", /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee6() {
561
+ var params,
562
+ options,
563
+ response,
564
+ _args6 = arguments;
565
+ return _regenerator.default.wrap(function (_context6) {
566
+ while (1) switch (_context6.prev = _context6.next) {
567
+ case 0:
568
+ params = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {};
569
+ options = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : {};
570
+ if (!(params.name && !(0, _utils.isString)(params.name))) {
571
+ _context6.next = 1;
572
+ break;
573
+ }
574
+ throw new errors.InvalidParameterError("Bad parameter: name must be of type String, received ".concat((0, _utils.getType)(params.name)));
575
+ case 1:
576
+ if (!(params.description && !(0, _utils.isString)(params.description))) {
577
+ _context6.next = 2;
578
+ break;
579
+ }
580
+ throw new errors.InvalidParameterError("Bad parameter: description must be of type String, received ".concat((0, _utils.getType)(params.description)));
581
+ case 2:
582
+ if (!(params.src_path && !(0, _utils.isString)(params.src_path))) {
583
+ _context6.next = 3;
584
+ break;
585
+ }
586
+ throw new errors.InvalidParameterError("Bad parameter: src_path must be of type String, received ".concat((0, _utils.getType)(params.src_path)));
587
+ case 3:
588
+ if (!(params.dest_path && !(0, _utils.isString)(params.dest_path))) {
589
+ _context6.next = 4;
590
+ break;
591
+ }
592
+ throw new errors.InvalidParameterError("Bad parameter: dest_path must be of type String, received ".concat((0, _utils.getType)(params.dest_path)));
593
+ case 4:
594
+ if (!(params.src_remote_server_id && !(0, _utils.isInt)(params.src_remote_server_id))) {
595
+ _context6.next = 5;
596
+ break;
597
+ }
598
+ throw new errors.InvalidParameterError("Bad parameter: src_remote_server_id must be of type Int, received ".concat((0, _utils.getType)(params.src_remote_server_id)));
599
+ case 5:
600
+ if (!(params.dest_remote_server_id && !(0, _utils.isInt)(params.dest_remote_server_id))) {
601
+ _context6.next = 6;
602
+ break;
603
+ }
604
+ throw new errors.InvalidParameterError("Bad parameter: dest_remote_server_id must be of type Int, received ".concat((0, _utils.getType)(params.dest_remote_server_id)));
605
+ case 6:
606
+ if (!(params.interval && !(0, _utils.isInt)(params.interval))) {
607
+ _context6.next = 7;
608
+ break;
609
+ }
610
+ throw new errors.InvalidParameterError("Bad parameter: interval must be of type Int, received ".concat((0, _utils.getType)(params.interval)));
611
+ case 7:
612
+ if (!(params.trigger && !(0, _utils.isString)(params.trigger))) {
613
+ _context6.next = 8;
614
+ break;
615
+ }
616
+ throw new errors.InvalidParameterError("Bad parameter: trigger must be of type String, received ".concat((0, _utils.getType)(params.trigger)));
617
+ case 8:
618
+ if (!(params.trigger_file && !(0, _utils.isString)(params.trigger_file))) {
619
+ _context6.next = 9;
620
+ break;
621
+ }
622
+ throw new errors.InvalidParameterError("Bad parameter: trigger_file must be of type String, received ".concat((0, _utils.getType)(params.trigger_file)));
623
+ case 9:
624
+ if (!(params.recurring_day && !(0, _utils.isInt)(params.recurring_day))) {
625
+ _context6.next = 10;
626
+ break;
627
+ }
628
+ throw new errors.InvalidParameterError("Bad parameter: recurring_day must be of type Int, received ".concat((0, _utils.getType)(params.recurring_day)));
629
+ case 10:
630
+ if (!(params.schedule_time_zone && !(0, _utils.isString)(params.schedule_time_zone))) {
631
+ _context6.next = 11;
632
+ break;
633
+ }
634
+ throw new errors.InvalidParameterError("Bad parameter: schedule_time_zone must be of type String, received ".concat((0, _utils.getType)(params.schedule_time_zone)));
635
+ case 11:
636
+ if (!(params.schedule_days_of_week && !(0, _utils.isArray)(params.schedule_days_of_week))) {
637
+ _context6.next = 12;
638
+ break;
639
+ }
640
+ throw new errors.InvalidParameterError("Bad parameter: schedule_days_of_week must be of type Array, received ".concat((0, _utils.getType)(params.schedule_days_of_week)));
641
+ case 12:
642
+ if (!(params.schedule_times_of_day && !(0, _utils.isArray)(params.schedule_times_of_day))) {
643
+ _context6.next = 13;
644
+ break;
645
+ }
646
+ throw new errors.InvalidParameterError("Bad parameter: schedule_times_of_day must be of type Array, received ".concat((0, _utils.getType)(params.schedule_times_of_day)));
647
+ case 13:
648
+ _context6.next = 14;
649
+ return _Api.default.sendRequest('/syncs', 'POST', params, options);
650
+ case 14:
651
+ response = _context6.sent;
652
+ return _context6.abrupt("return", new _Sync(response === null || response === void 0 ? void 0 : response.data, options));
653
+ case 15:
654
+ case "end":
655
+ return _context6.stop();
656
+ }
657
+ }, _callee6);
658
+ })));
659
+ (0, _defineProperty2.default)(Sync, "createMigrateTo", /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee7() {
660
+ var options,
661
+ _args7 = arguments;
662
+ return _regenerator.default.wrap(function (_context7) {
663
+ while (1) switch (_context7.prev = _context7.next) {
664
+ case 0:
665
+ options = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : {};
666
+ _context7.next = 1;
667
+ return _Api.default.sendRequest('/syncs/migrate_to_syncs', 'POST', {}, options);
668
+ case 1:
669
+ case "end":
670
+ return _context7.stop();
671
+ }
672
+ }, _callee7);
673
+ })));
674
+ var _default = exports.default = Sync;
675
+ module.exports = Sync;
676
+ module.exports.default = Sync;