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.
- package/CHANGELOG.md +37 -2
- package/README.md +1 -1
- package/lib/api-request-manager.d.ts +38 -0
- package/lib/api-request-manager.js +48 -55
- package/lib/api-request-manager.js.map +1 -0
- package/lib/api-request.d.ts +141 -0
- package/lib/api-request.js +202 -281
- package/lib/api-request.js.map +1 -0
- package/lib/box-client.d.ts +269 -0
- package/lib/box-client.js +551 -713
- package/lib/box-client.js.map +1 -0
- package/lib/box-node-sdk.d.ts +216 -0
- package/lib/box-node-sdk.js +317 -352
- package/lib/box-node-sdk.js.map +1 -0
- package/lib/chunked-uploader.d.ts +129 -0
- package/lib/chunked-uploader.js +287 -358
- package/lib/chunked-uploader.js.map +1 -0
- package/lib/enterprise-event-stream.d.ts +82 -0
- package/lib/enterprise-event-stream.js +189 -203
- package/lib/enterprise-event-stream.js.map +1 -0
- package/lib/event-stream.d.ts +92 -0
- package/lib/event-stream.js +274 -302
- package/lib/event-stream.js.map +1 -0
- package/lib/managers/collaboration-allowlist.d.ts +137 -0
- package/lib/managers/collaboration-allowlist.js +200 -0
- package/lib/managers/collaboration-allowlist.js.map +1 -0
- package/lib/managers/collaboration-whitelist.d.ts +3 -0
- package/lib/managers/collaboration-whitelist.js +8 -222
- package/lib/managers/collaboration-whitelist.js.map +1 -0
- package/lib/managers/collaborations.d.ts +166 -0
- package/lib/managers/collaborations.js +225 -258
- package/lib/managers/collaborations.js.map +1 -0
- package/lib/managers/collections.d.ts +42 -0
- package/lib/managers/collections.js +45 -50
- package/lib/managers/collections.js.map +1 -0
- package/lib/managers/comments.d.ts +103 -0
- package/lib/managers/comments.js +158 -173
- package/lib/managers/comments.js.map +1 -0
- package/lib/managers/device-pins.d.ts +52 -0
- package/lib/managers/device-pins.js +75 -88
- package/lib/managers/device-pins.js.map +1 -0
- package/lib/managers/enterprise.d.ts +162 -0
- package/lib/managers/enterprise.js +168 -199
- package/lib/managers/enterprise.js.map +1 -0
- package/lib/managers/events.d.ts +177 -0
- package/lib/managers/events.js +230 -254
- package/lib/managers/events.js.map +1 -0
- package/lib/managers/files.d.ts +772 -0
- package/lib/managers/files.js +1400 -1602
- package/lib/managers/files.js.map +1 -0
- package/lib/managers/folders.d.ts +347 -0
- package/lib/managers/folders.js +551 -567
- package/lib/managers/folders.js.map +1 -0
- package/lib/managers/groups.d.ts +202 -0
- package/lib/managers/groups.js +238 -287
- package/lib/managers/groups.js.map +1 -0
- package/lib/managers/legal-hold-policies.d.ts +190 -0
- package/lib/managers/legal-hold-policies.js +228 -272
- package/lib/managers/legal-hold-policies.js.map +1 -0
- package/lib/managers/metadata.d.ts +228 -0
- package/lib/managers/metadata.js +265 -328
- package/lib/managers/metadata.js.map +1 -0
- package/lib/managers/recent-items.d.ts +38 -0
- package/lib/managers/recent-items.js +32 -39
- package/lib/managers/recent-items.js.map +1 -0
- package/lib/managers/retention-policies.d.ts +213 -0
- package/lib/managers/retention-policies.js +235 -281
- package/lib/managers/retention-policies.js.map +1 -0
- package/lib/managers/search.d.ts +82 -0
- package/lib/managers/search.js +68 -88
- package/lib/managers/search.js.map +1 -0
- package/lib/managers/shared-items.d.ts +33 -0
- package/lib/managers/shared-items.js +54 -62
- package/lib/managers/shared-items.js.map +1 -0
- package/lib/managers/storage-policies.d.ts +86 -0
- package/lib/managers/storage-policies.js +108 -142
- package/lib/managers/storage-policies.js.map +1 -0
- package/lib/managers/tasks.d.ts +161 -0
- package/lib/managers/tasks.js +219 -260
- package/lib/managers/tasks.js.map +1 -0
- package/lib/managers/terms-of-service.d.ts +161 -0
- package/lib/managers/terms-of-service.js +250 -273
- package/lib/managers/terms-of-service.js.map +1 -0
- package/lib/managers/trash.d.ts +30 -0
- package/lib/managers/trash.js +30 -41
- package/lib/managers/trash.js.map +1 -0
- package/lib/managers/users.d.ts +131 -0
- package/lib/managers/users.js +160 -203
- package/lib/managers/users.js.map +1 -0
- package/lib/managers/web-links.d.ts +127 -0
- package/lib/managers/web-links.js +183 -209
- package/lib/managers/web-links.js.map +1 -0
- package/lib/managers/webhooks.d.ts +166 -0
- package/lib/managers/webhooks.js +312 -305
- package/lib/managers/webhooks.js.map +1 -0
- package/lib/sessions/anonymous-session.d.ts +69 -0
- package/lib/sessions/anonymous-session.js +88 -102
- package/lib/sessions/anonymous-session.js.map +1 -0
- package/lib/sessions/app-auth-session.d.ts +92 -0
- package/lib/sessions/app-auth-session.js +140 -160
- package/lib/sessions/app-auth-session.js.map +1 -0
- package/lib/sessions/basic-session.d.ts +56 -0
- package/lib/sessions/basic-session.js +40 -50
- package/lib/sessions/basic-session.js.map +1 -0
- package/lib/sessions/persistent-session.d.ts +96 -0
- package/lib/sessions/persistent-session.js +191 -211
- package/lib/sessions/persistent-session.js.map +1 -0
- package/lib/token-manager.d.ts +191 -0
- package/lib/token-manager.js +390 -465
- package/lib/token-manager.js.map +1 -0
- package/lib/util/config.d.ts +86 -0
- package/lib/util/config.js +124 -152
- package/lib/util/config.js.map +1 -0
- package/lib/util/errors.d.ts +50 -0
- package/lib/util/errors.js +134 -145
- package/lib/util/errors.js.map +1 -0
- package/lib/util/exponential-backoff.d.ts +11 -0
- package/lib/util/exponential-backoff.js +10 -22
- package/lib/util/exponential-backoff.js.map +1 -0
- package/lib/util/paging-iterator.d.ts +53 -0
- package/lib/util/paging-iterator.js +202 -218
- package/lib/util/paging-iterator.js.map +1 -0
- package/lib/util/url-path.d.ts +16 -0
- package/lib/util/url-path.js +20 -35
- package/lib/util/url-path.js.map +1 -0
- package/package.json +24 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.37.2 (2021-05-20)
|
|
4
|
+
|
|
5
|
+
**Bug Fixes:**
|
|
6
|
+
|
|
7
|
+
- Fix backwards compatibility issue by moving some TypeScript @types as direct dependencies ([#630](https://github.com/box/box-node-sdk/pull/630))
|
|
8
|
+
|
|
9
|
+
## 1.37.1 (2021-05-19)
|
|
10
|
+
|
|
11
|
+
**Bug Fixes:**
|
|
12
|
+
|
|
13
|
+
- Insensitive language: replace whitelist with allowlist ([#625](https://github.com/box/box-node-sdk/pull/625))
|
|
14
|
+
|
|
15
|
+
## 1.37.0 (2021-04-16)
|
|
16
|
+
|
|
17
|
+
**New Features and Enhancements:**
|
|
18
|
+
|
|
19
|
+
- Add support for copyInstanceOnItemCopy field for metadata templates ([#572](https://github.com/box/box-node-sdk/pull/572))
|
|
20
|
+
|
|
21
|
+
**Bug Fixes:**
|
|
22
|
+
|
|
23
|
+
- Fix webhook signature validation ([#568](https://github.com/box/box-node-sdk/pull/568))
|
|
24
|
+
- Update dependencies to patch security vulnerabilities ([#578](https://github.com/box/box-node-sdk/pull/578))
|
|
25
|
+
|
|
26
|
+
## 1.36.0 (2021-01-27)
|
|
27
|
+
|
|
28
|
+
**New Features and Enhancements:**
|
|
29
|
+
|
|
30
|
+
- Add folder lock functionality ([#560](https://github.com/box/box-node-sdk/pull/560))
|
|
31
|
+
- Add support for filtering groups by name ([#561](https://github.com/box/box-node-sdk/pull/561))
|
|
32
|
+
|
|
33
|
+
**Bug Fixes:**
|
|
34
|
+
|
|
35
|
+
- Update proxy-agent to patch proxy support issue ([#563](https://github.com/box/box-node-sdk/pull/563))
|
|
36
|
+
- Update dependencies to patch security vulnerabilities ([#566](https://github.com/box/box-node-sdk/pull/566))
|
|
37
|
+
|
|
3
38
|
## 1.35.0 (2020-11-02)
|
|
4
39
|
|
|
5
40
|
**New Features and Enhancements:**
|
|
@@ -151,11 +186,11 @@ to specify a client ID and secret (thanks to @cbetta)
|
|
|
151
186
|
|
|
152
187
|
## 1.16.0 [2018-04-10]
|
|
153
188
|
|
|
154
|
-
- Added support for [assigning Retention Policies to Metadata Templates](https://github.com/box/box-node-sdk/blob/
|
|
189
|
+
- 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)
|
|
155
190
|
|
|
156
191
|
## 1.15.0 [2018-03-29]
|
|
157
192
|
|
|
158
|
-
- Fixed [`client.webhooks.validateMessage() and `sdk.validateWebhookMessage()`](https://github.com/box/box-node-sdk/blob/
|
|
193
|
+
- Fixed [`client.webhooks.validateMessage() and `sdk.validateWebhookMessage()`](https://github.com/box/box-node-sdk/blob/main/docs/webhooks.md#validate-a-webhook-message)
|
|
159
194
|
to accept the request body as an `Object`
|
|
160
195
|
- Fixed `sdk.configure()` to correct reconfigure all options
|
|
161
196
|
- Improved error messages for API errors and added the request object as `error.request` for easier debugging
|
package/README.md
CHANGED
|
@@ -184,7 +184,7 @@ client.comments.delete('456')
|
|
|
184
184
|
|
|
185
185
|
For complete documentation about the available operations, please see
|
|
186
186
|
the [SDK documentation pages](./docs) and the auto-generated
|
|
187
|
-
[JSDocs](https://rawgit.com/box/box-node-sdk/
|
|
187
|
+
[JSDocs](https://rawgit.com/box/box-node-sdk/main/docs/jsdoc/index.html).
|
|
188
188
|
These contain detailed information about which methods are available and
|
|
189
189
|
how to use them.
|
|
190
190
|
|
|
@@ -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
|
-
|
|
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
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
*/
|
|
41
|
-
APIRequestManager
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
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,141 @@
|
|
|
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
|
+
* @NOTE(fschott) 08-19-2014: We cannot return the request/response objects directly because they contain loads of extra
|
|
13
|
+
* information, unnecessary bloat, circular dependencies, and cause an infinite loop when stringifying.
|
|
14
|
+
*
|
|
15
|
+
* @typedef {Object} APIRequest~ResponseObject
|
|
16
|
+
* @property {APIRequest~RequestObject} request Information about the request that generated this response
|
|
17
|
+
* @property {int} statusCode The response HTTP status code
|
|
18
|
+
* @property {Object} headers A collection of response headers
|
|
19
|
+
* @property {Object|Buffer|string} [body] The response body. Encoded to JSON by default, but can be a buffer
|
|
20
|
+
* (if encoding fails or if json encoding is disabled) or a string (if string encoding is enabled). Will be undefined
|
|
21
|
+
* if no response body is sent.
|
|
22
|
+
*/
|
|
23
|
+
declare type APIRequestResponseObject = {
|
|
24
|
+
request: APIRequestRequestObject;
|
|
25
|
+
statusCode: number;
|
|
26
|
+
headers: Record<string, string>;
|
|
27
|
+
body?: object | Buffer | string;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* The API request object includes information about the request made. The information attached is a subset of the information
|
|
31
|
+
* of a request module instance, which is too large and complex to be safely handled (contains circular references, errors on
|
|
32
|
+
* serialization, etc.).
|
|
33
|
+
* @NOTE(fschott) 08-19-2014: We cannot return the request/response objects directly because they contain loads of extra
|
|
34
|
+
* information, unnecessary bloat, circular dependencies, and cause an infinite loop when stringifying.
|
|
35
|
+
*
|
|
36
|
+
* @typedef {Object} APIRequest~RequestObject
|
|
37
|
+
* @property {Object} uri Information about the request, including host, path, and the full 'href' url
|
|
38
|
+
* @property {string} method The request method (GET, POST, etc.)
|
|
39
|
+
* @property {Object} headers A collection of headers sent with the request
|
|
40
|
+
*/
|
|
41
|
+
declare type APIRequestRequestObject = {
|
|
42
|
+
uri: Record<string, any>;
|
|
43
|
+
method: string;
|
|
44
|
+
headers: Record<string, string>;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* The error returned by APIRequest callbacks, which includes any relevent, available information about the request
|
|
48
|
+
* and response. Note that these properties do not exist on stream errors, only errors retuned to the callback.
|
|
49
|
+
*
|
|
50
|
+
* @typedef {Error} APIRequest~Error
|
|
51
|
+
* @property {APIRequest~RequestObject} request Information about the request that generated this error
|
|
52
|
+
* @property {APIRequest~ResponseObject} [response] Information about the response related to this error, if available
|
|
53
|
+
* @property {int} [statusCode] The response HTTP status code
|
|
54
|
+
* @property {boolean} [maxRetriesExceeded] True iff the max number of retries were exceeded. Otherwise, undefined.
|
|
55
|
+
*/
|
|
56
|
+
declare type APIRequestError = {
|
|
57
|
+
request: APIRequestRequestObject;
|
|
58
|
+
response?: APIRequestResponseObject;
|
|
59
|
+
statusCode?: number;
|
|
60
|
+
maxRetriesExceeded?: boolean;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Callback invoked when an APIRequest request is complete and finalized. On success,
|
|
64
|
+
* propagates the relevent response information. An err will indicate an unresolvable issue
|
|
65
|
+
* with the request (permanent failure or temp error response from the server, retried too many times).
|
|
66
|
+
*
|
|
67
|
+
* @callback APIRequest~Callback
|
|
68
|
+
* @param {?APIRequest~Error} err If Error object, API request did not get back the data it was supposed to. This
|
|
69
|
+
* could be either because of a temporary error, or a more serious error connecting to the API.
|
|
70
|
+
* @param {APIRequest~ResponseObject} response The response returned by an APIRequestManager request
|
|
71
|
+
*/
|
|
72
|
+
declare type APIRequestCallback = (err?: APIRequestError | null, response?: APIRequestResponseObject) => void;
|
|
73
|
+
/**
|
|
74
|
+
* APIRequest helps to prepare and execute requests to the Box API. It supports
|
|
75
|
+
* retries, multipart uploads, and more.
|
|
76
|
+
*
|
|
77
|
+
|
|
78
|
+
* @param {Config} config Request-specific Config object
|
|
79
|
+
* @param {EventEmitter} eventBus Event bus for the SDK instance
|
|
80
|
+
* @constructor
|
|
81
|
+
*/
|
|
82
|
+
declare class APIRequest {
|
|
83
|
+
config: Config;
|
|
84
|
+
eventBus: EventEmitter;
|
|
85
|
+
isRetryable: boolean;
|
|
86
|
+
_callback?: APIRequestCallback;
|
|
87
|
+
request?: request.Request;
|
|
88
|
+
stream?: request.Request;
|
|
89
|
+
numRetries?: number;
|
|
90
|
+
constructor(config: Config, eventBus: EventEmitter);
|
|
91
|
+
/**
|
|
92
|
+
* Executes the request with the given options. If a callback is provided, we'll
|
|
93
|
+
* handle the response via callbacks. Otherwise, the response will be streamed to
|
|
94
|
+
* via the stream property. You can access this stream with the getResponseStream()
|
|
95
|
+
* method.
|
|
96
|
+
*
|
|
97
|
+
* @param {APIRequest~Callback} [callback] Callback for handling the response
|
|
98
|
+
* @returns {void}
|
|
99
|
+
*/
|
|
100
|
+
execute(callback?: APIRequestCallback): void;
|
|
101
|
+
/**
|
|
102
|
+
* Return the response read stream for a request. This will be undefined until
|
|
103
|
+
* a stream-based request has been started.
|
|
104
|
+
*
|
|
105
|
+
* @returns {?ReadableStream} The response stream
|
|
106
|
+
*/
|
|
107
|
+
getResponseStream(): request.Request | undefined;
|
|
108
|
+
/**
|
|
109
|
+
* Handle the request response in the callback case.
|
|
110
|
+
*
|
|
111
|
+
* @param {?Error} err An error, if one occurred
|
|
112
|
+
* @param {Object} [response] The full response object, returned by the request module.
|
|
113
|
+
* Contains information about the request & response, including the response body itself.
|
|
114
|
+
* @returns {void}
|
|
115
|
+
* @private
|
|
116
|
+
*/
|
|
117
|
+
_handleResponse(err?: any, response?: any): void;
|
|
118
|
+
/**
|
|
119
|
+
* Attempt a retry. If the request hasn't exceeded it's maximum number of retries,
|
|
120
|
+
* re-execute the request (after the retry interval). Otherwise, propagate a new error.
|
|
121
|
+
*
|
|
122
|
+
* @param {?Error} err An error, if one occurred
|
|
123
|
+
* @returns {void}
|
|
124
|
+
* @private
|
|
125
|
+
*/
|
|
126
|
+
_retry(err?: any): void;
|
|
127
|
+
/**
|
|
128
|
+
* Propagate the response to the provided callback.
|
|
129
|
+
*
|
|
130
|
+
* @param {?Error} err An error, if one occurred
|
|
131
|
+
* @param {APIRequest~ResponseObject} response Information about the request & response
|
|
132
|
+
* @returns {void}
|
|
133
|
+
* @private
|
|
134
|
+
*/
|
|
135
|
+
_finish(err?: any, response?: APIRequestResponseObject): void;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* @module box-node-sdk/lib/api-request
|
|
139
|
+
* @see {@Link APIRequest}
|
|
140
|
+
*/
|
|
141
|
+
export = APIRequest;
|