files.com 1.2.103 → 1.2.105

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -1,23 +1,29 @@
1
1
  # Files.com JavaScript SDK
2
2
 
3
- The Files.com JavaScript SDK provides convenient access to the Files.com API from applications written in JavaScript.
3
+ The content included here should be enough to get started, but please visit our
4
+ [Developer Documentation Website](https://developers.files.com/javascript/) for the complete documentation.
5
+
6
+ ## Introduction
4
7
 
8
+ The Files.com JavaScript SDK provides convenient access to the Files.com API from applications written in JavaScript.
5
9
 
6
- ## Installation
10
+ ### Installation
7
11
 
8
12
  To install the package:
9
13
 
10
- yarn add files.com
14
+ ```shell
15
+ yarn add files.com
16
+ ```
11
17
 
12
18
  or
13
19
 
14
- npm install files.com
15
-
16
-
17
- ## Usage
20
+ ```shell
21
+ npm install files.com
22
+ ```
18
23
 
24
+ ### Usage
19
25
 
20
- ### Import and initialize
26
+ #### Import and initialize
21
27
 
22
28
  ```js
23
29
  import Files from "files.com/lib/Files.js";
@@ -28,8 +34,7 @@ import Files from "files.com/lib/Files.js";
28
34
  Files.setBaseUrl("https://MY-SUBDOMAIN.files.com");
29
35
  ```
30
36
 
31
-
32
- #### `require()` vs. `import`
37
+ ##### `require()` vs. `import`
33
38
 
34
39
  The examples provided in the documentation here use the newer ES6 `import` syntax. To
35
40
  instead use the older CommonJS module syntax with `require()`, ensure that `.default`
@@ -43,162 +48,512 @@ const User = require("files.com/lib/models/User.js").default;
43
48
  const { LogLevel } = require("files.com/lib/Logger.js").default;
44
49
  ```
45
50
 
51
+ <Note title="Repository">
52
+ Explore the [files-sdk-javascript](https://github.com/Files-com/files-sdk-javascript) code on GitHub.
53
+ </Note>
46
54
 
47
- ### Authentication
55
+ ### Getting Support
48
56
 
49
- There are multiple ways to authenticate to the Files.com SDK for Javascript.
57
+ The Files.com team is happy to help with any SDK Integration challenges you
58
+ may face.
50
59
 
60
+ Just email support@files.com and we'll get the process started.
51
61
 
52
- #### Global API Key
62
+ ## Authentication
53
63
 
54
- You can set an API key globally like this:
64
+ ### Authenticate with an API Key
55
65
 
56
- Files.setApiKey('my-api-key')
66
+ Authenticating with an API key is the recommended authentication method for most scenarios, and is
67
+ the method used in the examples on this site.
57
68
 
69
+ To use the API or SDKs with an API Key, first generate an API key from the [web
70
+ interface](https://www.files.com/docs/sdk-and-apis/api-keys) or [via the API or an
71
+ SDK](/javascript/resources/developers/api-keys).
58
72
 
59
- #### Per-Request API Key
73
+ Note that when using a user-specific API key, if the user is an administrator, you will have full
74
+ access to the entire API. If the user is not an administrator, you will only be able to access files
75
+ that user can access, and no access will be granted to site administration functions in the API.
60
76
 
61
- Or, you can pass an API key per-request, in the options object at the end of every method like this:
77
+ ```javascript title="Example Request"
78
+ Files.setApiKey('YOUR_API_KEY')
62
79
 
63
- import User from 'files.com/lib/models/User.js'
64
- const user = new User(params, { apiKey: 'my-api-key' })
80
+ // Alternatively, you can specify the API key on a per-object basis in the second parameter to a model constructor.
81
+ const user = new User(params, { apiKey: 'YOUR_API_KEY' })
65
82
 
83
+ // You may also specify the API key on a per-request basis in the final parameter to static methods.
84
+ await User.find(id, params, { apiKey: 'YOUR_API_KEY' })
85
+ ```
66
86
 
67
- #### User Session
87
+ <Note>
88
+ Don't forget to replace the placeholder, `YOUR_API_KEY`, with your actual API key.
89
+ </Note>
68
90
 
69
- Or, you can open a user session by calling `Session.create()`
91
+ ### Authenticate with a Session
70
92
 
71
- import Session from 'files.com/lib/models/Session.js'
72
- const session = await Session.create({ username, password })
93
+ You can also authenticate to the REST API or SDKs by creating a user session using the username and
94
+ password of an active user. If the user is an administrator, the session will have full access to
95
+ the entire API. Sessions created from regular user accounts will only be able to access files that
96
+ user can access, and no access will be granted to site administration functions.
73
97
 
74
- Then use it globally for all subsequent API calls like this:
98
+ API sessions use the exact same session timeout settings as web interface sessions. When an API
99
+ session times out, simply create a new session and resume where you left off. This process is not
100
+ automatically handled by SDKs because we do not want to store password information in memory without
101
+ your explicit consent.
75
102
 
76
- Files.setSessionId(session.id)
103
+ #### Logging in
77
104
 
78
- Or, you can pass the session ID per-request, in the options array at the end of every method like this:
105
+ To create a session, the `create` method is called on the `Session` object with the user's username and
106
+ password.
79
107
 
80
- import User from 'files.com/lib/models/User.js'
81
- const user = new User(params, { sessionId: session.id })
108
+ This returns a session object that can be used to authenticate SDK method calls.
82
109
 
110
+ ```javascript title="Example Request"
111
+ const session = await Session.create({ username: 'motor', password: 'vroom' })
112
+ ```
113
+
114
+ #### Using a session
115
+
116
+ Once a session has been created, you can store the session globally, use the session per object, or use the session per request to authenticate SDK operations.
117
+
118
+ ```javascript title="Example Request"
119
+ // You may set the returned session ID to be used by default for subsequent requests.
120
+ Files.setSessionId(session.id)
83
121
 
84
- ### Setting Global Options
122
+ // Alternatively, you can specify the session ID on a per-object basis in the second parameter to a model constructor.
123
+ const user = new User(params, { session_id: session.id })
85
124
 
86
- You can set the following global properties using static methods on the `Files` class:
125
+ // You may also specify the session ID on a per-request basis in the final parameter to static methods.
126
+ await User.find(id, params, { session_id: session.id })
127
+ ```
128
+
129
+ #### Logging out
87
130
 
131
+ User sessions can be ended calling the `destroy` method on the `session` object.
132
+
133
+ ```javascript title="Example Request"
134
+ await Session.destroy()
135
+ ```
88
136
 
89
- #### Log Level
137
+ ## Configuration
90
138
 
91
- import { LogLevel } from 'files.com/lib/Logger.js'
92
- Files.setLogLevel(LogLevel.INFO)
139
+ ### Configuration options
93
140
 
94
- /*
95
- Call Files.setLogLevel() with one of the following:
96
- LogLevel.NONE
97
- LogLevel.ERROR
98
- LogLevel.WARN
99
- LogLevel.INFO (default)
100
- LogLevel.DEBUG
101
- */
141
+ #### Base URL
102
142
 
143
+ Setting the base URL for the API is required if your site is configured to disable global acceleration.
144
+ This can also be set to use a mock server in development or CI.
145
+
146
+ ```javascript title="Example setting"
147
+ Files.setBaseUrl("https://MY-SUBDOMAIN.files.com");
148
+ ```
149
+
150
+ #### Log level
151
+
152
+ Supported values:
153
+
154
+ * LogLevel.NONE
155
+ * LogLevel.ERROR
156
+ * LogLevel.WARN
157
+ * LogLevel.INFO (default)
158
+ * LogLevel.DEBUG
159
+
160
+ ```javascript title="Example setting"
161
+ import { LogLevel } from 'files.com/lib/Logger.js'
162
+ Files.setLogLevel(LogLevel.INFO)
163
+ ```
103
164
 
104
165
  #### Debugging
105
166
 
106
- Files.configureDebugging({
107
- // enable debug logging of API requests (default: false)
108
- debugRequest: false,
167
+ Enable debug logging of API requests and/or response headers. Both settings default to `false`.
109
168
 
110
- // enable debug logging of API response headers (default: false)
111
- debugResponseHeaders: false,
112
- })
169
+ ```javascript title="Example setting"
170
+ Files.configureDebugging({
171
+ debugRequest: true,
172
+ debugResponseHeaders: true,
173
+ })
174
+ ```
175
+
176
+ #### Network settings
113
177
 
178
+ ```javascript title="Example setting"
179
+ Files.configureNetwork({
180
+ // max retries (default: 3)
181
+ maxNetworkRetries: 3,
114
182
 
115
- #### Network
183
+ // minimum delay in seconds before retrying (default: 0.5)
184
+ minNetworkRetryDelay: 0.5,
116
185
 
117
- Files.configureNetwork({
118
- // max retries (default: 3)
119
- maxNetworkRetries: 3,
186
+ // max delay in seconds before retrying (default: 1.5)
187
+ maxNetworkRetryDelay: 1.5,
120
188
 
121
- // minimum delay in seconds before retrying (default: 0.5)
122
- minNetworkRetryDelay: 0.5,
189
+ // network timeout in seconds (default: 30.0)
190
+ networkTimeout: 30.0,
123
191
 
124
- // max delay in seconds before retrying (default: 1.5)
125
- maxNetworkRetryDelay: 1.5,
192
+ // auto-fetch all pages when results span multiple pages (default: `true`)
193
+ autoPaginate: true,
194
+ })
195
+ ```
126
196
 
127
- // network timeout in seconds (default: 30.0)
128
- networkTimeout: 30.0,
197
+ ### Logging
129
198
 
130
- // auto-fetch all pages when results span multiple pages (default: `true`)
131
- autoPaginate: true,
132
- })
199
+ The Files.com SDK is compatible with the standard log4j logging scheme.
133
200
 
201
+ Add `com.files` logger to your `Loggers` root in the `log4j2.xml` file.
134
202
 
135
- ### File Operations
203
+ ```xml title="log4j2.xml"
204
+ <Loggers>
205
+ <!-- set preferred level -->
206
+ <Logger name="com.files" level="TRACE" />
207
+ <!-- to enable network request -->
208
+ <Logger name="okhttp3.logging.wire" level="INFO"/>
209
+ </Loggers>
210
+ ```
136
211
 
212
+ Create a `resources/log4j2.xml` file.
213
+
214
+ ```xml title="resources/log4j2.xml"
215
+ <?xml version="1.0" encoding="UTF-8"?>
216
+ <Configuration>
217
+ <Appenders>
218
+ <Console name="Console" target="SYSTEM_OUT">
219
+ <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
220
+ </Console>
221
+ </Appenders>
222
+ <Loggers>
223
+ <!-- set preferred level -->
224
+ <Logger name="com.files" level="TRACE"/>
225
+ <!-- to enable network request -->
226
+ <Logger name="okhttp3.logging.wire" level="INFO"/>
227
+ </Loggers>
228
+ </Configuration>
229
+ ```
137
230
 
138
- #### List root folder
231
+ You can read more about [log4j2 configuration](https://logging.apache.org/log4j/2.x/manual/configuration.html).
139
232
 
140
- import Folder from 'files.com/lib/models/Folder.js'
141
- const dirFiles = await Folder.listFor('/')
233
+ ## Errors
142
234
 
235
+ The Files.com JavaScript SDK will return errors by raising exceptions. There are many exception classes defined in the Files SDK that correspond
236
+ to specific errors.
143
237
 
144
- #### Uploading a file
238
+ The raised exceptions come from two categories:
145
239
 
146
- import File from 'files.com/lib/models/File.js'
147
- import { isBrowser } from 'files.com/lib/utils.js'
240
+ 1. SDK Exceptions - errors that originate within the SDK
241
+ 2. API Exceptions - errors that occur due to the response from the Files.com API. These errors are grouped into common error types.
148
242
 
149
- // uploading raw file data
150
- await File.uploadData(destinationFileName, data)
243
+ There are several types of exceptions within each category. Exception classes indicate different types of errors and are named in a
244
+ fashion that describe the general premise of the originating error. More details can be found in the exception object message using the
245
+ `message` attribute.
151
246
 
152
- // uploading a file on disk (not available in browser)
153
- if (!isBrowser()) {
154
- await File.uploadFile(destinationFileName, sourceFilePath)
247
+ Use standard Javascript exception handling to detect and deal with errors. It is generally recommended to catch specific errors first, then
248
+ catch the general `FilesError` exception as a catch-all.
249
+
250
+ ```javascript title="Example Error Handling"
251
+ import Session from 'files.com/lib/models/Session.js'
252
+ import * as FilesErrors from 'files.com/lib/Errors.js'
253
+
254
+ try {
255
+ const session = await Session.create({ username: 'USERNAME', password: 'BADPASSWORD' })
256
+ }
257
+ catch(err) {
258
+ if (err instanceof FilesErrors.NotAuthenticatedError) {
259
+ console.log("Authorization Error Occured (" + err.constructor.name + "): " + err.error);
260
+ } else if (err instanceof FilesErrors.FilesError) {
261
+ console.log("Unknown Error Occured (" + err.constructor.name + "): " + err.error);
262
+ } else {
263
+ throw err;
155
264
  }
265
+ }
266
+ ```
267
+
268
+ ### Error Types
269
+
270
+ #### SDK Errors
271
+
272
+ SDK errors are general errors that occur within the SDK code. These errors generate exceptions. Each of these
273
+ exception classes inherit from a standard `FilesError` base class.
274
+
275
+ ```javascript title="Example SDK Exception Class Inheritance Structure"
276
+ import * as FilesErrors from 'files.com/lib/Errors.js'
277
+
278
+ FilesErrors.ConfigurationError ->
279
+ FilesErrors.FilesError ->
280
+ Error
281
+ ```
282
+ ##### SDK Exception Classes
156
283
 
284
+ | Exception Class Name| Description |
285
+ | --------------- | ------------ |
286
+ | `ConfigurationError`| Invalid SDK configuration parameters |
287
+ | `EmptyPropertyError`| Missing a required property |
288
+ | `InvalidParameterError`| A passed in parameter is invalid |
289
+ | `MissingParameterError`| A method parameter is missing |
290
+ | `NotImplementedError`| The called method has not be implemented by the SDK |
291
+
292
+ #### API Errors
293
+
294
+ API errors are errors returned by the Files.com API. Each exception class inherits from an error group base class.
295
+ The error group base class indicates a particular type of error.
296
+
297
+ ```shell title="Example API Exception Class Inheritance Structure"
298
+ import * as FilesErrors from 'files.com/lib/Errors.js'
299
+
300
+ FilesErrors.NotAuthorized_FolderAdminPermissionRequiredError ->
301
+ FilesErrors.NotAuthorizedError ->
302
+ FilesErrors.FilesApiError ->
303
+ FilesErrors.FilesError ->
304
+ Error
305
+ ```
306
+ ##### API Exception Classes
307
+
308
+ | Exception Class Name | Error Group |
309
+ | --------- | --------- |
310
+ | `BadRequest_AgentUpgradeRequiredError`| `BadRequestError` |
311
+ | `BadRequest_AttachmentTooLargeError`| `BadRequestError` |
312
+ | `BadRequest_CannotDownloadDirectoryError`| `BadRequestError` |
313
+ | `BadRequest_CantMoveWithMultipleLocationsError`| `BadRequestError` |
314
+ | `BadRequest_DatetimeParseError`| `BadRequestError` |
315
+ | `BadRequest_DestinationSameError`| `BadRequestError` |
316
+ | `BadRequest_FolderMustNotBeAFileError`| `BadRequestError` |
317
+ | `BadRequest_InvalidBodyError`| `BadRequestError` |
318
+ | `BadRequest_InvalidCursorError`| `BadRequestError` |
319
+ | `BadRequest_InvalidCursorTypeForSortError`| `BadRequestError` |
320
+ | `BadRequest_InvalidEtagsError`| `BadRequestError` |
321
+ | `BadRequest_InvalidFilterAliasCombinationError`| `BadRequestError` |
322
+ | `BadRequest_InvalidFilterCombinationError`| `BadRequestError` |
323
+ | `BadRequest_InvalidFilterFieldError`| `BadRequestError` |
324
+ | `BadRequest_InvalidFilterParamError`| `BadRequestError` |
325
+ | `BadRequest_InvalidFilterParamValueError`| `BadRequestError` |
326
+ | `BadRequest_InvalidInputEncodingError`| `BadRequestError` |
327
+ | `BadRequest_InvalidInterfaceError`| `BadRequestError` |
328
+ | `BadRequest_InvalidOauthProviderError`| `BadRequestError` |
329
+ | `BadRequest_InvalidPathError`| `BadRequestError` |
330
+ | `BadRequest_InvalidReturnToUrlError`| `BadRequestError` |
331
+ | `BadRequest_InvalidUploadOffsetError`| `BadRequestError` |
332
+ | `BadRequest_InvalidUploadPartGapError`| `BadRequestError` |
333
+ | `BadRequest_InvalidUploadPartSizeError`| `BadRequestError` |
334
+ | `BadRequest_MethodNotAllowedError`| `BadRequestError` |
335
+ | `BadRequest_NoValidInputParamsError`| `BadRequestError` |
336
+ | `BadRequest_PartNumberTooLargeError`| `BadRequestError` |
337
+ | `BadRequest_PathCannotHaveTrailingWhitespaceError`| `BadRequestError` |
338
+ | `BadRequest_ReauthenticationNeededFieldsError`| `BadRequestError` |
339
+ | `BadRequest_RequestParamsContainInvalidCharacterError`| `BadRequestError` |
340
+ | `BadRequest_RequestParamsInvalidError`| `BadRequestError` |
341
+ | `BadRequest_RequestParamsRequiredError`| `BadRequestError` |
342
+ | `BadRequest_SearchAllOnChildPathError`| `BadRequestError` |
343
+ | `BadRequest_UnsupportedCurrencyError`| `BadRequestError` |
344
+ | `BadRequest_UnsupportedHttpResponseFormatError`| `BadRequestError` |
345
+ | `BadRequest_UnsupportedMediaTypeError`| `BadRequestError` |
346
+ | `BadRequest_UserIdInvalidError`| `BadRequestError` |
347
+ | `BadRequest_UserIdOnUserEndpointError`| `BadRequestError` |
348
+ | `BadRequest_UserRequiredError`| `BadRequestError` |
349
+ | `NotAuthenticated_AdditionalAuthenticationRequiredError`| `NotAuthenticatedError` |
350
+ | `NotAuthenticated_AuthenticationRequiredError`| `NotAuthenticatedError` |
351
+ | `NotAuthenticated_BundleRegistrationCodeFailedError`| `NotAuthenticatedError` |
352
+ | `NotAuthenticated_FilesAgentTokenFailedError`| `NotAuthenticatedError` |
353
+ | `NotAuthenticated_InboxRegistrationCodeFailedError`| `NotAuthenticatedError` |
354
+ | `NotAuthenticated_InvalidCredentialsError`| `NotAuthenticatedError` |
355
+ | `NotAuthenticated_InvalidOauthError`| `NotAuthenticatedError` |
356
+ | `NotAuthenticated_InvalidOrExpiredCodeError`| `NotAuthenticatedError` |
357
+ | `NotAuthenticated_InvalidSessionError`| `NotAuthenticatedError` |
358
+ | `NotAuthenticated_InvalidUsernameOrPasswordError`| `NotAuthenticatedError` |
359
+ | `NotAuthenticated_LockedOutError`| `NotAuthenticatedError` |
360
+ | `NotAuthenticated_LockoutRegionMismatchError`| `NotAuthenticatedError` |
361
+ | `NotAuthenticated_OneTimePasswordIncorrectError`| `NotAuthenticatedError` |
362
+ | `NotAuthenticated_TwoFactorAuthenticationErrorError`| `NotAuthenticatedError` |
363
+ | `NotAuthenticated_TwoFactorAuthenticationSetupExpiredError`| `NotAuthenticatedError` |
364
+ | `NotAuthorized_ApiKeyIsDisabledError`| `NotAuthorizedError` |
365
+ | `NotAuthorized_ApiKeyIsPathRestrictedError`| `NotAuthorizedError` |
366
+ | `NotAuthorized_ApiKeyOnlyForDesktopAppError`| `NotAuthorizedError` |
367
+ | `NotAuthorized_ApiKeyOnlyForMobileAppError`| `NotAuthorizedError` |
368
+ | `NotAuthorized_ApiKeyOnlyForOfficeIntegrationError`| `NotAuthorizedError` |
369
+ | `NotAuthorized_BillingPermissionRequiredError`| `NotAuthorizedError` |
370
+ | `NotAuthorized_BundleMaximumUsesReachedError`| `NotAuthorizedError` |
371
+ | `NotAuthorized_CannotLoginWhileUsingKeyError`| `NotAuthorizedError` |
372
+ | `NotAuthorized_CantActForOtherUserError`| `NotAuthorizedError` |
373
+ | `NotAuthorized_ContactAdminForPasswordChangeHelpError`| `NotAuthorizedError` |
374
+ | `NotAuthorized_FilesAgentFailedAuthorizationError`| `NotAuthorizedError` |
375
+ | `NotAuthorized_FolderAdminOrBillingPermissionRequiredError`| `NotAuthorizedError` |
376
+ | `NotAuthorized_FolderAdminPermissionRequiredError`| `NotAuthorizedError` |
377
+ | `NotAuthorized_FullPermissionRequiredError`| `NotAuthorizedError` |
378
+ | `NotAuthorized_HistoryPermissionRequiredError`| `NotAuthorizedError` |
379
+ | `NotAuthorized_InsufficientPermissionForParamsError`| `NotAuthorizedError` |
380
+ | `NotAuthorized_InsufficientPermissionForSiteError`| `NotAuthorizedError` |
381
+ | `NotAuthorized_MustAuthenticateWithApiKeyError`| `NotAuthorizedError` |
382
+ | `NotAuthorized_NeedAdminPermissionForInboxError`| `NotAuthorizedError` |
383
+ | `NotAuthorized_NonAdminsMustQueryByFolderOrPathError`| `NotAuthorizedError` |
384
+ | `NotAuthorized_NotAllowedToCreateBundleError`| `NotAuthorizedError` |
385
+ | `NotAuthorized_PasswordChangeNotRequiredError`| `NotAuthorizedError` |
386
+ | `NotAuthorized_PasswordChangeRequiredError`| `NotAuthorizedError` |
387
+ | `NotAuthorized_ReadOnlySessionError`| `NotAuthorizedError` |
388
+ | `NotAuthorized_ReadPermissionRequiredError`| `NotAuthorizedError` |
389
+ | `NotAuthorized_ReauthenticationFailedError`| `NotAuthorizedError` |
390
+ | `NotAuthorized_ReauthenticationFailedFinalError`| `NotAuthorizedError` |
391
+ | `NotAuthorized_ReauthenticationNeededActionError`| `NotAuthorizedError` |
392
+ | `NotAuthorized_RecaptchaFailedError`| `NotAuthorizedError` |
393
+ | `NotAuthorized_SelfManagedRequiredError`| `NotAuthorizedError` |
394
+ | `NotAuthorized_SiteAdminRequiredError`| `NotAuthorizedError` |
395
+ | `NotAuthorized_SiteFilesAreImmutableError`| `NotAuthorizedError` |
396
+ | `NotAuthorized_TwoFactorAuthenticationRequiredError`| `NotAuthorizedError` |
397
+ | `NotAuthorized_UserIdWithoutSiteAdminError`| `NotAuthorizedError` |
398
+ | `NotAuthorized_WriteAndBundlePermissionRequiredError`| `NotAuthorizedError` |
399
+ | `NotAuthorized_WritePermissionRequiredError`| `NotAuthorizedError` |
400
+ | `NotAuthorized_ZipDownloadIpMismatchError`| `NotAuthorizedError` |
401
+ | `NotFound_ApiKeyNotFoundError`| `NotFoundError` |
402
+ | `NotFound_BundlePathNotFoundError`| `NotFoundError` |
403
+ | `NotFound_BundleRegistrationNotFoundError`| `NotFoundError` |
404
+ | `NotFound_CodeNotFoundError`| `NotFoundError` |
405
+ | `NotFound_FileNotFoundError`| `NotFoundError` |
406
+ | `NotFound_FileUploadNotFoundError`| `NotFoundError` |
407
+ | `NotFound_FolderNotFoundError`| `NotFoundError` |
408
+ | `NotFound_GroupNotFoundError`| `NotFoundError` |
409
+ | `NotFound_InboxNotFoundError`| `NotFoundError` |
410
+ | `NotFound_NestedNotFoundError`| `NotFoundError` |
411
+ | `NotFound_PlanNotFoundError`| `NotFoundError` |
412
+ | `NotFound_SiteNotFoundError`| `NotFoundError` |
413
+ | `NotFound_UserNotFoundError`| `NotFoundError` |
414
+ | `ProcessingFailure_AlreadyCompletedError`| `ProcessingFailureError` |
415
+ | `ProcessingFailure_AutomationCannotBeRunManuallyError`| `ProcessingFailureError` |
416
+ | `ProcessingFailure_BehaviorNotAllowedOnRemoteServerError`| `ProcessingFailureError` |
417
+ | `ProcessingFailure_BundleOnlyAllowsPreviewsError`| `ProcessingFailureError` |
418
+ | `ProcessingFailure_BundleOperationRequiresSubfolderError`| `ProcessingFailureError` |
419
+ | `ProcessingFailure_CouldNotCreateParentError`| `ProcessingFailureError` |
420
+ | `ProcessingFailure_DestinationExistsError`| `ProcessingFailureError` |
421
+ | `ProcessingFailure_DestinationFolderLimitedError`| `ProcessingFailureError` |
422
+ | `ProcessingFailure_DestinationParentConflictError`| `ProcessingFailureError` |
423
+ | `ProcessingFailure_DestinationParentDoesNotExistError`| `ProcessingFailureError` |
424
+ | `ProcessingFailure_ExpiredPrivateKeyError`| `ProcessingFailureError` |
425
+ | `ProcessingFailure_ExpiredPublicKeyError`| `ProcessingFailureError` |
426
+ | `ProcessingFailure_ExportFailureError`| `ProcessingFailureError` |
427
+ | `ProcessingFailure_ExportNotReadyError`| `ProcessingFailureError` |
428
+ | `ProcessingFailure_FailedToChangePasswordError`| `ProcessingFailureError` |
429
+ | `ProcessingFailure_FileLockedError`| `ProcessingFailureError` |
430
+ | `ProcessingFailure_FileNotUploadedError`| `ProcessingFailureError` |
431
+ | `ProcessingFailure_FilePendingProcessingError`| `ProcessingFailureError` |
432
+ | `ProcessingFailure_FileProcessingErrorError`| `ProcessingFailureError` |
433
+ | `ProcessingFailure_FileTooBigToDecryptError`| `ProcessingFailureError` |
434
+ | `ProcessingFailure_FileTooBigToEncryptError`| `ProcessingFailureError` |
435
+ | `ProcessingFailure_FileUploadedToWrongRegionError`| `ProcessingFailureError` |
436
+ | `ProcessingFailure_FilenameTooLongError`| `ProcessingFailureError` |
437
+ | `ProcessingFailure_FolderLockedError`| `ProcessingFailureError` |
438
+ | `ProcessingFailure_FolderNotEmptyError`| `ProcessingFailureError` |
439
+ | `ProcessingFailure_HistoryUnavailableError`| `ProcessingFailureError` |
440
+ | `ProcessingFailure_InvalidBundleCodeError`| `ProcessingFailureError` |
441
+ | `ProcessingFailure_InvalidFileTypeError`| `ProcessingFailureError` |
442
+ | `ProcessingFailure_InvalidFilenameError`| `ProcessingFailureError` |
443
+ | `ProcessingFailure_InvalidPriorityColorError`| `ProcessingFailureError` |
444
+ | `ProcessingFailure_InvalidRangeError`| `ProcessingFailureError` |
445
+ | `ProcessingFailure_ModelSaveErrorError`| `ProcessingFailureError` |
446
+ | `ProcessingFailure_MultipleProcessingErrorsError`| `ProcessingFailureError` |
447
+ | `ProcessingFailure_PathTooLongError`| `ProcessingFailureError` |
448
+ | `ProcessingFailure_RecipientAlreadySharedError`| `ProcessingFailureError` |
449
+ | `ProcessingFailure_RemoteServerErrorError`| `ProcessingFailureError` |
450
+ | `ProcessingFailure_ResourceLockedError`| `ProcessingFailureError` |
451
+ | `ProcessingFailure_SubfolderLockedError`| `ProcessingFailureError` |
452
+ | `ProcessingFailure_TwoFactorAuthenticationCodeAlreadySentError`| `ProcessingFailureError` |
453
+ | `ProcessingFailure_TwoFactorAuthenticationCountryBlacklistedError`| `ProcessingFailureError` |
454
+ | `ProcessingFailure_TwoFactorAuthenticationGeneralErrorError`| `ProcessingFailureError` |
455
+ | `ProcessingFailure_TwoFactorAuthenticationUnsubscribedRecipientError`| `ProcessingFailureError` |
456
+ | `ProcessingFailure_UpdatesNotAllowedForRemotesError`| `ProcessingFailureError` |
457
+ | `RateLimited_DuplicateShareRecipientError`| `RateLimitedError` |
458
+ | `RateLimited_ReauthenticationRateLimitedError`| `RateLimitedError` |
459
+ | `RateLimited_TooManyConcurrentLoginsError`| `RateLimitedError` |
460
+ | `RateLimited_TooManyConcurrentRequestsError`| `RateLimitedError` |
461
+ | `RateLimited_TooManyLoginAttemptsError`| `RateLimitedError` |
462
+ | `RateLimited_TooManyRequestsError`| `RateLimitedError` |
463
+ | `RateLimited_TooManySharesError`| `RateLimitedError` |
464
+ | `ServiceUnavailable_AgentUnavailableError`| `ServiceUnavailableError` |
465
+ | `ServiceUnavailable_AutomationsUnavailableError`| `ServiceUnavailableError` |
466
+ | `ServiceUnavailable_MigrationInProgressError`| `ServiceUnavailableError` |
467
+ | `ServiceUnavailable_SiteDisabledError`| `ServiceUnavailableError` |
468
+ | `ServiceUnavailable_UploadsUnavailableError`| `ServiceUnavailableError` |
469
+ | `SiteConfiguration_AccountAlreadyExistsError`| `SiteConfigurationError` |
470
+ | `SiteConfiguration_AccountOverdueError`| `SiteConfigurationError` |
471
+ | `SiteConfiguration_NoAccountForSiteError`| `SiteConfigurationError` |
472
+ | `SiteConfiguration_SiteWasRemovedError`| `SiteConfigurationError` |
473
+ | `SiteConfiguration_TrialExpiredError`| `SiteConfigurationError` |
474
+ | `SiteConfiguration_TrialLockedError`| `SiteConfigurationError` |
475
+ | `SiteConfiguration_UserRequestsEnabledRequiredError`| `SiteConfigurationError` |
476
+
477
+ ## Examples
478
+
479
+ ### File Operations
480
+
481
+ #### List root folder
482
+
483
+ ```javascript
484
+ import Folder from 'files.com/lib/models/Folder.js'
485
+ const dirFiles = await Folder.listFor('/')
486
+ ```
487
+
488
+ #### Uploading a file
489
+
490
+ ```javascript
491
+ import File from 'files.com/lib/models/File.js'
492
+ import { isBrowser } from 'files.com/lib/utils.js'
493
+
494
+ // uploading raw file data
495
+ await File.uploadData(destinationFileName, data)
496
+
497
+ // uploading a file on disk (not available in browser)
498
+ if (!isBrowser()) {
499
+ await File.uploadFile(destinationFileName, sourceFilePath)
500
+ }
501
+ ```
157
502
 
158
503
  #### Downloading a file
159
504
 
160
505
  ##### Get a downloadable file object by path
161
506
 
162
- import File from 'files.com/lib/models/File.js'
163
-
164
- const foundFile = await File.find(remoteFilePath)
165
- const downloadableFile = await foundFile.download()
507
+ ```javascript
508
+ import File from 'files.com/lib/models/File.js'
166
509
 
510
+ const foundFile = await File.find(remoteFilePath)
511
+ const downloadableFile = await foundFile.download()
512
+ ```
167
513
 
168
514
  ##### Download a file (not available in browser)
169
515
 
170
- import { isBrowser } from 'files.com/lib/utils.js'
171
-
172
- if (!isBrowser()) {
173
- // download to a file on disk
174
- await downloadableFile.downloadToFile(localFilePath)
516
+ ```javascript
517
+ import { isBrowser } from 'files.com/lib/utils.js'
175
518
 
176
- // download to a writable stream
177
- await downloadableFile.downloadToStream(stream)
519
+ if (!isBrowser()) {
520
+ // download to a file on disk
521
+ await downloadableFile.downloadToFile(localFilePath)
178
522
 
179
- // download in memory and return as a UTF-8 string
180
- const textContent = await downloadableFile.downloadToString()
181
- }
523
+ // download to a writable stream
524
+ await downloadableFile.downloadToStream(stream)
182
525
 
526
+ // download in memory and return as a UTF-8 string
527
+ const textContent = await downloadableFile.downloadToString()
528
+ }
529
+ ```
183
530
 
184
531
  #### Comparing Case insensitive files and paths
185
532
 
186
533
  For related documentation see [Case Sensitivity Documentation](https://www.files.com/docs/files-and-folders/file-system-semantics/case-sensitivity).
187
534
 
188
- import { pathNormalizer } from 'files.com/lib/utils.js'
535
+ ```javascript
536
+ import { pathNormalizer } from 'files.com/lib/utils.js'
189
537
 
190
- if (pathNormalizer.same('Fïłèńämê.Txt', 'filename.txt')) {
191
- // the paths are the same
192
- }
538
+ if (pathNormalizer.same('Fïłèńämê.Txt', 'filename.txt')) {
539
+ // the paths are the same
540
+ }
541
+ ```
193
542
 
543
+ ## Mock Server
194
544
 
195
- ### Additional Object Documentation
545
+ Files.com publishes a Files.com API server, which is useful for testing your use of the Files.com
546
+ SDKs and other direct integrations against the Files.com API in an integration test environment.
196
547
 
197
- Additional docs are available at <https://developers.files.com>
548
+ It is a Ruby app that operates as a minimal server for the purpose of testing basic network
549
+ operations and JSON encoding for your SDK or API client. It does not maintain state and it does not
550
+ deeply inspect your submissions for correctness.
198
551
 
552
+ Eventually we will add more features intended for integration testing, such as the ability to
553
+ intentionally provoke errors.
199
554
 
200
- ## Getting Support
555
+ Download the server as a Docker image via [Docker Hub](https://hub.docker.com/r/filescom/files-mock-server).
201
556
 
202
- The Files.com team is happy to help with any SDK Integration challenges you may face.
557
+ The Source Code is also available on [GitHub](https://github.com/Files-com/files-mock-server).
203
558
 
204
- Just email <support@files.com> and we'll get the process started.
559
+ A README is available on the GitHub link.
package/_VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.103
1
+ 1.2.105
@@ -362,7 +362,7 @@ await file.move({
362
362
 
363
363
  ---
364
364
 
365
- ## Begin file upload
365
+ ## Begin File Upload
366
366
 
367
367
  ```
368
368
  const file = await File.find(path)
@@ -10,4 +10,4 @@
10
10
  ```
11
11
 
12
12
  * `status` (string): Status of file operation.
13
- * `file_migration_id` (int64): If status is pending, this is the id of the FileMigration to check for status updates.
13
+ * `file_migration_id` (int64): If status is pending, this is the id of the File Migration to check for status updates.
@@ -11,7 +11,7 @@
11
11
  }
12
12
  ```
13
13
 
14
- * `id` (int64): Sftp Host Key ID
14
+ * `id` (int64): SFTP Host Key ID
15
15
  * `name` (string): The friendly name of this SFTP Host Key.
16
16
  * `fingerprint_md5` (string): MD5 Fingerpint of the public key
17
17
  * `fingerprint_sha256` (string): SHA256 Fingerpint of the public key
package/lib/Files.js CHANGED
@@ -11,7 +11,7 @@ var endpointPrefix = '/api/rest/v1';
11
11
  var apiKey;
12
12
  var baseUrl = 'https://app.files.com';
13
13
  var sessionId = null;
14
- var version = '1.2.103';
14
+ var version = '1.2.105';
15
15
  var userAgent = "Files.com JavaScript SDK v".concat(version);
16
16
  var logLevel = _Logger.LogLevel.INFO;
17
17
  var debugRequest = false;
@@ -815,7 +815,7 @@ var File = /*#__PURE__*/(0, _createClass2.default)(function File() {
815
815
  }
816
816
  }, _callee10);
817
817
  })));
