files.com 1.1.19 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. package/.eslintrc.js +0 -3
  2. package/_VERSION +1 -1
  3. package/lib/Api.js +1 -1
  4. package/lib/Errors.js +354 -512
  5. package/lib/Files.js +1 -1
  6. package/lib/models/ActionNotificationExport.js +25 -25
  7. package/lib/models/ActionNotificationExportResult.js +10 -10
  8. package/lib/models/ActionWebhookFailure.js +5 -9
  9. package/lib/models/ApiKey.js +62 -70
  10. package/lib/models/App.js +5 -5
  11. package/lib/models/As2IncomingMessage.js +7 -7
  12. package/lib/models/As2OutgoingMessage.js +7 -7
  13. package/lib/models/As2Partner.js +54 -58
  14. package/lib/models/As2Station.js +51 -55
  15. package/lib/models/Automation.js +102 -110
  16. package/lib/models/AutomationRun.js +13 -13
  17. package/lib/models/BandwidthSnapshot.js +5 -5
  18. package/lib/models/Behavior.js +77 -85
  19. package/lib/models/Bundle.js +102 -110
  20. package/lib/models/BundleDownload.js +9 -9
  21. package/lib/models/BundleNotification.js +37 -41
  22. package/lib/models/BundleRecipient.js +22 -22
  23. package/lib/models/BundleRegistration.js +7 -7
  24. package/lib/models/Clickwrap.js +52 -56
  25. package/lib/models/DnsRecord.js +5 -5
  26. package/lib/models/EmailIncomingMessage.js +5 -5
  27. package/lib/models/ExternalEvent.js +18 -18
  28. package/lib/models/File.js +89 -93
  29. package/lib/models/FileComment.js +41 -45
  30. package/lib/models/FileCommentReaction.js +15 -19
  31. package/lib/models/FileMigration.js +5 -5
  32. package/lib/models/Folder.js +24 -24
  33. package/lib/models/FormFieldSet.js +44 -48
  34. package/lib/models/GpgKey.js +53 -57
  35. package/lib/models/Group.js +51 -55
  36. package/lib/models/GroupUser.js +53 -57
  37. package/lib/models/History.js +72 -72
  38. package/lib/models/HistoryExport.js +51 -51
  39. package/lib/models/HistoryExportResult.js +10 -10
  40. package/lib/models/InboxRecipient.js +22 -22
  41. package/lib/models/InboxRegistration.js +7 -7
  42. package/lib/models/InboxUpload.js +9 -9
  43. package/lib/models/Invoice.js +12 -12
  44. package/lib/models/IpAddress.js +17 -17
  45. package/lib/models/Lock.js +27 -31
  46. package/lib/models/Message.js +60 -64
  47. package/lib/models/MessageComment.js +46 -50
  48. package/lib/models/MessageCommentReaction.js +27 -31
  49. package/lib/models/MessageReaction.js +27 -31
  50. package/lib/models/Notification.js +66 -70
  51. package/lib/models/Payment.js +12 -12
  52. package/lib/models/Permission.js +28 -32
  53. package/lib/models/Priority.js +9 -9
  54. package/lib/models/Project.js +39 -43
  55. package/lib/models/PublicKey.js +46 -50
  56. package/lib/models/RemoteBandwidthSnapshot.js +5 -5
  57. package/lib/models/RemoteServer.js +306 -310
  58. package/lib/models/Request.js +33 -37
  59. package/lib/models/Session.js +11 -15
  60. package/lib/models/SettingsChange.js +5 -5
  61. package/lib/models/SftpHostKey.js +40 -44
  62. package/lib/models/ShareGroup.js +50 -54
  63. package/lib/models/Site.js +138 -138
  64. package/lib/models/Snapshot.js +44 -48
  65. package/lib/models/SsoStrategy.js +15 -19
  66. package/lib/models/Style.js +17 -21
  67. package/lib/models/UsageDailySnapshot.js +5 -5
  68. package/lib/models/UsageSnapshot.js +5 -5
  69. package/lib/models/User.js +156 -172
  70. package/lib/models/UserCipherUse.js +7 -7
  71. package/lib/models/UserRequest.js +26 -30
  72. package/lib/models/WebhookTest.js +15 -15
  73. package/package.json +6 -2
  74. package/src/Api.js +2 -1
  75. package/src/Errors.js +189 -178
  76. package/src/Files.js +1 -1
  77. package/src/models/AccountLineItem.js +5 -2
  78. package/src/models/Action.js +5 -2
  79. package/src/models/ActionNotificationExport.js +36 -35
  80. package/src/models/ActionNotificationExportResult.js +15 -13
  81. package/src/models/ActionWebhookFailure.js +9 -8
  82. package/src/models/ApiKey.js +69 -72
  83. package/src/models/App.js +10 -8
  84. package/src/models/As2IncomingMessage.js +12 -10
  85. package/src/models/As2OutgoingMessage.js +12 -10
  86. package/src/models/As2Partner.js +61 -60
  87. package/src/models/As2Station.js +58 -57
  88. package/src/models/Auto.js +5 -2
  89. package/src/models/Automation.js +121 -110
  90. package/src/models/AutomationRun.js +18 -17
  91. package/src/models/BandwidthSnapshot.js +10 -8
  92. package/src/models/Behavior.js +85 -86
  93. package/src/models/Bundle.js +121 -110
  94. package/src/models/BundleDownload.js +14 -12
  95. package/src/models/BundleNotification.js +40 -43
  96. package/src/models/BundleRecipient.js +33 -32
  97. package/src/models/BundleRegistration.js +12 -10
  98. package/src/models/Clickwrap.js +60 -58
  99. package/src/models/DnsRecord.js +10 -8
  100. package/src/models/EmailIncomingMessage.js +10 -8
  101. package/src/models/Errors.js +5 -2
  102. package/src/models/ExternalEvent.js +29 -29
  103. package/src/models/File.js +116 -108
  104. package/src/models/FileAction.js +5 -2
  105. package/src/models/FileComment.js +45 -46
  106. package/src/models/FileCommentReaction.js +26 -26
  107. package/src/models/FileMigration.js +10 -8
  108. package/src/models/FileUploadPart.js +5 -2
  109. package/src/models/Folder.js +32 -29
  110. package/src/models/FormField.js +5 -2
  111. package/src/models/FormFieldSet.js +49 -50
  112. package/src/models/GpgKey.js +60 -59
  113. package/src/models/Group.js +58 -57
  114. package/src/models/GroupUser.js +60 -58
  115. package/src/models/History.js +77 -74
  116. package/src/models/HistoryExport.js +62 -61
  117. package/src/models/HistoryExportResult.js +15 -13
  118. package/src/models/Image.js +5 -2
  119. package/src/models/InboxRecipient.js +33 -32
  120. package/src/models/InboxRegistration.js +12 -10
  121. package/src/models/InboxUpload.js +14 -12
  122. package/src/models/Invoice.js +17 -14
  123. package/src/models/InvoiceLineItem.js +5 -2
  124. package/src/models/IpAddress.js +22 -20
  125. package/src/models/Lock.js +36 -36
  126. package/src/models/Message.js +66 -66
  127. package/src/models/MessageComment.js +50 -52
  128. package/src/models/MessageCommentReaction.js +38 -40
  129. package/src/models/MessageReaction.js +38 -40
  130. package/src/models/Notification.js +74 -72
  131. package/src/models/Payment.js +17 -14
  132. package/src/models/PaymentLineItem.js +5 -2
  133. package/src/models/Permission.js +39 -40
  134. package/src/models/Preview.js +5 -2
  135. package/src/models/Priority.js +14 -12
  136. package/src/models/Project.js +43 -45
  137. package/src/models/PublicIpAddress.js +5 -2
  138. package/src/models/PublicKey.js +50 -52
  139. package/src/models/RemoteBandwidthSnapshot.js +10 -8
  140. package/src/models/RemoteServer.js +380 -312
  141. package/src/models/RemoteServerConfigurationFile.js +5 -2
  142. package/src/models/Request.js +44 -46
  143. package/src/models/Session.js +22 -22
  144. package/src/models/SettingsChange.js +10 -8
  145. package/src/models/SftpHostKey.js +45 -46
  146. package/src/models/ShareGroup.js +56 -56
  147. package/src/models/ShareGroupMember.js +5 -2
  148. package/src/models/Site.js +143 -142
  149. package/src/models/Snapshot.js +50 -50
  150. package/src/models/SsoStrategy.js +20 -21
  151. package/src/models/Status.js +5 -2
  152. package/src/models/Style.js +22 -23
  153. package/src/models/UsageDailySnapshot.js +10 -8
  154. package/src/models/UsageSnapshot.js +10 -8
  155. package/src/models/User.js +185 -168
  156. package/src/models/UserCipherUse.js +12 -10
  157. package/src/models/UserRequest.js +37 -39
  158. package/src/models/WebhookTest.js +26 -24
  159. package/test/Api.test.js +163 -0
  160. package/test/{package.json → integration/package.json} +1 -1
  161. package/test/{src → integration/src}/index.js +1 -1
  162. package/test.sh +2 -1
  163. /package/test/{.babelrc → integration/.babelrc} +0 -0
  164. /package/test/{index.js → integration/index.js} +0 -0
