@peripheries/renderer 0.8.0 → 0.9.0-data-render.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 CHANGED
@@ -23,8 +23,8 @@ page looks the same in each.
23
23
  diagnostics go.
24
24
 
25
25
  ```tsx
26
- const runtime = await loadPageData(page, source)
27
- <PageRenderer runtime={runtime} bundles={bundles} params={params} baseProps={baseProps} context={context} environment={environment} />
26
+ const runtime = await loadPageData(page, source, { params, baseProps, viewer, context })
27
+ <PageRenderer runtime={runtime} bundles={bundles} params={params} baseProps={baseProps} context={context} viewer={viewer} environment={environment} />
28
28
  ```
29
29
 
30
30
  ## What a consumer can hook in
@@ -68,6 +68,30 @@ bundle's `ThemeProvider` export.
68
68
 
69
69
  ## Versions
70
70
 
71
+ - **0.9.0** (prereleases `0.9.0-data-render.<n>`, dist-tag `data-render`):
72
+ queries (design/data.md §2–§6).
73
+ - A label can be `{ descriptor: QueryDescriptor }`, or a node binding to a
74
+ live `query_data` node, whose descriptor runs instead of returning its
75
+ state. `GraphSource` gains `query(descriptor, variables)`, which returns
76
+ the shaped result; the golden source answers from `queries`, by operation
77
+ name.
78
+ - `/core` exports `validateDescriptor`, `prepareDocument` (the render-time
79
+ rule, with `RENDER_FUNCTIONS`), `resolveDescriptorVariables` (the props
80
+ resolver, for variables), `selectionShape` and `selectionIssues`.
81
+ - `loadPageData(page, source, { params, baseProps, viewer, context })`
82
+ runs queries in rounds: those whose variables read no label with the
83
+ states and walks, then those that read a label, and live nodes' queries.
84
+ A failed or unresolved query gives its own label an error
85
+ (`QUERY_FAILED`, `QUERY_UNRESOLVED`); the rest of the page renders.
86
+ - `@viewer.*` and `@context.*` resolve in props (`PageRenderer` takes
87
+ `viewer`). `viewer`, `context`, `input` and `scope` are reserved labels
88
+ (`LABEL_RESERVED`).
89
+ - New diagnostics: `DESCRIPTOR_*`, `REF_NOT_SELECTED`, `QUERY_READS_QUERY`,
90
+ `QUERY_UNRESOLVED`, `QUERY_FAILED`, `LABEL_RESERVED`.
91
+ - `graphql` is a dependency.
92
+
93
+ - **0.8.1:** `BaseProps` carries the org's `locale` and `currency` (from its
94
+ org template's metadata), which `@stack/charts` formats with.
71
95
  - **0.8.0:** the old names go (design/core-and-tokens.md §14). The renderer
72
96
  writes only the attributes and container names above, the runtime installs
73
97
  only `__STACK_RUNTIME__` and maps only `@stack/store`, and the store has no
package/dist/catalog.js CHANGED
@@ -1,5 +1,5 @@
1
- import { y as isEach } from "./chunks/structure-Bp7xbPck.js";
2
- import { i as eachFormProblems, s as validatePage } from "./chunks/validate-Cz2tUUdm.js";
1
+ import { a as isEach } from "./chunks/references-D6BDsaqd.js";
2
+ import { i as eachFormProblems, s as validatePage } from "./chunks/validate-Bls6ttyi.js";
3
3
  import { KNOWLEDGE_BUDGETS, KNOWLEDGE_KEY } from "@peripheries/runtime";
4
4
  import Ajv2020 from "ajv/dist/2020.js";
5
5
  //#region packages/renderer/src/catalog/check.ts
