box-node-sdk 1.35.0 → 1.37.2

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