@@ -4,7 +4,9 @@ import { Buffer } from 'safe-buffer'
4
4
  /* eslint-disable no-unused-vars */
5
5
  import Api from '../Api'
6
6
  import * as errors from '../Errors'
7
- import { isBrowser, getType, isArray, isInt, isObject, isString } from '../utils'
7
+ import {
8
+ isBrowser, getType, isArray, isInt, isObject, isString,
9
+ } from '../utils'
8
10
  /* eslint-enable no-unused-vars */
9
11
 
10
12
  /**
@@ -12,6 +14,7 @@ import { isBrowser, getType, isArray, isInt, isObject, isString } from '../utils
12
14
  */
13
15
  class File {
14
16
  attributes = {}
17
+
15
18
  options = {}
16
19
 
17
20
  constructor(attributes = {}, options = {}) {
@@ -27,6 +30,7 @@ class File {
27
30
  }
28
31
 
29
32
  isLoaded = () => !!this.attributes.path
33
+
30
34
  static _openUpload = async (path, paramsRaw, options) => {
31
35
  const params = { ...paramsRaw, action: 'put' }
32
36
  const response = await Api.sendRequest(`/files/${encodeURIComponent(path)}`, 'POST', params, options)
@@ -105,25 +109,25 @@ class File {
105
109
  if (chunkBuffer !== null || !streamEnded) {
106
110
  return
107
111
  }
108
-
112
+
109
113
  try {
110
114
  if (chunks.length > 0) {
111
115
  const buffer = Buffer.concat(chunks)
112
116
  const nextFileUploadPart = await File._continueUpload(destinationPath, ++part, firstFileUploadPart, options)
113
-
117
+
114
118
  const uploadUri = determinePartUploadUri(nextFileUploadPart)
115
-
119
+
116
120
  // instantiate an httpsAgent dynamically if needed
117
121
  const agent = options.getAgentForUrl?.(uploadUri) || options?.agent
118
-
122
+
119
123
  concurrentUploads.push(Api.sendFilePart(uploadUri, 'PUT', buffer, { agent }))
120
124
  }
121
-
125
+
122
126
  await Promise.all(concurrentUploads)
123
-
127
+
124
128
  const response = await File._completeUpload(firstFileUploadPart, options)
125
129
  const createdFile = new File(response.data, options)
126
-
130
+
127
131
  resolve(createdFile)
128
132
  } catch (error) {
129
133
  reject(error)
@@ -212,7 +216,7 @@ class File {
212
216
  // note that this event may occur while there is still data being processed above
213
217
  readableStream.on('end', () => {
214
218
  streamEnded = true
215
-
219
+
216
220
  handleStreamEnd()
217
221
  })
218
222
  })
@@ -490,7 +494,6 @@ class File {
490
494
  this.attributes.with_rename = value
491
495
  }
492
496
 
493
-
494
497
  // Download file
495
498
  //
496
499
  // Parameters:
@@ -508,27 +511,28 @@ class File {
508
511
  }
509
512
 
510
513
  params.path = this.attributes.path
511
- if (params['path'] && !isString(params['path'])) {
512
- throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params['path'])}`)
514
+ if (params.path && !isString(params.path)) {
515
+ throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params.path)}`)
513
516
  }
514
- if (params['action'] && !isString(params['action'])) {
515
- throw new errors.InvalidParameterError(`Bad parameter: action must be of type String, received ${getType(params['action'])}`)
517
+
518
+ if (params.action && !isString(params.action)) {
519
+ throw new errors.InvalidParameterError(`Bad parameter: action must be of type String, received ${getType(params.action)}`)
516
520
  }
517
- if (params['preview_size'] && !isString(params['preview_size'])) {
518
- throw new errors.InvalidParameterError(`Bad parameter: preview_size must be of type String, received ${getType(params['preview_size'])}`)
521
+
522
+ if (params.preview_size && !isString(params.preview_size)) {
523
+ throw new errors.InvalidParameterError(`Bad parameter: preview_size must be of type String, received ${getType(params.preview_size)}`)
519
524
  }
520
525
 
521
- if (!params['path']) {
526
+ if (!params.path) {
522
527
  if (this.attributes.path) {
523
- params['path'] = this.path
528
+ params.path = this.path
524
529
  } else {
525
530
  throw new errors.MissingParameterError('Parameter missing: path')
526
531
  }
527
532
  }
528
533
 
529
- const response = await Api.sendRequest(`/files/${encodeURIComponent(params['path'])}`, 'GET', params, this.options)
534
+ const response = await Api.sendRequest(`/files/${encodeURIComponent(params.path)}`, 'GET', params, this.options)
530
535
 
531
-
532
536
  return new File(response?.data, this.options)
533
537
  }
534
538
 
@@ -545,27 +549,28 @@ class File {
545
549
  }
546
550
 
547
551
  params.path = this.attributes.path
548
- if (params['path'] && !isString(params['path'])) {
549
- throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params['path'])}`)
552
+ if (params.path && !isString(params.path)) {
553
+ throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params.path)}`)
550
554
  }
