files.com 1.0.221 → 1.0.223
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.
- package/_VERSION +1 -1
- package/docs/models/Bundle.md +14 -0
- package/lib/Api.js +15 -82
- package/lib/Errors.js +9 -962
- package/lib/Files.js +0 -11
- package/lib/Logger.js +0 -24
- package/lib/index.js +0 -5
- package/lib/isomorphic/File.node.js +0 -19
- package/lib/models/AccountLineItem.js +3 -21
- package/lib/models/Action.js +3 -21
- package/lib/models/ActionNotificationExport.js +9 -61
- package/lib/models/ActionNotificationExportResult.js +6 -40
- package/lib/models/ActionWebhookFailure.js +5 -39
- package/lib/models/ApiKey.js +23 -128
- package/lib/models/App.js +6 -34
- package/lib/models/As2IncomingMessage.js +6 -36
- package/lib/models/As2OutgoingMessage.js +6 -36
- package/lib/models/As2Partner.js +16 -112
- package/lib/models/As2Station.js +16 -108
- package/lib/models/Auto.js +3 -21
- package/lib/models/Automation.js +16 -146
- package/lib/models/AutomationRun.js +9 -54
- package/lib/models/BandwidthSnapshot.js +6 -34
- package/lib/models/Behavior.js +22 -151
- package/lib/models/Bundle.js +61 -177
- package/lib/models/BundleDownload.js +6 -38
- package/lib/models/BundleRecipient.js +9 -62
- package/lib/models/BundleRegistration.js +6 -38
- package/lib/models/Clickwrap.js +16 -106
- package/lib/models/DnsRecord.js +6 -34
- package/lib/models/Errors.js +3 -21
- package/lib/models/ExternalEvent.js +12 -62
- package/lib/models/File.js +21 -271
- package/lib/models/FileAction.js +3 -21
- package/lib/models/FileComment.js +13 -94
- package/lib/models/FileCommentReaction.js +8 -55
- package/lib/models/FileMigration.js +6 -37
- package/lib/models/FileUploadPart.js +3 -21
- package/lib/models/Folder.js +9 -63
- package/lib/models/FormField.js +3 -21
- package/lib/models/FormFieldSet.js +16 -98
- package/lib/models/Group.js +16 -104
- package/lib/models/GroupUser.js +13 -108
- package/lib/models/History.js +18 -132
- package/lib/models/HistoryExport.js +9 -87
- package/lib/models/HistoryExportResult.js +6 -40
- package/lib/models/Image.js +3 -21
- package/lib/models/InboxRecipient.js +9 -62
- package/lib/models/InboxRegistration.js +6 -36
- package/lib/models/InboxUpload.js +6 -38
- package/lib/models/Invoice.js +9 -48
- package/lib/models/InvoiceLineItem.js +3 -21
- package/lib/models/IpAddress.js +9 -45
- package/lib/models/Lock.js +11 -82
- package/lib/models/Message.js +16 -124
- package/lib/models/MessageComment.js +16 -104
- package/lib/models/MessageCommentReaction.js +14 -82
- package/lib/models/MessageReaction.js +14 -82
- package/lib/models/Notification.js +16 -120
- package/lib/models/Payment.js +9 -48
- package/lib/models/PaymentLineItem.js +3 -21
- package/lib/models/Permission.js +11 -72
- package/lib/models/Preview.js +3 -21
- package/lib/models/Priority.js +6 -42
- package/lib/models/Project.js +16 -96
- package/lib/models/PublicIpAddress.js +3 -21
- package/lib/models/PublicKey.js +16 -104
- package/lib/models/RemoteBandwidthSnapshot.js +6 -34
- package/lib/models/RemoteServer.js +16 -270
- package/lib/models/Request.js +14 -89
- package/lib/models/Session.js +8 -41
- package/lib/models/SettingsChange.js +6 -34
- package/lib/models/SftpHostKey.js +16 -94
- package/lib/models/Site.js +10 -157
- package/lib/models/SsoStrategy.js +11 -64
- package/lib/models/Status.js +3 -21
- package/lib/models/Style.js +10 -73
- package/lib/models/UsageDailySnapshot.js +6 -34
- package/lib/models/UsageSnapshot.js +6 -34
- package/lib/models/User.js +22 -238
- package/lib/models/UserCipherUse.js +6 -36
- package/lib/models/UserRequest.js +14 -82
- package/lib/models/WebhookTest.js +6 -43
- package/lib/utils.js +0 -16
- package/package.json +1 -1
- package/src/models/Bundle.js +25 -0
package/lib/models/File.js
CHANGED
@@ -1,58 +1,33 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
|
5
4
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
6
|
-
|
7
5
|
exports.__esModule = true;
|
8
6
|
exports.default = void 0;
|
9
|
-
|
10
7
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
11
|
-
|
12
8
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
13
|
-
|
14
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
15
|
-
|
16
10
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
17
|
-
|
18
11
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
19
|
-
|
20
12
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
21
|
-
|
22
13
|
var _readableStream = _interopRequireDefault(require("readable-stream"));
|
23
|
-
|
24
14
|
var _safeBuffer = require("safe-buffer");
|
25
|
-
|
26
15
|
var _Api = _interopRequireDefault(require("../Api"));
|
27
|
-
|
28
16
|
var errors = _interopRequireWildcard(require("../Errors"));
|
29
|
-
|
30
17
|
var _Logger = _interopRequireDefault(require("../Logger"));
|
31
|
-
|
32
18
|
var _utils = require("../utils");
|
33
|
-
|
34
19
|
var _FileAction = _interopRequireDefault(require("./FileAction"));
|
35
|
-
|
36
20
|
var _FileUploadPart = _interopRequireDefault(require("./FileUploadPart"));
|
37
|
-
|
38
21
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
39
|
-
|
40
22
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
41
|
-
|
42
23
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
43
|
-
|
44
24
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
45
|
-
|
46
25
|
/**
|
47
26
|
* Class File
|
48
|
-
*/
|
49
|
-
var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
27
|
+
*/var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
50
28
|
var _this = this;
|
51
|
-
|
52
29
|
var attributes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
53
|
-
|
54
30
|
var _options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
55
|
-
|
56
31
|
(0, _classCallCheck2.default)(this, File);
|
57
32
|
(0, _defineProperty2.default)(this, "attributes", {});
|
58
33
|
(0, _defineProperty2.default)(this, "options", {});
|
@@ -62,7 +37,6 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
62
37
|
(0, _defineProperty2.default)(this, "downloadToStream", /*#__PURE__*/function () {
|
63
38
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(writableStream) {
|
64
39
|
var downloadUri, _require, saveUrlToStream;
|
65
|
-
|
66
40
|
return _regenerator.default.wrap(function _callee$(_context) {
|
67
41
|
while (1) {
|
68
42
|
switch (_context.prev = _context.next) {
|
@@ -71,23 +45,17 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
71
45
|
_context.next = 2;
|
72
46
|
break;
|
73
47
|
}
|
74
|
-
|
75
48
|
throw new errors.NotImplementedError('Stream downloads are only available in a NodeJS environment');
|
76
|
-
|
77
49
|
case 2:
|
78
50
|
downloadUri = _this.getDownloadUri();
|
79
|
-
|
80
51
|
if (downloadUri) {
|
81
52
|
_context.next = 5;
|
82
53
|
break;
|
83
54
|
}
|
84
|
-
|
85
55
|
throw new errors.EmptyPropertyError('Current object has no download URI');
|
86
|
-
|
87
56
|
case 5:
|
88
57
|
_require = require('../isomorphic/File.node.js'), saveUrlToStream = _require.saveUrlToStream;
|
89
58
|
return _context.abrupt("return", saveUrlToStream(downloadUri, writableStream));
|
90
|
-
|
91
59
|
case 7:
|
92
60
|
case "end":
|
93
61
|
return _context.stop();
|
@@ -95,7 +63,6 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
95
63
|
}
|
96
64
|
}, _callee);
|
97
65
|
}));
|
98
|
-
|
99
66
|
return function (_x) {
|
100
67
|
return _ref.apply(this, arguments);
|
101
68
|
};
|
@@ -103,7 +70,6 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
103
70
|
(0, _defineProperty2.default)(this, "downloadToFile", /*#__PURE__*/function () {
|
104
71
|
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(destinationPath) {
|
105
72
|
var downloadUri, _require2, saveUrlToFile;
|
106
|
-
|
107
73
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
108
74
|
while (1) {
|
109
75
|
switch (_context2.prev = _context2.next) {
|
@@ -112,23 +78,17 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
112
78
|
_context2.next = 2;
|
113
79
|
break;
|
114
80
|
}
|
115
|
-
|
116
81
|
throw new errors.NotImplementedError('Disk file downloads are only available in a NodeJS environment');
|
117
|
-
|
118
82
|
case 2:
|
119
83
|
downloadUri = _this.getDownloadUri();
|
120
|
-
|
121
84
|
if (downloadUri) {
|
122
85
|
_context2.next = 5;
|
123
86
|
break;
|
124
87
|
}
|
125
|
-
|
126
88
|
throw new errors.EmptyPropertyError('Current object has no download URI');
|
127
|
-
|
128
89
|
case 5:
|
129
90
|
_require2 = require('../isomorphic/File.node.js'), saveUrlToFile = _require2.saveUrlToFile;
|
130
91
|
return _context2.abrupt("return", saveUrlToFile(downloadUri, destinationPath));
|
131
|
-
|
132
92
|
case 7:
|
133
93
|
case "end":
|
134
94
|
return _context2.stop();
|
@@ -136,7 +96,6 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
136
96
|
}
|
137
97
|
}, _callee2);
|
138
98
|
}));
|
139
|
-
|
140
99
|
return function (_x2) {
|
141
100
|
return _ref2.apply(this, arguments);
|
142
101
|
};
|
@@ -152,7 +111,6 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
152
111
|
destination: destinationFilePath
|
153
112
|
};
|
154
113
|
return _context3.abrupt("return", _Api.default.sendRequest("/file_actions/copy/".concat(encodeURIComponent(_this.path)), 'POST', params, options));
|
155
|
-
|
156
114
|
case 2:
|
157
115
|
case "end":
|
158
116
|
return _context3.stop();
|
@@ -160,7 +118,6 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
160
118
|
}
|
161
119
|
}, _callee3);
|
162
120
|
}));
|
163
|
-
|
164
121
|
return function (_x3, _x4) {
|
165
122
|
return _ref3.apply(this, arguments);
|
166
123
|
};
|
@@ -176,7 +133,6 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
176
133
|
destination: destinationFilePath
|
177
134
|
};
|
178
135
|
return _context4.abrupt("return", _Api.default.sendRequest("/file_actions/move/".concat(encodeURIComponent(_this.path)), 'POST', params, options));
|
179
|
-
|
180
136
|
case 2:
|
181
137
|
case "end":
|
182
138
|
return _context4.stop();
|
@@ -184,7 +140,6 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
184
140
|
}
|
185
141
|
}, _callee4);
|
186
142
|
}));
|
187
|
-
|
188
143
|
return function (_x5, _x6) {
|
189
144
|
return _ref4.apply(this, arguments);
|
190
145
|
};
|
@@ -344,81 +299,63 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
344
299
|
});
|
345
300
|
(0, _defineProperty2.default)(this, "download", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
|
346
301
|
var params,
|
347
|
-
|
348
|
-
|
302
|
+
response,
|
303
|
+
_args5 = arguments;
|
349
304
|
return _regenerator.default.wrap(function _callee5$(_context5) {
|
350
305
|
while (1) {
|
351
306
|
switch (_context5.prev = _context5.next) {
|
352
307
|
case 0:
|
353
308
|
params = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {};
|
354
|
-
|
355
309
|
if (_this.attributes.path) {
|
356
310
|
_context5.next = 3;
|
357
311
|
break;
|
358
312
|
}
|
359
|
-
|
360
313
|
throw new errors.EmptyPropertyError('Current object has no path');
|
361
|
-
|
362
314
|
case 3:
|
363
315
|
if ((0, _utils.isObject)(params)) {
|
364
316
|
_context5.next = 5;
|
365
317
|
break;
|
366
318
|
}
|
367
|
-
|
368
319
|
throw new errors.InvalidParameterError("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
|
369
|
-
|
370
320
|
case 5:
|
371
321
|
params.path = _this.attributes.path;
|
372
|
-
|
373
322
|
if (!(params['path'] && !(0, _utils.isString)(params['path']))) {
|
374
323
|
_context5.next = 8;
|
375
324
|
break;
|
376
325
|
}
|
377
|
-
|
378
326
|
throw new errors.InvalidParameterError("Bad parameter: path must be of type String, received ".concat((0, _utils.getType)(path)));
|
379
|
-
|
380
327
|
case 8:
|
381
328
|
if (!(params['action'] && !(0, _utils.isString)(params['action']))) {
|
382
329
|
_context5.next = 10;
|
383
330
|
break;
|
384
331
|
}
|
385
|
-
|
386
332
|
throw new errors.InvalidParameterError("Bad parameter: action must be of type String, received ".concat((0, _utils.getType)(action)));
|
387
|
-
|
388
333
|
case 10:
|
389
334
|
if (!(params['preview_size'] && !(0, _utils.isString)(params['preview_size']))) {
|
390
335
|
_context5.next = 12;
|
391
336
|
break;
|
392
337
|
}
|
393
|
-
|
394
338
|
throw new errors.InvalidParameterError("Bad parameter: preview_size must be of type String, received ".concat((0, _utils.getType)(preview_size)));
|
395
|
-
|
396
339
|
case 12:
|
397
340
|
if (params['path']) {
|
398
341
|
_context5.next = 18;
|
399
342
|
break;
|
400
343
|
}
|
401
|
-
|
402
344
|
if (!_this.attributes.path) {
|
403
345
|
_context5.next = 17;
|
404
346
|
break;
|
405
347
|
}
|
406
|
-
|
407
348
|
params['path'] = _this.path;
|
408
349
|
_context5.next = 18;
|
409
350
|
break;
|
410
|
-
|
411
351
|
case 17:
|
412
352
|
throw new errors.MissingParameterError('Parameter missing: path');
|
413
|
-
|
414
353
|
case 18:
|
415
354
|
_context5.next = 20;
|
416
355
|
return _Api.default.sendRequest("/files/".concat(encodeURIComponent(params['path'])), 'GET', params, _this.options);
|
417
|
-
|
418
356
|
case 20:
|
419
357
|
response = _context5.sent;
|
420
358
|
return _context5.abrupt("return", new File(response === null || response === void 0 ? void 0 : response.data, _this.options));
|
421
|
-
|
422
359
|
case 22:
|
423
360
|
case "end":
|
424
361
|
return _context5.stop();
|
@@ -428,81 +365,63 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
428
365
|
})));
|
429
366
|
(0, _defineProperty2.default)(this, "update", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6() {
|
430
367
|
var params,
|
431
|
-
|
432
|
-
|
368
|
+
response,
|
369
|
+
_args6 = arguments;
|
433
370
|
return _regenerator.default.wrap(function _callee6$(_context6) {
|
434
371
|
while (1) {
|
435
372
|
switch (_context6.prev = _context6.next) {
|
436
373
|
case 0:
|
437
374
|
params = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {};
|
438
|
-
|
439
375
|
if (_this.attributes.path) {
|
440
376
|
_context6.next = 3;
|
441
377
|
break;
|
442
378
|
}
|
443
|
-
|
444
379
|
throw new errors.EmptyPropertyError('Current object has no path');
|
445
|
-
|
446
380
|
case 3:
|
447
381
|
if ((0, _utils.isObject)(params)) {
|
448
382
|
_context6.next = 5;
|
449
383
|
break;
|
450
384
|
}
|
451
|
-
|
452
385
|
throw new errors.InvalidParameterError("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
|
453
|
-
|
454
386
|
case 5:
|
455
387
|
params.path = _this.attributes.path;
|
456
|
-
|
457
388
|
if (!(params['path'] && !(0, _utils.isString)(params['path']))) {
|
458
389
|
_context6.next = 8;
|
459
390
|
break;
|
460
391
|
}
|
461
|
-
|
462
392
|
throw new errors.InvalidParameterError("Bad parameter: path must be of type String, received ".concat((0, _utils.getType)(path)));
|
463
|
-
|
464
393
|
case 8:
|
465
394
|
if (!(params['provided_mtime'] && !(0, _utils.isString)(params['provided_mtime']))) {
|
466
395
|
_context6.next = 10;
|
467
396
|
break;
|
468
397
|
}
|
469
|
-
|
470
398
|
throw new errors.InvalidParameterError("Bad parameter: provided_mtime must be of type String, received ".concat((0, _utils.getType)(provided_mtime)));
|
471
|
-
|
472
399
|
case 10:
|
473
400
|
if (!(params['priority_color'] && !(0, _utils.isString)(params['priority_color']))) {
|
474
401
|
_context6.next = 12;
|
475
402
|
break;
|
476
403
|
}
|
477
|
-
|
478
404
|
throw new errors.InvalidParameterError("Bad parameter: priority_color must be of type String, received ".concat((0, _utils.getType)(priority_color)));
|
479
|
-
|
480
405
|
case 12:
|
481
406
|
if (params['path']) {
|
482
407
|
_context6.next = 18;
|
483
408
|
break;
|
484
409
|
}
|
485
|
-
|
486
410
|
if (!_this.attributes.path) {
|
487
411
|
_context6.next = 17;
|
488
412
|
break;
|
489
413
|
}
|
490
|
-
|
491
414
|
params['path'] = _this.path;
|
492
415
|
_context6.next = 18;
|
493
416
|
break;
|
494
|
-
|
495
417
|
case 17:
|
496
418
|
throw new errors.MissingParameterError('Parameter missing: path');
|
497
|
-
|
498
419
|
case 18:
|
499
420
|
_context6.next = 20;
|
500
421
|
return _Api.default.sendRequest("/files/".concat(encodeURIComponent(params['path'])), 'PATCH', params, _this.options);
|
501
|
-
|
502
422
|
case 20:
|
503
423
|
response = _context6.sent;
|
504
424
|
return _context6.abrupt("return", new File(response === null || response === void 0 ? void 0 : response.data, _this.options));
|
505
|
-
|
506
425
|
case 22:
|
507
426
|
case "end":
|
508
427
|
return _context6.stop();
|
@@ -512,65 +431,51 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
512
431
|
})));
|
513
432
|
(0, _defineProperty2.default)(this, "delete", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7() {
|
514
433
|
var params,
|
515
|
-
|
516
|
-
|
434
|
+
response,
|
435
|
+
_args7 = arguments;
|
517
436
|
return _regenerator.default.wrap(function _callee7$(_context7) {
|
518
437
|
while (1) {
|
519
438
|
switch (_context7.prev = _context7.next) {
|
520
439
|
case 0:
|
521
440
|
params = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : {};
|
522
|
-
|
523
441
|
if (_this.attributes.path) {
|
524
442
|
_context7.next = 3;
|
525
443
|
break;
|
526
444
|
}
|
527
|
-
|
528
445
|
throw new errors.EmptyPropertyError('Current object has no path');
|
529
|
-
|
530
446
|
case 3:
|
531
447
|
if ((0, _utils.isObject)(params)) {
|
532
448
|
_context7.next = 5;
|
533
449
|
break;
|
534
450
|
}
|
535
|
-
|
536
451
|
throw new errors.InvalidParameterError("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
|
537
|
-
|
538
452
|
case 5:
|
539
453
|
params.path = _this.attributes.path;
|
540
|
-
|
541
454
|
if (!(params['path'] && !(0, _utils.isString)(params['path']))) {
|
542
455
|
_context7.next = 8;
|
543
456
|
break;
|
544
457
|
}
|
545
|
-
|
546
458
|
throw new errors.InvalidParameterError("Bad parameter: path must be of type String, received ".concat((0, _utils.getType)(path)));
|
547
|
-
|
548
459
|
case 8:
|
549
460
|
if (params['path']) {
|
550
461
|
_context7.next = 14;
|
551
462
|
break;
|
552
463
|
}
|
553
|
-
|
554
464
|
if (!_this.attributes.path) {
|
555
465
|
_context7.next = 13;
|
556
466
|
break;
|
557
467
|
}
|
558
|
-
|
559
468
|
params['path'] = _this.path;
|
560
469
|
_context7.next = 14;
|
561
470
|
break;
|
562
|
-
|
563
471
|
case 13:
|
564
472
|
throw new errors.MissingParameterError('Parameter missing: path');
|
565
|
-
|
566
473
|
case 14:
|
567
474
|
_context7.next = 16;
|
568
475
|
return _Api.default.sendRequest("/files/".concat(encodeURIComponent(params['path'])), 'DELETE', params, _this.options);
|
569
|
-
|
570
476
|
case 16:
|
571
477
|
response = _context7.sent;
|
572
478
|
return _context7.abrupt("return", response === null || response === void 0 ? void 0 : response.data);
|
573
|
-
|
574
479
|
case 18:
|
575
480
|
case "end":
|
576
481
|
return _context7.stop();
|
@@ -584,91 +489,71 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
584
489
|
});
|
585
490
|
(0, _defineProperty2.default)(this, "copy", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
|
586
491
|
var params,
|
587
|
-
|
588
|
-
|
492
|
+
response,
|
493
|
+
_args8 = arguments;
|
589
494
|
return _regenerator.default.wrap(function _callee8$(_context8) {
|
590
495
|
while (1) {
|
591
496
|
switch (_context8.prev = _context8.next) {
|
592
497
|
case 0:
|
593
498
|
params = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : {};
|
594
|
-
|
595
499
|
if (_this.attributes.path) {
|
596
500
|
_context8.next = 3;
|
597
501
|
break;
|
598
502
|
}
|
599
|
-
|
600
503
|
throw new errors.EmptyPropertyError('Current object has no path');
|
601
|
-
|
602
504
|
case 3:
|
603
505
|
if ((0, _utils.isObject)(params)) {
|
604
506
|
_context8.next = 5;
|
605
507
|
break;
|
606
508
|
}
|
607
|
-
|
608
509
|
throw new errors.InvalidParameterError("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
|
609
|
-
|
610
510
|
case 5:
|
611
511
|
params.path = _this.attributes.path;
|
612
|
-
|
613
512
|
if (!(params['path'] && !(0, _utils.isString)(params['path']))) {
|
614
513
|
_context8.next = 8;
|
615
514
|
break;
|
616
515
|
}
|
617
|
-
|
618
516
|
throw new errors.InvalidParameterError("Bad parameter: path must be of type String, received ".concat((0, _utils.getType)(path)));
|
619
|
-
|
620
517
|
case 8:
|
621
518
|
if (!(params['destination'] && !(0, _utils.isString)(params['destination']))) {
|
622
519
|
_context8.next = 10;
|
623
520
|
break;
|
624
521
|
}
|
625
|
-
|
626
522
|
throw new errors.InvalidParameterError("Bad parameter: destination must be of type String, received ".concat((0, _utils.getType)(destination)));
|
627
|
-
|
628
523
|
case 10:
|
629
524
|
if (params['path']) {
|
630
525
|
_context8.next = 16;
|
631
526
|
break;
|
632
527
|
}
|
633
|
-
|
634
528
|
if (!_this.attributes.path) {
|
635
529
|
_context8.next = 15;
|
636
530
|
break;
|
637
531
|
}
|
638
|
-
|
639
532
|
params['path'] = _this.path;
|
640
533
|
_context8.next = 16;
|
641
534
|
break;
|
642
|
-
|
643
535
|
case 15:
|
644
536
|
throw new errors.MissingParameterError('Parameter missing: path');
|
645
|
-
|
646
537
|
case 16:
|
647
538
|
if (params['destination']) {
|
648
539
|
_context8.next = 22;
|
649
540
|
break;
|
650
541
|
}
|
651
|
-
|
652
542
|
if (!_this.attributes.destination) {
|
653
543
|
_context8.next = 21;
|
654
544
|
break;
|
655
545
|
}
|
656
|
-
|
657
546
|
params['destination'] = _this.destination;
|
658
547
|
_context8.next = 22;
|
659
548
|
break;
|
660
|
-
|
661
549
|
case 21:
|
662
550
|
throw new errors.MissingParameterError('Parameter missing: destination');
|
663
|
-
|
664
551
|
case 22:
|
665
552
|
_context8.next = 24;
|
666
553
|
return _Api.default.sendRequest("/file_actions/copy/".concat(encodeURIComponent(params['path'])), 'POST', params, _this.options);
|
667
|
-
|
668
554
|
case 24:
|
669
555
|
response = _context8.sent;
|
670
556
|
return _context8.abrupt("return", new _FileAction.default(response === null || response === void 0 ? void 0 : response.data, _this.options));
|
671
|
-
|
672
557
|
case 26:
|
673
558
|
case "end":
|
674
559
|
return _context8.stop();
|
@@ -678,91 +563,71 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
678
563
|
})));
|
679
564
|
(0, _defineProperty2.default)(this, "move", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9() {
|
680
565
|
var params,
|
681
|
-
|
682
|
-
|
566
|
+
response,
|
567
|
+
_args9 = arguments;
|
683
568
|
return _regenerator.default.wrap(function _callee9$(_context9) {
|
684
569
|
while (1) {
|
685
570
|
switch (_context9.prev = _context9.next) {
|
686
571
|
case 0:
|
687
572
|
params = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : {};
|
688
|
-
|
689
573
|
if (_this.attributes.path) {
|
690
574
|
_context9.next = 3;
|
691
575
|
break;
|
692
576
|
}
|
693
|
-
|
694
577
|
throw new errors.EmptyPropertyError('Current object has no path');
|
695
|
-
|
696
578
|
case 3:
|
697
579
|
if ((0, _utils.isObject)(params)) {
|
698
580
|
_context9.next = 5;
|
699
581
|
break;
|
700
582
|
}
|
701
|
-
|
702
583
|
throw new errors.InvalidParameterError("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
|
703
|
-
|
704
584
|
case 5:
|
705
585
|
params.path = _this.attributes.path;
|
706
|
-
|
707
586
|
if (!(params['path'] && !(0, _utils.isString)(params['path']))) {
|
708
587
|
_context9.next = 8;
|
709
588
|
break;
|
710
589
|
}
|
711
|
-
|
712
590
|
throw new errors.InvalidParameterError("Bad parameter: path must be of type String, received ".concat((0, _utils.getType)(path)));
|
713
|
-
|
714
591
|
case 8:
|
715
592
|
if (!(params['destination'] && !(0, _utils.isString)(params['destination']))) {
|
716
593
|
_context9.next = 10;
|
717
594
|
break;
|
718
595
|
}
|
719
|
-
|
720
596
|
throw new errors.InvalidParameterError("Bad parameter: destination must be of type String, received ".concat((0, _utils.getType)(destination)));
|
721
|
-
|
722
597
|
case 10:
|
723
598
|
if (params['path']) {
|
724
599
|
_context9.next = 16;
|
725
600
|
break;
|
726
601
|
}
|
727
|
-
|
728
602
|
if (!_this.attributes.path) {
|
729
603
|
_context9.next = 15;
|
730
604
|
break;
|
731
605
|
}
|
732
|
-
|
733
606
|
params['path'] = _this.path;
|
734
607
|
_context9.next = 16;
|
735
608
|
break;
|
736
|
-
|
737
609
|
case 15:
|
738
610
|
throw new errors.MissingParameterError('Parameter missing: path');
|
739
|
-
|
740
611
|
case 16:
|
741
612
|
if (params['destination']) {
|
742
613
|
_context9.next = 22;
|
743
614
|
break;
|
744
615
|
}
|
745
|
-
|
746
616
|
if (!_this.attributes.destination) {
|
747
617
|
_context9.next = 21;
|
748
618
|
break;
|
749
619
|
}
|
750
|
-
|
751
620
|
params['destination'] = _this.destination;
|
752
621
|
_context9.next = 22;
|
753
622
|
break;
|
754
|
-
|
755
623
|
case 21:
|
756
624
|
throw new errors.MissingParameterError('Parameter missing: destination');
|
757
|
-
|
758
625
|
case 22:
|
759
626
|
_context9.next = 24;
|
760
627
|
return _Api.default.sendRequest("/file_actions/move/".concat(encodeURIComponent(params['path'])), 'POST', params, _this.options);
|
761
|
-
|
762
628
|
case 24:
|
763
629
|
response = _context9.sent;
|
764
630
|
return _context9.abrupt("return", new _FileAction.default(response === null || response === void 0 ? void 0 : response.data, _this.options));
|
765
|
-
|
766
631
|
case 26:
|
767
632
|
case "end":
|
768
633
|
return _context9.stop();
|
@@ -772,109 +637,84 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
772
637
|
})));
|
773
638
|
(0, _defineProperty2.default)(this, "beginUpload", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee10() {
|
774
639
|
var _response$data;
|
775
|
-
|
776
640
|
var params,
|
777
|
-
|
778
|
-
|
641
|
+
response,
|
642
|
+
_args10 = arguments;
|
779
643
|
return _regenerator.default.wrap(function _callee10$(_context10) {
|
780
644
|
while (1) {
|
781
645
|
switch (_context10.prev = _context10.next) {
|
782
646
|
case 0:
|
783
647
|
params = _args10.length > 0 && _args10[0] !== undefined ? _args10[0] : {};
|
784
|
-
|
785
648
|
if (_this.attributes.path) {
|
786
649
|
_context10.next = 3;
|
787
650
|
break;
|
788
651
|
}
|
789
|
-
|
790
652
|
throw new errors.EmptyPropertyError('Current object has no path');
|
791
|
-
|
792
653
|
case 3:
|
793
654
|
if ((0, _utils.isObject)(params)) {
|
794
655
|
_context10.next = 5;
|
795
656
|
break;
|
796
657
|
}
|
797
|
-
|
798
658
|
throw new errors.InvalidParameterError("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
|
799
|
-
|
800
659
|
case 5:
|
801
660
|
params.path = _this.attributes.path;
|
802
|
-
|
803
661
|
if (!(params['path'] && !(0, _utils.isString)(params['path']))) {
|
804
662
|
_context10.next = 8;
|
805
663
|
break;
|
806
664
|
}
|
807
|
-
|
808
665
|
throw new errors.InvalidParameterError("Bad parameter: path must be of type String, received ".concat((0, _utils.getType)(path)));
|
809
|
-
|
810
666
|
case 8:
|
811
667
|
if (!(params['part'] && !(0, _utils.isInt)(params['part']))) {
|
812
668
|
_context10.next = 10;
|
813
669
|
break;
|
814
670
|
}
|
815
|
-
|
816
671
|
throw new errors.InvalidParameterError("Bad parameter: part must be of type Int, received ".concat((0, _utils.getType)(part)));
|
817
|
-
|
818
672
|
case 10:
|
819
673
|
if (!(params['parts'] && !(0, _utils.isInt)(params['parts']))) {
|
820
674
|
_context10.next = 12;
|
821
675
|
break;
|
822
676
|
}
|
823
|
-
|
824
677
|
throw new errors.InvalidParameterError("Bad parameter: parts must be of type Int, received ".concat((0, _utils.getType)(parts)));
|
825
|
-
|
826
678
|
case 12:
|
827
679
|
if (!(params['ref'] && !(0, _utils.isString)(params['ref']))) {
|
828
680
|
_context10.next = 14;
|
829
681
|
break;
|
830
682
|
}
|
831
|
-
|
832
683
|
throw new errors.InvalidParameterError("Bad parameter: ref must be of type String, received ".concat((0, _utils.getType)(ref)));
|
833
|
-
|
834
684
|
case 14:
|
835
685
|
if (!(params['restart'] && !(0, _utils.isInt)(params['restart']))) {
|
836
686
|
_context10.next = 16;
|
837
687
|
break;
|
838
688
|
}
|
839
|
-
|
840
689
|
throw new errors.InvalidParameterError("Bad parameter: restart must be of type Int, received ".concat((0, _utils.getType)(restart)));
|
841
|
-
|
842
690
|
case 16:
|
843
691
|
if (!(params['size'] && !(0, _utils.isInt)(params['size']))) {
|
844
692
|
_context10.next = 18;
|
845
693
|
break;
|
846
694
|
}
|
847
|
-
|
848
695
|
throw new errors.InvalidParameterError("Bad parameter: size must be of type Int, received ".concat((0, _utils.getType)(size)));
|
849
|
-
|
850
696
|
case 18:
|
851
697
|
if (params['path']) {
|
852
698
|
_context10.next = 24;
|
853
699
|
break;
|
854
700
|
}
|
855
|
-
|
856
701
|
if (!_this.attributes.path) {
|
857
702
|
_context10.next = 23;
|
858
703
|
break;
|
859
704
|
}
|
860
|
-
|
861
705
|
params['path'] = _this.path;
|
862
706
|
_context10.next = 24;
|
863
707
|
break;
|
864
|
-
|
865
708
|
case 23:
|
866
709
|
throw new errors.MissingParameterError('Parameter missing: path');
|
867
|
-
|
868
710
|
case 24:
|
869
711
|
_context10.next = 26;
|
870
712
|
return _Api.default.sendRequest("/file_actions/begin_upload/".concat(encodeURIComponent(params['path'])), 'POST', params, _this.options);
|
871
|
-
|
872
713
|
case 26:
|
873
714
|
response = _context10.sent;
|
874
715
|
return _context10.abrupt("return", (response === null || response === void 0 ? void 0 : (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.map(function (obj) {
|
875
716
|
return new _FileUploadPart.default(obj, _this.options);
|
876
717
|
})) || []);
|
877
|
-
|
878
718
|
case 28:
|
879
719
|
case "end":
|
880
720
|
return _context10.stop();
|
@@ -889,9 +729,8 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
889
729
|
});
|
890
730
|
Object.entries(attributes).forEach(function (_ref11) {
|
891
731
|
var _ref12 = (0, _slicedToArray2.default)(_ref11, 2),
|
892
|
-
|
893
|
-
|
894
|
-
|
732
|
+
key = _ref12[0],
|
733
|
+
value = _ref12[1];
|
895
734
|
var normalizedKey = key.replace('?', '');
|
896
735
|
_this.attributes[normalizedKey] = value;
|
897
736
|
Object.defineProperty(_this, normalizedKey, {
|
@@ -913,24 +752,19 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
913
752
|
});
|
914
753
|
_context11.next = 3;
|
915
754
|
return _Api.default.sendRequest("/files/".concat(encodeURIComponent(path)), 'POST', params, options);
|
916
|
-
|
917
755
|
case 3:
|
918
756
|
response = _context11.sent;
|
919
|
-
|
920
757
|
if (response) {
|
921
758
|
_context11.next = 6;
|
922
759
|
break;
|
923
760
|
}
|
924
|
-
|
925
761
|
return _context11.abrupt("return", null);
|
926
|
-
|
927
762
|
case 6:
|
928
763
|
partData = _objectSpread(_objectSpread({}, response.data), {}, {
|
929
764
|
headers: response.headers,
|
930
765
|
parameters: params
|
931
766
|
});
|
932
767
|
return _context11.abrupt("return", new _FileUploadPart.default(partData));
|
933
|
-
|
934
768
|
case 8:
|
935
769
|
case "end":
|
936
770
|
return _context11.stop();
|
@@ -938,7 +772,6 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
938
772
|
}
|
939
773
|
}, _callee11);
|
940
774
|
}));
|
941
|
-
|
942
775
|
return function (_x7, _x8, _x9) {
|
943
776
|
return _ref13.apply(this, arguments);
|
944
777
|
};
|
@@ -957,24 +790,19 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
957
790
|
};
|
958
791
|
_context12.next = 3;
|
959
792
|
return _Api.default.sendRequest("/files/".concat(encodeURIComponent(path)), 'POST', params, options);
|
960
|
-
|
961
793
|
case 3:
|
962
794
|
response = _context12.sent;
|
963
|
-
|
964
795
|
if (response) {
|
965
796
|
_context12.next = 6;
|
966
797
|
break;
|
967
798
|
}
|
968
|
-
|
969
799
|
return _context12.abrupt("return", null);
|
970
|
-
|
971
800
|
case 6:
|
972
801
|
partData = _objectSpread(_objectSpread({}, response.data), {}, {
|
973
802
|
headers: response.headers,
|
974
803
|
parameters: params
|
975
804
|
});
|
976
805
|
return _context12.abrupt("return", new _FileUploadPart.default(partData));
|
977
|
-
|
978
806
|
case 8:
|
979
807
|
case "end":
|
980
808
|
return _context12.stop();
|
@@ -982,7 +810,6 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
982
810
|
}
|
983
811
|
}, _callee12);
|
984
812
|
}));
|
985
|
-
|
986
813
|
return function (_x10, _x11, _x12, _x13) {
|
987
814
|
return _ref14.apply(this, arguments);
|
988
815
|
};
|
@@ -999,7 +826,6 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
999
826
|
ref: firstFileUploadPart.ref
|
1000
827
|
};
|
1001
828
|
return _context13.abrupt("return", _Api.default.sendRequest("/files/".concat(encodeURIComponent(firstFileUploadPart.path)), 'POST', params, options));
|
1002
|
-
|
1003
829
|
case 2:
|
1004
830
|
case "end":
|
1005
831
|
return _context13.stop();
|
@@ -1007,7 +833,6 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
1007
833
|
}
|
1008
834
|
}, _callee13);
|
1009
835
|
}));
|
1010
|
-
|
1011
836
|
return function (_x14, _x15) {
|
1012
837
|
return _ref15.apply(this, arguments);
|
1013
838
|
};
|
@@ -1021,17 +846,13 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
1021
846
|
case 0:
|
1022
847
|
_context16.next = 2;
|
1023
848
|
return File._openUpload(destinationPath, params, options);
|
1024
|
-
|
1025
849
|
case 2:
|
1026
850
|
firstFileUploadPart = _context16.sent;
|
1027
|
-
|
1028
851
|
if (firstFileUploadPart) {
|
1029
852
|
_context16.next = 5;
|
1030
853
|
break;
|
1031
854
|
}
|
1032
|
-
|
1033
855
|
return _context16.abrupt("return");
|
1034
|
-
|
1035
856
|
case 5:
|
1036
857
|
_context16.prev = 5;
|
1037
858
|
_context16.next = 8;
|
@@ -1054,12 +875,10 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
1054
875
|
nextLength = length + chunk.length;
|
1055
876
|
excessLength = nextLength - firstFileUploadPart.partsize;
|
1056
877
|
chunkBuffer = _safeBuffer.Buffer.from(chunk);
|
1057
|
-
|
1058
878
|
if (!(excessLength > 0)) {
|
1059
879
|
_context14.next = 19;
|
1060
880
|
break;
|
1061
881
|
}
|
1062
|
-
|
1063
882
|
readableStream.pause();
|
1064
883
|
lastChunkForPart = chunkBuffer.subarray(0, excessLength);
|
1065
884
|
firstChunkForNextPart = chunkBuffer.subarray(excessLength);
|
@@ -1067,7 +886,6 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
1067
886
|
buffer = _safeBuffer.Buffer.concat(chunks);
|
1068
887
|
_context14.next = 12;
|
1069
888
|
return File._continueUpload(destinationPath, ++part, firstFileUploadPart, options);
|
1070
|
-
|
1071
889
|
case 12:
|
1072
890
|
nextFileUploadPart = _context14.sent;
|
1073
891
|
concurrentUploads.push(_Api.default.sendFilePart(nextFileUploadPart.upload_uri, 'PUT', buffer));
|
@@ -1076,20 +894,16 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
1076
894
|
readableStream.resume();
|
1077
895
|
_context14.next = 21;
|
1078
896
|
break;
|
1079
|
-
|
1080
897
|
case 19:
|
1081
898
|
chunks.push(chunkBuffer);
|
1082
899
|
length += chunk.length;
|
1083
|
-
|
1084
900
|
case 21:
|
1085
901
|
_context14.next = 26;
|
1086
902
|
break;
|
1087
|
-
|
1088
903
|
case 23:
|
1089
904
|
_context14.prev = 23;
|
1090
905
|
_context14.t0 = _context14["catch"](0);
|
1091
906
|
reject(_context14.t0);
|
1092
|
-
|
1093
907
|
case 26:
|
1094
908
|
case "end":
|
1095
909
|
return _context14.stop();
|
@@ -1097,7 +911,6 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
1097
911
|
}
|
1098
912
|
}, _callee14, null, [[0, 23]]);
|
1099
913
|
}));
|
1100
|
-
|
1101
914
|
return function (_x20) {
|
1102
915
|
return _ref17.apply(this, arguments);
|
1103
916
|
};
|
@@ -1109,40 +922,32 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
1109
922
|
switch (_context15.prev = _context15.next) {
|
1110
923
|
case 0:
|
1111
924
|
_context15.prev = 0;
|
1112
|
-
|
1113
925
|
if (!(chunks.length > 0)) {
|
1114
926
|
_context15.next = 7;
|
1115
927
|
break;
|
1116
928
|
}
|
1117
|
-
|
1118
929
|
buffer = _safeBuffer.Buffer.concat(chunks);
|
1119
930
|
_context15.next = 5;
|
1120
931
|
return File._continueUpload(destinationPath, ++part, firstFileUploadPart, options);
|
1121
|
-
|
1122
932
|
case 5:
|
1123
933
|
nextFileUploadPart = _context15.sent;
|
1124
934
|
concurrentUploads.push(_Api.default.sendFilePart(nextFileUploadPart.upload_uri, 'PUT', buffer));
|
1125
|
-
|
1126
935
|
case 7:
|
1127
936
|
_context15.next = 9;
|
1128
937
|
return Promise.all(concurrentUploads);
|
1129
|
-
|
1130
938
|
case 9:
|
1131
939
|
_context15.next = 11;
|
1132
940
|
return File._completeUpload(firstFileUploadPart, options);
|
1133
|
-
|
1134
941
|
case 11:
|
1135
942
|
response = _context15.sent;
|
1136
943
|
createdFile = new File(response.data, options);
|
1137
944
|
resolve(createdFile);
|
1138
945
|
_context15.next = 19;
|
1139
946
|
break;
|
1140
|
-
|
1141
947
|
case 16:
|
1142
948
|
_context15.prev = 16;
|
1143
949
|
_context15.t0 = _context15["catch"](0);
|
1144
950
|
reject(_context15.t0);
|
1145
|
-
|
1146
951
|
case 19:
|
1147
952
|
case "end":
|
1148
953
|
return _context15.stop();
|
@@ -1151,16 +956,13 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
1151
956
|
}, _callee15, null, [[0, 16]]);
|
1152
957
|
})));
|
1153
958
|
});
|
1154
|
-
|
1155
959
|
case 8:
|
1156
960
|
file = _context16.sent;
|
1157
961
|
return _context16.abrupt("return", file);
|
1158
|
-
|
1159
962
|
case 12:
|
1160
963
|
_context16.prev = 12;
|
1161
964
|
_context16.t0 = _context16["catch"](5);
|
1162
965
|
errors.handleErrorResponse(_context16.t0);
|
1163
|
-
|
1164
966
|
case 15:
|
1165
967
|
case "end":
|
1166
968
|
return _context16.stop();
|
@@ -1168,7 +970,6 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
1168
970
|
}
|
1169
971
|
}, _callee16, null, [[5, 12]]);
|
1170
972
|
}));
|
1171
|
-
|
1172
973
|
return function (_x16, _x17, _x18, _x19) {
|
1173
974
|
return _ref16.apply(this, arguments);
|
1174
975
|
};
|
@@ -1183,12 +984,9 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
1183
984
|
_context17.next = 2;
|
1184
985
|
break;
|
1185
986
|
}
|
1186
|
-
|
1187
987
|
throw new errors.MissingParameterError('Upload data was not provided');
|
1188
|
-
|
1189
988
|
case 2:
|
1190
989
|
return _context17.abrupt("return", File.uploadStream(destinationPath, _readableStream.default.from(data), params, options));
|
1191
|
-
|
1192
990
|
case 3:
|
1193
991
|
case "end":
|
1194
992
|
return _context17.stop();
|
@@ -1196,7 +994,6 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
1196
994
|
}
|
1197
995
|
}, _callee17);
|
1198
996
|
}));
|
1199
|
-
|
1200
997
|
return function (_x21, _x22, _x23, _x24) {
|
1201
998
|
return _ref19.apply(this, arguments);
|
1202
999
|
};
|
@@ -1204,7 +1001,6 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
1204
1001
|
(0, _defineProperty2.default)(File, "uploadFile", /*#__PURE__*/function () {
|
1205
1002
|
var _ref20 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee18(destinationPath, sourceFilePath, params, options) {
|
1206
1003
|
var _require3, openDiskFileReadStream, stream;
|
1207
|
-
|
1208
1004
|
return _regenerator.default.wrap(function _callee18$(_context18) {
|
1209
1005
|
while (1) {
|
1210
1006
|
switch (_context18.prev = _context18.next) {
|
@@ -1213,14 +1009,11 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
1213
1009
|
_context18.next = 2;
|
1214
1010
|
break;
|
1215
1011
|
}
|
1216
|
-
|
1217
1012
|
throw new errors.NotImplementedError('Disk file uploads are only available in a NodeJS environment');
|
1218
|
-
|
1219
1013
|
case 2:
|
1220
1014
|
_require3 = require('../isomorphic/File.node.js'), openDiskFileReadStream = _require3.openDiskFileReadStream;
|
1221
1015
|
stream = openDiskFileReadStream(sourceFilePath);
|
1222
1016
|
return _context18.abrupt("return", File.uploadStream(destinationPath, stream, params, options));
|
1223
|
-
|
1224
1017
|
case 5:
|
1225
1018
|
case "end":
|
1226
1019
|
return _context18.stop();
|
@@ -1228,7 +1021,6 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
1228
1021
|
}
|
1229
1022
|
}, _callee18);
|
1230
1023
|
}));
|
1231
|
-
|
1232
1024
|
return function (_x25, _x26, _x27, _x28) {
|
1233
1025
|
return _ref20.apply(this, arguments);
|
1234
1026
|
};
|
@@ -1236,121 +1028,93 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
1236
1028
|
(0, _defineProperty2.default)(File, "create", /*#__PURE__*/function () {
|
1237
1029
|
var _ref21 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee19(path) {
|
1238
1030
|
var params,
|
1239
|
-
|
1240
|
-
|
1241
|
-
|
1031
|
+
options,
|
1032
|
+
response,
|
1033
|
+
_args19 = arguments;
|
1242
1034
|
return _regenerator.default.wrap(function _callee19$(_context19) {
|
1243
1035
|
while (1) {
|
1244
1036
|
switch (_context19.prev = _context19.next) {
|
1245
1037
|
case 0:
|
1246
1038
|
params = _args19.length > 1 && _args19[1] !== undefined ? _args19[1] : {};
|
1247
1039
|
options = _args19.length > 2 && _args19[2] !== undefined ? _args19[2] : {};
|
1248
|
-
|
1249
1040
|
if ((0, _utils.isObject)(params)) {
|
1250
1041
|
_context19.next = 4;
|
1251
1042
|
break;
|
1252
1043
|
}
|
1253
|
-
|
1254
1044
|
throw new errors.InvalidParameterError("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
|
1255
|
-
|
1256
1045
|
case 4:
|
1257
1046
|
params['path'] = path;
|
1258
|
-
|
1259
1047
|
if (params['path']) {
|
1260
1048
|
_context19.next = 7;
|
1261
1049
|
break;
|
1262
1050
|
}
|
1263
|
-
|
1264
1051
|
throw new errors.MissingParameterError('Parameter missing: path');
|
1265
|
-
|
1266
1052
|
case 7:
|
1267
1053
|
if (!(params['path'] && !(0, _utils.isString)(params['path']))) {
|
1268
1054
|
_context19.next = 9;
|
1269
1055
|
break;
|
1270
1056
|
}
|
1271
|
-
|
1272
1057
|
throw new errors.InvalidParameterError("Bad parameter: path must be of type String, received ".concat((0, _utils.getType)(params['path'])));
|
1273
|
-
|
1274
1058
|
case 9:
|
1275
1059
|
if (!(params['action'] && !(0, _utils.isString)(params['action']))) {
|
1276
1060
|
_context19.next = 11;
|
1277
1061
|
break;
|
1278
1062
|
}
|
1279
|
-
|
1280
1063
|
throw new errors.InvalidParameterError("Bad parameter: action must be of type String, received ".concat((0, _utils.getType)(params['action'])));
|
1281
|
-
|
1282
1064
|
case 11:
|
1283
1065
|
if (!(params['length'] && !(0, _utils.isInt)(params['length']))) {
|
1284
1066
|
_context19.next = 13;
|
1285
1067
|
break;
|
1286
1068
|
}
|
1287
|
-
|
1288
1069
|
throw new errors.InvalidParameterError("Bad parameter: length must be of type Int, received ".concat((0, _utils.getType)(params['length'])));
|
1289
|
-
|
1290
1070
|
case 13:
|
1291
1071
|
if (!(params['part'] && !(0, _utils.isInt)(params['part']))) {
|
1292
1072
|
_context19.next = 15;
|
1293
1073
|
break;
|
1294
1074
|
}
|
1295
|
-
|
1296
1075
|
throw new errors.InvalidParameterError("Bad parameter: part must be of type Int, received ".concat((0, _utils.getType)(params['part'])));
|
1297
|
-
|
1298
1076
|
case 15:
|
1299
1077
|
if (!(params['parts'] && !(0, _utils.isInt)(params['parts']))) {
|
1300
1078
|
_context19.next = 17;
|
1301
1079
|
break;
|
1302
1080
|
}
|
1303
|
-
|
1304
1081
|
throw new errors.InvalidParameterError("Bad parameter: parts must be of type Int, received ".concat((0, _utils.getType)(params['parts'])));
|
1305
|
-
|
1306
1082
|
case 17:
|
1307
1083
|
if (!(params['provided_mtime'] && !(0, _utils.isString)(params['provided_mtime']))) {
|
1308
1084
|
_context19.next = 19;
|
1309
1085
|
break;
|
1310
1086
|
}
|
1311
|
-
|
1312
1087
|
throw new errors.InvalidParameterError("Bad parameter: provided_mtime must be of type String, received ".concat((0, _utils.getType)(params['provided_mtime'])));
|
1313
|
-
|
1314
1088
|
case 19:
|
1315
1089
|
if (!(params['ref'] && !(0, _utils.isString)(params['ref']))) {
|
1316
1090
|
_context19.next = 21;
|
1317
1091
|
break;
|
1318
1092
|
}
|
1319
|
-
|
1320
1093
|
throw new errors.InvalidParameterError("Bad parameter: ref must be of type String, received ".concat((0, _utils.getType)(params['ref'])));
|
1321
|
-
|
1322
1094
|
case 21:
|
1323
1095
|
if (!(params['restart'] && !(0, _utils.isInt)(params['restart']))) {
|
1324
1096
|
_context19.next = 23;
|
1325
1097
|
break;
|
1326
1098
|
}
|
1327
|
-
|
1328
1099
|
throw new errors.InvalidParameterError("Bad parameter: restart must be of type Int, received ".concat((0, _utils.getType)(params['restart'])));
|
1329
|
-
|
1330
1100
|
case 23:
|
1331
1101
|
if (!(params['size'] && !(0, _utils.isInt)(params['size']))) {
|
1332
1102
|
_context19.next = 25;
|
1333
1103
|
break;
|
1334
1104
|
}
|
1335
|
-
|
1336
1105
|
throw new errors.InvalidParameterError("Bad parameter: size must be of type Int, received ".concat((0, _utils.getType)(params['size'])));
|
1337
|
-
|
1338
1106
|
case 25:
|
1339
1107
|
if (!(params['structure'] && !(0, _utils.isString)(params['structure']))) {
|
1340
1108
|
_context19.next = 27;
|
1341
1109
|
break;
|
1342
1110
|
}
|
1343
|
-
|
1344
1111
|
throw new errors.InvalidParameterError("Bad parameter: structure must be of type String, received ".concat((0, _utils.getType)(params['structure'])));
|
1345
|
-
|
1346
1112
|
case 27:
|
1347
1113
|
_context19.next = 29;
|
1348
1114
|
return _Api.default.sendRequest("/files/".concat(encodeURIComponent(params['path'])), 'POST', params, options);
|
1349
|
-
|
1350
1115
|
case 29:
|
1351
1116
|
response = _context19.sent;
|
1352
1117
|
return _context19.abrupt("return", new File(response === null || response === void 0 ? void 0 : response.data, options));
|
1353
|
-
|
1354
1118
|
case 31:
|
1355
1119
|
case "end":
|
1356
1120
|
return _context19.stop();
|
@@ -1358,7 +1122,6 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
1358
1122
|
}
|
1359
1123
|
}, _callee19);
|
1360
1124
|
}));
|
1361
|
-
|
1362
1125
|
return function (_x29) {
|
1363
1126
|
return _ref21.apply(this, arguments);
|
1364
1127
|
};
|
@@ -1366,57 +1129,45 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
1366
1129
|
(0, _defineProperty2.default)(File, "find", /*#__PURE__*/function () {
|
1367
1130
|
var _ref22 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee20(path) {
|
1368
1131
|
var params,
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1132
|
+
options,
|
1133
|
+
response,
|
1134
|
+
_args20 = arguments;
|
1372
1135
|
return _regenerator.default.wrap(function _callee20$(_context20) {
|
1373
1136
|
while (1) {
|
1374
1137
|
switch (_context20.prev = _context20.next) {
|
1375
1138
|
case 0:
|
1376
1139
|
params = _args20.length > 1 && _args20[1] !== undefined ? _args20[1] : {};
|
1377
1140
|
options = _args20.length > 2 && _args20[2] !== undefined ? _args20[2] : {};
|
1378
|
-
|
1379
1141
|
if ((0, _utils.isObject)(params)) {
|
1380
1142
|
_context20.next = 4;
|
1381
1143
|
break;
|
1382
1144
|
}
|
1383
|
-
|
1384
1145
|
throw new errors.InvalidParameterError("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
|
1385
|
-
|
1386
1146
|
case 4:
|
1387
1147
|
params['path'] = path;
|
1388
|
-
|
1389
1148
|
if (params['path']) {
|
1390
1149
|
_context20.next = 7;
|
1391
1150
|
break;
|
1392
1151
|
}
|
1393
|
-
|
1394
1152
|
throw new errors.MissingParameterError('Parameter missing: path');
|
1395
|
-
|
1396
1153
|
case 7:
|
1397
1154
|
if (!(params['path'] && !(0, _utils.isString)(params['path']))) {
|
1398
1155
|
_context20.next = 9;
|
1399
1156
|
break;
|
1400
1157
|
}
|
1401
|
-
|
1402
1158
|
throw new errors.InvalidParameterError("Bad parameter: path must be of type String, received ".concat((0, _utils.getType)(params['path'])));
|
1403
|
-
|
1404
1159
|
case 9:
|
1405
1160
|
if (!(params['preview_size'] && !(0, _utils.isString)(params['preview_size']))) {
|
1406
1161
|
_context20.next = 11;
|
1407
1162
|
break;
|
1408
1163
|
}
|
1409
|
-
|
1410
1164
|
throw new errors.InvalidParameterError("Bad parameter: preview_size must be of type String, received ".concat((0, _utils.getType)(params['preview_size'])));
|
1411
|
-
|
1412
1165
|
case 11:
|
1413
1166
|
_context20.next = 13;
|
1414
1167
|
return _Api.default.sendRequest("/file_actions/metadata/".concat(encodeURIComponent(params['path'])), 'GET', params, options);
|
1415
|
-
|
1416
1168
|
case 13:
|
1417
1169
|
response = _context20.sent;
|
1418
1170
|
return _context20.abrupt("return", new File(response === null || response === void 0 ? void 0 : response.data, options));
|
1419
|
-
|
1420
1171
|
case 15:
|
1421
1172
|
case "end":
|
1422
1173
|
return _context20.stop();
|
@@ -1424,7 +1175,6 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
|
|
1424
1175
|
}
|
1425
1176
|
}, _callee20);
|
1426
1177
|
}));
|
1427
|
-
|
1428
1178
|
return function (_x30) {
|
1429
1179
|
return _ref22.apply(this, arguments);
|
1430
1180
|
};
|