@org-quicko/silo-client 1.0.0 → 1.1.0
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 +166 -124
- package/dist/collections/collection-handle.d.cts +15 -23
- package/dist/collections/collection-handle.d.ts +15 -23
- package/dist/collections/collections.d.cts +3 -5
- package/dist/collections/collections.d.ts +3 -5
- package/dist/entries/entry-envelope.d.cts +18 -0
- package/dist/entries/entry-envelope.d.ts +18 -0
- package/dist/entries/entry-read-options.d.cts +16 -0
- package/dist/entries/entry-read-options.d.ts +16 -0
- package/dist/entries/entry-reader.d.cts +16 -16
- package/dist/entries/entry-reader.d.ts +16 -16
- package/dist/entries/entry.d.cts +11 -23
- package/dist/entries/entry.d.ts +11 -23
- package/dist/errors/network-error.d.cts +5 -0
- package/dist/errors/network-error.d.ts +5 -0
- package/dist/index.cjs +87 -170
- package/dist/index.d.cts +4 -5
- package/dist/index.d.ts +4 -5
- package/dist/index.js +87 -170
- 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-replace.d.cts +17 -0
- package/dist/media/media-replace.d.ts +17 -0
- package/dist/media/media.d.cts +0 -4
- package/dist/media/media.d.ts +0 -4
- package/dist/search/search-hit.d.cts +5 -5
- package/dist/search/search-hit.d.ts +5 -5
- package/dist/search/search.d.cts +4 -1
- package/dist/search/search.d.ts +4 -1
- package/dist/transport/api-path.d.cts +1 -0
- package/dist/transport/api-path.d.ts +1 -0
- package/dist/transport/transport.d.cts +4 -0
- package/dist/transport/transport.d.ts +4 -0
- package/package.json +58 -58
- package/dist/collections/reserved-field-names.d.cts +0 -9
- package/dist/collections/reserved-field-names.d.ts +0 -9
- package/dist/entries/entry-base.d.cts +0 -31
- package/dist/entries/entry-base.d.ts +0 -31
- package/dist/entries/entry-mapper.d.cts +0 -13
- package/dist/entries/entry-mapper.d.ts +0 -13
- package/dist/entries/entry-payload.d.cts +0 -12
- package/dist/entries/entry-payload.d.ts +0 -12
- package/dist/entries/resolved-entry.d.cts +0 -11
- package/dist/entries/resolved-entry.d.ts +0 -11
|
@@ -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
|
}
|
|
@@ -42,4 +42,8 @@ export declare class Transport {
|
|
|
42
42
|
private transportFailure;
|
|
43
43
|
private buildHeaders;
|
|
44
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;
|
|
45
49
|
}
|
|
@@ -42,4 +42,8 @@ export declare class Transport {
|
|
|
42
42
|
private transportFailure;
|
|
43
43
|
private buildHeaders;
|
|
44
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;
|
|
45
49
|
}
|
package/package.json
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@org-quicko/silo-client",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "A typed, object-oriented client for silo's HTTP API",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"silo",
|
|
7
|
-
"cms",
|
|
8
|
-
"headless-cms",
|
|
9
|
-
"client",
|
|
10
|
-
"api"
|
|
11
|
-
],
|
|
12
|
-
"homepage": "https://github.com/org-quicko/silo#silo-client",
|
|
13
|
-
"repository": {
|
|
14
|
-
"type": "git",
|
|
15
|
-
"url": "git+https://github.com/org-quicko/silo.git",
|
|
16
|
-
"directory": "packages/silo-client"
|
|
17
|
-
},
|
|
18
|
-
"license": "AGPL-3.0-or-later",
|
|
19
|
-
"type": "module",
|
|
20
|
-
"exports": {
|
|
21
|
-
".": {
|
|
22
|
-
"import": {
|
|
23
|
-
"types": "./dist/index.d.ts",
|
|
24
|
-
"default": "./dist/index.js"
|
|
25
|
-
},
|
|
26
|
-
"require": {
|
|
27
|
-
"types": "./dist/index.d.cts",
|
|
28
|
-
"default": "./dist/index.cjs"
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
"main": "./dist/index.cjs",
|
|
33
|
-
"module": "./dist/index.js",
|
|
34
|
-
"types": "./dist/index.d.ts",
|
|
35
|
-
"files": [
|
|
36
|
-
"dist",
|
|
37
|
-
"README.md"
|
|
38
|
-
],
|
|
39
|
-
"engines": {
|
|
40
|
-
"node": ">=18"
|
|
41
|
-
},
|
|
42
|
-
"scripts": {
|
|
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",
|
|
46
|
-
"build:types": "tsc -p tsconfig.build.json && bun run tools/emit-cts-types.ts",
|
|
47
|
-
"test": "bun test",
|
|
48
|
-
"test:packaged": "bun run tools/packaged-tests.ts",
|
|
49
|
-
"typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p tsconfig.test.json",
|
|
50
|
-
"prepublishOnly": "bun run build"
|
|
51
|
-
},
|
|
52
|
-
"devDependencies": {
|
|
53
|
-
"@arethetypeswrong/cli": "^0.18.
|
|
54
|
-
"@silo/shared": "workspace:*",
|
|
55
|
-
"publint": "^0.3.
|
|
56
|
-
"typescript": "^7.0.2"
|
|
57
|
-
}
|
|
58
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@org-quicko/silo-client",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "A typed, object-oriented client for silo's HTTP API",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"silo",
|
|
7
|
+
"cms",
|
|
8
|
+
"headless-cms",
|
|
9
|
+
"client",
|
|
10
|
+
"api"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/org-quicko/silo#silo-client",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/org-quicko/silo.git",
|
|
16
|
+
"directory": "packages/silo-client"
|
|
17
|
+
},
|
|
18
|
+
"license": "AGPL-3.0-or-later",
|
|
19
|
+
"type": "module",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"import": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"default": "./dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"require": {
|
|
27
|
+
"types": "./dist/index.d.cts",
|
|
28
|
+
"default": "./dist/index.cjs"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"main": "./dist/index.cjs",
|
|
33
|
+
"module": "./dist/index.js",
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
|
+
"files": [
|
|
36
|
+
"dist",
|
|
37
|
+
"README.md"
|
|
38
|
+
],
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=18"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
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",
|
|
46
|
+
"build:types": "tsc -p tsconfig.build.json && bun run tools/emit-cts-types.ts",
|
|
47
|
+
"test": "bun test",
|
|
48
|
+
"test:packaged": "bun run tools/packaged-tests.ts",
|
|
49
|
+
"typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p tsconfig.test.json",
|
|
50
|
+
"prepublishOnly": "bun run build"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@arethetypeswrong/cli": "^0.18.5",
|
|
54
|
+
"@silo/shared": "workspace:*",
|
|
55
|
+
"publint": "^0.3.24",
|
|
56
|
+
"typescript": "^7.0.2"
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The five field names the server strips from every entry response before
|
|
3
|
-
* answering, verified against `EntryUtils.toApiResponse`. A schema
|
|
4
|
-
* declaring one still validates and stores it; it just never comes back.
|
|
5
|
-
*/
|
|
6
|
-
export declare class ReservedFieldNames {
|
|
7
|
-
static readonly all: readonly string[];
|
|
8
|
-
static isReserved(name: string): boolean;
|
|
9
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The five field names the server strips from every entry response before
|
|
3
|
-
* answering, verified against `EntryUtils.toApiResponse`. A schema
|
|
4
|
-
* declaring one still validates and stores it; it just never comes back.
|
|
5
|
-
*/
|
|
6
|
-
export declare class ReservedFieldNames {
|
|
7
|
-
static readonly all: readonly string[];
|
|
8
|
-
static isReserved(name: string): boolean;
|
|
9
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { RequestOptions } from "../request-options.cjs";
|
|
2
|
-
import type { Transport } from "../transport/transport.cjs";
|
|
3
|
-
import type { EntryPayload } from "./entry-payload.cjs";
|
|
4
|
-
/** What an entry needs to address itself: the transport, and the scope and
|
|
5
|
-
* collection its id lives in. */
|
|
6
|
-
export interface EntryContext {
|
|
7
|
-
readonly transport: Transport;
|
|
8
|
-
readonly project: string;
|
|
9
|
-
readonly environment: string;
|
|
10
|
-
readonly collection: string;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* What every entry has regardless of whether it is editable: identity,
|
|
14
|
-
* timestamps, its fields, a plain snapshot, and `delete()` — which needs
|
|
15
|
-
* only an id and a rev, not the content. `rev`/`createdAt`/`updatedAt`/
|
|
16
|
-
* `fields` are declared `readonly` here; {@link Entry} is the one subclass
|
|
17
|
-
* that redeclares them mutable, since it is the one subclass with something
|
|
18
|
-
* that legitimately changes them.
|
|
19
|
-
*/
|
|
20
|
-
export declare abstract class EntryBase<Fields> {
|
|
21
|
-
protected readonly context: EntryContext;
|
|
22
|
-
readonly id: string;
|
|
23
|
-
readonly rev: number;
|
|
24
|
-
readonly createdAt: Date;
|
|
25
|
-
readonly updatedAt: Date;
|
|
26
|
-
readonly fields: Fields;
|
|
27
|
-
constructor(context: EntryContext, payload: EntryPayload);
|
|
28
|
-
/** The flat wire shape, for logging or React state. */
|
|
29
|
-
toJSON(): EntryPayload;
|
|
30
|
-
delete(options?: RequestOptions): Promise<void>;
|
|
31
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import type { RequestOptions } from "../request-options.js";
|
|
2
|
-
import type { Transport } from "../transport/transport.js";
|
|
3
|
-
import type { EntryPayload } from "./entry-payload.js";
|
|
4
|
-
/** What an entry needs to address itself: the transport, and the scope and
|
|
5
|
-
* collection its id lives in. */
|
|
6
|
-
export interface EntryContext {
|
|
7
|
-
readonly transport: Transport;
|
|
8
|
-
readonly project: string;
|
|
9
|
-
readonly environment: string;
|
|
10
|
-
readonly collection: string;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* What every entry has regardless of whether it is editable: identity,
|
|
14
|
-
* timestamps, its fields, a plain snapshot, and `delete()` — which needs
|
|
15
|
-
* only an id and a rev, not the content. `rev`/`createdAt`/`updatedAt`/
|
|
16
|
-
* `fields` are declared `readonly` here; {@link Entry} is the one subclass
|
|
17
|
-
* that redeclares them mutable, since it is the one subclass with something
|
|
18
|
-
* that legitimately changes them.
|
|
19
|
-
*/
|
|
20
|
-
export declare abstract class EntryBase<Fields> {
|
|
21
|
-
protected readonly context: EntryContext;
|
|
22
|
-
readonly id: string;
|
|
23
|
-
readonly rev: number;
|
|
24
|
-
readonly createdAt: Date;
|
|
25
|
-
readonly updatedAt: Date;
|
|
26
|
-
readonly fields: Fields;
|
|
27
|
-
constructor(context: EntryContext, payload: EntryPayload);
|
|
28
|
-
/** The flat wire shape, for logging or React state. */
|
|
29
|
-
toJSON(): EntryPayload;
|
|
30
|
-
delete(options?: RequestOptions): Promise<void>;
|
|
31
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { EntryPayload } from "./entry-payload.cjs";
|
|
2
|
-
/**
|
|
3
|
-
* The one place an entry's envelope (`id`, `rev`, `created_at`, `updated_at`)
|
|
4
|
-
* is split from its content. Never touches a field name either direction
|
|
5
|
-
*: whatever is left after the four known keys are removed is handed
|
|
6
|
-
* back exactly as it arrived.
|
|
7
|
-
*/
|
|
8
|
-
export declare class EntryMapper {
|
|
9
|
-
static fieldsOf<Fields>(payload: EntryPayload): Fields;
|
|
10
|
-
/** The flat wire shape `toJSON()` answers: the envelope rebuilt around
|
|
11
|
-
* whatever `fields` currently holds. */
|
|
12
|
-
static toPayload<Fields>(id: string, rev: number, fields: Fields, createdAt: Date, updatedAt: Date): EntryPayload;
|
|
13
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { EntryPayload } from "./entry-payload.js";
|
|
2
|
-
/**
|
|
3
|
-
* The one place an entry's envelope (`id`, `rev`, `created_at`, `updated_at`)
|
|
4
|
-
* is split from its content. Never touches a field name either direction
|
|
5
|
-
*: whatever is left after the four known keys are removed is handed
|
|
6
|
-
* back exactly as it arrived.
|
|
7
|
-
*/
|
|
8
|
-
export declare class EntryMapper {
|
|
9
|
-
static fieldsOf<Fields>(payload: EntryPayload): Fields;
|
|
10
|
-
/** The flat wire shape `toJSON()` answers: the envelope rebuilt around
|
|
11
|
-
* whatever `fields` currently holds. */
|
|
12
|
-
static toPayload<Fields>(id: string, rev: number, fields: Fields, createdAt: Date, updatedAt: Date): EntryPayload;
|
|
13
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* One entry exactly as the wire answers it: flattened, with the user's
|
|
3
|
-
* fields alongside the four envelope keys. `EntryUtils.toApiResponse` is
|
|
4
|
-
* where the server builds this shape.
|
|
5
|
-
*/
|
|
6
|
-
export interface EntryPayload {
|
|
7
|
-
id: string;
|
|
8
|
-
rev: number;
|
|
9
|
-
created_at: string;
|
|
10
|
-
updated_at: string;
|
|
11
|
-
[field: string]: unknown;
|
|
12
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* One entry exactly as the wire answers it: flattened, with the user's
|
|
3
|
-
* fields alongside the four envelope keys. `EntryUtils.toApiResponse` is
|
|
4
|
-
* where the server builds this shape.
|
|
5
|
-
*/
|
|
6
|
-
export interface EntryPayload {
|
|
7
|
-
id: string;
|
|
8
|
-
rev: number;
|
|
9
|
-
created_at: string;
|
|
10
|
-
updated_at: string;
|
|
11
|
-
[field: string]: unknown;
|
|
12
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { EntryBase } from "./entry-base.cjs";
|
|
2
|
-
/**
|
|
3
|
-
* A read whose variables have been substituted. Adds nothing over
|
|
4
|
-
* {@link EntryBase}: no `save()`, no `refresh()` — writing a resolved value
|
|
5
|
-
* back would overwrite whatever `{{NAME}}` template produced it. `fields` is
|
|
6
|
-
* narrowed to `Readonly<Fields>` at the type level; `Entry` is what an
|
|
7
|
-
* editor asks for instead.
|
|
8
|
-
*/
|
|
9
|
-
export declare class ResolvedEntry<Fields> extends EntryBase<Fields> {
|
|
10
|
-
readonly fields: Readonly<Fields>;
|
|
11
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { EntryBase } from "./entry-base.js";
|
|
2
|
-
/**
|
|
3
|
-
* A read whose variables have been substituted. Adds nothing over
|
|
4
|
-
* {@link EntryBase}: no `save()`, no `refresh()` — writing a resolved value
|
|
5
|
-
* back would overwrite whatever `{{NAME}}` template produced it. `fields` is
|
|
6
|
-
* narrowed to `Readonly<Fields>` at the type level; `Entry` is what an
|
|
7
|
-
* editor asks for instead.
|
|
8
|
-
*/
|
|
9
|
-
export declare class ResolvedEntry<Fields> extends EntryBase<Fields> {
|
|
10
|
-
readonly fields: Readonly<Fields>;
|
|
11
|
-
}
|