box-node-sdk 1.35.0 → 1.37.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/CHANGELOG.md +37 -2
  2. package/README.md +1 -1
  3. package/lib/api-request-manager.d.ts +38 -0
  4. package/lib/api-request-manager.js +48 -55
  5. package/lib/api-request-manager.js.map +1 -0
  6. package/lib/api-request.d.ts +141 -0
  7. package/lib/api-request.js +202 -281
  8. package/lib/api-request.js.map +1 -0
  9. package/lib/box-client.d.ts +269 -0
  10. package/lib/box-client.js +551 -713
  11. package/lib/box-client.js.map +1 -0
  12. package/lib/box-node-sdk.d.ts +216 -0
  13. package/lib/box-node-sdk.js +317 -352
  14. package/lib/box-node-sdk.js.map +1 -0
  15. package/lib/chunked-uploader.d.ts +129 -0
  16. package/lib/chunked-uploader.js +287 -358
  17. package/lib/chunked-uploader.js.map +1 -0
  18. package/lib/enterprise-event-stream.d.ts +82 -0
  19. package/lib/enterprise-event-stream.js +189 -203
  20. package/lib/enterprise-event-stream.js.map +1 -0
  21. package/lib/event-stream.d.ts +92 -0
  22. package/lib/event-stream.js +274 -302
  23. package/lib/event-stream.js.map +1 -0
  24. package/lib/managers/collaboration-allowlist.d.ts +137 -0
  25. package/lib/managers/collaboration-allowlist.js +200 -0
  26. package/lib/managers/collaboration-allowlist.js.map +1 -0
  27. package/lib/managers/collaboration-whitelist.d.ts +3 -0
  28. package/lib/managers/collaboration-whitelist.js +8 -222
  29. package/lib/managers/collaboration-whitelist.js.map +1 -0
  30. package/lib/managers/collaborations.d.ts +166 -0
  31. package/lib/managers/collaborations.js +225 -258
  32. package/lib/managers/collaborations.js.map +1 -0
  33. package/lib/managers/collections.d.ts +42 -0
  34. package/lib/managers/collections.js +45 -50
  35. package/lib/managers/collections.js.map +1 -0
  36. package/lib/managers/comments.d.ts +103 -0
  37. package/lib/managers/comments.js +158 -173
  38. package/lib/managers/comments.js.map +1 -0
  39. package/lib/managers/device-pins.d.ts +52 -0
  40. package/lib/managers/device-pins.js +75 -88
  41. package/lib/managers/device-pins.js.map +1 -0
  42. package/lib/managers/enterprise.d.ts +162 -0
  43. package/lib/managers/enterprise.js +168 -199
  44. package/lib/managers/enterprise.js.map +1 -0
  45. package/lib/managers/events.d.ts +177 -0
  46. package/lib/managers/events.js +230 -254
  47. package/lib/managers/events.js.map +1 -0
  48. package/lib/managers/files.d.ts +772 -0
  49. package/lib/managers/files.js +1400 -1602
  50. package/lib/managers/files.js.map +1 -0
  51. package/lib/managers/folders.d.ts +347 -0
  52. package/lib/managers/folders.js +551 -567
  53. package/lib/managers/folders.js.map +1 -0
  54. package/lib/managers/groups.d.ts +202 -0
  55. package/lib/managers/groups.js +238 -287
  56. package/lib/managers/groups.js.map +1 -0
  57. package/lib/managers/legal-hold-policies.d.ts +190 -0
  58. package/lib/managers/legal-hold-policies.js +228 -272
  59. package/lib/managers/legal-hold-policies.js.map +1 -0
  60. package/lib/managers/metadata.d.ts +228 -0
  61. package/lib/managers/metadata.js +265 -328
  62. package/lib/managers/metadata.js.map +1 -0
  63. package/lib/managers/recent-items.d.ts +38 -0
  64. package/lib/managers/recent-items.js +32 -39
  65. package/lib/managers/recent-items.js.map +1 -0
  66. package/lib/managers/retention-policies.d.ts +213 -0
  67. package/lib/managers/retention-policies.js +235 -281
  68. package/lib/managers/retention-policies.js.map +1 -0
  69. package/lib/managers/search.d.ts +82 -0
  70. package/lib/managers/search.js +68 -88
  71. package/lib/managers/search.js.map +1 -0
  72. package/lib/managers/shared-items.d.ts +33 -0
  73. package/lib/managers/shared-items.js +54 -62
  74. package/lib/managers/shared-items.js.map +1 -0
  75. package/lib/managers/storage-policies.d.ts +86 -0
  76. package/lib/managers/storage-policies.js +108 -142
  77. package/lib/managers/storage-policies.js.map +1 -0
  78. package/lib/managers/tasks.d.ts +161 -0
  79. package/lib/managers/tasks.js +219 -260
  80. package/lib/managers/tasks.js.map +1 -0
  81. package/lib/managers/terms-of-service.d.ts +161 -0
  82. package/lib/managers/terms-of-service.js +250 -273
  83. package/lib/managers/terms-of-service.js.map +1 -0
  84. package/lib/managers/trash.d.ts +30 -0
  85. package/lib/managers/trash.js +30 -41
  86. package/lib/managers/trash.js.map +1 -0
  87. package/lib/managers/users.d.ts +131 -0
  88. package/lib/managers/users.js +160 -203
  89. package/lib/managers/users.js.map +1 -0
  90. package/lib/managers/web-links.d.ts +127 -0
  91. package/lib/managers/web-links.js +183 -209
  92. package/lib/managers/web-links.js.map +1 -0
  93. package/lib/managers/webhooks.d.ts +166 -0
  94. package/lib/managers/webhooks.js +312 -305
  95. package/lib/managers/webhooks.js.map +1 -0
  96. package/lib/sessions/anonymous-session.d.ts +69 -0
  97. package/lib/sessions/anonymous-session.js +88 -102
  98. package/lib/sessions/anonymous-session.js.map +1 -0
  99. package/lib/sessions/app-auth-session.d.ts +92 -0
  100. package/lib/sessions/app-auth-session.js +140 -160
  101. package/lib/sessions/app-auth-session.js.map +1 -0
  102. package/lib/sessions/basic-session.d.ts +56 -0
  103. package/lib/sessions/basic-session.js +40 -50
  104. package/lib/sessions/basic-session.js.map +1 -0
  105. package/lib/sessions/persistent-session.d.ts +96 -0
  106. package/lib/sessions/persistent-session.js +191 -211
  107. package/lib/sessions/persistent-session.js.map +1 -0
  108. package/lib/token-manager.d.ts +191 -0
  109. package/lib/token-manager.js +390 -465
  110. package/lib/token-manager.js.map +1 -0
  111. package/lib/util/config.d.ts +86 -0
  112. package/lib/util/config.js +124 -152
  113. package/lib/util/config.js.map +1 -0
  114. package/lib/util/errors.d.ts +50 -0
  115. package/lib/util/errors.js +134 -145
  116. package/lib/util/errors.js.map +1 -0
  117. package/lib/util/exponential-backoff.d.ts +11 -0
  118. package/lib/util/exponential-backoff.js +10 -22
  119. package/lib/util/exponential-backoff.js.map +1 -0
  120. package/lib/util/paging-iterator.d.ts +53 -0
  121. package/lib/util/paging-iterator.js +202 -218
  122. package/lib/util/paging-iterator.js.map +1 -0
  123. package/lib/util/url-path.d.ts +16 -0
  124. package/lib/util/url-path.js +20 -35
  125. package/lib/util/url-path.js.map +1 -0
  126. package/package.json +24 -9
