box-node-sdk 10.4.0 → 10.5.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/lib/bundle.js +117 -7
- package/lib/bundle.js.map +1 -1
- package/lib/client.d.ts +8 -1
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +11 -0
- package/lib/client.js.map +1 -1
- package/lib/managers/archives.d.ts +4 -0
- package/lib/managers/archives.d.ts.map +1 -1
- package/lib/managers/archives.js +4 -0
- package/lib/managers/archives.js.map +1 -1
- package/lib/networking/boxNetworkClient.d.ts.map +1 -1
- package/lib/networking/boxNetworkClient.js +61 -6
- package/lib/networking/boxNetworkClient.js.map +1 -1
- package/lib/networking/network.d.ts +10 -1
- package/lib/networking/network.d.ts.map +1 -1
- package/lib/networking/network.js +29 -0
- package/lib/networking/network.js.map +1 -1
- package/lib/networking/timeoutConfig.d.ts +4 -0
- package/lib/networking/timeoutConfig.d.ts.map +1 -0
- package/lib/networking/timeoutConfig.js +3 -0
- package/lib/networking/timeoutConfig.js.map +1 -0
- package/lib/networking/version.d.ts +1 -1
- package/lib/networking/version.js +1 -1
- package/lib/schemas/index.d.ts +4 -4
- package/lib/schemas/index.d.ts.map +1 -1
- package/lib/schemas/index.js +4 -4
- package/lib/schemas/index.js.map +1 -1
- package/lib/schemas/v2025R0/hubUpdateRequestV2025R0.d.ts +3 -0
- package/lib/schemas/v2025R0/hubUpdateRequestV2025R0.d.ts.map +1 -1
- package/lib/schemas/v2025R0/hubUpdateRequestV2025R0.js +11 -0
- package/lib/schemas/v2025R0/hubUpdateRequestV2025R0.js.map +1 -1
- package/lib/schemas/v2025R0/hubV2025R0.d.ts +1 -0
- package/lib/schemas/v2025R0/hubV2025R0.d.ts.map +1 -1
- package/lib/schemas/v2025R0/hubV2025R0.js +14 -0
- package/lib/schemas/v2025R0/hubV2025R0.js.map +1 -1
- package/lib-esm/client.d.ts +8 -1
- package/lib-esm/client.js +11 -0
- package/lib-esm/client.js.map +1 -1
- package/lib-esm/managers/archives.d.ts +4 -0
- package/lib-esm/managers/archives.js +4 -0
- package/lib-esm/managers/archives.js.map +1 -1
- package/lib-esm/networking/boxNetworkClient.js +67 -6
- package/lib-esm/networking/boxNetworkClient.js.map +1 -1
- package/lib-esm/networking/network.d.ts +10 -1
- package/lib-esm/networking/network.js +30 -0
- package/lib-esm/networking/network.js.map +1 -1
- package/lib-esm/networking/timeoutConfig.d.ts +3 -0
- package/lib-esm/networking/timeoutConfig.js +2 -0
- package/lib-esm/networking/timeoutConfig.js.map +1 -0
- package/lib-esm/networking/version.d.ts +1 -1
- package/lib-esm/networking/version.js +1 -1
- package/lib-esm/schemas/index.d.ts +4 -4
- package/lib-esm/schemas/index.js +4 -4
- package/lib-esm/schemas/index.js.map +1 -1
- package/lib-esm/schemas/v2025R0/hubUpdateRequestV2025R0.d.ts +3 -0
- package/lib-esm/schemas/v2025R0/hubUpdateRequestV2025R0.js +11 -0
- package/lib-esm/schemas/v2025R0/hubUpdateRequestV2025R0.js.map +1 -1
- package/lib-esm/schemas/v2025R0/hubV2025R0.d.ts +1 -0
- package/lib-esm/schemas/v2025R0/hubV2025R0.js +15 -0
- package/lib-esm/schemas/v2025R0/hubV2025R0.js.map +1 -1
- package/package.json +1 -1
- package/src/client.ts +13 -0
- package/src/managers/archives.ts +4 -0
- package/src/networking/boxNetworkClient.ts +82 -13
- package/src/networking/network.ts +33 -0
- package/src/networking/timeoutConfig.ts +3 -0
- package/src/networking/version.ts +1 -1
- package/src/schemas/index.ts +4 -4
- package/src/schemas/v2025R0/hubUpdateRequestV2025R0.ts +18 -0
- package/src/schemas/v2025R0/hubV2025R0.ts +19 -0
- package/src/test/archives.test.ts +0 -1
- package/src/test/client.test.ts +17 -0
package/src/client.ts
CHANGED
|
@@ -90,6 +90,7 @@ import { BoxSdkError } from './box/errors';
|
|
|
90
90
|
import { FetchOptions } from './networking/fetchOptions';
|
|
91
91
|
import { FetchResponse } from './networking/fetchResponse';
|
|
92
92
|
import { BaseUrls } from './networking/baseUrls';
|
|
93
|
+
import { TimeoutConfig } from './networking/timeoutConfig';
|
|
93
94
|
import { ProxyConfig } from './networking/proxyConfig';
|
|
94
95
|
import { AgentOptions } from './internal/utils';
|
|
95
96
|
import { Interceptor } from './networking/interceptors';
|
|
@@ -279,6 +280,7 @@ export class BoxClient {
|
|
|
279
280
|
| 'withExtraHeaders'
|
|
280
281
|
| 'withCustomBaseUrls'
|
|
281
282
|
| 'withProxy'
|
|
283
|
+
| 'withTimeouts'
|
|
282
284
|
| 'withCustomAgentOptions'
|
|
283
285
|
| 'withInterceptors'
|
|
284
286
|
> &
|
|
@@ -739,6 +741,17 @@ export class BoxClient {
|
|
|
739
741
|
networkSession: this.networkSession.withProxy(config),
|
|
740
742
|
});
|
|
741
743
|
}
|
|
744
|
+
/**
|
|
745
|
+
* Create a new client with custom timeouts that will be used for every API call
|
|
746
|
+
* @param {TimeoutConfig} config Timeout configuration.
|
|
747
|
+
* @returns {BoxClient}
|
|
748
|
+
*/
|
|
749
|
+
withTimeouts(config: TimeoutConfig): BoxClient {
|
|
750
|
+
return new BoxClient({
|
|
751
|
+
auth: this.auth,
|
|
752
|
+
networkSession: this.networkSession.withTimeoutConfig(config),
|
|
753
|
+
});
|
|
754
|
+
}
|
|
742
755
|
/**
|
|
743
756
|
* Create a new client with a custom set of agent options that will be used for every API call
|
|
744
757
|
* @param {AgentOptions} agentOptions Custom set of agent options that will be used for every API call
|
package/src/managers/archives.ts
CHANGED
|
@@ -405,6 +405,10 @@ export class ArchivesManager {
|
|
|
405
405
|
* Permanently deletes an archive.
|
|
406
406
|
*
|
|
407
407
|
* To learn more about the archive APIs, see the [Archive API Guide](https://developer.box.com/guides/archives).
|
|
408
|
+
*
|
|
409
|
+
* <Danger>
|
|
410
|
+
* This endpoint is currently unavailable. Please contact support for assistance.
|
|
411
|
+
* </Danger>
|
|
408
412
|
* @param {string} archiveId The ID of the archive.
|
|
409
413
|
Example: "982312"
|
|
410
414
|
* @param {DeleteArchiveByIdV2025R0OptionalsInput} optionalsInput
|
|
@@ -40,6 +40,55 @@ export const shouldIncludeBoxUaHeader = (options: FetchOptions) => {
|
|
|
40
40
|
);
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
+
function createAbortSignalWithTimeout(
|
|
44
|
+
baseSignal: RequestInit['signal'],
|
|
45
|
+
timeoutMs: number,
|
|
46
|
+
): {
|
|
47
|
+
signal: AbortSignal;
|
|
48
|
+
clearTimeout: () => void;
|
|
49
|
+
didTimeout: () => boolean;
|
|
50
|
+
} {
|
|
51
|
+
const controller = new AbortController();
|
|
52
|
+
const upstream = baseSignal as unknown as AbortSignal | undefined;
|
|
53
|
+
let timedOut = false;
|
|
54
|
+
|
|
55
|
+
const abortFromUpstream = () => {
|
|
56
|
+
try {
|
|
57
|
+
(controller as any).abort((upstream as any)?.reason);
|
|
58
|
+
} catch {
|
|
59
|
+
controller.abort();
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
if (upstream) {
|
|
64
|
+
if (upstream.aborted) {
|
|
65
|
+
abortFromUpstream();
|
|
66
|
+
} else {
|
|
67
|
+
upstream.addEventListener('abort', abortFromUpstream, { once: true });
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const timeoutId = setTimeout(() => {
|
|
72
|
+
timedOut = true;
|
|
73
|
+
controller.abort();
|
|
74
|
+
}, timeoutMs);
|
|
75
|
+
|
|
76
|
+
// Node.js timers keep the event loop alive. If the only pending work is this
|
|
77
|
+
// watchdog timeout, we don't want it to prevent process exit (e.g. short CLI
|
|
78
|
+
// runs, tests, scripts). `unref()` detaches the timer from the event loop.
|
|
79
|
+
// It’s a no-op in environments where `unref` isn’t available.
|
|
80
|
+
(timeoutId as any)?.unref?.();
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
signal: controller.signal,
|
|
84
|
+
clearTimeout: () => {
|
|
85
|
+
clearTimeout(timeoutId);
|
|
86
|
+
if (upstream) upstream.removeEventListener('abort', abortFromUpstream);
|
|
87
|
+
},
|
|
88
|
+
didTimeout: () => timedOut,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
43
92
|
type FetchOptionsExtended = FetchOptions & {
|
|
44
93
|
attemptNumber?: number;
|
|
45
94
|
numberOfRetriesOnException?: number;
|
|
@@ -193,19 +242,33 @@ export class BoxNetworkClient implements NetworkClient {
|
|
|
193
242
|
: void 0,
|
|
194
243
|
});
|
|
195
244
|
|
|
245
|
+
const timeoutConfig = fetchOptions.networkSession?.timeoutConfig;
|
|
246
|
+
const timeoutMs = timeoutConfig?.timeoutMs;
|
|
247
|
+
|
|
248
|
+
const requestTimeout =
|
|
249
|
+
timeoutMs != null && timeoutMs > 0
|
|
250
|
+
? createAbortSignalWithTimeout(requestInit.signal, timeoutMs)
|
|
251
|
+
: undefined;
|
|
252
|
+
const requestInitWithTimeout: RequestInit = requestTimeout
|
|
253
|
+
? {
|
|
254
|
+
...requestInit,
|
|
255
|
+
signal: requestTimeout.signal as unknown as RequestInit['signal'],
|
|
256
|
+
}
|
|
257
|
+
: requestInit;
|
|
258
|
+
|
|
196
259
|
try {
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
new URLSearchParams(params).toString(),
|
|
204
|
-
),
|
|
205
|
-
{ ...requestInit, redirect: isBrowser() ? 'follow' : 'manual' },
|
|
260
|
+
const requestUrl = ''.concat(
|
|
261
|
+
fetchOptions.url,
|
|
262
|
+
Object.keys(params).length === 0 || fetchOptions.url.endsWith('?')
|
|
263
|
+
? ''
|
|
264
|
+
: '?',
|
|
265
|
+
new URLSearchParams(params).toString(),
|
|
206
266
|
);
|
|
267
|
+
const response = await nodeFetch(requestUrl, {
|
|
268
|
+
...requestInitWithTimeout,
|
|
269
|
+
redirect: isBrowser() ? 'follow' : 'manual',
|
|
270
|
+
});
|
|
207
271
|
|
|
208
|
-
const contentType = response.headers.get('content-type') ?? '';
|
|
209
272
|
const ignoreResponseBody = fetchOptions.followRedirects === false;
|
|
210
273
|
|
|
211
274
|
let data: SerializedData | undefined;
|
|
@@ -244,8 +307,14 @@ export class BoxNetworkClient implements NetworkClient {
|
|
|
244
307
|
} catch (error) {
|
|
245
308
|
isExceptionCase = true;
|
|
246
309
|
numberOfRetriesOnException++;
|
|
247
|
-
|
|
310
|
+
if (requestTimeout?.didTimeout()) {
|
|
311
|
+
caughtError = new Error(`Connection timeout after ${timeoutMs}ms`);
|
|
312
|
+
} else {
|
|
313
|
+
caughtError = error instanceof Error ? error : new Error(String(error));
|
|
314
|
+
}
|
|
248
315
|
fetchResponse = fetchResponse ?? { status: 0, headers: {} };
|
|
316
|
+
} finally {
|
|
317
|
+
requestTimeout?.clearTimeout();
|
|
249
318
|
}
|
|
250
319
|
const attemptForRetry = isExceptionCase
|
|
251
320
|
? numberOfRetriesOnException
|
|
@@ -263,7 +332,7 @@ export class BoxNetworkClient implements NetworkClient {
|
|
|
263
332
|
fetchResponse,
|
|
264
333
|
attemptForRetry,
|
|
265
334
|
);
|
|
266
|
-
await new Promise((resolve) => setTimeout(resolve, retryTimeout));
|
|
335
|
+
await new Promise((resolve) => setTimeout(resolve, retryTimeout * 1000));
|
|
267
336
|
return this.fetch({
|
|
268
337
|
...options,
|
|
269
338
|
attemptNumber: attemptNumber + 1,
|
|
@@ -325,7 +394,7 @@ export class BoxNetworkClient implements NetworkClient {
|
|
|
325
394
|
: [];
|
|
326
395
|
if (fetchResponse.status === 0) {
|
|
327
396
|
throw new BoxSdkError({
|
|
328
|
-
message: `Unexpected Error occurred`,
|
|
397
|
+
message: caughtError?.message || `Unexpected Error occurred`,
|
|
329
398
|
timestamp: `${Date.now()}`,
|
|
330
399
|
error: caughtError,
|
|
331
400
|
});
|
|
@@ -5,6 +5,7 @@ import { Agent } from '../internal/utils';
|
|
|
5
5
|
import { AgentOptions } from '../internal/utils';
|
|
6
6
|
import { createAgent } from '../internal/utils';
|
|
7
7
|
import { ProxyConfig } from './proxyConfig';
|
|
8
|
+
import { TimeoutConfig } from './timeoutConfig';
|
|
8
9
|
import { BoxNetworkClient } from './boxNetworkClient';
|
|
9
10
|
import { NetworkClient } from './networkClient';
|
|
10
11
|
import { RetryStrategy } from './retries';
|
|
@@ -22,6 +23,7 @@ export class NetworkSession {
|
|
|
22
23
|
readonly networkClient: NetworkClient = new BoxNetworkClient({});
|
|
23
24
|
readonly retryStrategy: RetryStrategy = new BoxRetryStrategy({});
|
|
24
25
|
readonly dataSanitizer: DataSanitizer = new DataSanitizer({});
|
|
26
|
+
readonly timeoutConfig?: TimeoutConfig;
|
|
25
27
|
constructor(
|
|
26
28
|
fields: Omit<
|
|
27
29
|
NetworkSession,
|
|
@@ -40,6 +42,7 @@ export class NetworkSession {
|
|
|
40
42
|
| 'withNetworkClient'
|
|
41
43
|
| 'withRetryStrategy'
|
|
42
44
|
| 'withDataSanitizer'
|
|
45
|
+
| 'withTimeoutConfig'
|
|
43
46
|
> &
|
|
44
47
|
Partial<
|
|
45
48
|
Pick<
|
|
@@ -81,6 +84,9 @@ export class NetworkSession {
|
|
|
81
84
|
if (fields.dataSanitizer !== undefined) {
|
|
82
85
|
this.dataSanitizer = fields.dataSanitizer;
|
|
83
86
|
}
|
|
87
|
+
if (fields.timeoutConfig !== undefined) {
|
|
88
|
+
this.timeoutConfig = fields.timeoutConfig;
|
|
89
|
+
}
|
|
84
90
|
}
|
|
85
91
|
/**
|
|
86
92
|
* Generate a fresh network session by duplicating the existing configuration and network parameters, while also including additional headers to be attached to every API call.
|
|
@@ -122,6 +128,7 @@ export class NetworkSession {
|
|
|
122
128
|
networkClient: this.networkClient,
|
|
123
129
|
retryStrategy: this.retryStrategy,
|
|
124
130
|
dataSanitizer: this.dataSanitizer,
|
|
131
|
+
timeoutConfig: this.timeoutConfig,
|
|
125
132
|
});
|
|
126
133
|
}
|
|
127
134
|
/**
|
|
@@ -140,6 +147,7 @@ export class NetworkSession {
|
|
|
140
147
|
networkClient: this.networkClient,
|
|
141
148
|
retryStrategy: this.retryStrategy,
|
|
142
149
|
dataSanitizer: this.dataSanitizer,
|
|
150
|
+
timeoutConfig: this.timeoutConfig,
|
|
143
151
|
});
|
|
144
152
|
}
|
|
145
153
|
/**
|
|
@@ -158,6 +166,7 @@ export class NetworkSession {
|
|
|
158
166
|
networkClient: this.networkClient,
|
|
159
167
|
retryStrategy: this.retryStrategy,
|
|
160
168
|
dataSanitizer: this.dataSanitizer,
|
|
169
|
+
timeoutConfig: this.timeoutConfig,
|
|
161
170
|
});
|
|
162
171
|
}
|
|
163
172
|
/**
|
|
@@ -176,6 +185,7 @@ export class NetworkSession {
|
|
|
176
185
|
networkClient: this.networkClient,
|
|
177
186
|
retryStrategy: this.retryStrategy,
|
|
178
187
|
dataSanitizer: this.dataSanitizer,
|
|
188
|
+
timeoutConfig: this.timeoutConfig,
|
|
179
189
|
});
|
|
180
190
|
}
|
|
181
191
|
/**
|
|
@@ -194,6 +204,7 @@ export class NetworkSession {
|
|
|
194
204
|
networkClient: networkClient,
|
|
195
205
|
retryStrategy: this.retryStrategy,
|
|
196
206
|
dataSanitizer: this.dataSanitizer,
|
|
207
|
+
timeoutConfig: this.timeoutConfig,
|
|
197
208
|
});
|
|
198
209
|
}
|
|
199
210
|
/**
|
|
@@ -212,6 +223,7 @@ export class NetworkSession {
|
|
|
212
223
|
networkClient: this.networkClient,
|
|
213
224
|
retryStrategy: retryStrategy,
|
|
214
225
|
dataSanitizer: this.dataSanitizer,
|
|
226
|
+
timeoutConfig: this.timeoutConfig,
|
|
215
227
|
});
|
|
216
228
|
}
|
|
217
229
|
/**
|
|
@@ -231,6 +243,26 @@ export class NetworkSession {
|
|
|
231
243
|
networkClient: this.networkClient,
|
|
232
244
|
retryStrategy: this.retryStrategy,
|
|
233
245
|
dataSanitizer: dataSanitizer,
|
|
246
|
+
timeoutConfig: this.timeoutConfig,
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Generate a fresh network session by duplicating the existing configuration and network parameters, while also applying timeout config
|
|
251
|
+
* @param {TimeoutConfig} timeoutConfig
|
|
252
|
+
* @returns {NetworkSession}
|
|
253
|
+
*/
|
|
254
|
+
withTimeoutConfig(timeoutConfig: TimeoutConfig): NetworkSession {
|
|
255
|
+
return new NetworkSession({
|
|
256
|
+
additionalHeaders: this.additionalHeaders,
|
|
257
|
+
baseUrls: this.baseUrls,
|
|
258
|
+
interceptors: this.interceptors,
|
|
259
|
+
agent: this.agent,
|
|
260
|
+
agentOptions: this.agentOptions,
|
|
261
|
+
proxyConfig: this.proxyConfig,
|
|
262
|
+
networkClient: this.networkClient,
|
|
263
|
+
retryStrategy: this.retryStrategy,
|
|
264
|
+
dataSanitizer: this.dataSanitizer,
|
|
265
|
+
timeoutConfig: timeoutConfig,
|
|
234
266
|
});
|
|
235
267
|
}
|
|
236
268
|
}
|
|
@@ -246,4 +278,5 @@ export interface NetworkSessionInput {
|
|
|
246
278
|
readonly networkClient?: NetworkClient;
|
|
247
279
|
readonly retryStrategy?: RetryStrategy;
|
|
248
280
|
readonly dataSanitizer?: DataSanitizer;
|
|
281
|
+
readonly timeoutConfig?: TimeoutConfig;
|
|
249
282
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const sdkVersion = '10.
|
|
1
|
+
export const sdkVersion = '10.5.0';
|
package/src/schemas/index.ts
CHANGED
|
@@ -180,8 +180,8 @@ export * from './skillCard';
|
|
|
180
180
|
export * from './skillCardsMetadata';
|
|
181
181
|
export * from './uploadPartMini';
|
|
182
182
|
export * from './uploadPart';
|
|
183
|
-
export * from './uploadedPart';
|
|
184
183
|
export * from './uploadParts';
|
|
184
|
+
export * from './uploadedPart';
|
|
185
185
|
export * from './uploadSession';
|
|
186
186
|
export * from './uploadUrl';
|
|
187
187
|
export * from './userBase';
|
|
@@ -251,6 +251,9 @@ export * from './aiSingleAgentResponseFull';
|
|
|
251
251
|
export * from './aiMultipleAgentResponse';
|
|
252
252
|
export * from './userAvatar';
|
|
253
253
|
export * from './watermark';
|
|
254
|
+
export * from './webhookMini';
|
|
255
|
+
export * from './webhooks';
|
|
256
|
+
export * from './webhook';
|
|
254
257
|
export * from './webLinkBase';
|
|
255
258
|
export * from './webLinkMini';
|
|
256
259
|
export * from './webLink';
|
|
@@ -285,9 +288,6 @@ export * from './collaborations';
|
|
|
285
288
|
export * from './appItemAssociatedItem';
|
|
286
289
|
export * from './appItemAssociation';
|
|
287
290
|
export * from './appItemAssociations';
|
|
288
|
-
export * from './webhookMini';
|
|
289
|
-
export * from './webhooks';
|
|
290
|
-
export * from './webhook';
|
|
291
291
|
export * from './workflowMini';
|
|
292
292
|
export * from './workflow';
|
|
293
293
|
export * from './workflows';
|
|
@@ -25,6 +25,9 @@ export interface HubUpdateRequestV2025R0 {
|
|
|
25
25
|
/**
|
|
26
26
|
* Indicates if a shared link can be created for the Box Hub. */
|
|
27
27
|
readonly canSharedLinkBeCreated?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Indicates if a public shared link can be created for the Box Hub. */
|
|
30
|
+
readonly canPublicSharedLinkBeCreated?: boolean;
|
|
28
31
|
readonly rawData?: SerializedData;
|
|
29
32
|
}
|
|
30
33
|
export function serializeHubUpdateRequestV2025R0(
|
|
@@ -38,6 +41,7 @@ export function serializeHubUpdateRequestV2025R0(
|
|
|
38
41
|
val.isCollaborationRestrictedToEnterprise,
|
|
39
42
|
['can_non_owners_invite']: val.canNonOwnersInvite,
|
|
40
43
|
['can_shared_link_be_created']: val.canSharedLinkBeCreated,
|
|
44
|
+
['can_public_shared_link_be_created']: val.canPublicSharedLinkBeCreated,
|
|
41
45
|
};
|
|
42
46
|
}
|
|
43
47
|
export function deserializeHubUpdateRequestV2025R0(
|
|
@@ -107,6 +111,19 @@ export function deserializeHubUpdateRequestV2025R0(
|
|
|
107
111
|
val.can_shared_link_be_created == void 0
|
|
108
112
|
? void 0
|
|
109
113
|
: val.can_shared_link_be_created;
|
|
114
|
+
if (
|
|
115
|
+
!(val.can_public_shared_link_be_created == void 0) &&
|
|
116
|
+
!sdIsBoolean(val.can_public_shared_link_be_created)
|
|
117
|
+
) {
|
|
118
|
+
throw new BoxSdkError({
|
|
119
|
+
message:
|
|
120
|
+
'Expecting boolean for "can_public_shared_link_be_created" of type "HubUpdateRequestV2025R0"',
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
const canPublicSharedLinkBeCreated: undefined | boolean =
|
|
124
|
+
val.can_public_shared_link_be_created == void 0
|
|
125
|
+
? void 0
|
|
126
|
+
: val.can_public_shared_link_be_created;
|
|
110
127
|
return {
|
|
111
128
|
title: title,
|
|
112
129
|
description: description,
|
|
@@ -115,5 +132,6 @@ export function deserializeHubUpdateRequestV2025R0(
|
|
|
115
132
|
isCollaborationRestrictedToEnterprise,
|
|
116
133
|
canNonOwnersInvite: canNonOwnersInvite,
|
|
117
134
|
canSharedLinkBeCreated: canSharedLinkBeCreated,
|
|
135
|
+
canPublicSharedLinkBeCreated: canPublicSharedLinkBeCreated,
|
|
118
136
|
} satisfies HubUpdateRequestV2025R0;
|
|
119
137
|
}
|
|
@@ -30,6 +30,7 @@ export class HubV2025R0 extends HubBaseV2025R0 {
|
|
|
30
30
|
readonly isCollaborationRestrictedToEnterprise?: boolean;
|
|
31
31
|
readonly canNonOwnersInvite?: boolean;
|
|
32
32
|
readonly canSharedLinkBeCreated?: boolean;
|
|
33
|
+
readonly canPublicSharedLinkBeCreated?: boolean;
|
|
33
34
|
constructor(fields: HubV2025R0) {
|
|
34
35
|
super(fields);
|
|
35
36
|
if (fields.title !== undefined) {
|
|
@@ -66,6 +67,9 @@ export class HubV2025R0 extends HubBaseV2025R0 {
|
|
|
66
67
|
if (fields.canSharedLinkBeCreated !== undefined) {
|
|
67
68
|
this.canSharedLinkBeCreated = fields.canSharedLinkBeCreated;
|
|
68
69
|
}
|
|
70
|
+
if (fields.canPublicSharedLinkBeCreated !== undefined) {
|
|
71
|
+
this.canPublicSharedLinkBeCreated = fields.canPublicSharedLinkBeCreated;
|
|
72
|
+
}
|
|
69
73
|
}
|
|
70
74
|
}
|
|
71
75
|
export function serializeHubV2025R0(val: HubV2025R0): SerializedData {
|
|
@@ -100,6 +104,7 @@ export function serializeHubV2025R0(val: HubV2025R0): SerializedData {
|
|
|
100
104
|
val.isCollaborationRestrictedToEnterprise,
|
|
101
105
|
['can_non_owners_invite']: val.canNonOwnersInvite,
|
|
102
106
|
['can_shared_link_be_created']: val.canSharedLinkBeCreated,
|
|
107
|
+
['can_public_shared_link_be_created']: val.canPublicSharedLinkBeCreated,
|
|
103
108
|
},
|
|
104
109
|
};
|
|
105
110
|
}
|
|
@@ -193,6 +198,19 @@ export function deserializeHubV2025R0(val: SerializedData): HubV2025R0 {
|
|
|
193
198
|
val.can_shared_link_be_created == void 0
|
|
194
199
|
? void 0
|
|
195
200
|
: val.can_shared_link_be_created;
|
|
201
|
+
if (
|
|
202
|
+
!(val.can_public_shared_link_be_created == void 0) &&
|
|
203
|
+
!sdIsBoolean(val.can_public_shared_link_be_created)
|
|
204
|
+
) {
|
|
205
|
+
throw new BoxSdkError({
|
|
206
|
+
message:
|
|
207
|
+
'Expecting boolean for "can_public_shared_link_be_created" of type "HubV2025R0"',
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
const canPublicSharedLinkBeCreated: undefined | boolean =
|
|
211
|
+
val.can_public_shared_link_be_created == void 0
|
|
212
|
+
? void 0
|
|
213
|
+
: val.can_public_shared_link_be_created;
|
|
196
214
|
if (val.id == void 0) {
|
|
197
215
|
throw new BoxSdkError({
|
|
198
216
|
message: 'Expecting "id" of type "HubV2025R0" to be defined',
|
|
@@ -225,6 +243,7 @@ export function deserializeHubV2025R0(val: SerializedData): HubV2025R0 {
|
|
|
225
243
|
isCollaborationRestrictedToEnterprise,
|
|
226
244
|
canNonOwnersInvite: canNonOwnersInvite,
|
|
227
245
|
canSharedLinkBeCreated: canSharedLinkBeCreated,
|
|
246
|
+
canPublicSharedLinkBeCreated: canPublicSharedLinkBeCreated,
|
|
228
247
|
id: id,
|
|
229
248
|
type: type,
|
|
230
249
|
} satisfies HubV2025R0;
|
|
@@ -65,7 +65,6 @@ test('testArchivesCreateListDelete', async function testArchivesCreateListDelete
|
|
|
65
65
|
if (!(archives.entries!.length > 0)) {
|
|
66
66
|
throw new Error('Assertion failed');
|
|
67
67
|
}
|
|
68
|
-
await client.archives.deleteArchiveByIdV2025R0(archive.id);
|
|
69
68
|
await expect(async () => {
|
|
70
69
|
await client.archives.deleteArchiveByIdV2025R0(archive.id);
|
|
71
70
|
}).rejects.toThrow();
|
package/src/test/client.test.ts
CHANGED
|
@@ -37,6 +37,7 @@ import { FileFull } from '@/schemas/fileFull';
|
|
|
37
37
|
import { ResponseFormat } from '@/networking/fetchOptions';
|
|
38
38
|
import { UserFull } from '@/schemas/userFull';
|
|
39
39
|
import { CreateUserRequestBody } from '@/managers/users';
|
|
40
|
+
import { TimeoutConfig } from '@/networking/timeoutConfig';
|
|
40
41
|
import { getUuid } from '@/internal/utils';
|
|
41
42
|
import { generateByteStream } from '@/internal/utils';
|
|
42
43
|
import { bufferEquals } from '@/internal/utils';
|
|
@@ -368,6 +369,22 @@ test('testWithCustomBaseUrls', async function testWithCustomBaseUrls(): Promise<
|
|
|
368
369
|
await customBaseClient.users.getUserMe();
|
|
369
370
|
}).rejects.toThrow();
|
|
370
371
|
});
|
|
372
|
+
test('testWithTimeoutWhenTimeoutOccurs', async function testWithTimeoutWhenTimeoutOccurs(): Promise<any> {
|
|
373
|
+
const timeoutMs: number = 1;
|
|
374
|
+
const clientWithTimeout: BoxClient = client.withTimeouts({
|
|
375
|
+
timeoutMs: timeoutMs,
|
|
376
|
+
} satisfies TimeoutConfig);
|
|
377
|
+
await expect(async () => {
|
|
378
|
+
await clientWithTimeout.users.getUserMe();
|
|
379
|
+
}).rejects.toThrow();
|
|
380
|
+
});
|
|
381
|
+
test('testWithTimeoutWhenTimeoutDoesNotOccur', async function testWithTimeoutWhenTimeoutDoesNotOccur(): Promise<any> {
|
|
382
|
+
const timeoutMs: number = 10000;
|
|
383
|
+
const clientWithTimeout: BoxClient = client.withTimeouts({
|
|
384
|
+
timeoutMs: timeoutMs,
|
|
385
|
+
} satisfies TimeoutConfig);
|
|
386
|
+
await clientWithTimeout.users.getUserMe();
|
|
387
|
+
});
|
|
371
388
|
test('testWithInterceptors', async function testWithInterceptors(): Promise<any> {
|
|
372
389
|
const user: UserFull = await client.users.getUserMe();
|
|
373
390
|
if (!(user.role == void 0)) {
|