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/_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.223
|
package/docs/models/Bundle.md
CHANGED
@@ -19,9 +19,11 @@
|
|
19
19
|
"skip_company": true,
|
20
20
|
"id": 1,
|
21
21
|
"created_at": "2000-01-01T01:00:00Z",
|
22
|
+
"dont_separate_submissions_by_folder": true,
|
22
23
|
"expires_at": "2000-01-01T01:00:00Z",
|
23
24
|
"max_uses": 1,
|
24
25
|
"note": "The internal note on the bundle.",
|
26
|
+
"path_template": "{{name}}_{{ip}}",
|
25
27
|
"user_id": 1,
|
26
28
|
"username": "user",
|
27
29
|
"clickwrap_id": 1,
|
@@ -52,9 +54,11 @@
|
|
52
54
|
* `skip_company` (boolean): BundleRegistrations can be saved without providing company?
|
53
55
|
* `id` (int64): Bundle ID
|
54
56
|
* `created_at` (date-time): Bundle created at date/time
|
57
|
+
* `dont_separate_submissions_by_folder` (boolean): Do not create subfolders for files uploaded to this share. Note: there are subtle security pitfalls with allowing anonymous uploads from multiple users to live in the same folder. We strongly discourage use of this option unless absolutely required.
|
55
58
|
* `expires_at` (date-time): Bundle expiration date/time
|
56
59
|
* `max_uses` (int64): Maximum number of times bundle can be accessed
|
57
60
|
* `note` (string): Bundle internal note
|
61
|
+
* `path_template` (string): Template for creating submission subfolders. Can use the uploader's name, email address, ip, company, and any custom form data.
|
58
62
|
* `user_id` (int64): Bundle creator user ID
|
59
63
|
* `username` (string): Bundle creator username
|
60
64
|
* `clickwrap_id` (int64): ID of the clickwrap to use with this bundle.
|
@@ -116,11 +120,13 @@ await Bundle.create({
|
|
116
120
|
'paths': ["file.txt"],
|
117
121
|
'password': "Password",
|
118
122
|
'form_field_set_id': 1,
|
123
|
+
'dont_separate_submissions_by_folder': true,
|
119
124
|
'expires_at': "2000-01-01T01:00:00Z",
|
120
125
|
'max_uses': 1,
|
121
126
|
'description': "The public description of the bundle.",
|
122
127
|
'note': "The internal note on the bundle.",
|
123
128
|
'code': "abc123",
|
129
|
+
'path_template': "{{name}}_{{ip}}",
|
124
130
|
'permissions': "read",
|
125
131
|
'preview_only': true,
|
126
132
|
'require_registration': true,
|
@@ -140,11 +146,13 @@ await Bundle.create({
|
|
140
146
|
* `paths` (array(string)): Required - A list of paths to include in this bundle.
|
141
147
|
* `password` (string): Password for this bundle.
|
142
148
|
* `form_field_set_id` (int64): Id of Form Field Set to use with this bundle
|
149
|
+
* `dont_separate_submissions_by_folder` (boolean): Do not create subfolders for files uploaded to this share. Note: there are subtle security pitfalls with allowing anonymous uploads from multiple users to live in the same folder. We strongly discourage use of this option unless absolutely required.
|
143
150
|
* `expires_at` (string): Bundle expiration date/time
|
144
151
|
* `max_uses` (int64): Maximum number of times bundle can be accessed
|
145
152
|
* `description` (string): Public description
|
146
153
|
* `note` (string): Bundle internal note
|
147
154
|
* `code` (string): Bundle code. This code forms the end part of the Public URL.
|
155
|
+
* `path_template` (string): Template for creating submission subfolders. Can use the uploader's name, email address, ip, company, and any custom form data.
|
148
156
|
* `permissions` (string): Permissions that apply to Folders in this Share Link.
|
149
157
|
* `preview_only` (boolean): Restrict users to previewing files only?
|
150
158
|
* `require_registration` (boolean): Show a registration page that captures the downloader's name and email address?
|
@@ -192,10 +200,12 @@ await bundle.update({
|
|
192
200
|
'clickwrap_id': 1,
|
193
201
|
'code': "abc123",
|
194
202
|
'description': "The public description of the bundle.",
|
203
|
+
'dont_separate_submissions_by_folder': true,
|
195
204
|
'expires_at': "2000-01-01T01:00:00Z",
|
196
205
|
'inbox_id': 1,
|
197
206
|
'max_uses': 1,
|
198
207
|
'note': "The internal note on the bundle.",
|
208
|
+
'path_template': "{{name}}_{{ip}}",
|
199
209
|
'permissions': "read",
|
200
210
|
'preview_only': true,
|
201
211
|
'require_registration': true,
|
@@ -216,10 +226,12 @@ await bundle.update({
|
|
216
226
|
* `clickwrap_id` (int64): ID of the clickwrap to use with this bundle.
|
217
227
|
* `code` (string): Bundle code. This code forms the end part of the Public URL.
|
218
228
|
* `description` (string): Public description
|
229
|
+
* `dont_separate_submissions_by_folder` (boolean): Do not create subfolders for files uploaded to this share. Note: there are subtle security pitfalls with allowing anonymous uploads from multiple users to live in the same folder. We strongly discourage use of this option unless absolutely required.
|
219
230
|
* `expires_at` (string): Bundle expiration date/time
|
220
231
|
* `inbox_id` (int64): ID of the associated inbox, if available.
|
221
232
|
* `max_uses` (int64): Maximum number of times bundle can be accessed
|
222
233
|
* `note` (string): Bundle internal note
|
234
|
+
* `path_template` (string): Template for creating submission subfolders. Can use the uploader's name, email address, ip, company, and any custom form data.
|
223
235
|
* `permissions` (string): Permissions that apply to Folders in this Share Link.
|
224
236
|
* `preview_only` (boolean): Restrict users to previewing files only?
|
225
237
|
* `require_registration` (boolean): Show a registration page that captures the downloader's name and email address?
|
@@ -249,9 +261,11 @@ await bundle.update({
|
|
249
261
|
"skip_company": true,
|
250
262
|
"id": 1,
|
251
263
|
"created_at": "2000-01-01T01:00:00Z",
|
264
|
+
"dont_separate_submissions_by_folder": true,
|
252
265
|
"expires_at": "2000-01-01T01:00:00Z",
|
253
266
|
"max_uses": 1,
|
254
267
|
"note": "The internal note on the bundle.",
|
268
|
+
"path_template": "{{name}}_{{ip}}",
|
255
269
|
"user_id": 1,
|
256
270
|
"username": "user",
|
257
271
|
"clickwrap_id": 1,
|
package/lib/Api.js
CHANGED
@@ -1,46 +1,26 @@
|
|
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 _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
15
|
-
|
16
10
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
17
|
-
|
18
11
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
19
|
-
|
20
12
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
21
|
-
|
22
13
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
23
|
-
|
24
14
|
var _axios = _interopRequireDefault(require("axios"));
|
25
|
-
|
26
15
|
var _axiosRetry = _interopRequireDefault(require("axios-retry"));
|
27
|
-
|
28
16
|
var _Files = _interopRequireDefault(require("./Files"));
|
29
|
-
|
30
17
|
var errors = _interopRequireWildcard(require("./Errors"));
|
31
|
-
|
32
18
|
var _Logger = _interopRequireDefault(require("./Logger"));
|
33
|
-
|
34
19
|
var _utils = require("./utils");
|
35
|
-
|
36
20
|
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); }
|
37
|
-
|
38
21
|
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; }
|
39
|
-
|
40
22
|
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; }
|
41
|
-
|
42
23
|
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; }
|
43
|
-
|
44
24
|
var Api = /*#__PURE__*/(0, _createClass2.default)(function Api() {
|
45
25
|
(0, _classCallCheck2.default)(this, Api);
|
46
26
|
});
|
@@ -49,7 +29,6 @@ var Api = /*#__PURE__*/(0, _createClass2.default)(function Api() {
|
|
49
29
|
retries: _Files.default.getMaxNetworkRetries(),
|
50
30
|
retryDelay: function retryDelay(retries) {
|
51
31
|
_Logger.default.info("Retrying request (retry ".concat(retries, " of ").concat(_Files.default.getMaxNetworkRetries(), ")"));
|
52
|
-
|
53
32
|
return Math.min(retries * _Files.default.getMinNetworkRetryDelay() * 1000, _Files.default.getMaxNetworkRetryDelay() * 1000);
|
54
33
|
}
|
55
34
|
});
|
@@ -63,27 +42,20 @@ var Api = /*#__PURE__*/(0, _createClass2.default)(function Api() {
|
|
63
42
|
case 0:
|
64
43
|
isExternal = /^[a-zA-Z]+:\/\//.test(path);
|
65
44
|
baseUrl = _Files.default.getBaseUrl();
|
66
|
-
|
67
45
|
if (!(!isExternal && !baseUrl)) {
|
68
46
|
_context.next = 4;
|
69
47
|
break;
|
70
48
|
}
|
71
|
-
|
72
49
|
throw new errors.ConfigurationError('Base URL has not been set - use Files.setBaseUrl() to set it');
|
73
|
-
|
74
50
|
case 4:
|
75
51
|
url = isExternal ? path : "".concat(baseUrl).concat(_Files.default.getEndpointPrefix()).concat(path);
|
76
|
-
|
77
52
|
_Logger.default.debug("Sending request: ".concat(verb, " ").concat(url));
|
78
|
-
|
79
53
|
_Logger.default.debug('Sending options:', _objectSpread(_objectSpread({}, options), {}, {
|
80
54
|
headers: _objectSpread(_objectSpread({}, options.headers), {}, {
|
81
55
|
'X-FilesAPI-Key': '<redacted>'
|
82
56
|
})
|
83
57
|
}));
|
84
|
-
|
85
58
|
Api._configureAutoRetry();
|
86
|
-
|
87
59
|
_context.prev = 8;
|
88
60
|
_context.next = 11;
|
89
61
|
return (0, _axios.default)(_objectSpread({
|
@@ -91,30 +63,23 @@ var Api = /*#__PURE__*/(0, _createClass2.default)(function Api() {
|
|
91
63
|
timeout: _Files.default.getNetworkTimeout() * 1000,
|
92
64
|
url: url
|
93
65
|
}, options));
|
94
|
-
|
95
66
|
case 11:
|
96
67
|
response = _context.sent;
|
97
|
-
|
98
68
|
_Logger.default.debug("Status: ".concat(response.status, " ").concat(response.statusText));
|
99
|
-
|
100
69
|
if (_Files.default.shouldDebugResponseHeaders()) {
|
101
70
|
_Logger.default.debug('Response Headers: ');
|
102
|
-
|
103
71
|
_Logger.default.debug(response.headers);
|
104
72
|
}
|
105
|
-
|
106
73
|
return _context.abrupt("return", {
|
107
74
|
status: response.status,
|
108
75
|
reason: response.statusText,
|
109
76
|
headers: response.headers,
|
110
77
|
data: response.data
|
111
78
|
});
|
112
|
-
|
113
79
|
case 17:
|
114
80
|
_context.prev = 17;
|
115
81
|
_context.t0 = _context["catch"](8);
|
116
82
|
errors.handleErrorResponse(_context.t0);
|
117
|
-
|
118
83
|
case 20:
|
119
84
|
case "end":
|
120
85
|
return _context.stop();
|
@@ -122,7 +87,6 @@ var Api = /*#__PURE__*/(0, _createClass2.default)(function Api() {
|
|
122
87
|
}
|
123
88
|
}, _callee, null, [[8, 17]]);
|
124
89
|
}));
|
125
|
-
|
126
90
|
return function (_x, _x2, _x3) {
|
127
91
|
return _ref.apply(this, arguments);
|
128
92
|
};
|
@@ -132,19 +96,15 @@ var Api = /*#__PURE__*/(0, _createClass2.default)(function Api() {
|
|
132
96
|
var params = {
|
133
97
|
data: data
|
134
98
|
};
|
135
|
-
|
136
99
|
if (headers) {
|
137
100
|
params.headers = headers;
|
138
101
|
}
|
139
|
-
|
140
102
|
return Api._sendVerbatim(externalUrl, verb, params);
|
141
103
|
});
|
142
104
|
(0, _defineProperty2.default)(Api, "_autoPaginate", /*#__PURE__*/function () {
|
143
105
|
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(path, verb, params, options, response, metadata) {
|
144
106
|
var _options$autoPaginate;
|
145
|
-
|
146
107
|
var _response$headers, nextCursor, _ref3, autoPaginateCount, previousAutoPaginateData, nextPage, nextParams, nextMetadata;
|
147
|
-
|
148
108
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
149
109
|
while (1) {
|
150
110
|
switch (_context2.prev = _context2.next) {
|
@@ -153,15 +113,12 @@ var Api = /*#__PURE__*/(0, _createClass2.default)(function Api() {
|
|
153
113
|
_context2.next = 12;
|
154
114
|
break;
|
155
115
|
}
|
156
|
-
|
157
116
|
nextCursor = response === null || response === void 0 ? void 0 : (_response$headers = response.headers) === null || _response$headers === void 0 ? void 0 : _response$headers['x-files-cursor'];
|
158
117
|
_ref3 = metadata || {}, autoPaginateCount = _ref3.autoPaginateCount, previousAutoPaginateData = _ref3.previousAutoPaginateData;
|
159
|
-
|
160
118
|
if (!nextCursor) {
|
161
119
|
_context2.next = 10;
|
162
120
|
break;
|
163
121
|
}
|
164
|
-
|
165
122
|
nextPage = (Number(params === null || params === void 0 ? void 0 : params.page) || 1) + 1;
|
166
123
|
nextParams = _objectSpread(_objectSpread({}, params), {}, {
|
167
124
|
cursor: nextCursor,
|
@@ -172,21 +129,17 @@ var Api = /*#__PURE__*/(0, _createClass2.default)(function Api() {
|
|
172
129
|
previousAutoPaginateData: [].concat((0, _toConsumableArray2.default)(previousAutoPaginateData || []), (0, _toConsumableArray2.default)((response === null || response === void 0 ? void 0 : response.data) || []))
|
173
130
|
};
|
174
131
|
return _context2.abrupt("return", Api.sendRequest(path, verb, nextParams, options, nextMetadata));
|
175
|
-
|
176
132
|
case 10:
|
177
133
|
if (!previousAutoPaginateData) {
|
178
134
|
_context2.next = 12;
|
179
135
|
break;
|
180
136
|
}
|
181
|
-
|
182
137
|
return _context2.abrupt("return", _objectSpread(_objectSpread({}, response), {}, {
|
183
138
|
autoPaginateRequests: autoPaginateCount,
|
184
139
|
data: [].concat((0, _toConsumableArray2.default)(previousAutoPaginateData), (0, _toConsumableArray2.default)((response === null || response === void 0 ? void 0 : response.data) || []))
|
185
140
|
}));
|
186
|
-
|
187
141
|
case 12:
|
188
142
|
return _context2.abrupt("return", response);
|
189
|
-
|
190
143
|
case 13:
|
191
144
|
case "end":
|
192
145
|
return _context2.stop();
|
@@ -194,7 +147,6 @@ var Api = /*#__PURE__*/(0, _createClass2.default)(function Api() {
|
|
194
147
|
}
|
195
148
|
}, _callee2);
|
196
149
|
}));
|
197
|
-
|
198
150
|
return function (_x4, _x5, _x6, _x7, _x8, _x9) {
|
199
151
|
return _ref2.apply(this, arguments);
|
200
152
|
};
|
@@ -202,19 +154,19 @@ var Api = /*#__PURE__*/(0, _createClass2.default)(function Api() {
|
|
202
154
|
(0, _defineProperty2.default)(Api, "sendRequest", /*#__PURE__*/function () {
|
203
155
|
var _ref4 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(path, verb) {
|
204
156
|
var params,
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
157
|
+
options,
|
158
|
+
metadata,
|
159
|
+
headers,
|
160
|
+
isExternal,
|
161
|
+
sessionId,
|
162
|
+
isCreatingSession,
|
163
|
+
apiKey,
|
164
|
+
updatedOptions,
|
165
|
+
requestPath,
|
166
|
+
hasParams,
|
167
|
+
pairs,
|
168
|
+
response,
|
169
|
+
_args3 = arguments;
|
218
170
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
219
171
|
while (1) {
|
220
172
|
switch (_context3.prev = _context3.next) {
|
@@ -228,57 +180,44 @@ var Api = /*#__PURE__*/(0, _createClass2.default)(function Api() {
|
|
228
180
|
'User-Agent': _Files.default.getUserAgent()
|
229
181
|
});
|
230
182
|
isExternal = /^[a-zA-Z]+:\/\//.test(path);
|
231
|
-
|
232
183
|
if (isExternal) {
|
233
184
|
_context3.next = 17;
|
234
185
|
break;
|
235
186
|
}
|
236
|
-
|
237
187
|
sessionId = options.sessionId || _Files.default.getSessionId();
|
238
|
-
|
239
188
|
if (!sessionId) {
|
240
189
|
_context3.next = 11;
|
241
190
|
break;
|
242
191
|
}
|
243
|
-
|
244
192
|
headers['X-FilesAPI-Auth'] = sessionId;
|
245
193
|
_context3.next = 17;
|
246
194
|
break;
|
247
|
-
|
248
195
|
case 11:
|
249
196
|
isCreatingSession = path === '/sessions' && verb.toUpperCase() === 'POST'; // api key cannot be used when creating a session
|
250
|
-
|
251
197
|
if (isCreatingSession) {
|
252
198
|
_context3.next = 17;
|
253
199
|
break;
|
254
200
|
}
|
255
|
-
|
256
201
|
apiKey = options.apiKey || _Files.default.getApiKey();
|
257
|
-
|
258
202
|
if (apiKey) {
|
259
203
|
_context3.next = 16;
|
260
204
|
break;
|
261
205
|
}
|
262
|
-
|
263
206
|
throw new errors.ConfigurationError('API key has not been set - use Files.setApiKey() to set it');
|
264
|
-
|
265
207
|
case 16:
|
266
208
|
headers['X-FilesAPI-Key'] = apiKey;
|
267
|
-
|
268
209
|
case 17:
|
269
210
|
updatedOptions = _objectSpread(_objectSpread({}, options), {}, {
|
270
211
|
headers: headers
|
271
212
|
});
|
272
213
|
requestPath = path;
|
273
214
|
hasParams = (0, _utils.isObject)(params) && !(0, _utils.isEmpty)(params);
|
274
|
-
|
275
215
|
if (hasParams) {
|
276
216
|
if (verb.toUpperCase() === 'GET') {
|
277
217
|
pairs = Object.entries(params).map(function (_ref5) {
|
278
218
|
var _ref6 = (0, _slicedToArray2.default)(_ref5, 2),
|
279
|
-
|
280
|
-
|
281
|
-
|
219
|
+
key = _ref6[0],
|
220
|
+
value = _ref6[1];
|
282
221
|
return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value));
|
283
222
|
});
|
284
223
|
requestPath += path.includes('?') ? '&' : '?';
|
@@ -288,10 +227,8 @@ var Api = /*#__PURE__*/(0, _createClass2.default)(function Api() {
|
|
288
227
|
headers['Content-Type'] = 'application/json';
|
289
228
|
}
|
290
229
|
}
|
291
|
-
|
292
230
|
if (_Files.default.shouldDebugRequest()) {
|
293
231
|
_Logger.default.debug('Request Options:');
|
294
|
-
|
295
232
|
_Logger.default.debug(_objectSpread(_objectSpread({}, updatedOptions), {}, {
|
296
233
|
data: hasParams ? "payload keys: ".concat(Object.keys(params).join(', ')) : '(none)',
|
297
234
|
headers: _objectSpread(_objectSpread({}, headers), {}, {
|
@@ -299,14 +236,11 @@ var Api = /*#__PURE__*/(0, _createClass2.default)(function Api() {
|
|
299
236
|
})
|
300
237
|
}));
|
301
238
|
}
|
302
|
-
|
303
239
|
_context3.next = 24;
|
304
240
|
return Api._sendVerbatim(requestPath, verb, updatedOptions);
|
305
|
-
|
306
241
|
case 24:
|
307
242
|
response = _context3.sent;
|
308
243
|
return _context3.abrupt("return", Api._autoPaginate(path, verb, params, updatedOptions, response, metadata));
|
309
|
-
|
310
244
|
case 26:
|
311
245
|
case "end":
|
312
246
|
return _context3.stop();
|
@@ -314,7 +248,6 @@ var Api = /*#__PURE__*/(0, _createClass2.default)(function Api() {
|
|
314
248
|
}
|
315
249
|
}, _callee3);
|
316
250
|
}));
|
317
|
-
|
318
251
|
return function (_x10, _x11) {
|
319
252
|
return _ref4.apply(this, arguments);
|
320
253
|
};
|