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
|
@@ -1,224 +1,193 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* @fileoverview Manager for Enterprise resources
|
|
3
4
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
7
|
+
};
|
|
8
|
+
var url_path_1 = __importDefault(require("../util/url-path"));
|
|
7
9
|
// -----------------------------------------------------------------------------
|
|
8
10
|
// Typedefs
|
|
9
11
|
// -----------------------------------------------------------------------------
|
|
10
|
-
|
|
11
|
-
/** @typedef {string} EnterpriseUserType */
|
|
12
|
-
|
|
13
|
-
/** @typedef {string} EnterpriseRole */
|
|
14
|
-
|
|
15
|
-
/** @typedef {string} EnterpriseUserStatus */
|
|
16
|
-
|
|
17
|
-
// -----------------------------------------------------------------------------
|
|
18
|
-
// Requirements
|
|
19
|
-
// -----------------------------------------------------------------------------
|
|
20
|
-
var urlPath = require('../util/url-path');
|
|
21
|
-
|
|
22
|
-
// -----------------------------------------------------------------------------
|
|
23
|
-
// Private
|
|
24
|
-
// -----------------------------------------------------------------------------
|
|
25
|
-
var USERS_PATH = '/users',
|
|
26
|
-
INVITES_PATH = '/invites',
|
|
27
|
-
FOLDERS_SUBRESOURCE = 'folders',
|
|
28
|
-
ROOT_FOLDER_ID = '0';
|
|
29
|
-
|
|
30
|
-
// -----------------------------------------------------------------------------
|
|
31
|
-
// Public
|
|
32
|
-
// -----------------------------------------------------------------------------
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Simple manager for interacting with all Enterprise endpoints and actions.
|
|
36
|
-
*
|
|
37
|
-
* @constructor
|
|
38
|
-
* @param {BoxClient} client - The Box API Client that is responsible for making calls to the API
|
|
39
|
-
* @returns {void}
|
|
40
|
-
*/
|
|
41
|
-
function Enterprise(client) {
|
|
42
|
-
this.client = client;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
12
|
/**
|
|
46
13
|
* List of valid user types
|
|
47
14
|
* @readonly
|
|
48
15
|
* @enum {EnterpriseUserType}
|
|
49
16
|
*/
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
17
|
+
var EnterpriseUserType;
|
|
18
|
+
(function (EnterpriseUserType) {
|
|
19
|
+
EnterpriseUserType["ALL"] = "all";
|
|
20
|
+
EnterpriseUserType["MANAGED"] = "managed";
|
|
21
|
+
EnterpriseUserType["EXTERNAL"] = "external";
|
|
22
|
+
})(EnterpriseUserType || (EnterpriseUserType = {}));
|
|
56
23
|
/**
|
|
57
24
|
* List of valid user statuses
|
|
58
25
|
* @readonly
|
|
59
26
|
* @enum {EnterpriseUserStatus}
|
|
60
27
|
*/
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
28
|
+
var EnterpriseUserStatus;
|
|
29
|
+
(function (EnterpriseUserStatus) {
|
|
30
|
+
EnterpriseUserStatus["ACTIVE"] = "active";
|
|
31
|
+
EnterpriseUserStatus["INACTIVE"] = "inactive";
|
|
32
|
+
EnterpriseUserStatus["CANNOT_DELETE_OR_EDIT"] = "cannot_delete_edit";
|
|
33
|
+
EnterpriseUserStatus["CANNOT_DELETE_EDIT_OR_UPLOAD"] = "cannot_delete_edit_upload";
|
|
34
|
+
})(EnterpriseUserStatus || (EnterpriseUserStatus = {}));
|
|
68
35
|
/**
|
|
69
36
|
* List of valid roles
|
|
70
37
|
* @readonly
|
|
71
38
|
* @enum {EnterpriseRole}
|
|
72
39
|
*/
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
* @param {string} [options.filter_term] - Filter the results to only users starting with the filter_term in either the name or the login
|
|
86
|
-
* @param {int} [options.limit=100] - The number of records to return
|
|
87
|
-
* @param {boolean} [options.usemarker=false] - Whether or not to use marker-based pagination
|
|
88
|
-
* @param {string} [options.marker=''] - The marker for the page at which to start. Default is the first page
|
|
89
|
-
* @param {int} [options.offset=0] - The record at which to start
|
|
90
|
-
* @param {EnterpriseUserType} [options.user_type=managed] - The type of user to search for
|
|
91
|
-
* @param {Function} [callback] - Passed the list of users if successful, error otherwise
|
|
92
|
-
* @returns {Promise<Object>} A promise resolving to the collection of users
|
|
93
|
-
*/
|
|
94
|
-
Enterprise.prototype.getUsers = function(options, callback) {
|
|
95
|
-
|
|
96
|
-
var apiPath = urlPath(USERS_PATH),
|
|
97
|
-
params = {
|
|
98
|
-
qs: options
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, params, callback);
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Invites a user to join the enterprise
|
|
106
|
-
*
|
|
107
|
-
* API Endpoint: '/invites'
|
|
108
|
-
* Method: POST
|
|
109
|
-
*
|
|
110
|
-
* @param {string} enterpriseID - The ID of the enterprise to invite the user to
|
|
111
|
-
* @param {string} email - The email address of the user to invite
|
|
112
|
-
* @param {Function} [callback] - Passed the invite object if successful, error otherwise
|
|
113
|
-
* @returns {Promise<Object>} A promise resolving to the invite object
|
|
114
|
-
*/
|
|
115
|
-
Enterprise.prototype.inviteUser = function(enterpriseID, email, callback) {
|
|
116
|
-
|
|
117
|
-
var apiPath = urlPath(INVITES_PATH),
|
|
118
|
-
params = {
|
|
119
|
-
body: {
|
|
120
|
-
enterprise: {
|
|
121
|
-
id: enterpriseID
|
|
122
|
-
},
|
|
123
|
-
actionable_by: {
|
|
124
|
-
login: email
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
return this.client.wrapWithDefaultHandler(this.client.post)(apiPath, params, callback);
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Create a new user in the current enterprise
|
|
134
|
-
*
|
|
135
|
-
* API Endpoint: '/users'
|
|
136
|
-
* Method: POST
|
|
137
|
-
*
|
|
138
|
-
* @param {string} login - The email address this user uses to login
|
|
139
|
-
* @param {string} name - The name of this user
|
|
140
|
-
* @param {Object} [options] - Optional parameters, can be left null in most cases
|
|
141
|
-
* @param {EnterpriseRole} [options.role] - This user’s enterprise role
|
|
142
|
-
* @param {string} [options.language] - The user's language
|
|
143
|
-
* @param {boolean} [options.is_sync_enabled] - Whether or not this user can use Box Sync
|
|
144
|
-
* @param {string} [options.job_title] - The user’s job title
|
|
145
|
-
* @param {string} [options.phone] - The user’s phone number
|
|
146
|
-
* @param {string} [options.address] - The user’s address
|
|
147
|
-
* @param {int} [options.space_amount] - The user’s total available storage space in bytes
|
|
148
|
-
* @param {Array} [options.tracking_codes] - An array of key/value pairs set by the user’s admin
|
|
149
|
-
* @param {EnterpriseUserStatus} [options.status] - The user's status
|
|
150
|
-
* @param {boolean} [options.can_see_managed_users] - Whether the user should be able to see other managed users
|
|
151
|
-
* @param {string} [options.timezone] - The user's timezone
|
|
152
|
-
* @param {boolean} [options.is_exempt_from_device_limits] - Whether to exempt this user from Enterprise device limits
|
|
153
|
-
* @param {boolean} [options.is_exempt_from_login_verification] - Whether or not this user must use two-factor authentication
|
|
154
|
-
* @param {Function} [callback] - Passed the created user if successful, error otherwise
|
|
155
|
-
* @returns {Promise<Object>} A promise resolving to the created user
|
|
156
|
-
*/
|
|
157
|
-
Enterprise.prototype.addUser = function(login, name, options, callback) {
|
|
158
|
-
|
|
159
|
-
var apiPath = urlPath(USERS_PATH),
|
|
160
|
-
params = {
|
|
161
|
-
body: {login, name}
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
Object.assign(params.body, options);
|
|
165
|
-
|
|
166
|
-
return this.client.wrapWithDefaultHandler(this.client.post)(apiPath, params, callback);
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Create a new app user in the current enterprise
|
|
171
|
-
*
|
|
172
|
-
* API Endpoint: '/users'
|
|
173
|
-
* Method: POST
|
|
174
|
-
*
|
|
175
|
-
* @param {string} name - The name of this user
|
|
176
|
-
* @param {Object} [options] - Optional parameters, can be left null in most cases
|
|
177
|
-
* @param {string} [options.language] - The user's language
|
|
178
|
-
* @param {string} [options.job_title] - The user’s job title
|
|
179
|
-
* @param {string} [options.phone] - The user’s phone number
|
|
180
|
-
* @param {string} [options.address] - The user’s address
|
|
181
|
-
* @param {int} [options.space_amount] - The user’s total available storage space in bytes
|
|
182
|
-
* @param {string} [options.timezone] - The user's timezone
|
|
183
|
-
* @param {Function} [callback] - Passed the created user if successful, error otherwise
|
|
184
|
-
* @returns {Promise<Object>} A promise resolving to the created user
|
|
185
|
-
*/
|
|
186
|
-
Enterprise.prototype.addAppUser = function(name, options, callback) {
|
|
187
|
-
|
|
188
|
-
var apiPath = urlPath(USERS_PATH),
|
|
189
|
-
params = {
|
|
190
|
-
body: {
|
|
191
|
-
name,
|
|
192
|
-
is_platform_access_only: true
|
|
193
|
-
}
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
Object.assign(params.body, options);
|
|
197
|
-
|
|
198
|
-
return this.client.wrapWithDefaultHandler(this.client.post)(apiPath, params, callback);
|
|
199
|
-
};
|
|
200
|
-
|
|
40
|
+
var EnterpriseRole;
|
|
41
|
+
(function (EnterpriseRole) {
|
|
42
|
+
EnterpriseRole["USER"] = "user";
|
|
43
|
+
EnterpriseRole["COADMIN"] = "coadmin";
|
|
44
|
+
})(EnterpriseRole || (EnterpriseRole = {}));
|
|
45
|
+
// -----------------------------------------------------------------------------
|
|
46
|
+
// Private
|
|
47
|
+
// -----------------------------------------------------------------------------
|
|
48
|
+
var USERS_PATH = '/users', INVITES_PATH = '/invites', FOLDERS_SUBRESOURCE = 'folders', ROOT_FOLDER_ID = '0';
|
|
49
|
+
// -----------------------------------------------------------------------------
|
|
50
|
+
// Public
|
|
51
|
+
// -----------------------------------------------------------------------------
|
|
201
52
|
/**
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
* API Endpoint: '/users/:sourceUserID/folders/0'
|
|
205
|
-
* Method: PUT
|
|
53
|
+
* Simple manager for interacting with all Enterprise endpoints and actions.
|
|
206
54
|
*
|
|
207
|
-
* @
|
|
208
|
-
* @param {
|
|
209
|
-
* @
|
|
210
|
-
* @returns {Promise<Object>} A promise resolving to the folder containing the transferred content
|
|
55
|
+
* @constructor
|
|
56
|
+
* @param {BoxClient} client - The Box API Client that is responsible for making calls to the API
|
|
57
|
+
* @returns {void}
|
|
211
58
|
*/
|
|
212
|
-
Enterprise
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
}
|
|
223
|
-
|
|
59
|
+
var Enterprise = /** @class */ (function () {
|
|
60
|
+
function Enterprise(client) {
|
|
61
|
+
this.client = client;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Get a list of users in the current enterprise
|
|
65
|
+
*
|
|
66
|
+
* API Endpoint: '/users'
|
|
67
|
+
* Method: GET
|
|
68
|
+
*
|
|
69
|
+
* @param {Object} [options] - Optional parameters, can be left null in most cases
|
|
70
|
+
* @param {string} [options.filter_term] - Filter the results to only users starting with the filter_term in either the name or the login
|
|
71
|
+
* @param {int} [options.limit=100] - The number of records to return
|
|
72
|
+
* @param {boolean} [options.usemarker=false] - Whether or not to use marker-based pagination
|
|
73
|
+
* @param {string} [options.marker=''] - The marker for the page at which to start. Default is the first page
|
|
74
|
+
* @param {int} [options.offset=0] - The record at which to start
|
|
75
|
+
* @param {EnterpriseUserType} [options.user_type=managed] - The type of user to search for
|
|
76
|
+
* @param {Function} [callback] - Passed the list of users if successful, error otherwise
|
|
77
|
+
* @returns {Promise<Object>} A promise resolving to the collection of users
|
|
78
|
+
*/
|
|
79
|
+
Enterprise.prototype.getUsers = function (options, callback) {
|
|
80
|
+
var apiPath = url_path_1.default(USERS_PATH), params = {
|
|
81
|
+
qs: options,
|
|
82
|
+
};
|
|
83
|
+
return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, params, callback);
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Invites a user to join the enterprise
|
|
87
|
+
*
|
|
88
|
+
* API Endpoint: '/invites'
|
|
89
|
+
* Method: POST
|
|
90
|
+
*
|
|
91
|
+
* @param {string} enterpriseID - The ID of the enterprise to invite the user to
|
|
92
|
+
* @param {string} email - The email address of the user to invite
|
|
93
|
+
* @param {Function} [callback] - Passed the invite object if successful, error otherwise
|
|
94
|
+
* @returns {Promise<Object>} A promise resolving to the invite object
|
|
95
|
+
*/
|
|
96
|
+
Enterprise.prototype.inviteUser = function (enterpriseID, email, callback) {
|
|
97
|
+
var apiPath = url_path_1.default(INVITES_PATH), params = {
|
|
98
|
+
body: {
|
|
99
|
+
enterprise: {
|
|
100
|
+
id: enterpriseID,
|
|
101
|
+
},
|
|
102
|
+
actionable_by: {
|
|
103
|
+
login: email,
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
return this.client.wrapWithDefaultHandler(this.client.post)(apiPath, params, callback);
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Create a new user in the current enterprise
|
|
111
|
+
*
|
|
112
|
+
* API Endpoint: '/users'
|
|
113
|
+
* Method: POST
|
|
114
|
+
*
|
|
115
|
+
* @param {string} login - The email address this user uses to login
|
|
116
|
+
* @param {string} name - The name of this user
|
|
117
|
+
* @param {Object} [options] - Optional parameters, can be left null in most cases
|
|
118
|
+
* @param {EnterpriseRole} [options.role] - This user’s enterprise role
|
|
119
|
+
* @param {string} [options.language] - The user's language
|
|
120
|
+
* @param {boolean} [options.is_sync_enabled] - Whether or not this user can use Box Sync
|
|
121
|
+
* @param {string} [options.job_title] - The user’s job title
|
|
122
|
+
* @param {string} [options.phone] - The user’s phone number
|
|
123
|
+
* @param {string} [options.address] - The user’s address
|
|
124
|
+
* @param {int} [options.space_amount] - The user’s total available storage space in bytes
|
|
125
|
+
* @param {Array} [options.tracking_codes] - An array of key/value pairs set by the user’s admin
|
|
126
|
+
* @param {EnterpriseUserStatus} [options.status] - The user's status
|
|
127
|
+
* @param {boolean} [options.can_see_managed_users] - Whether the user should be able to see other managed users
|
|
128
|
+
* @param {string} [options.timezone] - The user's timezone
|
|
129
|
+
* @param {boolean} [options.is_exempt_from_device_limits] - Whether to exempt this user from Enterprise device limits
|
|
130
|
+
* @param {boolean} [options.is_exempt_from_login_verification] - Whether or not this user must use two-factor authentication
|
|
131
|
+
* @param {Function} [callback] - Passed the created user if successful, error otherwise
|
|
132
|
+
* @returns {Promise<Object>} A promise resolving to the created user
|
|
133
|
+
*/
|
|
134
|
+
Enterprise.prototype.addUser = function (login, name, options, callback) {
|
|
135
|
+
var apiPath = url_path_1.default(USERS_PATH), params = {
|
|
136
|
+
body: { login: login, name: name },
|
|
137
|
+
};
|
|
138
|
+
Object.assign(params.body, options);
|
|
139
|
+
return this.client.wrapWithDefaultHandler(this.client.post)(apiPath, params, callback);
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* Create a new app user in the current enterprise
|
|
143
|
+
*
|
|
144
|
+
* API Endpoint: '/users'
|
|
145
|
+
* Method: POST
|
|
146
|
+
*
|
|
147
|
+
* @param {string} name - The name of this user
|
|
148
|
+
* @param {Object} [options] - Optional parameters, can be left null in most cases
|
|
149
|
+
* @param {string} [options.language] - The user's language
|
|
150
|
+
* @param {string} [options.job_title] - The user’s job title
|
|
151
|
+
* @param {string} [options.phone] - The user’s phone number
|
|
152
|
+
* @param {string} [options.address] - The user’s address
|
|
153
|
+
* @param {int} [options.space_amount] - The user’s total available storage space in bytes
|
|
154
|
+
* @param {string} [options.timezone] - The user's timezone
|
|
155
|
+
* @param {Function} [callback] - Passed the created user if successful, error otherwise
|
|
156
|
+
* @returns {Promise<Object>} A promise resolving to the created user
|
|
157
|
+
*/
|
|
158
|
+
Enterprise.prototype.addAppUser = function (name, options, callback) {
|
|
159
|
+
var apiPath = url_path_1.default(USERS_PATH), params = {
|
|
160
|
+
body: {
|
|
161
|
+
name: name,
|
|
162
|
+
is_platform_access_only: true,
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
Object.assign(params.body, options);
|
|
166
|
+
return this.client.wrapWithDefaultHandler(this.client.post)(apiPath, params, callback);
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* Transfers all of a user's files into another user's account.
|
|
170
|
+
*
|
|
171
|
+
* API Endpoint: '/users/:sourceUserID/folders/0'
|
|
172
|
+
* Method: PUT
|
|
173
|
+
*
|
|
174
|
+
* @param {string} sourceUserID - The ID of the user whose files will be transferred
|
|
175
|
+
* @param {string} destUserID - The ID of the user to transfer the files to
|
|
176
|
+
* @param {Function} [callback] - Passed the new folder which contains all the files if successful, error otherwise
|
|
177
|
+
* @returns {Promise<Object>} A promise resolving to the folder containing the transferred content
|
|
178
|
+
*/
|
|
179
|
+
Enterprise.prototype.transferUserContent = function (sourceUserID, destUserID, callback) {
|
|
180
|
+
var apiPath = url_path_1.default(USERS_PATH, sourceUserID, FOLDERS_SUBRESOURCE, ROOT_FOLDER_ID), params = {
|
|
181
|
+
body: {
|
|
182
|
+
owned_by: { id: destUserID },
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
return this.client.wrapWithDefaultHandler(this.client.put)(apiPath, params, callback);
|
|
186
|
+
};
|
|
187
|
+
return Enterprise;
|
|
188
|
+
}());
|
|
189
|
+
Enterprise.prototype.userTypes = EnterpriseUserType;
|
|
190
|
+
Enterprise.prototype.userStatuses = EnterpriseUserStatus;
|
|
191
|
+
Enterprise.prototype.userRoles = EnterpriseRole;
|
|
224
192
|
module.exports = Enterprise;
|
|
193
|
+
//# sourceMappingURL=enterprise.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enterprise.js","sourceRoot":"","sources":["../../src/managers/enterprise.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAOH,8DAAuC;AAEvC,gFAAgF;AAChF,WAAW;AACX,gFAAgF;AAEhF;;;;GAIG;AACH,IAAK,kBAIJ;AAJD,WAAK,kBAAkB;IACtB,iCAAW,CAAA;IACX,yCAAmB,CAAA;IACnB,2CAAqB,CAAA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cAAc,CACd,EACD,MAAM,GAAG;YACR,IAAI,EAAE;gBACL,QAAQ,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE;aAC5B;SACD,CAAC;QAEH,OAAO,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CACzD,OAAO,EACP,MAAM,EACN,QAAQ,CACR,CAAC;IACH,CAAC;IACF,iBAAC;AAAD,CAAC,AA3ND,IA2NC;AAED,UAAU,CAAC,SAAS,CAAC,SAAS,GAAG,kBAAkB,CAAC;AACpD,UAAU,CAAC,SAAS,CAAC,YAAY,GAAG,oBAAoB,CAAC;AACzD,UAAU,CAAC,SAAS,CAAC,SAAS,GAAG,cAAc,CAAC;AAEhD,iBAAS,UAAU,CAAC"}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Manager for the Box Events Resource
|
|
3
|
+
*/
|
|
4
|
+
/// <reference types="bluebird" />
|
|
5
|
+
import BoxClient from '../box-client';
|
|
6
|
+
import EnterpriseEventStream from '../enterprise-event-stream';
|
|
7
|
+
/**
|
|
8
|
+
* Enum of enterprise event types
|
|
9
|
+
*
|
|
10
|
+
* @readonly
|
|
11
|
+
* @enum {EventType}
|
|
12
|
+
*/
|
|
13
|
+
declare enum EventType {
|
|
14
|
+
ADD_DEVICE_ASSOCIATION = "ADD_DEVICE_ASSOCIATION",
|
|
15
|
+
ADD_LOGIN_ACTIVITY_DEVICE = "ADD_LOGIN_ACTIVITY_DEVICE",
|
|
16
|
+
ADMIN_LOGIN = "ADMIN_LOGIN",
|
|
17
|
+
APPLICATION_PUBLIC_KEY_ADDED = "APPLICATION_PUBLIC_KEY_ADDED",
|
|
18
|
+
APPLICATION_PUBLIC_KEY_DELETED = "APPLICATION_PUBLIC_KEY_DELETED",
|
|
19
|
+
CHANGE_ADMIN_ROLE = "CHANGE_ADMIN_ROLE",
|
|
20
|
+
COLLABORATION_ACCEPT = "COLLABORATION_ACCEPT",
|
|
21
|
+
COLLABORATION_EXPIRATION = "COLLABORATION_EXPIRATION",
|
|
22
|
+
COLLABORATION_INVITE = "COLLABORATION_INVITE",
|
|
23
|
+
COLLABORATION_REMOVE = "COLLABORATION_REMOVE",
|
|
24
|
+
COLLABORATION_ROLE_CHANGE = "COLLABORATION_ROLE_CHANGE",
|
|
25
|
+
COMMENT_CREATE = "COMMENT_CREATE",
|
|
26
|
+
COMMENT_DELETE = "COMMENT_DELETE",
|
|
27
|
+
COMMENT_EDIT = "COMMENT_EDIT",
|
|
28
|
+
CONTENT_ACCESS = "CONTENT_ACCESS",
|
|
29
|
+
CONTENT_WORKFLOW_AUTOMATION_ADD = "CONTENT_WORKFLOW_AUTOMATION_ADD",
|
|
30
|
+
CONTENT_WORKFLOW_UPLOAD_POLICY_VIOLATION = "CONTENT_WORKFLOW_UPLOAD_POLICY_VIOLATION",
|
|
31
|
+
COPY = "COPY",
|
|
32
|
+
DELETE = "DELETE",
|
|
33
|
+
DELETE_USER = "DELETE_USER",
|
|
34
|
+
DOWNLOAD = "DOWNLOAD",
|
|
35
|
+
EDIT = "EDIT",
|
|
36
|
+
EDIT_USER = "EDIT_USER",
|
|
37
|
+
EMAIL_ALIAS_CONFIRM = "EMAIL_ALIAS_CONFIRM",
|
|
38
|
+
ENABLE_TWO_FACTOR_AUTH = "ENABLE_TWO_FACTOR_AUTH",
|
|
39
|
+
ENTERPRISE_APP_AUTHORIZATION_DELETE = "ENTERPRISE_APP_AUTHORIZATION_DELETE",
|
|
40
|
+
FAILED_LOGIN = "FAILED_LOGIN",
|
|
41
|
+
FILE_MARKED_MALICIOUS = "FILE_MARKED_MALICIOUS",
|
|
42
|
+
FILE_WATERMARKED_DOWNLOAD = "FILE_WATERMARKED_DOWNLOAD",
|
|
43
|
+
GROUP_ADD_FILE = "GROUP_ADD_FILE",
|
|
44
|
+
GROUP_ADD_FOLDER = "GROUP_ADD_FOLDER",
|
|
45
|
+
GROUP_ADD_ITEM = "GROUP_ADD_ITEM",
|
|
46
|
+
GROUP_ADD_USER = "GROUP_ADD_USER",
|
|
47
|
+
GROUP_CREATION = "GROUP_CREATION",
|
|
48
|
+
GROUP_DELETION = "GROUP_DELETION",
|
|
49
|
+
GROUP_EDITED = "GROUP_EDITED",
|
|
50
|
+
GROUP_REMOVE_FILE = "GROUP_REMOVE_FILE",
|
|
51
|
+
GROUP_REMOVE_FOLDER = "GROUP_REMOVE_FOLDER",
|
|
52
|
+
GROUP_REMOVE_USER = "GROUP_REMOVE_USER",
|
|
53
|
+
ITEM_MODIFY = "ITEM_MODIFY",
|
|
54
|
+
ITEM_OPEN = "ITEM_OPEN",
|
|
55
|
+
ITEM_SHARED_UPDATE = "ITEM_SHARED_UPDATE",
|
|
56
|
+
ITEM_SYNC = "ITEM_SYNC",
|
|
57
|
+
ITEM_UNSYNC = "ITEM_UNSYNC",
|
|
58
|
+
LOCK = "LOCK",
|
|
59
|
+
LOGIN = "LOGIN",
|
|
60
|
+
METADATA_INSTANCE_CREATE = "METADATA_INSTANCE_CREATE",
|
|
61
|
+
METADATA_INSTANCE_DELETE = "METADATA_INSTANCE_DELETE",
|
|
62
|
+
METADATA_INSTANCE_UPDATE = "METADATA_INSTANCE_UPDATE",
|
|
63
|
+
METADATA_TEMPLATE_CREATE = "METADATA_TEMPLATE_CREATE",
|
|
64
|
+
METADATA_TEMPLATE_UPDATE = "METADATA_TEMPLATE_UPDATE",
|
|
65
|
+
MOVE = "MOVE",
|
|
66
|
+
NEW_USER = "NEW_USER",
|
|
67
|
+
PREVIEW = "PREVIEW",
|
|
68
|
+
REMOVE_DEVICE_ASSOCIATION = "REMOVE_DEVICE_ASSOCIATION",
|
|
69
|
+
REMOVE_LOGIN_ACTIVITY_DEVICE = "REMOVE_LOGIN_ACTIVITY_DEVICE",
|
|
70
|
+
RENAME = "RENAME",
|
|
71
|
+
SHARE = "SHARE",
|
|
72
|
+
SHARE_EXPIRATION = "SHARE_EXPIRATION",
|
|
73
|
+
STORAGE_EXPIRATION = "STORAGE_EXPIRATION",
|
|
74
|
+
TASK_ASSIGNMENT_CREATE = "TASK_ASSIGNMENT_CREATE",
|
|
75
|
+
TASK_ASSIGNMENT_UPDATE = "TASK_ASSIGNMENT_UPDATE",
|
|
76
|
+
TASK_CREATE = "TASK_CREATE",
|
|
77
|
+
TERMS_OF_SERVICE_AGREE = "TERMS_OF_SERVICE_AGREE",
|
|
78
|
+
TERMS_OF_SERVICE_REJECT = "TERMS_OF_SERVICE_REJECT",
|
|
79
|
+
UNDELETE = "UNDELETE",
|
|
80
|
+
UNLOCK = "UNLOCK",
|
|
81
|
+
UNSHARE = "UNSHARE",
|
|
82
|
+
UPDATE_COLLABORATION_EXPIRATION = "UPDATE_COLLABORATION_EXPIRATION",
|
|
83
|
+
UPDATE_SHARE_EXPIRATION = "UPDATE_SHARE_EXPIRATION",
|
|
84
|
+
UPLOAD = "UPLOAD",
|
|
85
|
+
WATERMARK_LABEL_CREATE = "WATERMARK_LABEL_CREATE",
|
|
86
|
+
WATERMARK_LABEL_DELETE = "WATERMARK_LABEL_DELETE"
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Simple manager for interacting with all 'Events' endpoints and actions.
|
|
90
|
+
*
|
|
91
|
+
* @param {BoxClient} client The Box API Client that is responsible for making calls to the API
|
|
92
|
+
* @constructor
|
|
93
|
+
*/
|
|
94
|
+
declare class Events {
|
|
95
|
+
client: BoxClient;
|
|
96
|
+
CURRENT_STREAM_POSITION: string;
|
|
97
|
+
enterpriseEventTypes: typeof EventType;
|
|
98
|
+
constructor(client: BoxClient);
|
|
99
|
+
/**
|
|
100
|
+
* Get the current stream position.
|
|
101
|
+
*
|
|
102
|
+
* API Endpoint: '/events'
|
|
103
|
+
* Method: GET
|
|
104
|
+
*
|
|
105
|
+
* @param {Function} [callback] Passed the current stream position if successful
|
|
106
|
+
* @returns {Promise<string>} A promise resolving to the stream position
|
|
107
|
+
*/
|
|
108
|
+
getCurrentStreamPosition(callback?: Function): any;
|
|
109
|
+
/**
|
|
110
|
+
* Get a chunk of events
|
|
111
|
+
*
|
|
112
|
+
* API Endpoint: '/events'
|
|
113
|
+
* Method: GET
|
|
114
|
+
*
|
|
115
|
+
* @param {Object} [options] - Additional options for the request. Can be left null in most cases.
|
|
116
|
+
* @param {Function} [callback] Passed the current stream position if successful
|
|
117
|
+
* @returns {Promise<Object>} A promise resolving to the collection of events
|
|
118
|
+
*/
|
|
119
|
+
get(options?: Record<string, any>, callback?: Function): any;
|
|
120
|
+
/**
|
|
121
|
+
* Get information for long-polling until new events are available
|
|
122
|
+
*
|
|
123
|
+
* API Endpoint: '/events'
|
|
124
|
+
* Method: OPTIONS
|
|
125
|
+
*
|
|
126
|
+
* @param {Function} [callback] Passed the long poll info if successful
|
|
127
|
+
* @returns {Promise<Object>} A promise resolving to the long poll info
|
|
128
|
+
*/
|
|
129
|
+
getLongPollInfo(callback?: Function): any;
|
|
130
|
+
/**
|
|
131
|
+
* Create a stream of events, using the long-poll API to wait for new events.
|
|
132
|
+
*
|
|
133
|
+
* API Endpoint: '/events'
|
|
134
|
+
* Method: OPTIONS
|
|
135
|
+
*
|
|
136
|
+
* @param {string} [streamPosition] Starting stream position
|
|
137
|
+
* @param {Object} [options] Optional parameters for the event stream
|
|
138
|
+
* @param {int} [options.retryDelay=1000] Number of ms to wait before retrying after an error
|
|
139
|
+
* @param {int} [options.deduplicationFilterSize=5000] Number of IDs to track for deduplication
|
|
140
|
+
* @param {int} [options.fetchInterval=1000] Minimunm number of ms between calls for more events
|
|
141
|
+
* @param {Function} [callback] Passed the events stream if successful
|
|
142
|
+
* @returns {Promise<EventStream>} A promise resolving to the event stream
|
|
143
|
+
*/
|
|
144
|
+
getEventStream(streamPosition: string, options?: {
|
|
145
|
+
retryDelay?: number;
|
|
146
|
+
deduplicationFilterSize?: number;
|
|
147
|
+
fetchInterval?: number;
|
|
148
|
+
} | Function, callback?: Function): any;
|
|
149
|
+
/**
|
|
150
|
+
* Create a stream of enterprise events.
|
|
151
|
+
*
|
|
152
|
+
* By default, the stream starts from the current time.
|
|
153
|
+
* Pass 'startDate' to start from a specific time.
|
|
154
|
+
* Pass 'streamPosition' to start from a previous stream position, or '0' for all available past events (~1 year).
|
|
155
|
+
* Once the stream catches up to the current time, it will begin polling every 'pollingInterval' seconds.
|
|
156
|
+
* If 'pollingInterval' = 0, then the stream will end when it catches up to the current time (no polling).
|
|
157
|
+
*
|
|
158
|
+
* @param {Object} [options] - Options
|
|
159
|
+
* @param {string} [options.streamPosition] - The stream position to start from (pass '0' for all past events)
|
|
160
|
+
* @param {string} [options.startDate] - The date to start from
|
|
161
|
+
* @param {string} [options.endDate] - The date to end at
|
|
162
|
+
* @param {EventType[]} [options.eventTypeFilter] - Array of event types to return
|
|
163
|
+
* @param {int} [options.pollingInterval=60] - Polling interval (in seconds). Pass 0 for no polling.
|
|
164
|
+
* @param {int} [options.chunkSize=500] - Number of events to fetch per call (max = 500)
|
|
165
|
+
* @param {Function} [callback] Passed the events stream if successful
|
|
166
|
+
* @returns {Promise<EnterpriseEventStream>} A promise resolving to the enterprise event stream
|
|
167
|
+
*/
|
|
168
|
+
getEnterpriseEventStream(options?: {
|
|
169
|
+
streamPosition?: string;
|
|
170
|
+
startDate?: string;
|
|
171
|
+
endDate?: string;
|
|
172
|
+
eventTypeFilter?: EventType[];
|
|
173
|
+
pollingInterval?: number;
|
|
174
|
+
chunkSize?: number;
|
|
175
|
+
}, callback?: Function): import("bluebird")<EnterpriseEventStream>;
|
|
176
|
+
}
|
|
177
|
+
export = Events;
|