@@ -1,42 +1,32 @@
1
+ "use strict";
1
2
  /**
2
3
  * @fileoverview Manager for the Box Search Resource
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
-
11
- var urlPath = require('../util/url-path'),
12
- Promise = require('bluebird');
13
-
14
- // -----------------------------------------------------------------------------
15
- // Typedefs
16
- // -----------------------------------------------------------------------------
17
-
11
+ var bluebird_1 = require("bluebird");
12
+ var url_path_1 = __importDefault(require("../util/url-path"));
18
13
  /**
19
- * Search metadata filter
20
- * @typedef {Object} SearchMetadataFilter
21
- * @property {string} templateKey The template to filter against
22
- * @property {string} scope The scope of the template, e.g. 'global' or 'enterprise'
23
- * @property {Object} filters Key/value filters against individual metadata template properties
14
+ * Valid search scopes
15
+ * @readonly
16
+ * @enum {SearchScope}
24
17
  */
25
-
26
- /** @typedef {string} SearchScope */
27
-
28
- /** @typedef {string} SearchTrashContent */
29
-
18
+ var SearchScope;
19
+ (function (SearchScope) {
20
+ SearchScope["USER"] = "user_content";
21
+ SearchScope["ENTERPRISE"] = "enterprise_content";
22
+ })(SearchScope || (SearchScope = {}));
30
23
  // -----------------------------------------------------------------------------
