@org-quicko/silo-client 1.0.1 → 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.
- package/README.md +49 -1
- package/dist/cache/cache-mode.d.cts +2 -0
- package/dist/cache/cache-mode.d.ts +2 -0
- package/dist/cache/response-cache.d.cts +16 -0
- package/dist/cache/response-cache.d.ts +16 -0
- package/dist/cache/silo-cache-options.d.cts +7 -0
- package/dist/cache/silo-cache-options.d.ts +7 -0
- package/dist/cache/silo-cache.d.cts +11 -0
- package/dist/cache/silo-cache.d.ts +11 -0
- package/dist/errors/network-error.d.cts +5 -0
- package/dist/errors/network-error.d.ts +5 -0
- package/dist/index.cjs +264 -74
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +264 -74
- package/dist/media/media-asset.d.cts +17 -0
- package/dist/media/media-asset.d.ts +17 -0
- package/dist/media/media-file.d.cts +16 -0
- package/dist/media/media-file.d.ts +16 -0
- package/dist/media/media-page.d.cts +1 -0
- package/dist/media/media-page.d.ts +1 -0
- package/dist/media/media-replace.d.cts +17 -0
- package/dist/media/media-replace.d.ts +17 -0
- package/dist/media/media-usage-page.d.cts +1 -0
- package/dist/media/media-usage-page.d.ts +1 -0
- package/dist/media/media.d.cts +0 -4
- package/dist/media/media.d.ts +0 -4
- package/dist/request-options.d.cts +3 -0
- package/dist/request-options.d.ts +3 -0
- package/dist/silo-options.d.cts +4 -0
- package/dist/silo-options.d.ts +4 -0
- package/dist/silo.d.cts +3 -0
- package/dist/silo.d.ts +3 -0
- package/dist/transport/api-path.d.cts +1 -0
- package/dist/transport/api-path.d.ts +1 -0
- package/dist/transport/caching-transport.d.cts +14 -0
- package/dist/transport/caching-transport.d.ts +14 -0
- package/dist/transport/fetch-transport.d.cts +31 -0
- package/dist/transport/fetch-transport.d.ts +31 -0
- package/dist/transport/prepared-transport-request.d.cts +6 -0
- package/dist/transport/prepared-transport-request.d.ts +6 -0
- package/dist/transport/transport-request.d.cts +2 -0
- package/dist/transport/transport-request.d.ts +2 -0
- package/dist/transport/transport.d.cts +2 -39
- package/dist/transport/transport.d.ts +2 -39
- package/package.json +6 -3
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { RequestOptions } from "../request-options.cjs";
|
|
2
|
+
/** The fully-described replacement: raw bytes plus the name whose extension
|
|
3
|
+
* the server checks against the one the asset already has. No `folder` — a
|
|
4
|
+
* replace changes bytes and nothing else about where the asset sits. */
|
|
5
|
+
export interface MediaReplaceBytes {
|
|
6
|
+
bytes: Uint8Array | ArrayBuffer | Blob;
|
|
7
|
+
filename: string;
|
|
8
|
+
contentType?: string;
|
|
9
|
+
}
|
|
10
|
+
/** The filename to read when the input carries none — a `File` has `.name`,
|
|
11
|
+
* a bare `Blob` does not, and the extension is what the server checks. */
|
|
12
|
+
export interface MediaReplaceOptions extends RequestOptions {
|
|
13
|
+
filename?: string;
|
|
14
|
+
}
|
|
15
|
+
/** `MediaAsset.replace()`'s input: a fully-described replacement, or a
|
|
16
|
+
* runtime `File`/`Blob`. */
|
|
17
|
+
export type MediaReplace = MediaReplaceBytes | File | Blob;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { RequestOptions } from "../request-options.js";
|
|
2
|
+
/** The fully-described replacement: raw bytes plus the name whose extension
|
|
3
|
+
* the server checks against the one the asset already has. No `folder` — a
|
|
4
|
+
* replace changes bytes and nothing else about where the asset sits. */
|
|
5
|
+
export interface MediaReplaceBytes {
|
|
6
|
+
bytes: Uint8Array | ArrayBuffer | Blob;
|
|
7
|
+
filename: string;
|
|
8
|
+
contentType?: string;
|
|
9
|
+
}
|
|
10
|
+
/** The filename to read when the input carries none — a `File` has `.name`,
|
|
11
|
+
* a bare `Blob` does not, and the extension is what the server checks. */
|
|
12
|
+
export interface MediaReplaceOptions extends RequestOptions {
|
|
13
|
+
filename?: string;
|
|
14
|
+
}
|
|
15
|
+
/** `MediaAsset.replace()`'s input: a fully-described replacement, or a
|
|
16
|
+
* runtime `File`/`Blob`. */
|
|
17
|
+
export type MediaReplace = MediaReplaceBytes | File | Blob;
|
|
@@ -20,6 +20,7 @@ export interface MediaUsageQuery {
|
|
|
20
20
|
export declare class MediaUsagePage extends Page<MediaUsage> {
|
|
21
21
|
private readonly transport;
|
|
22
22
|
private readonly assetId;
|
|
23
|
+
private readonly requestOptions;
|
|
23
24
|
readonly visible: number;
|
|
24
25
|
readonly visibleCapped: boolean;
|
|
25
26
|
private constructor();
|
|
@@ -20,6 +20,7 @@ export interface MediaUsageQuery {
|
|
|
20
20
|
export declare class MediaUsagePage extends Page<MediaUsage> {
|
|
21
21
|
private readonly transport;
|
|
22
22
|
private readonly assetId;
|
|
23
|
+
private readonly requestOptions;
|
|
23
24
|
readonly visible: number;
|
|
24
25
|
readonly visibleCapped: boolean;
|
|
25
26
|
private constructor();
|
package/dist/media/media.d.cts
CHANGED
|
@@ -30,8 +30,4 @@ export declare class Media {
|
|
|
30
30
|
* per-id outcomes live in the report, not in a thrown error. */
|
|
31
31
|
deleteMany(ids: readonly string[], options?: MediaDeleteOptions): Promise<MediaDeleteReport>;
|
|
32
32
|
private static toWireQuery;
|
|
33
|
-
private static toBlob;
|
|
34
|
-
/** A `File` carries its own name; a bare `Blob` does not, and uploading it
|
|
35
|
-
* as "blob" is worse than refusing outright. */
|
|
36
|
-
private static filenameOf;
|
|
37
33
|
}
|
package/dist/media/media.d.ts
CHANGED
|
@@ -30,8 +30,4 @@ export declare class Media {
|
|
|
30
30
|
* per-id outcomes live in the report, not in a thrown error. */
|
|
31
31
|
deleteMany(ids: readonly string[], options?: MediaDeleteOptions): Promise<MediaDeleteReport>;
|
|
32
32
|
private static toWireQuery;
|
|
33
|
-
private static toBlob;
|
|
34
|
-
/** A `File` carries its own name; a bare `Blob` does not, and uploading it
|
|
35
|
-
* as "blob" is worse than refusing outright. */
|
|
36
|
-
private static filenameOf;
|
|
37
33
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CacheMode } from "./cache/cache-mode.cjs";
|
|
1
2
|
/**
|
|
2
3
|
* The one cancellation convention on every call: the last parameter of
|
|
3
4
|
* every method in the client. A per-call value wins over the client's own
|
|
@@ -6,4 +7,6 @@
|
|
|
6
7
|
export interface RequestOptions {
|
|
7
8
|
signal?: AbortSignal;
|
|
8
9
|
timeoutMilliseconds?: number;
|
|
10
|
+
/** `bypass` skips lookup and storage; `refresh` fetches and stores. Ignored on writes and disabled caches. */
|
|
11
|
+
cache?: CacheMode;
|
|
9
12
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CacheMode } from "./cache/cache-mode.js";
|
|
1
2
|
/**
|
|
2
3
|
* The one cancellation convention on every call: the last parameter of
|
|
3
4
|
* every method in the client. A per-call value wins over the client's own
|
|
@@ -6,4 +7,6 @@
|
|
|
6
7
|
export interface RequestOptions {
|
|
7
8
|
signal?: AbortSignal;
|
|
8
9
|
timeoutMilliseconds?: number;
|
|
10
|
+
/** `bypass` skips lookup and storage; `refresh` fetches and stores. Ignored on writes and disabled caches. */
|
|
11
|
+
cache?: CacheMode;
|
|
9
12
|
}
|
package/dist/silo-options.d.cts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { FetchFunction } from "./transport/fetch-function.cjs";
|
|
2
|
+
import type { SiloCache } from "./cache/silo-cache.cjs";
|
|
3
|
+
import type { SiloCacheOptions } from "./cache/silo-cache-options.cjs";
|
|
2
4
|
/**
|
|
3
5
|
* Everything `new Silo(...)` accepts. Only `url` is required: a key is
|
|
4
6
|
* optional because anonymous reads are legal.
|
|
@@ -9,4 +11,6 @@ export interface SiloOptions {
|
|
|
9
11
|
timeoutMilliseconds?: number;
|
|
10
12
|
headers?: Record<string, string>;
|
|
11
13
|
fetch?: FetchFunction;
|
|
14
|
+
/** Enable read caching or share an existing cache. Omit to disable. */
|
|
15
|
+
cache?: SiloCacheOptions | SiloCache;
|
|
12
16
|
}
|
package/dist/silo-options.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { FetchFunction } from "./transport/fetch-function.js";
|
|
2
|
+
import type { SiloCache } from "./cache/silo-cache.js";
|
|
3
|
+
import type { SiloCacheOptions } from "./cache/silo-cache-options.js";
|
|
2
4
|
/**
|
|
3
5
|
* Everything `new Silo(...)` accepts. Only `url` is required: a key is
|
|
4
6
|
* optional because anonymous reads are legal.
|
|
@@ -9,4 +11,6 @@ export interface SiloOptions {
|
|
|
9
11
|
timeoutMilliseconds?: number;
|
|
10
12
|
headers?: Record<string, string>;
|
|
11
13
|
fetch?: FetchFunction;
|
|
14
|
+
/** Enable read caching or share an existing cache. Omit to disable. */
|
|
15
|
+
cache?: SiloCacheOptions | SiloCache;
|
|
12
16
|
}
|
package/dist/silo.d.cts
CHANGED
|
@@ -7,6 +7,7 @@ import type { EnvironmentHandle } from "./scope/environment-handle.cjs";
|
|
|
7
7
|
import type { SearchPage } from "./search/search-page.cjs";
|
|
8
8
|
import type { SearchQuery } from "./search/search-query.cjs";
|
|
9
9
|
import type { SiloOptions } from "./silo-options.cjs";
|
|
10
|
+
import { SiloCache } from "./cache/silo-cache.cjs";
|
|
10
11
|
/**
|
|
11
12
|
* One silo instance. Navigate it the way the API is shaped:
|
|
12
13
|
* `silo.project("acme").environment("prod").collection<Post>("posts")`.
|
|
@@ -20,6 +21,8 @@ export declare class Silo {
|
|
|
20
21
|
readonly projects: Projects;
|
|
21
22
|
/** The media catalog. Media is instance-global, so it takes no scope. */
|
|
22
23
|
readonly media: Media;
|
|
24
|
+
/** This instance's optional read cache. */
|
|
25
|
+
readonly cache: SiloCache;
|
|
23
26
|
private readonly options;
|
|
24
27
|
private readonly transport;
|
|
25
28
|
constructor(options: SiloOptions);
|
package/dist/silo.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type { EnvironmentHandle } from "./scope/environment-handle.js";
|
|
|
7
7
|
import type { SearchPage } from "./search/search-page.js";
|
|
8
8
|
import type { SearchQuery } from "./search/search-query.js";
|
|
9
9
|
import type { SiloOptions } from "./silo-options.js";
|
|
10
|
+
import { SiloCache } from "./cache/silo-cache.js";
|
|
10
11
|
/**
|
|
11
12
|
* One silo instance. Navigate it the way the API is shaped:
|
|
12
13
|
* `silo.project("acme").environment("prod").collection<Post>("posts")`.
|
|
@@ -20,6 +21,8 @@ export declare class Silo {
|
|
|
20
21
|
readonly projects: Projects;
|
|
21
22
|
/** The media catalog. Media is instance-global, so it takes no scope. */
|
|
22
23
|
readonly media: Media;
|
|
24
|
+
/** This instance's optional read cache. */
|
|
25
|
+
readonly cache: SiloCache;
|
|
23
26
|
private readonly options;
|
|
24
27
|
private readonly transport;
|
|
25
28
|
constructor(options: SiloOptions);
|
|
@@ -31,6 +31,7 @@ export declare class ApiPath {
|
|
|
31
31
|
static mediaExtensions(): string;
|
|
32
32
|
static mediaAsset(id: string): string;
|
|
33
33
|
static mediaAssetUsages(id: string): string;
|
|
34
|
+
static mediaAssetContent(id: string): string;
|
|
34
35
|
static mediaBulkDelete(): string;
|
|
35
36
|
static mediaFolders(): string;
|
|
36
37
|
}
|
|
@@ -31,6 +31,7 @@ export declare class ApiPath {
|
|
|
31
31
|
static mediaExtensions(): string;
|
|
32
32
|
static mediaAsset(id: string): string;
|
|
33
33
|
static mediaAssetUsages(id: string): string;
|
|
34
|
+
static mediaAssetContent(id: string): string;
|
|
34
35
|
static mediaBulkDelete(): string;
|
|
35
36
|
static mediaFolders(): string;
|
|
36
37
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ResponseCache } from "../cache/response-cache.cjs";
|
|
2
|
+
import type { FetchTransport } from "./fetch-transport.cjs";
|
|
3
|
+
import type { TransportRequest } from "./transport-request.cjs";
|
|
4
|
+
import type { Transport } from "./transport.cjs";
|
|
5
|
+
/** Adds opt-in GET JSON caching to the fetch transport. */
|
|
6
|
+
export declare class CachingTransport implements Transport {
|
|
7
|
+
#private;
|
|
8
|
+
constructor(fetchTransport: FetchTransport, cache: ResponseCache);
|
|
9
|
+
json<T>(request: TransportRequest): Promise<T>;
|
|
10
|
+
empty(request: TransportRequest): Promise<void>;
|
|
11
|
+
stream(request: TransportRequest): Promise<ReadableStream<Uint8Array> | null>;
|
|
12
|
+
upload<T>(request: TransportRequest, form: FormData): Promise<T>;
|
|
13
|
+
private write;
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ResponseCache } from "../cache/response-cache.js";
|
|
2
|
+
import type { FetchTransport } from "./fetch-transport.js";
|
|
3
|
+
import type { TransportRequest } from "./transport-request.js";
|
|
4
|
+
import type { Transport } from "./transport.js";
|
|
5
|
+
/** Adds opt-in GET JSON caching to the fetch transport. */
|
|
6
|
+
export declare class CachingTransport implements Transport {
|
|
7
|
+
#private;
|
|
8
|
+
constructor(fetchTransport: FetchTransport, cache: ResponseCache);
|
|
9
|
+
json<T>(request: TransportRequest): Promise<T>;
|
|
10
|
+
empty(request: TransportRequest): Promise<void>;
|
|
11
|
+
stream(request: TransportRequest): Promise<ReadableStream<Uint8Array> | null>;
|
|
12
|
+
upload<T>(request: TransportRequest, form: FormData): Promise<T>;
|
|
13
|
+
private write;
|
|
14
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { NetworkError } from "../errors/network-error.cjs";
|
|
2
|
+
import type { FetchFunction } from "./fetch-function.cjs";
|
|
3
|
+
import type { PreparedTransportRequest } from "./prepared-transport-request.cjs";
|
|
4
|
+
import type { TransportRequest } from "./transport-request.cjs";
|
|
5
|
+
import type { Transport } from "./transport.cjs";
|
|
6
|
+
export interface FetchTransportOptions {
|
|
7
|
+
url: string;
|
|
8
|
+
key?: string;
|
|
9
|
+
headers?: Record<string, string>;
|
|
10
|
+
timeoutMilliseconds?: number;
|
|
11
|
+
fetch?: FetchFunction;
|
|
12
|
+
}
|
|
13
|
+
/** The fetch-backed implementation behind the internal transport seam. */
|
|
14
|
+
export declare class FetchTransport implements Transport {
|
|
15
|
+
#private;
|
|
16
|
+
constructor(options: FetchTransportOptions);
|
|
17
|
+
json<T>(request: TransportRequest): Promise<T>;
|
|
18
|
+
jsonPrepared<T>(request: TransportRequest, prepared: PreparedTransportRequest): Promise<T>;
|
|
19
|
+
empty(request: TransportRequest): Promise<void>;
|
|
20
|
+
stream(request: TransportRequest): Promise<ReadableStream<Uint8Array> | null>;
|
|
21
|
+
upload<T>(request: TransportRequest, form: FormData): Promise<T>;
|
|
22
|
+
withKey(key: string | undefined): FetchTransport;
|
|
23
|
+
withUrl(url: string): FetchTransport;
|
|
24
|
+
prepare(request: TransportRequest, form?: FormData): PreparedTransportRequest;
|
|
25
|
+
preparationFailure(request: TransportRequest, caught: unknown): NetworkError;
|
|
26
|
+
private snapshot;
|
|
27
|
+
private execute;
|
|
28
|
+
private transportFailure;
|
|
29
|
+
private static normalizeUrl;
|
|
30
|
+
private static resolveFetch;
|
|
31
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { NetworkError } from "../errors/network-error.js";
|
|
2
|
+
import type { FetchFunction } from "./fetch-function.js";
|
|
3
|
+
import type { PreparedTransportRequest } from "./prepared-transport-request.js";
|
|
4
|
+
import type { TransportRequest } from "./transport-request.js";
|
|
5
|
+
import type { Transport } from "./transport.js";
|
|
6
|
+
export interface FetchTransportOptions {
|
|
7
|
+
url: string;
|
|
8
|
+
key?: string;
|
|
9
|
+
headers?: Record<string, string>;
|
|
10
|
+
timeoutMilliseconds?: number;
|
|
11
|
+
fetch?: FetchFunction;
|
|
12
|
+
}
|
|
13
|
+
/** The fetch-backed implementation behind the internal transport seam. */
|
|
14
|
+
export declare class FetchTransport implements Transport {
|
|
15
|
+
#private;
|
|
16
|
+
constructor(options: FetchTransportOptions);
|
|
17
|
+
json<T>(request: TransportRequest): Promise<T>;
|
|
18
|
+
jsonPrepared<T>(request: TransportRequest, prepared: PreparedTransportRequest): Promise<T>;
|
|
19
|
+
empty(request: TransportRequest): Promise<void>;
|
|
20
|
+
stream(request: TransportRequest): Promise<ReadableStream<Uint8Array> | null>;
|
|
21
|
+
upload<T>(request: TransportRequest, form: FormData): Promise<T>;
|
|
22
|
+
withKey(key: string | undefined): FetchTransport;
|
|
23
|
+
withUrl(url: string): FetchTransport;
|
|
24
|
+
prepare(request: TransportRequest, form?: FormData): PreparedTransportRequest;
|
|
25
|
+
preparationFailure(request: TransportRequest, caught: unknown): NetworkError;
|
|
26
|
+
private snapshot;
|
|
27
|
+
private execute;
|
|
28
|
+
private transportFailure;
|
|
29
|
+
private static normalizeUrl;
|
|
30
|
+
private static resolveFetch;
|
|
31
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CacheMode } from "../cache/cache-mode.cjs";
|
|
1
2
|
/** One query parameter's value. An object (the `filter` AST) is JSON-encoded
|
|
2
3
|
* by {@link QueryString}; everything else is stringified. */
|
|
3
4
|
export type TransportQueryValue = string | number | boolean | object | undefined;
|
|
@@ -15,4 +16,5 @@ export interface TransportRequest {
|
|
|
15
16
|
headers?: Record<string, string>;
|
|
16
17
|
signal?: AbortSignal;
|
|
17
18
|
timeoutMilliseconds?: number;
|
|
19
|
+
cache?: CacheMode;
|
|
18
20
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CacheMode } from "../cache/cache-mode.js";
|
|
1
2
|
/** One query parameter's value. An object (the `filter` AST) is JSON-encoded
|
|
2
3
|
* by {@link QueryString}; everything else is stringified. */
|
|
3
4
|
export type TransportQueryValue = string | number | boolean | object | undefined;
|
|
@@ -15,4 +16,5 @@ export interface TransportRequest {
|
|
|
15
16
|
headers?: Record<string, string>;
|
|
16
17
|
signal?: AbortSignal;
|
|
17
18
|
timeoutMilliseconds?: number;
|
|
19
|
+
cache?: CacheMode;
|
|
18
20
|
}
|
|
@@ -1,45 +1,8 @@
|
|
|
1
|
-
import type { FetchFunction } from "./fetch-function.cjs";
|
|
2
1
|
import type { TransportRequest } from "./transport-request.cjs";
|
|
3
|
-
/**
|
|
4
|
-
export interface
|
|
5
|
-
url: string;
|
|
6
|
-
key?: string;
|
|
7
|
-
headers?: Record<string, string>;
|
|
8
|
-
timeoutMilliseconds?: number;
|
|
9
|
-
fetch?: FetchFunction;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* The one place a request is made. Sends `Authorization: Bearer <key>`
|
|
13
|
-
* when a key is set and nothing when it is not, since anonymous reads are
|
|
14
|
-
* legal. A `fetch` rejection becomes `NetworkError`; an abort from the
|
|
15
|
-
* caller's own signal becomes `RequestAbortedError`; an abort from the
|
|
16
|
-
* deadline becomes `TimeoutError` — `AbortSignals` is what tells the three
|
|
17
|
-
* apart.
|
|
18
|
-
*/
|
|
19
|
-
export declare class Transport {
|
|
20
|
-
private readonly url;
|
|
21
|
-
private readonly key;
|
|
22
|
-
private readonly headers;
|
|
23
|
-
private readonly timeoutMilliseconds;
|
|
24
|
-
private readonly fetchFunction;
|
|
25
|
-
constructor(options: TransportOptions);
|
|
2
|
+
/** The requests every client handle issues. */
|
|
3
|
+
export interface Transport {
|
|
26
4
|
json<T>(request: TransportRequest): Promise<T>;
|
|
27
|
-
/** For a `204` response: decodes it, and discards the result. */
|
|
28
5
|
empty(request: TransportRequest): Promise<void>;
|
|
29
6
|
stream(request: TransportRequest): Promise<ReadableStream<Uint8Array> | null>;
|
|
30
|
-
/** Multipart upload. Never sets `Content-Type` by hand — the runtime sets
|
|
31
|
-
* it, boundary included, from the `FormData` body. */
|
|
32
7
|
upload<T>(request: TransportRequest, form: FormData): Promise<T>;
|
|
33
|
-
/** A new `Transport` reading a different key, sharing everything else. */
|
|
34
|
-
withKey(key: string | undefined): Transport;
|
|
35
|
-
/** A new `Transport` reading a different base URL, sharing everything
|
|
36
|
-
* else. */
|
|
37
|
-
withUrl(url: string): Transport;
|
|
38
|
-
private snapshot;
|
|
39
|
-
private execute;
|
|
40
|
-
/** Distinguishes why `fetch` itself failed: the deadline, the caller's own
|
|
41
|
-
* signal, or the request never landing at all. */
|
|
42
|
-
private transportFailure;
|
|
43
|
-
private buildHeaders;
|
|
44
|
-
private static normalizeUrl;
|
|
45
8
|
}
|
|
@@ -1,45 +1,8 @@
|
|
|
1
|
-
import type { FetchFunction } from "./fetch-function.js";
|
|
2
1
|
import type { TransportRequest } from "./transport-request.js";
|
|
3
|
-
/**
|
|
4
|
-
export interface
|
|
5
|
-
url: string;
|
|
6
|
-
key?: string;
|
|
7
|
-
headers?: Record<string, string>;
|
|
8
|
-
timeoutMilliseconds?: number;
|
|
9
|
-
fetch?: FetchFunction;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* The one place a request is made. Sends `Authorization: Bearer <key>`
|
|
13
|
-
* when a key is set and nothing when it is not, since anonymous reads are
|
|
14
|
-
* legal. A `fetch` rejection becomes `NetworkError`; an abort from the
|
|
15
|
-
* caller's own signal becomes `RequestAbortedError`; an abort from the
|
|
16
|
-
* deadline becomes `TimeoutError` — `AbortSignals` is what tells the three
|
|
17
|
-
* apart.
|
|
18
|
-
*/
|
|
19
|
-
export declare class Transport {
|
|
20
|
-
private readonly url;
|
|
21
|
-
private readonly key;
|
|
22
|
-
private readonly headers;
|
|
23
|
-
private readonly timeoutMilliseconds;
|
|
24
|
-
private readonly fetchFunction;
|
|
25
|
-
constructor(options: TransportOptions);
|
|
2
|
+
/** The requests every client handle issues. */
|
|
3
|
+
export interface Transport {
|
|
26
4
|
json<T>(request: TransportRequest): Promise<T>;
|
|
27
|
-
/** For a `204` response: decodes it, and discards the result. */
|
|
28
5
|
empty(request: TransportRequest): Promise<void>;
|
|
29
6
|
stream(request: TransportRequest): Promise<ReadableStream<Uint8Array> | null>;
|
|
30
|
-
/** Multipart upload. Never sets `Content-Type` by hand — the runtime sets
|
|
31
|
-
* it, boundary included, from the `FormData` body. */
|
|
32
7
|
upload<T>(request: TransportRequest, form: FormData): Promise<T>;
|
|
33
|
-
/** A new `Transport` reading a different key, sharing everything else. */
|
|
34
|
-
withKey(key: string | undefined): Transport;
|
|
35
|
-
/** A new `Transport` reading a different base URL, sharing everything
|
|
36
|
-
* else. */
|
|
37
|
-
withUrl(url: string): Transport;
|
|
38
|
-
private snapshot;
|
|
39
|
-
private execute;
|
|
40
|
-
/** Distinguishes why `fetch` itself failed: the deadline, the caller's own
|
|
41
|
-
* signal, or the request never landing at all. */
|
|
42
|
-
private transportFailure;
|
|
43
|
-
private buildHeaders;
|
|
44
|
-
private static normalizeUrl;
|
|
45
8
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@org-quicko/silo-client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "A typed, object-oriented client for silo's HTTP API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"silo",
|
|
@@ -41,14 +41,17 @@
|
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"build": "bun run build:esm && bun run build:cjs && bun run build:types",
|
|
44
|
-
"build:esm": "bun build src/index.ts --format=esm --outfile dist/index.js",
|
|
45
|
-
"build:cjs": "bun build src/index.ts --format=cjs --outfile dist/index.cjs",
|
|
44
|
+
"build:esm": "bun build src/index.ts --format=esm --packages=external --outfile dist/index.js",
|
|
45
|
+
"build:cjs": "bun build src/index.ts --format=cjs --packages=external --outfile dist/index.cjs",
|
|
46
46
|
"build:types": "tsc -p tsconfig.build.json && bun run tools/emit-cts-types.ts",
|
|
47
47
|
"test": "bun test",
|
|
48
48
|
"test:packaged": "bun run tools/packaged-tests.ts",
|
|
49
49
|
"typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p tsconfig.test.json",
|
|
50
50
|
"prepublishOnly": "bun run build"
|
|
51
51
|
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@isaacs/ttlcache": "2.1.5"
|
|
54
|
+
},
|
|
52
55
|
"devDependencies": {
|
|
53
56
|
"@arethetypeswrong/cli": "^0.18.5",
|
|
54
57
|
"@silo/shared": "workspace:*",
|