@lunora/client 1.0.0-alpha.26 → 1.0.0-alpha.28

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.
@@ -0,0 +1,35 @@
1
+ import { UploadControl, HeadersResolver, UploadRestrictions, ChunkedRestAdapter, MultipartAdapter, TusAdapter } from '@visulima/storage-client';
2
+ export { type ChunkedRestAdapter, type ChunkedRestAdapterOptions, type FingerprintFunction, type HeadersResolver, LocalStorageUrlStorage, MemoryUrlStorage, type MultipartAdapter, type MultipartAdapterOptions, type OnBeforeRequest, type RequestOptions, RestrictionError, type TusAdapter, type TusAdapterOptions, type UploadControl, UploadError, type UploadMethod, type UploadRestrictions, type UploadResult, type Uploader, type UrlStorage, createChunkedRestAdapter, createMultipartAdapter, createTusAdapter, putFile, validateFile, validateFiles } from '@visulima/storage-client';
3
+ /** Resumable upload wire protocols {@link createUpload} can drive. */
4
+ type UploadProtocol = "chunked-rest" | "multipart" | "tus";
5
+ /** The adapter shape {@link createUpload} returns — a `.upload(file)` driver plus lifecycle callbacks. */
6
+ type UploadAdapter = ChunkedRestAdapter | MultipartAdapter | TusAdapter;
7
+ /** Options for {@link createUpload}. */
8
+ interface CreateUploadOptions {
9
+ /** Chunk size in bytes (TUS / chunked-REST only). */
10
+ chunkSize?: number;
11
+ /** A shared {@link UploadControl} for pause/resume/cancel (TUS / chunked-REST). */
12
+ control?: UploadControl;
13
+ /** The upload endpoint — a route backed by `@lunora/storage/upload`'s handler. */
14
+ endpoint: string;
15
+ /** Static or dynamically-resolved request headers (e.g. an `Authorization` token). */
16
+ headers?: HeadersResolver;
17
+ /** Maximum retry attempts (TUS / chunked-REST, when `retry` is on). */
18
+ maxRetries?: number;
19
+ /** Extra metadata sent with the upload. */
20
+ metadata?: Record<string, string>;
21
+ /** Which protocol to speak. Default `"tus"` (resumable, pause/resume-capable). */
22
+ protocol?: UploadProtocol;
23
+ /** Client-side size/type restrictions, validated before any network request. */
24
+ restrictions?: UploadRestrictions;
25
+ /** Enable automatic retry on failure (TUS / chunked-REST). */
26
+ retry?: boolean;
27
+ }
28
+ /**
29
+ * Create a protocol-appropriate upload adapter against an RLS-gated endpoint.
30
+ * Defaults to TUS — the resumable path that survives pause/resume and a dropped
31
+ * connection. Call `.upload(file)` to start; use the shared {@link UploadControl}
32
+ * (or the adapter's `pause`/`resume`/`abort`) to steer it.
33
+ */
34
+ declare const createUpload: (options: CreateUploadOptions) => UploadAdapter;
35
+ export { CreateUploadOptions, UploadAdapter, UploadProtocol, createUpload };
@@ -0,0 +1,35 @@
1
+ import { UploadControl, HeadersResolver, UploadRestrictions, ChunkedRestAdapter, MultipartAdapter, TusAdapter } from '@visulima/storage-client';
2
+ export { type ChunkedRestAdapter, type ChunkedRestAdapterOptions, type FingerprintFunction, type HeadersResolver, LocalStorageUrlStorage, MemoryUrlStorage, type MultipartAdapter, type MultipartAdapterOptions, type OnBeforeRequest, type RequestOptions, RestrictionError, type TusAdapter, type TusAdapterOptions, type UploadControl, UploadError, type UploadMethod, type UploadRestrictions, type UploadResult, type Uploader, type UrlStorage, createChunkedRestAdapter, createMultipartAdapter, createTusAdapter, putFile, validateFile, validateFiles } from '@visulima/storage-client';
3
+ /** Resumable upload wire protocols {@link createUpload} can drive. */
4
+ type UploadProtocol = "chunked-rest" | "multipart" | "tus";
5
+ /** The adapter shape {@link createUpload} returns — a `.upload(file)` driver plus lifecycle callbacks. */
6
+ type UploadAdapter = ChunkedRestAdapter | MultipartAdapter | TusAdapter;
7
+ /** Options for {@link createUpload}. */
8
+ interface CreateUploadOptions {
9
+ /** Chunk size in bytes (TUS / chunked-REST only). */
10
+ chunkSize?: number;
11
+ /** A shared {@link UploadControl} for pause/resume/cancel (TUS / chunked-REST). */
12
+ control?: UploadControl;
13
+ /** The upload endpoint — a route backed by `@lunora/storage/upload`'s handler. */
14
+ endpoint: string;
15
+ /** Static or dynamically-resolved request headers (e.g. an `Authorization` token). */
16
+ headers?: HeadersResolver;
17
+ /** Maximum retry attempts (TUS / chunked-REST, when `retry` is on). */
18
+ maxRetries?: number;
19
+ /** Extra metadata sent with the upload. */
20
+ metadata?: Record<string, string>;
21
+ /** Which protocol to speak. Default `"tus"` (resumable, pause/resume-capable). */
22
+ protocol?: UploadProtocol;
23
+ /** Client-side size/type restrictions, validated before any network request. */
24
+ restrictions?: UploadRestrictions;
25
+ /** Enable automatic retry on failure (TUS / chunked-REST). */
26
+ retry?: boolean;
27
+ }
28
+ /**
29
+ * Create a protocol-appropriate upload adapter against an RLS-gated endpoint.
30
+ * Defaults to TUS — the resumable path that survives pause/resume and a dropped
31
+ * connection. Call `.upload(file)` to start; use the shared {@link UploadControl}
32
+ * (or the adapter's `pause`/`resume`/`abort`) to steer it.
33
+ */
34
+ declare const createUpload: (options: CreateUploadOptions) => UploadAdapter;
35
+ export { CreateUploadOptions, UploadAdapter, UploadProtocol, createUpload };
@@ -0,0 +1,24 @@
1
+ import { createMultipartAdapter, createChunkedRestAdapter, createTusAdapter } from '@visulima/storage-client';
2
+ export { LocalStorageUrlStorage, MemoryUrlStorage, RestrictionError, UploadControl, UploadError, createChunkedRestAdapter, createMultipartAdapter, createTusAdapter, putFile, validateFile, validateFiles } from '@visulima/storage-client';
3
+
4
+ const createUpload = (options) => {
5
+ const protocol = options.protocol ?? "tus";
6
+ const { chunkSize, control, endpoint, headers, maxRetries, metadata, restrictions, retry } = options;
7
+ if (protocol === "multipart") {
8
+ const multipartOptions = { endpoint, headers, maxRetries, metadata, restrictions, retry };
9
+ return createMultipartAdapter(multipartOptions);
10
+ }
11
+ const resumableOptions = {
12
+ chunkSize,
13
+ control,
14
+ endpoint,
15
+ headers,
16
+ maxRetries,
17
+ metadata,
18
+ restrictions,
19
+ retry
20
+ };
21
+ return protocol === "chunked-rest" ? createChunkedRestAdapter(resumableOptions) : createTusAdapter(resumableOptions);
22
+ };
23
+
24
+ export { createUpload };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/client",
3
- "version": "1.0.0-alpha.26",
3
+ "version": "1.0.0-alpha.28",
4
4
  "description": "Lunora browser SDK: WebSocket transport, optimistic updates, and an offline mutation queue",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -56,13 +56,18 @@
56
56
  "types": "./dist/ssr/index.d.ts",
57
57
  "import": "./dist/ssr/index.mjs"
58
58
  },
59
+ "./upload": {
60
+ "types": "./dist/upload.d.ts",
61
+ "import": "./dist/upload.mjs"
62
+ },
59
63
  "./package.json": "./package.json"
60
64
  },
61
65
  "publishConfig": {
62
66
  "access": "public"
63
67
  },
64
68
  "dependencies": {
65
- "@lunora/errors": "1.0.0-alpha.6"
69
+ "@lunora/errors": "1.0.0-alpha.8",
70
+ "@visulima/storage-client": "1.0.0"
66
71
  },
67
72
  "engines": {
68
73
  "node": "^22.15.0 || >=24.11.0"