31
24
  // Private
32
25
  // -----------------------------------------------------------------------------
33
-
34
26
  var API_PATHS_SEARCH = '/search';
35
-
36
27
  // -----------------------------------------------------------------------------
37
28
  // Public
38
29
  // -----------------------------------------------------------------------------
39
-
40
30
  /**
41
31
  * Simple manager for interacting with the search endpoints and actions.
42
32
  *
@@ -44,68 +34,58 @@ var API_PATHS_SEARCH = '/search';
44
34
  * @param {BoxClient} client - The Box API Client that is responsible for making calls to the API
45
35
  * @returns {void}
46
36
  */
47
- function Search(client) {
48
- this.client = client;
49
- }
50
-
51
- Search.prototype = {
52
-
53
- /**
54
- * Valid search scopes
55
- * @readonly
56
- * @enum {SearchScope}
57
- */
58
- scopes: Object.freeze({
59
- USER: 'user_content',
60
- ENTERPRISE: 'enterprise_content'
61
- }),
62
-
63
- /**
64
- * Searches Box for the given query.
65
- *
66
- * @param {string} searchString - The query string to use for search
67
- * @param {Object} [options] - Additional search filters. Can be left null in most cases.
68
- * @param {SearchScope} [options.scope] - The scope on which you want search. Can be user_content for a search limited to the current user or enterprise_content to search an entire enterprise
69
- * @param {string} [options.file_extensions] - Single or comma-delimited list of file extensions to filter against
70
- * @param {string} [options.created_at_range] - Date range for filtering on item creation time, e.g. '2014-05-15T13:35:01-07:00,2014-05-17T13:35:01-07:00'
71
- * @param {string} [options.updated_at_range] - Date range for filtering on item update time, e.g. '2014-05-15T13:35:01-07:00,2014-05-17T13:35:01-07:00'
72
- * @param {string} [options.size_range] - Range of item sizes (in bytes) to filter on, as lower_bound,upper_bound. Either bound can be ommitted, e.g. ',100000' for <= 100KB
73
- * @param {string} [options.owner_user_ids] - Comma-delimited list of user IDs to filter item owner against
74
- * @param {string} [options.ancestor_folder_ids] - Comma-delimited list of folder IDs, search results will contain only items in these folders (and folders within them)
75
- * @param {string} [options.content_types] - Query within specified comma-delimited fields. The types can be name, description, file_content, comments, or tags
76
- * @param {string} [options.type] - The type of objects you want to include in the search results. The type can be file, folder, or web_link
77
- * @param {string} [options.trash_content=non_trashed_only] - Controls whether to search in the trash. The value can be trashed_only or non_trashed_only
78
- * @param {SearchMetadataFilter[]} [options.mdfilters] - Searches for objects with a specific metadata object association. Searches with the this parameter do not require a query string
79
- * @param {boolean} [options.include_recent_shared_links] - Determines whether to include items accessible only via shared link in the response.
80
- * @param {string} [options.fields] - Comma-delimited list of fields to be included in the response
81
- * @param {int} [options.limit=30] - The number of search results to return, max 200
82
- * @param {int} [options.offset=0] - The search result at which to start the response, must be a multiple of limit
83
- * @param {string} [options.sort] - The field on which the results should be sorted, e.g. "modified_at"
84
- * @param {string} [options.direction] - The sort direction: "ASC" for ascending and "DESC" for descending
85
- * @param {APIRequest~Callback} [callback] - passed the new comment data if it was posted successfully
86
- * @returns {Promise<Object>} A promise resolving to the collection of search results
87
- */
88
- query(searchString, options, callback) {
89
-
90
- var apiPath = urlPath(API_PATHS_SEARCH),
91
- qs = options || {};
92
-
93
- qs.query = searchString;
94
-
95
- if (qs.mdfilters) {
96
- if (Array.isArray(qs.mdfilters)) {
97
- qs.mdfilters = JSON.stringify(qs.mdfilters);
98
- } else {
99
- return Promise.reject(new Error('Invalid mdfilters parameter: must be a valid array')).asCallback(callback);
100
- }
101
- }
102
-
103
- var params = {
104
- qs
105
- };
106
- return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, params, callback);
107
- }
108
-
109
- };
110
-
37
+ var Search = /** @class */ (function () {
38
+ function Search(client) {
39
+ this.client = client;
40
+ }
41
+ /**
42
+ * Searches Box for the given query.
43
+ *
44
+ * @param {string} searchString - The query string to use for search
45
+ * @param {Object} [options] - Additional search filters. Can be left null in most cases.
46
+ * @param {SearchScope} [options.scope] - The scope on which you want search. Can be user_content for a search limited to the current user or enterprise_content to search an entire enterprise
47
+ * @param {string} [options.file_extensions] - Single or comma-delimited list of file extensions to filter against
48
+ * @param {string} [options.created_at_range] - Date range for filtering on item creation time, e.g. '2014-05-15T13:35:01-07:00,2014-05-17T13:35:01-07:00'
49
+ * @param {string} [options.updated_at_range] - Date range for filtering on item update time, e.g. '2014-05-15T13:35:01-07:00,2014-05-17T13:35:01-07:00'
50
+ * @param {string} [options.size_range] - Range of item sizes (in bytes) to filter on, as lower_bound,upper_bound. Either bound can be ommitted, e.g. ',100000' for <= 100KB
51
+ * @param {string} [options.owner_user_ids] - Comma-delimited list of user IDs to filter item owner against
52
+ * @param {string} [options.ancestor_folder_ids] - Comma-delimited list of folder IDs, search results will contain only items in these folders (and folders within them)
53
+ * @param {string} [options.content_types] - Query within specified comma-delimited fields. The types can be name, description, file_content, comments, or tags
54
+ * @param {string} [options.type] - The type of objects you want to include in the search results. The type can be file, folder, or web_link
55
+ * @param {string} [options.trash_content=non_trashed_only] - Controls whether to search in the trash. The value can be trashed_only or non_trashed_only
56
+ * @param {SearchMetadataFilter[]} [options.mdfilters] - Searches for objects with a specific metadata object association. Searches with the this parameter do not require a query string
57
+ * @param {boolean} [options.include_recent_shared_links] - Determines whether to include items accessible only via shared link in the response.
58
+ * @param {string} [options.fields] - Comma-delimited list of fields to be included in the response
59
+ * @param {int} [options.limit=30] - The number of search results to return, max 200
60
+ * @param {int} [options.offset=0] - The search result at which to start the response, must be a multiple of limit
61
+ * @param {string} [options.sort] - The field on which the results should be sorted, e.g. "modified_at"
62
+ * @param {string} [options.direction] - The sort direction: "ASC" for ascending and "DESC" for descending
63
+ * @param {APIRequest~Callback} [callback] - passed the new comment data if it was posted successfully
64
+ * @returns {Promise<Object>} A promise resolving to the collection of search results
65
+ */
66
+ Search.prototype.query = function (searchString, options, callback) {
67
+ var apiPath = url_path_1.default(API_PATHS_SEARCH), qs = options || {};
68
+ qs.query = searchString;
69
+ if (qs.mdfilters) {
70
+ if (Array.isArray(qs.mdfilters)) {
71
+ qs.mdfilters = JSON.stringify(qs.mdfilters);
72
+ }
73
+ else {
74
+ return bluebird_1.Promise.reject(new Error('Invalid mdfilters parameter: must be a valid array')).asCallback(callback);
75
+ }
76
+ }
77
+ var params = {
78
+ qs: qs,
79
+ };
80
+ return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, params, callback);
81
+ };
82
+ return Search;
83
+ }());
84
+ /**
85
+ * Valid search scopes
86
+ * @readonly
87
+ * @enum {SearchScope}
88
+ */
89
+ Search.prototype.scopes = SearchScope;
111
90
  module.exports = Search;
