@peripheries/renderer 0.23.0 → 0.24.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 +62 -34
- package/dist/catalog.js +2 -6
- package/dist/chunks/{forms-CCAE7sCu.js → forms-DxA9WzCt.js} +0 -6
- package/dist/chunks/{load-CjPvISzH.js → load-b38vUiZM.js} +0 -4
- package/dist/chunks/{page-bundles-DLRIBP8g.js → page-bundles-CPj_vx-J.js} +1 -5
- package/dist/chunks/{persistence-DCMakM9H.js → persistence-hurkUUQ0.js} +0 -6
- package/dist/chunks/{projection-yvYKzMOS.js → projection-zhu32_KJ.js} +1 -15
- package/dist/chunks/{query-LnTbQghF.js → query-D6xQbTFK.js} +0 -6
- package/dist/chunks/{refs-BLUokra5.js → refs-Csgh6rXq.js} +0 -4
- package/dist/chunks/{structure-BrKSgzRJ.js → structure-CKBtQHJq.js} +1 -7
- package/dist/chunks/{validate-B_g7719l.js → validate-BcB_PA1k.js} +2 -10
- package/dist/core.js +26 -26
- package/dist/forms.js +1 -1
- package/dist/print.js +0 -24
- package/dist/react.js +9 -27
- package/dist/runtime.js +2 -12
- package/dist/styles.css +9 -15
- package/dist/testing.js +5 -21
- package/dist/theme.js +0 -10
- package/dist/types/catalog/check.d.ts +0 -13
- package/dist/types/core/actions.d.ts +0 -24
- package/dist/types/core/bundles/load.d.ts +0 -23
- package/dist/types/core/bundles/page-bundles.d.ts +0 -9
- package/dist/types/core/bundles/refs.d.ts +1 -28
- package/dist/types/core/bundles/resolve.d.ts +0 -10
- package/dist/types/core/cell-props.d.ts +0 -20
- package/dist/types/core/cells.d.ts +0 -21
- package/dist/types/core/data-context.d.ts +0 -22
- package/dist/types/core/diagnostics.d.ts +1 -3
- package/dist/types/core/graph.d.ts +0 -54
- package/dist/types/core/index.d.ts +1 -0
- package/dist/types/core/layers.d.ts +8 -0
- package/dist/types/core/layers.gen.d.ts +12 -0
- package/dist/types/core/layout.d.ts +0 -9
- package/dist/types/core/load-page.d.ts +0 -111
- package/dist/types/core/query.d.ts +0 -64
- package/dist/types/core/references.d.ts +0 -21
- package/dist/types/core/release.d.ts +0 -10
- package/dist/types/core/rules.d.ts +0 -1
- package/dist/types/core/selected.d.ts +0 -5
- package/dist/types/core/sources.d.ts +5 -64
- package/dist/types/core/store/create-store.d.ts +0 -6
- package/dist/types/core/store/persistence.d.ts +0 -1
- package/dist/types/core/store/projection.d.ts +0 -5
- package/dist/types/core/store/scope-keys.d.ts +0 -1
- package/dist/types/core/store/types.d.ts +0 -6
- package/dist/types/core/structure.d.ts +0 -33
- package/dist/types/core/types.d.ts +0 -13
- package/dist/types/core/validate.d.ts +0 -12
- package/dist/types/core/values.d.ts +0 -6
- package/dist/types/forms/conditions.d.ts +0 -37
- package/dist/types/forms/index.d.ts +1 -0
- package/dist/types/forms/model.d.ts +4 -48
- package/dist/types/forms/port.d.ts +0 -22
- package/dist/types/forms/section.d.ts +22 -0
- package/dist/types/print/document-bindings.d.ts +0 -61
- package/dist/types/print/document-profile.d.ts +0 -137
- package/dist/types/print/map-staleness.d.ts +0 -66
- package/dist/types/print/page-map.d.ts +1 -334
- package/dist/types/print/paginate.d.ts +0 -190
- package/dist/types/print/print-layout.d.ts +0 -161
- package/dist/types/print/print-lint.d.ts +0 -109
- package/dist/types/print/print-policy.d.ts +0 -184
- package/dist/types/print/print-stylesheet.d.ts +0 -135
- package/dist/types/print/running-header.d.ts +0 -86
- package/dist/types/print/structure-print.d.ts +1 -243
- package/dist/types/react/cell-states.d.ts +0 -2
- package/dist/types/react/cell-view.d.ts +0 -16
- package/dist/types/react/page-renderer.d.ts +0 -37
- package/dist/types/react/structure-view.d.ts +0 -12
- package/dist/types/react/use-cell-store.d.ts +0 -5
- package/dist/types/react/use-container-size.d.ts +0 -5
- package/dist/types/react/use-forms-runtime.d.ts +2 -55
- package/dist/types/react/use-paging.d.ts +0 -9
- package/dist/types/runtime/boot.d.ts +0 -11
- package/dist/types/runtime/install.d.ts +0 -15
- package/dist/types/runtime/shims.d.ts +0 -8
- package/dist/types/runtime/store-export.d.ts +0 -7
- package/dist/types/testing/base-props.d.ts +0 -1
- package/dist/types/testing/components.d.ts +0 -8
- package/dist/types/testing/form-workbook.d.ts +0 -3
- package/dist/types/testing/golden.d.ts +0 -16
- package/dist/types/testing/ids.d.ts +0 -2
- package/dist/types/testing/sources.d.ts +0 -7
- package/dist/types/theme/check.d.ts +0 -2
- package/dist/types/theme/color.d.ts +0 -12
- package/dist/types/theme/derive.d.ts +0 -12
- package/dist/types/theme/parse.d.ts +0 -7
- package/package.json +2 -2
- package/dist/catalog.js.map +0 -1
- package/dist/chunks/forms-CCAE7sCu.js.map +0 -1
- package/dist/chunks/load-CjPvISzH.js.map +0 -1
- package/dist/chunks/page-bundles-DLRIBP8g.js.map +0 -1
- package/dist/chunks/persistence-DCMakM9H.js.map +0 -1
- package/dist/chunks/projection-yvYKzMOS.js.map +0 -1
- package/dist/chunks/query-LnTbQghF.js.map +0 -1
- package/dist/chunks/refs-BLUokra5.js.map +0 -1
- package/dist/chunks/structure-BrKSgzRJ.js.map +0 -1
- package/dist/chunks/validate-B_g7719l.js.map +0 -1
- package/dist/core.js.map +0 -1
- package/dist/print.js.map +0 -1
- package/dist/react.js.map +0 -1
- package/dist/runtime.js.map +0 -1
- package/dist/testing.js.map +0 -1
- package/dist/theme.js.map +0 -1
|
@@ -1,59 +1,23 @@
|
|
|
1
1
|
import { type QueryDescriptor, type QueryOrderBy } from '@peripheries/runtime';
|
|
2
2
|
import type { Diagnostic } from './graph.js';
|
|
3
3
|
import { type ResolutionContext } from './references.js';
|
|
4
|
-
/**
|
|
5
|
-
* Functions a render-time document may read, with the tables each reads (for
|
|
6
|
-
* invalidation). pg_graphql reflects every stable function the role can run
|
|
7
|
-
* as a Query field, and many are SECURITY DEFINER, so a function is allowed
|
|
8
|
-
* only by name, once a database test has pinned it as stable, SECURITY
|
|
9
|
-
* INVOKER, closed to anon and with a fixed search_path
|
|
10
|
-
* (tests/integration/graph-reads.test.ts).
|
|
11
|
-
*/
|
|
12
4
|
export declare const RENDER_FUNCTIONS: Readonly<Record<string, readonly string[]>>;
|
|
13
|
-
/**
|
|
14
|
-
* Render functions declared before the schema milestone that brings them, by milestone: a
|
|
15
|
-
* document may name one now, and it reads nothing until the function exists. The database test
|
|
16
|
-
* checks each like the rest once it exists, and fails if its milestone is in and it still isn't.
|
|
17
|
-
*/
|
|
18
5
|
export declare const RENDER_FUNCTIONS_AHEAD: Readonly<Record<string, string>>;
|
|
19
6
|
export type PreparedDocument = {
|
|
20
7
|
text: string;
|
|
21
8
|
operationName: string | undefined;
|
|
22
|
-
/** Root entity names, e.g. `project_page` for `project_pageCollection`; `*` for `node`; a render function's tables. */
|
|
23
9
|
entities: readonly string[];
|
|
24
|
-
/** Stable short hash of the prepared text; part of query keys. */
|
|
25
10
|
hash: string;
|
|
26
11
|
};
|
|
27
12
|
export declare class UnsafeDocumentError extends Error {
|
|
28
13
|
name: string;
|
|
29
|
-
/** The diagnostic a descriptor's check reports; DESCRIPTOR_DOCUMENT_INVALID when unset. */
|
|
30
14
|
readonly code?: 'DESCRIPTOR_VERSION_FILTER' | 'DESCRIPTOR_STATE_UNSCOPED';
|
|
31
15
|
constructor(message: string, options?: {
|
|
32
16
|
code: 'DESCRIPTOR_VERSION_FILTER' | 'DESCRIPTOR_STATE_UNSCOPED';
|
|
33
17
|
});
|
|
34
18
|
}
|
|
35
|
-
/**
|
|
36
|
-
* The collections a render-time document reads main rows of only (versions.md §4.6, graph-model
|
|
37
|
-
* G1 · DF M0): prepareDocument adds `version: { is: NULL }` to each one's filter, at any depth.
|
|
38
|
-
* A branch is read through a version context, never a hand-written filter, so a document that
|
|
39
|
-
* filters on `version` itself is refused.
|
|
40
|
-
*/
|
|
41
19
|
export declare const MAIN_ONLY_COLLECTIONS: ReadonlySet<string>;
|
|
42
|
-
/**
|
|
43
|
-
* A GraphQL document checked against the render-time rule (design/renderer.md
|
|
44
|
-
* §4.5) and ready to send: exactly one `query` operation whose root fields are
|
|
45
|
-
* table or view collections, `ByPk` reads, `node`, or a render function.
|
|
46
|
-
* `__typename` is added to every nested selection, so a host can find JSON
|
|
47
|
-
* columns in the result. Throws UnsafeDocumentError.
|
|
48
|
-
*/
|
|
49
20
|
export declare function prepareDocument(source: string): PreparedDocument;
|
|
50
|
-
/**
|
|
51
|
-
* The shape of a query's result, from its selection alone (design/data.md
|
|
52
|
-
* §2.1): a field without a selection set is a `leaf` (a scalar, a JSON column
|
|
53
|
-
* or an array column, so any path below it may exist); `edges { node }` is a
|
|
54
|
-
* list. With `flatten_connections`, a connection that selects edges is the
|
|
55
|
-
* list of its nodes, as the host shapes it.
|
|
56
|
-
*/
|
|
57
21
|
export type SelectionShape = {
|
|
58
22
|
kind: 'leaf';
|
|
59
23
|
} | {
|
|
@@ -63,53 +27,25 @@ export type SelectionShape = {
|
|
|
63
27
|
kind: 'list';
|
|
64
28
|
of: SelectionShape;
|
|
65
29
|
};
|
|
66
|
-
/** The shape a document's selection yields, before `result.path`. */
|
|
67
30
|
export declare function selectionShape(document: string, flatten?: boolean): SelectionShape;
|
|
68
|
-
/**
|
|
69
|
-
* The shape at a dot path, or null when the selection doesn't select it. A
|
|
70
|
-
* numeric segment indexes a list; anything below a leaf is accepted.
|
|
71
|
-
*/
|
|
72
31
|
export declare function shapeAt(shape: SelectionShape, path: readonly string[]): SelectionShape | null;
|
|
73
|
-
/** What a descriptor's label holds: its selection, flattened, at `result.path`. Null when the path isn't selected. */
|
|
74
32
|
export declare function descriptorShape(descriptor: QueryDescriptor): SelectionShape | null;
|
|
75
|
-
/** Namespaces a variable may read, besides labels (design/data.md §5). */
|
|
76
33
|
export declare const VARIABLE_NAMESPACES: readonly ["params", "baseProps", "viewer", "context"];
|
|
77
|
-
/** Every whole-string reference in a descriptor's variables, by the label or namespace it reads. */
|
|
78
34
|
export declare function variableReferences(variables: unknown): Array<{
|
|
79
35
|
ref: string;
|
|
80
36
|
label: string;
|
|
81
37
|
}>;
|
|
82
|
-
/** The labels (not namespaces) a descriptor's variables read: what decides its round (design/data.md §5, §6). */
|
|
83
38
|
export declare const variableLabels: (descriptor: Pick<QueryDescriptor, "variables">) => string[];
|
|
84
|
-
/**
|
|
85
|
-
* A descriptor's static checks (design/data.md §4): the version-1 shape, one
|
|
86
|
-
* query operation under the render-time rule, every required variable given
|
|
87
|
-
* (`$orderBy` by `order_by`), references well formed, and `result.path`
|
|
88
|
-
* selected. It doesn't run anything; a dry run under a real viewer checks the
|
|
89
|
-
* rest against the database. `path` prefixes each diagnostic's path.
|
|
90
|
-
*/
|
|
91
39
|
export declare function validateDescriptor(descriptor: unknown, path?: string): Diagnostic[];
|
|
92
|
-
/** `order_by` as pg_graphql's `orderBy` argument: `[{ updated_at: DescNullsLast }]`. */
|
|
93
40
|
export declare const orderByVariable: (orderBy: readonly QueryOrderBy[]) => {
|
|
94
41
|
[x: string]: string;
|
|
95
42
|
}[];
|
|
96
43
|
export type ResolvedVariables = {
|
|
97
44
|
variables: Record<string, unknown>;
|
|
98
|
-
/** References that resolved to nothing (null or undefined): the query doesn't run (QUERY_UNRESOLVED). */
|
|
99
45
|
unresolved: string[];
|
|
100
|
-
/** References whose data is still loading: the query waits. */
|
|
101
46
|
pending: string[];
|
|
102
47
|
};
|
|
103
|
-
/**
|
|
104
|
-
* A descriptor's variables, resolved with the one reference grammar (the same
|
|
105
|
-
* resolver as props), plus `$orderBy` from `order_by` when the document
|
|
106
|
-
* declares it. A whole-string reference that resolves to null or nothing is
|
|
107
|
-
* unresolved; interpolation (`${x}`) works as in props.
|
|
108
|
-
*/
|
|
109
48
|
export declare function resolveDescriptorVariables(descriptor: QueryDescriptor, ctx: ResolutionContext): ResolvedVariables;
|
|
110
|
-
/** The variables a paged descriptor's document declares and the renderer sets. */
|
|
111
49
|
export declare const PAGING_VARIABLES: ReadonlySet<string>;
|
|
112
|
-
/** A paged descriptor's variables for one page: `$first` its size, `$after` the cursor (null for the first page). */
|
|
113
50
|
export declare const pageVariables: (descriptor: QueryDescriptor, variables: Record<string, unknown>, after?: string | null) => Record<string, unknown>;
|
|
114
|
-
/** One query per distinct question: the document and the resolved variables, and the result's shape. */
|
|
115
51
|
export declare const queryKey: (descriptor: QueryDescriptor, variables: Record<string, unknown>) => string;
|
|
@@ -3,16 +3,11 @@ import type { DataContext } from './types.js';
|
|
|
3
3
|
export type ResolutionContext = {
|
|
4
4
|
data: DataContext;
|
|
5
5
|
params: Record<string, unknown>;
|
|
6
|
-
/** Told of each whole-string `@ref` that resolves to nothing (a missing label, path or leaf), except while its data loads. */
|
|
7
6
|
onUnresolved?: (ref: string) => void;
|
|
8
|
-
/** Told of each whole-string `@ref` whose data is still loading. */
|
|
9
7
|
onLoading?: (ref: string) => void;
|
|
10
|
-
/** Told of each resolved leaf, by its prop path, with where its value came from (INV-DOC-6; sources.ts). */
|
|
11
8
|
onSource?: OnSource;
|
|
12
9
|
};
|
|
13
|
-
/** The key that marks a projection: `{ "@each": "@label.path", "as": "item", "map": … }`. */
|
|
14
10
|
export declare const EACH = "@each";
|
|
15
|
-
/** The element's label inside `map` when `as` is not given. */
|
|
16
11
|
export declare const EACH_DEFAULT_AS = "item";
|
|
17
12
|
export type Each = {
|
|
18
13
|
[EACH]: string;
|
|
@@ -20,17 +15,12 @@ export type Each = {
|
|
|
20
15
|
map: unknown;
|
|
21
16
|
};
|
|
22
17
|
export declare const isEach: (value: unknown) => value is Each;
|
|
23
|
-
/**
|
|
24
|
-
* Resolve every string in a value, recursively through arrays and plain objects. Keys aren't
|
|
25
|
-
* resolved. `at` is the value's path among the props, for `onSource`.
|
|
26
|
-
*/
|
|
27
18
|
export declare function resolveReferences<T = unknown>(value: T, ctx: ResolutionContext, at?: string[]): T;
|
|
28
19
|
export declare const settled: (data: unknown) => {
|
|
29
20
|
data: unknown;
|
|
30
21
|
isLoading: boolean;
|
|
31
22
|
error: null;
|
|
32
23
|
};
|
|
33
|
-
/** What a cell brings to its own resolution (loadPageData's CellData), and the labels the page declares. */
|
|
34
24
|
export type CellScope = {
|
|
35
25
|
static?: DataContext;
|
|
36
26
|
declared?: DataContext;
|
|
@@ -43,14 +33,6 @@ export type CellScope = {
|
|
|
43
33
|
};
|
|
44
34
|
pageDeclared?: ReadonlySet<string>;
|
|
45
35
|
};
|
|
46
|
-
/**
|
|
47
|
-
* The context one cell resolves against (design/renderer.md §5.2), lowest
|
|
48
|
-
* first: the page's static values, the cell's own static values, the labels
|
|
49
|
-
* the cell's walk found, the page's declarations, the cell's own
|
|
50
|
-
* declarations; then the reserved
|
|
51
|
-
* `_traversal`, `params`, `baseProps`, `viewer` and `context`, which nothing
|
|
52
|
-
* can shadow. Explicit beats discovered: no walk label replaces a declared one.
|
|
53
|
-
*/
|
|
54
36
|
export declare function cellResolutionContext(_cell: {
|
|
55
37
|
data?: {
|
|
56
38
|
queries?: Record<string, unknown>;
|
|
@@ -59,7 +41,6 @@ export declare function cellResolutionContext(_cell: {
|
|
|
59
41
|
viewer?: unknown;
|
|
60
42
|
context?: unknown;
|
|
61
43
|
}): ResolutionContext;
|
|
62
|
-
/** The location context every cell on a page shares (core.md §8): the host's, with the page's own ids. */
|
|
63
44
|
export declare const pageContext: (context: Record<string, unknown> | undefined, page: {
|
|
64
45
|
id: string;
|
|
65
46
|
project_id: string | null;
|
|
@@ -69,14 +50,12 @@ export declare const pageContext: (context: Record<string, unknown> | undefined,
|
|
|
69
50
|
projectId: string | null;
|
|
70
51
|
processId: string | null;
|
|
71
52
|
};
|
|
72
|
-
/** One cell's location context: the page's, with the cell's own node. */
|
|
73
53
|
export declare const cellContext: (context: Record<string, unknown>, cell: {
|
|
74
54
|
graph_node_id?: string;
|
|
75
55
|
metadata?: Record<string, unknown>;
|
|
76
56
|
}) => {
|
|
77
57
|
nodeId: string | undefined;
|
|
78
58
|
};
|
|
79
|
-
/** showIf / hideIf: values (usually strict refs) tested for truthiness. An empty string skips the check. */
|
|
80
59
|
export declare function passesConditions(conditions: {
|
|
81
60
|
showIf?: unknown;
|
|
82
61
|
hideIf?: unknown;
|
|
@@ -1,21 +1,11 @@
|
|
|
1
1
|
import type { ReleaseProblem } from '@peripheries/runtime';
|
|
2
2
|
import type { ProjectPage } from './types.js';
|
|
3
3
|
import { type Catalog } from './validate.js';
|
|
4
|
-
/** One page the release records: the node it lives on (the anchor, or its artifact) and its document. */
|
|
5
4
|
export type ManifestPage = {
|
|
6
5
|
graphNodeId: string;
|
|
7
6
|
page: Pick<ProjectPage, 'content' | 'layout'> & {
|
|
8
7
|
is_template?: boolean | null;
|
|
9
8
|
};
|
|
10
9
|
};
|
|
11
|
-
/** The pages' errors as VERSION_INVALID's problems: a release that has any isn't cut. Warnings don't stop one. */
|
|
12
10
|
export declare function validateManifest(pages: ManifestPage[], catalog?: Catalog): ReleaseProblem[];
|
|
13
|
-
/**
|
|
14
|
-
* A page artifact's data state as a ManifestPage (pages.md §2): the artifact's `data` is the page
|
|
15
|
-
* document itself (`cells`, `data`, page configuration such as `layout.editing`), each cell
|
|
16
|
-
* carrying the `layout_entry` the publish splits into the row's `layout.structure`. So the
|
|
17
|
-
* document is the content, and a `layout` key, when the artifact has one, the layout. The
|
|
18
|
-
* structure isn't rebuilt from the entries (the publish's split), so STRUCTURE_INVALID is judged
|
|
19
|
-
* at publish, not here.
|
|
20
|
-
*/
|
|
21
11
|
export declare function manifestPageFrom(graphNodeId: string, data: unknown): ManifestPage;
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import type { QueryDescriptor } from '@peripheries/runtime';
|
|
2
2
|
import type { Diagnostic } from './graph.js';
|
|
3
3
|
import type { PageCell } from './types.js';
|
|
4
|
-
/**
|
|
5
|
-
* The paths one cell's props and conditions read from the given query labels
|
|
6
|
-
* that the queries don't select. Inside an `@each` over a query's list, the
|
|
7
|
-
* element's paths are checked against the list's element. `at` prefixes paths.
|
|
8
|
-
*/
|
|
9
4
|
export declare function selectionIssues(cell: Pick<PageCell, 'id' | 'props' | 'conditions'>, queries: Record<string, QueryDescriptor>, at: string): Diagnostic[];
|
|
@@ -2,47 +2,29 @@ import { type VersionContext } from '@peripheries/runtime';
|
|
|
2
2
|
import type { CellSource, ResolvedCell } from './cells.js';
|
|
3
3
|
import type { PageRuntime } from './load-page.js';
|
|
4
4
|
import type { StateOrigin } from './types.js';
|
|
5
|
-
|
|
6
|
-
export type PropSource =
|
|
7
|
-
/** A node's state (a declared binding, or an element of an `@each` over one): `path` is inside the state's data. */
|
|
8
|
-
{
|
|
5
|
+
export type PropSource = {
|
|
9
6
|
kind: 'state';
|
|
10
7
|
graphNodeId: string;
|
|
11
8
|
reads: StateOrigin[];
|
|
12
9
|
path: string[];
|
|
13
|
-
}
|
|
14
|
-
/** A literal in the cell's props, at its prop path. */
|
|
15
|
-
| {
|
|
10
|
+
} | {
|
|
16
11
|
kind: 'literal';
|
|
17
12
|
path: string[];
|
|
18
|
-
}
|
|
19
|
-
/** A literal in the page's or the cell's static data (`data.static`): `path` starts with its label. */
|
|
20
|
-
| {
|
|
13
|
+
} | {
|
|
21
14
|
kind: 'static';
|
|
22
15
|
scope: 'page' | 'cell';
|
|
23
16
|
path: string[];
|
|
24
|
-
}
|
|
25
|
-
/** Computed, queried, walked or the host's own: not editable. */
|
|
26
|
-
| {
|
|
17
|
+
} | {
|
|
27
18
|
kind: 'derived';
|
|
28
19
|
why: 'query' | 'walk' | 'record' | 'param' | 'reserved';
|
|
29
20
|
};
|
|
30
|
-
/** A prop path (`['items', '0', 'title']`) and its source. */
|
|
31
21
|
export type PropSourceEntry = {
|
|
32
22
|
prop: string[];
|
|
33
23
|
source: PropSource;
|
|
34
24
|
};
|
|
35
|
-
/** Told of each leaf of a cell's resolved props, with its source. */
|
|
36
25
|
export type OnSource = (prop: string[], source: PropSource) => void;
|
|
37
|
-
/** Keys under a state that only the agency's tools write (data.md §9.5). */
|
|
38
26
|
export declare const TOOL_OWNED_KEYS: readonly ["content_index", "ref_index"];
|
|
39
|
-
/** A section's fields a person edits on the structure itself (data.md §9.5, `doc_edit_structure`). */
|
|
40
27
|
export declare const STRUCTURE_FIELDS: readonly ["title", "applicable", "startsPage", "directed", "status"];
|
|
41
|
-
/**
|
|
42
|
-
* Where an edit of a value goes: the write function and the arguments that come from the source.
|
|
43
|
-
* The new value (and, for a page edit, the version seen) is the caller's. `fn: null` says why the
|
|
44
|
-
* value can't be edited here; the write functions still decide everything that can.
|
|
45
|
-
*/
|
|
46
28
|
export type EditTarget = ({
|
|
47
29
|
fn: 'doc_edit_content';
|
|
48
30
|
graphNodeId: string;
|
|
@@ -61,59 +43,18 @@ export type EditTarget = ({
|
|
|
61
43
|
fn: 'page_edit_data';
|
|
62
44
|
path: string[];
|
|
63
45
|
}) & {
|
|
64
|
-
/** The branch the edit writes (`p_version_id`, versions.md §4.3); absent on main. */
|
|
65
46
|
versionId?: string;
|
|
66
47
|
} | {
|
|
67
48
|
fn: null;
|
|
68
49
|
reason: EditRefusal;
|
|
69
50
|
};
|
|
70
|
-
export type EditRefusal =
|
|
71
|
-
/** Computed, queried or walked: nothing holds it to edit. */
|
|
72
|
-
'DERIVED'
|
|
73
|
-
/** The cell's content is its node's `page_cell_config`, not the page's. */
|
|
74
|
-
| 'NODE_CONFIG'
|
|
75
|
-
/** A `data.static` literal of a cell whose content is its node's (NODE_CONFIG's case for static data). */
|
|
76
|
-
| 'STATIC'
|
|
77
|
-
/** The read didn't say which state it saw, so no version check is possible. */
|
|
78
|
-
| 'NO_STATE_ID'
|
|
79
|
-
/** The value merges more than one system's state, so which one to write is ambiguous. */
|
|
80
|
-
| 'MERGED_READS'
|
|
81
|
-
/** Not a data state (`<tier>_data`): the document write functions write data states only. */
|
|
82
|
-
| 'NOT_DATA_STATE'
|
|
83
|
-
/** A tool-owned index (`content_index`, `ref_index`). */
|
|
84
|
-
| 'TOOL_OWNED'
|
|
85
|
-
/**
|
|
86
|
-
* An element of a list the write functions refused: a path whose index names no element
|
|
87
|
-
* (`jsonb_set_path`). The host no longer refuses list paths itself: the functions write at a
|
|
88
|
-
* path into a list (DF-SCH-9), and their dry run says whether the element exists.
|
|
89
|
-
*/
|
|
90
|
-
| 'LIST_ELEMENT'
|
|
91
|
-
/** Read at a release or a channel (or another scope's published version): releases are read-only (versions.md §5.3). */
|
|
92
|
-
| 'VERSION_IS_RELEASE';
|
|
93
|
-
/** The cell a value is in, and how its content was resolved (ResolvedCell.source). */
|
|
51
|
+
export type EditRefusal = 'DERIVED' | 'NODE_CONFIG' | 'STATIC' | 'NO_STATE_ID' | 'MERGED_READS' | 'NOT_DATA_STATE' | 'TOOL_OWNED' | 'LIST_ELEMENT' | 'VERSION_IS_RELEASE';
|
|
94
52
|
export type EditCell = {
|
|
95
53
|
id: string;
|
|
96
54
|
source?: CellSource;
|
|
97
55
|
};
|
|
98
|
-
/**
|
|
99
|
-
* The write function an edit of this value goes to (design/data.md §9.5):
|
|
100
|
-
* - a node's data state: a section's structure field or `order` to `doc_edit_structure`,
|
|
101
|
-
* anything else to `doc_edit_content`, with the state id the viewer saw;
|
|
102
|
-
* - a literal in an inline cell, or its own `data.static`, to `page_edit_cell`'s path write, which
|
|
103
|
-
* writes the page artifact and the row together;
|
|
104
|
-
* - the page's `data.static` to `page_edit_data`'s path write;
|
|
105
|
-
* - everything else nowhere, with the reason.
|
|
106
|
-
* Paths may run through list indices: the functions write at a path into a list (DF-SCH-9).
|
|
107
|
-
*/
|
|
108
56
|
export declare function editTarget(source: PropSource, cell: EditCell, version?: VersionContext): EditTarget;
|
|
109
|
-
/** A value at a path, as the nested object a patch is (`['props', 'caption']` → `{ props: { caption } }`). */
|
|
110
57
|
export declare function patchAt(path: readonly string[], value: unknown): unknown;
|
|
111
|
-
/**
|
|
112
|
-
* One cell's props as the renderer resolves them (CellView), with each leaf's source and value,
|
|
113
|
-
* without rendering: what an assistant reads to plan an edit (docs-forms M3). Null when the cell's
|
|
114
|
-
* conditions hide it. The same resolution context CellView builds, from the same runtime; paged
|
|
115
|
-
* labels' later pages aren't loaded, so a paged list reads its first page.
|
|
116
|
-
*/
|
|
117
58
|
export declare function cellPropSources(runtime: Pick<PageRuntime, 'page' | 'data' | 'declared' | 'cellData'>, cell: ResolvedCell, env?: {
|
|
118
59
|
params?: Record<string, unknown>;
|
|
119
60
|
baseProps?: unknown;
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import { Store } from '@tanstack/store';
|
|
2
2
|
import type { LiveEntry, ScopeId, SelectionsScope, StackStoreData, StackStoreState, ViewStateScope } from './types.js';
|
|
3
3
|
export type StackStoreApi = ReturnType<typeof createStackStore>;
|
|
4
|
-
/**
|
|
5
|
-
* The shared store, on TanStack Store (design/bundles.md §5). One instance per
|
|
6
|
-
* page tree. `getState()` returns the data with the actions, the shape the
|
|
7
|
-
* PWA's zustand store exposed to the escape-hatch API.
|
|
8
|
-
*/
|
|
9
4
|
export declare function createStackStore(initial?: Partial<StackStoreData>): {
|
|
10
5
|
getState: () => StackStoreState;
|
|
11
6
|
subscribe: (listener: (state: StackStoreState) => void) => import("@tanstack/store").Subscription;
|
|
@@ -22,6 +17,5 @@ export declare function createStackStore(initial?: Partial<StackStoreData>): {
|
|
|
22
17
|
};
|
|
23
18
|
_clearScope: (scope: ScopeId) => void;
|
|
24
19
|
_reset: () => void;
|
|
25
|
-
/** The underlying TanStack store, for `useSelector`. */
|
|
26
20
|
store: Store<StackStoreData, never>;
|
|
27
21
|
};
|
|
@@ -7,5 +7,4 @@ export interface PersistedScope {
|
|
|
7
7
|
export declare function loadScope(scope: ScopeId, mode: StorageMode): PersistedScope | null;
|
|
8
8
|
export declare function saveScope(scope: ScopeId, slice: PersistedScope, mode: StorageMode): void;
|
|
9
9
|
export declare function clearScope(scope: ScopeId, mode: StorageMode): void;
|
|
10
|
-
/** Removes every persisted scope from session and local storage: a different viewer starts clean. */
|
|
11
10
|
export declare function clearAllScopes(): void;
|
|
@@ -2,14 +2,9 @@ import type { StackStoreApi } from './create-store.js';
|
|
|
2
2
|
import { type ScopeContext } from './scope-keys.js';
|
|
3
3
|
import type { LiveDeclarations, ProjectedBundle, ScopeId, SelectionDeclarations, StackStoreData, ViewStateDeclarations } from './types.js';
|
|
4
4
|
export declare function projectSelections(decls: SelectionDeclarations | undefined, state: StackStoreData, ctx: ScopeContext): ProjectedBundle | undefined;
|
|
5
|
-
/** Selections are read-only unless `writable`. */
|
|
6
5
|
export declare function attachSelectionSetters(values: ProjectedBundle, decls: SelectionDeclarations, store: StackStoreApi, ctx: ScopeContext): ProjectedBundle;
|
|
7
6
|
export declare function projectViewState(decls: ViewStateDeclarations | undefined, state: StackStoreData, ctx: ScopeContext): ProjectedBundle | undefined;
|
|
8
|
-
/** viewState is writable unless `writable: false`. */
|
|
9
7
|
export declare function attachViewStateSetters(values: ProjectedBundle, decls: ViewStateDeclarations, store: StackStoreApi, ctx: ScopeContext): ProjectedBundle;
|
|
10
|
-
/** `live.<name>` is the data; `live.<name>Status` the envelope. */
|
|
11
8
|
export declare function projectLive(decls: LiveDeclarations | undefined, state: StackStoreData): ProjectedBundle | undefined;
|
|
12
|
-
/** Equality for a selector: re-render only when a projected channel changes. */
|
|
13
9
|
export declare function shallowEqualBundle(a: ProjectedBundle | undefined, b: ProjectedBundle | undefined): boolean;
|
|
14
|
-
/** Every scope a cell's declarations touch (for hydration and persistence). */
|
|
15
10
|
export declare function collectScopeIds(ctx: ScopeContext, selections?: SelectionDeclarations, viewState?: ViewStateDeclarations): ScopeId[];
|
|
@@ -11,14 +11,11 @@ export interface LiveEntry<T = unknown> {
|
|
|
11
11
|
export interface StackStoreData {
|
|
12
12
|
selections: Record<ScopeId, SelectionsScope>;
|
|
13
13
|
viewState: Record<ScopeId, ViewStateScope>;
|
|
14
|
-
/** Global, not scoped: a channel is one source. */
|
|
15
14
|
live: Record<string, LiveEntry>;
|
|
16
15
|
}
|
|
17
16
|
export interface StackStoreActions {
|
|
18
|
-
/** Cell-facing, through projected setter props. */
|
|
19
17
|
setSelection: (scope: ScopeId, channel: string, value: unknown) => void;
|
|
20
18
|
setViewState: (scope: ScopeId, key: string, value: unknown) => void;
|
|
21
|
-
/** Host-internal. */
|
|
22
19
|
_setLive: (channel: string, entry: LiveEntry) => void;
|
|
23
20
|
_hydrateScope: (scope: ScopeId, slice: {
|
|
24
21
|
selections?: SelectionsScope;
|
|
@@ -29,11 +26,8 @@ export interface StackStoreActions {
|
|
|
29
26
|
viewState: ViewStateScope;
|
|
30
27
|
};
|
|
31
28
|
_clearScope: (scope: ScopeId) => void;
|
|
32
|
-
/** Empties selections, view state and live data: a different viewer starts clean. */
|
|
33
29
|
_reset: () => void;
|
|
34
30
|
}
|
|
35
|
-
/** What a selector sees: the data plus the actions, as the PWA's zustand store exposed. */
|
|
36
31
|
export type StackStoreState = StackStoreData & StackStoreActions;
|
|
37
32
|
export type { LiveDecl, LiveDeclarations, SelectionDecl, SelectionDeclarations, ViewStateDecl, ViewStateDeclarations, } from '@peripheries/runtime';
|
|
38
|
-
/** Spread onto a cell's `selections` / `viewState` / `live` props. */
|
|
39
33
|
export type ProjectedBundle = Record<string, unknown>;
|
|
@@ -5,28 +5,17 @@ export type { LayoutNode, SectionKind, SectionReference };
|
|
|
5
5
|
export type ResolvedLayoutNode = Omit<LayoutNode, 'children'> & {
|
|
6
6
|
children?: ResolvedLayoutNode[];
|
|
7
7
|
};
|
|
8
|
-
/** The page's own document, which almost every page is. */
|
|
9
8
|
export declare const PAGE_DOCUMENT = "__page__";
|
|
10
|
-
/** A string child is sugar for `{ cellId }`. */
|
|
11
9
|
export declare function normalizeStructure(nodes: ReadonlyArray<LayoutNode | string> | null | undefined): ResolvedLayoutNode[];
|
|
12
|
-
/** Siblings by `order` (default 0), stable. */
|
|
13
10
|
export declare const sortByOrder: <T extends {
|
|
14
11
|
order?: number;
|
|
15
12
|
}>(nodes: readonly T[]) => T[];
|
|
16
13
|
export declare const isSectionNode: (n: ResolvedLayoutNode) => boolean;
|
|
17
14
|
export declare const isSectionKind: (v: unknown) => v is SectionKind;
|
|
18
|
-
/** A section's anchor: its cell, else its section id (the same value `DocumentSection` and the contents use). */
|
|
19
15
|
export declare const sectionAnchor: (n: Pick<ResolvedLayoutNode, "cellId" | "sectionId">) => string;
|
|
20
|
-
/**
|
|
21
|
-
* Hierarchical rendering when the structure wants it: `type: 'document'`, or
|
|
22
|
-
* any top-level node naming a section or carrying children. A flat list of
|
|
23
|
-
* `{ cellId }` is only an ordering hint for print, and renders flat.
|
|
24
|
-
*/
|
|
25
16
|
export declare function usesStructureLayout(layout: Record<string, unknown> | null | undefined): boolean;
|
|
26
17
|
export type DocumentNumbering = {
|
|
27
|
-
/** Only `kind: 'article'` sections are numbered, per document, prefixed by the parent trail. */
|
|
28
18
|
numbers: Record<string, number[]>;
|
|
29
|
-
/** Structural depth of each section. */
|
|
30
19
|
levels: Record<string, number>;
|
|
31
20
|
authoredLevels: Record<string, number>;
|
|
32
21
|
titles: Record<string, string>;
|
|
@@ -42,35 +31,19 @@ export type SectionNumbering = {
|
|
|
42
31
|
};
|
|
43
32
|
export declare const numberingFor: (numbering: SectionNumbering | undefined, documentId: string | undefined) => DocumentNumbering;
|
|
44
33
|
export declare function deriveSectionNumbering(structure: ReadonlyArray<LayoutNode | string> | null | undefined): SectionNumbering;
|
|
45
|
-
/** Per document: every target a cell in it may cite, by role (`residue`), `label:role`, or `role#clause`. */
|
|
46
34
|
export type SectionReferences = Record<string, Record<string, SectionReference>>;
|
|
47
35
|
type Documents = Record<string, {
|
|
48
36
|
label?: unknown;
|
|
49
37
|
}> | null | undefined;
|
|
50
|
-
/** Same-page section references: a document's own roles, plus `label:role` for every uniquely labelled document. */
|
|
51
38
|
export declare function deriveSectionReferences(numbering: SectionNumbering, documents: Documents): SectionReferences;
|
|
52
|
-
/**
|
|
53
|
-
* Clause citations (`role#clauseId`): each section's cells' resolved
|
|
54
|
-
* `props.blocks`, where a `clause` block's items carry ids. The item's index
|
|
55
|
-
* and the clause shape let a Reference render the clause's number.
|
|
56
|
-
*/
|
|
57
39
|
export declare function deriveElementReferences(structure: ReadonlyArray<LayoutNode | string> | null | undefined, blocksByCellId: Readonly<Record<string, unknown>>, documents: Documents): SectionReferences;
|
|
58
|
-
/** Same-page references win over data-derived ones (clauses; cross-page arrive in R5). */
|
|
59
40
|
export declare function mergeSectionReferences(samePage: SectionReferences, other: SectionReferences | undefined): SectionReferences;
|
|
60
41
|
export declare const referencesFor: (refs: SectionReferences | undefined, documentId: string | undefined) => Record<string, SectionReference>;
|
|
61
|
-
/** What stops a structure rendering: a node naming a missing cell, or an unknown section kind (a refusal, by design). */
|
|
62
42
|
export declare function structureIssues(structure: ReadonlyArray<LayoutNode | string> | null | undefined, cells: PageCell[]): string[];
|
|
63
|
-
/**
|
|
64
|
-
* A node's extrinsic pagination: a page break before, keep-with-previous
|
|
65
|
-
* (break-before: avoid), or avoid breaking inside. `breakInside: 'auto'` is
|
|
66
|
-
* dropped, so a node can't relax what a component declares; a break before
|
|
67
|
-
* wins over keep-with-previous. The component's own @printPolicy joins in R5.
|
|
68
|
-
*/
|
|
69
43
|
export declare function nodePrintStyle(node: Pick<LayoutNode, 'print'>): {
|
|
70
44
|
breakBefore?: 'page' | 'avoid';
|
|
71
45
|
breakInside?: 'avoid';
|
|
72
46
|
} | undefined;
|
|
73
|
-
/** One entry in a document's table of contents. */
|
|
74
47
|
export type ContentsEntry = {
|
|
75
48
|
sectionId: string;
|
|
76
49
|
anchor: string;
|
|
@@ -79,10 +52,4 @@ export type ContentsEntry = {
|
|
|
79
52
|
level: number;
|
|
80
53
|
children: ContentsEntry[];
|
|
81
54
|
};
|
|
82
|
-
/**
|
|
83
|
-
* A document's table of contents (INV-DOC-1): its sections in order, nested, with the numbers
|
|
84
|
-
* articles get and the anchors the page renders (`sectionAnchor`). A section's title is its
|
|
85
|
-
* structure node's, else its cell's `title` prop, else its id. `tocHidden` sections are left out,
|
|
86
|
-
* their children kept in their place. Only the page's own document.
|
|
87
|
-
*/
|
|
88
55
|
export declare function tableOfContents(structure: ReadonlyArray<LayoutNode | string> | null | undefined, cells?: ReadonlyArray<PageCell>): ContentsEntry[];
|
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
import type { DeclaredBinding, PageCell, QueryDescriptor } from '@peripheries/runtime';
|
|
2
|
-
/** One source in a DataContext: the value and its state. */
|
|
3
|
-
/** A paged label's position (QueryDescriptor.paging): what loading its next page needs. */
|
|
4
2
|
export type DataPage = {
|
|
5
3
|
hasMore: boolean;
|
|
6
4
|
endCursor: string | null;
|
|
7
5
|
descriptor: QueryDescriptor;
|
|
8
6
|
variables: Record<string, unknown>;
|
|
9
7
|
};
|
|
10
|
-
/**
|
|
11
|
-
* A label's read. `unresolved` names the references that resolved to nothing, so the query never
|
|
12
|
-
* ran (QUERY_UNRESOLVED): there is nothing to show yet, which is not a failed read.
|
|
13
|
-
*/
|
|
14
8
|
export type DataEntry = {
|
|
15
9
|
data: unknown;
|
|
16
10
|
isLoading: boolean;
|
|
@@ -19,7 +13,6 @@ export type DataEntry = {
|
|
|
19
13
|
unresolved?: string[];
|
|
20
14
|
origin?: DataOrigin;
|
|
21
15
|
};
|
|
22
|
-
/** A system a label's value was read from, and the newest state seen there (null: none, or the source doesn't say). */
|
|
23
16
|
export type StateOrigin = {
|
|
24
17
|
systemId: string;
|
|
25
18
|
name?: string;
|
|
@@ -27,12 +20,6 @@ export type StateOrigin = {
|
|
|
27
20
|
versionId?: string | null;
|
|
28
21
|
outOfScope?: boolean;
|
|
29
22
|
};
|
|
30
|
-
/**
|
|
31
|
-
* Where a label's value came from (INV-DOC-6), so an edit can go back to it (design/data.md §9.5).
|
|
32
|
-
* `at` is the path inside the source to the label's value: inside the state's data (a binding's
|
|
33
|
-
* `field`, an `@each` element's index), or the label and its path in the page's or cell's static data.
|
|
34
|
-
* A label without an origin was read some other way (a query): it isn't editable.
|
|
35
|
-
*/
|
|
36
23
|
export type DataOrigin = {
|
|
37
24
|
kind: 'state';
|
|
38
25
|
graphNodeId: string;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { type Diagnostic } from './graph.js';
|
|
2
2
|
import { type Each } from './references.js';
|
|
3
3
|
import type { PageCell, ProjectPage } from './types.js';
|
|
4
|
-
/** What validation knows about the components in scope. Stream 3 fills it from the catalog. */
|
|
5
4
|
export type Catalog = {
|
|
6
5
|
components: Record<string, {
|
|
7
6
|
props_schema?: {
|
|
@@ -11,34 +10,23 @@ export type Catalog = {
|
|
|
11
10
|
} | null;
|
|
12
11
|
} | undefined>;
|
|
13
12
|
};
|
|
14
|
-
/**
|
|
15
|
-
* The names nearest a name that isn't in scope, nearest first: a near spelling
|
|
16
|
-
* (`Prse`), or each of its words starting a word of the name (`DocSection` →
|
|
17
|
-
* `DocumentSection`). Full-text search can't find either.
|
|
18
|
-
*/
|
|
19
13
|
export declare function nearestNames(name: string, names: Iterable<string>, limit?: number): string[];
|
|
20
14
|
export declare const RESPONSIVE_BUCKETS: readonly ["narrow", "compact", "wide"];
|
|
21
15
|
export declare const STORE_SCOPES: readonly ["page", "project"];
|
|
22
16
|
export declare const WALK_DIRECTIONS: readonly ["incoming", "outgoing", "both"];
|
|
23
|
-
/** Options: `template` for a page template, whose node bindings are filled when it is instantiated. */
|
|
24
17
|
export type ValidateOptions = {
|
|
25
18
|
template?: boolean;
|
|
26
19
|
};
|
|
27
|
-
/** What is wrong with a projection's form, if anything: the one judgement EACH_INVALID and validatePageProps share. */
|
|
28
20
|
export declare function eachFormProblems(value: Each): string[];
|
|
29
|
-
/** One cell's configuration. `ids` are the page's cell ids, for `children`. */
|
|
30
21
|
export declare function validateCell(cell: PageCell, catalog?: Catalog, path?: string, ids?: ReadonlySet<string>, options?: ValidateOptions): Diagnostic[];
|
|
31
|
-
/** A whole page: every cell, the page's own declarations, unique cell ids, and its document structure. */
|
|
32
22
|
export declare function validatePage(page: Pick<ProjectPage, 'content' | 'layout'> & {
|
|
33
23
|
is_template?: boolean | null;
|
|
34
24
|
}, catalog?: Catalog): Diagnostic[];
|
|
35
|
-
/** A slot a component declares in its props schema: `properties.<name>["x-slot"]` (ui-consistency.md §2.8). */
|
|
36
25
|
export type SlotDeclaration = {
|
|
37
26
|
name: string;
|
|
38
27
|
accepts?: readonly string[];
|
|
39
28
|
max?: number;
|
|
40
29
|
};
|
|
41
|
-
/** The slots a catalog entry declares, by name. */
|
|
42
30
|
export declare function declaredSlots(schema: {
|
|
43
31
|
properties?: Record<string, unknown>;
|
|
44
32
|
} | null | undefined): Map<string, SlotDeclaration>;
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import type { Traversal } from '@peripheries/runtime';
|
|
2
2
|
import type { PageRuntime } from './load-page.js';
|
|
3
3
|
import type { ProjectPage } from './types.js';
|
|
4
|
-
/**
|
|
5
|
-
* `values` are labels and their resolved values, on top of the page's static
|
|
6
|
-
* data. `traversal` is `@_traversal` for every walking cell: one subgraph for
|
|
7
|
-
* all of them, or one per cell id; a walking cell it doesn't cover gets an
|
|
8
|
-
* empty one, as the host gives a walk that found nothing.
|
|
9
|
-
*/
|
|
10
4
|
export declare function pageRuntimeFromValues(page: ProjectPage, { values, traversal }?: {
|
|
11
5
|
values?: Record<string, unknown>;
|
|
12
6
|
traversal?: Traversal | Record<string, Traversal>;
|
|
@@ -1,26 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Conditions on pages, sections, questions and content blocks (design/forms.md §3.1).
|
|
3
|
-
*
|
|
4
|
-
* One shape: `{ all: [{ q: '<question key>', op, value }], not?: boolean }`, operators
|
|
5
|
-
* in lower case only. Ported from the PWA's `lib/forms/evaluate-conditional.ts` and
|
|
6
|
-
* `lib/forms/normalize-conditional-logic.ts`; the semantics are theirs:
|
|
7
|
-
*
|
|
8
|
-
* - every clause must hold (AND); `not: true` negates the result;
|
|
9
|
-
* - absent or empty conditions show the target;
|
|
10
|
-
* - an unknown operator, or an error while evaluating, SHOWS the target. Hiding would
|
|
11
|
-
* silently remove a question from a workbook; an extra one is visible and correctable.
|
|
12
|
-
*
|
|
13
|
-
* The PWA had two stored shapes and mixed operator casing (`equals`, `not_equals`,
|
|
14
|
-
* `notEquals`, `is_not_empty`, `greaterThan` …). `normalizeCondition` maps all of them
|
|
15
|
-
* to this shape once, at migration and validation time, so the evaluator reads only
|
|
16
|
-
* the canonical operators.
|
|
17
|
-
*/
|
|
18
1
|
export declare const CONDITION_OPS: readonly ["eq", "ne", "in", "not_in", "gt", "lt", "gte", "lte", "contains", "not_contains", "empty", "not_empty"];
|
|
19
2
|
export type ConditionOp = (typeof CONDITION_OPS)[number];
|
|
20
3
|
export interface ConditionClause {
|
|
21
|
-
/** The question key the clause reads from the answers. */
|
|
22
4
|
q: string;
|
|
23
|
-
/** A `ConditionOp`; anything else shows the target and is reported. */
|
|
24
5
|
op: ConditionOp | (string & {});
|
|
25
6
|
value?: unknown;
|
|
26
7
|
}
|
|
@@ -29,26 +10,8 @@ export interface Condition {
|
|
|
29
10
|
not?: boolean;
|
|
30
11
|
}
|
|
31
12
|
export declare function isConditionOp(op: unknown): op is ConditionOp;
|
|
32
|
-
/**
|
|
33
|
-
* True when the condition passes and the target should render.
|
|
34
|
-
*
|
|
35
|
-
* @param answers Answers keyed by question key, unwrapped (`unwrapAnswerValue`).
|
|
36
|
-
* @param onProblem Called for an unknown operator or an evaluation error; the target
|
|
37
|
-
* is shown in both cases.
|
|
38
|
-
*/
|
|
39
13
|
export declare function evaluateCondition(condition: Condition | null | undefined, answers: Record<string, unknown>, onProblem?: (problem: string) => void): boolean;
|
|
40
|
-
/** The canonical operator for a legacy spelling, or null when it is not one we know. */
|
|
41
14
|
export declare function normalizeOperator(op: unknown): ConditionOp | null;
|
|
42
|
-
/**
|
|
43
|
-
* Map a stored condition to the one shape.
|
|
44
|
-
*
|
|
45
|
-
* Accepts the new shape, the PWA's current `{ conditions: [{ questionId, operator, value }],
|
|
46
|
-
* not? }`, its legacy `[{ when, operator, is }]`, and any of them as a JSON string (the
|
|
47
|
-
* column is jsonb and some seeding wrote it stringified).
|
|
48
|
-
*
|
|
49
|
-
* `condition: null` means UNGATED, i.e. the target shows: the safe direction for input
|
|
50
|
-
* that is absent or unusable. Unusable input and dropped clauses are listed in `problems`.
|
|
51
|
-
*/
|
|
52
15
|
export declare function normalizeCondition(legacy: unknown): {
|
|
53
16
|
condition: Condition | null;
|
|
54
17
|
problems: string[];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { CONDITION_OPS, evaluateCondition, isConditionOp, normalizeCondition, normalizeOperator, type Condition, type ConditionClause, type ConditionOp } from './conditions.js';
|
|
2
2
|
export { defaultMode, enterAdvances, fromPageSteps, goTo, goToQuestion, isReadOnlyStatus, linkTo, missing, move, positionFromLink, positionsOf, progress, questionsOf, settle, stepKind, visibleSteps, type DisplayMode, type FormChapter, type FormItem, type FormItemKind, type FormLink, type FormModel, type FormQuestion, type FormQuestionDefinition, type FormStep, type Position, type StepKind, type StepProgress, type SubmissionStatus, } from './model.js';
|
|
3
3
|
export type { AnswerToSave, FileToUpload, FormsPort, FormsRefusal, FormsResult } from './port.js';
|
|
4
|
+
export type { FormContentBlock, FormSection } from './section.js';
|