818
- // Begin file upload
818
+ // Begin File Upload
819
819
  //
820
820
  // Parameters:
821
821
  // mkdir_parents - boolean - Create parent directories if they do not exist?
@@ -33,7 +33,7 @@ var FileAction = /*#__PURE__*/(0, _createClass2.default)(function FileAction() {
33
33
  (0, _defineProperty2.default)(this, "getStatus", function () {
34
34
  return _this.attributes.status;
35
35
  });
36
- // int64 # If status is pending, this is the id of the FileMigration to check for status updates.
36
+ // int64 # If status is pending, this is the id of the File Migration to check for status updates.
37
37
  (0, _defineProperty2.default)(this, "getFileMigrationId", function () {
38
38
  return _this.attributes.file_migration_id;
39
39
  });
@@ -33,7 +33,7 @@ var SftpHostKey = /*#__PURE__*/(0, _createClass2.default)(function SftpHostKey()
33
33
  (0, _defineProperty2.default)(this, "isLoaded", function () {
34
34
  return !!_this.attributes.id;
35
35
  });
36
- // int64 # Sftp Host Key ID
36
+ // int64 # SFTP Host Key ID
37
37
  (0, _defineProperty2.default)(this, "getId", function () {
38
38
  return _this.attributes.id;
39
39
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "files.com",
3
- "version": "1.2.103",
3
+ "version": "1.2.105",
4
4
  "description": "Files.com SDK for JavaScript",
5
5
  "keywords": [
6
6
  "files.com",
package/src/Files.js CHANGED
@@ -5,7 +5,7 @@ const endpointPrefix = '/api/rest/v1'
5
5
  let apiKey
6
6
  let baseUrl = 'https://app.files.com'
7
7
  let sessionId = null
8
- const version = '1.2.103'
8
+ const version = '1.2.105'
9
9
  let userAgent = `Files.com JavaScript SDK v${version}`
10
10
 
11
11
  let logLevel = LogLevel.INFO
@@ -806,7 +806,7 @@ class File {
806
806
  return new FileAction(response?.data, this.options)
807
807
  }
808
808
 
809
- // Begin file upload
809
+ // Begin File Upload
810
810
  //
811
811
  // Parameters:
812
812
  // mkdir_parents - boolean - Create parent directories if they do not exist?
@@ -31,7 +31,7 @@ class FileAction {
31
31
  // string # Status of file operation.
32
32
  getStatus = () => this.attributes.status
33
33
 
34
- // int64 # If status is pending, this is the id of the FileMigration to check for status updates.
34
+ // int64 # If status is pending, this is the id of the File Migration to check for status updates.
35
35
  getFileMigrationId = () => this.attributes.file_migration_id
36
36
  }
37
37
 
@@ -28,7 +28,7 @@ class SftpHostKey {
28
28
 
29
29
  isLoaded = () => !!this.attributes.id
30
30
 
31
- // int64 # Sftp Host Key ID
31
+ // int64 # SFTP Host Key ID
32
32
  getId = () => this.attributes.id
33
33
 
34
34
  setId = value => {
@@ -1,16 +0,0 @@
1
-
2
- ---
3
-
4
- ## retry Action Webhook Failure
5
-
6
- ```
7
- const action_webhook_failure = new ActionWebhookFailure()
8
- action_webhook_failure.path = myFilePath
9
-
10
- await action_webhook_failure.retry()
11
- ```
12
-
13
- ### Parameters
14
-
15
- * `id` (int64): Required - Action Webhook Failure ID.
16
-
@@ -1,98 +0,0 @@
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 _utils = require("../utils");
16
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
17
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
18
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
19
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } /* eslint-disable no-unused-vars */
20
- /* eslint-enable no-unused-vars */
21
- /**
22
- * Class ActionWebhookFailure
23
- */
24
- var ActionWebhookFailure = /*#__PURE__*/(0, _createClass2.default)(function ActionWebhookFailure() {
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, ActionWebhookFailure);
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
- // retry Action Webhook Failure
35
- (0, _defineProperty2.default)(this, "retry", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
36
- var params,
37
- _args = arguments;
38
- return _regenerator.default.wrap(function _callee$(_context) {
39
- while (1) switch (_context.prev = _context.next) {
40
- case 0:
41
- params = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
42
- if (_this.attributes.id) {
43
- _context.next = 3;
44
- break;
45
- }
46
- throw new errors.EmptyPropertyError('Current object has no id');
47
- case 3:
48
- if ((0, _utils.isObject)(params)) {
49
- _context.next = 5;
50
- break;
51
- }
52
- throw new errors.InvalidParameterError("Bad parameter: params must be of type object, received ".concat((0, _utils.getType)(params)));
53
- case 5:
54
- params.id = _this.attributes.id;
55
- if (!(params.id && !(0, _utils.isInt)(params.id))) {
56
- _context.next = 8;
57
- break;
58
- }
59
- throw new errors.InvalidParameterError("Bad parameter: id must be of type Int, received ".concat((0, _utils.getType)(params.id)));
60
- case 8:
61
- if (params.id) {
62
- _context.next = 14;
63
- break;
64
- }
65
- if (!_this.attributes.id) {
66
- _context.next = 13;
67
- break;
68
- }
69
- params.id = _this.id;
70
- _context.next = 14;
71
- break;
72
- case 13:
73
- throw new errors.MissingParameterError('Parameter missing: id');
74
- case 14:
75
- _context.next = 16;
76
- return _Api.default.sendRequest("/action_webhook_failures/".concat(encodeURIComponent(params.id), "/retry"), 'POST', params, _this.options);
77
- case 16:
78
- case "end":
79
- return _context.stop();
80
- }
81
- }, _callee);
82
- })));
83
- Object.entries(attributes).forEach(function (_ref2) {
84
- var _ref3 = (0, _slicedToArray2.default)(_ref2, 2),
85
- key = _ref3[0],
86
- value = _ref3[1];
87
- var normalizedKey = key.replace('?', '');
88
- _this.attributes[normalizedKey] = value;
89
- Object.defineProperty(_this, normalizedKey, {
90
- value: value,
91
- writable: false
92
- });
93
- });
94
- this.options = _objectSpread({}, options);
95
- });
96
- var _default = exports.default = ActionWebhookFailure;
97
- module.exports = ActionWebhookFailure;
98
- module.exports.default = ActionWebhookFailure;
@@ -1,61 +0,0 @@
1
- /* eslint-disable no-unused-vars */
2
- import Api from '../Api'
3
- import * as errors from '../Errors'
4
- import {
5
- getType, isArray, isInt, isObject, isString,
6
- } from '../utils'
7
- /* eslint-enable no-unused-vars */
8
-
9
- /**
10
- * Class ActionWebhookFailure
11
- */
12
- class ActionWebhookFailure {
13
- attributes = {}
14
-
15
- options = {}
16
-
17
- constructor(attributes = {}, options = {}) {
18
- Object.entries(attributes).forEach(([key, value]) => {
19
- const normalizedKey = key.replace('?', '')
20
-
21
- this.attributes[normalizedKey] = value
22
-
23
- Object.defineProperty(this, normalizedKey, { value, writable: false })
24
- })
25
-
26
- this.options = { ...options }
27
- }
28
-
29
- isLoaded = () => !!this.attributes.id
30
-
31
- // retry Action Webhook Failure
32
- retry = async (params = {}) => {
33
- if (!this.attributes.id) {
34
- throw new errors.EmptyPropertyError('Current object has no id')
35
- }
36
-
37
- if (!isObject(params)) {
38
- throw new errors.InvalidParameterError(`Bad parameter: params must be of type object, received ${getType(params)}`)
39
- }
40
-
41
- params.id = this.attributes.id
42
- if (params.id && !isInt(params.id)) {
43
- throw new errors.InvalidParameterError(`Bad parameter: id must be of type Int, received ${getType(params.id)}`)
44
- }
45
-
46
- if (!params.id) {
47
- if (this.attributes.id) {
48
- params.id = this.id
49
- } else {
50
- throw new errors.MissingParameterError('Parameter missing: id')
51
- }
52
- }
53
-
54
- await Api.sendRequest(`/action_webhook_failures/${encodeURIComponent(params.id)}/retry`, 'POST', params, this.options)
55
- }
56
- }
57
-
58
- export default ActionWebhookFailure
59
-
60
- module.exports = ActionWebhookFailure
61
- module.exports.default = ActionWebhookFailure