91
+ //# sourceMappingURL=search.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search.js","sourceRoot":"","sources":["../../src/managers/search.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,gFAAgF;AAChF,eAAe;AACf,gFAAgF;AAEhF,qCAAmC;AAEnC,8DAAuC;AAmBvC;;;;GAIG;AACH,IAAK,WAGJ;AAHD,WAAK,WAAW;IACf,oCAAqB,CAAA;IACrB,gDAAiC,CAAA;AAClC,CAAC,EAHI,WAAW,KAAX,WAAW,QAGf;AAKD,gFAAgF;AAChF,UAAU;AACV,gFAAgF;AAEhF,IAAI,gBAAgB,GAAG,SAAS,CAAC;AAEjC,gFAAgF;AAChF,SAAS;AACT,gFAAgF;AAEhF;;;;;;GAMG;AACH;IAIC,gBAAY,MAAiB;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,sBAAK,GAAL,UACC,YAAoB,EACpB,OAkBC,EACD,QAAmB;QAEnB,IAAI,OAAO,GAAG,kBAAO,CAAC,gBAAgB,CAAC,EACtC,EAAE,GAAG,OAAO,IAAK,EAA0B,CAAC;QAE7C,EAAE,CAAC,KAAK,GAAG,YAAY,CAAC;QAExB,IAAI,EAAE,CAAC,SAAS,EAAE;YACjB,IAAI,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE;gBAChC,EAAE,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;aAC5C;iBAAM;gBACN,OAAO,kBAAO,CAAC,MAAM,CACpB,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAC/D,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;aACvB;SACD;QAED,IAAI,MAAM,GAAG;YACZ,EAAE,IAAA;SACF,CAAC;QACF,OAAO,IAAI,CAAC,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CACzD,OAAO,EACP,MAAM,EACN,QAAQ,CACR,CAAC;IACH,CAAC;IACF,aAAC;AAAD,CAAC,AAhFD,IAgFC;AAED;;;;GAIG;AACH,MAAM,CAAC,SAAS,CAAC,MAAM,GAAG,WAAW,CAAC;AAEtC,iBAAS,MAAM,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @fileoverview Manager for the Shared Items
3
+ */
4
+ import BoxClient from '../box-client';
5
+ /**
6
+ * Simple manager for interacting with all 'Shared Item' endpoints and actions.
7
+ *
8
+ * @constructor
9
+ * @param {BoxClient} client - The Box API Client that is responsible for making calls to the API
10
+ * @returns {void}
11
+ */
12
+ declare class SharedItems {
13
+ client: BoxClient;
14
+ constructor(client: BoxClient);
15
+ /**
16
+ * Requests a Box item associated with a shared link.
17
+ *
18
+ * API Endpoint: '/shared_items'
19
+ * Method: GET
20
+ *
21
+ * @param {string} url - Shared Link URL
22
+ * @param {string} [password] - Shared Link Password (null if no password)
23
+ * @param {Object} [options] - Additional options for the request. Can be left null in most cases.
24
+ * @param {Function} [callback] - passed the shared item if it was successfully acquired
25
+ * @returns {Promise<Object>} A promise resolving to the shared item object
26
+ */
27
+ get(url: string, password: string, options?: Record<string, any>, callback?: Function): any;
28
+ }
29
+ /**
30
+ * @module box-node-sdk/lib/managers/shared-items
31
+ * @see {@Link SharedItems}
32
+ */
33
+ export = SharedItems;
@@ -1,26 +1,22 @@
1
+ "use strict";
1
2
  /**
2
3
  * @fileoverview Manager for the Shared Items
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 errors = require('../util/errors'),
11
- httpStatusCodes = require('http-status');
12
-
13
-
11
+ var http_status_1 = __importDefault(require("http-status"));
12
+ var errors_1 = __importDefault(require("../util/errors"));
14
13
  // ------------------------------------------------------------------------------
15
14
  // Private
16
15
  // ------------------------------------------------------------------------------
17
16
  var BASE_PATH = '/shared_items';
18
-
19
-
20
17
  // ------------------------------------------------------------------------------
21
18
  // Public
22
19
  // ------------------------------------------------------------------------------
23
-
24
20
  /**
25
21
  * Simple manager for interacting with all 'Shared Item' endpoints and actions.
26
22
  *
@@ -28,56 +24,52 @@ var BASE_PATH = '/shared_items';
28
24
  * @param {BoxClient} client - The Box API Client that is responsible for making calls to the API
29
25
  * @returns {void}
30
26
  */