551
- if (params['provided_mtime'] && !isString(params['provided_mtime'])) {
552
- throw new errors.InvalidParameterError(`Bad parameter: provided_mtime must be of type String, received ${getType(params['provided_mtime'])}`)
555
+
556
+ if (params.provided_mtime && !isString(params.provided_mtime)) {
557
+ throw new errors.InvalidParameterError(`Bad parameter: provided_mtime must be of type String, received ${getType(params.provided_mtime)}`)
553
558
  }
554
- if (params['priority_color'] && !isString(params['priority_color'])) {
555
- throw new errors.InvalidParameterError(`Bad parameter: priority_color must be of type String, received ${getType(params['priority_color'])}`)
559
+
560
+ if (params.priority_color && !isString(params.priority_color)) {
561
+ throw new errors.InvalidParameterError(`Bad parameter: priority_color must be of type String, received ${getType(params.priority_color)}`)
556
562
  }
557
563
 
558
- if (!params['path']) {
564
+ if (!params.path) {
559
565
  if (this.attributes.path) {
560
- params['path'] = this.path
566
+ params.path = this.path
561
567
  } else {
562
568
  throw new errors.MissingParameterError('Parameter missing: path')
563
569
  }
564
570
  }
565
571
 
566
- const response = await Api.sendRequest(`/files/${encodeURIComponent(params['path'])}`, 'PATCH', params, this.options)
572
+ const response = await Api.sendRequest(`/files/${encodeURIComponent(params.path)}`, 'PATCH', params, this.options)
567
573
 
568
-
569
574
  return new File(response?.data, this.options)
570
575
  }
571
576
 
@@ -581,21 +586,19 @@ class File {
581
586
  }
582
587
 
583
588
  params.path = this.attributes.path
584
- if (params['path'] && !isString(params['path'])) {
585
- throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params['path'])}`)
589
+ if (params.path && !isString(params.path)) {
590
+ throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params.path)}`)
586
591
  }
