files.com 1.0.160 → 1.0.163

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -136,7 +136,7 @@ You can set the following global properties using static methods on the `Files`
136
136
  #### Getting a file record by path
137
137
 
138
138
  import File from 'files.com/lib/models/File'
139
- const foundFile = await File.find(remoteFilePath)
139
+ const foundFile = await File.findDownload(remoteFilePath)
140
140
 
141
141
  #### Download a file (not available in browser)
142
142
 
package/_VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.160
1
+ 1.0.163
@@ -1166,7 +1166,7 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
1166
1166
  return _ref21.apply(this, arguments);
1167
1167
  };
1168
1168
  }());
1169
- (0, _defineProperty2.default)(File, "find", /*#__PURE__*/function () {
1169
+ (0, _defineProperty2.default)(File, "findDownload", /*#__PURE__*/function () {
1170
1170
  var _ref22 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee20(path) {
1171
1171
  var response;
1172
1172
  return _regenerator.default.wrap(function _callee20$(_context20) {
@@ -101,6 +101,12 @@ var RemoteServer = /*#__PURE__*/(0, _createClass2.default)(function RemoteServer
101
101
  (0, _defineProperty2.default)(this, "setS3Region", function (value) {
102
102
  _this.attributes.s3_region = value;
103
103
  });
104
+ (0, _defineProperty2.default)(this, "getAwsAccessKey", function () {
105
+ return _this.attributes.aws_access_key;
106
+ });
107
+ (0, _defineProperty2.default)(this, "setAwsAccessKey", function (value) {
108
+ _this.attributes.aws_access_key = value;
109
+ });
104
110
  (0, _defineProperty2.default)(this, "getServerCertificate", function () {
105
111
  return _this.attributes.server_certificate;
106
112
  });
@@ -167,6 +173,12 @@ var RemoteServer = /*#__PURE__*/(0, _createClass2.default)(function RemoteServer
167
173
  (0, _defineProperty2.default)(this, "setWasabiRegion", function (value) {
168
174
  _this.attributes.wasabi_region = value;
169
175
  });
176
+ (0, _defineProperty2.default)(this, "getWasabiAccessKey", function () {
177
+ return _this.attributes.wasabi_access_key;
178
+ });
179
+ (0, _defineProperty2.default)(this, "setWasabiAccessKey", function (value) {
180
+ _this.attributes.wasabi_access_key = value;
181
+ });
170
182
  (0, _defineProperty2.default)(this, "getRackspaceUsername", function () {
171
183
  return _this.attributes.rackspace_username;
172
184
  });
@@ -233,18 +245,24 @@ var RemoteServer = /*#__PURE__*/(0, _createClass2.default)(function RemoteServer
233
245
  (0, _defineProperty2.default)(this, "setS3CompatibleEndpoint", function (value) {
234
246
  _this.attributes.s3_compatible_endpoint = value;
235
247
  });
248
+ (0, _defineProperty2.default)(this, "getS3CompatibleRegion", function () {
249
+ return _this.attributes.s3_compatible_region;
250
+ });
251
+ (0, _defineProperty2.default)(this, "setS3CompatibleRegion", function (value) {
252
+ _this.attributes.s3_compatible_region = value;
253
+ });
254
+ (0, _defineProperty2.default)(this, "getS3CompatibleAccessKey", function () {
255
+ return _this.attributes.s3_compatible_access_key;
256
+ });
257
+ (0, _defineProperty2.default)(this, "setS3CompatibleAccessKey", function (value) {
258
+ _this.attributes.s3_compatible_access_key = value;
259
+ });
236
260
  (0, _defineProperty2.default)(this, "getEnableDedicatedIps", function () {
237
261
  return _this.attributes.enable_dedicated_ips;
238
262
  });
239
263
  (0, _defineProperty2.default)(this, "setEnableDedicatedIps", function (value) {
240
264
  _this.attributes.enable_dedicated_ips = value;
241
265
  });
242
- (0, _defineProperty2.default)(this, "getAwsAccessKey", function () {
243
- return _this.attributes.aws_access_key;
244
- });
245
- (0, _defineProperty2.default)(this, "setAwsAccessKey", function (value) {
246
- _this.attributes.aws_access_key = value;
247
- });
248
266
  (0, _defineProperty2.default)(this, "getAwsSecretKey", function () {
249
267
  return _this.attributes.aws_secret_key;
250
268
  });
@@ -275,12 +293,6 @@ var RemoteServer = /*#__PURE__*/(0, _createClass2.default)(function RemoteServer
275
293
  (0, _defineProperty2.default)(this, "setGoogleCloudStorageCredentialsJson", function (value) {
276
294
  _this.attributes.google_cloud_storage_credentials_json = value;
277
295
  });
278
- (0, _defineProperty2.default)(this, "getWasabiAccessKey", function () {
279
- return _this.attributes.wasabi_access_key;
280
- });
281
- (0, _defineProperty2.default)(this, "setWasabiAccessKey", function (value) {
282
- _this.attributes.wasabi_access_key = value;
283
- });
284
296
  (0, _defineProperty2.default)(this, "getWasabiSecretKey", function () {
285
297
  return _this.attributes.wasabi_secret_key;
286
298
  });
@@ -317,12 +329,6 @@ var RemoteServer = /*#__PURE__*/(0, _createClass2.default)(function RemoteServer
317
329
  (0, _defineProperty2.default)(this, "setAzureBlobStorageAccessKey", function (value) {
318
330
  _this.attributes.azure_blob_storage_access_key = value;
319
331
  });
320
- (0, _defineProperty2.default)(this, "getS3CompatibleAccessKey", function () {
321
- return _this.attributes.s3_compatible_access_key;
322
- });
323
- (0, _defineProperty2.default)(this, "setS3CompatibleAccessKey", function (value) {
324
- _this.attributes.s3_compatible_access_key = value;
325
- });
326
332
  (0, _defineProperty2.default)(this, "getS3CompatibleSecretKey", function () {
327
333
  return _this.attributes.s3_compatible_secret_key;
328
334
  });
@@ -660,43 +666,51 @@ var RemoteServer = /*#__PURE__*/(0, _createClass2.default)(function RemoteServer
660
666
  throw new Error("Bad parameter: s3_compatible_endpoint must be of type String, received ".concat((0, _utils.getType)(s3_compatible_endpoint)));
661
667
 
662
668
  case 82:
663
- if (!(params['s3_compatible_access_key'] && !(0, _utils.isString)(params['s3_compatible_access_key']))) {
669
+ if (!(params['s3_compatible_region'] && !(0, _utils.isString)(params['s3_compatible_region']))) {
664
670
  _context.next = 84;
665
671
  break;
666
672
  }
667
673
 
668
- throw new Error("Bad parameter: s3_compatible_access_key must be of type String, received ".concat((0, _utils.getType)(s3_compatible_access_key)));
674
+ throw new Error("Bad parameter: s3_compatible_region must be of type String, received ".concat((0, _utils.getType)(s3_compatible_region)));
669
675
 
670
676
  case 84:
671
- if (!(params['s3_compatible_secret_key'] && !(0, _utils.isString)(params['s3_compatible_secret_key']))) {
677
+ if (!(params['s3_compatible_access_key'] && !(0, _utils.isString)(params['s3_compatible_access_key']))) {
672
678
  _context.next = 86;
673
679
  break;
674
680
  }
675
681
 
676
- throw new Error("Bad parameter: s3_compatible_secret_key must be of type String, received ".concat((0, _utils.getType)(s3_compatible_secret_key)));
682
+ throw new Error("Bad parameter: s3_compatible_access_key must be of type String, received ".concat((0, _utils.getType)(s3_compatible_access_key)));
677
683
 
678
684
  case 86:
685
+ if (!(params['s3_compatible_secret_key'] && !(0, _utils.isString)(params['s3_compatible_secret_key']))) {
686
+ _context.next = 88;
687
+ break;
688
+ }
689
+
690
+ throw new Error("Bad parameter: s3_compatible_secret_key must be of type String, received ".concat((0, _utils.getType)(s3_compatible_secret_key)));
691
+
692
+ case 88:
679
693
  if (params['id']) {
680
- _context.next = 92;
694
+ _context.next = 94;
681
695
  break;
682
696
  }
683
697
 
684
698
  if (!_this.attributes.id) {
685
- _context.next = 91;
699
+ _context.next = 93;
686
700
  break;
687
701
  }
688
702
 
689
703
  params['id'] = _this.id;
690
- _context.next = 92;
704
+ _context.next = 94;
691
705
  break;
692
706
 
693
- case 91:
707
+ case 93:
694
708
  throw new Error('Parameter missing: id');
695
709
 
696
- case 92:
710
+ case 94:
697
711
  return _context.abrupt("return", _Api.default.sendRequest("/remote_servers/".concat(params['id']), 'PATCH', params, _this.options));
698
712
 
699
- case 93:
713
+ case 95:
700
714
  case "end":
701
715
  return _context.stop();
702
716
  }
@@ -1214,30 +1228,38 @@ var RemoteServer = /*#__PURE__*/(0, _createClass2.default)(function RemoteServer
1214
1228
  throw new Error("Bad parameter: s3_compatible_endpoint must be of type String, received ".concat((0, _utils.getType)(s3_compatible_endpoint)));
1215
1229
 
1216
1230
  case 76:
1217
- if (!(params['s3_compatible_access_key'] && !(0, _utils.isString)(params['s3_compatible_access_key']))) {
1231
+ if (!(params['s3_compatible_region'] && !(0, _utils.isString)(params['s3_compatible_region']))) {
1218
1232
  _context5.next = 78;
1219
1233
  break;
1220
1234
  }
1221
1235
 
1222
- throw new Error("Bad parameter: s3_compatible_access_key must be of type String, received ".concat((0, _utils.getType)(s3_compatible_access_key)));
1236
+ throw new Error("Bad parameter: s3_compatible_region must be of type String, received ".concat((0, _utils.getType)(s3_compatible_region)));
1223
1237
 
1224
1238
  case 78:
1225
- if (!(params['s3_compatible_secret_key'] && !(0, _utils.isString)(params['s3_compatible_secret_key']))) {
1239
+ if (!(params['s3_compatible_access_key'] && !(0, _utils.isString)(params['s3_compatible_access_key']))) {
1226
1240
  _context5.next = 80;
1227
1241
  break;
1228
1242
  }
1229
1243
 
1230
- throw new Error("Bad parameter: s3_compatible_secret_key must be of type String, received ".concat((0, _utils.getType)(s3_compatible_secret_key)));
1244
+ throw new Error("Bad parameter: s3_compatible_access_key must be of type String, received ".concat((0, _utils.getType)(s3_compatible_access_key)));
1231
1245
 
1232
1246
  case 80:
1233
- _context5.next = 82;
1234
- return _Api.default.sendRequest("/remote_servers", 'POST', params, options);
1247
+ if (!(params['s3_compatible_secret_key'] && !(0, _utils.isString)(params['s3_compatible_secret_key']))) {
1248
+ _context5.next = 82;
1249
+ break;
1250
+ }
1251
+
1252
+ throw new Error("Bad parameter: s3_compatible_secret_key must be of type String, received ".concat((0, _utils.getType)(s3_compatible_secret_key)));
1235
1253
 
1236
1254
  case 82:
1255
+ _context5.next = 84;
1256
+ return _Api.default.sendRequest("/remote_servers", 'POST', params, options);
1257
+
1258
+ case 84:
1237
1259
  response = _context5.sent;
1238
1260
  return _context5.abrupt("return", new RemoteServer(response === null || response === void 0 ? void 0 : response.data, options));
1239
1261
 
1240
- case 84:
1262
+ case 86:
1241
1263
  case "end":
1242
1264
  return _context5.stop();
1243
1265
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "files.com",
3
- "version": "1.0.160",
3
+ "version": "1.0.163",
4
4
  "description": "Files.com SDK for JavaScript",
5
5
  "keywords": [
6
6
  "files.com",
@@ -178,7 +178,7 @@ class File {
178
178
  return saveUrlToFile(this.download_uri, destinationPath)
179
179
  }
180
180
 
181
- static find = async path => {
181
+ static findDownload = async path => {
182
182
  const response = await Api.sendRequest(`/files/${encodeURIComponent(path)}`, 'GET')
183
183
  return new File(response.data)
184
184
  }
@@ -92,6 +92,13 @@ class RemoteServer {
92
92
  this.attributes.s3_region = value
93
93
  }
94
94
 
95
+ // string # AWS Access Key.
96
+ getAwsAccessKey = () => this.attributes.aws_access_key
97
+
98
+ setAwsAccessKey = value => {
99
+ this.attributes.aws_access_key = value
100
+ }
101
+
95
102
  // string # Remote server certificate
96
103
  getServerCertificate = () => this.attributes.server_certificate
97
104
 
@@ -169,6 +176,13 @@ class RemoteServer {
169
176
  this.attributes.wasabi_region = value
170
177
  }
171
178
 
179
+ // string # Wasabi access key.
180
+ getWasabiAccessKey = () => this.attributes.wasabi_access_key
181
+
182
+ setWasabiAccessKey = value => {
183
+ this.attributes.wasabi_access_key = value
184
+ }
185
+
172
186
  // string # Rackspace username used to login to the Rackspace Cloud Control Panel.
173
187
  getRackspaceUsername = () => this.attributes.rackspace_username
174
188
 
@@ -246,6 +260,20 @@ class RemoteServer {
246
260
  this.attributes.s3_compatible_endpoint = value
247
261
  }
248
262
 
263
+ // string # S3-compatible endpoint
264
+ getS3CompatibleRegion = () => this.attributes.s3_compatible_region
265
+
266
+ setS3CompatibleRegion = value => {
267
+ this.attributes.s3_compatible_region = value
268
+ }
269
+
270
+ // string # S3-compatible Access Key.
271
+ getS3CompatibleAccessKey = () => this.attributes.s3_compatible_access_key
272
+
273
+ setS3CompatibleAccessKey = value => {
274
+ this.attributes.s3_compatible_access_key = value
275
+ }
276
+
249
277
  // boolean # `true` if remote server only accepts connections from dedicated IPs
250
278
  getEnableDedicatedIps = () => this.attributes.enable_dedicated_ips
251
279
 
@@ -253,13 +281,6 @@ class RemoteServer {
253
281
  this.attributes.enable_dedicated_ips = value
254
282
  }
255
283
 
256
- // string # AWS Access Key.
257
- getAwsAccessKey = () => this.attributes.aws_access_key
258
-
259
- setAwsAccessKey = value => {
260
- this.attributes.aws_access_key = value
261
- }
262
-
263
284
  // string # AWS secret key.
264
285
  getAwsSecretKey = () => this.attributes.aws_secret_key
265
286
 
@@ -295,13 +316,6 @@ class RemoteServer {
295
316
  this.attributes.google_cloud_storage_credentials_json = value
296
317
  }
297
318
 
298
- // string # Wasabi access key.
299
- getWasabiAccessKey = () => this.attributes.wasabi_access_key
300
-
301
- setWasabiAccessKey = value => {
302
- this.attributes.wasabi_access_key = value
303
- }
304
-
305
319
  // string # Wasabi secret key.
306
320
  getWasabiSecretKey = () => this.attributes.wasabi_secret_key
307
321
 
@@ -344,13 +358,6 @@ class RemoteServer {
344
358
  this.attributes.azure_blob_storage_access_key = value
345
359
  }
346
360
 
347
- // string # S3-compatible access key
348
- getS3CompatibleAccessKey = () => this.attributes.s3_compatible_access_key
349
-
350
- setS3CompatibleAccessKey = value => {
351
- this.attributes.s3_compatible_access_key = value
352
- }
353
-
354
361
  // string # S3-compatible secret key
355
362
  getS3CompatibleSecretKey = () => this.attributes.s3_compatible_secret_key
356
363
 
@@ -398,8 +405,9 @@ class RemoteServer {
398
405
  // azure_blob_storage_container - string - Azure Blob Storage Container name
399
406
  // s3_compatible_bucket - string - S3-compatible Bucket name
400
407
  // s3_compatible_endpoint - string - S3-compatible endpoint
408
+ // s3_compatible_region - string - S3-compatible endpoint
401
409
  // enable_dedicated_ips - boolean - `true` if remote server only accepts connections from dedicated IPs
402
- // s3_compatible_access_key - string - S3-compatible access key
410
+ // s3_compatible_access_key - string - S3-compatible Access Key.
403
411
  // s3_compatible_secret_key - string - S3-compatible secret key
404
412
  update = async (params = {}) => {
405
413
  if (!this.attributes.id) {
@@ -525,6 +533,9 @@ class RemoteServer {
525
533
  if (params['s3_compatible_endpoint'] && !isString(params['s3_compatible_endpoint'])) {
526
534
  throw new Error(`Bad parameter: s3_compatible_endpoint must be of type String, received ${getType(s3_compatible_endpoint)}`)
527
535
  }
536
+ if (params['s3_compatible_region'] && !isString(params['s3_compatible_region'])) {
537
+ throw new Error(`Bad parameter: s3_compatible_region must be of type String, received ${getType(s3_compatible_region)}`)
538
+ }
528
539
  if (params['s3_compatible_access_key'] && !isString(params['s3_compatible_access_key'])) {
529
540
  throw new Error(`Bad parameter: s3_compatible_access_key must be of type String, received ${getType(s3_compatible_access_key)}`)
530
541
  }
@@ -665,8 +676,9 @@ class RemoteServer {
665
676
  // azure_blob_storage_container - string - Azure Blob Storage Container name
666
677
  // s3_compatible_bucket - string - S3-compatible Bucket name
667
678
  // s3_compatible_endpoint - string - S3-compatible endpoint
679
+ // s3_compatible_region - string - S3-compatible endpoint
668
680
  // enable_dedicated_ips - boolean - `true` if remote server only accepts connections from dedicated IPs
669
- // s3_compatible_access_key - string - S3-compatible access key
681
+ // s3_compatible_access_key - string - S3-compatible Access Key.
670
682
  // s3_compatible_secret_key - string - S3-compatible secret key
671
683
  static create = async (params = {}, options = {}) => {
672
684
  if (params['aws_access_key'] && !isString(params['aws_access_key'])) {
@@ -817,6 +829,10 @@ class RemoteServer {
817
829
  throw new Error(`Bad parameter: s3_compatible_endpoint must be of type String, received ${getType(s3_compatible_endpoint)}`)
818
830
  }
819
831
 
832
+ if (params['s3_compatible_region'] && !isString(params['s3_compatible_region'])) {
833
+ throw new Error(`Bad parameter: s3_compatible_region must be of type String, received ${getType(s3_compatible_region)}`)
834
+ }
835
+
820
836
  if (params['s3_compatible_access_key'] && !isString(params['s3_compatible_access_key'])) {
821
837
  throw new Error(`Bad parameter: s3_compatible_access_key must be of type String, received ${getType(s3_compatible_access_key)}`)
822
838
  }
package/test/src/index.js CHANGED
@@ -40,12 +40,16 @@ const testSuite = async () => {
40
40
  const nonce = new Date().getTime()
41
41
 
42
42
  const testFolderListAutoPagination = async () => {
43
- Files.setAutoPaginate(false)
43
+ Files.configureNetwork({
44
+ autoPaginate: false,
45
+ })
44
46
  const firstPageItems = await Folder.listFor('/', { per_page: 1 })
45
- assert(firstPageItems.length === 1)
46
47
 
47
- Files.setAutoPaginate(true)
48
+ assert(firstPageItems.length === 1)
48
49
 
50
+ Files.configureNetwork({
51
+ autoPaginate: true,
52
+ })
49
53
  // note: this test will fail if the root folder has <= 1 file or folder
50
54
  const allPageItems = await Folder.listFor('/', { per_page: 1 })
51
55
 
@@ -66,7 +70,7 @@ const testSuite = async () => {
66
70
  assert(!!file.path)
67
71
  assert(file.display_name === displayName)
68
72
 
69
- const foundFile = await File.find(destinationPath)
73
+ const foundFile = await File.findDownload(destinationPath)
70
74
 
71
75
  assert(foundFile.path === destinationPath)
72
76
  assert(foundFile.display_name === displayName)