box-node-sdk 1.36.0 → 1.38.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.
Files changed (126) hide show
  1. package/CHANGELOG.md +45 -3
  2. package/README.md +3 -1
  3. package/lib/api-request-manager.d.ts +38 -0
  4. package/lib/api-request-manager.js +48 -55
  5. package/lib/api-request-manager.js.map +1 -0
  6. package/lib/api-request.d.ts +137 -0
  7. package/lib/api-request.js +202 -281
  8. package/lib/api-request.js.map +1 -0
  9. package/lib/box-client.d.ts +269 -0
  10. package/lib/box-client.js +551 -713
  11. package/lib/box-client.js.map +1 -0
  12. package/lib/box-node-sdk.d.ts +216 -0
  13. package/lib/box-node-sdk.js +317 -352
  14. package/lib/box-node-sdk.js.map +1 -0
  15. package/lib/chunked-uploader.d.ts +129 -0
  16. package/lib/chunked-uploader.js +287 -358
  17. package/lib/chunked-uploader.js.map +1 -0
  18. package/lib/enterprise-event-stream.d.ts +82 -0
  19. package/lib/enterprise-event-stream.js +189 -203
  20. package/lib/enterprise-event-stream.js.map +1 -0
  21. package/lib/event-stream.d.ts +92 -0
  22. package/lib/event-stream.js +274 -302
  23. package/lib/event-stream.js.map +1 -0
  24. package/lib/managers/collaboration-allowlist.d.ts +137 -0
  25. package/lib/managers/collaboration-allowlist.js +200 -0
  26. package/lib/managers/collaboration-allowlist.js.map +1 -0
  27. package/lib/managers/collaboration-whitelist.d.ts +3 -0
  28. package/lib/managers/collaboration-whitelist.js +8 -222
  29. package/lib/managers/collaboration-whitelist.js.map +1 -0
  30. package/lib/managers/collaborations.d.ts +166 -0
  31. package/lib/managers/collaborations.js +225 -258
  32. package/lib/managers/collaborations.js.map +1 -0
  33. package/lib/managers/collections.d.ts +42 -0
  34. package/lib/managers/collections.js +45 -50
  35. package/lib/managers/collections.js.map +1 -0
  36. package/lib/managers/comments.d.ts +103 -0
  37. package/lib/managers/comments.js +158 -173
  38. package/lib/managers/comments.js.map +1 -0
  39. package/lib/managers/device-pins.d.ts +52 -0
  40. package/lib/managers/device-pins.js +75 -88
  41. package/lib/managers/device-pins.js.map +1 -0
  42. package/lib/managers/enterprise.d.ts +162 -0
  43. package/lib/managers/enterprise.js +168 -199
  44. package/lib/managers/enterprise.js.map +1 -0
  45. package/lib/managers/events.d.ts +179 -0
  46. package/lib/managers/events.js +232 -254
  47. package/lib/managers/events.js.map +1 -0
  48. package/lib/managers/files.d.ts +773 -0
  49. package/lib/managers/files.js +1401 -1602
  50. package/lib/managers/files.js.map +1 -0
  51. package/lib/managers/folders.d.ts +347 -0
  52. package/lib/managers/folders.js +551 -630
  53. package/lib/managers/folders.js.map +1 -0
  54. package/lib/managers/groups.d.ts +202 -0
  55. package/lib/managers/groups.js +238 -288
  56. package/lib/managers/groups.js.map +1 -0
  57. package/lib/managers/legal-hold-policies.d.ts +190 -0
  58. package/lib/managers/legal-hold-policies.js +228 -272
  59. package/lib/managers/legal-hold-policies.js.map +1 -0
  60. package/lib/managers/metadata.d.ts +228 -0
  61. package/lib/managers/metadata.js +265 -328
  62. package/lib/managers/metadata.js.map +1 -0
  63. package/lib/managers/recent-items.d.ts +38 -0
  64. package/lib/managers/recent-items.js +32 -39
  65. package/lib/managers/recent-items.js.map +1 -0
  66. package/lib/managers/retention-policies.d.ts +251 -0
  67. package/lib/managers/retention-policies.js +278 -281
  68. package/lib/managers/retention-policies.js.map +1 -0
  69. package/lib/managers/search.d.ts +82 -0
  70. package/lib/managers/search.js +68 -88
  71. package/lib/managers/search.js.map +1 -0
  72. package/lib/managers/shared-items.d.ts +33 -0
  73. package/lib/managers/shared-items.js +54 -62
  74. package/lib/managers/shared-items.js.map +1 -0
  75. package/lib/managers/storage-policies.d.ts +86 -0
  76. package/lib/managers/storage-policies.js +108 -142
  77. package/lib/managers/storage-policies.js.map +1 -0
  78. package/lib/managers/tasks.d.ts +161 -0
  79. package/lib/managers/tasks.js +219 -260
  80. package/lib/managers/tasks.js.map +1 -0
  81. package/lib/managers/terms-of-service.d.ts +161 -0
  82. package/lib/managers/terms-of-service.js +250 -273
  83. package/lib/managers/terms-of-service.js.map +1 -0
  84. package/lib/managers/trash.d.ts +30 -0
  85. package/lib/managers/trash.js +30 -41
  86. package/lib/managers/trash.js.map +1 -0
  87. package/lib/managers/users.d.ts +130 -0
  88. package/lib/managers/users.js +160 -203
  89. package/lib/managers/users.js.map +1 -0
  90. package/lib/managers/web-links.d.ts +127 -0
  91. package/lib/managers/web-links.js +183 -209
  92. package/lib/managers/web-links.js.map +1 -0
  93. package/lib/managers/webhooks.d.ts +166 -0
  94. package/lib/managers/webhooks.js +312 -305
  95. package/lib/managers/webhooks.js.map +1 -0
  96. package/lib/sessions/anonymous-session.d.ts +69 -0
  97. package/lib/sessions/anonymous-session.js +88 -102
  98. package/lib/sessions/anonymous-session.js.map +1 -0
  99. package/lib/sessions/app-auth-session.d.ts +92 -0
  100. package/lib/sessions/app-auth-session.js +140 -160
  101. package/lib/sessions/app-auth-session.js.map +1 -0
  102. package/lib/sessions/basic-session.d.ts +56 -0
  103. package/lib/sessions/basic-session.js +40 -50
  104. package/lib/sessions/basic-session.js.map +1 -0
  105. package/lib/sessions/persistent-session.d.ts +96 -0
  106. package/lib/sessions/persistent-session.js +191 -211
  107. package/lib/sessions/persistent-session.js.map +1 -0
  108. package/lib/token-manager.d.ts +191 -0
  109. package/lib/token-manager.js +390 -465
  110. package/lib/token-manager.js.map +1 -0
  111. package/lib/util/config.d.ts +86 -0
  112. package/lib/util/config.js +146 -152
  113. package/lib/util/config.js.map +1 -0
  114. package/lib/util/errors.d.ts +50 -0
  115. package/lib/util/errors.js +134 -145
  116. package/lib/util/errors.js.map +1 -0
  117. package/lib/util/exponential-backoff.d.ts +11 -0
  118. package/lib/util/exponential-backoff.js +10 -22
  119. package/lib/util/exponential-backoff.js.map +1 -0
  120. package/lib/util/paging-iterator.d.ts +53 -0
  121. package/lib/util/paging-iterator.js +202 -218
  122. package/lib/util/paging-iterator.js.map +1 -0
  123. package/lib/util/url-path.d.ts +16 -0
  124. package/lib/util/url-path.js +20 -35
  125. package/lib/util/url-path.js.map +1 -0
  126. package/package.json +14 -3