587
592
 
588
- if (!params['path']) {
593
+ if (!params.path) {
589
594
  if (this.attributes.path) {
590
- params['path'] = this.path
595
+ params.path = this.path
591
596
  } else {
592
597
  throw new errors.MissingParameterError('Parameter missing: path')
593
598
  }
594
599
  }
595
600
 
596
- const response = await Api.sendRequest(`/files/${encodeURIComponent(params['path'])}`, 'DELETE', params, this.options)
597
-
598
- return
601
+ await Api.sendRequest(`/files/${encodeURIComponent(params.path)}`, 'DELETE', params, this.options)
599
602
  }
600
603
 
601
604
  destroy = (params = {}) =>
@@ -616,32 +619,33 @@ class File {
616
619
  }
617
620
 
618
621
  params.path = this.attributes.path
619
- if (params['path'] && !isString(params['path'])) {
620
- throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params['path'])}`)
622
+ if (params.path && !isString(params.path)) {
623
+ throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params.path)}`)
621
624
  }
622
- if (params['destination'] && !isString(params['destination'])) {
623
- throw new errors.InvalidParameterError(`Bad parameter: destination must be of type String, received ${getType(params['destination'])}`)
625
+
626
+ if (params.destination && !isString(params.destination)) {
627
+ throw new errors.InvalidParameterError(`Bad parameter: destination must be of type String, received ${getType(params.destination)}`)
624
628
  }
625
629
 
626
- if (!params['path']) {
630
+ if (!params.path) {
627
631
  if (this.attributes.path) {
628
- params['path'] = this.path
632
+ params.path = this.path
629
633
  } else {
630
634
  throw new errors.MissingParameterError('Parameter missing: path')
631
635
  }
632
636
  }
633
637
 
634
- if (!params['destination']) {
638
+ if (!params.destination) {
635
639
  if (this.attributes.destination) {
636
- params['destination'] = this.destination
640
+ params.destination = this.destination
637
641
  } else {
638
642
  throw new errors.MissingParameterError('Parameter missing: destination')
639
643
  }
640
644
  }
641
645
 
642
- const response = await Api.sendRequest(`/file_actions/copy/${encodeURIComponent(params['path'])}`, 'POST', params, this.options)
646
+ const response = await Api.sendRequest(`/file_actions/copy/${encodeURIComponent(params.path)}`, 'POST', params, this.options)
643
647
 
644
- const FileAction = require("./FileAction.js").default
648
+ const FileAction = require('./FileAction.js').default
645
649
  return new FileAction(response?.data, this.options)
646
650
  }
647
651
 
@@ -659,32 +663,33 @@ class File {
659
663
  }
660
664
 
661
665
  params.path = this.attributes.path
662
- if (params['path'] && !isString(params['path'])) {
663
- throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params['path'])}`)
666
+ if (params.path && !isString(params.path)) {
667
+ throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params.path)}`)
664
668
  }
