@org-quicko/silo-client 1.0.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 +313 -0
- package/dist/collections/collection-definition.d.cts +10 -0
- package/dist/collections/collection-definition.d.ts +10 -0
- package/dist/collections/collection-handle.d.cts +54 -0
- package/dist/collections/collection-handle.d.ts +54 -0
- package/dist/collections/collection-schema.d.cts +16 -0
- package/dist/collections/collection-schema.d.ts +16 -0
- package/dist/collections/collection-summary.d.cts +10 -0
- package/dist/collections/collection-summary.d.ts +10 -0
- package/dist/collections/collections.d.cts +19 -0
- package/dist/collections/collections.d.ts +19 -0
- package/dist/collections/json-schema.d.cts +9 -0
- package/dist/collections/json-schema.d.ts +9 -0
- package/dist/collections/reserved-field-names.d.cts +9 -0
- package/dist/collections/reserved-field-names.d.ts +9 -0
- package/dist/entries/entry-base.d.cts +31 -0
- package/dist/entries/entry-base.d.ts +31 -0
- package/dist/entries/entry-list-query.d.cts +11 -0
- package/dist/entries/entry-list-query.d.ts +11 -0
- package/dist/entries/entry-mapper.d.cts +13 -0
- package/dist/entries/entry-mapper.d.ts +13 -0
- package/dist/entries/entry-page-stream.d.cts +14 -0
- package/dist/entries/entry-page-stream.d.ts +14 -0
- package/dist/entries/entry-page.d.cts +16 -0
- package/dist/entries/entry-page.d.ts +16 -0
- package/dist/entries/entry-payload.d.cts +12 -0
- package/dist/entries/entry-payload.d.ts +12 -0
- package/dist/entries/entry-reader.d.cts +26 -0
- package/dist/entries/entry-reader.d.ts +26 -0
- package/dist/entries/entry-stream.d.cts +5 -0
- package/dist/entries/entry-stream.d.ts +5 -0
- package/dist/entries/entry.d.cts +25 -0
- package/dist/entries/entry.d.ts +25 -0
- package/dist/entries/resolved-entry.d.cts +11 -0
- package/dist/entries/resolved-entry.d.ts +11 -0
- package/dist/errors/conflict-error.d.cts +6 -0
- package/dist/errors/conflict-error.d.ts +6 -0
- package/dist/errors/error-code.d.cts +4 -0
- package/dist/errors/error-code.d.ts +4 -0
- package/dist/errors/error-factory.d.cts +15 -0
- package/dist/errors/error-factory.d.ts +15 -0
- package/dist/errors/error-payload.d.cts +13 -0
- package/dist/errors/error-payload.d.ts +13 -0
- package/dist/errors/forbidden-error.d.cts +5 -0
- package/dist/errors/forbidden-error.d.ts +5 -0
- package/dist/errors/internal-error.d.cts +6 -0
- package/dist/errors/internal-error.d.ts +6 -0
- package/dist/errors/invalid-response-error.d.cts +11 -0
- package/dist/errors/invalid-response-error.d.ts +11 -0
- package/dist/errors/media-delete-stalled-error.d.cts +14 -0
- package/dist/errors/media-delete-stalled-error.d.ts +14 -0
- package/dist/errors/media-in-use-error.d.cts +21 -0
- package/dist/errors/media-in-use-error.d.ts +21 -0
- package/dist/errors/network-error.d.cts +11 -0
- package/dist/errors/network-error.d.ts +11 -0
- package/dist/errors/not-found-error.d.cts +6 -0
- package/dist/errors/not-found-error.d.ts +6 -0
- package/dist/errors/request-aborted-error.d.cts +10 -0
- package/dist/errors/request-aborted-error.d.ts +10 -0
- package/dist/errors/silo-error.d.cts +12 -0
- package/dist/errors/silo-error.d.ts +12 -0
- package/dist/errors/timeout-error.d.cts +11 -0
- package/dist/errors/timeout-error.d.ts +11 -0
- package/dist/errors/unauthorized-error.d.cts +5 -0
- package/dist/errors/unauthorized-error.d.ts +5 -0
- package/dist/errors/validation-detail.d.cts +8 -0
- package/dist/errors/validation-detail.d.ts +8 -0
- package/dist/errors/validation-failed-error.d.cts +11 -0
- package/dist/errors/validation-failed-error.d.ts +11 -0
- package/dist/index.cjs +2095 -0
- package/dist/index.d.cts +96 -0
- package/dist/index.d.ts +96 -0
- package/dist/index.js +2053 -0
- package/dist/instance/health-report.d.cts +5 -0
- package/dist/instance/health-report.d.ts +5 -0
- package/dist/media/media-asset-mapper.d.cts +31 -0
- package/dist/media/media-asset-mapper.d.ts +31 -0
- package/dist/media/media-asset-payload.d.cts +20 -0
- package/dist/media/media-asset-payload.d.ts +20 -0
- package/dist/media/media-asset.d.cts +63 -0
- package/dist/media/media-asset.d.ts +63 -0
- package/dist/media/media-delete-failure.d.cts +16 -0
- package/dist/media/media-delete-failure.d.ts +16 -0
- package/dist/media/media-delete-options.d.cts +9 -0
- package/dist/media/media-delete-options.d.ts +9 -0
- package/dist/media/media-delete-report.d.cts +13 -0
- package/dist/media/media-delete-report.d.ts +13 -0
- package/dist/media/media-folder-delete.d.cts +10 -0
- package/dist/media/media-folder-delete.d.ts +10 -0
- package/dist/media/media-folder-move.d.cts +9 -0
- package/dist/media/media-folder-move.d.ts +9 -0
- package/dist/media/media-folders.d.cts +22 -0
- package/dist/media/media-folders.d.ts +22 -0
- package/dist/media/media-page-stream.d.cts +10 -0
- package/dist/media/media-page-stream.d.ts +10 -0
- package/dist/media/media-page.d.cts +19 -0
- package/dist/media/media-page.d.ts +19 -0
- package/dist/media/media-query.d.cts +24 -0
- package/dist/media/media-query.d.ts +24 -0
- package/dist/media/media-reference.d.cts +18 -0
- package/dist/media/media-reference.d.ts +18 -0
- package/dist/media/media-stream.d.cts +7 -0
- package/dist/media/media-stream.d.ts +7 -0
- package/dist/media/media-upload.d.cts +18 -0
- package/dist/media/media-upload.d.ts +18 -0
- package/dist/media/media-usage-page.d.cts +35 -0
- package/dist/media/media-usage-page.d.ts +35 -0
- package/dist/media/media-usage.d.cts +13 -0
- package/dist/media/media-usage.d.ts +13 -0
- package/dist/media/media.d.cts +37 -0
- package/dist/media/media.d.ts +37 -0
- package/dist/pagination/page-window.d.cts +14 -0
- package/dist/pagination/page-window.d.ts +14 -0
- package/dist/pagination/page.d.cts +27 -0
- package/dist/pagination/page.d.ts +27 -0
- package/dist/pagination/row-stream.d.cts +28 -0
- package/dist/pagination/row-stream.d.ts +28 -0
- package/dist/query/field-path.d.cts +14 -0
- package/dist/query/field-path.d.ts +14 -0
- package/dist/query/filter-expression.d.cts +15 -0
- package/dist/query/filter-expression.d.ts +15 -0
- package/dist/query/filter-field.d.cts +19 -0
- package/dist/query/filter-field.d.ts +19 -0
- package/dist/query/filter-node.d.cts +9 -0
- package/dist/query/filter-node.d.ts +9 -0
- package/dist/query/filter-operator.d.cts +7 -0
- package/dist/query/filter-operator.d.ts +7 -0
- package/dist/query/filter.d.cts +18 -0
- package/dist/query/filter.d.ts +18 -0
- package/dist/query/sort-term.d.cts +13 -0
- package/dist/query/sort-term.d.ts +13 -0
- package/dist/query/sort.d.cts +15 -0
- package/dist/query/sort.d.ts +15 -0
- package/dist/query/typed-filter.d.cts +32 -0
- package/dist/query/typed-filter.d.ts +32 -0
- package/dist/request-options.d.cts +9 -0
- package/dist/request-options.d.ts +9 -0
- package/dist/scope/delete-options.d.cts +9 -0
- package/dist/scope/delete-options.d.ts +9 -0
- package/dist/scope/environment-handle.d.cts +29 -0
- package/dist/scope/environment-handle.d.ts +29 -0
- package/dist/scope/environment.d.cts +8 -0
- package/dist/scope/environment.d.ts +8 -0
- package/dist/scope/environments.d.cts +11 -0
- package/dist/scope/environments.d.ts +11 -0
- package/dist/scope/project-handle.d.cts +22 -0
- package/dist/scope/project-handle.d.ts +22 -0
- package/dist/scope/project.d.cts +8 -0
- package/dist/scope/project.d.ts +8 -0
- package/dist/scope/projects.d.cts +10 -0
- package/dist/scope/projects.d.ts +10 -0
- package/dist/scope/rename-options.d.cts +10 -0
- package/dist/scope/rename-options.d.ts +10 -0
- package/dist/scope/rename-report.d.cts +21 -0
- package/dist/scope/rename-report.d.ts +21 -0
- package/dist/scope/scope-reference.d.cts +12 -0
- package/dist/scope/scope-reference.d.ts +12 -0
- package/dist/search/search-engine.d.cts +3 -0
- package/dist/search/search-engine.d.ts +3 -0
- package/dist/search/search-hit.d.cts +18 -0
- package/dist/search/search-hit.d.ts +18 -0
- package/dist/search/search-page.d.cts +19 -0
- package/dist/search/search-page.d.ts +19 -0
- package/dist/search/search-query.d.cts +11 -0
- package/dist/search/search-query.d.ts +11 -0
- package/dist/search/search-reach.d.cts +12 -0
- package/dist/search/search-reach.d.ts +12 -0
- package/dist/search/search-snippet.d.cts +8 -0
- package/dist/search/search-snippet.d.ts +8 -0
- package/dist/search/search.d.cts +18 -0
- package/dist/search/search.d.ts +18 -0
- package/dist/silo-options.d.cts +12 -0
- package/dist/silo-options.d.ts +12 -0
- package/dist/silo.d.cts +42 -0
- package/dist/silo.d.ts +42 -0
- package/dist/transport/abort-signals.d.cts +23 -0
- package/dist/transport/abort-signals.d.ts +23 -0
- package/dist/transport/api-path.d.cts +36 -0
- package/dist/transport/api-path.d.ts +36 -0
- package/dist/transport/fetch-function.d.cts +11 -0
- package/dist/transport/fetch-function.d.ts +11 -0
- package/dist/transport/page-payload.d.cts +15 -0
- package/dist/transport/page-payload.d.ts +15 -0
- package/dist/transport/query-string.d.cts +10 -0
- package/dist/transport/query-string.d.ts +10 -0
- package/dist/transport/response-decoder.d.cts +14 -0
- package/dist/transport/response-decoder.d.ts +14 -0
- package/dist/transport/route-inventory.d.cts +22 -0
- package/dist/transport/route-inventory.d.ts +22 -0
- package/dist/transport/transport-request.d.cts +18 -0
- package/dist/transport/transport-request.d.ts +18 -0
- package/dist/transport/transport.d.cts +45 -0
- package/dist/transport/transport.d.ts +45 -0
- package/dist/variables/environment-variables.d.cts +14 -0
- package/dist/variables/environment-variables.d.ts +14 -0
- package/dist/variables/project-variables.d.cts +38 -0
- package/dist/variables/project-variables.d.ts +38 -0
- package/dist/variables/variable-declaration.d.cts +10 -0
- package/dist/variables/variable-declaration.d.ts +10 -0
- package/dist/variables/variable.d.cts +17 -0
- package/dist/variables/variable.d.ts +17 -0
- package/package.json +58 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FilterExpression } from "../query/filter-expression.js";
|
|
2
|
+
import type { SortTerm } from "../query/sort-term.js";
|
|
3
|
+
/** Everything `collection.list()` accepts, all optional. `where`
|
|
4
|
+
* builds through `collection.filter`; `sort` takes a built `SortTerm` or a
|
|
5
|
+
* raw string. */
|
|
6
|
+
export interface EntryListQuery {
|
|
7
|
+
where?: FilterExpression;
|
|
8
|
+
sort?: SortTerm | string;
|
|
9
|
+
limit?: number;
|
|
10
|
+
offset?: number;
|
|
11
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RequestOptions } from "../request-options.cjs";
|
|
2
|
+
import type { EntryPage } from "./entry-page.cjs";
|
|
3
|
+
/**
|
|
4
|
+
* `collection.pages()`'s return type: whole pages, one at a time, advancing
|
|
5
|
+
* by each page's own echoed window and stopping on the first short or empty
|
|
6
|
+
* one — the same termination rule `RowStream` uses, applied one page
|
|
7
|
+
* up.
|
|
8
|
+
*/
|
|
9
|
+
export declare class EntryPageStream<Row> implements AsyncIterable<EntryPage<Row>> {
|
|
10
|
+
private readonly loadFirst;
|
|
11
|
+
private readonly options;
|
|
12
|
+
constructor(loadFirst: () => Promise<EntryPage<Row>>, options?: RequestOptions);
|
|
13
|
+
[Symbol.asyncIterator](): AsyncIterator<EntryPage<Row>>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RequestOptions } from "../request-options.js";
|
|
2
|
+
import type { EntryPage } from "./entry-page.js";
|
|
3
|
+
/**
|
|
4
|
+
* `collection.pages()`'s return type: whole pages, one at a time, advancing
|
|
5
|
+
* by each page's own echoed window and stopping on the first short or empty
|
|
6
|
+
* one — the same termination rule `RowStream` uses, applied one page
|
|
7
|
+
* up.
|
|
8
|
+
*/
|
|
9
|
+
export declare class EntryPageStream<Row> implements AsyncIterable<EntryPage<Row>> {
|
|
10
|
+
private readonly loadFirst;
|
|
11
|
+
private readonly options;
|
|
12
|
+
constructor(loadFirst: () => Promise<EntryPage<Row>>, options?: RequestOptions);
|
|
13
|
+
[Symbol.asyncIterator](): AsyncIterator<EntryPage<Row>>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Page } from "../pagination/page.cjs";
|
|
2
|
+
import type { PageWindow } from "../pagination/page-window.cjs";
|
|
3
|
+
/** Loads the page at `window`, keeping whatever filter and sort produced
|
|
4
|
+
* this page in the first place. */
|
|
5
|
+
export type EntryPageLoader<Row> = (window: PageWindow) => Promise<EntryPage<Row>>;
|
|
6
|
+
/**
|
|
7
|
+
* One page of entries, navigated by the window the server echoed
|
|
8
|
+
* rather than the one requested.
|
|
9
|
+
*/
|
|
10
|
+
export declare class EntryPage<Row> extends Page<Row> {
|
|
11
|
+
private readonly loader;
|
|
12
|
+
constructor(rows: readonly Row[], total: number, window: PageWindow, loader: EntryPageLoader<Row>);
|
|
13
|
+
get entries(): readonly Row[];
|
|
14
|
+
next(): Promise<EntryPage<Row> | null>;
|
|
15
|
+
previous(): Promise<EntryPage<Row> | null>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Page } from "../pagination/page.js";
|
|
2
|
+
import type { PageWindow } from "../pagination/page-window.js";
|
|
3
|
+
/** Loads the page at `window`, keeping whatever filter and sort produced
|
|
4
|
+
* this page in the first place. */
|
|
5
|
+
export type EntryPageLoader<Row> = (window: PageWindow) => Promise<EntryPage<Row>>;
|
|
6
|
+
/**
|
|
7
|
+
* One page of entries, navigated by the window the server echoed
|
|
8
|
+
* rather than the one requested.
|
|
9
|
+
*/
|
|
10
|
+
export declare class EntryPage<Row> extends Page<Row> {
|
|
11
|
+
private readonly loader;
|
|
12
|
+
constructor(rows: readonly Row[], total: number, window: PageWindow, loader: EntryPageLoader<Row>);
|
|
13
|
+
get entries(): readonly Row[];
|
|
14
|
+
next(): Promise<EntryPage<Row> | null>;
|
|
15
|
+
previous(): Promise<EntryPage<Row> | null>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { RequestOptions } from "../request-options.cjs";
|
|
2
|
+
import type { EntryContext } from "./entry-base.cjs";
|
|
3
|
+
import type { EntryListQuery } from "./entry-list-query.cjs";
|
|
4
|
+
import { EntryPage } from "./entry-page.cjs";
|
|
5
|
+
import { EntryPageStream } from "./entry-page-stream.cjs";
|
|
6
|
+
import type { EntryPayload } from "./entry-payload.cjs";
|
|
7
|
+
import { EntryStream } from "./entry-stream.cjs";
|
|
8
|
+
/**
|
|
9
|
+
* Reads entries out of one collection and hands each answer to `wrap`.
|
|
10
|
+
*
|
|
11
|
+
* A collection holds two: one asks for substituted values and answers
|
|
12
|
+
* snapshots, the other asks for the stored templates and answers editable
|
|
13
|
+
* entries. Both read the same routes, so the paging is written once here.
|
|
14
|
+
*/
|
|
15
|
+
export declare class EntryReader<Row> {
|
|
16
|
+
private readonly context;
|
|
17
|
+
private readonly variables;
|
|
18
|
+
private readonly wrap;
|
|
19
|
+
constructor(context: EntryContext, variables: "raw" | undefined, wrap: (payload: EntryPayload) => Row);
|
|
20
|
+
get(id: string, options?: RequestOptions): Promise<Row>;
|
|
21
|
+
list(query?: EntryListQuery, options?: RequestOptions): Promise<EntryPage<Row>>;
|
|
22
|
+
/** Every matching entry, one at a time, `limit` rows per request. */
|
|
23
|
+
all(query?: EntryListQuery, options?: RequestOptions): EntryStream<Row>;
|
|
24
|
+
/** Every matching page, one at a time. */
|
|
25
|
+
pages(query?: EntryListQuery, options?: RequestOptions): EntryPageStream<Row>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { RequestOptions } from "../request-options.js";
|
|
2
|
+
import type { EntryContext } from "./entry-base.js";
|
|
3
|
+
import type { EntryListQuery } from "./entry-list-query.js";
|
|
4
|
+
import { EntryPage } from "./entry-page.js";
|
|
5
|
+
import { EntryPageStream } from "./entry-page-stream.js";
|
|
6
|
+
import type { EntryPayload } from "./entry-payload.js";
|
|
7
|
+
import { EntryStream } from "./entry-stream.js";
|
|
8
|
+
/**
|
|
9
|
+
* Reads entries out of one collection and hands each answer to `wrap`.
|
|
10
|
+
*
|
|
11
|
+
* A collection holds two: one asks for substituted values and answers
|
|
12
|
+
* snapshots, the other asks for the stored templates and answers editable
|
|
13
|
+
* entries. Both read the same routes, so the paging is written once here.
|
|
14
|
+
*/
|
|
15
|
+
export declare class EntryReader<Row> {
|
|
16
|
+
private readonly context;
|
|
17
|
+
private readonly variables;
|
|
18
|
+
private readonly wrap;
|
|
19
|
+
constructor(context: EntryContext, variables: "raw" | undefined, wrap: (payload: EntryPayload) => Row);
|
|
20
|
+
get(id: string, options?: RequestOptions): Promise<Row>;
|
|
21
|
+
list(query?: EntryListQuery, options?: RequestOptions): Promise<EntryPage<Row>>;
|
|
22
|
+
/** Every matching entry, one at a time, `limit` rows per request. */
|
|
23
|
+
all(query?: EntryListQuery, options?: RequestOptions): EntryStream<Row>;
|
|
24
|
+
/** Every matching page, one at a time. */
|
|
25
|
+
pages(query?: EntryListQuery, options?: RequestOptions): EntryPageStream<Row>;
|
|
26
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { RowStream } from "../pagination/row-stream.cjs";
|
|
2
|
+
/** `collection.all()`'s return type: entries one at a time. Named for what
|
|
3
|
+
* it yields, though the paging behaviour is entirely {@link RowStream}'s. */
|
|
4
|
+
export declare class EntryStream<Row> extends RowStream<Row> {
|
|
5
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { RowStream } from "../pagination/row-stream.js";
|
|
2
|
+
/** `collection.all()`'s return type: entries one at a time. Named for what
|
|
3
|
+
* it yields, though the paging behaviour is entirely {@link RowStream}'s. */
|
|
4
|
+
export declare class EntryStream<Row> extends RowStream<Row> {
|
|
5
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { RequestOptions } from "../request-options.cjs";
|
|
2
|
+
import { ResolvedEntry } from "./resolved-entry.cjs";
|
|
3
|
+
/**
|
|
4
|
+
* An editable entry, from a raw read: `posts.edit(id)`, a create, a
|
|
5
|
+
* replace, or any read on a client constructed with `variables: "raw"`.
|
|
6
|
+
* `fields` is mutable again here, undoing `ResolvedEntry`'s narrowing.
|
|
7
|
+
*/
|
|
8
|
+
export declare class Entry<Fields> extends ResolvedEntry<Fields> {
|
|
9
|
+
rev: number;
|
|
10
|
+
createdAt: Date;
|
|
11
|
+
updatedAt: Date;
|
|
12
|
+
fields: Fields;
|
|
13
|
+
private saving;
|
|
14
|
+
/**
|
|
15
|
+
* Sends `PUT` with the rev this instance holds, adopts the rev and
|
|
16
|
+
* timestamps the response answers, and mutates in place. A second
|
|
17
|
+
* overlapping call on the same instance is refused locally — it would
|
|
18
|
+
* send a rev already known to be stale.
|
|
19
|
+
*/
|
|
20
|
+
save(options?: RequestOptions): Promise<this>;
|
|
21
|
+
/** Re-reads this entry raw, and replaces `fields`, `rev` and the
|
|
22
|
+
* timestamps in place — what a `ConflictError` from `save()` calls for. */
|
|
23
|
+
refresh(options?: RequestOptions): Promise<this>;
|
|
24
|
+
private adopt;
|
|
25
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { RequestOptions } from "../request-options.js";
|
|
2
|
+
import { ResolvedEntry } from "./resolved-entry.js";
|
|
3
|
+
/**
|
|
4
|
+
* An editable entry, from a raw read: `posts.edit(id)`, a create, a
|
|
5
|
+
* replace, or any read on a client constructed with `variables: "raw"`.
|
|
6
|
+
* `fields` is mutable again here, undoing `ResolvedEntry`'s narrowing.
|
|
7
|
+
*/
|
|
8
|
+
export declare class Entry<Fields> extends ResolvedEntry<Fields> {
|
|
9
|
+
rev: number;
|
|
10
|
+
createdAt: Date;
|
|
11
|
+
updatedAt: Date;
|
|
12
|
+
fields: Fields;
|
|
13
|
+
private saving;
|
|
14
|
+
/**
|
|
15
|
+
* Sends `PUT` with the rev this instance holds, adopts the rev and
|
|
16
|
+
* timestamps the response answers, and mutates in place. A second
|
|
17
|
+
* overlapping call on the same instance is refused locally — it would
|
|
18
|
+
* send a rev already known to be stale.
|
|
19
|
+
*/
|
|
20
|
+
save(options?: RequestOptions): Promise<this>;
|
|
21
|
+
/** Re-reads this entry raw, and replaces `fields`, `rev` and the
|
|
22
|
+
* timestamps in place — what a `ConflictError` from `save()` calls for. */
|
|
23
|
+
refresh(options?: RequestOptions): Promise<this>;
|
|
24
|
+
private adopt;
|
|
25
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SiloError } from "./silo-error.cjs";
|
|
2
|
+
/** A `409`. `code` defaults to `"conflict"` (a stale revision); a subclass
|
|
3
|
+
* like {@link MediaInUseError} passes its own more specific wire code. */
|
|
4
|
+
export declare class ConflictError extends SiloError {
|
|
5
|
+
constructor(message: string, method: string, path: string, code?: string);
|
|
6
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SiloError } from "./silo-error.js";
|
|
2
|
+
/** A `409`. `code` defaults to `"conflict"` (a stale revision); a subclass
|
|
3
|
+
* like {@link MediaInUseError} passes its own more specific wire code. */
|
|
4
|
+
export declare class ConflictError extends SiloError {
|
|
5
|
+
constructor(message: string, method: string, path: string, code?: string);
|
|
6
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** The wire's `error.code` values this client maps to a class. An
|
|
2
|
+
* unrecognised string still arrives as `string` from the wire; `ErrorFactory`
|
|
3
|
+
* falls back to HTTP status when it sees one. */
|
|
4
|
+
export type ErrorCode = "validation_failed" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "media_in_use" | "media_delete_stalled" | "internal";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** The wire's `error.code` values this client maps to a class. An
|
|
2
|
+
* unrecognised string still arrives as `string` from the wire; `ErrorFactory`
|
|
3
|
+
* falls back to HTTP status when it sees one. */
|
|
4
|
+
export type ErrorCode = "validation_failed" | "unauthorized" | "forbidden" | "not_found" | "conflict" | "media_in_use" | "media_delete_stalled" | "internal";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SiloError } from "./silo-error.cjs";
|
|
2
|
+
/**
|
|
3
|
+
* Turns a non-2xx response body into the right error class. Reads
|
|
4
|
+
* the wire's `code` first and falls back to HTTP status when the code is
|
|
5
|
+
* missing or unrecognised, so it survives a body that is not JSON at all —
|
|
6
|
+
* an HTML proxy error page, say — without throwing.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ErrorFactory {
|
|
9
|
+
static fromResponseBody(status: number, method: string, path: string, rawBody: string): SiloError;
|
|
10
|
+
/** An unrecognised code, or none at all: fall back on the HTTP status, and
|
|
11
|
+
* on `SiloError` itself when even the status is not one this client
|
|
12
|
+
* otherwise names a class for. */
|
|
13
|
+
private static byStatus;
|
|
14
|
+
private static parse;
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { SiloError } from "./silo-error.js";
|
|
2
|
+
/**
|
|
3
|
+
* Turns a non-2xx response body into the right error class. Reads
|
|
4
|
+
* the wire's `code` first and falls back to HTTP status when the code is
|
|
5
|
+
* missing or unrecognised, so it survives a body that is not JSON at all —
|
|
6
|
+
* an HTML proxy error page, say — without throwing.
|
|
7
|
+
*/
|
|
8
|
+
export declare class ErrorFactory {
|
|
9
|
+
static fromResponseBody(status: number, method: string, path: string, rawBody: string): SiloError;
|
|
10
|
+
/** An unrecognised code, or none at all: fall back on the HTTP status, and
|
|
11
|
+
* on `SiloError` itself when even the status is not one this client
|
|
12
|
+
* otherwise names a class for. */
|
|
13
|
+
private static byStatus;
|
|
14
|
+
private static parse;
|
|
15
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The wire's error body: `{"error": {"code", "message", "details"}}`.
|
|
3
|
+
* `details` is left as `unknown` here because its shape is code-specific — an
|
|
4
|
+
* array for `validation_failed`, an object for `media_in_use` and
|
|
5
|
+
* `media_delete_stalled`, absent otherwise.
|
|
6
|
+
*/
|
|
7
|
+
export interface ErrorPayload {
|
|
8
|
+
error: {
|
|
9
|
+
code: string;
|
|
10
|
+
message: string;
|
|
11
|
+
details?: unknown;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The wire's error body: `{"error": {"code", "message", "details"}}`.
|
|
3
|
+
* `details` is left as `unknown` here because its shape is code-specific — an
|
|
4
|
+
* array for `validation_failed`, an object for `media_in_use` and
|
|
5
|
+
* `media_delete_stalled`, absent otherwise.
|
|
6
|
+
*/
|
|
7
|
+
export interface ErrorPayload {
|
|
8
|
+
error: {
|
|
9
|
+
code: string;
|
|
10
|
+
message: string;
|
|
11
|
+
details?: unknown;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SiloError } from "./silo-error.cjs";
|
|
2
|
+
/** A `500` with no more specific code: the server has a bug, or hit a
|
|
3
|
+
* failure it does not describe further. */
|
|
4
|
+
export declare class InternalError extends SiloError {
|
|
5
|
+
constructor(message: string, method: string, path: string);
|
|
6
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SiloError } from "./silo-error.js";
|
|
2
|
+
/** A `500` with no more specific code: the server has a bug, or hit a
|
|
3
|
+
* failure it does not describe further. */
|
|
4
|
+
export declare class InternalError extends SiloError {
|
|
5
|
+
constructor(message: string, method: string, path: string);
|
|
6
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A `2xx` carried a body its route does not promise — an HTML proxy page in
|
|
3
|
+
* front of a JSON route, say. Distinct from `SiloError`: the request
|
|
4
|
+
* succeeded, and what is wrong is the shape of the answer, not a refusal.
|
|
5
|
+
*/
|
|
6
|
+
export declare class InvalidResponseError extends Error {
|
|
7
|
+
readonly method: string;
|
|
8
|
+
readonly path: string;
|
|
9
|
+
readonly contentType: string;
|
|
10
|
+
constructor(method: string, path: string, contentType: string);
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A `2xx` carried a body its route does not promise — an HTML proxy page in
|
|
3
|
+
* front of a JSON route, say. Distinct from `SiloError`: the request
|
|
4
|
+
* succeeded, and what is wrong is the shape of the answer, not a refusal.
|
|
5
|
+
*/
|
|
6
|
+
export declare class InvalidResponseError extends Error {
|
|
7
|
+
readonly method: string;
|
|
8
|
+
readonly path: string;
|
|
9
|
+
readonly contentType: string;
|
|
10
|
+
constructor(method: string, path: string, contentType: string);
|
|
11
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SiloError } from "./silo-error.cjs";
|
|
2
|
+
/**
|
|
3
|
+
* A `500` where the asset was staged for deletion but the blob store refused
|
|
4
|
+
* to remove its bytes. Not a refusal like {@link MediaInUseError} — it is a
|
|
5
|
+
* storage failure the caller fixes by fixing the blob store, or by running
|
|
6
|
+
* the remedy this error names.
|
|
7
|
+
*/
|
|
8
|
+
export declare class MediaDeleteStalledError extends SiloError {
|
|
9
|
+
readonly remedy: string;
|
|
10
|
+
constructor(message: string, method: string, path: string, remedy: string);
|
|
11
|
+
/** Builds from the wire's `error.details` object, which carries `remedy`
|
|
12
|
+
* alongside fields this client does not otherwise surface. */
|
|
13
|
+
static fromWireDetails(message: string, method: string, path: string, details: unknown): MediaDeleteStalledError;
|
|
14
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SiloError } from "./silo-error.js";
|
|
2
|
+
/**
|
|
3
|
+
* A `500` where the asset was staged for deletion but the blob store refused
|
|
4
|
+
* to remove its bytes. Not a refusal like {@link MediaInUseError} — it is a
|
|
5
|
+
* storage failure the caller fixes by fixing the blob store, or by running
|
|
6
|
+
* the remedy this error names.
|
|
7
|
+
*/
|
|
8
|
+
export declare class MediaDeleteStalledError extends SiloError {
|
|
9
|
+
readonly remedy: string;
|
|
10
|
+
constructor(message: string, method: string, path: string, remedy: string);
|
|
11
|
+
/** Builds from the wire's `error.details` object, which carries `remedy`
|
|
12
|
+
* alongside fields this client does not otherwise surface. */
|
|
13
|
+
static fromWireDetails(message: string, method: string, path: string, details: unknown): MediaDeleteStalledError;
|
|
14
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { MediaUsage } from "../media/media-usage.cjs";
|
|
2
|
+
import { ConflictError } from "./conflict-error.cjs";
|
|
3
|
+
/**
|
|
4
|
+
* A `409` refusing to delete a media asset still referenced by entries
|
|
5
|
+
*. Distinct from a plain `ConflictError` because it carries structured
|
|
6
|
+
* facts a caller can act on: the true usage count, how much of it this key
|
|
7
|
+
* may see, and the visible referrers themselves — mapped through
|
|
8
|
+
* `MediaAssetMapper` so the client has one referrer type (`MediaUsage`)
|
|
9
|
+
* rather than a second one local to this error.
|
|
10
|
+
*/
|
|
11
|
+
export declare class MediaInUseError extends ConflictError {
|
|
12
|
+
readonly usageCount: number;
|
|
13
|
+
readonly visibleCount: number;
|
|
14
|
+
readonly visibleCapped: boolean;
|
|
15
|
+
readonly referrers: MediaUsage[];
|
|
16
|
+
constructor(message: string, method: string, path: string, usageCount: number, visibleCount: number, visibleCapped: boolean, referrers: MediaUsage[]);
|
|
17
|
+
/** Builds from the wire's `error.details`, which for this code is an
|
|
18
|
+
* OBJECT (`usage_count`, `visible_count`, `visible_capped`, `referrers`),
|
|
19
|
+
* unlike every other error's array-shaped `details`. */
|
|
20
|
+
static fromWireDetails(message: string, method: string, path: string, details: unknown): MediaInUseError;
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { MediaUsage } from "../media/media-usage.js";
|
|
2
|
+
import { ConflictError } from "./conflict-error.js";
|
|
3
|
+
/**
|
|
4
|
+
* A `409` refusing to delete a media asset still referenced by entries
|
|
5
|
+
*. Distinct from a plain `ConflictError` because it carries structured
|
|
6
|
+
* facts a caller can act on: the true usage count, how much of it this key
|
|
7
|
+
* may see, and the visible referrers themselves — mapped through
|
|
8
|
+
* `MediaAssetMapper` so the client has one referrer type (`MediaUsage`)
|
|
9
|
+
* rather than a second one local to this error.
|
|
10
|
+
*/
|
|
11
|
+
export declare class MediaInUseError extends ConflictError {
|
|
12
|
+
readonly usageCount: number;
|
|
13
|
+
readonly visibleCount: number;
|
|
14
|
+
readonly visibleCapped: boolean;
|
|
15
|
+
readonly referrers: MediaUsage[];
|
|
16
|
+
constructor(message: string, method: string, path: string, usageCount: number, visibleCount: number, visibleCapped: boolean, referrers: MediaUsage[]);
|
|
17
|
+
/** Builds from the wire's `error.details`, which for this code is an
|
|
18
|
+
* OBJECT (`usage_count`, `visible_count`, `visible_capped`, `referrers`),
|
|
19
|
+
* unlike every other error's array-shaped `details`. */
|
|
20
|
+
static fromWireDetails(message: string, method: string, path: string, details: unknown): MediaInUseError;
|
|
21
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `fetch` itself rejected: the request never reached the server. Does
|
|
3
|
+
* NOT extend `SiloError`, because nothing answered. A `NetworkError` on a
|
|
4
|
+
* write does not prove the write did not commit — reconcile by re-reading,
|
|
5
|
+
* do not blindly retry.
|
|
6
|
+
*/
|
|
7
|
+
export declare class NetworkError extends Error {
|
|
8
|
+
readonly method: string;
|
|
9
|
+
readonly path: string;
|
|
10
|
+
constructor(method: string, path: string, cause: unknown);
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `fetch` itself rejected: the request never reached the server. Does
|
|
3
|
+
* NOT extend `SiloError`, because nothing answered. A `NetworkError` on a
|
|
4
|
+
* write does not prove the write did not commit — reconcile by re-reading,
|
|
5
|
+
* do not blindly retry.
|
|
6
|
+
*/
|
|
7
|
+
export declare class NetworkError extends Error {
|
|
8
|
+
readonly method: string;
|
|
9
|
+
readonly path: string;
|
|
10
|
+
constructor(method: string, path: string, cause: unknown);
|
|
11
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SiloError } from "./silo-error.cjs";
|
|
2
|
+
/** A `404`: the project, environment, collection, entry, or asset named in
|
|
3
|
+
* the path does not exist. */
|
|
4
|
+
export declare class NotFoundError extends SiloError {
|
|
5
|
+
constructor(message: string, method: string, path: string);
|
|
6
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SiloError } from "./silo-error.js";
|
|
2
|
+
/** A `404`: the project, environment, collection, entry, or asset named in
|
|
3
|
+
* the path does not exist. */
|
|
4
|
+
export declare class NotFoundError extends SiloError {
|
|
5
|
+
constructor(message: string, method: string, path: string);
|
|
6
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The caller's own `AbortSignal` fired. Distinct from
|
|
3
|
+
* {@link TimeoutError}: this one is the caller changing its mind, not a
|
|
4
|
+
* deadline the client imposed.
|
|
5
|
+
*/
|
|
6
|
+
export declare class RequestAbortedError extends Error {
|
|
7
|
+
readonly method: string;
|
|
8
|
+
readonly path: string;
|
|
9
|
+
constructor(method: string, path: string);
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The caller's own `AbortSignal` fired. Distinct from
|
|
3
|
+
* {@link TimeoutError}: this one is the caller changing its mind, not a
|
|
4
|
+
* deadline the client imposed.
|
|
5
|
+
*/
|
|
6
|
+
export declare class RequestAbortedError extends Error {
|
|
7
|
+
readonly method: string;
|
|
8
|
+
readonly path: string;
|
|
9
|
+
constructor(method: string, path: string);
|
|
10
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The base for every error the server itself answered: it received the
|
|
3
|
+
* request and refused it. `status` and `code` are the wire's;
|
|
4
|
+
* `method` and `path` say what was being attempted.
|
|
5
|
+
*/
|
|
6
|
+
export declare class SiloError extends Error {
|
|
7
|
+
readonly status: number;
|
|
8
|
+
readonly code: string;
|
|
9
|
+
readonly method: string;
|
|
10
|
+
readonly path: string;
|
|
11
|
+
constructor(status: number, code: string, message: string, method: string, path: string);
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The base for every error the server itself answered: it received the
|
|
3
|
+
* request and refused it. `status` and `code` are the wire's;
|
|
4
|
+
* `method` and `path` say what was being attempted.
|
|
5
|
+
*/
|
|
6
|
+
export declare class SiloError extends Error {
|
|
7
|
+
readonly status: number;
|
|
8
|
+
readonly code: string;
|
|
9
|
+
readonly method: string;
|
|
10
|
+
readonly path: string;
|
|
11
|
+
constructor(status: number, code: string, message: string, method: string, path: string);
|
|
12
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The deadline `AbortSignals` composed fired before an answer came back
|
|
3
|
+
*. Distinct from {@link RequestAbortedError} so a caller can tell "I
|
|
4
|
+
* cancelled this" from "this took too long" without inspecting a reason.
|
|
5
|
+
*/
|
|
6
|
+
export declare class TimeoutError extends Error {
|
|
7
|
+
readonly method: string;
|
|
8
|
+
readonly path: string;
|
|
9
|
+
readonly timeoutMilliseconds: number;
|
|
10
|
+
constructor(method: string, path: string, timeoutMilliseconds: number);
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The deadline `AbortSignals` composed fired before an answer came back
|
|
3
|
+
*. Distinct from {@link RequestAbortedError} so a caller can tell "I
|
|
4
|
+
* cancelled this" from "this took too long" without inspecting a reason.
|
|
5
|
+
*/
|
|
6
|
+
export declare class TimeoutError extends Error {
|
|
7
|
+
readonly method: string;
|
|
8
|
+
readonly path: string;
|
|
9
|
+
readonly timeoutMilliseconds: number;
|
|
10
|
+
constructor(method: string, path: string, timeoutMilliseconds: number);
|
|
11
|
+
}
|