files.com 1.1.18 → 1.2.0
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/.eslintrc.js +0 -3
- package/_VERSION +1 -1
- package/docs/Errors.md +1 -0
- package/lib/Api.js +1 -1
- package/lib/Errors.js +957 -933
- package/lib/Files.js +1 -1
- package/lib/models/ActionNotificationExport.js +25 -25
- package/lib/models/ActionNotificationExportResult.js +10 -10
- package/lib/models/ActionWebhookFailure.js +5 -9
- package/lib/models/ApiKey.js +62 -70
- package/lib/models/App.js +5 -5
- package/lib/models/As2IncomingMessage.js +7 -7
- package/lib/models/As2OutgoingMessage.js +7 -7
- package/lib/models/As2Partner.js +54 -58
- package/lib/models/As2Station.js +51 -55
- package/lib/models/Automation.js +102 -110
- package/lib/models/AutomationRun.js +13 -13
- package/lib/models/BandwidthSnapshot.js +5 -5
- package/lib/models/Behavior.js +77 -85
- package/lib/models/Bundle.js +102 -110
- package/lib/models/BundleDownload.js +9 -9
- package/lib/models/BundleNotification.js +37 -41
- package/lib/models/BundleRecipient.js +22 -22
- package/lib/models/BundleRegistration.js +7 -7
- package/lib/models/Clickwrap.js +52 -56
- package/lib/models/DnsRecord.js +5 -5
- package/lib/models/EmailIncomingMessage.js +5 -5
- package/lib/models/ExternalEvent.js +18 -18
- package/lib/models/File.js +89 -93
- package/lib/models/FileComment.js +41 -45
- package/lib/models/FileCommentReaction.js +15 -19
- package/lib/models/FileMigration.js +5 -5
- package/lib/models/Folder.js +24 -24
- package/lib/models/FormFieldSet.js +44 -48
- package/lib/models/GpgKey.js +53 -57
- package/lib/models/Group.js +51 -55
- package/lib/models/GroupUser.js +53 -57
- package/lib/models/History.js +72 -72
- package/lib/models/HistoryExport.js +51 -51
- package/lib/models/HistoryExportResult.js +10 -10
- package/lib/models/InboxRecipient.js +22 -22
- package/lib/models/InboxRegistration.js +7 -7
- package/lib/models/InboxUpload.js +9 -9
- package/lib/models/Invoice.js +12 -12
- package/lib/models/IpAddress.js +17 -17
- package/lib/models/Lock.js +27 -31
- package/lib/models/Message.js +60 -64
- package/lib/models/MessageComment.js +46 -50
- package/lib/models/MessageCommentReaction.js +27 -31
- package/lib/models/MessageReaction.js +27 -31
- package/lib/models/Notification.js +66 -70
- package/lib/models/Payment.js +12 -12
- package/lib/models/Permission.js +28 -32
- package/lib/models/Priority.js +9 -9
- package/lib/models/Project.js +39 -43
- package/lib/models/PublicKey.js +46 -50
- package/lib/models/RemoteBandwidthSnapshot.js +5 -5
- package/lib/models/RemoteServer.js +306 -310
- package/lib/models/Request.js +33 -37
- package/lib/models/Session.js +11 -15
- package/lib/models/SettingsChange.js +5 -5
- package/lib/models/SftpHostKey.js +40 -44
- package/lib/models/ShareGroup.js +50 -54
- package/lib/models/Site.js +138 -138
- package/lib/models/Snapshot.js +44 -48
- package/lib/models/SsoStrategy.js +15 -19
- package/lib/models/Style.js +17 -21
- package/lib/models/UsageDailySnapshot.js +5 -5
- package/lib/models/UsageSnapshot.js +5 -5
- package/lib/models/User.js +156 -172
- package/lib/models/UserCipherUse.js +7 -7
- package/lib/models/UserRequest.js +26 -30
- package/lib/models/WebhookTest.js +15 -15
- package/package.json +6 -2
- package/src/Api.js +2 -1
- package/src/Errors.js +189 -177
- package/src/Files.js +1 -1
- package/src/models/AccountLineItem.js +5 -2
- package/src/models/Action.js +5 -2
- package/src/models/ActionNotificationExport.js +36 -35
- package/src/models/ActionNotificationExportResult.js +15 -13
- package/src/models/ActionWebhookFailure.js +9 -8
- package/src/models/ApiKey.js +69 -72
- package/src/models/App.js +10 -8
- package/src/models/As2IncomingMessage.js +12 -10
- package/src/models/As2OutgoingMessage.js +12 -10
- package/src/models/As2Partner.js +61 -60
- package/src/models/As2Station.js +58 -57
- package/src/models/Auto.js +5 -2
- package/src/models/Automation.js +121 -110
- package/src/models/AutomationRun.js +18 -17
- package/src/models/BandwidthSnapshot.js +10 -8
- package/src/models/Behavior.js +85 -86
- package/src/models/Bundle.js +121 -110
- package/src/models/BundleDownload.js +14 -12
- package/src/models/BundleNotification.js +40 -43
- package/src/models/BundleRecipient.js +33 -32
- package/src/models/BundleRegistration.js +12 -10
- package/src/models/Clickwrap.js +60 -58
- package/src/models/DnsRecord.js +10 -8
- package/src/models/EmailIncomingMessage.js +10 -8
- package/src/models/Errors.js +5 -2
- package/src/models/ExternalEvent.js +29 -29
- package/src/models/File.js +116 -108
- package/src/models/FileAction.js +5 -2
- package/src/models/FileComment.js +45 -46
- package/src/models/FileCommentReaction.js +26 -26
- package/src/models/FileMigration.js +10 -8
- package/src/models/FileUploadPart.js +5 -2
- package/src/models/Folder.js +32 -29
- package/src/models/FormField.js +5 -2
- package/src/models/FormFieldSet.js +49 -50
- package/src/models/GpgKey.js +60 -59
- package/src/models/Group.js +58 -57
- package/src/models/GroupUser.js +60 -58
- package/src/models/History.js +77 -74
- package/src/models/HistoryExport.js +62 -61
- package/src/models/HistoryExportResult.js +15 -13
- package/src/models/Image.js +5 -2
- package/src/models/InboxRecipient.js +33 -32
- package/src/models/InboxRegistration.js +12 -10
- package/src/models/InboxUpload.js +14 -12
- package/src/models/Invoice.js +17 -14
- package/src/models/InvoiceLineItem.js +5 -2
- package/src/models/IpAddress.js +22 -20
- package/src/models/Lock.js +36 -36
- package/src/models/Message.js +66 -66
- package/src/models/MessageComment.js +50 -52
- package/src/models/MessageCommentReaction.js +38 -40
- package/src/models/MessageReaction.js +38 -40
- package/src/models/Notification.js +74 -72
- package/src/models/Payment.js +17 -14
- package/src/models/PaymentLineItem.js +5 -2
- package/src/models/Permission.js +39 -40
- package/src/models/Preview.js +5 -2
- package/src/models/Priority.js +14 -12
- package/src/models/Project.js +43 -45
- package/src/models/PublicIpAddress.js +5 -2
- package/src/models/PublicKey.js +50 -52
- package/src/models/RemoteBandwidthSnapshot.js +10 -8
- package/src/models/RemoteServer.js +380 -312
- package/src/models/RemoteServerConfigurationFile.js +5 -2
- package/src/models/Request.js +44 -46
- package/src/models/Session.js +22 -22
- package/src/models/SettingsChange.js +10 -8
- package/src/models/SftpHostKey.js +45 -46
- package/src/models/ShareGroup.js +56 -56
- package/src/models/ShareGroupMember.js +5 -2
- package/src/models/Site.js +143 -142
- package/src/models/Snapshot.js +50 -50
- package/src/models/SsoStrategy.js +20 -21
- package/src/models/Status.js +5 -2
- package/src/models/Style.js +22 -23
- package/src/models/UsageDailySnapshot.js +10 -8
- package/src/models/UsageSnapshot.js +10 -8
- package/src/models/User.js +185 -168
- package/src/models/UserCipherUse.js +12 -10
- package/src/models/UserRequest.js +37 -39
- package/src/models/WebhookTest.js +26 -24
- package/test/Api.test.js +163 -0
- package/test/{package.json → integration/package.json} +1 -1
- package/test/{src → integration/src}/index.js +1 -1
- package/test.sh +2 -1
- /package/test/{.babelrc → integration/.babelrc} +0 -0
- /package/test/{index.js → integration/index.js} +0 -0
|
@@ -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 {
|
|
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 FileComment {
|
|
11
13
|
attributes = {}
|
|
14
|
+
|
|
12
15
|
options = {}
|
|
13
16
|
|
|
14
17
|
constructor(attributes = {}, options = {}) {
|
|
@@ -24,6 +27,7 @@ class FileComment {
|
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
isLoaded = () => !!this.attributes.id
|
|
30
|
+
|
|
27
31
|
// int64 # File Comment ID
|
|
28
32
|
getId = () => this.attributes.id
|
|
29
33
|
|
|
@@ -52,7 +56,6 @@ class FileComment {
|
|
|
52
56
|
this.attributes.path = value
|
|
53
57
|
}
|
|
54
58
|
|
|
55
|
-
|
|
56
59
|
// Parameters:
|
|
57
60
|
// body (required) - string - Comment body.
|
|
58
61
|
update = async (params = {}) => {
|
|
@@ -65,32 +68,32 @@ class FileComment {
|
|
|
65
68
|
}
|
|
66
69
|
|
|
67
70
|
params.id = this.attributes.id
|
|
68
|
-
if (params
|
|
69
|
-
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params
|
|
71
|
+
if (params.id && !isInt(params.id)) {
|
|
72
|
+
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
|
|
70
73
|
}
|
|
71
|
-
|
|
72
|
-
|
|
74
|
+
|
|
75
|
+
if (params.body && !isString(params.body)) {
|
|
76
|
+
throw new errors.InvalidParameterError(`Bad parameter: body must be of type String, received ${getType(params.body)}`)
|
|
73
77
|
}
|
|
74
78
|
|
|
75
|
-
if (!params
|
|
79
|
+
if (!params.id) {
|
|
76
80
|
if (this.attributes.id) {
|
|
77
|
-
params
|
|
81
|
+
params.id = this.id
|
|
78
82
|
} else {
|
|
79
83
|
throw new errors.MissingParameterError('Parameter missing: id')
|
|
80
84
|
}
|
|
81
85
|
}
|
|
82
86
|
|
|
83
|
-
if (!params
|
|
87
|
+
if (!params.body) {
|
|
84
88
|
if (this.attributes.body) {
|
|
85
|
-
params
|
|
89
|
+
params.body = this.body
|
|
86
90
|
} else {
|
|
87
91
|
throw new errors.MissingParameterError('Parameter missing: body')
|
|
88
92
|
}
|
|
89
93
|
}
|
|
90
94
|
|
|
91
|
-
const response = await Api.sendRequest(`/file_comments/${encodeURIComponent(params
|
|
95
|
+
const response = await Api.sendRequest(`/file_comments/${encodeURIComponent(params.id)}`, 'PATCH', params, this.options)
|
|
92
96
|
|
|
93
|
-
|
|
94
97
|
return new FileComment(response?.data, this.options)
|
|
95
98
|
}
|
|
96
99
|
|
|
@@ -104,36 +107,34 @@ class FileComment {
|
|
|
104
107
|
}
|
|
105
108
|
|
|
106
109
|
params.id = this.attributes.id
|
|
107
|
-
if (params
|
|
108
|
-
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params
|
|
110
|
+
if (params.id && !isInt(params.id)) {
|
|
111
|
+
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
|
|
109
112
|
}
|
|
110
113
|
|
|
111
|
-
if (!params
|
|
114
|
+
if (!params.id) {
|
|
112
115
|
if (this.attributes.id) {
|
|
113
|
-
params
|
|
116
|
+
params.id = this.id
|
|
114
117
|
} else {
|
|
115
118
|
throw new errors.MissingParameterError('Parameter missing: id')
|
|
116
119
|
}
|
|
117
120
|
}
|
|
118
121
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
return
|
|
122
|
+
await Api.sendRequest(`/file_comments/${encodeURIComponent(params.id)}`, 'DELETE', params, this.options)
|
|
122
123
|
}
|
|
123
124
|
|
|
124
125
|
destroy = (params = {}) =>
|
|
125
126
|
this.delete(params)
|
|
126
127
|
|
|
127
128
|
save = async () => {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
129
|
+
if (this.attributes.id) {
|
|
130
|
+
const newObject = await this.update(this.attributes)
|
|
131
|
+
this.attributes = { ...newObject.attributes }
|
|
132
|
+
return true
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const newObject = await FileComment.create(this.attributes, this.options)
|
|
136
|
+
this.attributes = { ...newObject.attributes }
|
|
137
|
+
return true
|
|
137
138
|
}
|
|
138
139
|
|
|
139
140
|
// Parameters:
|
|
@@ -145,27 +146,26 @@ class FileComment {
|
|
|
145
146
|
throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
|
|
146
147
|
}
|
|
147
148
|
|
|
148
|
-
params
|
|
149
|
+
params.path = path
|
|
149
150
|
|
|
150
|
-
if (!params
|
|
151
|
+
if (!params.path) {
|
|
151
152
|
throw new errors.MissingParameterError('Parameter missing: path')
|
|
152
153
|
}
|
|
153
154
|
|
|
154
|
-
if (params
|
|
155
|
-
throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params
|
|
155
|
+
if (params.cursor && !isString(params.cursor)) {
|
|
156
|
+
throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params.cursor)}`)
|
|
156
157
|
}
|
|
157
158
|
|
|
158
|
-
if (params
|
|
159
|
-
throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params
|
|
159
|
+
if (params.per_page && !isInt(params.per_page)) {
|
|
160
|
+
throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params.per_page)}`)
|
|
160
161
|
}
|
|
161
162
|
|
|
162
|
-
if (params
|
|
163
|
-
throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params
|
|
163
|
+
if (params.path && !isString(params.path)) {
|
|
164
|
+
throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params.path)}`)
|
|
164
165
|
}
|
|
165
166
|
|
|
166
|
-
const response = await Api.sendRequest(`/file_comments/files/${encodeURIComponent(params
|
|
167
|
+
const response = await Api.sendRequest(`/file_comments/files/${encodeURIComponent(params.path)}`, 'GET', params, options)
|
|
167
168
|
|
|
168
|
-
|
|
169
169
|
return response?.data?.map(obj => new FileComment(obj, options)) || []
|
|
170
170
|
}
|
|
171
171
|
|
|
@@ -173,25 +173,24 @@ class FileComment {
|
|
|
173
173
|
// body (required) - string - Comment body.
|
|
174
174
|
// path (required) - string - File path.
|
|
175
175
|
static create = async (params = {}, options = {}) => {
|
|
176
|
-
if (!params
|
|
176
|
+
if (!params.body) {
|
|
177
177
|
throw new errors.MissingParameterError('Parameter missing: body')
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
-
if (!params
|
|
180
|
+
if (!params.path) {
|
|
181
181
|
throw new errors.MissingParameterError('Parameter missing: path')
|
|
182
182
|
}
|
|
183
183
|
|
|
184
|
-
if (params
|
|
185
|
-
throw new errors.InvalidParameterError(`Bad parameter: body must be of type String, received ${getType(params
|
|
184
|
+
if (params.body && !isString(params.body)) {
|
|
185
|
+
throw new errors.InvalidParameterError(`Bad parameter: body must be of type String, received ${getType(params.body)}`)
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
if (params
|
|
189
|
-
throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params
|
|
188
|
+
if (params.path && !isString(params.path)) {
|
|
189
|
+
throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params.path)}`)
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
-
const response = await Api.sendRequest(
|
|
192
|
+
const response = await Api.sendRequest('/file_comments', 'POST', params, options)
|
|
193
193
|
|
|
194
|
-
|
|
195
194
|
return new FileComment(response?.data, options)
|
|
196
195
|
}
|
|
197
196
|
}
|
|
@@ -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 {
|
|
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 FileCommentReaction {
|
|
11
13
|
attributes = {}
|
|
14
|
+
|
|
12
15
|
options = {}
|
|
13
16
|
|
|
14
17
|
constructor(attributes = {}, options = {}) {
|
|
@@ -24,6 +27,7 @@ class FileCommentReaction {
|
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
isLoaded = () => !!this.attributes.id
|
|
30
|
+
|
|
27
31
|
// int64 # Reaction ID
|
|
28
32
|
getId = () => this.attributes.id
|
|
29
33
|
|
|
@@ -52,7 +56,6 @@ class FileCommentReaction {
|
|
|
52
56
|
this.attributes.file_comment_id = value
|
|
53
57
|
}
|
|
54
58
|
|
|
55
|
-
|
|
56
59
|
delete = async (params = {}) => {
|
|
57
60
|
if (!this.attributes.id) {
|
|
58
61
|
throw new errors.EmptyPropertyError('Current object has no id')
|
|
@@ -63,34 +66,32 @@ class FileCommentReaction {
|
|
|
63
66
|
}
|
|
64
67
|
|
|
65
68
|
params.id = this.attributes.id
|
|
66
|
-
if (params
|
|
67
|
-
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params
|
|
69
|
+
if (params.id && !isInt(params.id)) {
|
|
70
|
+
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
|
|
68
71
|
}
|
|
69
72
|
|
|
70
|
-
if (!params
|
|
73
|
+
if (!params.id) {
|
|
71
74
|
if (this.attributes.id) {
|
|
72
|
-
params
|
|
75
|
+
params.id = this.id
|
|
73
76
|
} else {
|
|
74
77
|
throw new errors.MissingParameterError('Parameter missing: id')
|
|
75
78
|
}
|
|
76
79
|
}
|
|
77
80
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
return
|
|
81
|
+
await Api.sendRequest(`/file_comment_reactions/${encodeURIComponent(params.id)}`, 'DELETE', params, this.options)
|
|
81
82
|
}
|
|
82
83
|
|
|
83
84
|
destroy = (params = {}) =>
|
|
84
85
|
this.delete(params)
|
|
85
86
|
|
|
86
87
|
save = async () => {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
88
|
+
if (this.attributes.id) {
|
|
89
|
+
throw new errors.NotImplementedError('The FileCommentReaction object doesn\'t support updates.')
|
|
90
|
+
} else {
|
|
91
|
+
const newObject = await FileCommentReaction.create(this.attributes, this.options)
|
|
92
|
+
this.attributes = { ...newObject.attributes }
|
|
93
|
+
return true
|
|
94
|
+
}
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
// Parameters:
|
|
@@ -98,29 +99,28 @@ class FileCommentReaction {
|
|
|
98
99
|
// file_comment_id (required) - int64 - ID of file comment to attach reaction to.
|
|
99
100
|
// emoji (required) - string - Emoji to react with.
|
|
100
101
|
static create = async (params = {}, options = {}) => {
|
|
101
|
-
if (!params
|
|
102
|
+
if (!params.file_comment_id) {
|
|
102
103
|
throw new errors.MissingParameterError('Parameter missing: file_comment_id')
|
|
103
104
|
}
|
|
104
105
|
|
|
105
|
-
if (!params
|
|
106
|
+
if (!params.emoji) {
|
|
106
107
|
throw new errors.MissingParameterError('Parameter missing: emoji')
|
|
107
108
|
}
|
|
108
109
|
|
|
109
|
-
if (params
|
|
110
|
-
throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params
|
|
110
|
+
if (params.user_id && !isInt(params.user_id)) {
|
|
111
|
+
throw new errors.InvalidParameterError(`Bad parameter: user_id must be of type Int, received ${getType(params.user_id)}`)
|
|
111
112
|
}
|
|
112
113
|
|
|
113
|
-
if (params
|
|
114
|
-
throw new errors.InvalidParameterError(`Bad parameter: file_comment_id must be of type Int, received ${getType(params
|
|
114
|
+
if (params.file_comment_id && !isInt(params.file_comment_id)) {
|
|
115
|
+
throw new errors.InvalidParameterError(`Bad parameter: file_comment_id must be of type Int, received ${getType(params.file_comment_id)}`)
|
|
115
116
|
}
|
|
116
117
|
|
|
117
|
-
if (params
|
|
118
|
-
throw new errors.InvalidParameterError(`Bad parameter: emoji must be of type String, received ${getType(params
|
|
118
|
+
if (params.emoji && !isString(params.emoji)) {
|
|
119
|
+
throw new errors.InvalidParameterError(`Bad parameter: emoji must be of type String, received ${getType(params.emoji)}`)
|
|
119
120
|
}
|
|
120
121
|
|
|
121
|
-
const response = await Api.sendRequest(
|
|
122
|
+
const response = await Api.sendRequest('/file_comment_reactions', 'POST', params, options)
|
|
122
123
|
|
|
123
|
-
|
|
124
124
|
return new FileCommentReaction(response?.data, options)
|
|
125
125
|
}
|
|
126
126
|
}
|
|
@@ -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 {
|
|
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 FileMigration {
|
|
11
13
|
attributes = {}
|
|
14
|
+
|
|
12
15
|
options = {}
|
|
13
16
|
|
|
14
17
|
constructor(attributes = {}, options = {}) {
|
|
@@ -24,6 +27,7 @@ class FileMigration {
|
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
isLoaded = () => !!this.attributes.id
|
|
30
|
+
|
|
27
31
|
// int64 # File migration ID
|
|
28
32
|
getId = () => this.attributes.id
|
|
29
33
|
|
|
@@ -51,7 +55,6 @@ class FileMigration {
|
|
|
51
55
|
// string # Link to download the log file for this migration.
|
|
52
56
|
getLogUrl = () => this.attributes.log_url
|
|
53
57
|
|
|
54
|
-
|
|
55
58
|
// Parameters:
|
|
56
59
|
// id (required) - int64 - File Migration ID.
|
|
57
60
|
static find = async (id, params = {}, options = {}) => {
|
|
@@ -59,19 +62,18 @@ class FileMigration {
|
|
|
59
62
|
throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
|
|
60
63
|
}
|
|
61
64
|
|
|
62
|
-
params
|
|
65
|
+
params.id = id
|
|
63
66
|
|
|
64
|
-
if (!params
|
|
67
|
+
if (!params.id) {
|
|
65
68
|
throw new errors.MissingParameterError('Parameter missing: id')
|
|
66
69
|
}
|
|
67
70
|
|
|
68
|
-
if (params
|
|
69
|
-
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params
|
|
71
|
+
if (params.id && !isInt(params.id)) {
|
|
72
|
+
throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
|
|
70
73
|
}
|
|
71
74
|
|
|
72
|
-
const response = await Api.sendRequest(`/file_migrations/${encodeURIComponent(params
|
|
75
|
+
const response = await Api.sendRequest(`/file_migrations/${encodeURIComponent(params.id)}`, 'GET', params, options)
|
|
73
76
|
|
|
74
|
-
|
|
75
77
|
return new FileMigration(response?.data, options)
|
|
76
78
|
}
|
|
77
79
|
|
|
@@ -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 {
|
|
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 FileUploadPart {
|
|
11
13
|
attributes = {}
|
|
14
|
+
|
|
12
15
|
options = {}
|
|
13
16
|
|
|
14
17
|
constructor(attributes = {}, options = {}) {
|
|
@@ -24,6 +27,7 @@ class FileUploadPart {
|
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
isLoaded = () => !!this.attributes.id
|
|
30
|
+
|
|
27
31
|
// object # Content-Type and File to send
|
|
28
32
|
getSend = () => this.attributes.send
|
|
29
33
|
|
|
@@ -71,7 +75,6 @@ class FileUploadPart {
|
|
|
71
75
|
|
|
72
76
|
// string # URI to upload this part to
|
|
73
77
|
getUploadUri = () => this.attributes.upload_uri
|
|
74
|
-
|
|
75
78
|
}
|
|
76
79
|
|
|
77
80
|
export default FileUploadPart
|
package/src/models/Folder.js
CHANGED
|
@@ -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 {
|
|
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 Folder {
|
|
11
13
|
attributes = {}
|
|
14
|
+
|
|
12
15
|
options = {}
|
|
13
16
|
|
|
14
17
|
constructor(attributes = {}, options = {}) {
|
|
@@ -24,6 +27,7 @@ class Folder {
|
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
isLoaded = () => !!this.attributes.path
|
|
30
|
+
|
|
27
31
|
// string # File/Folder path This must be slash-delimited, but it must neither start nor end with a slash. Maximum of 5000 characters.
|
|
28
32
|
getPath = () => this.attributes.path
|
|
29
33
|
|
|
@@ -153,11 +157,10 @@ class Folder {
|
|
|
153
157
|
this.attributes.mkdir_parents = value
|
|
154
158
|
}
|
|
155
159
|
|
|
156
|
-
|
|
157
160
|
save = async () => {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
+
const newObject = await Folder.create(this.attributes.path, this.attributes, this.options)
|
|
162
|
+
this.attributes = { ...newObject.attributes }
|
|
163
|
+
return true
|
|
161
164
|
}
|
|
162
165
|
|
|
163
166
|
// Parameters:
|
|
@@ -176,39 +179,39 @@ class Folder {
|
|
|
176
179
|
throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
|
|
177
180
|
}
|
|
178
181
|
|
|
179
|
-
params
|
|
182
|
+
params.path = path
|
|
180
183
|
|
|
181
|
-
if (!params
|
|
184
|
+
if (!params.path) {
|
|
182
185
|
throw new errors.MissingParameterError('Parameter missing: path')
|
|
183
186
|
}
|
|
184
187
|
|
|
185
|
-
if (params
|
|
186
|
-
throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params
|
|
188
|
+
if (params.cursor && !isString(params.cursor)) {
|
|
189
|
+
throw new errors.InvalidParameterError(`Bad parameter: cursor must be of type String, received ${getType(params.cursor)}`)
|
|
187
190
|
}
|
|
188
191
|
|
|
189
|
-
if (params
|
|
190
|
-
throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params
|
|
192
|
+
if (params.per_page && !isInt(params.per_page)) {
|
|
193
|
+
throw new errors.InvalidParameterError(`Bad parameter: per_page must be of type Int, received ${getType(params.per_page)}`)
|
|
191
194
|
}
|
|
192
195
|
|
|
193
|
-
if (params
|
|
194
|
-
throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params
|
|
196
|
+
if (params.path && !isString(params.path)) {
|
|
197
|
+
throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params.path)}`)
|
|
195
198
|
}
|
|
196
199
|
|
|
197
|
-
if (params
|
|
198
|
-
throw new errors.InvalidParameterError(`Bad parameter: filter must be of type String, received ${getType(params
|
|
200
|
+
if (params.filter && !isString(params.filter)) {
|
|
201
|
+
throw new errors.InvalidParameterError(`Bad parameter: filter must be of type String, received ${getType(params.filter)}`)
|
|
199
202
|
}
|
|
200
203
|
|
|
201
|
-
if (params
|
|
202
|
-
throw new errors.InvalidParameterError(`Bad parameter: preview_size must be of type String, received ${getType(params
|
|
204
|
+
if (params.preview_size && !isString(params.preview_size)) {
|
|
205
|
+
throw new errors.InvalidParameterError(`Bad parameter: preview_size must be of type String, received ${getType(params.preview_size)}`)
|
|
203
206
|
}
|
|
204
207
|
|
|
205
|
-
if (params
|
|
206
|
-
throw new errors.InvalidParameterError(`Bad parameter: search must be of type String, received ${getType(params
|
|
208
|
+
if (params.search && !isString(params.search)) {
|
|
209
|
+
throw new errors.InvalidParameterError(`Bad parameter: search must be of type String, received ${getType(params.search)}`)
|
|
207
210
|
}
|
|
208
211
|
|
|
209
|
-
const response = await Api.sendRequest(`/folders/${encodeURIComponent(params
|
|
212
|
+
const response = await Api.sendRequest(`/folders/${encodeURIComponent(params.path)}`, 'GET', params, options)
|
|
210
213
|
|
|
211
|
-
const File = require(
|
|
214
|
+
const File = require('./File.js').default
|
|
212
215
|
return response?.data?.map(obj => new File(obj, options)) || []
|
|
213
216
|
}
|
|
214
217
|
|
|
@@ -221,23 +224,23 @@ class Folder {
|
|
|
221
224
|
throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
|
|
222
225
|
}
|
|
223
226
|
|
|
224
|
-
params
|
|
227
|
+
params.path = path
|
|
225
228
|
|
|
226
|
-
if (!params
|
|
229
|
+
if (!params.path) {
|
|
227
230
|
throw new errors.MissingParameterError('Parameter missing: path')
|
|
228
231
|
}
|
|
229
232
|
|
|
230
|
-
if (params
|
|
231
|
-
throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params
|
|
233
|
+
if (params.path && !isString(params.path)) {
|
|
234
|
+
throw new errors.InvalidParameterError(`Bad parameter: path must be of type String, received ${getType(params.path)}`)
|
|
232
235
|
}
|
|
233
236
|
|
|
234
|
-
if (params
|
|
235
|
-
throw new errors.InvalidParameterError(`Bad parameter: provided_mtime must be of type String, received ${getType(params
|
|
237
|
+
if (params.provided_mtime && !isString(params.provided_mtime)) {
|
|
238
|
+
throw new errors.InvalidParameterError(`Bad parameter: provided_mtime must be of type String, received ${getType(params.provided_mtime)}`)
|
|
236
239
|
}
|
|
237
240
|
|
|
238
|
-
const response = await Api.sendRequest(`/folders/${encodeURIComponent(params
|
|
241
|
+
const response = await Api.sendRequest(`/folders/${encodeURIComponent(params.path)}`, 'POST', params, options)
|
|
239
242
|
|
|
240
|
-
const File = require(
|
|
243
|
+
const File = require('./File.js').default
|
|
241
244
|
return new File(response?.data, options)
|
|
242
245
|
}
|
|
243
246
|
}
|
package/src/models/FormField.js
CHANGED
|
@@ -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 {
|
|
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 FormField {
|
|
11
13
|
attributes = {}
|
|
14
|
+
|
|
12
15
|
options = {}
|
|
13
16
|
|
|
14
17
|
constructor(attributes = {}, options = {}) {
|
|
@@ -24,6 +27,7 @@ class FormField {
|
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
isLoaded = () => !!this.attributes.id
|
|
30
|
+
|
|
27
31
|
// int64 # Form field id
|
|
28
32
|
getId = () => this.attributes.id
|
|
29
33
|
|
|
@@ -47,7 +51,6 @@ class FormField {
|
|
|
47
51
|
|
|
48
52
|
// int64 # Form field set id
|
|
49
53
|
getFormFieldSetId = () => this.attributes.form_field_set_id
|
|
50
|
-
|
|
51
54
|
}
|
|
52
55
|
|
|
53
56
|
export default FormField
|