665
- if (params['destination'] && !isString(params['destination'])) {
666
- throw new errors.InvalidParameterError(`Bad parameter: destination must be of type String, received ${getType(params['destination'])}`)
669
+
670
+ if (params.destination && !isString(params.destination)) {
671
+ throw new errors.InvalidParameterError(`Bad parameter: destination must be of type String, received ${getType(params.destination)}`)
667
672
  }
668
673
 
669
- if (!params['path']) {
674
+ if (!params.path) {
670
675
  if (this.attributes.path) {
671
- params['path'] = this.path
676
+ params.path = this.path
672
677
  } else {
673
678
  throw new errors.MissingParameterError('Parameter missing: path')
674
679
  }
675
680
  }
676
681
 
677
- if (!params['destination']) {
682
+ if (!params.destination) {
678
683
  if (this.attributes.destination) {
679
- params['destination'] = this.destination
684
+ params.destination = this.destination
680
685
  } else {
681
686
  throw new errors.MissingParameterError('Parameter missing: destination')
682
687
  }
683
688
  }
684
689
 
685
- const response = await Api.sendRequest(`/file_actions/move/${encodeURIComponent(params['path'])}`, 'POST', params, this.options)
690
+ const response = await Api.sendRequest(`/file_actions/move/${encodeURIComponent(params.path)}`, 'POST', params, this.options)
686
691
 
687
- const FileAction = require("./FileAction.js").default
692
+ const FileAction = require('./FileAction.js').default
688
693
  return new FileAction(response?.data, this.options)
689
694
  }
690
695
 
@@ -708,43 +713,48 @@ class File {
708
713
  }
709
714
 
710
715
  params.path = this.attributes.path
711
- if (params['path'] && !isString(params['path'])) {
712
- throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params['path'])}`)
716
+ if (params.path && !isString(params.path)) {
717
+ throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params.path)}`)
713
718
  }
