@vertesia/client 1.6.0-dev.20261022.120426Z → 1.7.0-dev.20261120.100641Z
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/AccountApi.d.ts +2 -0
- package/lib/AccountApi.d.ts.map +1 -1
- package/lib/AccountApi.js +3 -0
- package/lib/AccountApi.js.map +1 -1
- package/lib/AccountRolesApi.d.ts +11 -0
- package/lib/AccountRolesApi.d.ts.map +1 -0
- package/lib/AccountRolesApi.js +22 -0
- package/lib/AccountRolesApi.js.map +1 -0
- package/lib/AppsApi.d.ts +18 -3
- package/lib/AppsApi.d.ts.map +1 -1
- package/lib/AppsApi.js +34 -4
- package/lib/AppsApi.js.map +1 -1
- package/lib/AuditTrailApi.d.ts +6 -1
- package/lib/AuditTrailApi.d.ts.map +1 -1
- package/lib/AuditTrailApi.js +8 -0
- package/lib/AuditTrailApi.js.map +1 -1
- package/lib/EnvironmentsApi.d.ts +2 -2
- package/lib/EnvironmentsApi.d.ts.map +1 -1
- package/lib/IamApi.d.ts +1 -1
- package/lib/IamApi.js +1 -1
- package/lib/InteractionCatalogApi.d.ts +19 -1
- package/lib/InteractionCatalogApi.d.ts.map +1 -1
- package/lib/InteractionCatalogApi.js +30 -0
- package/lib/InteractionCatalogApi.js.map +1 -1
- package/lib/InteractionsApi.d.ts +3 -12
- package/lib/InteractionsApi.d.ts.map +1 -1
- package/lib/InteractionsApi.js +2 -23
- package/lib/InteractionsApi.js.map +1 -1
- package/lib/OAuthClientsApi.d.ts +3 -1
- package/lib/OAuthClientsApi.d.ts.map +1 -1
- package/lib/OAuthClientsApi.js +4 -0
- package/lib/OAuthClientsApi.js.map +1 -1
- package/lib/OAuthProvidersApi.d.ts +6 -2
- package/lib/OAuthProvidersApi.d.ts.map +1 -1
- package/lib/OAuthProvidersApi.js +6 -2
- package/lib/OAuthProvidersApi.js.map +1 -1
- package/lib/RemoteMcpConnectionsApi.d.ts +5 -1
- package/lib/RemoteMcpConnectionsApi.d.ts.map +1 -1
- package/lib/RemoteMcpConnectionsApi.js +6 -2
- package/lib/RemoteMcpConnectionsApi.js.map +1 -1
- package/lib/StreamSource.d.ts +19 -1
- package/lib/StreamSource.d.ts.map +1 -1
- package/lib/StreamSource.js +31 -1
- package/lib/StreamSource.js.map +1 -1
- package/lib/UsersApi.d.ts +7 -1
- package/lib/UsersApi.d.ts.map +1 -1
- package/lib/UsersApi.js +8 -0
- package/lib/UsersApi.js.map +1 -1
- package/lib/client.d.ts +14 -2
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +57 -8
- package/lib/client.js.map +1 -1
- package/lib/execute.d.ts.map +1 -1
- package/lib/execute.js +4 -2
- package/lib/execute.js.map +1 -1
- package/lib/idempotency-key.d.ts +19 -0
- package/lib/idempotency-key.d.ts.map +1 -0
- package/lib/idempotency-key.js +34 -0
- package/lib/idempotency-key.js.map +1 -0
- package/lib/nodejs/NodeStreamSource.d.ts +10 -1
- package/lib/nodejs/NodeStreamSource.d.ts.map +1 -1
- package/lib/nodejs/NodeStreamSource.js +40 -2
- package/lib/nodejs/NodeStreamSource.js.map +1 -1
- package/lib/store/AgentsApi.d.ts.map +1 -1
- package/lib/store/AgentsApi.js +5 -2
- package/lib/store/AgentsApi.js.map +1 -1
- package/lib/store/ContentSourcesApi.d.ts +57 -0
- package/lib/store/ContentSourcesApi.d.ts.map +1 -0
- package/lib/store/ContentSourcesApi.js +92 -0
- package/lib/store/ContentSourcesApi.js.map +1 -0
- package/lib/store/CostApi.d.ts +9 -1
- package/lib/store/CostApi.d.ts.map +1 -1
- package/lib/store/CostApi.js +16 -0
- package/lib/store/CostApi.js.map +1 -1
- package/lib/store/DashboardApi.d.ts +61 -19
- package/lib/store/DashboardApi.d.ts.map +1 -1
- package/lib/store/DashboardApi.js +75 -19
- package/lib/store/DashboardApi.js.map +1 -1
- package/lib/store/DataApi.d.ts +9 -9
- package/lib/store/DataApi.d.ts.map +1 -1
- package/lib/store/DataApi.js +14 -10
- package/lib/store/DataApi.js.map +1 -1
- package/lib/store/FilesApi.d.ts +15 -1
- package/lib/store/FilesApi.d.ts.map +1 -1
- package/lib/store/FilesApi.js +54 -75
- package/lib/store/FilesApi.js.map +1 -1
- package/lib/store/NotificationsApi.d.ts +39 -0
- package/lib/store/NotificationsApi.d.ts.map +1 -0
- package/lib/store/NotificationsApi.js +68 -0
- package/lib/store/NotificationsApi.js.map +1 -0
- package/lib/store/ObjectsApi.d.ts +6 -1
- package/lib/store/ObjectsApi.d.ts.map +1 -1
- package/lib/store/ObjectsApi.js +23 -30
- package/lib/store/ObjectsApi.js.map +1 -1
- package/lib/store/RenderingApi.d.ts.map +1 -1
- package/lib/store/RenderingApi.js +1 -0
- package/lib/store/RenderingApi.js.map +1 -1
- package/lib/store/WorkflowsApi.d.ts +19 -1
- package/lib/store/WorkflowsApi.d.ts.map +1 -1
- package/lib/store/WorkflowsApi.js +21 -0
- package/lib/store/WorkflowsApi.js.map +1 -1
- package/lib/store/chunked-upload.d.ts +71 -0
- package/lib/store/chunked-upload.d.ts.map +1 -0
- package/lib/store/chunked-upload.js +206 -0
- package/lib/store/chunked-upload.js.map +1 -0
- package/lib/store/client.d.ts +9 -1
- package/lib/store/client.d.ts.map +1 -1
- package/lib/store/client.js +17 -1
- package/lib/store/client.js.map +1 -1
- package/lib/store/index.d.ts +3 -0
- package/lib/store/index.d.ts.map +1 -1
- package/lib/store/index.js +3 -0
- package/lib/store/index.js.map +1 -1
- package/lib/store/node-request.browser.d.ts +14 -0
- package/lib/store/node-request.browser.d.ts.map +1 -0
- package/lib/store/node-request.browser.js +20 -0
- package/lib/store/node-request.browser.js.map +1 -0
- package/lib/store/node-request.d.ts +20 -0
- package/lib/store/node-request.d.ts.map +1 -0
- package/lib/store/node-request.js +116 -0
- package/lib/store/node-request.js.map +1 -0
- package/lib/store/node-sessions.browser.d.ts +3 -0
- package/lib/store/node-sessions.browser.d.ts.map +1 -0
- package/lib/store/node-sessions.browser.js +15 -0
- package/lib/store/node-sessions.browser.js.map +1 -0
- package/lib/store/node-sessions.d.ts +14 -0
- package/lib/store/node-sessions.d.ts.map +1 -0
- package/lib/store/node-sessions.js +88 -0
- package/lib/store/node-sessions.js.map +1 -0
- package/lib/store/signed-url.d.ts +12 -16
- package/lib/store/signed-url.d.ts.map +1 -1
- package/lib/store/signed-url.js +111 -71
- package/lib/store/signed-url.js.map +1 -1
- package/lib/store/stream-bytes.d.ts +16 -0
- package/lib/store/stream-bytes.d.ts.map +1 -0
- package/lib/store/stream-bytes.js +70 -0
- package/lib/store/stream-bytes.js.map +1 -0
- package/lib/store/stream-termination.d.ts.map +1 -1
- package/lib/store/stream-termination.js +17 -16
- package/lib/store/stream-termination.js.map +1 -1
- package/lib/store/upload-body.d.ts +21 -0
- package/lib/store/upload-body.d.ts.map +1 -0
- package/lib/store/upload-body.js +32 -0
- package/lib/store/upload-body.js.map +1 -0
- package/lib/store/upload-content.d.ts +21 -0
- package/lib/store/upload-content.d.ts.map +1 -0
- package/lib/store/upload-content.js +113 -0
- package/lib/store/upload-content.js.map +1 -0
- package/lib/store/upload-runtime.d.ts +21 -0
- package/lib/store/upload-runtime.d.ts.map +1 -0
- package/lib/store/upload-runtime.js +40 -0
- package/lib/store/upload-runtime.js.map +1 -0
- package/lib/user-agent.d.ts +11 -0
- package/lib/user-agent.d.ts.map +1 -0
- package/lib/user-agent.js +35 -0
- package/lib/user-agent.js.map +1 -0
- package/lib/vertesia-client.js +10 -9
- package/lib/vertesia-client.js.map +1 -1
- package/package.json +35 -11
- package/src/AccountApi.ts +3 -0
- package/src/AccountRolesApi.ts +29 -0
- package/src/AppsApi.ts +58 -4
- package/src/AuditTrailApi.ts +11 -0
- package/src/EnvironmentsApi.ts +2 -2
- package/src/IamApi.ts +1 -1
- package/src/InteractionCatalogApi.ts +44 -1
- package/src/InteractionsApi.ts +2 -31
- package/src/OAuthClientsApi.ts +6 -0
- package/src/OAuthProvidersApi.ts +7 -2
- package/src/RemoteMcpConnectionsApi.ts +7 -3
- package/src/StreamSource.ts +29 -0
- package/src/UsersApi.ts +10 -1
- package/src/client.ts +74 -8
- package/src/execute.ts +4 -2
- package/src/idempotency-key.ts +34 -0
- package/src/nodejs/NodeStreamSource.ts +37 -2
- package/src/store/AgentsApi.ts +5 -2
- package/src/store/ContentSourcesApi.ts +135 -0
- package/src/store/CostApi.ts +24 -0
- package/src/store/DashboardApi.ts +93 -18
- package/src/store/DataApi.ts +14 -10
- package/src/store/FilesApi.ts +84 -78
- package/src/store/NotificationsApi.ts +103 -0
- package/src/store/ObjectsApi.ts +30 -34
- package/src/store/RenderingApi.ts +1 -0
- package/src/store/WorkflowsApi.ts +25 -0
- package/src/store/chunked-upload.ts +272 -0
- package/src/store/client.ts +23 -1
- package/src/store/index.ts +3 -0
- package/src/store/node-request.browser.ts +22 -0
- package/src/store/node-request.ts +120 -0
- package/src/store/node-sessions.browser.ts +16 -0
- package/src/store/node-sessions.ts +109 -0
- package/src/store/signed-url.ts +126 -72
- package/src/store/stream-bytes.ts +79 -0
- package/src/store/stream-termination.ts +24 -24
- package/src/store/upload-body.ts +37 -0
- package/src/store/upload-content.ts +129 -0
- package/src/store/upload-runtime.ts +42 -0
- package/src/user-agent.ts +41 -0
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The upload of a source to a file, shared by `FilesApi` and `ObjectsApi`. Internal: not exported from the package.
|
|
3
|
+
*/
|
|
4
|
+
import { RequestError } from '@vertesia/api-fetch-client';
|
|
5
|
+
import { partsAsUploadBody, planUpload, uploadInParts } from './chunked-upload.js';
|
|
6
|
+
import { fetchSignedUrl } from './signed-url.js';
|
|
7
|
+
import { unquoteEtag, uploadHeaders } from './upload-body.js';
|
|
8
|
+
import { UploadSessionUnavailableError } from './upload-runtime.js';
|
|
9
|
+
import { resolveUploadMimeType } from './uploadMimeType.js';
|
|
10
|
+
/** A location without its query string or fragment, which hold a signed URL's credentials. */
|
|
11
|
+
export function fileLocationForError(location) {
|
|
12
|
+
try {
|
|
13
|
+
const url = new URL(location);
|
|
14
|
+
return `${url.protocol}//${url.host}${url.pathname}`;
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return location.split(/[?#]/, 1)[0] || 'unknown file';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/** A copy of an error safe to log: every URL in its message is cut to its location. */
|
|
21
|
+
export function sanitizedErrorCause(error) {
|
|
22
|
+
if (!(error instanceof Error)) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
const message = error.message.replace(/https?:\/\/[^\s)\]}>"']+/g, (url) => fileLocationForError(url));
|
|
26
|
+
const cause = new Error(message);
|
|
27
|
+
cause.name = error.name;
|
|
28
|
+
return cause;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The statuses of a server without upload sessions (404, or 405 where another route matches the path), or whose
|
|
32
|
+
* storage has none (501).
|
|
33
|
+
*/
|
|
34
|
+
const NO_UPLOAD_SESSION_STATUSES = new Set([404, 405, 501]);
|
|
35
|
+
/** The stream of a plan, which a failed upload must cancel to release what it holds (a socket, a file). */
|
|
36
|
+
function planStream(plan) {
|
|
37
|
+
const body = plan.kind === 'parts' ? plan.parts.body : plan.upload.body;
|
|
38
|
+
return body instanceof ReadableStream ? body : undefined;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Upload a source to the file `request` names: in one signed PUT, or, for a stream source longer than one part in
|
|
42
|
+
* Node.js, in parts through an upload session (see `chunked-upload.ts`). On failure the source's stream is cancelled.
|
|
43
|
+
*
|
|
44
|
+
* @param signUpload the signed PUT URL to use, when the caller already has one or signs it another way
|
|
45
|
+
* @param fallbackMimeType the content type when neither the source nor the server names one
|
|
46
|
+
*/
|
|
47
|
+
export async function uploadContent(files, source, request, signUpload = () => files.getUploadUrl(request), fallbackMimeType) {
|
|
48
|
+
const plan = await planUpload(source);
|
|
49
|
+
try {
|
|
50
|
+
return await sendPlan(files, source, request, plan, signUpload, fallbackMimeType);
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
// A stream already being sent is locked, and its sender cancels it; this one was never read whole.
|
|
54
|
+
await planStream(plan)
|
|
55
|
+
?.cancel(err)
|
|
56
|
+
.catch(() => undefined);
|
|
57
|
+
throw err;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async function sendPlan(files, source, request, plan, signUpload, fallbackMimeType) {
|
|
61
|
+
let upload;
|
|
62
|
+
if (plan.kind === 'parts') {
|
|
63
|
+
const session = await files.createUploadSession(request).catch((err) => {
|
|
64
|
+
if (err instanceof RequestError && NO_UPLOAD_SESSION_STATUSES.has(err.status))
|
|
65
|
+
return undefined;
|
|
66
|
+
throw err;
|
|
67
|
+
});
|
|
68
|
+
if (!session) {
|
|
69
|
+
console.warn(`Upload sessions are not available; uploading ${request.name} in a single request`);
|
|
70
|
+
upload = partsAsUploadBody(plan.parts);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
try {
|
|
74
|
+
const etag = await uploadInParts(files, session, plan.parts);
|
|
75
|
+
const mime_type = resolveUploadMimeType(source.type, session.mime_type) || fallbackMimeType;
|
|
76
|
+
return { id: session.id, path: session.path, mime_type, etag };
|
|
77
|
+
}
|
|
78
|
+
catch (err) {
|
|
79
|
+
if (!(err instanceof UploadSessionUnavailableError)) {
|
|
80
|
+
console.error('Failed to upload file', { err: sanitizedErrorCause(err), id: session.id });
|
|
81
|
+
throw err;
|
|
82
|
+
}
|
|
83
|
+
console.warn(`${err.message}; uploading ${session.path} in a single request instead`);
|
|
84
|
+
upload = partsAsUploadBody(plan.parts);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
upload = plan.upload;
|
|
90
|
+
}
|
|
91
|
+
const { url, id, path, mime_type } = await signUpload();
|
|
92
|
+
const sourceMimeType = resolveUploadMimeType(source.type, mime_type) || fallbackMimeType;
|
|
93
|
+
const res = await fetchSignedUrl(url, {
|
|
94
|
+
method: 'PUT',
|
|
95
|
+
body: upload.body,
|
|
96
|
+
headers: uploadHeaders(upload, sourceMimeType),
|
|
97
|
+
}).catch((err) => {
|
|
98
|
+
console.error('Failed to upload file', { err, location: fileLocationForError(url), id, path });
|
|
99
|
+
throw err;
|
|
100
|
+
});
|
|
101
|
+
if (!res.ok) {
|
|
102
|
+
console.error('Failed to upload file', {
|
|
103
|
+
status: res.status,
|
|
104
|
+
statusText: res.statusText,
|
|
105
|
+
location: fileLocationForError(url),
|
|
106
|
+
id,
|
|
107
|
+
path,
|
|
108
|
+
});
|
|
109
|
+
throw new Error(`Failed to upload file ${source.name}: ${res.statusText}`);
|
|
110
|
+
}
|
|
111
|
+
return { id, path, mime_type: sourceMimeType, etag: unquoteEtag(res.headers.get('etag') ?? undefined) };
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=upload-content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload-content.js","sourceRoot":"","sources":["../../src/store/upload-content.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAG1D,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAmB,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpG,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAmB,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,6BAA6B,EAAE,MAAM,qBAAqB,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,8FAA8F;AAC9F,MAAM,UAAU,oBAAoB,CAAC,QAAgB;IACjD,IAAI,CAAC;QACD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;QAC9B,OAAO,GAAG,GAAG,CAAC,QAAQ,KAAK,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,QAAQ,EAAE,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IAAI,EAAE,CAAC,CAAC;QAC/F,MAAM,GAAG,CAAC;IACd,CAAC,CAAC,CAAC;IACH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;QACV,OAAO,CAAC,KAAK,CAAC,uBAAuB,EAAE;YACnC,MAAM,EAAE,GAAG,CAAC,MAAM;YAClB,UAAU,EAAE,GAAG,CAAC,UAAU;YAC1B,QAAQ,EAAE,oBAAoB,CAAC,GAAG,CAAC;YACnC,EAAE;YACF,IAAI;SACP,CAAC,CAAC;QACH,MAAM,IAAI,KAAK,CAAC,yBAAyB,MAAM,CAAC,IAAI,KAAK,GAAG,CAAC,UAAU,EAAE,CAAC,CAAC;IAC/E,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,cAAc,EAAE,IAAI,EAAE,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,SAAS,CAAC,EAAE,CAAC;AAC5G,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Runtime checks and errors of the upload transports, safe to load in any runtime. */
|
|
2
|
+
/** Whether this runtime has Node's `http` client (Node.js, and runtimes compatible with it such as Bun). */
|
|
3
|
+
export declare function hasNodeHttp(): boolean;
|
|
4
|
+
/** The error for a body whose size differs from its declared `Content-Length`. */
|
|
5
|
+
export declare class ContentLengthMismatchError extends Error {
|
|
6
|
+
readonly declared: number;
|
|
7
|
+
readonly actual: number;
|
|
8
|
+
readonly direction: 'short' | 'long';
|
|
9
|
+
constructor(declared: number, actual: number, direction: 'short' | 'long');
|
|
10
|
+
}
|
|
11
|
+
/** This client cannot use the upload session: an SDK it needs is not installed, or it does not know its protocol. */
|
|
12
|
+
export declare class UploadSessionUnavailableError extends Error {
|
|
13
|
+
/** What is missing, such as `the optional package @azure/storage-blob`. */
|
|
14
|
+
readonly requirement: string;
|
|
15
|
+
constructor(
|
|
16
|
+
/** What is missing, such as `the optional package @azure/storage-blob`. */
|
|
17
|
+
requirement: string, cause?: unknown);
|
|
18
|
+
}
|
|
19
|
+
/** The `Content-Length` in `headers`, in any letter case; undefined when absent or not a whole byte count. */
|
|
20
|
+
export declare function contentLengthHeader(headers: Record<string, string> | undefined): number | undefined;
|
|
21
|
+
//# sourceMappingURL=upload-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload-runtime.d.ts","sourceRoot":"","sources":["../../src/store/upload-runtime.ts"],"names":[],"mappings":"AAAA,uFAAuF;AAEvF,4GAA4G;AAC5G,wBAAgB,WAAW,IAAI,OAAO,CAErC;AAED,kFAAkF;AAClF,qBAAa,0BAA2B,SAAQ,KAAK;IAE7C,QAAQ,CAAC,QAAQ,EAAE,MAAM;IACzB,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,SAAS,EAAE,OAAO,GAAG,MAAM;IAHxC,YACa,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,OAAO,GAAG,MAAM,EAQvC;CACJ;AAED,qHAAqH;AACrH,qBAAa,6BAA8B,SAAQ,KAAK;IAEhD,2EAA2E;IAC3E,QAAQ,CAAC,WAAW,EAAE,MAAM;IAFhC;IACI,2EAA2E;IAClE,WAAW,EAAE,MAAM,EAC5B,KAAK,CAAC,EAAE,OAAO,EAIlB;CACJ;AAED,8GAA8G;AAC9G,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAKnG"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** Runtime checks and errors of the upload transports, safe to load in any runtime. */
|
|
2
|
+
/** Whether this runtime has Node's `http` client (Node.js, and runtimes compatible with it such as Bun). */
|
|
3
|
+
export function hasNodeHttp() {
|
|
4
|
+
return typeof process !== 'undefined' && typeof process.versions?.node === 'string';
|
|
5
|
+
}
|
|
6
|
+
/** The error for a body whose size differs from its declared `Content-Length`. */
|
|
7
|
+
export class ContentLengthMismatchError extends Error {
|
|
8
|
+
declared;
|
|
9
|
+
actual;
|
|
10
|
+
direction;
|
|
11
|
+
constructor(declared, actual, direction) {
|
|
12
|
+
super(direction === 'short'
|
|
13
|
+
? `Upload body ended after ${actual} bytes, short of its declared length of ${declared}`
|
|
14
|
+
: `Upload body ran past its declared length of ${declared} bytes`);
|
|
15
|
+
this.declared = declared;
|
|
16
|
+
this.actual = actual;
|
|
17
|
+
this.direction = direction;
|
|
18
|
+
this.name = 'ContentLengthMismatchError';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/** This client cannot use the upload session: an SDK it needs is not installed, or it does not know its protocol. */
|
|
22
|
+
export class UploadSessionUnavailableError extends Error {
|
|
23
|
+
requirement;
|
|
24
|
+
constructor(
|
|
25
|
+
/** What is missing, such as `the optional package @azure/storage-blob`. */
|
|
26
|
+
requirement, cause) {
|
|
27
|
+
super(`Uploading in parts needs ${requirement}`, { cause });
|
|
28
|
+
this.requirement = requirement;
|
|
29
|
+
this.name = 'UploadSessionUnavailableError';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/** The `Content-Length` in `headers`, in any letter case; undefined when absent or not a whole byte count. */
|
|
33
|
+
export function contentLengthHeader(headers) {
|
|
34
|
+
const entry = Object.entries(headers ?? {}).find(([name]) => name.toLowerCase() === 'content-length');
|
|
35
|
+
if (!entry || !/^\d+$/.test(entry[1].trim()))
|
|
36
|
+
return undefined;
|
|
37
|
+
const length = Number(entry[1].trim());
|
|
38
|
+
return Number.isSafeInteger(length) ? length : undefined;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=upload-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload-runtime.js","sourceRoot":"","sources":["../../src/store/upload-runtime.ts"],"names":[],"mappings":"AAAA,uFAAuF;AAEvF,4GAA4G;AAC5G,MAAM,UAAU,WAAW;IACvB,OAAO,OA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CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Product token every Vertesia SDK sends first in its User-Agent: `vertesia-client-<language>/<version>`. */
|
|
2
|
+
export declare const CLIENT_USER_AGENT_PRODUCT: string;
|
|
3
|
+
/**
|
|
4
|
+
* The User-Agent header identifying this SDK and its version, e.g.
|
|
5
|
+
* `vertesia-client-ts/1.7.0 node/22.11.0`.
|
|
6
|
+
*
|
|
7
|
+
* Empty in a browser: the browser owns its User-Agent, and any other custom header would add a
|
|
8
|
+
* CORS preflight requirement that servers on an older release do not allow.
|
|
9
|
+
*/
|
|
10
|
+
export declare function clientUserAgentHeaders(): Record<string, string>;
|
|
11
|
+
//# sourceMappingURL=user-agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-agent.d.ts","sourceRoot":"","sources":["../src/user-agent.ts"],"names":[],"mappings":"AAEA,8GAA8G;AAC9G,eAAO,MAAM,yBAAyB,QAAkD,CAAC;AA2BzF;;;;;;GAMG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAG/D"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import packageMetadata from '../package.json' with { type: 'json' };
|
|
2
|
+
/** Product token every Vertesia SDK sends first in its User-Agent: `vertesia-client-<language>/<version>`. */
|
|
3
|
+
export const CLIENT_USER_AGENT_PRODUCT = `vertesia-client-ts/${packageMetadata.version}`;
|
|
4
|
+
/**
|
|
5
|
+
* The server-side JavaScript runtime, as `<name>/<version>`, or undefined in a browser.
|
|
6
|
+
*/
|
|
7
|
+
function serverRuntime() {
|
|
8
|
+
const runtime = globalThis;
|
|
9
|
+
if (typeof runtime.window !== 'undefined') {
|
|
10
|
+
return undefined;
|
|
11
|
+
}
|
|
12
|
+
const versions = runtime.process?.versions;
|
|
13
|
+
if (typeof versions?.bun === 'string') {
|
|
14
|
+
return `bun/${versions.bun}`;
|
|
15
|
+
}
|
|
16
|
+
if (typeof runtime.Deno?.version?.deno === 'string') {
|
|
17
|
+
return `deno/${runtime.Deno.version.deno}`;
|
|
18
|
+
}
|
|
19
|
+
if (typeof versions?.node === 'string') {
|
|
20
|
+
return `node/${versions.node}`;
|
|
21
|
+
}
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The User-Agent header identifying this SDK and its version, e.g.
|
|
26
|
+
* `vertesia-client-ts/1.7.0 node/22.11.0`.
|
|
27
|
+
*
|
|
28
|
+
* Empty in a browser: the browser owns its User-Agent, and any other custom header would add a
|
|
29
|
+
* CORS preflight requirement that servers on an older release do not allow.
|
|
30
|
+
*/
|
|
31
|
+
export function clientUserAgentHeaders() {
|
|
32
|
+
const runtime = serverRuntime();
|
|
33
|
+
return runtime ? { 'user-agent': `${CLIENT_USER_AGENT_PRODUCT} ${runtime}` } : {};
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=user-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-agent.js","sourceRoot":"","sources":["../src/user-agent.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAEpE,8GAA8G;AAC9G,MAAM,CAAC,MAAM,yBAAyB,GAAG,sBAAsB,eAAe,CAAC,OAAO,EAAE,CAAC;AAEzF;;GAEG;AACH,SAAS,aAAa;IAClB,MAAM,OAAO,GAAG,UAIf,CAAC;IACF,IAAI,OAAO,OAAO,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;QACxC,OAAO,SAAS,CAAC;IACrB,CAAC;IACD,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC;IAC3C,IAAI,OAAO,QAAQ,EAAE,GAAG,KAAK,QAAQ,EAAE,CAAC;QACpC,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