@peripheries/renderer 0.23.0 → 0.23.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/README.md +45 -33
  2. package/dist/catalog.js +2 -6
  3. package/dist/chunks/{forms-CCAE7sCu.js → forms-DxA9WzCt.js} +0 -6
  4. package/dist/chunks/{load-CjPvISzH.js → load-b38vUiZM.js} +0 -4
  5. package/dist/chunks/{page-bundles-DLRIBP8g.js → page-bundles-CPj_vx-J.js} +1 -5
  6. package/dist/chunks/{persistence-DCMakM9H.js → persistence-hurkUUQ0.js} +0 -6
  7. package/dist/chunks/{projection-yvYKzMOS.js → projection-zhu32_KJ.js} +1 -15
  8. package/dist/chunks/{query-LnTbQghF.js → query-D6xQbTFK.js} +0 -6
  9. package/dist/chunks/{refs-BLUokra5.js → refs-Csgh6rXq.js} +0 -4
  10. package/dist/chunks/{structure-BrKSgzRJ.js → structure-CKBtQHJq.js} +1 -7
  11. package/dist/chunks/{validate-B_g7719l.js → validate-BcB_PA1k.js} +2 -10
  12. package/dist/core.js +9 -25
  13. package/dist/forms.js +1 -1
  14. package/dist/print.js +0 -24
  15. package/dist/react.js +4 -22
  16. package/dist/runtime.js +2 -12
  17. package/dist/styles.css +9 -15
  18. package/dist/testing.js +5 -21
  19. package/dist/theme.js +0 -10
  20. package/dist/types/catalog/check.d.ts +0 -13
  21. package/dist/types/core/actions.d.ts +0 -24
  22. package/dist/types/core/bundles/load.d.ts +0 -23
  23. package/dist/types/core/bundles/page-bundles.d.ts +0 -9
  24. package/dist/types/core/bundles/refs.d.ts +1 -28
  25. package/dist/types/core/bundles/resolve.d.ts +0 -10
  26. package/dist/types/core/cell-props.d.ts +0 -20
  27. package/dist/types/core/cells.d.ts +0 -21
  28. package/dist/types/core/data-context.d.ts +0 -22
  29. package/dist/types/core/diagnostics.d.ts +1 -3
  30. package/dist/types/core/graph.d.ts +0 -54
  31. package/dist/types/core/layout.d.ts +0 -9
  32. package/dist/types/core/load-page.d.ts +0 -111
  33. package/dist/types/core/query.d.ts +0 -64
  34. package/dist/types/core/references.d.ts +0 -21
  35. package/dist/types/core/release.d.ts +0 -10
  36. package/dist/types/core/rules.d.ts +0 -1
  37. package/dist/types/core/selected.d.ts +0 -5
  38. package/dist/types/core/sources.d.ts +5 -64
  39. package/dist/types/core/store/create-store.d.ts +0 -6
  40. package/dist/types/core/store/persistence.d.ts +0 -1
  41. package/dist/types/core/store/projection.d.ts +0 -5
  42. package/dist/types/core/store/scope-keys.d.ts +0 -1
  43. package/dist/types/core/store/types.d.ts +0 -6
  44. package/dist/types/core/structure.d.ts +0 -33
  45. package/dist/types/core/types.d.ts +0 -13
  46. package/dist/types/core/validate.d.ts +0 -12
  47. package/dist/types/core/values.d.ts +0 -6
  48. package/dist/types/forms/conditions.d.ts +0 -37
  49. package/dist/types/forms/model.d.ts +0 -44
  50. package/dist/types/forms/port.d.ts +0 -22
  51. package/dist/types/print/document-bindings.d.ts +0 -61
  52. package/dist/types/print/document-profile.d.ts +0 -137
  53. package/dist/types/print/map-staleness.d.ts +0 -66
  54. package/dist/types/print/page-map.d.ts +1 -334
  55. package/dist/types/print/paginate.d.ts +0 -190
  56. package/dist/types/print/print-layout.d.ts +0 -161
  57. package/dist/types/print/print-lint.d.ts +0 -109
  58. package/dist/types/print/print-policy.d.ts +0 -184
  59. package/dist/types/print/print-stylesheet.d.ts +0 -135
  60. package/dist/types/print/running-header.d.ts +0 -86
  61. package/dist/types/print/structure-print.d.ts +1 -243
  62. package/dist/types/react/cell-states.d.ts +0 -2
  63. package/dist/types/react/cell-view.d.ts +0 -16
  64. package/dist/types/react/page-renderer.d.ts +0 -37
  65. package/dist/types/react/structure-view.d.ts +0 -12
  66. package/dist/types/react/use-cell-store.d.ts +0 -5
  67. package/dist/types/react/use-container-size.d.ts +0 -5
  68. package/dist/types/react/use-forms-runtime.d.ts +1 -55
  69. package/dist/types/react/use-paging.d.ts +0 -9
  70. package/dist/types/runtime/boot.d.ts +0 -11
  71. package/dist/types/runtime/install.d.ts +0 -15
  72. package/dist/types/runtime/shims.d.ts +0 -8
  73. package/dist/types/runtime/store-export.d.ts +0 -7
  74. package/dist/types/testing/base-props.d.ts +0 -1
  75. package/dist/types/testing/components.d.ts +0 -8
  76. package/dist/types/testing/form-workbook.d.ts +0 -3
  77. package/dist/types/testing/golden.d.ts +0 -16
  78. package/dist/types/testing/ids.d.ts +0 -2
  79. package/dist/types/testing/sources.d.ts +0 -7
  80. package/dist/types/theme/check.d.ts +0 -2
  81. package/dist/types/theme/color.d.ts +0 -12
  82. package/dist/types/theme/derive.d.ts +0 -12
  83. package/dist/types/theme/parse.d.ts +0 -7
  84. package/package.json +2 -2
  85. package/dist/catalog.js.map +0 -1
  86. package/dist/chunks/forms-CCAE7sCu.js.map +0 -1
  87. package/dist/chunks/load-CjPvISzH.js.map +0 -1
  88. package/dist/chunks/page-bundles-DLRIBP8g.js.map +0 -1
  89. package/dist/chunks/persistence-DCMakM9H.js.map +0 -1
  90. package/dist/chunks/projection-yvYKzMOS.js.map +0 -1
  91. package/dist/chunks/query-LnTbQghF.js.map +0 -1
  92. package/dist/chunks/refs-BLUokra5.js.map +0 -1
  93. package/dist/chunks/structure-BrKSgzRJ.js.map +0 -1
  94. package/dist/chunks/validate-B_g7719l.js.map +0 -1
  95. package/dist/core.js.map +0 -1
  96. package/dist/print.js.map +0 -1
  97. package/dist/react.js.map +0 -1
  98. package/dist/runtime.js.map +0 -1
  99. package/dist/testing.js.map +0 -1
  100. package/dist/theme.js.map +0 -1