31
- function SharedItems(client) {
32
- this.client = client;
33
- }
34
-
35
- /**
36
- * Requests a Box item associated with a shared link.
37
- *
38
- * API Endpoint: '/shared_items'
39
- * Method: GET
40
- *
41
- * @param {string} url - Shared Link URL
42
- * @param {string} [password] - Shared Link Password (null if no password)
43
- * @param {Object} [options] - Additional options for the request. Can be left null in most cases.
44
- * @param {Function} [callback] - passed the shared item if it was successfully acquired
45
- * @returns {Promise<Object>} A promise resolving to the shared item object
46
- */
47
- SharedItems.prototype.get = function(url, password, options, callback) {
48
- var params = {
49
- qs: options,
50
- headers: {
51
- BoxApi: this.client.buildSharedItemAuthHeader(url, password)
52
- }
53
- };
54
-
55
- // Handle the Special API Response
56
- return this.client.get(BASE_PATH, params)
57
- .then(response => {
58
-
59
- switch (response.statusCode) {
60
-
61
- // 200 - Shared Item Recieved
62
- case httpStatusCodes.OK:
63
- return response.body;
64
-
65
- // 403 - Incorrect or missing password
66
- // Propagate an error explaining that the password is either missing or incorrect
67
- case httpStatusCodes.FORBIDDEN:
68
- var errMessage = (password) ? 'Incorrect shared link password' : 'Shared link password missing';
69
- throw errors.buildResponseError(response, errMessage);
70
-
71
- // Unexpected Response
72
- default:
73
- throw errors.buildUnexpectedResponseError(response);
74
- }
75
- })
76
- .asCallback(callback);
77
- };
78
-
79
- /**
80
- * @module box-node-sdk/lib/managers/shared-items
81
- * @see {@Link SharedItems}
82
- */
27
+ var SharedItems = /** @class */ (function () {
28
+ function SharedItems(client) {
29
+ this.client = client;
30
+ }
31
+ /**
32
+ * Requests a Box item associated with a shared link.
33
+ *
34
+ * API Endpoint: '/shared_items'
35
+ * Method: GET
36
+ *
37
+ * @param {string} url - Shared Link URL
38
+ * @param {string} [password] - Shared Link Password (null if no password)
39
+ * @param {Object} [options] - Additional options for the request. Can be left null in most cases.
40
+ * @param {Function} [callback] - passed the shared item if it was successfully acquired
41
+ * @returns {Promise<Object>} A promise resolving to the shared item object
42
+ */
43
+ SharedItems.prototype.get = function (url, password, options, callback) {
44
+ var params = {
45
+ qs: options,
46
+ headers: {
47
+ BoxApi: this.client.buildSharedItemAuthHeader(url, password),
48
+ },
49
+ };
50
+ // Handle the Special API Response
51
+ return this.client
52
+ .get(BASE_PATH, params)
53
+ .then(function (response /* FIXME */) {
54
+ switch (response.statusCode) {
55
+ // 200 - Shared Item Recieved
56
+ case http_status_1.default.OK:
57
+ return response.body;
58
+ // 403 - Incorrect or missing password
59
+ // Propagate an error explaining that the password is either missing or incorrect
60
+ case http_status_1.default.FORBIDDEN:
61
+ var errMessage = password
62
+ ? 'Incorrect shared link password'
63
+ : 'Shared link password missing';
64
+ throw errors_1.default.buildResponseError(response, errMessage);
65
+ // Unexpected Response
66
+ default:
67
+ throw errors_1.default.buildUnexpectedResponseError(response);
68
+ }
69
+ })
70
+ .asCallback(callback);
71
+ };
72
+ return SharedItems;
73
+ }());
83
74
  module.exports = SharedItems;