@@ -0,0 +1,773 @@
1
+ /**
2
+ * @fileoverview Manager for the Box Files Resource
3
+ */
4
+ /// <reference types="node" />
5
+ import { Readable, Writable } from 'stream';
6
+ import BoxClient from '../box-client';
7
+ /**
8
+ * Enum of valid x-rep- hint values for generating representation info
9
+ *
10
+ * @readonly
11
+ * @enum {FileRepresentationType}
12
+ */
13
+ declare enum FileRepresentationType {
14
+ PDF = "[pdf]",
15
+ THUMBNAIL = "[jpg?dimensions=320x320]",
16
+ IMAGE_MEDIUM = "[jpg?dimensions=1024x1024][png?dimensions=1024x1024]",
17
+ IMAGE_LARGE = "[jpg?dimensions=2048x2048][png?dimensions=2048x2048]",
18
+ EXTRACTED_TEXT = "[extracted_text]"
19
+ }
20
+ /**
21
+ * @typedef {Object} UploadPart
22
+ * @property {string} part_id An 8-character hexadecimal string identifying the part
23
+ * @property {int} offset The byte offset of the part within the whole file
24
+ * @property {int} size The size of the part in bytes
25
+ */
26
+ declare type UploadPart = {
27
+ part_id: string;
28
+ offset: number;
29
+ size: number;
30
+ };
31
+ /**
32
+ * Simple manager for interacting with all 'File' endpoints and actions.
33
+ *
34
+ * @param {BoxClient} client The Box API Client that is responsible for making calls to the API
35
+ * @constructor
36
+ */
37
+ declare class Files {
38
+ client: BoxClient;
39
+ representation: typeof FileRepresentationType;
40
+ constructor(client: BoxClient);
41
+ /**
42
+ * Requests a file object with the given ID.
43
+ *
44
+ * API Endpoint: '/files/:fileID'
45
+ * Method: GET
46
+ *
47
+ * @param {string} fileID - Box ID of the file being requested
48
+ * @param {Object} [options] - Additional options for the request. Can be left null in most cases.
49
+ * @param {Function} [callback] - Passed the file information if it was acquired successfully
50
+ * @returns {Promise<Object>} A promise resolving to the file object
51
+ */
52
+ get(fileID: string, options?: Record<string, any>, callback?: Function): any;
53
+ /**
54
+ * Requests a download URL for a given file.
55
+ *
56
+ * API Endpoint: '/files/:fileID/content'
57
+ * Method: GET
58
+ * Special Expected Responses:
59
+ * 202 ACCEPTED - Download isn't available yet. Returns an error.
60
+ * 302 FOUND - Download is available. A Download URL is returned.
61
+ *
62
+ * @param {string} fileID - Box ID of the file being requested
63
+ * @param {Object} [options] - Additional options for the request. Can be left null in most cases.
64
+ * @param {Function} [callback] - Passed the download URL if request was successful.
65
+ * @returns {Promise<string>} A promise resolving to the file's download URL
66
+ */
67
+ getDownloadURL(fileID: string, options?: Record<string, any>, callback?: Function): any;
68
+ /**
69
+ * Requests a Readable Stream for the given file ID.
70
+ *
71
+ * API Endpoint: '/files/:fileID/content'
72
+ * Method: GET
73
+ * Special Expected Responses:
74
+ * 202 ACCEPTED - Download isn't available yet. Returns an error.
75
+ * 302 FOUND - Download is available. A Download stream is returned.
76
+ *
77
+ * @param {string} fileID - Box ID of the file being requested
78
+ * @param {Object} [options] - Additional options for the request. Can be left null in most cases.
79
+ * @param {string} [options.version] - ID of the version of this file to download
80
+ * @param {int[]} [options.byteRange] - starting and ending bytes of the file to read, e.g. [0, 99] to read the first 100 bytes
81
+ * @param {Function} [callback] - passed the readable stream if request was successful
82
+ * @returns {Promise<Readable>} A promise resolving for the file stream
83
+ */
84
+ getReadStream(fileID: string, options?: {
85
+ version?: string;
86
+ byteRange?: number[];
87
+ }, callback?: Function): any;
88
+ /**
89
+ * Requests a Thumbnail for a given file.
90
+ *
91
+ * API Endpoint: '/files/:fileID/thumbnail.png'
92
+ * Method: GET
93
+ * Special Expected Responses:
94
+ * 200 OK - Thumbnail available. Returns a thumbnail file.
95
+ * 202 ACCEPTED - Thumbnail isn't available yet. Returns a `location` URL for a generic placeholder thumbnail.
96
+ * 302 FOUND - Unable to generate thumbnail. Returns a `location` URL for a generic placeholder thumbnail.
97
+ *
98
+ * @param {string} fileID - Box ID of the file being requested
99
+ * @param {Object} [options] - Additional options for the request. Can be left null in most cases.
100
+ * @param {Function} [callback] - Passed the thumbnail file or the URL to a placeholder thumbnail if successful.
101
+ * @returns {Promise<Object>} A promise resolving to the thumbnail information
102
+ * @deprecated use getRepresentationContent() instead
103
+ */
104
+ getThumbnail(fileID: string, options?: Record<string, any>, callback?: Function): any;
105
+ /**
106
+ * Gets the comments on a file.
107
+ *
108
+ * API Endpoint: '/files/:fileID/comments'
109
+ * Method: GET
110
+ *
111
+ * @param {string} fileID - Box file id of the file
112
+ * @param {Object} [options] - Additional options for the request. Can be left null in most cases.
113
+ * @param {Function} [callback] - passed the file comments if they were successfully acquired
114
+ * @returns {Promise<Object>} A promise resolving to the collection of comments
115
+ */
116
+ getComments(fileID: string, options?: Record<string, any>, callback?: Function): any;
117
+ /**
118
+ * Update some information about a given file.
119
+ *
120
+ * API Endpoint: '/files/:fileID'
121
+ * Method: PUT
122
+ *
123
+ * @param {string} fileID - Box ID of the file being requested
124
+ * @param {Object} updates - File fields to update
125
+ * @param {string} [updates.etag] Only apply the updates if the file etag matches
126
+ * @param {Function} [callback] - Passed the updated file information if it was acquired successfully
127
+ * @returns {Promise<Object>} A promise resolving to the update file object
128
+ */
129
+ update(fileID: string, updates: {
130
+ [key: string]: any;
131
+ etag?: string;
132
+ }, callback?: Function): any;
133
+ /**
134
+ * Add a file to a given collection
135
+ *
136
+ * API Endpoint: '/files/:fileID'
137
+ * Method: PUT
138
+ *
139
+ * @param {string} fileID - The file to add to the collection
140
+ * @param {string} collectionID - The collection to add the file to
141
+ * @param {Function} [callback] - Passed the updated file if successful, error otherwise
142
+ * @returns {Promise<Object>} A promise resolving to the updated file object
143
+ */
144
+ addToCollection(fileID: string, collectionID: string, callback?: Function): any;
145
+ /**
146
+ * Remove a file from a given collection
147
+ *
148
+ * API Endpoint: '/files/:fileID'
149
+ * Method: PUT
150
+ *
151
+ * @param {string} fileID - The file to remove from the collection
152
+ * @param {string} collectionID - The collection to remove the file from
153
+ * @param {Function} [callback] - Passed the updated file if successful, error otherwise
154
+ * @returns {Promise<Object>} A promise resolving to the updated file object
155
+ */
156
+ removeFromCollection(fileID: string, collectionID: string, callback?: Function): any;
157
+ /**
158
+ * Move a file into a new parent folder.
159
+ *
160
+ * API Endpoint: '/files/:fileID'
161
+ * Method: PUT
162
+ *
163
+ * @param {string} fileID - The Box ID of the file being requested
164
+ * @param {string} newParentID - The Box ID for the new parent folder. '0' to move to All Files.
165
+ * @param {Function} [callback] - Passed the updated file information if it was acquired successfully
166
+ * @returns {Promise<Object>} A promise resolving to the updated file object
167
+ */
168
+ move(fileID: string, newParentID: string, callback?: Function): any;
169
+ /**
170
+ * Copy a file into a new folder.
171
+ *
172
+ * API Endpoint: '/files/:fileID/copy
173
+ * Method: POST
174
+ *
175
+ * @param {string} fileID - The Box ID of the file being requested
176
+ * @param {string} newParentID - The Box ID for the new parent folder. '0' to copy to All Files.
177
+ * @param {Object} [options] - Optional parameters for the copy operation, can be left null in most cases
178
+ * @param {string} [options.name] - A new name to use if there is an identically-named item in the new parent folder
179
+ * @param {Function} [callback] - passed the new file info if call was successful
180
+ * @returns {Promise<Object>} A promise resolving to the new file object
181
+ */
182
+ copy(fileID: string, newParentID: string, options?: {
183
+ name?: string;
184
+ } | Function, callback?: Function): any;
185
+ /**
186
+ * Delete a given file.
187
+ *
188
+ * API Endpoint: '/files/:fileID'
189
+ * Method: DELETE
190
+ *
191
+ * @param {string} fileID - Box ID of the file being requested
192
+ * @param {Object} [options] Optional parameters
193
+ * @param {string} [options.etag] Only delete the file if the etag value matches
194
+ * @param {Function} [callback] - Empty response body passed if successful.
195
+ * @returns {Promise<void>} A promise resolving to nothing
196
+ */
197
+ delete(fileID: string, options?: {
198
+ [key: string]: any;
199
+ etag?: string;
200
+ } | Function, callback?: Function): any;
201
+ /**
202
+ * Get preflight information for a new file upload. Without any file data,
203
+ * this will return an upload URL and token to be used when uploading the file.
204
+ * Using this upload URL will allow for the fastest upload, and the one-time
205
+ * token can be passed to a worker or other client to actually perform the
206
+ * upload with. If file data (e.g. size, parent, name) is passed, it will be
207
+ * validated as if the actual file were being uploaded. This enables checking
208
+ * of preconditions such as name uniqueness and available storage space before
209
+ * attempting a large file upload.
210
+ *
211
+ * API Endpoint: '/files/content'
212
+ * Method: OPTIONS
213
+ *
214
+ * @param {string} parentFolderID - The id of the parent folder to upload to
215
+ * @param {Object} [fileData] - Optional data about the file to be uploaded
216
+ * @param {Object} [options] - Additional options for the request. Can be left null in most cases.
217
+ * @param {Function} [callback] - Called with upload data if successful, or err if the upload would not succeed
218
+ * @returns {Promise<Object>} A promise resolving to the upload data
219
+ */
220
+ preflightUploadFile(parentFolderID: string, fileData?: Record<string, any>, options?: Record<string, any>, callback?: Function): any;
221
+ /**
222
+ * Get preflight information for a file version upload. Without any file data,
223
+ * this will return an upload URL and token to be used when uploading the file.
224
+ * Using this upload URL will allow for the fastest upload, and the one-time
225
+ * token can be passed to a worker or other client to actually perform the
226
+ * upload with. If file data (e.g. size, parent, name) is passed, it will be
227
+ * validated as if the actual file were being uploaded. This enables checking
228
+ * of preconditions such as name uniqueness and available storage space before
229
+ * attempting a large file upload.
230
+ *
231
+ * API Endpoint: '/files/:fileID/content'
232
+ * Method: OPTIONS
233
+ *
234
+ * @param {string} fileID - The file ID to which a new version will be uploaded
235
+ * @param {Object} [fileData] - Optional data about the file to be uploaded
236
+ * @param {Object} [options] - Additional options for the request. Can be left null in most cases.
237
+ * @param {Function} [callback] - Called with upload data if successful, or err if the upload would not succeed
238
+ * @returns {Promise<Object>} A promise resolving to the upload data
239
+ */
240
+ preflightUploadNewFileVersion(fileID: string, fileData?: Record<string, any>, options?: Record<string, any>, callback?: Function): any;
241
+ /**
242
+ * If there are previous versions of this file, this method can be used to promote one of the older
243
+ * versions to the top of the stack. This actually mints a copy of the old version and puts it on
244
+ * the top of the versions stack. The file will have the exact same contents, the same SHA1/etag,
245
+ * and the same name as the original. Other properties such as comments do not get updated to their former values.
246
+ *
247
+ * API Endpoint: '/files/:fileID/versions/current'
248
+ * Method: POST
249
+ *
250
+ * @param {string} fileID - The file ID which version will be promoted
251
+ * @param {string} versionID - The ID of the file_version that you want to make current
252
+ * @param {Function} [callback] - Passed the promoted file version information if successful, error otherwise
253
+ * @returns {Promise<Object>} A promise resolving to the promoted file version
254
+ */
255
+ promoteVersion(fileID: string, versionID: string, callback?: Function): any;
256
+ /**
257
+ * Uploads a new file. Unlike non-upload methods, this method will not perform any retries.
258
+ * This method currently does not support any optional parameters such as contentModifiedAt.
259
+ *
260
+ * API Endpoint: '/files/content'
261
+ * Method: POST
262
+ *
263
+ * @param {string} parentFolderID - the id of the parent folder to upload to
264
+ * @param {string} filename - the file name that the uploaded file should have
265
+ * @param {string|Buffer|ReadStream} content - the content of the file. It can be a string, a Buffer, or a read stream
266
+ * (like that returned by fs.createReadStream()).
267
+ * @param {Object} [options] - Optional parameters
268
+ * @param {string} [options.content_created_at] - RFC 3339 timestamp when the file was created
269
+ * @param {string} [options.content_modified_at] - RFC 3339 timestamp when the file was last modified
270
+ * @param {int} [options.content_length] - Optional length of the content. Required if content is a read stream of any type other than fs stream.
271
+ * @param {Function} [callback] - called with data about the upload if successful, or an error if the
272
+ * upload failed
273
+ * @returns {Promise<Object>} A promise resolving to the uploaded file
274
+ */
275
+ uploadFile(parentFolderID: string, filename: string, content: string | Buffer | Readable, options?: {
276
+ content_created_at?: string;
277
+ content_modified_at?: string;
278
+ content_length?: number;
279
+ } | Function, callback?: Function): any;
280
+ /**
281
+ * Uploads a new version of a file. Unlike non-upload methods, this method will not perform any retries.
282
+ * This method currently does not support any optional parameters such as contentModifiedAt.
283
+ *
284
+ * API Endpoint: '/files/:fileID/content'
285
+ * Method: POST
286
+ *
287
+ * @param {string} fileID - the id of the file to upload a new version of
288
+ * @param {string|Buffer|Stream} content - the content of the file. It can be a string, a Buffer, or a read stream
289
+ * (like that returned by fs.createReadStream()).
290
+ * @param {Object} [options] - Optional parameters
291
+ * @param {string} [options.content_modified_at] - RFC 3339 timestamp when the file was last modified
292
+ * @param {string} [options.name] - A new name for the file
293
+ * @param {int} [options.content_length] - Optional length of the content. Required if content is a read stream of any type other than fs stream.
294
+ * @param {Function} [callback] - called with data about the upload if successful, or an error if the
295
+ * upload failed
296
+ * @returns {Promise<Object>} A promise resolving to the uploaded file
297
+ */
298
+ uploadNewFileVersion(fileID: string, content: string | Buffer | Readable, options?: {
299
+ content_modified_at?: string;
300
+ name?: string;
301
+ content_length?: number;
302
+ } | Function, callback?: Function): any;
303
+ /**
304
+ * Retrieves all metadata associated with a file.
305
+ *
306
+ * API Endpoint: '/files/:fileID/metadata'
307
+ * Method: GET
308
+ *
309
+ * @param {string} fileID - the ID of the file to get metadata for
310
+ * @param {Function} [callback] - called with an array of metadata when successful
311
+ * @returns {Promise<Object>} A promise resolving to a collection of metadata on the file
312
+ */
313
+ getAllMetadata(fileID: string, callback?: Function): any;
314
+ /**
315
+ * Retrieve a single metadata template instance for a file.
316
+ *
317
+ * API Endpoint: '/files/:fileID/metadata/:scope/:template'
318
+ * Method: GET
319
+ *
320
+ * @param {string} fileID - The ID of the file to retrive the metadata of
321
+ * @param {string} scope - The scope of the metadata template, e.g. "global"
322
+ * @param {string} template - The metadata template to retrieve
323
+ * @param {Function} [callback] - Passed the metadata template if successful
324
+ * @returns {Promise<Object>} A promise resolving to the metadata template
325
+ */
326
+ getMetadata(fileID: string, scope: string, template: string, callback?: Function): any;
327
+ /**
328
+ * Adds metadata to a file. Metadata must either match a template schema or
329
+ * be placed into the unstructured "properties" template in global scope.
330
+ *
331
+ * API Endpoint: '/files/:fileID/metadata/:scope/:template'
332
+ * Method: POST
333
+ *
334
+ * @param {string} fileID - The ID of the file to add metadata to
335
+ * @param {string} scope - The scope of the metadata template, e.g. "enterprise"
336
+ * @param {string} template - The metadata template schema to add
337
+ * @param {Object} data - Key/value pairs tp add as metadata
338
+ * @param {Function} [callback] - Called with error if unsuccessful
339
+ * @returns {Promise<Object>} A promise resolving to the new metadata
340
+ */
341
+ addMetadata(fileID: string, scope: string, template: string, data: Record<string, any>, callback?: Function): any;
342
+ /**
343
+ * Updates a metadata template instance with JSON Patch-formatted data.
344
+ *
345
+ * API Endpoint: '/files/:fileID/metadata/:scope/:template'
346
+ * Method: PUT
347
+ *
348
+ * @param {string} fileID - The file to update metadata for
349
+ * @param {string} scope - The scope of the template to update
350
+ * @param {string} template - The template to update
351
+ * @param {Object} patch - The patch data
352
+ * @param {Function} [callback] - Called with updated metadata if successful
353
+ * @returns {Promise<Object>} A promise resolving to the updated metadata
354
+ */
355
+ updateMetadata(fileID: string, scope: string, template: string, patch: Record<string, any>, callback?: Function): any;
356
+ /**
357
+ * Sets metadata on a file, overwriting any metadata that exists for the provided keys.
358
+ *
359
+ * @param {string} fileID - The file to set metadata on
360
+ * @param {string} scope - The scope of the metadata template
361
+ * @param {string} template - The key of the metadata template
362
+ * @param {Object} metadata - The metadata to set
363
+ * @param {Function} [callback] - Called with updated metadata if successful
364
+ * @returns {Promise<Object>} A promise resolving to the updated metadata
365
+ */
366
+ setMetadata(fileID: string, scope: string, template: string, metadata: Record<string, any>, callback?: Function): any;
367
+ /**
368
+ * Deletes a metadata template from a file.
369
+ *
370
+ * API Endpoint: '/files/:fileID/metadata/:scope/:template'
371
+ * Method: DELETE
372
+ *
373
+ * @param {string} fileID - The ID of the file to remove metadata from
374
+ * @param {string} scope - The scope of the metadata template
375
+ * @param {string} template - The template to remove from the file
376
+ * @param {Function} [callback] - Called with nothing if successful, error otherwise
377
+ * @returns {Promise<void>} A promise resolving to nothing
378
+ */
379
+ deleteMetadata(fileID: string, scope: string, template: string, callback?: Function): any;
380
+ /**
381
+ * Permanently deletes an item that is in the trash. The item will no longer exist in Box. This action cannot be undone.
382
+ *
383
+ * API Endpoint: '/files/:fileID/trash'
384
+ * Method: DELETE
385
+ *
386
+ * @param {string} fileID - The ID of the file to remove metadata from
387
+ * @param {Object} [options] Optional parameters
388
+ * @param {string} [options.etag] Only delete the file if the etag matches
389
+ * @param {Function} [callback] - Called with nothing if successful, error otherwise
390
+ * @returns {Promise<void>} A promise resolving to nothing
391
+ */
392
+ deletePermanently(fileID: string, options?: {
393
+ [key: string]: any;
394
+ etag?: string;
395
+ } | Function, callback?: Function): any;
396
+ /**
397
+ * Retrieves a file that has been moved to the trash.
398
+ *
399
+ * API Endpoint: '/files/:fileID/trash'
400
+ * Method: GET
401
+ *
402
+ * @param {string} fileID - The ID of the file being requested
403
+ * @param {Object} [options] - Additional options for the request. Can be left null in most cases.
404
+ * @param {Function} [callback] - Passed the trashed file information if successful, error otherwise
405
+ * @returns {Promise<Object>} A promise resolving to the trashed file
406
+ */
407
+ getTrashedFile(fileID: string, options?: Record<string, any>, callback?: Function): any;
408
+ /**
409
+ * Retrieves all of the tasks for given file.
410
+ *
411
+ * API Endpoint: '/files/:fileID/tasks'
412
+ * Method: GET
413
+ *
414
+ * @param {string} fileID - The ID of the file to get tasks for
415
+ * @param {Object} [options] - Additional options for the request. Can be left null in most cases.
416
+ * @param {Function} [callback] - Passed the file tasks if successful, error otherwise
417
+ * @returns {Promise<Object>} A promise resolving to a collections of tasks on the file
418
+ */
419
+ getTasks(fileID: string, options?: Record<string, any>, callback?: Function): any;
420
+ /**
421
+ * Used to retrieve an expiring URL for creating an embedded preview session.
422
+ * The URL will expire after 60 seconds and the preview session will expire after 60 minutes.
423
+ *
424
+ * API Endpoint: '/files/:fileID?fields=expiring_embed_link'
425
+ * Method: GET
426
+ *
427
+ * @param {string} fileID - The ID of the file to generate embed link for
428
+ * @param {Function} [callback] - Passed with the embed link if successful, error otherwise
429
+ * @returns {Promise<string>} A promise resolving to the file embed link URL
430
+ */
431
+ getEmbedLink(fileID: string, callback?: Function): any;
432
+ /**
433
+ * Locks a file.
434
+ *
435
+ * API Endpoint: '/files/:fileID'
436
+ * Method: PUT
437
+ *
438
+ * @param {string} fileID - The ID of the file to lock
439
+ * @param {Object} [options] - Optional parameters, can be left null in most cases
440
+ * @param {?string} [options.expires_at] - The time the lock expires
441
+ * @param {boolean} [options.is_download_prevented] - Whether or not the file can be downloaded while locked
442
+ * @param {Function} [callback] - Passed with the locked file information if successful, error otherwise
443
+ * @returns {Promise<Object>} A promise resolving to the locked file object
444
+ */
445
+ lock(fileID: string, options?: {
446
+ expires_at?: string;
447
+ is_download_prevented?: boolean;
448
+ }, callback?: Function): any;
449
+ /**
450
+ * Unlocks a file.
451
+ *
452
+ * API Endpoint: '/files/:fileID'
453
+ * Method: PUT
454
+ *
455
+ * @param {string} fileID - The ID of the file to unlock
456
+ * @param {Function} [callback] - Passed with the unlocked file information if successful, error otherwise
457
+ * @returns {Promise<Object>} A promise resolving to the unlocked file object
458
+ */
459
+ unlock(fileID: string, callback?: Function): any;
460
+ /**
461
+ * Restores an item that has been moved to the trash. Default behavior is to
462
+ * restore the item to the folder it was in before it was moved to the trash.
463
+ * If that parent folder no longer exists or if there is now an item with the
464
+ * same name in that parent folder, the new parent folder and/or new name will
465
+ * need to be included in the request.
466
+ *
467
+ * API Endpoint: '/files/:fileID'
468
+ * Method: POST
469
+ *
470
+ * @param {string} fileID - The ID of the file to restore
471
+ * @param {Object} [options] - Optional parameters, can be left null in most cases
472
+ * @param {string} [options.name] - The new name for this item
473
+ * @param {string} [options.parent_id] - The new parent folder for this item
474
+ * @param {Function} [callback] - Called with item information if successful, error otherwise
475
+ * @returns {Promise<Object>} A promise resolving to the restored file object
476
+ */
477
+ restoreFromTrash(fileID: string, options?: {
478
+ name?: string;
479
+ parent_id?: string;
480
+ }, callback?: Function): any;
481
+ /**
482
+ * If there are previous versions of this file, this method can be used to retrieve information
483
+ * about the older versions.
484
+ *
485
+ * API Endpoint: '/files/:fileID/versions'
486
+ * Method: GET
487
+ *
488
+ * @param {string} fileID - The ID of the file to view version for
489
+ * @param {Object} [options] - Additional options for the request. Can be left null in most cases.
490
+ * @param {Function} [callback] - Passed a list of previous file versions if successful, error otherwise
491
+ * @returns {Promise<Object>} A promise resolving to the collection of file versions
492
+ */
493
+ getVersions(fileID: string, options?: Record<string, any>, callback?: Function): any;
494
+ /**
495
+ * Used to retrieve the watermark for a corresponding Box file.
496
+ *
497
+ * API Endpoint: '/files/:fileID/watermark'
498
+ * Method: GET
499
+ *
500
+ * @param {string} fileID - The Box ID of the file to get watermark for
501
+ * @param {Object} [options] - Additional options for the request. Can be left null in most cases.
502
+ * @param {Function} [callback] - Passed the watermark information if successful, error otherwise
503
+ * @returns {Promise<Object>} A promise resolving to the watermark info
504
+ */
505
+ getWatermark(fileID: string, options?: Record<string, any>, callback?: Function): any;
506
+ /**
507
+ * Used to apply or update the watermark for a corresponding Box file.
508
+ *
509
+ * API Endpoint: '/files/:fileID/watermark'
510
+ * Method: PUT
511
+ *
512
+ * @param {string} fileID - The Box ID of the file to update watermark for
513
+ * @param {Object} [options] - Optional parameters, can be left null
514
+ * @param {Function} [callback] - Passed the watermark information if successful, error otherwise
515
+ * @returns {Promise<Object>} A promise resolving to the watermark info
516
+ */
517
+ applyWatermark(fileID: string, options?: Record<string, any>, callback?: Function): any;
518
+ /**
519
+ * Used to remove the watermark for a corresponding Box file.
520
+ *
521
+ * API Endpoint: '/files/:fileID/watermark'
522
+ * Method: DELETE
523
+ *
524
+ * @param {string} fileID - The Box ID of the file to remove watermark from
525
+ * @param {Function} [callback] - Empty response body passed if successful, error otherwise
526
+ * @returns {Promise<void>} A promise resolving to nothing
527
+ */
528
+ removeWatermark(fileID: string, callback: Function): any;
529
+ /**
530
+ * Discards a specific file version to the trash. Depending on the enterprise settings
531
+ * for this user, the item will either be actually deleted from Box or moved to the trash.
532
+ *
533
+ * API Endpoint: '/files/:fileID/version/:versionID'
534
+ * Method: DELETE
535
+ *
536
+ * @param {string} fileID - The file ID which old version will be moved to the trash or delete permanently
537
+ * @param {string} versionID - The ID of the version to move to the trash or delete permanently
538
+ * @param {Object} [options] Optional parameters
539
+ * @param {string} [options.etag] Only delete the version of the file etag matches
540
+ * @param {Function} [callback] - Empty response body, error otherwise
541
+ * @returns {Promise<void>} A promise resolving to nothing
542
+ */
543
+ deleteVersion(fileID: string, versionID: string, options?: {
544
+ [key: string]: any;
545
+ etag?: string;
546
+ } | Function, callback?: Function): any;
547
+ /**
548
+ * Creates a session used to upload a new file in chunks.. This will first
549
+ * verify that the file can be created and then open a session for uploading
550
+ * pieces of the file.
551
+ *
552
+ * API Endpoint: '/files/upload_sessions'
553
+ * Method: POST
554
+ *
555
+ * @param {string} folderID - The ID of the folder to upload the file to
556
+ * @param {int} size - The size of the file that will be uploaded
557
+ * @param {string} name - The name of the file to be created
558
+ * @param {Function} [callback] - Passed the upload session info if successful
559
+ * @returns {Promise<Object>} A promise resolving to the new upload session object
560
+ */
561
+ createUploadSession(folderID: string, size: number, name: string, callback?: Function): any;
562
+ /**
563
+ * Creates a session used to upload a new version of a file in chunks. This
564
+ * will first verify that the version can be created and then open a session for
565
+ * uploading pieces of the file.
566
+ *
567
+ * API Endpoint: '/files/:fileID/upload_sessions'
568
+ * Method: POST
569
+ *
570
+ * @param {string} fileID - The ID of the file to upload a new version of
571
+ * @param {int} size - The size of the file that will be uploaded
572
+ * @param {Function} [callback] - Passed the upload session info if successful
573
+ * @returns {Promise<Object>} A promise resolving to the new upload session object
574
+ */
575
+ createNewVersionUploadSession(fileID: string, size: number, callback?: Function): any;
576
+ /**
577
+ * Uploads a chunk of a file to an open upload session
578
+ *
579
+ * API Endpoint: '/files/upload_sessions/:sessionID'
580
+ * Method: PUT
581
+ *
582
+ * @param {string} sessionID - The ID of the upload session to upload to
583
+ * @param {Buffer|string} part - The chunk of the file to upload
584
+ * @param {int} offset - The byte position where the chunk begins in the file
585
+ * @param {int} totalSize - The total size of the file being uploaded
586
+ * @param {Function} [callback] - Passed the part definition if successful
587
+ * @returns {Promise<Object>} A promise resolving to the part object
588
+ */
589
+ uploadPart(sessionID: string, part: Buffer | string, offset: number, totalSize: number, callback?: Function): any;
590
+ /**
591
+ * Commit an upload session after all parts have been uploaded, creating the new file
592
+ *
593
+ * API Endpoint: '/files/upload_sessions/:sessionID/commit'
594
+ * Method: POST
595
+ *
596
+ * @param {string} sessionID - The ID of the upload session to commit
597
+ * @param {string} fileHash - The base64-encoded SHA-1 hash of the file being uploaded
598
+ * @param {Object} [options] - Optional parameters set on the created file, can be left null
599
+ * @param {UploadPart[]} [options.parts] The list of uploaded parts to be committed, will be fetched from the API otherwise
600
+ * @param {Function} [callback] - Passed the new file information if successful
601
+ * @returns {Promise<Object>} A promise resolving to the uploaded file object
602
+ */
603
+ commitUploadSession(sessionID: string, fileHash: string, options?: {
604
+ parts?: UploadPart[];
605
+ }, callback?: Function): any;
606
+ /**
607
+ * Abort an upload session, discarding any chunks that were uploaded to it
608
+ *
609
+ * API Endpoint: '/files/upload_sessions/:sessionID'
610
+ * Method: DELETE
611
+ *
612
+ * @param {string} sessionID - The ID of the upload session to commit
613
+ * @param {Function} [callback] - Passed nothing if successful, error otherwise
614
+ * @returns {Promise<void>} A promise resolving to nothing
615
+ */
616
+ abortUploadSession(sessionID: string, callback?: Function): any;
617
+ /**
618
+ * Get a list of all parts that have been uploaded to an upload session
619
+ *
620
+ * API Endpoint: '/files/upload_sessions/:sessionID/parts'
621
+ * Method: GET
622
+ *
623
+ * @param {string} sessionID - The ID of the session to get a list of parts from
624
+ * @param {Object} [options] - Optional parameters, can be left null
625
+ * @param {string} [options.offset] - Paging offset for the list of parts
626
+ * @param {int} [options.limit] - Maximum number of parts to return
627
+ * @param {Function} [callback] - Passed the list of parts if successful
628
+ * @returns {Promise<Object>} A promise resolving to the collection of uploaded parts
629
+ */
630
+ getUploadSessionParts(sessionID: string, options?: {
631
+ offset?: string;
632
+ limit?: number;
633
+ }, callback?: Function): any;
634
+ /**
635
+ * Get the status of an upload session, e.g. whether or not is has started or
636
+ * finished committing
637
+ *
638
+ * API Endpoint: '/files/upload_sessions/:sessionID'
639
+ * Method: GET
640
+ *
641
+ * @param {string} sessionID - The ID of the upload session to get the status of
642
+ * @param {Function} [callback] - Passed the session status if successful
643
+ * @returns {Promise<Object>} A promise resolving to the upload session object
644
+ */
645
+ getUploadSession(sessionID: string, callback?: Function): any;
646
+ /**
647
+ * Upload a file in chunks, which is generally faster and more reliable for
648
+ * large files.
649
+ *
650
+ * API Endpoint: '/files/upload_sessions'
651
+ * Method: POST
652
+ *
653
+ * @param {string} folderID - The ID of the folder to upload the file to
654
+ * @param {int} size - The size of the file that will be uploaded
655
+ * @param {string} name - The name of the file to be created
656
+ * @param {Buffer|string|Readable} file - The file to upload
657
+ * @param {Object} [options] - Optional parameters for the upload
658
+ * @param {int} [options.parallelism] The number of chunks to upload concurrently
659
+ * @param {int} [options.retryInterval] The amount of time to wait before retrying a failed chunk upload, in ms
660
+ * @param {Object} [options.fileAttributes] Attributes to set on the newly-uploaded file
661
+ * @param {Function} [callback] - Passed the uploader if successful
662
+ * @returns {Promise<ChunkedUploader>} A promise resolving to the chunked uploader
663
+ */
664
+ getChunkedUploader(folderID: string, size: number, name: string, file: Buffer | string | Readable, options?: {
665
+ parallelism?: number;
666
+ retryInterval?: number;
667
+ fileAttributes?: Record<string, any>;
668
+ }, callback?: Function): any;
669
+ /**
670
+ * Upload a new file version in chunks, which is generally faster and more
671
+ * reliable for large files.
672
+ *
673
+ * API Endpoint: '/files/:fileID/upload_sessions'
674
+ * Method: POST
675
+ *
676
+ * @param {string} fileID - The ID of the file to upload a new version of
677
+ * @param {int} size - The size of the file that will be uploaded
678
+ * @param {Buffer|string|Readable} file - The file to upload
679
+ * @param {Object} [options] - Optional parameters for the upload
680
+ * @param {int} [options.parallelism] The number of chunks to upload concurrently
681
+ * @param {int} [options.retryInterval] The amount of time to wait before retrying a failed chunk upload, in ms
682
+ * @param {Object} [options.fileAttributes] Attributes to set on the updated file object
683
+ * @param {Function} [callback] - Passed the uploader if successful
684
+ * @returns {Promise<ChunkedUploader>} A promise resolving to the chunked uploader
685
+ */
686
+ getNewVersionChunkedUploader(fileID: string, size: number, file: Buffer | string | Readable, options?: {
687
+ parallelism?: number;
688
+ retryInterval?: number;
689
+ fileAttributes?: Record<string, any>;
690
+ }, callback?: Function): any;
691
+ /**
692
+ * Requests collaborations on a given file.
693
+ *
694
+ * API Endpoint: '/files/:fileID/collaborations'
695
+ * Method: GET
696
+ *
697
+ * @param {string} fileID - Box ID of the file being requested
698
+ * @param {Object} [options] - Additional options. Can be left null in most cases.
699
+ * @param {int} [options.limit] - The maximum number of collaborations to return
700
+ * @param {int} [options.offset] - Paging parameter for the collaborations collection
701
+ * @param {string} [options.fields] - Comma-separated list of fields to return on the collaboration objects
702
+ * @param {Function} [callback] - Passed the collaborations if successful, error otherwise
703
+ * @returns {Promise<Object>} A promise resolving to the collection of collaborations on the file
704
+ */
705
+ getCollaborations(fileID: string, options?: {
706
+ limit?: number;
707
+ offset?: number;
708
+ fields?: string;
709
+ }, callback?: Function): any;
710
+ /**
711
+ * Requests information for all representation objects generated for a specific Box file
712
+ *
713
+ * API Endpoint: '/files/:fileID?fields=representations'
714
+ * Method : GET
715
+ *
716
+ * @param {string} fileID - Box ID of the file being requested
717
+ * @param {client.files.representation} representationType - The x-rep-hints value the application should create a
718
+ * representation for. This value can either come from FileRepresentationType enum or manually created
719
+ * @param {Object} [options] - Additional options. Can be left empty
720
+ * @param {boolean} [options.generateRepresentations = false] - Set to true to return representation info where all states resolve to success.
721
+ * @param {Function} [callback] - Passed an array of representaton objects if successful
722
+ * @returns {Promise<Object>} A promise resolving to the representation response objects
723
+ */
724
+ getRepresentationInfo(fileID: string, representationType: FileRepresentationType, options?: {
725
+ generateRepresentations?: boolean;
726
+ } | Function, callback?: Function): any;
727
+ /**
728
+ * Get the contents of a representation of a file, e.g, the binary content of an image or pdf.
729
+ *
730
+ * API Endpoint: '/files/:fileID?fields=representations'
731
+ * Method : GET
732
+ *
733
+ * @param {string} fileID The file ID to get the representation of
734
+ * @param {string} representationType The X-Rep-Hints type to request
735
+ * @param {Object} [options] Optional parameters
736
+ * @param {string} [options.assetPath] Asset path for representations with multiple files
737
+ * @param {Function} [callback] Passed a stream over the representation contents if successful
738
+ * @returns {Promise<Readable>} A promise resolving to a stream over the representation contents
739
+ */
740
+ getRepresentationContent(fileID: string, representationType: FileRepresentationType, options?: {
741
+ assetPath?: string;
742
+ }, callback?: Function): any;
743
+ /**
744
+ * Creates a zip of multiple files and folders.
745
+ *
746
+ * API Endpoint: '/zip_downloads'
747
+ * Method: POST
748
+ *
749
+ * @param {name} name - The name of the zip file to be created
750
+ * @param {Array} items - Array of files or folders to be part of the created zip
751
+ * @param {Function} [callback] Passed a zip information object
752
+ * @returns {Promise<string>} A promise resolving to a zip information object
753
+ */
754
+ createZip(name: string, items: any[], callback?: Function): any;
755
+ /**
756
+ * Creates a zip of multiple files and folders and downloads it.
757
+ *
758
+ * API Endpoint: '/zip_downloads'
759
+ * Method: GET
760
+ *
761
+ * @param {name} name - The name of the zip file to be created
762
+ * @param {Array} items - Array of files or folders to be part of the created zip
763
+ * @param {Stream} stream - Stream to pipe the readable stream of the zip file
764
+ * @param {Function} [callback] - Passed a zip download status object
765
+ * @returns {Promise<Readable>} A promise resolving to a zip download status object
766
+ */
767
+ downloadZip(name: string, items: any[], stream: Writable, callback?: Function): any;
768
+ }
769
+ /**
770
+ * @module box-node-sdk/lib/managers/files
771
+ * @see {@Link Files}
772
+ */
773
+ export = Files;