@@ -2,48 +2,26 @@ import { type NodeBinding, type NodeRecord, type QueryDescriptor, type StateName
2
2
  import { readField, type Diagnostic, type ProcessSystems } from './graph.js';
3
3
  export { readField };
4
4
  import type { DataContext, ProjectPage } from './types.js';
5
- /** A system a declaration reads: by name from the page's process, or named outright by id. */
6
5
  export type StateRead = {
7
6
  name?: StateName;
8
7
  systemId: string;
9
8
  };
10
- /** A declaration with the systems it reads, in merge order. */
11
9
  export type ResolvedDeclaration = NodeBinding & {
12
10
  reads: StateRead[];
13
11
  };
14
- /**
15
- * Declarations (`data.queries`) with the systems each reads: `system_id`
16
- * outright, else its `state` names (default `eng_data`) through the page's
17
- * systems. Only node bindings: a retired registry binding is left to
18
- * validation. A declaration none of whose systems exist
19
- * is dropped, with a diagnostic.
20
- */
21
12
  export declare function resolveDeclarations(queries: Record<string, unknown> | undefined, systems: ProcessSystems, diagnostics?: Diagnostic[], cellId?: string): Record<string, ResolvedDeclaration>;
22
- /** The inline descriptors among declarations (`{ descriptor }`), by label (design/data.md §3). */
23
13
  export declare function collectDescriptors(queries: Record<string, unknown> | undefined): Record<string, QueryDescriptor>;
24
- /** The page's own declarations (`content.data.queries`), which every cell sees. */
25
14
  export declare const collectDeclarations: (page: ProjectPage, systems: ProcessSystems, diagnostics?: Diagnostic[]) => Record<string, ResolvedDeclaration>;
26
- /** The page's static values (`content.data.static`), which every cell sees. */
27
15
  export declare function collectStatic(page: ProjectPage): Record<string, unknown>;
28
- /**
29
- * The page-wide DataContext: static, then declared on top. A declared label
30
- * whose producer has no state resolves to null. `states` is keyed
31
- * `<system_id>/<graph_node_id>`; `records` holds the NodeRecords for
32
- * `as: 'record'` declarations, by graph node id. Traversal is per cell
33
- * (the cell's walk; design/renderer.md §5.2), not part of this context.
34
- */
35
16
  export declare function buildDataContext(input: {
36
17
  static: Record<string, unknown>;
37
18
  declared: Record<string, ResolvedDeclaration>;
38
19
  states: Map<string, unknown>;
39
20
  records?: Record<string, NodeRecord>;
40
- /** The id of each newest state, keyed as `states`: where an edit of a declared value goes (INV-DOC-6). */
41
21
  stateIds?: Map<string, string>;
42
- /** What version each state was read at (StateRow), by `system/node`, when the page was read at one. */
43
22
  stateVersions?: Map<string, {
44
23
  versionId: string | null;
45
24
  outOfScope: boolean;
46
25
  }>;
47
- /** Whose static values these are: the page's (the default) or a cell's. */
48
26
  staticScope?: 'page' | 'cell';
49
27
  }): DataContext;
@@ -1,7 +1,5 @@
1
1
  export type DiagnosticEntry = {
2
- /** What the diagnostic means, in a sentence. */
3
2
  meaning: string;
4
- /** What to change. */
5
3
  fix: string;
6
4
  };
7
5
  export declare const DIAGNOSTICS: {
@@ -111,7 +109,7 @@ export declare const DIAGNOSTICS: {
111
109
  };
112
110
  readonly UNSUPPORTED_REGISTRY_BINDING: {
113
111
  readonly meaning: "A binding names a registry query (`{ registry: \"x.y\" }`) from the retired host contract.";
114
- readonly fix: "Copy the matching recipe’s descriptor into `{ descriptor }` (the component’s pattern pack has it), or bind the graph node that produces the data. docs/plan/host-contract-verdicts.md maps every id.";
112
+ readonly fix: "Copy the matching recipe’s descriptor into `{ descriptor }` (the component’s pattern pack has it), or bind the graph node that produces the data.";
115
113
  };
116
114
  readonly STATE_UNKNOWN_NAME: {
117
115
  readonly meaning: "A state name is not `<tier>_<role>`.";
@@ -1,81 +1,37 @@
1
1
  import { type EdgeRecord, type NodeRecord, type StateName, type StateRecord, type Traversal, type TraversalConfig } from '@peripheries/runtime';
2
2
  import type { DiagnosticCode } from './diagnostics.js';
3
3
  import type { PageCell } from './types.js';
4
- /** The page's systems by name, from its process's graphs (and, for eng_data, the page's metadata fallback). */
5
4
  export type ProcessSystems = Partial<Record<StateName, string>>;
6
- /**
7
- * A main, keyless system on one of a process's graphs, as GraphSource.graphSystems returns it:
8
- * the graph's `graph_type` (its tier) and the system's layer role (`system_layer.role`; null for
9
- * a layer that isn't a role, such as `edits`).
10
- */
11
5
  export type GraphSystem = {
12
6
  id: string;
13
7
  graph_type: string | null;
14
8
  role: string | null;
15
9
  };
16
- /**
17
- * A process's systems by name from its graphs (systems.md §3: the tier is `graph.graph_type`, the
18
- * role the layer's): every registered layer with a role, not only the four the process columns
19
- * cache. A layer without a role, or a graph of another type, has no name.
20
- */
21
10
  export declare function systemsFromGraphs(rows: readonly GraphSystem[] | null | undefined): ProcessSystems;
22
- /**
23
- * Something wrong with a page's configuration (design/renderer.md §7). Codes
24
- * are stable, so tools can explain them; `legacy` marks a form still read but
25
- * on its way out.
26
- */
27
11
  export type Diagnostic = {
28
12
  severity: 'error' | 'warning' | 'legacy';
29
- /** One of DIAGNOSTICS' keys, which says what it means and how to fix it. */
30
13
  code: DiagnosticCode;
31
14
  message: string;
32
- /** Where in the page, e.g. `content.cells[3].traversal`. */
33
15
  path?: string;
34
16
  cellId?: string;
35
17
  label?: string;
36
- /** The nearest names in scope, for a name that isn't there (CELL_UNKNOWN_COMPONENT). */
37
18
  suggestions?: string[];
38
19
  };
39
- /** A process row's system columns, `<tier>_<role>_system_id`, as names. */
40
20
  export declare function systemsFromProcess(row: Record<string, unknown> | null | undefined): ProcessSystems;
41
- /** The state names a read asks for, in order, duplicates dropped; the default when it names none. */
42
21
  export declare function stateNames(state: unknown): {
43
22
  names: StateName[];
44
23
  unknown: string[];
45
24
  };
46
- /** A value at a dot-path: the whole value without one. */
47
25
  export declare function readField(state: unknown, field?: string): unknown;
48
- /**
49
- * Several systems' data for one node, merged in order, later winning: plain
50
- * objects key by key, anything else replaces. `undefined` when none had any,
51
- * so "not loaded" and "empty" differ.
52
- */
53
26
  export declare function mergeStates(values: readonly unknown[]): unknown;
54
- /** The named states of a NodeRecord, merged, then `field`. */
55
27
  export declare function stateValue(state: NodeRecord['state'], names: readonly StateName[], field?: string): unknown;
56
28
  export type WalkStart = {
57
29
  graphNodeId: string;
58
30
  kind: 'cell' | 'page';
59
31
  };
60
- /** A cell's own node (a thin ref's, or an inline cell's `graph_node_id`), else the page node (agency doc 17). */
61
32
  export declare function resolveWalkStart(cell: Pick<PageCell, 'graph_node_id' | 'metadata'>, pageGraphNodeId: string | null | undefined): WalkStart | null;
62
- /**
63
- * Labels no declaration or walk can take: the cell's walk, the route's
64
- * parameters, the host's props, the viewer and the location (design/data.md
65
- * §5); `input` (an action's argument) and `scope` (the apps release) are kept free.
66
- */
67
33
  export declare const RESERVED_LABELS: readonly ["_traversal", "params", "baseProps", "viewer", "context", "input", "scope"];
68
- /**
69
- * Every data label a cell's props and conditions read with a whole-string
70
- * `@label…` reference. Inside an `@each` projection's `map`, its element's
71
- * label (`as`) is the projection's own, not the page's.
72
- */
73
34
  export declare function referencedLabels(cell: Pick<PageCell, 'props' | 'conditions'>): Set<string>;
74
- /**
75
- * Whether a cell's walk has anything to give it (design/renderer.md §5.2): it
76
- * reads `@_traversal`, or a label nothing explicit provides. Declarations win
77
- * over what a walk finds, so a walk whose labels are all declared changes nothing.
78
- */
79
35
  export declare function needsWalk(cell: PageCell, explicit: ReadonlySet<string>): boolean;
80
36
  export type WalkRequest = {
81
37
  start: WalkStart;
@@ -84,7 +40,6 @@ export type WalkRequest = {
84
40
  nodeTypes: string[] | null;
85
41
  maxDepth: number;
86
42
  maxNodes: number;
87
- /** The state names asked for, and the system each resolves to. */
88
43
  states: Array<{
89
44
  name: StateName;
90
45
  systemId: string;
@@ -92,14 +47,11 @@ export type WalkRequest = {
92
47
  excludeNodeTypes: string[] | null;
93
48
  excludeEdgeTypes: string[] | null;
94
49
  };
95
- /** A cell's walk as a request, or why it can't run. */
96
50
  export declare function walkRequest(config: TraversalConfig, start: WalkStart, systems: ProcessSystems): {
97
51
  request?: WalkRequest;
98
52
  diagnostics: Omit<Diagnostic, 'cellId'>[];
99
53
  };
100
- /** One walk per distinct question: cells asking the same one from the same start share it. */
101
54
  export declare const walkKey: (r: WalkRequest) => string;
102
- /** What walk_graph returns: nodes with their states keyed by system id. */
103
55
  export type RawWalk = {
104
56
  nodes: Array<Omit<NodeRecord, 'state'> & {
105
57
  state: Record<string, StateRecord | null>;
@@ -112,12 +64,6 @@ export type WalkBinding = {
112
64
  graph_node_id: string;
113
65
  field?: string;
114
66
  };
115
- /**
116
- * A walk's result for its cells: `@_traversal` (NodeRecords with states by
117
- * name, noise stripped, edges only between what's left), and the labels its
118
- * `binding_key` nodes provide. Two nodes with one key is a diagnostic, and
119
- * neither binds.
120
- */
121
67
  export declare function readWalk(raw: RawWalk, request: WalkRequest): {
122
68
  traversal: Traversal;
123
69
  bindings: WalkBinding[];
@@ -1,15 +1,6 @@
1
1
  import type { CSSProperties } from 'react';
2
2
  import type { CellLayout, PageCell } from './types.js';
3
- /** The page container (the PWA's ProjectPageRenderer): stack by default; grid of `columns` (12); flex. */
4
3
  export declare function pageContainerStyle(layout: Record<string, unknown> | null | undefined): CSSProperties;
5
- /** A cell's placement in the page grid; a nested cell gets none. */
6
4
  export declare function cellPlacementStyle(layout: CellLayout | undefined): CSSProperties;
7
- /** Hooks for CSS: the renderer's responsive rules (styles.css) and bundles read these names (design/bundles.md §6). */
8
5
  export declare function cellAttributes(cell: PageCell): Record<string, string>;
9
- /**
10
- * A document page's profile (`layout.profile`), set as `data-profile` on the
11
- * page container so the document kit's `--doc-*` tokens resolve for it
12
- * (design/core-and-tokens.md §6.5). Only a document page has one, and only a
13
- * slug: the value becomes an attribute.
14
- */
15
6
  export declare function documentProfile(layout: Record<string, unknown> | null | undefined): string | undefined;
@@ -2,15 +2,9 @@ import { type EmbedSelector, type NodeRecord, type QueryDescriptor, type StateRe
2
2
  import { type ResolvedCell } from './cells.js';
3
3
  import { type Diagnostic, type GraphSystem, type ProcessSystems, type RawWalk, type WalkRequest } from './graph.js';
4
4
  import type { DataContext, DataEntry, ProjectPage } from './types.js';
5
- /**
6
- * The version a read is made at (versions.md §5.1): a release, a channel or a branch id, opaque
7
- * to the renderer. Passed as each read's last argument only when the page isn't read at main, so
8
- * a source that takes no context reads main, as before.
9
- */
10
5
  export type ReadContext = {
11
6
  versionId: string;
12
7
  };
13
- /** A state row as a source returns it; the version fields when it was read at a version (StateAsOf). */
14
8
  export type StateRow = {
15
9
  id: string;
16
10
  data: unknown;
@@ -18,105 +12,40 @@ export type StateRow = {
18
12
  unversioned?: boolean;
19
13
  outOfScope?: boolean;
20
14
  };
21
- /** A NodeRecord as a source returns it: its states keyed by system id. */
22
15
  export type NodeRecordRow = Omit<NodeRecord, 'state'> & {
23
16
  stateBySystem: Record<string, StateRecord | null>;
24
17
  };
25
- /**
26
- * Where a page's graph data comes from (design/renderer.md §6). The host's
27
- * reads GraphQL under the viewer's JWT; the harness's reads fixtures; the
28
- * agency's reads its own client. Every method may cache.
29
- */
30
18
  export interface GraphSource {
31
- /**
32
- * The main, keyless systems on a process's graphs, with each graph's type and each layer's role
33
- * (systems.md §3): how a page finds its systems, any registered layer included. Optional for
34
- * 0.22 sources, which have `processSystems`; G4 drops the process columns, so a source needs this
35
- * by then.
36
- */
37
19
  graphSystems?(processId: string): Promise<GraphSystem[]>;
38
- /**
39
- * The process row: its `<tier>_<role>_system_id` columns, a cache of the four role layers.
40
- * Read only by a source without `graphSystems`.
41
- */
42
20
  processSystems?(processId: string): Promise<Record<string, unknown> | null>;
43
- /** The newest `page_cell_config` of each cell node in a system. */
44
21
  cellConfigs(systemId: string, graphNodeIds: string[], context?: ReadContext): Promise<Record<string, Record<string, unknown> | null>>;
45
- /** The newest state's data of each node in a system; missing nodes absent. */
46
22
  latestStates(systemId: string, graphNodeIds: string[], context?: ReadContext): Promise<Record<string, unknown>>;
47
- /**
48
- * The same, with each state's id: what a content edit's version check names (INV-DOC-6).
49
- * Optional: without it, declared values carry no state id, and can't be edited.
50
- */
51
23
  latestStateRows?(systemId: string, graphNodeIds: string[], context?: ReadContext): Promise<Record<string, StateRow>>;
52
24
  walk(request: WalkRequest, context?: ReadContext): Promise<RawWalk>;
53
25
  nodeRecords(graphNodeIds: string[], systemIds: string[], context?: ReadContext): Promise<Record<string, NodeRecordRow>>;
54
- /**
55
- * A query, as the viewer, its result shaped by the descriptor's `result`
56
- * (design/data.md §6). Variables are resolved, `$orderBy` included. The
57
- * host runs it through prepareDocument; a harness answers from fixtures
58
- * keyed by the operation's name.
59
- */
60
26
  query(descriptor: QueryDescriptor, variables: Record<string, unknown>): Promise<unknown>;
61
- /**
62
- * One page of a paged descriptor (QueryDescriptor.paging): the connection at
63
- * `result.path`, its nodes shaped as `query` shapes them, and its pageInfo.
64
- * Optional: without it a paged label loads its first page through `query`,
65
- * with no more to load.
66
- */
67
27
  queryPage?(descriptor: QueryDescriptor, variables: Record<string, unknown>): Promise<QueryPage>;
68
- /**
69
- * Of these systems, the main ones (`system.version` null; versions.md §4.6, graph-model G1):
70
- * a page reads main only, so a branch system a ref, a declaration or a walk names is read as
71
- * absent (SYSTEM_NOT_MAIN). Optional: without it, every system named is read.
72
- */
73
28
  mainSystems?(systemIds: string[]): Promise<ReadonlySet<string>>;
74
- /**
75
- * The page an embed cell names (PageCell.embed, resolved), as the viewer:
76
- * by id, or the newest published of a type in a project. Null when none is
77
- * readable. Optional: without it, embed cells report EMBED_NOT_FOUND.
78
- */
79
29
  page?(selector: EmbedSelector, context?: ReadContext): Promise<ProjectPage | null>;
80
30
  }
81
- /** One page of a paged label. */
82
31
  export type QueryPage = {
83
32
  items: unknown[];
84
33
  hasMore: boolean;
85
34
  endCursor: string | null;
86
35
  };
87
- /** What a page's queries may read besides labels (design/data.md §5). */
88
36
  export type PageScope = {
89
37
  params?: Record<string, unknown>;
90
38
  baseProps?: unknown;
91
- /** The signed-in person: `userId`, `isAdvisor`, `isClient`… */
92
39
  viewer?: unknown;
93
- /** The host's location context (core.md §8); the page's own ids are added. */
94
40
  context?: Record<string, unknown>;
95
- /** Set when loading an embedded page: its own embeds don't load. */
96
41
  embedded?: boolean;
97
- /**
98
- * The version the page is read at (versions.md §6.3), resolved by the host: every read takes it,
99
- * and `@context.version` / `@context.versionKind` name it. Absent or main: today's reads.
100
- */
101
42
  version?: VersionContext;
102
- /**
103
- * When the page is read at a release, the release it recorded for each page it embeds (its
104
- * `metadata.embeds`, from versions_for; versions.md §5.3): an embed renders that release, and
105
- * one not recorded renders at the viewer's context.
106
- */
107
43
  recordedEmbeds?: RecordedEmbed[];
108
44
  };
109
- /** A cell's own walk: `@_traversal`, and the labels its `binding_key` nodes provide. */
110
45
  export type CellWalk = {
111
46
  traversal: Traversal;
112
47
  labels: DataContext;
113
48
  };
114
- /**
115
- * A cell's own data (design/renderer.md §5.2): its static values, its
116
- * declarations (inline, or from its ref's config) and its walk. A cell
117
- * resolves against, lowest first: static (the page's, then its own), its
118
- * walk, the page's declarations, its own declarations.
119
- */
120
49
  export type CellData = {
121
50
  static: DataContext;
122
51
  declared: DataContext;
@@ -124,63 +53,23 @@ export type CellData = {
124
53
  };
125
54
  export type PageRuntime = {
126
55
  page: ProjectPage;
127
- /** Every cell, its content resolved: inline as written, a ref's from its node (or its fallback). */
128
56
  cells: ResolvedCell[];
129
- /** Ref cells with neither a node config nor a component of their own: rendered as pending. */
130
57
  unresolved: string[];
131
- /** The page's static values, then its declarations on top: what every cell sees. */
132
58
  data: DataContext;
133
- /** Labels the page declares: a walk's label of the same name never replaces them. */
134
59
  declared: string[];
135
- /** Each cell's own data, by cell id (only cells that have some). */
136
60
  cellData: Record<string, CellData>;
137
61
  systems: ProcessSystems;
138
62
  engDataSystemId: string | null;
139
- /**
140
- * Every graph node the page reads: its own, its cells', its producers', its
141
- * walks' starts. Their graphs are the Realtime topics the page joins
142
- * (design/data.md §10).
143
- */
144
63
  graphNodeIds: string[];
145
- /** The version the page was read at; absent at main. */
146
64
  version?: VersionContext;
147
- /**
148
- * The versions the page's states were read from, at a version (each row's `version_id`; nodes
149
- * outside the scope left out): what print and an embed say they show ("Release N"). Absent at
150
- * main, or when the source returns no rows with versions.
151
- */
152
65
  readVersionIds?: string[];
153
- /** An embedded page's version: the release its host recorded for it, or the viewer's context. */
154
66
  embedVersion?: 'recorded' | 'context';
155
- /** Each embed cell's page, loaded as the viewer (null when not found), by cell id. */
156
67
  embeds?: Record<string, PageRuntime | null>;
157
68
  diagnostics: Diagnostic[];
158
69
  };
159
70
  type SystemsSource = Pick<GraphSource, 'graphSystems' | 'processSystems'>;
160
- /**
161
- * A page's systems by name: the main systems on its process's graphs (`graphSystems`; a 0.22
162
- * source's process columns otherwise), with `metadata.systemGraph` as eng_data's fallback for a
163
- * page without a process. `metadata.pageProcess`, a copy of the process columns, isn't read: G4
164
- * drops the columns it copies.
165
- */
166
71
  export declare function resolveSystems(source: SystemsSource, page: ProjectPage): Promise<ProcessSystems>;
167
- /** The page's DSNS: what thin refs hydrate from and what declarations read by default. */
168
72
  export declare function resolveDataSystem(source: SystemsSource, page: ProjectPage): Promise<string | null>;
169
- /**
170
- * Everything a page needs before it renders (design/core.md §3, stages 1–3;
171
- * design/renderer.md §3, §5; design/data.md §6): read every ref's node config
172
- * (one read per system), then every declaration's producer (one read per
173
- * system), every walk a cell needs, any NodeRecords, and the queries whose
174
- * variables read no label, in parallel; then the queries whose variables read
175
- * a label, and those found in live query nodes. Framework-free: the source
176
- * decides how each read runs (the host's runs in its route loader, through
177
- * TanStack Query, under the viewer's JWT).
178
- */
179
- /**
180
- * A query that didn't run because references resolved to nothing. It has nothing to show yet
181
- * (`unresolved`) only when every reference is simply absent; one into a label whose read failed
182
- * is that failure (shell audit S1), not an empty result.
183
- */
184
73
  export declare function unresolvedEntry(missing: string[], data: DataContext): DataEntry;
185
74
  export declare function loadPageData(page: ProjectPage, source: GraphSource, scope?: PageScope): Promise<PageRuntime>;
186
75
  export {};
@@ -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,3 +1,2 @@
1
- /** The page layout types `pageContainerStyle` and the structure renderer handle. */
2
1
  export declare const LAYOUT_TYPES: readonly ["stack", "grid", "flex", "document"];
3
2
  export declare const PAGE_RULES: string;
@@ -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[];