@@ -0,0 +1,444 @@
1
+ import { a as isEach, c as resolveReferences } from "./references-D6BDsaqd.js";
2
+ import { DESCRIPTOR_VERSION } from "@peripheries/runtime";
3
+ import { Kind, parse, print, visit } from "graphql";
4
+ //#region packages/renderer/src/core/query.ts
5
+ var RENDER_FUNCTIONS = { walk_graph: [
6
+ "edge",
7
+ "graph_edge",
8
+ "graph_node",
9
+ "node",
10
+ "system_node_state"
11
+ ] };
12
+ var UnsafeDocumentError = class extends Error {
13
+ name = "UnsafeDocumentError";
14
+ };
15
+ var ENTITY_ROOT = /^(.+?)(Collection|ByPk)$/;
16
+ var prepared = new Map();
17
+ function prepareDocument(source) {
18
+ const hit = prepared.get(source);
19
+ if (hit) return hit;
20
+ const { doc, op } = parseOperation(source);
21
+ const entities = new Set();
22
+ for (const selection of op.selectionSet.selections) {
23
+ if (selection.kind !== Kind.FIELD) throw new UnsafeDocumentError("Fragments are not allowed at the root of a render-time query");
24
+ for (const e of rootEntities(selection)) entities.add(e);
25
+ }
26
+ const text = print(withTypename(doc));
27
+ const out = {
28
+ text,
29
+ operationName: op.name?.value,
30
+ entities: [...entities].sort(),
31
+ hash: fnv1a(text)
32
+ };
33
+ prepared.set(source, out);
34
+ return out;
35
+ }
36
+ function parseOperation(source) {
37
+ let doc;
38
+ try {
39
+ doc = parse(source);
40
+ } catch (e) {
41
+ throw new UnsafeDocumentError(`Not a valid GraphQL document: ${e.message}`);
42
+ }
43
+ const operations = doc.definitions.filter((d) => d.kind === Kind.OPERATION_DEFINITION);
44
+ if (operations.length !== 1) throw new UnsafeDocumentError(`Expected exactly one operation, found ${operations.length}`);
45
+ const [op] = operations;
46
+ if (op.operation !== "query") throw new UnsafeDocumentError(`Only query operations are executable at render time (got ${op.operation})`);
47
+ return {
48
+ doc,
49
+ op
50
+ };
51
+ }
52
+ function rootEntities(field) {
53
+ const name = field.name.value;
54
+ if (name === "__typename") return ["__typename"];
55
+ if (name === "node") return ["*"];
56
+ if (Object.hasOwn(RENDER_FUNCTIONS, name)) return RENDER_FUNCTIONS[name];
57
+ const match = ENTITY_ROOT.exec(name);
58
+ if (!match) throw new UnsafeDocumentError(`Root field "${name}" is not a table or view collection, or a render function. Other function fields (RPCs, rls_* helpers) and introspection are not allowed at render time.`);
59
+ return [match[1]];
60
+ }
61
+ function withTypename(doc) {
62
+ return visit(doc, { SelectionSet: { leave(node, _key, parent) {
63
+ if (parent && "kind" in parent && parent.kind === Kind.OPERATION_DEFINITION) return node;
64
+ if (node.selections.some((s) => s.kind === Kind.FIELD && s.name.value === "__typename" && !s.alias)) return node;
65
+ return {
66
+ ...node,
67
+ selections: [...node.selections, {
68
+ kind: Kind.FIELD,
69
+ name: {
70
+ kind: Kind.NAME,
71
+ value: "__typename"
72
+ }
73
+ }]
74
+ };
75
+ } } });
76
+ }
77
+ function fnv1a(input) {
78
+ let hash = 2166136261;
79
+ for (let i = 0; i < input.length; i++) {
80
+ hash ^= input.charCodeAt(i);
81
+ hash = Math.imul(hash, 16777619);
82
+ }
83
+ return (hash >>> 0).toString(36);
84
+ }
85
+ var LEAF = { kind: "leaf" };
86
+ function selectionShape(document, flatten = true) {
87
+ const { doc, op } = parseOperation(document);
88
+ const fragments = new Map(doc.definitions.filter((d) => d.kind === Kind.FRAGMENT_DEFINITION).map((f) => [f.name.value, f]));
89
+ const build = (set, nested, seen) => {
90
+ const fields = nested ? { __typename: LEAF } : {};
91
+ const visiting = new Set(seen);
92
+ const add = (s) => {
93
+ for (const sel of s.selections) if (sel.kind === Kind.FIELD) {
94
+ const key = sel.alias?.value ?? sel.name.value;
95
+ const child = sel.selectionSet ? build(sel.selectionSet, true, visiting) : LEAF;
96
+ fields[key] = merge(fields[key], sel.name.value === "edges" && child.kind === "object" && child.fields.node ? {
97
+ kind: "list",
98
+ of: child
99
+ } : child);
100
+ } else if (sel.kind === Kind.INLINE_FRAGMENT) add(sel.selectionSet);
101
+ else {
102
+ const f = fragments.get(sel.name.value);
103
+ if (f && !visiting.has(f.name.value)) {
104
+ visiting.add(f.name.value);
105
+ add(f.selectionSet);
106
+ }
107
+ }
108
+ };
109
+ add(set);
110
+ if (flatten) {
111
+ const edges = fields.edges;
112
+ if (edges?.kind === "list" && edges.of.kind === "object" && edges.of.fields.node) return {
113
+ kind: "list",
114
+ of: edges.of.fields.node
115
+ };
116
+ }
117
+ return {
118
+ kind: "object",
119
+ fields
120
+ };
121
+ };
122
+ return build(op.selectionSet, false, new Set());
123
+ }
124
+ function merge(a, b) {
125
+ if (!a || a.kind === "leaf") return b;
126
+ if (b.kind === "leaf") return a;
127
+ if (a.kind === "object" && b.kind === "object") {
128
+ const fields = { ...a.fields };
129
+ for (const [k, v] of Object.entries(b.fields)) fields[k] = merge(fields[k], v);
130
+ return {
131
+ kind: "object",
132
+ fields
133
+ };
134
+ }
135
+ if (a.kind === "list" && b.kind === "list") return {
136
+ kind: "list",
137
+ of: merge(a.of, b.of)
138
+ };
139
+ return b;
140
+ }
141
+ function shapeAt(shape, path) {
142
+ let cur = shape;
143
+ for (const seg of path) {
144
+ if (cur.kind === "leaf") return LEAF;
145
+ if (cur.kind === "list") {
146
+ if (!/^\d+$/.test(seg)) return null;
147
+ cur = cur.of;
148
+ } else {
149
+ const next = cur.fields[seg];
150
+ if (!next) return null;
151
+ cur = next;
152
+ }
153
+ }
154
+ return cur;
155
+ }
156
+ function descriptorShape(descriptor) {
157
+ return shapeAt(selectionShape(descriptor.document, descriptor.result?.flatten_connections !== false), splitPath(descriptor.result?.path));
158
+ }
159
+ var splitPath = (path) => path ? path.split(".").filter(Boolean) : [];
160
+ var DESCRIPTOR_KEYS = new Set([
161
+ "kind",
162
+ "version",
163
+ "document",
164
+ "variables",
165
+ "result",
166
+ "order_by"
167
+ ]);
168
+ var RESULT_KEYS = new Set(["path", "flatten_connections"]);
169
+ var ORDER_KEYS = new Set([
170
+ "field",
171
+ "direction",
172
+ "nulls"
173
+ ]);
174
+ var COLUMN = /^[A-Za-z_][A-Za-z0-9_]*$/;
175
+ var STRICT_REF = /^@([A-Za-z0-9_$-]+)(\.[A-Za-z0-9_$[\]-]+)*$/;
176
+ var VARIABLE_NAMESPACES = [
177
+ "params",
178
+ "baseProps",
179
+ "viewer",
180
+ "context"
181
+ ];
182
+ var NOT_IN_VARIABLES = new Set(["input", "scope"]);
183
+ var NAMESPACES = new Set(VARIABLE_NAMESPACES);
184
+ var isObject = (v) => !!v && typeof v === "object" && !Array.isArray(v);
185
+ function variableReferences(variables) {
186
+ const out = [];
187
+ const visitValue = (v) => {
188
+ if (typeof v === "string") {
189
+ const m = STRICT_REF.exec(v);
190
+ if (m) out.push({
191
+ ref: v,
192
+ label: m[1]
193
+ });
194
+ } else if (Array.isArray(v)) v.forEach(visitValue);
195
+ else if (isObject(v)) Object.values(v).forEach(visitValue);
196
+ };
197
+ visitValue(variables);
198
+ return out;
199
+ }
200
+ var variableLabels = (descriptor) => [...new Set(variableReferences(descriptor.variables).map((r) => r.label))].filter((l) => !NAMESPACES.has(l));
201
+ function validateDescriptor(descriptor, path = "descriptor") {
202
+ const out = [];
203
+ const push = (d) => out.push(d);
204
+ if (!isObject(descriptor)) {
205
+ push({
206
+ severity: "error",
207
+ code: "DESCRIPTOR_INVALID",
208
+ path,
209
+ message: "a descriptor is an object: { kind: \"graphql\", version: 1, document, variables?, result?, order_by? }"
210
+ });
211
+ return out;
212
+ }
213
+ if (descriptor.kind !== "graphql") push({
214
+ severity: "error",
215
+ code: "DESCRIPTOR_INVALID",
216
+ path: `${path}.kind`,
217
+ message: `kind is "${String(descriptor.kind)}"; expected "graphql"`
218
+ });
219
+ if (descriptor.version !== DESCRIPTOR_VERSION) push({
220
+ severity: "error",
221
+ code: "DESCRIPTOR_INVALID",
222
+ path: `${path}.version`,
223
+ message: `version is ${JSON.stringify(descriptor.version)}; expected ${DESCRIPTOR_VERSION}`
224
+ });
225
+ for (const k of Object.keys(descriptor)) if (!DESCRIPTOR_KEYS.has(k)) push({
226
+ severity: "error",
227
+ code: "DESCRIPTOR_INVALID",
228
+ path: `${path}.${k}`,
229
+ message: `a descriptor has no "${k}"`
230
+ });
231
+ const variables = descriptor.variables;
232
+ if (variables !== void 0 && !isObject(variables)) push({
233
+ severity: "error",
234
+ code: "DESCRIPTOR_INVALID",
235
+ path: `${path}.variables`,
236
+ message: "variables must be an object of name → value"
237
+ });
238
+ const given = isObject(variables) ? variables : {};
239
+ checkVariableValues(given, `${path}.variables`, push);
240
+ const result = descriptor.result;
241
+ if (result !== void 0) {
242
+ if (!isObject(result)) push({
243
+ severity: "error",
244
+ code: "DESCRIPTOR_INVALID",
245
+ path: `${path}.result`,
246
+ message: "result must be { path?, flatten_connections? }"
247
+ });
248
+ else {
249
+ for (const k of Object.keys(result)) if (!RESULT_KEYS.has(k)) push({
250
+ severity: "error",
251
+ code: "DESCRIPTOR_INVALID",
252
+ path: `${path}.result.${k}`,
253
+ message: `result has no "${k}"`
254
+ });
255
+ if (result.path !== void 0 && typeof result.path !== "string") push({
256
+ severity: "error",
257
+ code: "DESCRIPTOR_INVALID",
258
+ path: `${path}.result.path`,
259
+ message: "result.path is a dot path string"
260
+ });
261
+ if (result.flatten_connections !== void 0 && typeof result.flatten_connections !== "boolean") push({
262
+ severity: "error",
263
+ code: "DESCRIPTOR_INVALID",
264
+ path: `${path}.result.flatten_connections`,
265
+ message: "result.flatten_connections is true or false"
266
+ });
267
+ }
268
+ }
269
+ const orderBy = descriptor.order_by;
270
+ if (orderBy !== void 0) {
271
+ if (!Array.isArray(orderBy)) push({
272
+ severity: "error",
273
+ code: "DESCRIPTOR_INVALID",
274
+ path: `${path}.order_by`,
275
+ message: "order_by is a list of { field, direction?, nulls? }"
276
+ });
277
+ else orderBy.forEach((o, i) => {
278
+ const at = `${path}.order_by[${i}]`;
279
+ if (!isObject(o)) return push({
280
+ severity: "error",
281
+ code: "DESCRIPTOR_INVALID",
282
+ path: at,
283
+ message: "an order_by entry is { field, direction?, nulls? }"
284
+ });
285
+ for (const k of Object.keys(o)) if (!ORDER_KEYS.has(k)) push({
286
+ severity: "error",
287
+ code: "DESCRIPTOR_INVALID",
288
+ path: `${at}.${k}`,
289
+ message: `an order_by entry has no "${k}"`
290
+ });
291
+ if (typeof o.field !== "string" || !COLUMN.test(o.field)) push({
292
+ severity: "error",
293
+ code: "DESCRIPTOR_INVALID",
294
+ path: `${at}.field`,
295
+ message: "a query sorts by a column of its rows; a path into a state is for traversals and folders"
296
+ });
297
+ if (o.direction !== void 0 && o.direction !== "asc" && o.direction !== "desc") push({
298
+ severity: "error",
299
+ code: "DESCRIPTOR_INVALID",
300
+ path: `${at}.direction`,
301
+ message: "direction is asc or desc"
302
+ });
303
+ if (o.nulls !== void 0 && o.nulls !== "first" && o.nulls !== "last") push({
304
+ severity: "error",
305
+ code: "DESCRIPTOR_INVALID",
306
+ path: `${at}.nulls`,
307
+ message: "nulls is first or last"
308
+ });
309
+ });
310
+ }
311
+ if (typeof descriptor.document !== "string" || !descriptor.document.trim()) {
312
+ push({
313
+ severity: "error",
314
+ code: "DESCRIPTOR_DOCUMENT_INVALID",
315
+ path: `${path}.document`,
316
+ message: "document is one GraphQL query operation"
317
+ });
318
+ return out;
319
+ }
320
+ let op;
321
+ try {
322
+ prepareDocument(descriptor.document);
323
+ op = parseOperation(descriptor.document).op;
324
+ } catch (e) {
325
+ push({
326
+ severity: "error",
327
+ code: "DESCRIPTOR_DOCUMENT_INVALID",
328
+ path: `${path}.document`,
329
+ message: e.message
330
+ });
331
+ return out;
332
+ }
333
+ const declared = new Map(op.variableDefinitions?.map((v) => [v.variable.name.value, v]) ?? []);
334
+ for (const [name, def] of declared) {
335
+ const required = def.type.kind === Kind.NON_NULL_TYPE && !def.defaultValue;
336
+ if (name === "orderBy" && Array.isArray(orderBy) && orderBy.length) continue;
337
+ if (required && given[name] === void 0) push({
338
+ severity: "error",
339
+ code: "DESCRIPTOR_VARIABLE_MISSING",
340
+ path: `${path}.variables.${name}`,
341
+ message: `the document requires $${name}, and variables gives none`
342
+ });
343
+ }
344
+ for (const name of Object.keys(given)) if (!declared.has(name)) push({
345
+ severity: "warning",
346
+ code: "DESCRIPTOR_VARIABLE_UNDECLARED",
347
+ path: `${path}.variables.${name}`,
348
+ message: `the document declares no $${name}, so this value is never used`
349
+ });
350
+ if (Array.isArray(orderBy) && orderBy.length && !declared.has("orderBy")) push({
351
+ severity: "warning",
352
+ code: "DESCRIPTOR_ORDER_BY_UNUSED",
353
+ path: `${path}.order_by`,
354
+ message: "the document declares no $orderBy, so its own orderBy applies and order_by is ignored"
355
+ });
356
+ const resultPath = isObject(result) && typeof result.path === "string" ? result.path : void 0;
357
+ if (resultPath && !descriptorShape(descriptor)) push({
358
+ severity: "error",
359
+ code: "DESCRIPTOR_RESULT_PATH",
360
+ path: `${path}.result.path`,
361
+ message: `the document selects nothing at "${resultPath}"`
362
+ });
363
+ return out;
364
+ }
365
+ function checkVariableValues(value, path, push) {
366
+ if (typeof value === "string") {
367
+ if (!value.startsWith("@")) return;
368
+ const m = STRICT_REF.exec(value);
369
+ if (!m) return push({
370
+ severity: "error",
371
+ code: "DESCRIPTOR_REFERENCE_INVALID",
372
+ path,
373
+ message: `"${value}" isn't a whole \`@label.path\` reference`
374
+ });
375
+ if (NOT_IN_VARIABLES.has(m[1])) push({
376
+ severity: "error",
377
+ code: "DESCRIPTOR_REFERENCE_INVALID",
378
+ path,
379
+ message: `a variable can't read @${m[1]}; it reads @params, @baseProps, @viewer, @context or a label`
380
+ });
381
+ return;
382
+ }
383
+ if (Array.isArray(value)) return value.forEach((v, i) => checkVariableValues(v, `${path}[${i}]`, push));
384
+ if (!isObject(value)) return;
385
+ if (isEach(value)) return push({
386
+ severity: "error",
387
+ code: "DESCRIPTOR_REFERENCE_INVALID",
388
+ path,
389
+ message: "a projection (@each) shapes props, not variables; select the list you need in the query"
390
+ });
391
+ for (const [k, v] of Object.entries(value)) checkVariableValues(v, `${path}.${k}`, push);
392
+ }
393
+ var ORDER = {
394
+ "asc|first": "AscNullsFirst",
395
+ "asc|last": "AscNullsLast",
396
+ "desc|first": "DescNullsFirst",
397
+ "desc|last": "DescNullsLast"
398
+ };
399
+ var orderByVariable = (orderBy) => orderBy.map((o) => ({ [o.field]: ORDER[`${o.direction ?? "asc"}|${o.nulls ?? "last"}`] }));
400
+ function resolveDescriptorVariables(descriptor, ctx) {
401
+ const unresolved = [];
402
+ const pending = [];
403
+ const resolve = (v) => {
404
+ if (typeof v === "string") {
405
+ if (!STRICT_REF.test(v)) return resolveReferences(v, ctx);
406
+ let loading = false;
407
+ const value = resolveReferences(v, {
408
+ ...ctx,
409
+ onUnresolved: void 0,
410
+ onLoading: () => loading = true
411
+ });
412
+ if (loading) pending.push(v);
413
+ else if (value === null || value === void 0) unresolved.push(v);
414
+ return value;
415
+ }
416
+ if (Array.isArray(v)) return v.map(resolve);
417
+ if (isObject(v)) return Object.fromEntries(Object.entries(v).map(([k, x]) => [k, resolve(x)]));
418
+ return v;
419
+ };
420
+ const variables = resolve(descriptor.variables ?? {});
421
+ if (descriptor.order_by?.length && declaresVariable(descriptor.document, "orderBy")) variables.orderBy = orderByVariable(descriptor.order_by);
422
+ return {
423
+ variables,
424
+ unresolved,
425
+ pending
426
+ };
427
+ }
428
+ function declaresVariable(document, name) {
429
+ try {
430
+ return parseOperation(document).op.variableDefinitions?.some((v) => v.variable.name.value === name) ?? false;
431
+ } catch {
432
+ return false;
433
+ }
434
+ }
435
+ var queryKey = (descriptor, variables) => JSON.stringify([
436
+ prepareDocument(descriptor.document).hash,
437
+ variables,
438
+ descriptor.result?.path ?? null,
439
+ descriptor.result?.flatten_connections !== false
440
+ ]);
441
+ //#endregion
442
+ export { orderByVariable as a, resolveDescriptorVariables as c, validateDescriptor as d, variableLabels as f, descriptorShape as i, selectionShape as l, UnsafeDocumentError as n, prepareDocument as o, variableReferences as p, VARIABLE_NAMESPACES as r, queryKey as s, RENDER_FUNCTIONS as t, shapeAt as u };
443
+
444
+ //# sourceMappingURL=query-1yZv4GY8.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-1yZv4GY8.js","names":[],"sources":["../../src/core/query.ts"],"mappings":";;;;AAiCA,IAAa,mBAAgE,EAE3E,YAAY;CAAC;CAAQ;CAAc;CAAc;CAAQ;AAAmB,EAC9E;AAWA,IAAa,sBAAb,cAAyC,MAAM;CAC7C,OAAgB;AAClB;AAEA,IAAM,cAAc;AACpB,IAAM,WAAW,IAAI,IAA8B;AASnD,SAAgB,gBAAgB,QAAkC;CAChE,MAAM,MAAM,SAAS,IAAI,MAAM;CAC/B,IAAI,KAAK,OAAO;CAChB,MAAM,EAAE,KAAK,OAAO,eAAe,MAAM;CACzC,MAAM,WAAW,IAAI,IAAY;CACjC,KAAK,MAAM,aAAa,GAAG,aAAa,YAAY;EAClD,IAAI,UAAU,SAAS,KAAK,OAAO,MAAM,IAAI,oBAAoB,8DAA8D;EAC/H,KAAK,MAAM,KAAK,aAAa,SAAS,GAAG,SAAS,IAAI,CAAC;CACzD;CACA,MAAM,OAAO,MAAM,aAAa,GAAG,CAAC;CACpC,MAAM,MAAwB;EAAE;EAA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AY,YAA6B,cACpD,KAAK,UAAU;CAAC,gBAAgB,WAAW,QAAQ,CAAC,CAAC;CAAM;CAAW,WAAW,QAAQ,QAAQ;CAAM,WAAW,QAAQ,wBAAwB;AAAK,CAAC"}
@@ -0,0 +1,135 @@
1
+ //#region packages/renderer/src/core/references.ts
2
+ var STRICT_REF = /^@[A-Za-z0-9_$-]+(\.[A-Za-z0-9_$[\]-]+)*$/;
3
+ var INTERPOLATION = /\$\{(?:context\.)?([^}]+)\}/g;
4
+ var UnresolvedReference = class extends Error {
5
+ loading;
6
+ constructor(message, loading = false) {
7
+ super(message);
8
+ this.loading = loading;
9
+ }
10
+ };
11
+ function walk(root, path) {
12
+ let cur = root;
13
+ for (const seg of path) {
14
+ if (cur === null || cur === void 0) throw new UnresolvedReference(`null before "${seg}"`);
15
+ if (Array.isArray(cur) && /^\d+$/.test(seg)) {
16
+ const i = Number(seg);
17
+ if (i >= cur.length) throw new UnresolvedReference(`index ${i} out of range`);
18
+ cur = cur[i];
19
+ } else if (typeof cur === "object" || Array.isArray(cur)) cur = cur[seg];
20
+ else throw new UnresolvedReference(`"${seg}" on a ${typeof cur}`);
21
+ }
22
+ return cur;
23
+ }
24
+ function resolveRef(ref, ctx) {
25
+ const [key, ...path] = ref.slice(1).split(".");
26
+ const entry = ctx.data[key];
27
+ if (!entry) throw new UnresolvedReference(`no data "${key}"`);
28
+ if (entry.isLoading) throw new UnresolvedReference(`"${key}" is loading`, true);
29
+ if (entry.error) throw new UnresolvedReference(`"${key}" failed`);
30
+ return path.length ? walk(entry.data, path) : entry.data;
31
+ }
32
+ function interpolate(s, params) {
33
+ return s.replace(INTERPOLATION, (whole, path) => {
34
+ let cur = params;
35
+ for (const seg of path.split(".")) {
36
+ if (cur === null || cur === void 0) return whole;
37
+ cur = cur[seg];
38
+ }
39
+ return cur === void 0 ? whole : String(cur);
40
+ });
41
+ }
42
+ function resolveString(s, ctx) {
43
+ const text = interpolate(s, ctx.params);
44
+ if (!text.startsWith("@")) return text;
45
+ try {
46
+ const value = resolveRef(text, ctx);
47
+ if (value === void 0 && STRICT_REF.test(text)) ctx.onUnresolved?.(text);
48
+ return value;
49
+ } catch (e) {
50
+ if (!(e instanceof UnresolvedReference)) throw e;
51
+ if (!STRICT_REF.test(text)) return s;
52
+ if (e.loading) ctx.onLoading?.(text);
53
+ else ctx.onUnresolved?.(text);
54
+ return;
55
+ }
56
+ }
57
+ var EACH = "@each";
58
+ var EACH_DEFAULT_AS = "item";
59
+ var isEach = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && "@each" in value;
60
+ function resolveEach(each, ctx) {
61
+ const source = typeof each["@each"] === "string" ? resolveString(each[EACH], ctx) : void 0;
62
+ if (!Array.isArray(source)) {
63
+ if (source !== void 0) ctx.onUnresolved?.(String(each[EACH]));
64
+ return;
65
+ }
66
+ const as = each.as ?? "item";
67
+ return source.map((element) => resolveReferences(each.map, {
68
+ ...ctx,
69
+ data: {
70
+ ...ctx.data,
71
+ [as]: settled(element)
72
+ }
73
+ }));
74
+ }
75
+ function resolveReferences(value, ctx) {
76
+ if (value === null || value === void 0) return value;
77
+ if (typeof value === "string") return resolveString(value, ctx);
78
+ if (Array.isArray(value)) return value.map((v) => resolveReferences(v, ctx));
79
+ if (isEach(value)) return resolveEach(value, ctx);
80
+ if (typeof value === "object") {
81
+ const out = {};
82
+ for (const [k, v] of Object.entries(value)) out[k] = resolveReferences(v, ctx);
83
+ return out;
84
+ }
85
+ return value;
86
+ }
87
+ var settled = (data) => ({
88
+ data,
89
+ isLoading: false,
90
+ error: null
91
+ });
92
+ function cellResolutionContext(cell, page, own, baseProps, who) {
93
+ const pageDeclared = own?.pageDeclared ?? new Set();
94
+ const data = { ...page.data };
95
+ for (const [label, entry] of Object.entries(own?.static ?? {})) if (!pageDeclared.has(label)) data[label] = entry;
96
+ for (const [label, entry] of Object.entries(own?.walk?.labels ?? {})) if (!pageDeclared.has(label) && !own?.declared?.[label]) data[label] = entry;
97
+ Object.assign(data, own?.declared);
98
+ for (const [friendly, decl] of Object.entries(cell.data?.queries ?? {})) {
99
+ const registry = decl.registry;
100
+ if (registry && page.data[registry]) data[friendly] = page.data[registry];
101
+ }
102
+ data._traversal = settled(own?.walk?.traversal ?? {
103
+ nodes: [],
104
+ edges: []
105
+ });
106
+ data.params = settled(page.params);
107
+ if (baseProps !== void 0) data.baseProps = settled(baseProps);
108
+ if (who?.viewer !== void 0) data.viewer = settled(who.viewer);
109
+ if (who?.context !== void 0) data.context = settled(who.context);
110
+ return {
111
+ data,
112
+ params: page.params
113
+ };
114
+ }
115
+ var pageContext = (context, page) => ({
116
+ ...context,
117
+ pageId: page.id,
118
+ projectId: page.project_id,
119
+ processId: page.process_id
120
+ });
121
+ var cellContext = (context, cell) => ({
122
+ ...context,
123
+ nodeId: cell.graph_node_id ?? cell.metadata?.graph_node_id
124
+ });
125
+ function passesConditions(conditions, ctx) {
126
+ if (!conditions) return true;
127
+ const { showIf, hideIf } = conditions;
128
+ if (showIf !== void 0 && showIf !== "" && !resolveReferences(showIf, ctx)) return false;
129
+ if (hideIf !== void 0 && hideIf !== "" && resolveReferences(hideIf, ctx)) return false;
130
+ return true;
131
+ }
132
+ //#endregion
133
+ export { isEach as a, resolveReferences as c, cellResolutionContext as i, settled as l, EACH_DEFAULT_AS as n, pageContext as o, cellContext as r, passesConditions as s, EACH as t };
134
+
135
+ //# sourceMappingURL=references-D6BDsaqd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"references-D6BDsaqd.js","names":[],"sources":["../../src/core/references.ts"],"mappings":";AAmBA,IAAM,aAAa;AACnB,IAAM,gBAAgB;AAEtB,IAAM,sBAAN,cAAkC,MAAM;CACA;CAAtC,YAAY,SAAiB,UAAmB,OAAO;EACrD,MAAM,OAAO;EADuB,KAAA,UAAA;CAEtC;AACF;AAEA,SAAS,KAAK,MAAe,MAAyB;CACpD,IAAI,MAAM;CACV,KAAK,MAAM,OAAO,MAAM;EACtB,IAAI,QAAQ,QAAQ,QAAQ,KAAA,GA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