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,269 @@
1
+ /**
2
+ * @fileoverview Box API Client
3
+ */
4
+ /**
5
+ * A collaboration role constant
6
+ * @typedef {string} CollaborationRole
7
+ */
8
+ declare type CollaborationRole = string;
9
+ /**
10
+ * A Box file or folder type constant
11
+ * @typedef {string} ItemType
12
+ */
13
+ declare type ItemType = 'file' | 'folder';
14
+ /**
15
+ * An access level constant. Used for setting and updating shared links, folder upload, etc.
16
+ * @typedef {?Object} AccessLevel
17
+ */
18
+ declare type AccessLevel = object | null;
19
+ declare type APISession = any;
20
+ declare type APIRequestManager = any;
21
+ declare class BoxClient {
22
+ _session: APISession;
23
+ _requestManager: APIRequestManager;
24
+ _customHeaders: any;
25
+ _baseURL: any;
26
+ _uploadBaseURL: any;
27
+ _uploadRequestTimeoutMS: any;
28
+ _useIterators: any;
29
+ _analyticsClient: any;
30
+ _tokenOptions: any;
31
+ users: any;
32
+ files: any;
33
+ folders: any;
34
+ comments: any;
35
+ collaborations: any;
36
+ groups: any;
37
+ sharedItems: any;
38
+ metadata: any;
39
+ collections: any;
40
+ events: any;
41
+ search: any;
42
+ tasks: any;
43
+ trash: any;
44
+ enterprise: any;
45
+ legalHoldPolicies: any;
46
+ weblinks: any;
47
+ retentionPolicies: any;
48
+ devicePins: any;
49
+ webhooks: any;
50
+ recentItems: any;
51
+ collaborationAllowlist: any;
52
+ termsOfService: any;
53
+ storagePolicies: any;
54
+ _batch: any;
55
+ collaborationRoles: Record<string, CollaborationRole>;
56
+ itemTypes: Record<string, ItemType>;
57
+ accessLevels: Record<string, AccessLevel>;
58
+ CURRENT_USER_ID: string;
59
+ /** @deprecated */
60
+ collaborationWhitelist: any;
61
+ /**
62
+ * The BoxClient can make API calls on behalf of a valid API Session. It is responsible
63
+ * for formatting the requests and handling the response. Its goal is to deliver
64
+ * sensible results to the user.
65
+ *
66
+ * @param {APISession} apiSession An initialized API Session, used to get/revoke tokens and handle
67
+ * unauthorized responses from the API.
68
+ * @param {Config} config The SDK configuration options
69
+ * @param {APIRequestManager} requestManager The API Request Manager
70
+ * @constructor
71
+ */
72
+ constructor(apiSession: APISession, config: any, requestManager: APIRequestManager);
73
+ /**
74
+ * Returns an object containing the given headers as well as other headers (like the authorization header and
75
+ * custom headers) that should be included in a request.
76
+ * @param {?Object} callerHeaders - headers that the caller wishes to include in the request. This method will not
77
+ * override these headers with its own. Thus, if all the headers that this method was planning to add are already
78
+ * specified here, this method will return an object with exactly the same headers.
79
+ * @param {string} accessToken - the access token that will be used to make the request
80
+ * @returns {Object} - a new object with the headers needed for the request
81
+ * @private
82
+ */
83
+ _createHeadersForRequest(callerHeaders: object | null, accessToken: string): Record<string, string>;
84
+ /**
85
+ * Makes an API request to the Box API on behalf of the client. Before executing
86
+ * the request, it first ensures the user has usable tokens. Will be called again
87
+ * if the request returns a temporary error. Will propogate error if request returns
88
+ * a permanent error, or if usable tokens are not available.
89
+ *
90
+ * @param {Object} params - Request lib params to configure the request
91
+ * @param {APIRequest~Callback} [callback] - passed response data
92
+ * @returns {Promise} Promise resolving to the response
93
+ * @private
94
+ */
95
+ _makeRequest(params: any, callback?: Function): any;
96
+ /**
97
+ * Set a custom header. A custom header is applied to every request for the life of the client. To
98
+ * remove a header, set it's value to null.
99
+ *
100
+ * @param {string} header The name of the custom header to set.
101
+ * @param {*} value The value of the custom header. Set to null to remove the given header.
102
+ * @returns {void}
103
+ */
104
+ setCustomHeader(header: string, value: any): void;
105
+ /**
106
+ * Sets the list of requesting IP addresses for the X-Forwarded-For header. Used to give the API
107
+ * better information for uploads, rate-limiting, etc.
108
+ *
109
+ * @param {string[]} ips - Array of IP Addresses
110
+ * @returns {void}
111
+ */
112
+ setIPs(ips: string[]): void;
113
+ /**
114
+ * Sets the shared item context on the API Session. Overwrites any current context.
115
+ *
116
+ * @param {string} url The shared link url
117
+ * @param {?string} password The shared link password, null if no password exists.
118
+ * @returns {void}
119
+ */
120
+ setSharedContext(url: string, password: string | null): void;
121
+ /**
122
+ * Removes any current shared item context from API Session.
123
+ *
124
+ * @returns {void}
125
+ */
126
+ revokeSharedContext(): void;
127
+ /**
128
+ * Set up the As-User context, which is used by enterprise admins to
129
+ * impersonate their managed users and perform actions on their behalf.
130
+ *
131
+ * @param {string} userID - The ID of the user to impersonate
132
+ * @returns {void}
133
+ */
134
+ asUser(userID: string): void;
135
+ /**
136
+ * Revoke the As-User context and return to making calls on behalf of the user
137
+ * who owns the client's access token.
138
+ *
139
+ * @returns {void}
140
+ */
141
+ asSelf(): void;
142
+ /**
143
+ * Revokes the client's access tokens. The client will no longer be tied to a user
144
+ * and will be unable to make calls to the API, rendering it effectively useless.
145
+ *
146
+ * @param {Function} [callback] Called after revoking, with an error if one existed
147
+ * @returns {Promise} A promise resolving when the client's access token is revoked
148
+ */
149
+ revokeTokens(callback: Function): any;
150
+ /**
151
+ * Exchange the client access token for one with lower scope
152
+ * @param {string|string[]} scopes The scope(s) requested for the new token
153
+ * @param {string} [resource] The absolute URL of an API resource to scope the new token to
154
+ * @param {Object} [options] - Optional parameters
155
+ * @param {ActorParams} [options.actor] - Optional actor parameters for creating annotator tokens with Token Auth client
156
+ * @param {SharedLinkParams} [options.sharedLink] - Optional shared link parameters for creating tokens using shared links
157
+ * @param {Function} [callback] Called with the new token
158
+ * @returns {Promise<TokenInfo>} A promise resolving to the exchanged token info
159
+ */
160
+ exchangeToken(scopes: string | string[], resource?: string, options?: Function | object, callback?: Function): any;
161
+ /**
162
+ * Makes GET request to Box API V2 endpoint
163
+ *
164
+ * @param {string} path - path to a certain API endpoint (ex: /file)
165
+ * @param {?Object} params - object containing parameters for the request, such as query strings and headers
166
+ * @param {APIRequest~Callback} [callback] - passed final API response or err if request failed
167
+ * @returns {void}
168
+ */
169
+ get(path: string, params?: object | null, callback?: Function): any;
170
+ /**
171
+ * Makes POST request to Box API V2 endpoint
172
+ *
173
+ * @param {string} path - path to a certain API endpoint (ex: /file)
174
+ * @param {?Object} params - object containing parameters for the request, such as query strings and headers
175
+ * @param {APIRequest~Callback} [callback] - passed final API response or err if request failed
176
+ * @returns {void}
177
+ */
178
+ post(path: string, params: object | null, callback?: Function): any;
179
+ /**
180
+ * Makes PUT request to Box API V2 endpoint
181
+ *
182
+ * @param {string} path - path to a certain API endpoint (ex: /file)
183
+ * @param {?Object} params - object containing parameters for the request, such as query strings and headers
184
+ * @param {APIRequest~Callback} callback - passed final API response or err if request failed
185
+ * @returns {void}
186
+ */
187
+ put(path: string, params?: object | null, callback?: Function): any;
188
+ /**
189
+ * Makes DELETE request to Box API V2 endpoint
190
+ *
191
+ * @param {string} path - path to a certain API endpoint (ex: /file)
192
+ * @param {?Object} params - object containing parameters for the request, such as query strings and headers
193
+ * @param {APIRequest~Callback} callback - passed final API response or err if request failed
194
+ * @returns {void}
195
+ */
196
+ del(path: string, params: object | null, callback: Function): any;
197
+ /**
198
+ * Makes an OPTIONS call to a Box API V2 endpoint
199
+ *
200
+ * @param {string} path - Path to an API endpoint (e.g. /files/content)
201
+ * @param {?Object} params - An optional object containing request parameters
202
+ * @param {APIRequest~Callback} callback - Called with API call results, or err if call failed
203
+ * @returns {void}
204
+ */
205
+ options(path: string, params: object | null, callback?: Function): any;
206
+ /**
207
+ * Makes a POST call to a Box API V2 upload endpoint
208
+ * @param {string} path - path to an upload API endpoint
209
+ * @param {?Object} params - an optional object containing request parameters
210
+ * @param {?Object} formData - multipart form data to include in the upload request {@see https://github.com/mikeal/request#multipartform-data-multipart-form-uploads}
211
+ * @param {APIRequest~Callback} callback - called with API call results, or an error if the call failed
212
+ * @returns {void}
213
+ */
214
+ upload(path: string, params: object | null, formData: object | null, callback: Function): any;
215
+ /**
216
+ * Puts the client into batch mode, which will queue calls instead of
217
+ * immediately making the API request.
218
+ *
219
+ * DEPRECATED: Batch API is not supported and should not be used; make calls in parallel instead.
220
+ *
221
+ * @returns {BoxClient} Current client object
222
+ */
223
+ batch: any;
224
+ /**
225
+ * Executes a batch of requests.
226
+ *
227
+ * DEPRECATED: Batch API is not supported and should not be used; make calls in parallel instead.
228
+ *
229
+ * @returns {Promise<Object>} Promise resolving to the collection of batch responses
230
+ */
231
+ batchExec: any;
232
+ /**
233
+ * Build the 'BoxApi' Header used for authenticating access to a shared item
234
+ *
235
+ * @param {string} url The shared link url
236
+ * @param {string} [password] The shared link password
237
+ * @returns {string} A properly formatted 'BoxApi' header
238
+ */
239
+ buildSharedItemAuthHeader(url: string, password: string | null): any;
240
+ /**
241
+ * Return a callback that properly handles a successful response code by passing the response
242
+ * body to the original callback. Any request error or unsuccessful response codes are propagated
243
+ * back to the callback as errors. This is the standard behavior of most endpoints.
244
+ *
245
+ * @param {Function} callback The original callback given by the consumer
246
+ * @returns {?APIRequest~Callback} A new callback that processes the response before passing it to the callback.
247
+ */
248
+ defaultResponseHandler(callback: Function): ((err: any, response: any) => void) | null;
249
+ /**
250
+ * Wrap a client method with the default handler for both callback and promise styles
251
+ * @param {Function} method The client method (e.g. client.get)
252
+ * @returns {Function} The wrapped method
253
+ */
254
+ wrapWithDefaultHandler(method: Function): Function;
255
+ /**
256
+ * Add a SDK plugin. Warning: This will modify the box-client interface and can override existing properties.
257
+ * @param {string} name Plugin name. Will be accessible via client.<plugin-name>
258
+ * @param {Function} plugin The SDK plugin to add
259
+ * @param {Object} [options] Plugin-specific options
260
+ * @returns {void}
261
+ * @throws Will throw an error if plugin name matches an existing method on box-client
262
+ */
263
+ plug(name: string, plugin: Function, options: object): void;
264
+ }
265
+ /**
266
+ * @module box-node-sdk/lib/box-client
267
+ * @see {@Link BoxClient}
268
+ */
269
+ export = BoxClient;