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
package/CHANGELOG.md CHANGED
@@ -1,6 +1,48 @@
1
1
  # Changelog
2
2
 
3
- ## 1.36.0 (2020-01-27)
3
+ ## Next Release
4
+
5
+ ## 1.38.0 (2021-08-05)
6
+
7
+ **New Features and Enhancements:**
8
+
9
+ - Add sensitive-language event types for admin invites ([#648](https://github.com/box/box-node-sdk/pull/648))
10
+ - Use BetterDocs to adapt JSDocs to TypeScript ([#646](https://github.com/box/box-node-sdk/pull/646))
11
+ - Change ProxyAgent import to be dynamic ([#641](https://github.com/box/box-node-sdk/pull/641))
12
+ - New API for get files and file versions under retention ([#585](https://github.com/box/box-node-sdk/pull/585))
13
+
14
+ **Bug Fixes:**
15
+
16
+ - Deeply freeze Config except Buffers and Readable streams ([#651](https://github.com/box/box-node-sdk/pull/651))
17
+ - Fix a typo in docs of src/managers/search.ts ([#649](https://github.com/box/box-node-sdk/pull/649))
18
+ - Update broken documentation link ([#647](https://github.com/box/box-node-sdk/pull/647))
19
+ - fix type annotations for exchangeToken functions ([#645](https://github.com/box/box-node-sdk/pull/645))
20
+ - Deprecate files getThumbnail API in favor of getRepresentationContent ([#627](https://github.com/box/box-node-sdk/pull/627))
21
+
22
+ ## 1.37.2 (2021-05-20)
23
+
24
+ **Bug Fixes:**
25
+
26
+ - Fix backwards compatibility issue by moving some TypeScript @types as direct dependencies ([#630](https://github.com/box/box-node-sdk/pull/630))
27
+
28
+ ## 1.37.1 (2021-05-19)
29
+
30
+ **Bug Fixes:**
31
+
32
+ - Insensitive language: replace whitelist with allowlist ([#625](https://github.com/box/box-node-sdk/pull/625))
33
+
34
+ ## 1.37.0 (2021-04-16)
35
+
36
+ **New Features and Enhancements:**
37
+
38
+ - Add support for copyInstanceOnItemCopy field for metadata templates ([#572](https://github.com/box/box-node-sdk/pull/572))
39
+
40
+ **Bug Fixes:**
41
+
42
+ - Fix webhook signature validation ([#568](https://github.com/box/box-node-sdk/pull/568))
43
+ - Update dependencies to patch security vulnerabilities ([#578](https://github.com/box/box-node-sdk/pull/578))
44
+
45
+ ## 1.36.0 (2021-01-27)
4
46
 
5
47
  **New Features and Enhancements:**
6
48
 
@@ -163,11 +205,11 @@ to specify a client ID and secret (thanks to @cbetta)
163
205
 
164
206
  ## 1.16.0 [2018-04-10]
165
207
 
166
- - Added support for [assigning Retention Policies to Metadata Templates](https://github.com/box/box-node-sdk/blob/master/docs/retention-policies.md#assign-retention-policy)
208
+ - Added support for [assigning Retention Policies to Metadata Templates](https://github.com/box/box-node-sdk/blob/main/docs/retention-policies.md#assign-retention-policy)
167
209
 
168
210
  ## 1.15.0 [2018-03-29]
169
211
 
170
- - Fixed [`client.webhooks.validateMessage() and `sdk.validateWebhookMessage()`](https://github.com/box/box-node-sdk/blob/master/docs/webhooks.md#validate-a-webhook-message)
212
+ - Fixed [`client.webhooks.validateMessage() and `sdk.validateWebhookMessage()`](https://github.com/box/box-node-sdk/blob/main/docs/webhooks.md#validate-a-webhook-message)
171
213
  to accept the request body as an `Object`
172
214
  - Fixed `sdk.configure()` to correct reconfigure all options
173
215
  - Improved error messages for API errors and added the request object as `error.request` for easier debugging
package/README.md CHANGED
@@ -7,6 +7,8 @@ Box Node.js SDK
7
7
 
8
8
  A Node.js interface to the [Box Content API](https://developers.box.com/docs/).
9
9
 
10
+ Getting Started Docs: https://developer.box.com/guides/tooling/sdks/node/
11
+
10
12
  <!-- START doctoc generated TOC please keep comment here to allow auto update -->
11
13
  <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
12
14
 
@@ -184,7 +186,7 @@ client.comments.delete('456')
184
186
 
185
187
  For complete documentation about the available operations, please see
186
188
  the [SDK documentation pages](./docs) and the auto-generated
187
- [JSDocs](https://rawgit.com/box/box-node-sdk/master/docs/jsdoc/index.html).
189
+ [JSDocs](https://rawgit.com/box/box-node-sdk/main/docs/jsdoc/index.html).
188
190
  These contain detailed information about which methods are available and
189
191
  how to use them.
190
192
 
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @fileoverview A library for making requests to the Box API.
3
+ */
4
+ /// <reference types="node" />
5
+ /// <reference types="bluebird" />
6
+ import { EventEmitter } from 'events';
7
+ declare type Config = any;
8
+ /**
9
+ * A library for communicating with the Box API.
10
+ *
11
+ * @param {Config} config SDK configuration object instance.
12
+ * @param {EventEmitter} eventBus The event bus for SDK events
13
+ * @constructor
14
+ */
15
+ declare class APIRequestManager {
16
+ config: Config;
17
+ eventBus: EventEmitter;
18
+ constructor(config: Config, eventBus: EventEmitter);
19
+ /**
20
+ * Make a request to the API, and get the response via callback.
21
+ *
22
+ * @param {Object} options The request options
23
+ * @returns {Promise<Response>} A promise resolving to the response object
24
+ */
25
+ makeRequest(options: any): import("bluebird")<unknown>;
26
+ /**
27
+ * Make a request to the API, and return a read stream for the response.
28
+ *
29
+ * @param {Object} options The request options
30
+ * @returns {Stream.Readable} The response stream
31
+ */
32
+ makeStreamingRequest(options: any): any;
33
+ }
34
+ /**
35
+ * @module box-node-sdk/lib/api-request-manager
36
+ * @see {@Link APIRequestManager}
37
+ */
38
+ export = APIRequestManager;
@@ -1,24 +1,22 @@
1
+ "use strict";
1
2
  /**
2
3
  * @fileoverview A library for making requests to the Box API.
3
4
  */
4
-
5
- 'use strict';
6
-
5
+ var __importDefault = (this && this.__importDefault) || function (mod) {
6
+ return (mod && mod.__esModule) ? mod : { "default": mod };
7
+ };
7
8
  // ------------------------------------------------------------------------------
8
9
  // Requirements
9
10
  // ------------------------------------------------------------------------------
10
- var APIRequest = require('./api-request'),
11
- errors = require('./util/errors'),
12
- Promise = require('bluebird');
13
-
11
+ var bluebird_1 = require("bluebird");
12
+ var errors_1 = __importDefault(require("./util/errors"));
13
+ var APIRequest = require('./api-request');
14
14
  // ------------------------------------------------------------------------------
15
15
  // Private
16
16
  // ------------------------------------------------------------------------------
17
-
18
17
  // ------------------------------------------------------------------------------
19
18
  // Public
20
19
  // ------------------------------------------------------------------------------
21
-
22
20
  /**
23
21
  * A library for communicating with the Box API.
24
22
  *
@@ -26,50 +24,45 @@ var APIRequest = require('./api-request'),
26
24
  * @param {EventEmitter} eventBus The event bus for SDK events
27
25
  * @constructor
28
26
  */
29
- function APIRequestManager(config, eventBus) {
30
-
31
- this.config = config;
32
- this.eventBus = eventBus;
33
- }
34
-
35
- /**
36
- * Make a request to the API, and get the response via callback.
37
- *
38
- * @param {Object} options The request options
39
- * @returns {Promise<Response>} A promise resolving to the response object
40
- */
41
- APIRequestManager.prototype.makeRequest = function(options) {
42
- // Add default APIRequestManager options to each request
43
- var requestConfig = this.config.extend({
44
- request: options
45
- });
46
-
47
- // Make the request
48
- var apiRequest = new APIRequest(requestConfig, this.eventBus);
49
- return Promise.fromCallback(callback => apiRequest.execute(callback))
50
- .catch(err => errors.unwrapAndThrow(err));
51
- };
52
-
53
- /**
54
- * Make a request to the API, and return a read stream for the response.
55
- *
56
- * @param {Object} options The request options
57
- * @returns {Stream.Readable} The response stream
58
- */
59
- APIRequestManager.prototype.makeStreamingRequest = function(options) {
60
- // Add default APIRequestManager options to each request
61
- var requestConfig = this.config.extend({
62
- request: options
63
- });
64
-
65
- // Make the request
66
- var apiRequest = new APIRequest(requestConfig, this.eventBus);
67
- apiRequest.execute();
68
- return apiRequest.getResponseStream();
69
- };
70
-
71
- /**
72
- * @module box-node-sdk/lib/api-request-manager
73
- * @see {@Link APIRequestManager}
74
- */
27
+ var APIRequestManager = /** @class */ (function () {
28
+ function APIRequestManager(config, eventBus) {
29
+ this.config = config;
30
+ this.eventBus = eventBus;
31
+ }
32
+ /**
33
+ * Make a request to the API, and get the response via callback.
34
+ *
35
+ * @param {Object} options The request options
36
+ * @returns {Promise<Response>} A promise resolving to the response object
37
+ */
38
+ APIRequestManager.prototype.makeRequest = function (options /* FIXME */) {
39
+ // Add default APIRequestManager options to each request
40
+ var requestConfig = this.config.extend({
41
+ request: options,
42
+ });
43
+ // Make the request
44
+ var apiRequest = new APIRequest(requestConfig, this.eventBus);
45
+ return bluebird_1.Promise.fromCallback(function (callback) {
46
+ return apiRequest.execute(callback);
47
+ }).catch(function (err) { return errors_1.default.unwrapAndThrow(err); });
48
+ };
49
+ /**
50
+ * Make a request to the API, and return a read stream for the response.
51
+ *
52
+ * @param {Object} options The request options
53
+ * @returns {Stream.Readable} The response stream
54
+ */
55
+ APIRequestManager.prototype.makeStreamingRequest = function (options /* FIXME */) {
56
+ // Add default APIRequestManager options to each request
57
+ var requestConfig = this.config.extend({
58
+ request: options,
59
+ });
60
+ // Make the request
61
+ var apiRequest = new APIRequest(requestConfig, this.eventBus);
62
+ apiRequest.execute();
63
+ return apiRequest.getResponseStream();
64
+ };
65
+ return APIRequestManager;
66
+ }());
75
67
  module.exports = APIRequestManager;
68
+ //# sourceMappingURL=api-request-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-request-manager.js","sourceRoot":"","sources":["../src/api-request-manager.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,iFAAiF;AACjF,eAAe;AACf,iFAAiF;AAEjF,qCAAmC;AAEnC,yDAAmC;AAEnC,IAAM,UAAU,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;AAQ5C,iFAAiF;AACjF,UAAU;AACV,iFAAiF;AAEjF,iFAAiF;AACjF,SAAS;AACT,iFAAiF;AAEjF;;;;;;GAMG;AACH;IAIC,2BAAY,MAAc,EAAE,QAAsB;QACjD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC1B,CAAC;IAED;;;;;OAKG;IACH,uCAAW,GAAX,UAAY,OAAY,CAAC,WAAW;QACnC,wDAAwD;QACxD,IAAI,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;YACtC,OAAO,EAAE,OAAO;SAChB,CAAC,CAAC;QAEH,mBAAmB;QACnB,IAAI,UAAU,GAAG,IAAI,UAAU,CAAC,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC9D,OAAO,kBAAO,CAAC,YAAY,CAAC,UAAC,QAAQ;YACpC,OAAA,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC;QAA5B,CAA4B,CAC5B,CAAC,KAAK,CAAC,UAAC,GAAG,IAAK,OAAA,gBAAM,CAAC,cAAc,CAAC,GAAG,CAAC,EAA1B,CAA0B,CAAC,CAAC;IAC9C,CAAC;IAED;;;;;OAKG;IACH,gDAAoB,GAApB,UAAqB,OAAY,CAAC,WAAW;QAC5C,wDAAwD;QACxD,IAAI,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;YACtC,OAAO,EAAE,OAAO;SAChB,CAAC,CAAC;QAEH,mBAAmB;QACnB,IAAI,UAAU,GAAG,IAAI,UAAU,CAAC,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC9D,UAAU,CAAC,OAAO,EAAE,CAAC;QACrB,OAAO,UAAU,CAAC,iBAAiB,EAAE,CAAC;IACvC,CAAC;IACF,wBAAC;AAAD,CAAC,AA7CD,IA6CC;AAMD,iBAAS,iBAAiB,CAAC"}
@@ -0,0 +1,137 @@
1
+ /**
2
+ * @fileoverview A Box API Request
3
+ */
4
+ /// <reference types="node" />
5
+ import { EventEmitter } from 'events';
6
+ import request from 'request';
7
+ import Config from './util/config';
8
+ /**
9
+ * The API response object includes information about the request made and its response. The information attached is a subset
10
+ * of the information returned by the request module, which is too large and complex to be safely handled (contains circular
11
+ * references, errors on serialization, etc.)
12
+ *
13
+ * @typedef {Object} APIRequest~ResponseObject
14
+ * @property {APIRequest~RequestObject} request Information about the request that generated this response
15
+ * @property {int} statusCode The response HTTP status code
16
+ * @property {Object} headers A collection of response headers
17
+ * @property {Object|Buffer|string} [body] The response body. Encoded to JSON by default, but can be a buffer
18
+ * (if encoding fails or if json encoding is disabled) or a string (if string encoding is enabled). Will be undefined
19
+ * if no response body is sent.
20
+ */
21
+ declare type APIRequestResponseObject = {
22
+ request: APIRequestRequestObject;
23
+ statusCode: number;
24
+ headers: Record<string, string>;
25
+ body?: object | Buffer | string;
26
+ };
27
+ /**
28
+ * The API request object includes information about the request made. The information attached is a subset of the information
29
+ * of a request module instance, which is too large and complex to be safely handled (contains circular references, errors on
30
+ * serialization, etc.).
31
+ *
32
+ * @typedef {Object} APIRequest~RequestObject
33
+ * @property {Object} uri Information about the request, including host, path, and the full 'href' url
34
+ * @property {string} method The request method (GET, POST, etc.)
35
+ * @property {Object} headers A collection of headers sent with the request
36
+ */
37
+ declare type APIRequestRequestObject = {
38
+ uri: Record<string, any>;
39
+ method: string;
40
+ headers: Record<string, string>;
41
+ };
42
+ /**
43
+ * The error returned by APIRequest callbacks, which includes any relevent, available information about the request
44
+ * and response. Note that these properties do not exist on stream errors, only errors retuned to the callback.
45
+ *
46
+ * @typedef {Error} APIRequest~Error
47
+ * @property {APIRequest~RequestObject} request Information about the request that generated this error
48
+ * @property {APIRequest~ResponseObject} [response] Information about the response related to this error, if available
49
+ * @property {int} [statusCode] The response HTTP status code
50
+ * @property {boolean} [maxRetriesExceeded] True iff the max number of retries were exceeded. Otherwise, undefined.
51
+ */
52
+ declare type APIRequestError = {
53
+ request: APIRequestRequestObject;
54
+ response?: APIRequestResponseObject;
55
+ statusCode?: number;
56
+ maxRetriesExceeded?: boolean;
57
+ };
58
+ /**
59
+ * Callback invoked when an APIRequest request is complete and finalized. On success,
60
+ * propagates the relevent response information. An err will indicate an unresolvable issue
61
+ * with the request (permanent failure or temp error response from the server, retried too many times).
62
+ *
63
+ * @callback APIRequest~Callback
64
+ * @param {?APIRequest~Error} err If Error object, API request did not get back the data it was supposed to. This
65
+ * could be either because of a temporary error, or a more serious error connecting to the API.
66
+ * @param {APIRequest~ResponseObject} response The response returned by an APIRequestManager request
67
+ */
68
+ declare type APIRequestCallback = (err?: APIRequestError | null, response?: APIRequestResponseObject) => void;
69
+ /**
70
+ * APIRequest helps to prepare and execute requests to the Box API. It supports
71
+ * retries, multipart uploads, and more.
72
+ *
73
+
74
+ * @param {Config} config Request-specific Config object
75
+ * @param {EventEmitter} eventBus Event bus for the SDK instance
76
+ * @constructor
77
+ */
78
+ declare class APIRequest {
79
+ config: Config;
80
+ eventBus: EventEmitter;
81
+ isRetryable: boolean;
82
+ _callback?: APIRequestCallback;
83
+ request?: request.Request;
84
+ stream?: request.Request;
85
+ numRetries?: number;
86
+ constructor(config: Config, eventBus: EventEmitter);
87
+ /**
88
+ * Executes the request with the given options. If a callback is provided, we'll
89
+ * handle the response via callbacks. Otherwise, the response will be streamed to
90
+ * via the stream property. You can access this stream with the getResponseStream()
91
+ * method.
92
+ *
93
+ * @param {APIRequest~Callback} [callback] Callback for handling the response
94
+ * @returns {void}
95
+ */
96
+ execute(callback?: APIRequestCallback): void;
97
+ /**
98
+ * Return the response read stream for a request. This will be undefined until
99
+ * a stream-based request has been started.
100
+ *
101
+ * @returns {?ReadableStream} The response stream
102
+ */
103
+ getResponseStream(): request.Request | undefined;
104
+ /**
105
+ * Handle the request response in the callback case.
106
+ *
107
+ * @param {?Error} err An error, if one occurred
108
+ * @param {Object} [response] The full response object, returned by the request module.
109
+ * Contains information about the request & response, including the response body itself.
110
+ * @returns {void}
111
+ * @private
112
+ */
113
+ _handleResponse(err?: any, response?: any): void;
114
+ /**
115
+ * Attempt a retry. If the request hasn't exceeded it's maximum number of retries,
116
+ * re-execute the request (after the retry interval). Otherwise, propagate a new error.
117
+ *
118
+ * @param {?Error} err An error, if one occurred
119
+ * @returns {void}
120
+ * @private
121
+ */
122
+ _retry(err?: any): void;
123
+ /**
124
+ * Propagate the response to the provided callback.
125
+ *
126
+ * @param {?Error} err An error, if one occurred
127
+ * @param {APIRequest~ResponseObject} response Information about the request & response
128
+ * @returns {void}
129
+ * @private
130
+ */
131
+ _finish(err?: any, response?: APIRequestResponseObject): void;
132
+ }
133
+ /**
134
+ * @module box-node-sdk/lib/api-request
135
+ * @see {@Link APIRequest}
136
+ */
137
+ export = APIRequest;