@unofficialbox/box-open-sdk 0.2.0 → 0.4.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.
- package/LICENSE +21 -0
- package/README.md +3 -1
- package/dist/cjs/auth.js +3 -3
- package/dist/cjs/buildinfo.js +2 -2
- package/dist/cjs/chunked_upload.js +108 -0
- package/dist/cjs/client.js +3 -0
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/jwt.js +1 -1
- package/dist/cjs/managers/chunked_uploads.js +4 -4
- package/dist/cjs/managers/collaboration_allowlist_entries.js +6 -6
- package/dist/cjs/managers/collaboration_allowlist_exempt_targets.js +6 -6
- package/dist/cjs/managers/index.js +1 -0
- package/dist/cjs/managers/memberships.js +4 -4
- package/dist/cjs/managers/query.js +68 -0
- package/dist/cjs/models/schemas.js +1 -1
- package/dist/cjs/runtime.js +8 -3
- package/dist/cjs/tokens.js +5 -3
- package/dist/esm/auth.js +3 -3
- package/dist/esm/buildinfo.js +2 -2
- package/dist/esm/chunked_upload.js +104 -0
- package/dist/esm/client.js +3 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/jwt.js +1 -1
- package/dist/esm/managers/chunked_uploads.js +4 -4
- package/dist/esm/managers/collaboration_allowlist_entries.js +6 -6
- package/dist/esm/managers/collaboration_allowlist_exempt_targets.js +6 -6
- package/dist/esm/managers/index.js +1 -0
- package/dist/esm/managers/memberships.js +4 -4
- package/dist/esm/managers/query.js +31 -0
- package/dist/esm/models/schemas.js +1 -1
- package/dist/esm/runtime.js +8 -3
- package/dist/esm/tokens.js +5 -3
- package/dist/types/auth.d.ts +8 -0
- package/dist/types/buildinfo.d.ts +1 -1
- package/dist/types/chunked_upload.d.ts +21 -0
- package/dist/types/client.d.ts +2 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/jwt.d.ts +4 -0
- package/dist/types/managers/archives.d.ts +2 -2
- package/dist/types/managers/avatars.d.ts +1 -1
- package/dist/types/managers/chunked_uploads.d.ts +3 -3
- package/dist/types/managers/classifications.d.ts +3 -3
- package/dist/types/managers/collaboration_allowlist_entries.d.ts +7 -7
- package/dist/types/managers/collaboration_allowlist_exempt_targets.d.ts +7 -7
- package/dist/types/managers/comments.d.ts +2 -2
- package/dist/types/managers/email_aliases.d.ts +1 -1
- package/dist/types/managers/file_classifications.d.ts +2 -2
- package/dist/types/managers/file_metadata.d.ts +4 -4
- package/dist/types/managers/file_versions.d.ts +2 -2
- package/dist/types/managers/file_watermarks.d.ts +1 -1
- package/dist/types/managers/files.d.ts +2 -2
- package/dist/types/managers/folder_classifications.d.ts +2 -2
- package/dist/types/managers/folder_locks.d.ts +1 -1
- package/dist/types/managers/folder_metadata.d.ts +4 -4
- package/dist/types/managers/folder_watermarks.d.ts +1 -1
- package/dist/types/managers/folders.d.ts +3 -3
- package/dist/types/managers/groups.d.ts +2 -2
- package/dist/types/managers/index.d.ts +1 -0
- package/dist/types/managers/integration_mappings.d.ts +2 -2
- package/dist/types/managers/invites.d.ts +1 -1
- package/dist/types/managers/legal_hold_policies.d.ts +2 -2
- package/dist/types/managers/legal_hold_policy_assignments.d.ts +1 -1
- package/dist/types/managers/memberships.d.ts +10 -10
- package/dist/types/managers/metadata_cascade_policies.d.ts +2 -2
- package/dist/types/managers/metadata_taxonomies.d.ts +6 -6
- package/dist/types/managers/metadata_templates.d.ts +4 -4
- package/dist/types/managers/query.d.ts +9 -0
- package/dist/types/managers/retention_policies.d.ts +2 -2
- package/dist/types/managers/retention_policy_assignments.d.ts +1 -1
- package/dist/types/managers/session_termination.d.ts +2 -2
- package/dist/types/managers/shared_links_files.d.ts +3 -3
- package/dist/types/managers/shared_links_folders.d.ts +3 -3
- package/dist/types/managers/shared_links_web_links.d.ts +3 -3
- package/dist/types/managers/shield_information_barrier_segment_members.d.ts +1 -1
- package/dist/types/managers/shield_information_barrier_segment_restrictions.d.ts +1 -1
- package/dist/types/managers/shield_information_barrier_segments.d.ts +2 -2
- package/dist/types/managers/shield_information_barriers.d.ts +2 -2
- package/dist/types/managers/skills.d.ts +3 -3
- package/dist/types/managers/storage_policy_assignments.d.ts +2 -2
- package/dist/types/managers/task_assignments.d.ts +2 -2
- package/dist/types/managers/tasks.d.ts +2 -2
- package/dist/types/managers/terms_of_service_user_statuses.d.ts +2 -2
- package/dist/types/managers/terms_of_services.d.ts +2 -2
- package/dist/types/managers/transfer.d.ts +1 -1
- package/dist/types/managers/trashed_files.d.ts +1 -1
- package/dist/types/managers/trashed_folders.d.ts +1 -1
- package/dist/types/managers/trashed_web_links.d.ts +1 -1
- package/dist/types/managers/uploads.d.ts +2 -2
- package/dist/types/managers/user_collaborations.d.ts +2 -2
- package/dist/types/managers/users.d.ts +2 -2
- package/dist/types/managers/web_links.d.ts +2 -2
- package/dist/types/managers/webhooks.d.ts +2 -2
- package/dist/types/managers/workflows.d.ts +1 -1
- package/dist/types/models/schemas.d.ts +204 -141
- package/dist/types/runtime.d.ts +10 -0
- package/dist/types/tokens.d.ts +4 -2
- package/docs/README.md +1 -0
- package/docs/managers/archives.md +2 -2
- package/docs/managers/avatars.md +1 -1
- package/docs/managers/chunked_uploads.md +7 -7
- package/docs/managers/classifications.md +3 -3
- package/docs/managers/collaboration_allowlist_entries.md +10 -10
- package/docs/managers/collaboration_allowlist_exempt_targets.md +10 -10
- package/docs/managers/comments.md +2 -2
- package/docs/managers/email_aliases.md +1 -1
- package/docs/managers/file_classifications.md +2 -2
- package/docs/managers/file_metadata.md +5 -5
- package/docs/managers/file_versions.md +2 -2
- package/docs/managers/file_watermarks.md +1 -1
- package/docs/managers/files.md +2 -2
- package/docs/managers/folder_classifications.md +2 -2
- package/docs/managers/folder_locks.md +1 -1
- package/docs/managers/folder_metadata.md +5 -5
- package/docs/managers/folder_watermarks.md +1 -1
- package/docs/managers/folders.md +3 -3
- package/docs/managers/groups.md +2 -2
- package/docs/managers/integration_mappings.md +2 -2
- package/docs/managers/invites.md +1 -1
- package/docs/managers/legal_hold_policies.md +2 -2
- package/docs/managers/legal_hold_policy_assignments.md +1 -1
- package/docs/managers/memberships.md +10 -10
- package/docs/managers/metadata_cascade_policies.md +2 -2
- package/docs/managers/metadata_taxonomies.md +6 -6
- package/docs/managers/metadata_templates.md +5 -5
- package/docs/managers/query.md +33 -0
- package/docs/managers/retention_policies.md +2 -2
- package/docs/managers/retention_policy_assignments.md +1 -1
- package/docs/managers/session_termination.md +2 -2
- package/docs/managers/shared_links_files.md +3 -3
- package/docs/managers/shared_links_folders.md +3 -3
- package/docs/managers/shared_links_web_links.md +3 -3
- package/docs/managers/shield_information_barrier_segment_members.md +1 -1
- package/docs/managers/shield_information_barrier_segment_restrictions.md +1 -1
- package/docs/managers/shield_information_barrier_segments.md +2 -2
- package/docs/managers/shield_information_barriers.md +2 -2
- package/docs/managers/skills.md +3 -3
- package/docs/managers/storage_policy_assignments.md +2 -2
- package/docs/managers/task_assignments.md +2 -2
- package/docs/managers/tasks.md +2 -2
- package/docs/managers/terms_of_service_user_statuses.md +2 -2
- package/docs/managers/terms_of_services.md +2 -2
- package/docs/managers/transfer.md +1 -1
- package/docs/managers/trashed_files.md +1 -1
- package/docs/managers/trashed_folders.md +1 -1
- package/docs/managers/trashed_web_links.md +1 -1
- package/docs/managers/uploads.md +2 -2
- package/docs/managers/user_collaborations.md +2 -2
- package/docs/managers/users.md +2 -2
- package/docs/managers/web_links.md +2 -2
- package/docs/managers/webhooks.md +2 -2
- package/docs/managers/workflows.md +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// Code generated by box-gantry. DO NOT EDIT.
|
|
2
|
+
/**
|
|
3
|
+
* ChunkedUpload orchestrates a Box chunked (multipart) upload over a Client: it
|
|
4
|
+
* creates an upload session, uploads the content's parts with bounded
|
|
5
|
+
* concurrency, and commits — for a new file (upload) or a new version of an
|
|
6
|
+
* existing file (uploadVersion). Box requires chunked upload for files at or
|
|
7
|
+
* above its minimum session size; smaller files use the single-shot endpoints.
|
|
8
|
+
*/
|
|
9
|
+
export class ChunkedUpload {
|
|
10
|
+
client;
|
|
11
|
+
/** Bounds parts in flight, capping peak memory. */
|
|
12
|
+
maxConcurrent = 4;
|
|
13
|
+
constructor(client) {
|
|
14
|
+
this.client = client;
|
|
15
|
+
}
|
|
16
|
+
/** Upload content as a new file named fileName into folderId. */
|
|
17
|
+
async upload(content, fileName, folderId) {
|
|
18
|
+
const session = await this.client.chunkedUploads.createFileUploadSession({
|
|
19
|
+
folder_id: folderId,
|
|
20
|
+
file_size: content.length,
|
|
21
|
+
file_name: fileName,
|
|
22
|
+
});
|
|
23
|
+
return this.finish(session, content);
|
|
24
|
+
}
|
|
25
|
+
/** Upload content as a new version of the existing file fileId. */
|
|
26
|
+
async uploadVersion(content, fileName, fileId) {
|
|
27
|
+
const session = await this.client.chunkedUploads.createFileVersionUploadSession(fileId, {
|
|
28
|
+
file_size: content.length,
|
|
29
|
+
file_name: fileName,
|
|
30
|
+
});
|
|
31
|
+
return this.finish(session, content);
|
|
32
|
+
}
|
|
33
|
+
async finish(session, content) {
|
|
34
|
+
if (session.id === undefined) {
|
|
35
|
+
throw new Error('gantry: upload session returned no id');
|
|
36
|
+
}
|
|
37
|
+
if (session.part_size === undefined || session.part_size <= 0) {
|
|
38
|
+
throw new Error('gantry: upload session returned a non-positive part_size');
|
|
39
|
+
}
|
|
40
|
+
const id = session.id;
|
|
41
|
+
const partSize = session.part_size;
|
|
42
|
+
const total = content.length;
|
|
43
|
+
const offsets = [];
|
|
44
|
+
for (let off = 0; off < total; off += partSize) {
|
|
45
|
+
offsets.push(off);
|
|
46
|
+
}
|
|
47
|
+
const parts = new Array(offsets.length);
|
|
48
|
+
// A bounded worker pool: each of maxConcurrent workers claims the next
|
|
49
|
+
// offset (the `next++` read is atomic between awaits on a single thread).
|
|
50
|
+
// Once any part fails, `failed` stops the others from starting new parts,
|
|
51
|
+
// so a failure early in a large upload doesn't push every remaining part.
|
|
52
|
+
let next = 0;
|
|
53
|
+
let failed = false;
|
|
54
|
+
const worker = async () => {
|
|
55
|
+
for (;;) {
|
|
56
|
+
if (failed) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const i = next++;
|
|
60
|
+
if (i >= offsets.length) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const start = offsets[i];
|
|
64
|
+
const end = Math.min(start + partSize, total);
|
|
65
|
+
try {
|
|
66
|
+
parts[i] = await this.uploadPart(id, content, start, end, total);
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
failed = true;
|
|
70
|
+
throw err;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
const workerCount = Math.min(this.maxConcurrent, offsets.length);
|
|
75
|
+
await Promise.all(Array.from({ length: workerCount }, () => worker()));
|
|
76
|
+
const digest = 'sha=' + (await sha1Base64(content));
|
|
77
|
+
return this.client.chunkedUploads.commitFileUploadSession(id, digest, { parts });
|
|
78
|
+
}
|
|
79
|
+
async uploadPart(id, content, start, end, total) {
|
|
80
|
+
const slice = content.subarray(start, end);
|
|
81
|
+
const digest = 'sha=' + (await sha1Base64(slice));
|
|
82
|
+
const contentRange = `bytes ${start}-${end - 1}/${total}`;
|
|
83
|
+
// The `as BlobPart` cast bridges the `Uint8Array<ArrayBufferLike>` vs
|
|
84
|
+
// `BufferSource` (ArrayBuffer-only) generic gap in the DOM lib, exactly as
|
|
85
|
+
// the runtime casts its `fetch` body; a plain `Uint8Array` is a valid part.
|
|
86
|
+
const uploaded = await this.client.chunkedUploads.updateFileUploadSession(id, digest, contentRange, new Blob([slice]));
|
|
87
|
+
if (uploaded.part === undefined) {
|
|
88
|
+
throw new Error('gantry: upload part returned no part');
|
|
89
|
+
}
|
|
90
|
+
return uploaded.part;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/** Base64 of the SHA-1 of data — the Box `Digest: sha=…` header value. Uses Web
|
|
94
|
+
* Crypto (browser and Node 18+), so it adds no dependency. */
|
|
95
|
+
async function sha1Base64(data) {
|
|
96
|
+
// `as BufferSource` bridges the `Uint8Array<ArrayBufferLike>` vs ArrayBuffer-only
|
|
97
|
+
// generic gap in the DOM lib (as the runtime does for its `fetch` body).
|
|
98
|
+
const digest = new Uint8Array(await crypto.subtle.digest('SHA-1', data));
|
|
99
|
+
let binary = '';
|
|
100
|
+
for (const byte of digest) {
|
|
101
|
+
binary += String.fromCharCode(byte);
|
|
102
|
+
}
|
|
103
|
+
return btoa(binary);
|
|
104
|
+
}
|
package/dist/esm/client.js
CHANGED
|
@@ -49,6 +49,7 @@ import { MetadataCascadePoliciesManager } from './managers/metadata_cascade_poli
|
|
|
49
49
|
import { MetadataTaxonomiesManager } from './managers/metadata_taxonomies.js';
|
|
50
50
|
import { MetadataTemplatesManager } from './managers/metadata_templates.js';
|
|
51
51
|
import { NotesManager } from './managers/notes.js';
|
|
52
|
+
import { QueryManager } from './managers/query.js';
|
|
52
53
|
import { RecentItemsManager } from './managers/recent_items.js';
|
|
53
54
|
import { RetentionPoliciesManager } from './managers/retention_policies.js';
|
|
54
55
|
import { RetentionPolicyAssignmentsManager } from './managers/retention_policy_assignments.js';
|
|
@@ -136,6 +137,7 @@ export class Client {
|
|
|
136
137
|
metadataTaxonomies;
|
|
137
138
|
metadataTemplates;
|
|
138
139
|
notes;
|
|
140
|
+
query;
|
|
139
141
|
recentItems;
|
|
140
142
|
retentionPolicies;
|
|
141
143
|
retentionPolicyAssignments;
|
|
@@ -224,6 +226,7 @@ export class Client {
|
|
|
224
226
|
this.metadataTaxonomies = new MetadataTaxonomiesManager(session);
|
|
225
227
|
this.metadataTemplates = new MetadataTemplatesManager(session);
|
|
226
228
|
this.notes = new NotesManager(session);
|
|
229
|
+
this.query = new QueryManager(session);
|
|
227
230
|
this.recentItems = new RecentItemsManager(session);
|
|
228
231
|
this.retentionPolicies = new RetentionPoliciesManager(session);
|
|
229
232
|
this.retentionPolicyAssignments = new RetentionPolicyAssignmentsManager(session);
|
package/dist/esm/index.js
CHANGED
package/dist/esm/jwt.js
CHANGED
|
@@ -7,7 +7,7 @@ export class ChunkedUploadsManager {
|
|
|
7
7
|
constructor(session) {
|
|
8
8
|
this.session = session;
|
|
9
9
|
}
|
|
10
|
-
async
|
|
10
|
+
async createFileUploadSession(body) {
|
|
11
11
|
let url = this.session.baseUrl("upload");
|
|
12
12
|
url += "/files";
|
|
13
13
|
url += "/upload_sessions";
|
|
@@ -18,7 +18,7 @@ export class ChunkedUploadsManager {
|
|
|
18
18
|
const data = runtime.responseBytes(resp);
|
|
19
19
|
return JSON.parse(new TextDecoder().decode(data));
|
|
20
20
|
}
|
|
21
|
-
async
|
|
21
|
+
async createFileVersionUploadSession(fileId, body) {
|
|
22
22
|
let url = this.session.baseUrl("upload");
|
|
23
23
|
url += "/files";
|
|
24
24
|
url += '/' + pathEscape(fileId);
|
|
@@ -48,8 +48,8 @@ export class ChunkedUploadsManager {
|
|
|
48
48
|
let req = this.session.newRequest("PUT", url);
|
|
49
49
|
req = runtime.withHeader(req, "digest", digest);
|
|
50
50
|
req = runtime.withHeader(req, "content-range", contentRange);
|
|
51
|
-
|
|
52
|
-
req = runtime.withStreamBody(req, runtime.Stream
|
|
51
|
+
const fileBytes = new Uint8Array(await body.arrayBuffer());
|
|
52
|
+
req = runtime.withStreamBody(req, new runtime.Stream(fileBytes), 'application/octet-stream');
|
|
53
53
|
const resp = await this.session.fetch(req);
|
|
54
54
|
const data = runtime.responseBytes(resp);
|
|
55
55
|
return JSON.parse(new TextDecoder().decode(data));
|
|
@@ -8,10 +8,10 @@ export class CollaborationAllowlistEntriesManager {
|
|
|
8
8
|
this.session = session;
|
|
9
9
|
}
|
|
10
10
|
/** Iterate every `models.schemas.CollaborationAllowlistEntry` across pages, threading the marker cursor. */
|
|
11
|
-
async *
|
|
11
|
+
async *list(opts) {
|
|
12
12
|
const options = { ...opts };
|
|
13
13
|
for (;;) {
|
|
14
|
-
const page = await this.
|
|
14
|
+
const page = await this.listPage(options);
|
|
15
15
|
const items = page.entries ?? [];
|
|
16
16
|
for (const item of items) {
|
|
17
17
|
yield item;
|
|
@@ -23,7 +23,7 @@ export class CollaborationAllowlistEntriesManager {
|
|
|
23
23
|
options.marker = cursor;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
async
|
|
26
|
+
async listPage(opts) {
|
|
27
27
|
let url = this.session.baseUrl("api");
|
|
28
28
|
url += "/collaboration_whitelist_entries";
|
|
29
29
|
let req = this.session.newRequest("GET", url);
|
|
@@ -38,7 +38,7 @@ export class CollaborationAllowlistEntriesManager {
|
|
|
38
38
|
const data = runtime.responseBytes(resp);
|
|
39
39
|
return JSON.parse(new TextDecoder().decode(data));
|
|
40
40
|
}
|
|
41
|
-
async
|
|
41
|
+
async create(body) {
|
|
42
42
|
let url = this.session.baseUrl("api");
|
|
43
43
|
url += "/collaboration_whitelist_entries";
|
|
44
44
|
let req = this.session.newRequest("POST", url);
|
|
@@ -48,7 +48,7 @@ export class CollaborationAllowlistEntriesManager {
|
|
|
48
48
|
const data = runtime.responseBytes(resp);
|
|
49
49
|
return JSON.parse(new TextDecoder().decode(data));
|
|
50
50
|
}
|
|
51
|
-
async
|
|
51
|
+
async get(collaborationWhitelistEntryId) {
|
|
52
52
|
let url = this.session.baseUrl("api");
|
|
53
53
|
url += "/collaboration_whitelist_entries";
|
|
54
54
|
url += '/' + pathEscape(collaborationWhitelistEntryId);
|
|
@@ -57,7 +57,7 @@ export class CollaborationAllowlistEntriesManager {
|
|
|
57
57
|
const data = runtime.responseBytes(resp);
|
|
58
58
|
return JSON.parse(new TextDecoder().decode(data));
|
|
59
59
|
}
|
|
60
|
-
async
|
|
60
|
+
async delete_(collaborationWhitelistEntryId) {
|
|
61
61
|
let url = this.session.baseUrl("api");
|
|
62
62
|
url += "/collaboration_whitelist_entries";
|
|
63
63
|
url += '/' + pathEscape(collaborationWhitelistEntryId);
|
|
@@ -8,10 +8,10 @@ export class CollaborationAllowlistExemptTargetsManager {
|
|
|
8
8
|
this.session = session;
|
|
9
9
|
}
|
|
10
10
|
/** Iterate every `models.schemas.CollaborationAllowlistExemptTarget` across pages, threading the marker cursor. */
|
|
11
|
-
async *
|
|
11
|
+
async *list(opts) {
|
|
12
12
|
const options = { ...opts };
|
|
13
13
|
for (;;) {
|
|
14
|
-
const page = await this.
|
|
14
|
+
const page = await this.listPage(options);
|
|
15
15
|
const items = page.entries ?? [];
|
|
16
16
|
for (const item of items) {
|
|
17
17
|
yield item;
|
|
@@ -23,7 +23,7 @@ export class CollaborationAllowlistExemptTargetsManager {
|
|
|
23
23
|
options.marker = cursor;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
async
|
|
26
|
+
async listPage(opts) {
|
|
27
27
|
let url = this.session.baseUrl("api");
|
|
28
28
|
url += "/collaboration_whitelist_exempt_targets";
|
|
29
29
|
let req = this.session.newRequest("GET", url);
|
|
@@ -38,7 +38,7 @@ export class CollaborationAllowlistExemptTargetsManager {
|
|
|
38
38
|
const data = runtime.responseBytes(resp);
|
|
39
39
|
return JSON.parse(new TextDecoder().decode(data));
|
|
40
40
|
}
|
|
41
|
-
async
|
|
41
|
+
async create(body) {
|
|
42
42
|
let url = this.session.baseUrl("api");
|
|
43
43
|
url += "/collaboration_whitelist_exempt_targets";
|
|
44
44
|
let req = this.session.newRequest("POST", url);
|
|
@@ -48,7 +48,7 @@ export class CollaborationAllowlistExemptTargetsManager {
|
|
|
48
48
|
const data = runtime.responseBytes(resp);
|
|
49
49
|
return JSON.parse(new TextDecoder().decode(data));
|
|
50
50
|
}
|
|
51
|
-
async
|
|
51
|
+
async get(collaborationWhitelistExemptTargetId) {
|
|
52
52
|
let url = this.session.baseUrl("api");
|
|
53
53
|
url += "/collaboration_whitelist_exempt_targets";
|
|
54
54
|
url += '/' + pathEscape(collaborationWhitelistExemptTargetId);
|
|
@@ -57,7 +57,7 @@ export class CollaborationAllowlistExemptTargetsManager {
|
|
|
57
57
|
const data = runtime.responseBytes(resp);
|
|
58
58
|
return JSON.parse(new TextDecoder().decode(data));
|
|
59
59
|
}
|
|
60
|
-
async
|
|
60
|
+
async delete_(collaborationWhitelistExemptTargetId) {
|
|
61
61
|
let url = this.session.baseUrl("api");
|
|
62
62
|
url += "/collaboration_whitelist_exempt_targets";
|
|
63
63
|
url += '/' + pathEscape(collaborationWhitelistExemptTargetId);
|
|
@@ -48,6 +48,7 @@ export * from './metadata_cascade_policies.js';
|
|
|
48
48
|
export * from './metadata_taxonomies.js';
|
|
49
49
|
export * from './metadata_templates.js';
|
|
50
50
|
export * from './notes.js';
|
|
51
|
+
export * from './query.js';
|
|
51
52
|
export * from './recent_items.js';
|
|
52
53
|
export * from './retention_policies.js';
|
|
53
54
|
export * from './retention_policy_assignments.js';
|
|
@@ -71,7 +71,7 @@ export class MembershipsManager {
|
|
|
71
71
|
const data = runtime.responseBytes(resp);
|
|
72
72
|
return JSON.parse(new TextDecoder().decode(data));
|
|
73
73
|
}
|
|
74
|
-
async
|
|
74
|
+
async createGroupMembership(body, opts) {
|
|
75
75
|
let url = this.session.baseUrl("api");
|
|
76
76
|
url += "/group_memberships";
|
|
77
77
|
let req = this.session.newRequest("POST", url);
|
|
@@ -85,7 +85,7 @@ export class MembershipsManager {
|
|
|
85
85
|
const data = runtime.responseBytes(resp);
|
|
86
86
|
return JSON.parse(new TextDecoder().decode(data));
|
|
87
87
|
}
|
|
88
|
-
async
|
|
88
|
+
async getGroupMembership(groupMembershipId, opts) {
|
|
89
89
|
let url = this.session.baseUrl("api");
|
|
90
90
|
url += "/group_memberships";
|
|
91
91
|
url += '/' + pathEscape(groupMembershipId);
|
|
@@ -98,7 +98,7 @@ export class MembershipsManager {
|
|
|
98
98
|
const data = runtime.responseBytes(resp);
|
|
99
99
|
return JSON.parse(new TextDecoder().decode(data));
|
|
100
100
|
}
|
|
101
|
-
async
|
|
101
|
+
async updateGroupMembership(groupMembershipId, body, opts) {
|
|
102
102
|
let url = this.session.baseUrl("api");
|
|
103
103
|
url += "/group_memberships";
|
|
104
104
|
url += '/' + pathEscape(groupMembershipId);
|
|
@@ -113,7 +113,7 @@ export class MembershipsManager {
|
|
|
113
113
|
const data = runtime.responseBytes(resp);
|
|
114
114
|
return JSON.parse(new TextDecoder().decode(data));
|
|
115
115
|
}
|
|
116
|
-
async
|
|
116
|
+
async deleteGroupMembership(groupMembershipId) {
|
|
117
117
|
let url = this.session.baseUrl("api");
|
|
118
118
|
url += "/group_memberships";
|
|
119
119
|
url += '/' + pathEscape(groupMembershipId);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Code generated by box-gantry. DO NOT EDIT.
|
|
2
|
+
import * as runtime from '../runtime.js';
|
|
3
|
+
/** Operations for the "query" API area. */
|
|
4
|
+
export class QueryManager {
|
|
5
|
+
session;
|
|
6
|
+
constructor(session) {
|
|
7
|
+
this.session = session;
|
|
8
|
+
}
|
|
9
|
+
async query(body) {
|
|
10
|
+
let url = this.session.baseUrl("api");
|
|
11
|
+
url += "/query";
|
|
12
|
+
let req = this.session.newRequest("POST", url);
|
|
13
|
+
req = runtime.withHeader(req, "box-version", "2026.0");
|
|
14
|
+
const payload = new TextEncoder().encode(JSON.stringify(body));
|
|
15
|
+
req = runtime.withJsonBody(req, payload);
|
|
16
|
+
const resp = await this.session.fetch(req);
|
|
17
|
+
const data = runtime.responseBytes(resp);
|
|
18
|
+
return JSON.parse(new TextDecoder().decode(data));
|
|
19
|
+
}
|
|
20
|
+
async queryInsights(body) {
|
|
21
|
+
let url = this.session.baseUrl("api");
|
|
22
|
+
url += "/query_insights";
|
|
23
|
+
let req = this.session.newRequest("POST", url);
|
|
24
|
+
req = runtime.withHeader(req, "box-version", "2026.0");
|
|
25
|
+
const payload = new TextEncoder().encode(JSON.stringify(body));
|
|
26
|
+
req = runtime.withJsonBody(req, payload);
|
|
27
|
+
const resp = await this.session.fetch(req);
|
|
28
|
+
const data = runtime.responseBytes(resp);
|
|
29
|
+
return JSON.parse(new TextDecoder().decode(data));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
// Code generated by box-gantry 0.1.0 (spec
|
|
1
|
+
// Code generated by box-gantry 0.1.0 (spec 3fb3510fe12f2f80) for Box API 2024.0. DO NOT EDIT.
|
|
2
2
|
export {};
|
package/dist/esm/runtime.js
CHANGED
|
@@ -55,6 +55,8 @@ export class Client {
|
|
|
55
55
|
auth;
|
|
56
56
|
baseUrls;
|
|
57
57
|
maxRetries;
|
|
58
|
+
fetchImpl;
|
|
59
|
+
defaultHeaders;
|
|
58
60
|
constructor(auth, options = {}) {
|
|
59
61
|
this.auth = auth;
|
|
60
62
|
const maxRetries = options.maxRetries ?? 5;
|
|
@@ -63,6 +65,8 @@ export class Client {
|
|
|
63
65
|
}
|
|
64
66
|
this.maxRetries = maxRetries;
|
|
65
67
|
this.baseUrls = { ...DEFAULT_BASE_URLS, ...(options.baseUrls ?? {}) };
|
|
68
|
+
this.fetchImpl = options.fetch ?? fetch;
|
|
69
|
+
this.defaultHeaders = { ...(options.headers ?? {}) };
|
|
66
70
|
}
|
|
67
71
|
/** The configured base URL for a D-106 class, without a trailing slash. */
|
|
68
72
|
baseUrl(name) {
|
|
@@ -93,13 +97,14 @@ export class Client {
|
|
|
93
97
|
let refreshed = false;
|
|
94
98
|
let lastError;
|
|
95
99
|
for (let attempt = 0; attempt <= this.maxRetries; attempt++) {
|
|
96
|
-
const headers = new Headers(
|
|
100
|
+
const headers = new Headers(this.defaultHeaders);
|
|
101
|
+
request.headers.forEach((value, name) => headers.set(name, value));
|
|
97
102
|
headers.set('Authorization', `Bearer ${token}`);
|
|
98
103
|
// `httpResponse` is the platform `Response` (via inference — the name is
|
|
99
104
|
// shadowed by this module's `Response` class, so it is never annotated).
|
|
100
105
|
let httpResponse;
|
|
101
106
|
try {
|
|
102
|
-
httpResponse = await
|
|
107
|
+
httpResponse = await this.fetchImpl(url, {
|
|
103
108
|
method: request.method,
|
|
104
109
|
headers,
|
|
105
110
|
// A `Uint8Array` is a valid `BodyInit` at runtime; the cast bridges
|
|
@@ -123,7 +128,7 @@ export class Client {
|
|
|
123
128
|
const response = new Response(httpResponse.status, httpResponse.headers, bodyBytes);
|
|
124
129
|
// A single force-refresh on 401: re-acquire past the token cache so the
|
|
125
130
|
// retry doesn't just resend the same rejected token.
|
|
126
|
-
if (response.status === 401 && !refreshed) {
|
|
131
|
+
if (response.status === 401 && !refreshed && attempt < this.maxRetries) {
|
|
127
132
|
refreshed = true;
|
|
128
133
|
token = await this.auth.forceRefresh(token);
|
|
129
134
|
continue;
|
package/dist/esm/tokens.js
CHANGED
|
@@ -67,9 +67,11 @@ export class CachedToken {
|
|
|
67
67
|
* token acquisition never escapes the runtime's error contract. The optional
|
|
68
68
|
* `signal` cancels an explicit caller-initiated exchange (`exchangeCode`); the
|
|
69
69
|
* cached flows do not thread one, so a shared refresh is never bound to a single
|
|
70
|
-
* request's cancellation.
|
|
70
|
+
* request's cancellation. `fetchImpl` defaults to the global `fetch`; a caller
|
|
71
|
+
* building an `Auth` with a custom transport (matching the runtime `Client`'s
|
|
72
|
+
* own `fetch` override) passes it through so auth traffic is observable too.
|
|
71
73
|
*/
|
|
72
|
-
export async function postTokenForm(tokenUrl, form, signal) {
|
|
74
|
+
export async function postTokenForm(tokenUrl, form, signal, fetchImpl = fetch) {
|
|
73
75
|
// An internal deadline independent of the caller's signal, combined with it
|
|
74
76
|
// when present. It also covers the body read, since the signal aborts an
|
|
75
77
|
// in-progress `fetch` (including body streaming). `AbortSignal.timeout` owns
|
|
@@ -79,7 +81,7 @@ export async function postTokenForm(tokenUrl, form, signal) {
|
|
|
79
81
|
let response;
|
|
80
82
|
let text;
|
|
81
83
|
try {
|
|
82
|
-
response = await
|
|
84
|
+
response = await fetchImpl(tokenUrl, {
|
|
83
85
|
method: 'POST',
|
|
84
86
|
headers: {
|
|
85
87
|
'Content-Type': 'application/x-www-form-urlencoded',
|
package/dist/types/auth.d.ts
CHANGED
|
@@ -18,6 +18,10 @@ export interface CcgConfig {
|
|
|
18
18
|
userId?: string;
|
|
19
19
|
/** Optional; defaults to Box's token endpoint. */
|
|
20
20
|
tokenUrl?: string;
|
|
21
|
+
/** Override the platform `fetch` used for the token exchange — e.g. to match
|
|
22
|
+
* the runtime `Client`'s own transport override. Defaults to the global
|
|
23
|
+
* `fetch`. */
|
|
24
|
+
fetch?: typeof fetch;
|
|
21
25
|
}
|
|
22
26
|
/** Build a CCG `Auth`. Requires a subject: `enterpriseId` or `userId`. */
|
|
23
27
|
export declare function clientCredentials(config: CcgConfig): Auth;
|
|
@@ -37,6 +41,10 @@ export interface OAuthConfig {
|
|
|
37
41
|
* stale, already-invalidated token.
|
|
38
42
|
*/
|
|
39
43
|
onRefresh?: (refreshToken: string) => void;
|
|
44
|
+
/** Override the platform `fetch` used for token exchanges — e.g. to match
|
|
45
|
+
* the runtime `Client`'s own transport override. Defaults to the global
|
|
46
|
+
* `fetch`. */
|
|
47
|
+
fetch?: typeof fetch;
|
|
40
48
|
}
|
|
41
49
|
/**
|
|
42
50
|
* Build the URL to redirect a user to so they can grant access. `state` is
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** The box-gantry engine version that generated this SDK. */
|
|
2
2
|
export declare const ENGINE = "0.1.0";
|
|
3
3
|
/** Fingerprint of the input spec set. */
|
|
4
|
-
export declare const SPEC_FINGERPRINT = "
|
|
4
|
+
export declare const SPEC_FINGERPRINT = "3fb3510fe12f2f80";
|
|
5
5
|
/** The target language key (FR-4). */
|
|
6
6
|
export declare const TARGET = "typescript";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Client } from './client.js';
|
|
2
|
+
import type * as models from './models/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* ChunkedUpload orchestrates a Box chunked (multipart) upload over a Client: it
|
|
5
|
+
* creates an upload session, uploads the content's parts with bounded
|
|
6
|
+
* concurrency, and commits — for a new file (upload) or a new version of an
|
|
7
|
+
* existing file (uploadVersion). Box requires chunked upload for files at or
|
|
8
|
+
* above its minimum session size; smaller files use the single-shot endpoints.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ChunkedUpload {
|
|
11
|
+
private readonly client;
|
|
12
|
+
/** Bounds parts in flight, capping peak memory. */
|
|
13
|
+
private readonly maxConcurrent;
|
|
14
|
+
constructor(client: Client);
|
|
15
|
+
/** Upload content as a new file named fileName into folderId. */
|
|
16
|
+
upload(content: Uint8Array, fileName: string, folderId: string): Promise<models.schemas.Files>;
|
|
17
|
+
/** Upload content as a new version of the existing file fileId. */
|
|
18
|
+
uploadVersion(content: Uint8Array, fileName: string, fileId: string): Promise<models.schemas.Files>;
|
|
19
|
+
private finish;
|
|
20
|
+
private uploadPart;
|
|
21
|
+
}
|
package/dist/types/client.d.ts
CHANGED
|
@@ -48,6 +48,7 @@ import { MetadataCascadePoliciesManager } from './managers/metadata_cascade_poli
|
|
|
48
48
|
import { MetadataTaxonomiesManager } from './managers/metadata_taxonomies.js';
|
|
49
49
|
import { MetadataTemplatesManager } from './managers/metadata_templates.js';
|
|
50
50
|
import { NotesManager } from './managers/notes.js';
|
|
51
|
+
import { QueryManager } from './managers/query.js';
|
|
51
52
|
import { RecentItemsManager } from './managers/recent_items.js';
|
|
52
53
|
import { RetentionPoliciesManager } from './managers/retention_policies.js';
|
|
53
54
|
import { RetentionPolicyAssignmentsManager } from './managers/retention_policy_assignments.js';
|
|
@@ -135,6 +136,7 @@ export declare class Client {
|
|
|
135
136
|
readonly metadataTaxonomies: MetadataTaxonomiesManager;
|
|
136
137
|
readonly metadataTemplates: MetadataTemplatesManager;
|
|
137
138
|
readonly notes: NotesManager;
|
|
139
|
+
readonly query: QueryManager;
|
|
138
140
|
readonly recentItems: RecentItemsManager;
|
|
139
141
|
readonly retentionPolicies: RetentionPoliciesManager;
|
|
140
142
|
readonly retentionPolicyAssignments: RetentionPolicyAssignmentsManager;
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/jwt.d.ts
CHANGED
|
@@ -14,6 +14,10 @@ export interface JwtConfig {
|
|
|
14
14
|
userId?: string;
|
|
15
15
|
/** Optional; defaults to Box's token endpoint. */
|
|
16
16
|
tokenUrl?: string;
|
|
17
|
+
/** Override the platform `fetch` used for the token exchange — e.g. to match
|
|
18
|
+
* the runtime `Client`'s own transport override. Defaults to the global
|
|
19
|
+
* `fetch`. */
|
|
20
|
+
fetch?: typeof fetch;
|
|
17
21
|
}
|
|
18
22
|
/**
|
|
19
23
|
* Build a JWT-assertion `Auth`, parsing (and if needed decrypting) the RSA
|
|
@@ -12,7 +12,7 @@ export declare class ArchivesManager {
|
|
|
12
12
|
/** Iterate every `models.schemas.Archive` across pages, threading the marker cursor. */
|
|
13
13
|
list(opts?: ArchivesManagerListOptions): AsyncIterableIterator<models.schemas.Archive>;
|
|
14
14
|
private listPage;
|
|
15
|
-
create(body: models.schemas.
|
|
16
|
-
update(archiveId: string, body: models.schemas.
|
|
15
|
+
create(body: models.schemas.CreateArchiveRequest): Promise<models.schemas.Archive>;
|
|
16
|
+
update(archiveId: string, body: models.schemas.UpdateArchiveRequest): Promise<models.schemas.Archive>;
|
|
17
17
|
delete_(archiveId: string): Promise<void>;
|
|
18
18
|
}
|
|
@@ -5,6 +5,6 @@ export declare class AvatarsManager {
|
|
|
5
5
|
private readonly session;
|
|
6
6
|
constructor(session: runtime.Client);
|
|
7
7
|
getUserAvatar(userId: string): Promise<runtime.Stream>;
|
|
8
|
-
createUserAvatar(userId: string, body: models.schemas.
|
|
8
|
+
createUserAvatar(userId: string, body: models.schemas.CreateUserAvatarRequest): Promise<models.schemas.UserAvatar>;
|
|
9
9
|
deleteUserAvatar(userId: string): Promise<void>;
|
|
10
10
|
}
|
|
@@ -14,13 +14,13 @@ export interface ChunkedUploadsManagerCommitFileUploadSessionOptions {
|
|
|
14
14
|
export declare class ChunkedUploadsManager {
|
|
15
15
|
private readonly session;
|
|
16
16
|
constructor(session: runtime.Client);
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
createFileUploadSession(body: models.schemas.CreateFileUploadSessionRequest): Promise<models.schemas.UploadSession>;
|
|
18
|
+
createFileVersionUploadSession(fileId: string, body: models.schemas.CreateFileVersionUploadSessionRequest): Promise<models.schemas.UploadSession>;
|
|
19
19
|
getFileUploadSession(uploadSessionId: string): Promise<models.schemas.UploadSession>;
|
|
20
20
|
updateFileUploadSession(uploadSessionId: string, digest: string, contentRange: string, body: Blob): Promise<models.schemas.UploadedPart>;
|
|
21
21
|
deleteFileUploadSession(uploadSessionId: string): Promise<void>;
|
|
22
22
|
/** Iterate every `models.schemas.UploadPart` across pages, threading the offset cursor. */
|
|
23
23
|
listFileUploadSessionParts(uploadSessionId: string, opts?: ChunkedUploadsManagerListFileUploadSessionPartsOptions): AsyncIterableIterator<models.schemas.UploadPart>;
|
|
24
24
|
private listFileUploadSessionPartsPage;
|
|
25
|
-
commitFileUploadSession(uploadSessionId: string, digest: string, body: models.schemas.
|
|
25
|
+
commitFileUploadSession(uploadSessionId: string, digest: string, body: models.schemas.CommitFileUploadSessionRequest, opts?: ChunkedUploadsManagerCommitFileUploadSessionOptions): Promise<models.schemas.Files>;
|
|
26
26
|
}
|
|
@@ -5,7 +5,7 @@ export declare class ClassificationsManager {
|
|
|
5
5
|
private readonly session;
|
|
6
6
|
constructor(session: runtime.Client);
|
|
7
7
|
get(): Promise<models.schemas.ClassificationTemplate>;
|
|
8
|
-
updateAdd(body: Array<models.schemas.
|
|
9
|
-
updateUpdate(body: Array<models.schemas.
|
|
10
|
-
createMetadataTemplateSchemaClassifications(body: models.schemas.
|
|
8
|
+
updateAdd(body: Array<models.schemas.UpdateClassificationAddRequest>): Promise<models.schemas.ClassificationTemplate>;
|
|
9
|
+
updateUpdate(body: Array<models.schemas.UpdateClassificationUpdateRequest>): Promise<models.schemas.ClassificationTemplate>;
|
|
10
|
+
createMetadataTemplateSchemaClassifications(body: models.schemas.CreateMetadataTemplateSchemaClassificationsRequest): Promise<models.schemas.ClassificationTemplate>;
|
|
11
11
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as runtime from '../runtime.js';
|
|
2
2
|
import type * as models from '../models/index.js';
|
|
3
|
-
/** Optional parameters for CollaborationAllowlistEntriesManager.
|
|
4
|
-
export interface
|
|
3
|
+
/** Optional parameters for CollaborationAllowlistEntriesManager.list. */
|
|
4
|
+
export interface CollaborationAllowlistEntriesManagerListOptions {
|
|
5
5
|
marker?: string;
|
|
6
6
|
limit?: number;
|
|
7
7
|
}
|
|
@@ -10,9 +10,9 @@ export declare class CollaborationAllowlistEntriesManager {
|
|
|
10
10
|
private readonly session;
|
|
11
11
|
constructor(session: runtime.Client);
|
|
12
12
|
/** Iterate every `models.schemas.CollaborationAllowlistEntry` across pages, threading the marker cursor. */
|
|
13
|
-
|
|
14
|
-
private
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
list(opts?: CollaborationAllowlistEntriesManagerListOptions): AsyncIterableIterator<models.schemas.CollaborationAllowlistEntry>;
|
|
14
|
+
private listPage;
|
|
15
|
+
create(body: models.schemas.CreateCollaborationAllowlistEntryRequest): Promise<models.schemas.CollaborationAllowlistEntry>;
|
|
16
|
+
get(collaborationWhitelistEntryId: string): Promise<models.schemas.CollaborationAllowlistEntry>;
|
|
17
|
+
delete_(collaborationWhitelistEntryId: string): Promise<void>;
|
|
18
18
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as runtime from '../runtime.js';
|
|
2
2
|
import type * as models from '../models/index.js';
|
|
3
|
-
/** Optional parameters for CollaborationAllowlistExemptTargetsManager.
|
|
4
|
-
export interface
|
|
3
|
+
/** Optional parameters for CollaborationAllowlistExemptTargetsManager.list. */
|
|
4
|
+
export interface CollaborationAllowlistExemptTargetsManagerListOptions {
|
|
5
5
|
marker?: string;
|
|
6
6
|
limit?: number;
|
|
7
7
|
}
|
|
@@ -10,9 +10,9 @@ export declare class CollaborationAllowlistExemptTargetsManager {
|
|
|
10
10
|
private readonly session;
|
|
11
11
|
constructor(session: runtime.Client);
|
|
12
12
|
/** Iterate every `models.schemas.CollaborationAllowlistExemptTarget` across pages, threading the marker cursor. */
|
|
13
|
-
|
|
14
|
-
private
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
list(opts?: CollaborationAllowlistExemptTargetsManagerListOptions): AsyncIterableIterator<models.schemas.CollaborationAllowlistExemptTarget>;
|
|
14
|
+
private listPage;
|
|
15
|
+
create(body: models.schemas.CreateCollaborationAllowlistExemptTargetRequest): Promise<models.schemas.CollaborationAllowlistExemptTarget>;
|
|
16
|
+
get(collaborationWhitelistExemptTargetId: string): Promise<models.schemas.CollaborationAllowlistExemptTarget>;
|
|
17
|
+
delete_(collaborationWhitelistExemptTargetId: string): Promise<void>;
|
|
18
18
|
}
|
|
@@ -26,7 +26,7 @@ export declare class CommentsManager {
|
|
|
26
26
|
listFile(fileId: string, opts?: CommentsManagerListFileOptions): AsyncIterableIterator<models.schemas.CommentFull>;
|
|
27
27
|
private listFilePage;
|
|
28
28
|
get(commentId: string, opts?: CommentsManagerGetOptions): Promise<models.schemas.CommentFull>;
|
|
29
|
-
update(commentId: string, body: models.schemas.
|
|
29
|
+
update(commentId: string, body: models.schemas.UpdateCommentRequest, opts?: CommentsManagerUpdateOptions): Promise<models.schemas.CommentFull>;
|
|
30
30
|
delete_(commentId: string): Promise<void>;
|
|
31
|
-
create(body: models.schemas.
|
|
31
|
+
create(body: models.schemas.CreateCommentRequest, opts?: CommentsManagerCreateOptions): Promise<models.schemas.CommentFull>;
|
|
32
32
|
}
|
|
@@ -5,6 +5,6 @@ export declare class EmailAliasesManager {
|
|
|
5
5
|
private readonly session;
|
|
6
6
|
constructor(session: runtime.Client);
|
|
7
7
|
listUser(userId: string): Promise<models.schemas.EmailAliases>;
|
|
8
|
-
createUser(userId: string, body: models.schemas.
|
|
8
|
+
createUser(userId: string, body: models.schemas.CreateUserIdRequest): Promise<models.schemas.EmailAlias>;
|
|
9
9
|
deleteUser(userId: string, emailAliasId: string): Promise<void>;
|
|
10
10
|
}
|