@vol-a/client 0.0.0-stage → 1.1.1

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 (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +254 -2
  3. package/dist/body.d.ts +40 -0
  4. package/dist/body.d.ts.map +1 -0
  5. package/dist/body.js +112 -0
  6. package/dist/body.js.map +1 -0
  7. package/dist/client.d.ts +161 -0
  8. package/dist/client.d.ts.map +1 -0
  9. package/dist/client.js +245 -0
  10. package/dist/client.js.map +1 -0
  11. package/dist/env.d.ts +19 -0
  12. package/dist/env.d.ts.map +1 -0
  13. package/dist/env.js +52 -0
  14. package/dist/env.js.map +1 -0
  15. package/dist/errors.d.ts +43 -0
  16. package/dist/errors.d.ts.map +1 -0
  17. package/dist/errors.js +93 -0
  18. package/dist/errors.js.map +1 -0
  19. package/dist/files.d.ts +144 -0
  20. package/dist/files.d.ts.map +1 -0
  21. package/dist/files.js +239 -0
  22. package/dist/files.js.map +1 -0
  23. package/dist/folders.d.ts +35 -0
  24. package/dist/folders.d.ts.map +1 -0
  25. package/dist/folders.js +62 -0
  26. package/dist/folders.js.map +1 -0
  27. package/dist/index.d.ts +20 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +11 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/keyrings.d.ts +44 -0
  32. package/dist/keyrings.d.ts.map +1 -0
  33. package/dist/keyrings.js +111 -0
  34. package/dist/keyrings.js.map +1 -0
  35. package/dist/management.d.ts +47 -0
  36. package/dist/management.d.ts.map +1 -0
  37. package/dist/management.js +65 -0
  38. package/dist/management.js.map +1 -0
  39. package/dist/shares.d.ts +87 -0
  40. package/dist/shares.d.ts.map +1 -0
  41. package/dist/shares.js +144 -0
  42. package/dist/shares.js.map +1 -0
  43. package/dist/uploads.d.ts +112 -0
  44. package/dist/uploads.d.ts.map +1 -0
  45. package/dist/uploads.js +290 -0
  46. package/dist/uploads.js.map +1 -0
  47. package/package.json +48 -3
package/dist/client.js ADDED
@@ -0,0 +1,245 @@
1
+ import { UdcClient } from "@jsudc/core/client";
2
+ import { CALLER_KEY_FROM_BROWSER_CODE, CONTENT_KEY_BYTES, CONTENT_KEY_HEADER, InstanceTypesResponseSchema, LiveResponseSchema, LOCALE_QUERY, LookupsResponseSchema, ReadyResponseSchema, TENANT_SLUG_HEADER, UNLOCK_HEADER, USER_ID_HEADER, } from "@vol-a/core";
3
+ import { bytesToBase64, isBrowser } from "./env.js";
4
+ import { errorFromResponse, VolaError } from "./errors.js";
5
+ import { FilesApi } from "./files.js";
6
+ import { FoldersApi } from "./folders.js";
7
+ import { KeyringsApi } from "./keyrings.js";
8
+ import { AdminApi, KeysApi, StatsApi } from "./management.js";
9
+ import { openShareUrl, SharesApi } from "./shares.js";
10
+ import { UploadsApi } from "./uploads.js";
11
+ /** `true` for a `2xx`. */
12
+ export const ok2xx = (status) => status >= 200 && status < 300;
13
+ function contentKeyHeader(key) {
14
+ if (typeof key === "string")
15
+ return key;
16
+ if (key.byteLength !== CONTENT_KEY_BYTES) {
17
+ throw new VolaError({
18
+ status: 0,
19
+ code: "bad_request",
20
+ message: `contentKey: ${CONTENT_KEY_BYTES} bytes are required (got ${key.byteLength})`,
21
+ });
22
+ }
23
+ return bytesToBase64(key);
24
+ }
25
+ /**
26
+ * The SDK: one instance per API key (and per principal). Groups mirror the routes —
27
+ * `files`, `folders`, `uploads`, `shares`, `keyrings`, `stats`, `keys`, `admin`, `udc` —
28
+ * and `request()` / `json()` are the escape hatch they are built on.
29
+ *
30
+ * Secrets: the API key, the unlock token, the content key, a share secret and a PIN travel
31
+ * in headers or bodies only — never in a URL, never in an error message, never logged.
32
+ */
33
+ export class VolaClient {
34
+ baseUrl;
35
+ files;
36
+ folders;
37
+ uploads;
38
+ shares;
39
+ keyrings;
40
+ stats;
41
+ keys;
42
+ admin;
43
+ /** The options the instance was made with (the unlock token is NOT in here; see `withUnlock`). */
44
+ options;
45
+ fetchImpl;
46
+ validate;
47
+ unlockToken;
48
+ udcClient;
49
+ constructor(options) {
50
+ const { unlock, ...rest } = options;
51
+ this.options = Object.freeze({ ...rest });
52
+ this.baseUrl = options.baseUrl.replace(/\/+$/, "");
53
+ this.fetchImpl = options.fetch ?? ((input, init) => globalThis.fetch(input, init));
54
+ this.validate = options.validate ?? false;
55
+ this.unlockToken = unlock ?? null;
56
+ this.files = new FilesApi(this);
57
+ this.folders = new FoldersApi(this);
58
+ this.uploads = new UploadsApi(this);
59
+ this.shares = new SharesApi(this);
60
+ this.keyrings = new KeyringsApi(this);
61
+ this.stats = new StatsApi(this);
62
+ this.keys = new KeysApi(this);
63
+ this.admin = new AdminApi(this);
64
+ }
65
+ // --- unlock state -------------------------------------------------------------------------
66
+ /** A client with the same options that sends `token` as `X-Vola-Unlock` (this instance is unchanged). */
67
+ withUnlock(token) {
68
+ return new VolaClient({ ...this.options, unlock: token });
69
+ }
70
+ /** `true` while the instance holds an unlock token (it may still have expired on the server). */
71
+ get unlocked() {
72
+ return this.unlockToken !== null;
73
+ }
74
+ /** Sets (or clears, with `null`) the unlock token the instance sends. `keyrings.unlock()` calls it. */
75
+ setUnlock(token) {
76
+ this.unlockToken = token;
77
+ }
78
+ /** Ends the unlock on the server (`DELETE /keyrings/me/unlock`) and forgets the token. Idempotent. */
79
+ lock() {
80
+ return this.keyrings.lock();
81
+ }
82
+ /**
83
+ * Browser only: on `pagehide` (default) a `navigator.sendBeacon` to `/keyrings/me/unlock/close`
84
+ * ends the unlock the instance holds, so a closed tab leaves no live token behind. The token
85
+ * goes in the beacon's body (`text/plain`), never in the URL. Returns the function that
86
+ * removes the listener. A no-op outside a browser.
87
+ */
88
+ lockOnUnload(options = {}) {
89
+ if (!isBrowser() || typeof navigator === "undefined" || !navigator.sendBeacon) {
90
+ return () => undefined;
91
+ }
92
+ const event = options.event ?? "pagehide";
93
+ const handler = () => {
94
+ if (event === "visibilitychange" && document.visibilityState !== "hidden")
95
+ return;
96
+ const token = this.unlockToken;
97
+ if (!token)
98
+ return;
99
+ this.unlockToken = null;
100
+ navigator.sendBeacon(`${this.baseUrl}/keyrings/me/unlock/close`, new Blob([token], { type: "text/plain" }));
101
+ };
102
+ window.addEventListener(event, handler);
103
+ return () => window.removeEventListener(event, handler);
104
+ }
105
+ // --- transport ----------------------------------------------------------------------------
106
+ /** `baseUrl + path + ?query`. `path` starts with `/` and is already encoded. */
107
+ url(path, query) {
108
+ const params = new URLSearchParams();
109
+ for (const [key, value] of Object.entries(query ?? {})) {
110
+ if (value === undefined || value === null || value === false)
111
+ continue;
112
+ params.set(key, value === true ? "1" : String(value));
113
+ }
114
+ const qs = params.toString();
115
+ return `${this.baseUrl}${path}${qs ? `?${qs}` : ""}`;
116
+ }
117
+ /** The headers of a request: auth, principal, tenant, unlock, content key, extras, then `options.headers`. */
118
+ headers(options = {}) {
119
+ const headers = new Headers();
120
+ for (const [name, value] of Object.entries(this.options.headers ?? {}))
121
+ headers.set(name, value);
122
+ if (this.options.apiKey && !options.anonymous) {
123
+ headers.set("authorization", `Bearer ${this.options.apiKey}`);
124
+ }
125
+ if (this.options.userId)
126
+ headers.set(USER_ID_HEADER, this.options.userId);
127
+ if (this.options.tenantSlug)
128
+ headers.set(TENANT_SLUG_HEADER, this.options.tenantSlug);
129
+ const unlock = options.unlock ?? this.unlockToken;
130
+ if (unlock)
131
+ headers.set(UNLOCK_HEADER, unlock);
132
+ if (options.contentKey !== undefined) {
133
+ if (isBrowser()) {
134
+ throw new VolaError({
135
+ status: 0,
136
+ code: CALLER_KEY_FROM_BROWSER_CODE,
137
+ message: "contentKey (the caller encryption key) cannot be used from a browser: the server refuses every browser request that carries one, and the key would live in the page. Use keyring encryption in the browser, or make this call from your server.",
138
+ });
139
+ }
140
+ headers.set(CONTENT_KEY_HEADER, contentKeyHeader(options.contentKey));
141
+ }
142
+ for (const [name, value] of Object.entries(options.headers ?? {})) {
143
+ if (value !== undefined)
144
+ headers.set(name, value);
145
+ }
146
+ return headers;
147
+ }
148
+ /**
149
+ * One request to `path` (already encoded, starting with `/`). Resolves with the `Response`
150
+ * for every status `options.ok` accepts (default `2xx`) and throws the `VolaError` of any
151
+ * other. Transport failures (no network, a refused connection) throw what `fetch` throws.
152
+ */
153
+ async request(path, options = {}) {
154
+ const headers = this.headers(options);
155
+ let body = options.body ?? null;
156
+ if (options.json !== undefined) {
157
+ headers.set("content-type", "application/json");
158
+ body = JSON.stringify(options.json);
159
+ }
160
+ const init = {
161
+ method: options.method ?? "GET",
162
+ headers,
163
+ body,
164
+ ...(options.signal ? { signal: options.signal } : {}),
165
+ ...(options.streaming ? { duplex: "half" } : {}),
166
+ };
167
+ const response = await this.fetchImpl(this.url(path, options.query), init);
168
+ const accepted = options.ok ?? ok2xx;
169
+ if (!accepted(response.status))
170
+ throw await errorFromResponse(response);
171
+ return response;
172
+ }
173
+ /** `request()` for a JSON answer, typed by (and, with `validate`, checked against) its `@vol-a/core` schema. */
174
+ async json(path, schema, options = {}) {
175
+ const response = await this.request(path, {
176
+ ...options,
177
+ headers: { accept: "application/json", ...options.headers },
178
+ });
179
+ const body = response.status === 204 ? undefined : await response.json();
180
+ if (!(options.validate ?? this.validate))
181
+ return body;
182
+ const parsed = schema.safeParse(body);
183
+ if (!parsed.success) {
184
+ const issue = parsed.error.issues[0];
185
+ throw new VolaError({
186
+ status: response.status,
187
+ code: "invalid_response",
188
+ message: `${options.method ?? "GET"} ${path}: the answer does not match its schema (${issue?.path.map(String).join(".") || "body"}: ${issue?.message ?? "invalid"})`,
189
+ });
190
+ }
191
+ return parsed.data;
192
+ }
193
+ /** The `fetch` this instance was given (or the global one), without any header of its own: for the anonymous routes. */
194
+ get rawFetch() {
195
+ return this.fetchImpl;
196
+ }
197
+ /** Internal: `fetch` with this instance's headers merged in (what `udc` uses). */
198
+ fetchWithAuth(input, init) {
199
+ const headers = this.headers();
200
+ for (const [name, value] of new Headers(init?.headers))
201
+ headers.set(name, value);
202
+ return this.fetchImpl(input, { ...init, headers });
203
+ }
204
+ // --- groups without a class of their own ----------------------------------------------------
205
+ /** `GET /health/live`. No key needed (one is sent when the instance has it). */
206
+ live() {
207
+ return this.json("/health/live", LiveResponseSchema);
208
+ }
209
+ /** `GET /health/ready`; a `503` resolves too (`status: "fail"`) — it is a valid answer. */
210
+ ready() {
211
+ return this.json("/health/ready", ReadyResponseSchema, {
212
+ ok: (status) => ok2xx(status) || status === 503,
213
+ });
214
+ }
215
+ /** `GET /lookups[?locale=]`: the vocabulary of `lookups.yaml`, labelled in `locale`. No key needed. */
216
+ lookups(locale) {
217
+ return this.json("/lookups", LookupsResponseSchema, { query: { [LOCALE_QUERY]: locale } });
218
+ }
219
+ /** `GET /instance-types`: the tenant's instance types with live files, with their counts. */
220
+ instanceTypes(options = {}) {
221
+ return this.json("/instance-types", InstanceTypesResponseSchema, options);
222
+ }
223
+ /**
224
+ * The UDC collections of the server (`POST /udc/<action>`) through `@jsudc/core`'s
225
+ * `UdcClient`, with this instance's auth (key, principal, tenant, unlock token) on every call.
226
+ */
227
+ get udc() {
228
+ this.udcClient ??= new UdcClient({
229
+ httpUrl: this.baseUrl,
230
+ fetch: (input, init) => this.fetchWithAuth(input, init),
231
+ });
232
+ return this.udcClient;
233
+ }
234
+ /**
235
+ * Follows a share link (`…/s/<token>[#<secret>]`) anonymously: the fragment, when there is
236
+ * one, goes as `X-Share-Secret`; a password as `X-Share-Password`; `range` as `Range`. The
237
+ * `Response` streams the file (a folder share answers its JSON listing). Throws the
238
+ * `VolaError` of a refusal (`410 share_gone`, `401 share_password_required`, `401
239
+ * share_secret_required`, `409 vola_integrity`…).
240
+ */
241
+ static openShare(url, options = {}) {
242
+ return openShareUrl(options.fetch ?? ((input, init) => globalThis.fetch(input, init)), url, options);
243
+ }
244
+ }
245
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC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,CACR,CAAC;IACJ,CAAC;CACF"}
package/dist/env.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The little the SDK needs to know about where it runs. It targets Node 24+ and browsers
3
+ * alike, through the web APIs they share (`fetch`, `Blob`, `ReadableStream`, `crypto`).
4
+ */
5
+ /** `true` in a browser page (a `window` with a `document`); `false` in Node, a worker, a test. */
6
+ export declare function isBrowser(): boolean;
7
+ /** Bytes → base64 (standard alphabet, padded). */
8
+ export declare function bytesToBase64(bytes: Uint8Array): string;
9
+ /** Bytes → base64url (no padding): the form of a share secret in a URL fragment. */
10
+ export declare function bytesToBase64Url(bytes: Uint8Array): string;
11
+ /** base64 or base64url → bytes. Throws a `TypeError` on malformed input. */
12
+ export declare function base64ToBytes(value: string): Uint8Array;
13
+ /** `n` random bytes from the platform's CSPRNG. */
14
+ export declare function randomBytes(n: number): Uint8Array<ArrayBuffer>;
15
+ /** A random hex string (a multipart boundary, a fingerprint salt). */
16
+ export declare function randomHex(bytes?: number): string;
17
+ /** `encodeURIComponent` of every segment of `a/b/c`, keeping the slashes; leading and trailing slashes dropped. */
18
+ export declare function encodePath(path: string): string;
19
+ //# sourceMappingURL=env.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,kGAAkG;AAClG,wBAAgB,SAAS,IAAI,OAAO,CAEnC;AAED,kDAAkD;AAClD,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAIvD;AAED,oFAAoF;AACpF,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAE1D;AAED,4EAA4E;AAC5E,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAYvD;AAED,mDAAmD;AACnD,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,CAE9D;AAED,sEAAsE;AACtE,wBAAgB,SAAS,CAAC,KAAK,SAAK,GAAG,MAAM,CAE5C;AAED,mHAAmH;AACnH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM/C"}
package/dist/env.js ADDED
@@ -0,0 +1,52 @@
1
+ /**
2
+ * The little the SDK needs to know about where it runs. It targets Node 24+ and browsers
3
+ * alike, through the web APIs they share (`fetch`, `Blob`, `ReadableStream`, `crypto`).
4
+ */
5
+ /** `true` in a browser page (a `window` with a `document`); `false` in Node, a worker, a test. */
6
+ export function isBrowser() {
7
+ return typeof window !== "undefined" && typeof window.document !== "undefined";
8
+ }
9
+ /** Bytes → base64 (standard alphabet, padded). */
10
+ export function bytesToBase64(bytes) {
11
+ let binary = "";
12
+ for (const byte of bytes)
13
+ binary += String.fromCharCode(byte);
14
+ return btoa(binary);
15
+ }
16
+ /** Bytes → base64url (no padding): the form of a share secret in a URL fragment. */
17
+ export function bytesToBase64Url(bytes) {
18
+ return bytesToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
19
+ }
20
+ /** base64 or base64url → bytes. Throws a `TypeError` on malformed input. */
21
+ export function base64ToBytes(value) {
22
+ const normalised = value.replace(/-/g, "+").replace(/_/g, "/");
23
+ const padded = normalised + "=".repeat((4 - (normalised.length % 4)) % 4);
24
+ let binary;
25
+ try {
26
+ binary = atob(padded);
27
+ }
28
+ catch {
29
+ throw new TypeError("not base64");
30
+ }
31
+ const bytes = new Uint8Array(binary.length);
32
+ for (let i = 0; i < binary.length; i++)
33
+ bytes[i] = binary.charCodeAt(i);
34
+ return bytes;
35
+ }
36
+ /** `n` random bytes from the platform's CSPRNG. */
37
+ export function randomBytes(n) {
38
+ return crypto.getRandomValues(new Uint8Array(n));
39
+ }
40
+ /** A random hex string (a multipart boundary, a fingerprint salt). */
41
+ export function randomHex(bytes = 16) {
42
+ return Array.from(randomBytes(bytes), (b) => b.toString(16).padStart(2, "0")).join("");
43
+ }
44
+ /** `encodeURIComponent` of every segment of `a/b/c`, keeping the slashes; leading and trailing slashes dropped. */
45
+ export function encodePath(path) {
46
+ return path
47
+ .split("/")
48
+ .filter((segment) => segment !== "")
49
+ .map((segment) => encodeURIComponent(segment))
50
+ .join("/");
51
+ }
52
+ //# sourceMappingURL=env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"env.js","sourceRoot":"","sources":["../src/env.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,kGAAkG;AAClG,MAAM,UAAU,SAAS;IACvB,OAAO,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,MAAM,CAAC,QAAQ,KAAK,WAAW,CAAC;AACjF,CAAC;AAED,kDAAkD;AAClD,MAAM,UAAU,aAAa,CAAC,KAAiB;IAC7C,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,MAAM,IAAI,IAAI,KAAK;QAAE,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IAC9D,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC;AACtB,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,gBAAgB,CAAC,KAAiB;IAChD,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACzF,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,aAAa,CAAC,KAAa;IACzC,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC/D,MAAM,MAAM,GAAG,UAAU,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1E,IAAI,MAAc,CAAC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itself (before any request went out). */
3
+ status: number;
4
+ /** The server's snake_case code (`file_not_found`, `vola_locked`, …) or an SDK code (`invalid_response`). */
5
+ code: string;
6
+ message: string;
7
+ /** Seconds to wait before trying again (`Retry-After`, or `retry_after` of the body), when the server said so. */
8
+ retryAfter?: number | undefined;
9
+ /** Everything else the error envelope carried (`required` scopes, `attempts`, `reason`, …). */
10
+ details?: Record<string, unknown> | undefined;
11
+ /** `X-Request-Id` of the answer, for a support ticket. */
12
+ requestId?: string | null | undefined;
13
+ }
14
+ /**
15
+ * A non-2xx answer of the server, carrying its `{ error: { code, message, … } }` envelope —
16
+ * or an error the SDK raised itself (`status: 0`). Never a secret: no key, token, PIN or
17
+ * share secret is ever part of the message or the details.
18
+ */
19
+ export declare class VolaError extends Error {
20
+ readonly status: number;
21
+ readonly code: string;
22
+ readonly retryAfter: number | undefined;
23
+ readonly details: Record<string, unknown>;
24
+ readonly requestId: string | null;
25
+ constructor(init: VolaErrorInit);
26
+ }
27
+ /** `423 vola_locked`: the request needs an unlock token (keyring) or a content key (caller) it did not carry, or the one it carried is dead. */
28
+ export declare class VolaLockedError extends VolaError {
29
+ constructor(init: VolaErrorInit);
30
+ }
31
+ /** `409 vola_integrity`: the file (or a share grant) could not be decrypted — a wrong key, a wrong secret, or damaged bytes. */
32
+ export declare class VolaIntegrityError extends VolaError {
33
+ constructor(init: VolaErrorInit);
34
+ }
35
+ /** @deprecated The name of the health-only client's error; `VolaError` is the same class. */
36
+ export declare const VolaApiError: typeof VolaError;
37
+ /**
38
+ * The `VolaError` of a non-2xx `response`: the envelope when the body is one, `unknown_error`
39
+ * with `HTTP <status>` otherwise. `423` is a `VolaLockedError`, `409 vola_integrity` a
40
+ * `VolaIntegrityError`. Consumes the body.
41
+ */
42
+ export declare function errorFromResponse(response: Response): Promise<VolaError>;
43
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,gGAAgG;IAChG,MAAM,EAAE,MAAM,CAAC;IACf,6GAA6G;IAC7G,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,kHAAkH;IAClH,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,+FAA+F;IAC/F,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IAC9C,0DAA0D;IAC1D,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;CACvC;AAED;;;;GAIG;AACH,qBAAa,SAAU,SAAQ,KAAK;IAClC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;gBAEtB,IAAI,EAAE,aAAa;CAShC;AAED,gJAAgJ;AAChJ,qBAAa,eAAgB,SAAQ,SAAS;gBAChC,IAAI,EAAE,aAAa;CAIhC;AAED,gIAAgI;AAChI,qBAAa,kBAAmB,SAAQ,SAAS;gBACnC,IAAI,EAAE,aAAa;CAIhC;AAED,6FAA6F;AAC7F,eAAO,MAAM,YAAY,kBAAY,CAAC;AAYtC;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,CAuC9E"}
package/dist/errors.js ADDED
@@ -0,0 +1,93 @@
1
+ import { ErrorResponseSchema, INTEGRITY_ERROR_CODE, REQUEST_ID_HEADER } from "@vol-a/core";
2
+ /**
3
+ * A non-2xx answer of the server, carrying its `{ error: { code, message, … } }` envelope —
4
+ * or an error the SDK raised itself (`status: 0`). Never a secret: no key, token, PIN or
5
+ * share secret is ever part of the message or the details.
6
+ */
7
+ export class VolaError extends Error {
8
+ status;
9
+ code;
10
+ retryAfter;
11
+ details;
12
+ requestId;
13
+ constructor(init) {
14
+ super(init.message);
15
+ this.name = "VolaError";
16
+ this.status = init.status;
17
+ this.code = init.code;
18
+ this.retryAfter = init.retryAfter;
19
+ this.details = init.details ?? {};
20
+ this.requestId = init.requestId ?? null;
21
+ }
22
+ }
23
+ /** `423 vola_locked`: the request needs an unlock token (keyring) or a content key (caller) it did not carry, or the one it carried is dead. */
24
+ export class VolaLockedError extends VolaError {
25
+ constructor(init) {
26
+ super(init);
27
+ this.name = "VolaLockedError";
28
+ }
29
+ }
30
+ /** `409 vola_integrity`: the file (or a share grant) could not be decrypted — a wrong key, a wrong secret, or damaged bytes. */
31
+ export class VolaIntegrityError extends VolaError {
32
+ constructor(init) {
33
+ super(init);
34
+ this.name = "VolaIntegrityError";
35
+ }
36
+ }
37
+ /** @deprecated The name of the health-only client's error; `VolaError` is the same class. */
38
+ export const VolaApiError = VolaError;
39
+ const INTEGER_RE = /^\d{1,9}$/;
40
+ /** `Retry-After` in seconds (the delta form only; an HTTP date is ignored). */
41
+ function retryAfterOf(response, details) {
42
+ const header = response.headers.get("retry-after")?.trim();
43
+ if (header && INTEGER_RE.test(header))
44
+ return Number(header);
45
+ const body = details.retry_after;
46
+ return typeof body === "number" && Number.isFinite(body) ? body : undefined;
47
+ }
48
+ /**
49
+ * The `VolaError` of a non-2xx `response`: the envelope when the body is one, `unknown_error`
50
+ * with `HTTP <status>` otherwise. `423` is a `VolaLockedError`, `409 vola_integrity` a
51
+ * `VolaIntegrityError`. Consumes the body.
52
+ */
53
+ export async function errorFromResponse(response) {
54
+ const text = await response.text().catch(() => "");
55
+ let body;
56
+ try {
57
+ body = text === "" ? undefined : JSON.parse(text);
58
+ }
59
+ catch {
60
+ body = undefined;
61
+ }
62
+ const parsed = ErrorResponseSchema.safeParse(body);
63
+ const raw = typeof body === "object" && body !== null && "error" in body
64
+ ? body.error
65
+ : undefined;
66
+ const details = typeof raw === "object" && raw !== null ? { ...raw } : {};
67
+ delete details.code;
68
+ delete details.message;
69
+ const init = parsed.success
70
+ ? {
71
+ status: response.status,
72
+ code: parsed.data.error.code,
73
+ message: parsed.data.error.message,
74
+ details,
75
+ retryAfter: retryAfterOf(response, details),
76
+ requestId: response.headers.get(REQUEST_ID_HEADER),
77
+ }
78
+ : {
79
+ status: response.status,
80
+ code: "unknown_error",
81
+ message: `HTTP ${response.status}`,
82
+ details,
83
+ retryAfter: retryAfterOf(response, details),
84
+ requestId: response.headers.get(REQUEST_ID_HEADER),
85
+ };
86
+ if (response.status === 423)
87
+ return new VolaLockedError(init);
88
+ if (response.status === 409 && init.code === INTEGRITY_ERROR_CODE) {
89
+ return new VolaIntegrityError(init);
90
+ }
91
+ return new VolaError(init);
92
+ }
93
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAgB3F;;;;GAIG;AACH,MAAM,OAAO,SAAU,SAAQ,KAAK;IACzB,MAAM,CAAS;IACf,IAAI,CAAS;IACb,UAAU,CAAqB;IAC/B,OAAO,CAA0B;IACjC,SAAS,CAAgB;IAElC,YAAY,IAAmB;QAC7B,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,EAAE,CA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AAiB,CAAC;SACnD,CAAC;IACN,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG;QAAE,OAAO,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC;IAC9D,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,IAAI,KAAK,oBAAoB,EAAE,CAAC;QAClE,OAAO,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,144 @@
1
+ import { type FileDetail, type FileEncryption, type FileInfo, type FileList, type FileMetadata, type FilePatch, type FileVersions, type PurgeResult, type ThumbnailCrop, type ThumbnailSize } from "@vol-a/core";
2
+ import { type UploadSource } from "./body.js";
3
+ import type { CallOptions, VolaClient } from "./client.js";
4
+ /** A `Range`: `{start, end?}` (inclusive, as HTTP), `{suffix}` (the last N bytes), or the header value itself. */
5
+ export type ByteRange = {
6
+ start: number;
7
+ end?: number | undefined;
8
+ } | {
9
+ suffix: number;
10
+ } | string;
11
+ export declare function rangeHeader(range: ByteRange): string;
12
+ /** Where an upload lands and what it is. */
13
+ export interface UploadPlacement {
14
+ /** Required unless the source is a `File` (its `name` is used). */
15
+ filename?: string | undefined;
16
+ /** The MIME type of the bytes; default: the `Blob`'s type, else `application/octet-stream` (the server sniffs anyway). */
17
+ contentType?: string | undefined;
18
+ /** The folder (`a/b/c`, created when missing; `""` the root). Excludes `folderId`. */
19
+ folderPath?: string | undefined;
20
+ /** An existing folder by id (`null`: the root). */
21
+ folderId?: string | null | undefined;
22
+ /** The previous version this upload supersedes. */
23
+ parentId?: string | undefined;
24
+ /** Free JSON attached to the file. */
25
+ metadata?: FileMetadata | undefined;
26
+ /** `none` | `tenant` | `keyring` (needs an unlock token) | `caller` (needs `contentKey`, Node only). Default: the folder's policy, else the tenant's default. */
27
+ encryption?: FileEncryption | undefined;
28
+ }
29
+ export interface UploadOptions extends UploadPlacement, CallOptions {
30
+ /** Upsert the file under this slug (`PUT …/slug/:slug`): at most one live file per slug. */
31
+ slug?: string | undefined;
32
+ }
33
+ export interface DownloadOptions extends CallOptions {
34
+ range?: ByteRange | undefined;
35
+ /** `?download=1`: `Content-Disposition: attachment` whatever the type. */
36
+ download?: boolean | undefined;
37
+ /** `If-None-Match`: a `304` resolves (with an empty body). */
38
+ ifNoneMatch?: string | undefined;
39
+ }
40
+ export interface InfoOptions extends CallOptions {
41
+ /** See a soft-deleted file too. */
42
+ includeDeleted?: boolean | undefined;
43
+ /** `"full"`: the whole OCR text under `ocr.text` (the 500-character preview is always there). */
44
+ ocr?: "full" | undefined;
45
+ }
46
+ export interface ListOptions extends CallOptions {
47
+ cursor?: string | null | undefined;
48
+ /** Page size, at most 200. */
49
+ limit?: number | undefined;
50
+ includeDeleted?: boolean | undefined;
51
+ }
52
+ export interface VersionsOptions extends CallOptions {
53
+ includeDeleted?: boolean | undefined;
54
+ }
55
+ export interface ThumbnailOptions extends CallOptions {
56
+ crop?: ThumbnailCrop | undefined;
57
+ ifNoneMatch?: string | undefined;
58
+ }
59
+ /**
60
+ * What `thumb()` resolves with. A `202` of the server is NOT the image: it is a grey placeholder
61
+ * while the worker renders — `generating` tells the caller to retry (and never to cache).
62
+ */
63
+ export type ThumbnailResult = {
64
+ status: "ready";
65
+ blob: Blob;
66
+ etag: string | null;
67
+ response: Response;
68
+ } | {
69
+ status: "not_modified";
70
+ etag: string | null;
71
+ response: Response;
72
+ } | {
73
+ status: "generating";
74
+ response: Response;
75
+ } | {
76
+ status: "failed";
77
+ response: Response;
78
+ };
79
+ /** `/files/:type/:id`. */
80
+ export declare function instancePath(type: string, id: string): string;
81
+ /** `/files/:type/:id/:fileId`. */
82
+ export declare function filePath(type: string, id: string, fileId: string): string;
83
+ /** The files of an instance: upload, download, metadata, versions, visibility, delete. */
84
+ export declare class FilesApi {
85
+ private readonly client;
86
+ constructor(client: VolaClient);
87
+ /**
88
+ * `POST /files/:type/:id` (multipart) — or `PUT …/slug/:slug` with `slug`. The source is a
89
+ * `File`/`Blob`, a `Uint8Array`/`Buffer`, an `ArrayBuffer`, a web `ReadableStream` or any
90
+ * async iterable of bytes (a Node `Readable`): streams are sent without being buffered.
91
+ * Resolves with the stored file (`201`).
92
+ */
93
+ upload(type: string, id: string, source: UploadSource, options?: UploadOptions): Promise<FileInfo>;
94
+ /** `PUT /files/:type/:id/slug/:slug`: `upload()` as an upsert under `slug`. */
95
+ putSlug(type: string, id: string, slug: string, source: UploadSource, options?: Omit<UploadOptions, "slug">): Promise<FileInfo>;
96
+ private fetchFile;
97
+ /**
98
+ * `GET /files/:type/:id/:fileId`: the bytes as a streaming `Response` (`200`, or `206` for a
99
+ * `range`, `304` for a matching `ifNoneMatch`) — read `response.body`, `.blob()`,
100
+ * `.arrayBuffer()` as needed. Headers: `ETag`, `Content-Disposition`, `Content-Range`,
101
+ * `X-Vola-Encryption` for an encrypted file.
102
+ */
103
+ download(type: string, id: string, fileId: string, options?: DownloadOptions): Promise<Response>;
104
+ /** `HEAD /files/:type/:id/:fileId`: the headers of a download without the body. */
105
+ head(type: string, id: string, fileId: string, options?: DownloadOptions): Promise<Response>;
106
+ /** `GET /files/:type/:id/path/*`: the newest live file of that name in that folder (`docs/q4/report.pdf`). */
107
+ byPath(type: string, id: string, path: string, options?: DownloadOptions): Promise<Response>;
108
+ /** `GET /files/:type/:id/slug/:slug`: the live file under `slug`. */
109
+ bySlug(type: string, id: string, slug: string, options?: DownloadOptions): Promise<Response>;
110
+ /** `GET /public/:fileId`: an `is_global_public` file, no key needed. */
111
+ public(fileId: string, options?: Omit<DownloadOptions, "unlock" | "contentKey">): Promise<Response>;
112
+ /** The URL of a download — WITHOUT credentials: for a `<a href>` behind a proxy or cookie auth, or for `fetch` with `client.headers()`. */
113
+ downloadUrl(type: string, id: string, fileId: string, options?: {
114
+ download?: boolean | undefined;
115
+ }): string;
116
+ /** The URL of `GET /public/:fileId` (anonymous: usable as an `<img src>` for an `is_global_public` file). */
117
+ publicUrl(fileId: string): string;
118
+ /** `GET …/:fileId/info`: the metadata (never the bytes) with the aggregate processing status and the `ocr` block. */
119
+ info(type: string, id: string, fileId: string, options?: InfoOptions): Promise<FileDetail>;
120
+ /** `GET /files/:type/:id`: the instance's files, newest first, one page (`next_cursor` feeds `cursor`). */
121
+ list(type: string, id: string, options?: ListOptions): Promise<FileList>;
122
+ /** Every file of the instance, page after page. */
123
+ iterate(type: string, id: string, options?: ListOptions): AsyncGenerator<FileInfo>;
124
+ /** `GET …/:fileId/versions`: the whole version chain, newest first. */
125
+ versions(type: string, id: string, fileId: string, options?: VersionsOptions): Promise<FileVersions>;
126
+ /** `PATCH …/:fileId`: move (`folder_path`), rename (`filename`), visibility (`is_public`, `is_global_public`). */
127
+ patch(type: string, id: string, fileId: string, patch: FilePatch, options?: CallOptions): Promise<FileInfo>;
128
+ /** `DELETE …/:fileId`: soft delete (the bytes stay; `purge` removes them). Idempotent. */
129
+ delete(type: string, id: string, fileId: string, options?: CallOptions): Promise<FileInfo>;
130
+ /** `DELETE …/:fileId/purge`: the row, its version chain, and every blob nothing references any more. */
131
+ purge(type: string, id: string, fileId: string, options?: CallOptions): Promise<PurgeResult>;
132
+ /** `…/:fileId/thumb/:size[?crop=]` as a URL — WITHOUT credentials (see `downloadUrl`). */
133
+ thumbUrl(type: string, id: string, fileId: string, size: ThumbnailSize, options?: {
134
+ crop?: ThumbnailCrop | undefined;
135
+ }): string;
136
+ /**
137
+ * `GET …/:fileId/thumb/:size?crop=`: `{status: "ready", blob}` for the WebP, `{status:
138
+ * "generating"}` while the worker renders it (a `202` — retry later, never cache),
139
+ * `{status: "failed"}` when the file could not be rendered. `404 no_thumbnail` throws: the
140
+ * file has none by its nature.
141
+ */
142
+ thumb(type: string, id: string, fileId: string, size: ThumbnailSize, options?: ThumbnailOptions): Promise<ThumbnailResult>;
143
+ }
144
+ //# sourceMappingURL=files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.d.ts","s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