files.com 1.0.266 → 1.0.268
Sign up to get free protection for your applications and to get access to all the features.
- package/_VERSION +1 -1
- package/docs/models/Bundle.md +13 -0
- package/docs/models/Snapshot.md +99 -0
- package/lib/models/Bundle.js +25 -0
- package/lib/models/Snapshot.js +322 -0
- package/package.json +1 -1
- package/src/models/Bundle.js +25 -0
- package/src/models/Snapshot.js +188 -0
package/_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.268
|
package/docs/models/Bundle.md
CHANGED
@@ -40,6 +40,7 @@
|
|
40
40
|
"note": "The internal note on the bundle.",
|
41
41
|
"path_template": "{{name}}_{{ip}}",
|
42
42
|
"send_email_receipt_to_uploader": true,
|
43
|
+
"snapshot_id": 1,
|
43
44
|
"user_id": 1,
|
44
45
|
"username": "user",
|
45
46
|
"clickwrap_id": 1,
|
@@ -76,6 +77,7 @@
|
|
76
77
|
* `note` (string): Bundle internal note
|
77
78
|
* `path_template` (string): Template for creating submission subfolders. Can use the uploader's name, email address, ip, company, and any custom form data.
|
78
79
|
* `send_email_receipt_to_uploader` (boolean): Send delivery receipt to the uploader. Note: For writable share only
|
80
|
+
* `snapshot_id` (int64): ID of the snapshot containing this bundle's contents.
|
79
81
|
* `user_id` (int64): Bundle creator user ID
|
80
82
|
* `username` (string): Bundle creator username
|
81
83
|
* `clickwrap_id` (int64): ID of the clickwrap to use with this bundle.
|
@@ -86,6 +88,8 @@
|
|
86
88
|
* `paths` (array): A list of paths in this bundle. For performance reasons, this is not provided when listing bundles.
|
87
89
|
* `password` (string): Password for this bundle.
|
88
90
|
* `form_field_set_id` (int64): Id of Form Field Set to use with this bundle
|
91
|
+
* `create_snapshot` (boolean): If true, create a snapshot of this bundle's contents.
|
92
|
+
* `finalize_snapshot` (boolean): If true, finalize the snapshot of this bundle's contents. Note that `create_snapshot` must also be true.
|
89
93
|
* `watermark_attachment_file` (file): Preview watermark image applied to all bundle items.
|
90
94
|
* `watermark_attachment_delete` (boolean): If true, will delete the file stored in watermark_attachment
|
91
95
|
|
@@ -136,8 +140,10 @@ await Bundle.create({
|
|
136
140
|
'paths': ["file.txt"],
|
137
141
|
'password': "Password",
|
138
142
|
'form_field_set_id': 1,
|
143
|
+
'create_snapshot': true,
|
139
144
|
'dont_separate_submissions_by_folder': true,
|
140
145
|
'expires_at': "2000-01-01T01:00:00Z",
|
146
|
+
'finalize_snapshot': true,
|
141
147
|
'max_uses': 1,
|
142
148
|
'description': "The public description of the bundle.",
|
143
149
|
'note': "The internal note on the bundle.",
|
@@ -163,8 +169,10 @@ await Bundle.create({
|
|
163
169
|
* `paths` (array(string)): Required - A list of paths to include in this bundle.
|
164
170
|
* `password` (string): Password for this bundle.
|
165
171
|
* `form_field_set_id` (int64): Id of Form Field Set to use with this bundle
|
172
|
+
* `create_snapshot` (boolean): If true, create a snapshot of this bundle's contents.
|
166
173
|
* `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.
|
167
174
|
* `expires_at` (string): Bundle expiration date/time
|
175
|
+
* `finalize_snapshot` (boolean): If true, finalize the snapshot of this bundle's contents. Note that `create_snapshot` must also be true.
|
168
176
|
* `max_uses` (int64): Maximum number of times bundle can be accessed
|
169
177
|
* `description` (string): Public description
|
170
178
|
* `note` (string): Bundle internal note
|
@@ -217,9 +225,11 @@ await bundle.update({
|
|
217
225
|
'form_field_set_id': 1,
|
218
226
|
'clickwrap_id': 1,
|
219
227
|
'code': "abc123",
|
228
|
+
'create_snapshot': true,
|
220
229
|
'description': "The public description of the bundle.",
|
221
230
|
'dont_separate_submissions_by_folder': true,
|
222
231
|
'expires_at': "2000-01-01T01:00:00Z",
|
232
|
+
'finalize_snapshot': true,
|
223
233
|
'inbox_id': 1,
|
224
234
|
'max_uses': 1,
|
225
235
|
'note': "The internal note on the bundle.",
|
@@ -244,9 +254,11 @@ await bundle.update({
|
|
244
254
|
* `form_field_set_id` (int64): Id of Form Field Set to use with this bundle
|
245
255
|
* `clickwrap_id` (int64): ID of the clickwrap to use with this bundle.
|
246
256
|
* `code` (string): Bundle code. This code forms the end part of the Public URL.
|
257
|
+
* `create_snapshot` (boolean): If true, create a snapshot of this bundle's contents.
|
247
258
|
* `description` (string): Public description
|
248
259
|
* `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.
|
249
260
|
* `expires_at` (string): Bundle expiration date/time
|
261
|
+
* `finalize_snapshot` (boolean): If true, finalize the snapshot of this bundle's contents. Note that `create_snapshot` must also be true.
|
250
262
|
* `inbox_id` (int64): ID of the associated inbox, if available.
|
251
263
|
* `max_uses` (int64): Maximum number of times bundle can be accessed
|
252
264
|
* `note` (string): Bundle internal note
|
@@ -302,6 +314,7 @@ await bundle.update({
|
|
302
314
|
"note": "The internal note on the bundle.",
|
303
315
|
"path_template": "{{name}}_{{ip}}",
|
304
316
|
"send_email_receipt_to_uploader": true,
|
317
|
+
"snapshot_id": 1,
|
305
318
|
"user_id": 1,
|
306
319
|
"username": "user",
|
307
320
|
"clickwrap_id": 1,
|
@@ -0,0 +1,99 @@
|
|
1
|
+
# Snapshot
|
2
|
+
|
3
|
+
## Example Snapshot Object
|
4
|
+
|
5
|
+
```
|
6
|
+
{
|
7
|
+
"expires_at": "2000-01-01T01:00:00Z",
|
8
|
+
"finalized_at": "2000-01-01T01:00:00Z",
|
9
|
+
"name": "My Snapshot",
|
10
|
+
"user_id": 1,
|
11
|
+
"bundle_id": 1
|
12
|
+
}
|
13
|
+
```
|
14
|
+
|
15
|
+
* `expires_at` (date-time): When the snapshot expires.
|
16
|
+
* `finalized_at` (date-time): When the snapshot was finalized.
|
17
|
+
* `name` (string): A name for the snapshot.
|
18
|
+
* `user_id` (int64): The user that created this snapshot, if applicable.
|
19
|
+
* `bundle_id` (int64): The bundle using this snapshot, if applicable.
|
20
|
+
* `id` (int64): Snapshot ID.
|
21
|
+
|
22
|
+
---
|
23
|
+
|
24
|
+
## List Snapshots
|
25
|
+
|
26
|
+
```
|
27
|
+
await Snapshot.list({
|
28
|
+
'per_page': 1,
|
29
|
+
})
|
30
|
+
```
|
31
|
+
|
32
|
+
|
33
|
+
### Parameters
|
34
|
+
|
35
|
+
* `cursor` (string): Used for pagination. When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`. Send one of those cursor value here to resume an existing list from the next available record. Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
|
36
|
+
* `per_page` (int64): Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
|
37
|
+
|
38
|
+
---
|
39
|
+
|
40
|
+
## Show Snapshot
|
41
|
+
|
42
|
+
```
|
43
|
+
await Snapshot.find(id)
|
44
|
+
```
|
45
|
+
|
46
|
+
|
47
|
+
### Parameters
|
48
|
+
|
49
|
+
* `id` (int64): Required - Snapshot ID.
|
50
|
+
|
51
|
+
---
|
52
|
+
|
53
|
+
## Create Snapshot
|
54
|
+
|
55
|
+
```
|
56
|
+
await Snapshot.create
|
57
|
+
```
|
58
|
+
|
59
|
+
|
60
|
+
---
|
61
|
+
|
62
|
+
## Update Snapshot
|
63
|
+
|
64
|
+
```
|
65
|
+
const [snapshot] = await Snapshot.list()
|
66
|
+
|
67
|
+
await snapshot.update()
|
68
|
+
```
|
69
|
+
|
70
|
+
### Parameters
|
71
|
+
|
72
|
+
* `id` (int64): Required - Snapshot ID.
|
73
|
+
|
74
|
+
### Example Response
|
75
|
+
|
76
|
+
```json
|
77
|
+
{
|
78
|
+
"expires_at": "2000-01-01T01:00:00Z",
|
79
|
+
"finalized_at": "2000-01-01T01:00:00Z",
|
80
|
+
"name": "My Snapshot",
|
81
|
+
"user_id": 1,
|
82
|
+
"bundle_id": 1
|
83
|
+
}
|
84
|
+
```
|
85
|
+
|
86
|
+
---
|
87
|
+
|
88
|
+
## Delete Snapshot
|
89
|
+
|
90
|
+
```
|
91
|
+
const [snapshot] = await Snapshot.list()
|
92
|
+
|
93
|
+
await snapshot.delete()
|
94
|
+
```
|
95
|
+
|
96
|
+
### Parameters
|
97
|
+
|
98
|
+
* `id` (int64): Required - Snapshot ID.
|
99
|
+
|
package/lib/models/Bundle.js
CHANGED
@@ -175,6 +175,13 @@ var Bundle = /*#__PURE__*/(0, _createClass2.default)(function Bundle() {
|
|
175
175
|
(0, _defineProperty2.default)(this, "setSendEmailReceiptToUploader", function (value) {
|
176
176
|
_this.attributes.send_email_receipt_to_uploader = value;
|
177
177
|
});
|
178
|
+
// int64 # ID of the snapshot containing this bundle's contents.
|
179
|
+
(0, _defineProperty2.default)(this, "getSnapshotId", function () {
|
180
|
+
return _this.attributes.snapshot_id;
|
181
|
+
});
|
182
|
+
(0, _defineProperty2.default)(this, "setSnapshotId", function (value) {
|
183
|
+
_this.attributes.snapshot_id = value;
|
184
|
+
});
|
178
185
|
// int64 # Bundle creator user ID
|
179
186
|
(0, _defineProperty2.default)(this, "getUserId", function () {
|
180
187
|
return _this.attributes.user_id;
|
@@ -245,6 +252,20 @@ var Bundle = /*#__PURE__*/(0, _createClass2.default)(function Bundle() {
|
|
245
252
|
(0, _defineProperty2.default)(this, "setFormFieldSetId", function (value) {
|
246
253
|
_this.attributes.form_field_set_id = value;
|
247
254
|
});
|
255
|
+
// boolean # If true, create a snapshot of this bundle's contents.
|
256
|
+
(0, _defineProperty2.default)(this, "getCreateSnapshot", function () {
|
257
|
+
return _this.attributes.create_snapshot;
|
258
|
+
});
|
259
|
+
(0, _defineProperty2.default)(this, "setCreateSnapshot", function (value) {
|
260
|
+
_this.attributes.create_snapshot = value;
|
261
|
+
});
|
262
|
+
// boolean # If true, finalize the snapshot of this bundle's contents. Note that `create_snapshot` must also be true.
|
263
|
+
(0, _defineProperty2.default)(this, "getFinalizeSnapshot", function () {
|
264
|
+
return _this.attributes.finalize_snapshot;
|
265
|
+
});
|
266
|
+
(0, _defineProperty2.default)(this, "setFinalizeSnapshot", function (value) {
|
267
|
+
_this.attributes.finalize_snapshot = value;
|
268
|
+
});
|
248
269
|
// file # Preview watermark image applied to all bundle items.
|
249
270
|
(0, _defineProperty2.default)(this, "getWatermarkAttachmentFile", function () {
|
250
271
|
return _this.attributes.watermark_attachment_file;
|
@@ -341,9 +362,11 @@ var Bundle = /*#__PURE__*/(0, _createClass2.default)(function Bundle() {
|
|
341
362
|
// form_field_set_id - int64 - Id of Form Field Set to use with this bundle
|
342
363
|
// clickwrap_id - int64 - ID of the clickwrap to use with this bundle.
|
343
364
|
// code - string - Bundle code. This code forms the end part of the Public URL.
|
365
|
+
// create_snapshot - boolean - If true, create a snapshot of this bundle's contents.
|
344
366
|
// description - string - Public description
|
345
367
|
// 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.
|
346
368
|
// expires_at - string - Bundle expiration date/time
|
369
|
+
// finalize_snapshot - boolean - If true, finalize the snapshot of this bundle's contents. Note that `create_snapshot` must also be true.
|
347
370
|
// inbox_id - int64 - ID of the associated inbox, if available.
|
348
371
|
// max_uses - int64 - Maximum number of times bundle can be accessed
|
349
372
|
// note - string - Bundle internal note
|
@@ -674,8 +697,10 @@ var Bundle = /*#__PURE__*/(0, _createClass2.default)(function Bundle() {
|
|
674
697
|
// paths (required) - array(string) - A list of paths to include in this bundle.
|
675
698
|
// password - string - Password for this bundle.
|
676
699
|
// form_field_set_id - int64 - Id of Form Field Set to use with this bundle
|
700
|
+
// create_snapshot - boolean - If true, create a snapshot of this bundle's contents.
|
677
701
|
// 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.
|
678
702
|
// expires_at - string - Bundle expiration date/time
|
703
|
+
// finalize_snapshot - boolean - If true, finalize the snapshot of this bundle's contents. Note that `create_snapshot` must also be true.
|
679
704
|
// max_uses - int64 - Maximum number of times bundle can be accessed
|
680
705
|
// description - string - Public description
|
681
706
|
// note - string - Bundle internal note
|
@@ -0,0 +1,322 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
5
|
+
exports.__esModule = true;
|
6
|
+
exports.default = void 0;
|
7
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
8
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
9
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
10
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
11
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
13
|
+
var _Api = _interopRequireDefault(require("../Api"));
|
14
|
+
var errors = _interopRequireWildcard(require("../Errors"));
|
15
|
+
var _Logger = _interopRequireDefault(require("../Logger"));
|
16
|
+
var _utils = require("../utils");
|
17
|
+
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); }
|
18
|
+
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; }
|
19
|
+
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; }
|
20
|
+
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; }
|
21
|
+
/**
|
22
|
+
* Class Snapshot
|
23
|
+
*/
|
24
|
+
var Snapshot = /*#__PURE__*/(0, _createClass2.default)(function Snapshot() {
|
25
|
+
var _this = this;
|
26
|
+
var attributes = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
27
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
28
|
+
(0, _classCallCheck2.default)(this, Snapshot);
|
29
|
+
(0, _defineProperty2.default)(this, "attributes", {});
|
30
|
+
(0, _defineProperty2.default)(this, "options", {});
|
31
|
+
(0, _defineProperty2.default)(this, "isLoaded", function () {
|
32
|
+
return !!_this.attributes.id;
|
33
|
+
});
|
34
|
+
// date-time # When the snapshot expires.
|
35
|
+
(0, _defineProperty2.default)(this, "getExpiresAt", function () {
|
36
|
+
return _this.attributes.expires_at;
|
37
|
+
});
|
38
|
+
(0, _defineProperty2.default)(this, "setExpiresAt", function (value) {
|
39
|
+
_this.attributes.expires_at = value;
|
40
|
+
});
|
41
|
+
// date-time # When the snapshot was finalized.
|
42
|
+
(0, _defineProperty2.default)(this, "getFinalizedAt", function () {
|
43
|
+
return _this.attributes.finalized_at;
|
44
|
+
});
|
45
|
+
(0, _defineProperty2.default)(this, "setFinalizedAt", function (value) {
|
46
|
+
_this.attributes.finalized_at = value;
|
47
|
+
});
|
48
|
+
// string # A name for the snapshot.
|
49
|
+
(0, _defineProperty2.default)(this, "getName", function () {
|
50
|
+
return _this.attributes.name;
|
51
|
+
});
|
52
|
+
(0, _defineProperty2.default)(this, "setName", function (value) {
|
53
|
+
_this.attributes.name = value;
|
54
|
+
});
|
55
|
+
// int64 # The user that created this snapshot, if applicable.
|
56
|
+
(0, _defineProperty2.default)(this, "getUserId", function () {
|
57
|
+
return _this.attributes.user_id;
|
58
|
+
});
|
59
|
+
(0, _defineProperty2.default)(this, "setUserId", function (value) {
|
60
|
+
_this.attributes.user_id = value;
|
61
|
+
});
|
62
|
+
// int64 # The bundle using this snapshot, if applicable.
|
63
|
+
(0, _defineProperty2.default)(this, "getBundleId", function () {
|
64
|
+
return _this.attributes.bundle_id;
|
65
|
+
});
|
66
|
+
(0, _defineProperty2.default)(this, "setBundleId", function (value) {
|
67
|
+
_this.attributes.bundle_id = value;
|
68
|
+
});
|
69
|
+
// int64 # Snapshot ID.
|
70
|
+
(0, _defineProperty2.default)(this, "getId", function () {
|
71
|
+
return _this.attributes.id;
|
72
|
+
});
|
73
|
+
(0, _defineProperty2.default)(this, "setId", function (value) {
|
74
|
+
_this.attributes.id = value;
|
75
|
+
});
|
76
|
+
(0, _defineProperty2.default)(this, "update", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
77
|
+
var params,
|
78
|
+
response,
|
79
|
+
_args = arguments;
|
80
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
81
|
+
while (1) switch (_context.prev = _context.next) {
|
82
|
+
case 0:
|
83
|
+
params = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
|
84
|
+
if (_this.attributes.id) {
|
85
|
+
_context.next = 3;
|
86
|
+
break;
|
87
|
+
}
|
88
|
+
throw new errors.EmptyPropertyError('Current object has no id');
|
89
|
+
case 3:
|
90
|
+
if ((0, _utils.isObject)(params)) {
|
91
|
+
_context.next = 5;
|
92
|
+
break;
|
93
|
+
}
|
94
|
+
throw new errors.InvalidParameterError("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
|
95
|
+
case 5:
|
96
|
+
params.id = _this.attributes.id;
|
97
|
+
if (!(params['id'] && !(0, _utils.isInt)(params['id']))) {
|
98
|
+
_context.next = 8;
|
99
|
+
break;
|
100
|
+
}
|
101
|
+
throw new errors.InvalidParameterError("Bad parameter: id must be of type Int, received ".concat((0, _utils.getType)(id)));
|
102
|
+
case 8:
|
103
|
+
if (params['id']) {
|
104
|
+
_context.next = 14;
|
105
|
+
break;
|
106
|
+
}
|
107
|
+
if (!_this.attributes.id) {
|
108
|
+
_context.next = 13;
|
109
|
+
break;
|
110
|
+
}
|
111
|
+
params['id'] = _this.id;
|
112
|
+
_context.next = 14;
|
113
|
+
break;
|
114
|
+
case 13:
|
115
|
+
throw new errors.MissingParameterError('Parameter missing: id');
|
116
|
+
case 14:
|
117
|
+
_context.next = 16;
|
118
|
+
return _Api.default.sendRequest("/snapshots/".concat(encodeURIComponent(params['id'])), 'PATCH', params, _this.options);
|
119
|
+
case 16:
|
120
|
+
response = _context.sent;
|
121
|
+
return _context.abrupt("return", new Snapshot(response === null || response === void 0 ? void 0 : response.data, _this.options));
|
122
|
+
case 18:
|
123
|
+
case "end":
|
124
|
+
return _context.stop();
|
125
|
+
}
|
126
|
+
}, _callee);
|
127
|
+
})));
|
128
|
+
(0, _defineProperty2.default)(this, "delete", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
129
|
+
var params,
|
130
|
+
response,
|
131
|
+
_args2 = arguments;
|
132
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
133
|
+
while (1) switch (_context2.prev = _context2.next) {
|
134
|
+
case 0:
|
135
|
+
params = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
|
136
|
+
if (_this.attributes.id) {
|
137
|
+
_context2.next = 3;
|
138
|
+
break;
|
139
|
+
}
|
140
|
+
throw new errors.EmptyPropertyError('Current object has no id');
|
141
|
+
case 3:
|
142
|
+
if ((0, _utils.isObject)(params)) {
|
143
|
+
_context2.next = 5;
|
144
|
+
break;
|
145
|
+
}
|
146
|
+
throw new errors.InvalidParameterError("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
|
147
|
+
case 5:
|
148
|
+
params.id = _this.attributes.id;
|
149
|
+
if (!(params['id'] && !(0, _utils.isInt)(params['id']))) {
|
150
|
+
_context2.next = 8;
|
151
|
+
break;
|
152
|
+
}
|
153
|
+
throw new errors.InvalidParameterError("Bad parameter: id must be of type Int, received ".concat((0, _utils.getType)(id)));
|
154
|
+
case 8:
|
155
|
+
if (params['id']) {
|
156
|
+
_context2.next = 14;
|
157
|
+
break;
|
158
|
+
}
|
159
|
+
if (!_this.attributes.id) {
|
160
|
+
_context2.next = 13;
|
161
|
+
break;
|
162
|
+
}
|
163
|
+
params['id'] = _this.id;
|
164
|
+
_context2.next = 14;
|
165
|
+
break;
|
166
|
+
case 13:
|
167
|
+
throw new errors.MissingParameterError('Parameter missing: id');
|
168
|
+
case 14:
|
169
|
+
_context2.next = 16;
|
170
|
+
return _Api.default.sendRequest("/snapshots/".concat(encodeURIComponent(params['id'])), 'DELETE', params, _this.options);
|
171
|
+
case 16:
|
172
|
+
response = _context2.sent;
|
173
|
+
return _context2.abrupt("return", response === null || response === void 0 ? void 0 : response.data);
|
174
|
+
case 18:
|
175
|
+
case "end":
|
176
|
+
return _context2.stop();
|
177
|
+
}
|
178
|
+
}, _callee2);
|
179
|
+
})));
|
180
|
+
(0, _defineProperty2.default)(this, "destroy", function () {
|
181
|
+
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
182
|
+
return _this.delete(params);
|
183
|
+
});
|
184
|
+
(0, _defineProperty2.default)(this, "save", function () {
|
185
|
+
if (_this.attributes['id']) {
|
186
|
+
return _this.update(_this.attributes);
|
187
|
+
} else {
|
188
|
+
var newObject = Snapshot.create(_this.attributes, _this.options);
|
189
|
+
_this.attributes = _objectSpread({}, newObject.attributes);
|
190
|
+
return true;
|
191
|
+
}
|
192
|
+
});
|
193
|
+
Object.entries(attributes).forEach(function (_ref3) {
|
194
|
+
var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
|
195
|
+
key = _ref4[0],
|
196
|
+
value = _ref4[1];
|
197
|
+
var normalizedKey = key.replace('?', '');
|
198
|
+
_this.attributes[normalizedKey] = value;
|
199
|
+
Object.defineProperty(_this, normalizedKey, {
|
200
|
+
value: value,
|
201
|
+
writable: false
|
202
|
+
});
|
203
|
+
});
|
204
|
+
this.options = _objectSpread({}, options);
|
205
|
+
});
|
206
|
+
// Parameters:
|
207
|
+
// cursor - string - Used for pagination. When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`. Send one of those cursor value here to resume an existing list from the next available record. Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
|
208
|
+
// per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
|
209
|
+
(0, _defineProperty2.default)(Snapshot, "list", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
210
|
+
var _response$data;
|
211
|
+
var params,
|
212
|
+
options,
|
213
|
+
response,
|
214
|
+
_args3 = arguments;
|
215
|
+
return _regenerator.default.wrap(function _callee3$(_context3) {
|
216
|
+
while (1) switch (_context3.prev = _context3.next) {
|
217
|
+
case 0:
|
218
|
+
params = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {};
|
219
|
+
options = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : {};
|
220
|
+
if (!(params['cursor'] && !(0, _utils.isString)(params['cursor']))) {
|
221
|
+
_context3.next = 4;
|
222
|
+
break;
|
223
|
+
}
|
224
|
+
throw new errors.InvalidParameterError("Bad parameter: cursor must be of type String, received ".concat((0, _utils.getType)(params['cursor'])));
|
225
|
+
case 4:
|
226
|
+
if (!(params['per_page'] && !(0, _utils.isInt)(params['per_page']))) {
|
227
|
+
_context3.next = 6;
|
228
|
+
break;
|
229
|
+
}
|
230
|
+
throw new errors.InvalidParameterError("Bad parameter: per_page must be of type Int, received ".concat((0, _utils.getType)(params['per_page'])));
|
231
|
+
case 6:
|
232
|
+
_context3.next = 8;
|
233
|
+
return _Api.default.sendRequest("/snapshots", 'GET', params, options);
|
234
|
+
case 8:
|
235
|
+
response = _context3.sent;
|
236
|
+
return _context3.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) {
|
237
|
+
return new Snapshot(obj, options);
|
238
|
+
})) || []);
|
239
|
+
case 10:
|
240
|
+
case "end":
|
241
|
+
return _context3.stop();
|
242
|
+
}
|
243
|
+
}, _callee3);
|
244
|
+
})));
|
245
|
+
(0, _defineProperty2.default)(Snapshot, "all", function () {
|
246
|
+
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
247
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
248
|
+
return Snapshot.list(params, options);
|
249
|
+
});
|
250
|
+
// Parameters:
|
251
|
+
// id (required) - int64 - Snapshot ID.
|
252
|
+
(0, _defineProperty2.default)(Snapshot, "find", /*#__PURE__*/function () {
|
253
|
+
var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(id) {
|
254
|
+
var params,
|
255
|
+
options,
|
256
|
+
response,
|
257
|
+
_args4 = arguments;
|
258
|
+
return _regenerator.default.wrap(function _callee4$(_context4) {
|
259
|
+
while (1) switch (_context4.prev = _context4.next) {
|
260
|
+
case 0:
|
261
|
+
params = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
|
262
|
+
options = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : {};
|
263
|
+
if ((0, _utils.isObject)(params)) {
|
264
|
+
_context4.next = 4;
|
265
|
+
break;
|
266
|
+
}
|
267
|
+
throw new errors.InvalidParameterError("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
|
268
|
+
case 4:
|
269
|
+
params['id'] = id;
|
270
|
+
if (params['id']) {
|
271
|
+
_context4.next = 7;
|
272
|
+
break;
|
273
|
+
}
|
274
|
+
throw new errors.MissingParameterError('Parameter missing: id');
|
275
|
+
case 7:
|
276
|
+
if (!(params['id'] && !(0, _utils.isInt)(params['id']))) {
|
277
|
+
_context4.next = 9;
|
278
|
+
break;
|
279
|
+
}
|
280
|
+
throw new errors.InvalidParameterError("Bad parameter: id must be of type Int, received ".concat((0, _utils.getType)(params['id'])));
|
281
|
+
case 9:
|
282
|
+
_context4.next = 11;
|
283
|
+
return _Api.default.sendRequest("/snapshots/".concat(encodeURIComponent(params['id'])), 'GET', params, options);
|
284
|
+
case 11:
|
285
|
+
response = _context4.sent;
|
286
|
+
return _context4.abrupt("return", new Snapshot(response === null || response === void 0 ? void 0 : response.data, options));
|
287
|
+
case 13:
|
288
|
+
case "end":
|
289
|
+
return _context4.stop();
|
290
|
+
}
|
291
|
+
}, _callee4);
|
292
|
+
}));
|
293
|
+
return function (_x) {
|
294
|
+
return _ref6.apply(this, arguments);
|
295
|
+
};
|
296
|
+
}());
|
297
|
+
(0, _defineProperty2.default)(Snapshot, "get", function (id) {
|
298
|
+
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
299
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
300
|
+
return Snapshot.find(id, params, options);
|
301
|
+
});
|
302
|
+
(0, _defineProperty2.default)(Snapshot, "create", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
|
303
|
+
var options,
|
304
|
+
response,
|
305
|
+
_args5 = arguments;
|
306
|
+
return _regenerator.default.wrap(function _callee5$(_context5) {
|
307
|
+
while (1) switch (_context5.prev = _context5.next) {
|
308
|
+
case 0:
|
309
|
+
options = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {};
|
310
|
+
_context5.next = 3;
|
311
|
+
return _Api.default.sendRequest("/snapshots", 'POST', {}, options);
|
312
|
+
case 3:
|
313
|
+
response = _context5.sent;
|
314
|
+
return _context5.abrupt("return", new Snapshot(response === null || response === void 0 ? void 0 : response.data, options));
|
315
|
+
case 5:
|
316
|
+
case "end":
|
317
|
+
return _context5.stop();
|
318
|
+
}
|
319
|
+
}, _callee5);
|
320
|
+
})));
|
321
|
+
var _default = Snapshot;
|
322
|
+
exports.default = _default;
|
package/package.json
CHANGED
package/src/models/Bundle.js
CHANGED
@@ -166,6 +166,13 @@ class Bundle {
|
|
166
166
|
this.attributes.send_email_receipt_to_uploader = value
|
167
167
|
}
|
168
168
|
|
169
|
+
// int64 # ID of the snapshot containing this bundle's contents.
|
170
|
+
getSnapshotId = () => this.attributes.snapshot_id
|
171
|
+
|
172
|
+
setSnapshotId = value => {
|
173
|
+
this.attributes.snapshot_id = value
|
174
|
+
}
|
175
|
+
|
169
176
|
// int64 # Bundle creator user ID
|
170
177
|
getUserId = () => this.attributes.user_id
|
171
178
|
|
@@ -236,6 +243,20 @@ class Bundle {
|
|
236
243
|
this.attributes.form_field_set_id = value
|
237
244
|
}
|
238
245
|
|
246
|
+
// boolean # If true, create a snapshot of this bundle's contents.
|
247
|
+
getCreateSnapshot = () => this.attributes.create_snapshot
|
248
|
+
|
249
|
+
setCreateSnapshot = value => {
|
250
|
+
this.attributes.create_snapshot = value
|
251
|
+
}
|
252
|
+
|
253
|
+
// boolean # If true, finalize the snapshot of this bundle's contents. Note that `create_snapshot` must also be true.
|
254
|
+
getFinalizeSnapshot = () => this.attributes.finalize_snapshot
|
255
|
+
|
256
|
+
setFinalizeSnapshot = value => {
|
257
|
+
this.attributes.finalize_snapshot = value
|
258
|
+
}
|
259
|
+
|
239
260
|
// file # Preview watermark image applied to all bundle items.
|
240
261
|
getWatermarkAttachmentFile = () => this.attributes.watermark_attachment_file
|
241
262
|
|
@@ -299,9 +320,11 @@ class Bundle {
|
|
299
320
|
// form_field_set_id - int64 - Id of Form Field Set to use with this bundle
|
300
321
|
// clickwrap_id - int64 - ID of the clickwrap to use with this bundle.
|
301
322
|
// code - string - Bundle code. This code forms the end part of the Public URL.
|
323
|
+
// create_snapshot - boolean - If true, create a snapshot of this bundle's contents.
|
302
324
|
// description - string - Public description
|
303
325
|
// 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.
|
304
326
|
// expires_at - string - Bundle expiration date/time
|
327
|
+
// finalize_snapshot - boolean - If true, finalize the snapshot of this bundle's contents. Note that `create_snapshot` must also be true.
|
305
328
|
// inbox_id - int64 - ID of the associated inbox, if available.
|
306
329
|
// max_uses - int64 - Maximum number of times bundle can be accessed
|
307
330
|
// note - string - Bundle internal note
|
@@ -480,8 +503,10 @@ class Bundle {
|
|
480
503
|
// paths (required) - array(string) - A list of paths to include in this bundle.
|
481
504
|
// password - string - Password for this bundle.
|
482
505
|
// form_field_set_id - int64 - Id of Form Field Set to use with this bundle
|
506
|
+
// create_snapshot - boolean - If true, create a snapshot of this bundle's contents.
|
483
507
|
// 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.
|
484
508
|
// expires_at - string - Bundle expiration date/time
|
509
|
+
// finalize_snapshot - boolean - If true, finalize the snapshot of this bundle's contents. Note that `create_snapshot` must also be true.
|
485
510
|
// max_uses - int64 - Maximum number of times bundle can be accessed
|
486
511
|
// description - string - Public description
|
487
512
|
// note - string - Bundle internal note
|
@@ -0,0 +1,188 @@
|
|
1
|
+
import Api from '../Api'
|
2
|
+
import * as errors from '../Errors'
|
3
|
+
import Logger from '../Logger'
|
4
|
+
import { getType, isArray, isBrowser, isInt, isObject, isString } from '../utils'
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Class Snapshot
|
8
|
+
*/
|
9
|
+
class Snapshot {
|
10
|
+
attributes = {}
|
11
|
+
options = {}
|
12
|
+
|
13
|
+
constructor(attributes = {}, options = {}) {
|
14
|
+
Object.entries(attributes).forEach(([key, value]) => {
|
15
|
+
const normalizedKey = key.replace('?', '')
|
16
|
+
|
17
|
+
this.attributes[normalizedKey] = value
|
18
|
+
|
19
|
+
Object.defineProperty(this, normalizedKey, { value, writable: false })
|
20
|
+
})
|
21
|
+
|
22
|
+
this.options = { ...options }
|
23
|
+
}
|
24
|
+
|
25
|
+
isLoaded = () => !!this.attributes.id
|
26
|
+
// date-time # When the snapshot expires.
|
27
|
+
getExpiresAt = () => this.attributes.expires_at
|
28
|
+
|
29
|
+
setExpiresAt = value => {
|
30
|
+
this.attributes.expires_at = value
|
31
|
+
}
|
32
|
+
|
33
|
+
// date-time # When the snapshot was finalized.
|
34
|
+
getFinalizedAt = () => this.attributes.finalized_at
|
35
|
+
|
36
|
+
setFinalizedAt = value => {
|
37
|
+
this.attributes.finalized_at = value
|
38
|
+
}
|
39
|
+
|
40
|
+
// string # A name for the snapshot.
|
41
|
+
getName = () => this.attributes.name
|
42
|
+
|
43
|
+
setName = value => {
|
44
|
+
this.attributes.name = value
|
45
|
+
}
|
46
|
+
|
47
|
+
// int64 # The user that created this snapshot, if applicable.
|
48
|
+
getUserId = () => this.attributes.user_id
|
49
|
+
|
50
|
+
setUserId = value => {
|
51
|
+
this.attributes.user_id = value
|
52
|
+
}
|
53
|
+
|
54
|
+
// int64 # The bundle using this snapshot, if applicable.
|
55
|
+
getBundleId = () => this.attributes.bundle_id
|
56
|
+
|
57
|
+
setBundleId = value => {
|
58
|
+
this.attributes.bundle_id = value
|
59
|
+
}
|
60
|
+
|
61
|
+
// int64 # Snapshot ID.
|
62
|
+
getId = () => this.attributes.id
|
63
|
+
|
64
|
+
setId = value => {
|
65
|
+
this.attributes.id = value
|
66
|
+
}
|
67
|
+
|
68
|
+
|
69
|
+
update = async (params = {}) => {
|
70
|
+
if (!this.attributes.id) {
|
71
|
+
throw new errors.EmptyPropertyError('Current object has no id')
|
72
|
+
}
|
73
|
+
|
74
|
+
if (!isObject(params)) {
|
75
|
+
throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
|
76
|
+
}
|
77
|
+
|
78
|
+
params.id = this.attributes.id
|
79
|
+
if (params['id'] && !isInt(params['id'])) {
|
80
|
+
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(id)}`)
|
81
|
+
}
|
82
|
+
|
83
|
+
if (!params['id']) {
|
84
|
+
if (this.attributes.id) {
|
85
|
+
params['id'] = this.id
|
86
|
+
} else {
|
87
|
+
throw new errors.MissingParameterError('Parameter missing: id')
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
const response = await Api.sendRequest(`/snapshots/${encodeURIComponent(params['id'])}`, 'PATCH', params, this.options)
|
92
|
+
|
93
|
+
return new Snapshot(response?.data, this.options)
|
94
|
+
}
|
95
|
+
|
96
|
+
delete = async (params = {}) => {
|
97
|
+
if (!this.attributes.id) {
|
98
|
+
throw new errors.EmptyPropertyError('Current object has no id')
|
99
|
+
}
|
100
|
+
|
101
|
+
if (!isObject(params)) {
|
102
|
+
throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
|
103
|
+
}
|
104
|
+
|
105
|
+
params.id = this.attributes.id
|
106
|
+
if (params['id'] && !isInt(params['id'])) {
|
107
|
+
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(id)}`)
|
108
|
+
}
|
109
|
+
|
110
|
+
if (!params['id']) {
|
111
|
+
if (this.attributes.id) {
|
112
|
+
params['id'] = this.id
|
113
|
+
} else {
|
114
|
+
throw new errors.MissingParameterError('Parameter missing: id')
|
115
|
+
}
|
116
|
+
}
|
117
|
+
|
118
|
+
const response = await Api.sendRequest(`/snapshots/${encodeURIComponent(params['id'])}`, 'DELETE', params, this.options)
|
119
|
+
|
120
|
+
return response?.data
|
121
|
+
}
|
122
|
+
|
123
|
+
destroy = (params = {}) =>
|
124
|
+
this.delete(params)
|
125
|
+
|
126
|
+
save = () => {
|
127
|
+
if (this.attributes['id']) {
|
128
|
+
return this.update(this.attributes)
|
129
|
+
} else {
|
130
|
+
const newObject = Snapshot.create(this.attributes, this.options)
|
131
|
+
this.attributes = { ...newObject.attributes }
|
132
|
+
return true
|
133
|
+
}
|
134
|
+
}
|
135
|
+
|
136
|
+
// Parameters:
|
137
|
+
// cursor - string - Used for pagination. When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`. Send one of those cursor value here to resume an existing list from the next available record. Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
|
138
|
+
// per_page - int64 - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
|
139
|
+
static list = async (params = {}, options = {}) => {
|
140
|
+
if (params['cursor'] && !isString(params['cursor'])) {
|
141
|
+
throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params['cursor'])}`)
|
142
|
+
}
|
143
|
+
|
144
|
+
if (params['per_page'] && !isInt(params['per_page'])) {
|
145
|
+
throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params['per_page'])}`)
|
146
|
+
}
|
147
|
+
|
148
|
+
const response = await Api.sendRequest(`/snapshots`, 'GET', params, options)
|
149
|
+
|
150
|
+
return response?.data?.map(obj => new Snapshot(obj, options)) || []
|
151
|
+
}
|
152
|
+
|
153
|
+
static all = (params = {}, options = {}) =>
|
154
|
+
Snapshot.list(params, options)
|
155
|
+
|
156
|
+
// Parameters:
|
157
|
+
// id (required) - int64 - Snapshot ID.
|
158
|
+
static find = async (id, params = {}, options = {}) => {
|
159
|
+
if (!isObject(params)) {
|
160
|
+
throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
|
161
|
+
}
|
162
|
+
|
163
|
+
params['id'] = id
|
164
|
+
|
165
|
+
if (!params['id']) {
|
166
|
+
throw new errors.MissingParameterError('Parameter missing: id')
|
167
|
+
}
|
168
|
+
|
169
|
+
if (params['id'] && !isInt(params['id'])) {
|
170
|
+
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params['id'])}`)
|
171
|
+
}
|
172
|
+
|
173
|
+
const response = await Api.sendRequest(`/snapshots/${encodeURIComponent(params['id'])}`, 'GET', params, options)
|
174
|
+
|
175
|
+
return new Snapshot(response?.data, options)
|
176
|
+
}
|
177
|
+
|
178
|
+
static get = (id, params = {}, options = {}) =>
|
179
|
+
Snapshot.find(id, params, options)
|
180
|
+
|
181
|
+
static create = async (options = {}) => {
|
182
|
+
const response = await Api.sendRequest(`/snapshots`, 'POST', {}, options)
|
183
|
+
|
184
|
+
return new Snapshot(response?.data, options)
|
185
|
+
}
|
186
|
+
}
|
187
|
+
|
188
|
+
export default Snapshot
|