714
- if (params['part'] && !isInt(params['part'])) {
715
- throw new errors.InvalidParameterError(`Bad parameter: part must be of type Int, received ${getType(params['part'])}`)
719
+
720
+ if (params.part && !isInt(params.part)) {
721
+ throw new errors.InvalidParameterError(`Bad parameter: part must be of type Int, received ${getType(params.part)}`)
716
722
  }
717
- if (params['parts'] && !isInt(params['parts'])) {
718
- throw new errors.InvalidParameterError(`Bad parameter: parts must be of type Int, received ${getType(params['parts'])}`)
723
+
724
+ if (params.parts && !isInt(params.parts)) {
725
+ throw new errors.InvalidParameterError(`Bad parameter: parts must be of type Int, received ${getType(params.parts)}`)
719
726
  }
720
- if (params['ref'] && !isString(params['ref'])) {
721
- throw new errors.InvalidParameterError(`Bad parameter: ref must be of type String, received ${getType(params['ref'])}`)
727
+
728
+ if (params.ref && !isString(params.ref)) {
729
+ throw new errors.InvalidParameterError(`Bad parameter: ref must be of type String, received ${getType(params.ref)}`)
722
730
  }
723
- if (params['restart'] && !isInt(params['restart'])) {
724
- throw new errors.InvalidParameterError(`Bad parameter: restart must be of type Int, received ${getType(params['restart'])}`)
731
+
732
+ if (params.restart && !isInt(params.restart)) {
733
+ throw new errors.InvalidParameterError(`Bad parameter: restart must be of type Int, received ${getType(params.restart)}`)
725
734
  }
726
- if (params['size'] && !isInt(params['size'])) {
727
- throw new errors.InvalidParameterError(`Bad parameter: size must be of type Int, received ${getType(params['size'])}`)
735
+
736
+ if (params.size && !isInt(params.size)) {
737
+ throw new errors.InvalidParameterError(`Bad parameter: size must be of type Int, received ${getType(params.size)}`)
728
738
  }
729
739
 
730
- if (!params['path']) {
740
+ if (!params.path) {
731
741
  if (this.attributes.path) {
732
- params['path'] = this.path
742
+ params.path = this.path
733
743
  } else {
734
744
  throw new errors.MissingParameterError('Parameter missing: path')
735
745
  }
736
746
  }
737
747
 
738
- const response = await Api.sendRequest(`/file_actions/begin_upload/${encodeURIComponent(params['path'])}`, 'POST', params, this.options)
748
+ const response = await Api.sendRequest(`/file_actions/begin_upload/${encodeURIComponent(params.path)}`, 'POST', params, this.options)
739
749
 
740
- const FileUploadPart = require("./FileUploadPart.js").default
750
+ const FileUploadPart = require('./FileUploadPart.js').default
741
751
  return response?.data?.map(obj => new FileUploadPart(obj, this.options)) || []
742
752
  }
743
753
 
744
754
  save = async () => {
745
- const newObject = await File.create(this.attributes.path, this.attributes, this.options)
746
- this.attributes = { ...newObject.attributes }
747
- return true
755
+ const newObject = await File.create(this.attributes.path, this.attributes, this.options)
756
+ this.attributes = { ...newObject.attributes }
757
+ return true
748
758
  }
749
759
 
750
760
  // Parameters:
@@ -767,55 +777,54 @@ class File {
767
777
  throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
768
778
  }
769
779
 
770
- params['path'] = path
780
+ params.path = path
771
781
 
772
- if (!params['path']) {
782
+ if (!params.path) {
773
783
  throw new errors.MissingParameterError('Parameter missing: path')
774
784
  }
775
785
 
776
- if (params['path'] && !isString(params['path'])) {
777
- throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params['path'])}`)
786
+ if (params.path && !isString(params.path)) {
787
+ throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params.path)}`)
778
788
  }
779
789
 
780
- if (params['action'] && !isString(params['action'])) {
781
- throw new errors.InvalidParameterError(`Bad parameter: action must be of type String, received ${getType(params['action'])}`)
790
+ if (params.action && !isString(params.action)) {
791
+ throw new errors.InvalidParameterError(`Bad parameter: action must be of type String, received ${getType(params.action)}`)
782
792
  }
783
793
 
784
- if (params['length'] && !isInt(params['length'])) {
785
- throw new errors.InvalidParameterError(`Bad parameter: length must be of type Int, received ${getType(params['length'])}`)
794
+ if (params.length && !isInt(params.length)) {
795
+ throw new errors.InvalidParameterError(`Bad parameter: length must be of type Int, received ${getType(params.length)}`)
786
796
  }
787
797
 
788
- if (params['part'] && !isInt(params['part'])) {
789
- throw new errors.InvalidParameterError(`Bad parameter: part must be of type Int, received ${getType(params['part'])}`)
798
+ if (params.part && !isInt(params.part)) {
799
+ throw new errors.InvalidParameterError(`Bad parameter: part must be of type Int, received ${getType(params.part)}`)
790
800
  }
791
801
 
792
- if (params['parts'] && !isInt(params['parts'])) {
793
- throw new errors.InvalidParameterError(`Bad parameter: parts must be of type Int, received ${getType(params['parts'])}`)
802
+ if (params.parts && !isInt(params.parts)) {
803
+ throw new errors.InvalidParameterError(`Bad parameter: parts must be of type Int, received ${getType(params.parts)}`)
794
804
  }
795
805
 
796
- if (params['provided_mtime'] && !isString(params['provided_mtime'])) {
797
- throw new errors.InvalidParameterError(`Bad parameter: provided_mtime must be of type String, received ${getType(params['provided_mtime'])}`)
806
+ if (params.provided_mtime && !isString(params.provided_mtime)) {
807
+ throw new errors.InvalidParameterError(`Bad parameter: provided_mtime must be of type String, received ${getType(params.provided_mtime)}`)
798
808
  }
799
809
 
800
- if (params['ref'] && !isString(params['ref'])) {
801
- throw new errors.InvalidParameterError(`Bad parameter: ref must be of type String, received ${getType(params['ref'])}`)
810
+ if (params.ref && !isString(params.ref)) {
811
+ throw new errors.InvalidParameterError(`Bad parameter: ref must be of type String, received ${getType(params.ref)}`)
802
812
  }
803
813
 
804
- if (params['restart'] && !isInt(params['restart'])) {
805
- throw new errors.InvalidParameterError(`Bad parameter: restart must be of type Int, received ${getType(params['restart'])}`)
814
+ if (params.restart && !isInt(params.restart)) {
815
+ throw new errors.InvalidParameterError(`Bad parameter: restart must be of type Int, received ${getType(params.restart)}`)
806
816
  }
807
817
 
808
- if (params['size'] && !isInt(params['size'])) {
809
- throw new errors.InvalidParameterError(`Bad parameter: size must be of type Int, received ${getType(params['size'])}`)
818
+ if (params.size && !isInt(params.size)) {
819
+ throw new errors.InvalidParameterError(`Bad parameter: size must be of type Int, received ${getType(params.size)}`)
810
820
  }
811
821
 
812
- if (params['structure'] && !isString(params['structure'])) {
813
- throw new errors.InvalidParameterError(`Bad parameter: structure must be of type String, received ${getType(params['structure'])}`)
822
+ if (params.structure && !isString(params.structure)) {
823
+ throw new errors.InvalidParameterError(`Bad parameter: structure must be of type String, received ${getType(params.structure)}`)
814
824
  }
815
825
 
816
- const response = await Api.sendRequest(`/files/${encodeURIComponent(params['path'])}`, 'POST', params, options)
826
+ const response = await Api.sendRequest(`/files/${encodeURIComponent(params.path)}`, 'POST', params, options)
817
827
 
818
-
819
828
  return new File(response?.data, options)
820
829
  }
821
830
 
@@ -829,23 +838,22 @@ class File {
829
838
  throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
830
839
  }
831
840
 
832
- params['path'] = path
841
+ params.path = path
833
842
 
834
- if (!params['path']) {
843
+ if (!params.path) {
835
844
  throw new errors.MissingParameterError('Parameter missing: path')
836
845
  }
837
846
 
838
- if (params['path'] && !isString(params['path'])) {
839
- throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params['path'])}`)
847
+ if (params.path && !isString(params.path)) {
848
+ throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params.path)}`)
840
849
  }
841
850
 
842
- if (params['preview_size'] && !isString(params['preview_size'])) {
843
- throw new errors.InvalidParameterError(`Bad parameter: preview_size must be of type String, received ${getType(params['preview_size'])}`)
851
+ if (params.preview_size && !isString(params.preview_size)) {
852
+ throw new errors.InvalidParameterError(`Bad parameter: preview_size must be of type String, received ${getType(params.preview_size)}`)
844
853
  }
845
854
 
846
- const response = await Api.sendRequest(`/file_actions/metadata/${encodeURIComponent(params['path'])}`, 'GET', params, options)
855
+ const response = await Api.sendRequest(`/file_actions/metadata/${encodeURIComponent(params.path)}`, 'GET', params, options)
847
856
 
848
-
849
857
  return new File(response?.data, options)
850
858
  }
851
859
 
@@ -1,7 +1,9 @@
1
1
  /* eslint-disable no-unused-vars */
2
2
  import Api from '../Api'
3
3
  import * as errors from '../Errors'
4
- import { getType, isArray, isInt, isObject, isString } from '../utils'
4
+ import {
5
+ getType, isArray, isInt, isObject, isString,
6
+ } from '../utils'
5
7
  /* eslint-enable no-unused-vars */
6
8
 
7
9
  /**
@@ -9,6 +11,7 @@ import { getType, isArray, isInt, isObject, isString } from '../utils'
9
11
  */
10
12
  class FileAction {
11
13
  attributes = {}
14
+
12
15
  options = {}
13
16
 
14
17
  constructor(attributes = {}, options = {}) {
@@ -24,12 +27,12 @@ class FileAction {
24
27
  }
25
28
 
26
29
  isLoaded = () => !!this.attributes.path
30
+
27
31
  // string # Status of file operation.
28
32
  getStatus = () => this.attributes.status
29
33
 
30
34
  // int64 # If status is pending, this is the id of the FileMigration to check for status updates.
31
35
  getFileMigrationId = () => this.attributes.file_migration_id
32
-
33
36
  }
34
37
 
35
38
  export default FileAction