files.com 1.0.235 → 1.0.237
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 +9 -2
- package/docs/models/BundleNotification.md +35 -0
- package/docs/models/BundleRegistration.md +3 -1
- package/docs/models/InboxRegistration.md +3 -1
- package/docs/models/Site.md +2 -0
- package/lib/Api.js +153 -159
- package/lib/isomorphic/File.node.js +24 -28
- package/lib/models/ActionNotificationExport.js +97 -101
- package/lib/models/ActionNotificationExportResult.js +44 -46
- package/lib/models/ActionWebhookFailure.js +42 -44
- package/lib/models/ApiKey.js +271 -287
- package/lib/models/App.js +26 -28
- package/lib/models/As2IncomingMessage.js +32 -34
- package/lib/models/As2OutgoingMessage.js +32 -34
- package/lib/models/As2Partner.js +231 -241
- package/lib/models/As2Station.js +219 -229
- package/lib/models/Automation.js +333 -343
- package/lib/models/AutomationRun.js +75 -79
- package/lib/models/BandwidthSnapshot.js +26 -28
- package/lib/models/Behavior.js +323 -337
- package/lib/models/Bundle.js +381 -387
- package/lib/models/BundleDownload.js +38 -40
- package/lib/models/BundleNotification.js +223 -173
- package/lib/models/BundleRecipient.js +104 -108
- package/lib/models/BundleRegistration.js +41 -40
- package/lib/models/Clickwrap.js +213 -223
- package/lib/models/DnsRecord.js +26 -28
- package/lib/models/ExternalEvent.js +93 -99
- package/lib/models/File.js +726 -766
- package/lib/models/FileComment.js +180 -188
- package/lib/models/FileCommentReaction.js +84 -88
- package/lib/models/FileMigration.js +31 -33
- package/lib/models/Folder.js +94 -98
- package/lib/models/FormFieldSet.js +189 -199
- package/lib/models/Group.js +207 -217
- package/lib/models/GroupUser.js +230 -238
- package/lib/models/History.js +266 -276
- package/lib/models/HistoryExport.js +175 -179
- package/lib/models/HistoryExportResult.js +44 -46
- package/lib/models/InboxRecipient.js +104 -108
- package/lib/models/InboxRegistration.js +35 -34
- package/lib/models/InboxUpload.js +38 -40
- package/lib/models/Invoice.js +57 -61
- package/lib/models/IpAddress.js +78 -84
- package/lib/models/Lock.js +148 -154
- package/lib/models/Message.js +267 -277
- package/lib/models/MessageComment.js +207 -217
- package/lib/models/MessageCommentReaction.js +147 -155
- package/lib/models/MessageReaction.js +147 -155
- package/lib/models/Notification.js +255 -265
- package/lib/models/Payment.js +57 -61
- package/lib/models/Permission.js +128 -134
- package/lib/models/Priority.js +45 -47
- package/lib/models/Project.js +183 -193
- package/lib/models/PublicKey.js +207 -217
- package/lib/models/RemoteBandwidthSnapshot.js +26 -28
- package/lib/models/RemoteServer.js +805 -819
- package/lib/models/Request.js +166 -174
- package/lib/models/Session.js +47 -51
- package/lib/models/SettingsChange.js +26 -28
- package/lib/models/SftpHostKey.js +177 -187
- package/lib/models/Site.js +415 -418
- package/lib/models/SsoStrategy.js +99 -105
- package/lib/models/Style.js +127 -133
- package/lib/models/UsageDailySnapshot.js +26 -28
- package/lib/models/UsageSnapshot.js +26 -28
- package/lib/models/User.js +587 -603
- package/lib/models/UserCipherUse.js +32 -34
- package/lib/models/UserRequest.js +147 -155
- package/lib/models/WebhookTest.js +54 -56
- package/package.json +1 -1
- package/src/models/Bundle.js +10 -1
- package/src/models/BundleNotification.js +39 -1
- package/src/models/BundleRegistration.js +3 -0
- package/src/models/InboxRegistration.js +3 -0
- package/src/models/Site.js +3 -0
package/_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.237
|
package/docs/models/Bundle.md
CHANGED
@@ -24,6 +24,7 @@
|
|
24
24
|
"max_uses": 1,
|
25
25
|
"note": "The internal note on the bundle.",
|
26
26
|
"path_template": "{{name}}_{{ip}}",
|
27
|
+
"send_email_receipt_to_uploader": true,
|
27
28
|
"user_id": 1,
|
28
29
|
"username": "user",
|
29
30
|
"clickwrap_id": 1,
|
@@ -59,6 +60,7 @@
|
|
59
60
|
* `max_uses` (int64): Maximum number of times bundle can be accessed
|
60
61
|
* `note` (string): Bundle internal note
|
61
62
|
* `path_template` (string): Template for creating submission subfolders. Can use the uploader's name, email address, ip, company, and any custom form data.
|
63
|
+
* `send_email_receipt_to_uploader` (boolean): Send delivery receipt to the uploader. Note: For writable share only
|
62
64
|
* `user_id` (int64): Bundle creator user ID
|
63
65
|
* `username` (string): Bundle creator username
|
64
66
|
* `clickwrap_id` (int64): ID of the clickwrap to use with this bundle.
|
@@ -133,6 +135,7 @@ await Bundle.create({
|
|
133
135
|
'clickwrap_id': 1,
|
134
136
|
'inbox_id': 1,
|
135
137
|
'require_share_recipient': true,
|
138
|
+
'send_email_receipt_to_uploader': true,
|
136
139
|
'skip_email': true,
|
137
140
|
'skip_name': true,
|
138
141
|
'skip_company': true,
|
@@ -159,6 +162,7 @@ await Bundle.create({
|
|
159
162
|
* `clickwrap_id` (int64): ID of the clickwrap to use with this bundle.
|
160
163
|
* `inbox_id` (int64): ID of the associated inbox, if available.
|
161
164
|
* `require_share_recipient` (boolean): Only allow access to recipients who have explicitly received the share via an email sent through the Files.com UI?
|
165
|
+
* `send_email_receipt_to_uploader` (boolean): Send delivery receipt to the uploader. Note: For writable share only
|
162
166
|
* `skip_email` (boolean): BundleRegistrations can be saved without providing email?
|
163
167
|
* `skip_name` (boolean): BundleRegistrations can be saved without providing name?
|
164
168
|
* `skip_company` (boolean): BundleRegistrations can be saved without providing company?
|
@@ -210,9 +214,10 @@ await bundle.update({
|
|
210
214
|
'preview_only': true,
|
211
215
|
'require_registration': true,
|
212
216
|
'require_share_recipient': true,
|
217
|
+
'send_email_receipt_to_uploader': true,
|
218
|
+
'skip_company': true,
|
213
219
|
'skip_email': true,
|
214
220
|
'skip_name': true,
|
215
|
-
'skip_company': true,
|
216
221
|
'watermark_attachment_delete': true,
|
217
222
|
})
|
218
223
|
```
|
@@ -236,9 +241,10 @@ await bundle.update({
|
|
236
241
|
* `preview_only` (boolean): Restrict users to previewing files only?
|
237
242
|
* `require_registration` (boolean): Show a registration page that captures the downloader's name and email address?
|
238
243
|
* `require_share_recipient` (boolean): Only allow access to recipients who have explicitly received the share via an email sent through the Files.com UI?
|
244
|
+
* `send_email_receipt_to_uploader` (boolean): Send delivery receipt to the uploader. Note: For writable share only
|
245
|
+
* `skip_company` (boolean): BundleRegistrations can be saved without providing company?
|
239
246
|
* `skip_email` (boolean): BundleRegistrations can be saved without providing email?
|
240
247
|
* `skip_name` (boolean): BundleRegistrations can be saved without providing name?
|
241
|
-
* `skip_company` (boolean): BundleRegistrations can be saved without providing company?
|
242
248
|
* `watermark_attachment_delete` (boolean): If true, will delete the file stored in watermark_attachment
|
243
249
|
* `watermark_attachment_file` (file): Preview watermark image applied to all bundle items.
|
244
250
|
|
@@ -266,6 +272,7 @@ await bundle.update({
|
|
266
272
|
"max_uses": 1,
|
267
273
|
"note": "The internal note on the bundle.",
|
268
274
|
"path_template": "{{name}}_{{ip}}",
|
275
|
+
"send_email_receipt_to_uploader": true,
|
269
276
|
"user_id": 1,
|
270
277
|
"username": "user",
|
271
278
|
"clickwrap_id": 1,
|
@@ -7,6 +7,7 @@
|
|
7
7
|
"bundle_id": 1,
|
8
8
|
"id": 1,
|
9
9
|
"notify_on_registration": true,
|
10
|
+
"notify_on_upload": true,
|
10
11
|
"user_id": 1
|
11
12
|
}
|
12
13
|
```
|
@@ -14,6 +15,7 @@
|
|
14
15
|
* `bundle_id` (int64): Bundle ID to notify on
|
15
16
|
* `id` (int64): Bundle Notification ID
|
16
17
|
* `notify_on_registration` (boolean): Triggers bundle notification when a registration action occurs for it.
|
18
|
+
* `notify_on_upload` (boolean): Triggers bundle notification when a upload action occurs for it.
|
17
19
|
* `user_id` (int64): The id of the user to notify.
|
18
20
|
|
19
21
|
---
|
@@ -57,6 +59,7 @@ await BundleNotification.find(id)
|
|
57
59
|
await BundleNotification.create({
|
58
60
|
'user_id': 1,
|
59
61
|
'notify_on_registration': true,
|
62
|
+
'notify_on_upload': true,
|
60
63
|
'bundle_id': 1,
|
61
64
|
})
|
62
65
|
```
|
@@ -66,10 +69,42 @@ await BundleNotification.create({
|
|
66
69
|
|
67
70
|
* `user_id` (int64): Required - The id of the user to notify.
|
68
71
|
* `notify_on_registration` (boolean): Triggers bundle notification when a registration action occurs for it.
|
72
|
+
* `notify_on_upload` (boolean): Triggers bundle notification when a upload action occurs for it.
|
69
73
|
* `bundle_id` (int64): Required - Bundle ID to notify on
|
70
74
|
|
71
75
|
---
|
72
76
|
|
77
|
+
## Update Bundle Notification
|
78
|
+
|
79
|
+
```
|
80
|
+
const [bundle_notification] = await BundleNotification.list()
|
81
|
+
|
82
|
+
await bundle_notification.update({
|
83
|
+
'notify_on_registration': true,
|
84
|
+
'notify_on_upload': true,
|
85
|
+
})
|
86
|
+
```
|
87
|
+
|
88
|
+
### Parameters
|
89
|
+
|
90
|
+
* `id` (int64): Required - Bundle Notification ID.
|
91
|
+
* `notify_on_registration` (boolean): Triggers bundle notification when a registration action occurs for it.
|
92
|
+
* `notify_on_upload` (boolean): Triggers bundle notification when a upload action occurs for it.
|
93
|
+
|
94
|
+
### Example Response
|
95
|
+
|
96
|
+
```json
|
97
|
+
{
|
98
|
+
"bundle_id": 1,
|
99
|
+
"id": 1,
|
100
|
+
"notify_on_registration": true,
|
101
|
+
"notify_on_upload": true,
|
102
|
+
"user_id": 1
|
103
|
+
}
|
104
|
+
```
|
105
|
+
|
106
|
+
---
|
107
|
+
|
73
108
|
## Delete Bundle Notification
|
74
109
|
|
75
110
|
```
|
@@ -17,7 +17,8 @@
|
|
17
17
|
},
|
18
18
|
"bundle_code": "example",
|
19
19
|
"bundle_id": 1,
|
20
|
-
"bundle_recipient_id": 1
|
20
|
+
"bundle_recipient_id": 1,
|
21
|
+
"created_at": "2000-01-01T01:00:00Z"
|
21
22
|
}
|
22
23
|
```
|
23
24
|
|
@@ -33,6 +34,7 @@
|
|
33
34
|
* `bundle_code` (string): Bundle URL code
|
34
35
|
* `bundle_id` (int64): Id of associated bundle
|
35
36
|
* `bundle_recipient_id` (int64): Id of associated bundle recipient
|
37
|
+
* `created_at` (date-time): Registration creation date/time
|
36
38
|
|
37
39
|
---
|
38
40
|
|
@@ -15,7 +15,8 @@
|
|
15
15
|
},
|
16
16
|
"inbox_id": 1,
|
17
17
|
"inbox_recipient_id": 1,
|
18
|
-
"inbox_title": "example"
|
18
|
+
"inbox_title": "example",
|
19
|
+
"created_at": "2000-01-01T01:00:00Z"
|
19
20
|
}
|
20
21
|
```
|
21
22
|
|
@@ -29,6 +30,7 @@
|
|
29
30
|
* `inbox_id` (int64): Id of associated inbox
|
30
31
|
* `inbox_recipient_id` (int64): Id of associated inbox recipient
|
31
32
|
* `inbox_title` (string): Title of associated inbox
|
33
|
+
* `created_at` (date-time): Registration creation date/time
|
32
34
|
|
33
35
|
---
|
34
36
|
|
package/docs/models/Site.md
CHANGED
@@ -124,6 +124,7 @@
|
|
124
124
|
"smtp_port": 25,
|
125
125
|
"smtp_username": "mail",
|
126
126
|
"session_expiry": 6.0,
|
127
|
+
"session_expiry_minutes": 360,
|
127
128
|
"ssl_required": true,
|
128
129
|
"subdomain": "mysite",
|
129
130
|
"switch_to_plan_date": "2000-01-01T01:00:00Z",
|
@@ -267,6 +268,7 @@
|
|
267
268
|
* `smtp_port` (int64): SMTP server port
|
268
269
|
* `smtp_username` (string): SMTP server username
|
269
270
|
* `session_expiry` (double): Session expiry in hours
|
271
|
+
* `session_expiry_minutes` (int64): Session expiry in minutes
|
270
272
|
* `ssl_required` (boolean): Is SSL required? Disabling this is insecure.
|
271
273
|
* `subdomain` (string): Site subdomain
|
272
274
|
* `switch_to_plan_date` (date-time): If switching plans, when does the new plan take effect?
|
package/lib/Api.js
CHANGED
@@ -37,53 +37,51 @@ var Api = /*#__PURE__*/(0, _createClass2.default)(function Api() {
|
|
37
37
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(path, verb, options) {
|
38
38
|
var isExternal, baseUrl, url, response;
|
39
39
|
return _regenerator.default.wrap(function _callee$(_context) {
|
40
|
-
while (1) {
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
return _context.stop();
|
86
|
-
}
|
40
|
+
while (1) switch (_context.prev = _context.next) {
|
41
|
+
case 0:
|
42
|
+
isExternal = /^[a-zA-Z]+:\/\//.test(path);
|
43
|
+
baseUrl = _Files.default.getBaseUrl();
|
44
|
+
if (!(!isExternal && !baseUrl)) {
|
45
|
+
_context.next = 4;
|
46
|
+
break;
|
47
|
+
}
|
48
|
+
throw new errors.ConfigurationError('Base URL has not been set - use Files.setBaseUrl() to set it');
|
49
|
+
case 4:
|
50
|
+
url = isExternal ? path : "".concat(baseUrl).concat(_Files.default.getEndpointPrefix()).concat(path);
|
51
|
+
_Logger.default.debug("Sending request: ".concat(verb, " ").concat(url));
|
52
|
+
_Logger.default.debug('Sending options:', _objectSpread(_objectSpread({}, options), {}, {
|
53
|
+
headers: _objectSpread(_objectSpread({}, options.headers), {}, {
|
54
|
+
'X-FilesAPI-Key': '<redacted>'
|
55
|
+
})
|
56
|
+
}));
|
57
|
+
Api._configureAutoRetry();
|
58
|
+
_context.prev = 8;
|
59
|
+
_context.next = 11;
|
60
|
+
return (0, _axios.default)(_objectSpread({
|
61
|
+
method: verb,
|
62
|
+
timeout: _Files.default.getNetworkTimeout() * 1000,
|
63
|
+
url: url
|
64
|
+
}, options));
|
65
|
+
case 11:
|
66
|
+
response = _context.sent;
|
67
|
+
_Logger.default.debug("Status: ".concat(response.status, " ").concat(response.statusText));
|
68
|
+
if (_Files.default.shouldDebugResponseHeaders()) {
|
69
|
+
_Logger.default.debug('Response Headers: ');
|
70
|
+
_Logger.default.debug(response.headers);
|
71
|
+
}
|
72
|
+
return _context.abrupt("return", {
|
73
|
+
status: response.status,
|
74
|
+
reason: response.statusText,
|
75
|
+
headers: response.headers,
|
76
|
+
data: response.data
|
77
|
+
});
|
78
|
+
case 17:
|
79
|
+
_context.prev = 17;
|
80
|
+
_context.t0 = _context["catch"](8);
|
81
|
+
errors.handleErrorResponse(_context.t0);
|
82
|
+
case 20:
|
83
|
+
case "end":
|
84
|
+
return _context.stop();
|
87
85
|
}
|
88
86
|
}, _callee, null, [[8, 17]]);
|
89
87
|
}));
|
@@ -106,44 +104,42 @@ var Api = /*#__PURE__*/(0, _createClass2.default)(function Api() {
|
|
106
104
|
var _options$autoPaginate;
|
107
105
|
var _response$headers, nextCursor, _ref3, autoPaginateCount, previousAutoPaginateData, nextPage, nextParams, nextMetadata;
|
108
106
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
109
|
-
while (1) {
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
return _context2.stop();
|
146
|
-
}
|
107
|
+
while (1) switch (_context2.prev = _context2.next) {
|
108
|
+
case 0:
|
109
|
+
if (!((_options$autoPaginate = options.autoPaginate) !== null && _options$autoPaginate !== void 0 ? _options$autoPaginate : _Files.default.getAutoPaginate())) {
|
110
|
+
_context2.next = 12;
|
111
|
+
break;
|
112
|
+
}
|
113
|
+
nextCursor = response === null || response === void 0 ? void 0 : (_response$headers = response.headers) === null || _response$headers === void 0 ? void 0 : _response$headers['x-files-cursor'];
|
114
|
+
_ref3 = metadata || {}, autoPaginateCount = _ref3.autoPaginateCount, previousAutoPaginateData = _ref3.previousAutoPaginateData;
|
115
|
+
if (!nextCursor) {
|
116
|
+
_context2.next = 10;
|
117
|
+
break;
|
118
|
+
}
|
119
|
+
nextPage = (Number(params === null || params === void 0 ? void 0 : params.page) || 1) + 1;
|
120
|
+
nextParams = _objectSpread(_objectSpread({}, params), {}, {
|
121
|
+
cursor: nextCursor,
|
122
|
+
page: nextPage
|
123
|
+
});
|
124
|
+
nextMetadata = {
|
125
|
+
autoPaginateCount: (autoPaginateCount || 1) + 1,
|
126
|
+
previousAutoPaginateData: [].concat((0, _toConsumableArray2.default)(previousAutoPaginateData || []), (0, _toConsumableArray2.default)((response === null || response === void 0 ? void 0 : response.data) || []))
|
127
|
+
};
|
128
|
+
return _context2.abrupt("return", Api.sendRequest(path, verb, nextParams, options, nextMetadata));
|
129
|
+
case 10:
|
130
|
+
if (!previousAutoPaginateData) {
|
131
|
+
_context2.next = 12;
|
132
|
+
break;
|
133
|
+
}
|
134
|
+
return _context2.abrupt("return", _objectSpread(_objectSpread({}, response), {}, {
|
135
|
+
autoPaginateRequests: autoPaginateCount,
|
136
|
+
data: [].concat((0, _toConsumableArray2.default)(previousAutoPaginateData), (0, _toConsumableArray2.default)((response === null || response === void 0 ? void 0 : response.data) || []))
|
137
|
+
}));
|
138
|
+
case 12:
|
139
|
+
return _context2.abrupt("return", response);
|
140
|
+
case 13:
|
141
|
+
case "end":
|
142
|
+
return _context2.stop();
|
147
143
|
}
|
148
144
|
}, _callee2);
|
149
145
|
}));
|
@@ -168,83 +164,81 @@ var Api = /*#__PURE__*/(0, _createClass2.default)(function Api() {
|
|
168
164
|
response,
|
169
165
|
_args3 = arguments;
|
170
166
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
171
|
-
while (1) {
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
if (isExternal) {
|
184
|
-
_context3.next = 17;
|
185
|
-
break;
|
186
|
-
}
|
187
|
-
sessionId = options.sessionId || _Files.default.getSessionId();
|
188
|
-
if (!sessionId) {
|
189
|
-
_context3.next = 11;
|
190
|
-
break;
|
191
|
-
}
|
192
|
-
headers['X-FilesAPI-Auth'] = sessionId;
|
167
|
+
while (1) switch (_context3.prev = _context3.next) {
|
168
|
+
case 0:
|
169
|
+
params = _args3.length > 2 && _args3[2] !== undefined ? _args3[2] : null;
|
170
|
+
options = _args3.length > 3 && _args3[3] !== undefined ? _args3[3] : {};
|
171
|
+
metadata = _args3.length > 4 && _args3[4] !== undefined ? _args3[4] : null;
|
172
|
+
headers = _objectSpread(_objectSpread({
|
173
|
+
Accept: 'application/json'
|
174
|
+
}, options.headers), {}, {
|
175
|
+
'User-Agent': _Files.default.getUserAgent()
|
176
|
+
});
|
177
|
+
isExternal = /^[a-zA-Z]+:\/\//.test(path);
|
178
|
+
if (isExternal) {
|
193
179
|
_context3.next = 17;
|
194
180
|
break;
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
}));
|
181
|
+
}
|
182
|
+
sessionId = options.sessionId || _Files.default.getSessionId();
|
183
|
+
if (!sessionId) {
|
184
|
+
_context3.next = 11;
|
185
|
+
break;
|
186
|
+
}
|
187
|
+
headers['X-FilesAPI-Auth'] = sessionId;
|
188
|
+
_context3.next = 17;
|
189
|
+
break;
|
190
|
+
case 11:
|
191
|
+
isCreatingSession = path === '/sessions' && verb.toUpperCase() === 'POST'; // api key cannot be used when creating a session
|
192
|
+
if (isCreatingSession) {
|
193
|
+
_context3.next = 17;
|
194
|
+
break;
|
195
|
+
}
|
196
|
+
apiKey = options.apiKey || _Files.default.getApiKey();
|
197
|
+
if (apiKey) {
|
198
|
+
_context3.next = 16;
|
199
|
+
break;
|
200
|
+
}
|
201
|
+
throw new errors.ConfigurationError('API key has not been set - use Files.setApiKey() to set it');
|
202
|
+
case 16:
|
203
|
+
headers['X-FilesAPI-Key'] = apiKey;
|
204
|
+
case 17:
|
205
|
+
updatedOptions = _objectSpread(_objectSpread({}, options), {}, {
|
206
|
+
headers: headers
|
207
|
+
});
|
208
|
+
requestPath = path;
|
209
|
+
hasParams = (0, _utils.isObject)(params) && !(0, _utils.isEmpty)(params);
|
210
|
+
if (hasParams) {
|
211
|
+
if (verb.toUpperCase() === 'GET') {
|
212
|
+
pairs = Object.entries(params).map(function (_ref5) {
|
213
|
+
var _ref6 = (0, _slicedToArray2.default)(_ref5, 2),
|
214
|
+
key = _ref6[0],
|
215
|
+
value = _ref6[1];
|
216
|
+
return "".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value));
|
217
|
+
});
|
218
|
+
requestPath += path.includes('?') ? '&' : '?';
|
219
|
+
requestPath += pairs.join('&');
|
220
|
+
} else {
|
221
|
+
updatedOptions.data = JSON.stringify(params);
|
222
|
+
headers['Content-Type'] = 'application/json';
|
238
223
|
}
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
224
|
+
}
|
225
|
+
if (_Files.default.shouldDebugRequest()) {
|
226
|
+
_Logger.default.debug('Request Options:');
|
227
|
+
_Logger.default.debug(_objectSpread(_objectSpread({}, updatedOptions), {}, {
|
228
|
+
data: hasParams ? "payload keys: ".concat(Object.keys(params).join(', ')) : '(none)',
|
229
|
+
headers: _objectSpread(_objectSpread({}, headers), {}, {
|
230
|
+
'X-FilesAPI-Key': '<redacted>'
|
231
|
+
})
|
232
|
+
}));
|
233
|
+
}
|
234
|
+
_context3.next = 24;
|
235
|
+
return Api._sendVerbatim(requestPath, verb, updatedOptions);
|
236
|
+
case 24:
|
237
|
+
response = _context3.sent;
|
238
|
+
return _context3.abrupt("return", Api._autoPaginate(path, verb, params, updatedOptions, response, metadata));
|
239
|
+
case 26:
|
240
|
+
case "end":
|
241
|
+
return _context3.stop();
|
248
242
|
}
|
249
243
|
}, _callee3);
|
250
244
|
}));
|
@@ -18,22 +18,20 @@ exports.openDiskFileWriteStream = openDiskFileWriteStream;
|
|
18
18
|
var saveUrlToStream = /*#__PURE__*/function () {
|
19
19
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(url, stream) {
|
20
20
|
return _regenerator.default.wrap(function _callee$(_context) {
|
21
|
-
while (1) {
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
return _context.stop();
|
36
|
-
}
|
21
|
+
while (1) switch (_context.prev = _context.next) {
|
22
|
+
case 0:
|
23
|
+
return _context.abrupt("return", new Promise(function (resolve, reject) {
|
24
|
+
var https = require('https');
|
25
|
+
https.get(url, function (response) {
|
26
|
+
response.pipe(stream);
|
27
|
+
stream.on('finish', resolve);
|
28
|
+
}).on('error', function (error) {
|
29
|
+
reject(error);
|
30
|
+
});
|
31
|
+
}));
|
32
|
+
case 1:
|
33
|
+
case "end":
|
34
|
+
return _context.stop();
|
37
35
|
}
|
38
36
|
}, _callee);
|
39
37
|
}));
|
@@ -46,18 +44,16 @@ var saveUrlToFile = /*#__PURE__*/function () {
|
|
46
44
|
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(url, destinationPath) {
|
47
45
|
var stream;
|
48
46
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
49
|
-
while (1) {
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
return _context2.stop();
|
60
|
-
}
|
47
|
+
while (1) switch (_context2.prev = _context2.next) {
|
48
|
+
case 0:
|
49
|
+
stream = openDiskFileWriteStream(destinationPath);
|
50
|
+
_context2.next = 3;
|
51
|
+
return saveUrlToStream(url, stream);
|
52
|
+
case 3:
|
53
|
+
stream.close();
|
54
|
+
case 4:
|
55
|
+
case "end":
|
56
|
+
return _context2.stop();
|
61
57
|
}
|
62
58
|
}, _callee2);
|
63
59
|
}));
|