75
+ //# sourceMappingURL=shared-items.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-items.js","sourceRoot":"","sources":["../../src/managers/shared-items.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,iFAAiF;AACjF,eAAe;AACf,iFAAiF;AAEjF,4DAA0C;AAE1C,0DAAoC;AAEpC,iFAAiF;AACjF,UAAU;AACV,iFAAiF;AAEjF,IAAM,SAAS,GAAG,eAAe,CAAC;AAElC,iFAAiF;AACjF,SAAS;AACT,iFAAiF;AAEjF;;;;;;GAMG;AACH;IAGC,qBAAY,MAAiB;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACtB,CAAC;IAED;;;;;;;;;;;OAWG;IACH,yBAAG,GAAH,UACC,GAAW,EACX,QAAgB,EAChB,OAA6B,EAC7B,QAAmB;QAEnB,IAAI,MAAM,GAAG;YACZ,EAAE,EAAE,OAAO;YACX,OAAO,EAAE;gBACR,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,yBAAyB,CAAC,GAAG,EAAE,QAAQ,CAAC;aAC5D;SACD,CAAC;QAEF,kCAAkC;QAClC,OAAO,IAAI,CAAC,MAAM;aAChB,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC;aACtB,IAAI,CAAC,UAAC,QAAa,CAAC,WAAW;YAC/B,QAAQ,QAAQ,CAAC,UAAU,EAAE;gBAC5B,6BAA6B;gBAC7B,KAAK,qBAAe,CAAC,EAAE;oBACtB,OAAO,QAAQ,CAAC,IAAI,CAAC;gBAEtB,sCAAsC;gBACtC,iFAAiF;gBACjF,KAAK,qBAAe,CAAC,SAAS;oBAC7B,IAAI,UAAU,GAAG,QAAQ;wBACxB,CAAC,CAAC,gCAAgC;wBAClC,CAAC,CAAC,8BAA8B,CAAC;oBAClC,MAAM,gBAAM,CAAC,kBAAkB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;gBAEvD,sBAAsB;gBACtB;oBACC,MAAM,gBAAM,CAAC,4BAA4B,CAAC,QAAQ,CAAC,CAAC;aACrD;QACF,CAAC,CAAC;aACD,UAAU,CAAC,QAAQ,CAAC,CAAC;IACxB,CAAC;IACF,kBAAC;AAAD,CAAC,AAxDD,IAwDC;AAMD,iBAAS,WAAW,CAAC"}
@@ -0,0 +1,86 @@
1
+ /**
2
+ * @fileoverview Manager for the Storage Policies resource
3
+ */
4
+ import BoxClient from '../box-client';
5
+ /**
6
+ * Simple manager for interacting with all Retention Policies endpoints and actions.
7
+ *
8
+ * @constructor
9
+ * @param {BoxClient} client - The Box API Client that is responsible for making calls to the API
10
+ * @returns {void}
11
+ */
12
+ declare class StoragePolicies {
13
+ client: BoxClient;
14
+ constructor(client: BoxClient);
15
+ /**
16
+ * Get information about a specific storage policy
17
+ * @param {string} storagePolicyID The ID of the storage policy
18
+ * @param {Object} [options] Optional parameters
19
+ * @param {string} [options.fields] Comma-separated list of fields of the storage policy to retrieve
20
+ * @param {Function} [callback] Passed the storage policy object if successful
21
+ * @returns {Promise<Object>} Promise resolving to the storage policy object
22
+ */
23
+ get(storagePolicyID: string, options?: {
24
+ fields?: string;
25
+ }, callback?: Function): any;
26
+ /**
27
+ * Get all available storage policies for the enterprise
28
+ * @param {Object} [options] Optional parameters
29
+ * @param {string} [options.fields] Comma-separated list of fields of the storage policy to retrieve
30
+ * @param {Function} [callback] Passed a collection of storage policies if successful
31
+ * @returns {Promise<Object>} Promise resolving to the collection of storage policies
32
+ */
33
+ getAll(options?: {
34
+ fields?: string;
35
+ }, callback?: Function): any;
36
+ /**
37
+ * Assign a storage policy to a user
38
+ * @param {string} storagePolicyID The ID of the storage policy to assign
39
+ * @param {string} userID The ID of the user to assign the storage policy to
40
+ * @param {Function} [callback] Passed the assignment object if successful
41
+ * @returns {Promise<Object>} Promise resolving to the assignment object
42
+ */
43
+ assign(storagePolicyID: string, userID: string, callback?: Function): any;
44
+ /**
45
+ * Get information about a specific storage policy asisgnment by ID
46
+ * @param {string} assignmentID The ID of the assignment
47
+ * @param {Function} [callback] Passed the assignment object if successful
48
+ * @returns {Promise<Object>} Promise resolving to the assignment object
49
+ */
50
+ getAssignment(assignmentID: string, callback?: Function): any;
51
+ /**
52
+ * Gets the storage policy assignment for a specific user
53
+ * @param {string} targetID The ID of the target
54
+ * @param {Object} [options] Optional parameters
55
+ * @param {string} [options.targetType=user] The type of the assignment target to resolve for
56
+ * @param {Function} [callback] Passed the assignment object if successful
57
+ * @returns {Promise<Object>} Promise resolving to the assignment object
58
+ */
59
+ getAssignmentForTarget(targetID: string, options?: {
60
+ targetType?: string;
61
+ }, callback?: Function): any;
62
+ /**
63
+ * Create a new storage policy assignment to a user
64
+ * @param {string} storagePolicyID The ID of the storage policy to assign
65
+ * @param {string} userID The ID of the user to assign the storage policy to
66
+ * @param {Function} [callback] Passed the assignment object if successful
67
+ * @returns {Promise<Object>} Promise resolving to the assignment object
68
+ */
69
+ createAssignment(storagePolicyID: string, userID: string, callback?: Function): any;
70
+ /**
71
+ * Update a storage policy assignment
72
+ * @param {string} assignmentID The ID of the storage policy assignment to update
73
+ * @param {Object} updates The updates fields to apply
74
+ * @param {Function} [callback] Passed the updated assignment object if successful
75
+ * @returns {Promise<Object>} Promise resolving to the updated assignment object
76
+ */
77
+ updateAssignment(assignmentID: string, updates: Record<string, any>, callback?: Function): any;
78
+ /**
79
+ * Remove a storage policy assignment, returning the user to the default policy
80
+ * @param {string} assignmentID The ID of the assignment to remove
81
+ * @param {Function} [callback] Passed nothing if successful
82
+ * @returns {Promise<void>} Promise resolving if the removal succeeds
83
+ */
84
+ removeAssignment(assignmentID: string, callback?: Function): any;
85
+ }
86
+ export = StoragePolicies;