@org-quicko/silo-client 1.1.0 → 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 +42 -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/index.cjs +209 -60
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +209 -60
- package/dist/media/media-page.d.cts +1 -0
- package/dist/media/media-page.d.ts +1 -0
- package/dist/media/media-usage-page.d.cts +1 -0
- package/dist/media/media-usage-page.d.ts +1 -0
- 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/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 -43
- package/dist/transport/transport.d.ts +2 -43
- package/package.json +6 -3
|
@@ -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,49 +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
|
-
/** The caller's own `fetch`, or the runtime's bound to the global. A
|
|
46
|
-
* browser's `fetch` is a `Window` method and refuses every other receiver,
|
|
47
|
-
* so the default is stored already bound rather than bare. */
|
|
48
|
-
private static resolveFetch;
|
|
49
8
|
}
|
|
@@ -1,49 +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
|
-
/** The caller's own `fetch`, or the runtime's bound to the global. A
|
|
46
|
-
* browser's `fetch` is a `Window` method and refuses every other receiver,
|
|
47
|
-
* so the default is stored already bound rather than bare. */
|
|
48
|
-
private static resolveFetch;
|
|
49
8
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@org-quicko/silo-client",
|
|
3
|
-
"version": "1.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:*",
|