@peripheries/renderer 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -0
- package/dist/chunks/create-store-CglsI7tw.js +90 -0
- package/dist/chunks/create-store-CglsI7tw.js.map +1 -0
- package/dist/chunks/load-6zEgvJ6I.js +60 -0
- package/dist/chunks/load-6zEgvJ6I.js.map +1 -0
- package/dist/chunks/page-bundles-C4VW3dsK.js +87 -0
- package/dist/chunks/page-bundles-C4VW3dsK.js.map +1 -0
- package/dist/chunks/projection-Dsy9ruj8.js +592 -0
- package/dist/chunks/projection-Dsy9ruj8.js.map +1 -0
- package/dist/core.js +740 -0
- package/dist/core.js.map +1 -0
- package/dist/react.js +357 -0
- package/dist/react.js.map +1 -0
- package/dist/runtime.js +91 -0
- package/dist/runtime.js.map +1 -0
- package/dist/styles.css +51 -0
- package/dist/testing.js +944 -0
- package/dist/testing.js.map +1 -0
- package/dist/types/core/bundles/load.d.ts +49 -0
- package/dist/types/core/bundles/page-bundles.d.ts +17 -0
- package/dist/types/core/bundles/refs.d.ts +41 -0
- package/dist/types/core/bundles/resolve.d.ts +25 -0
- package/dist/types/core/cell-props.d.ts +39 -0
- package/dist/types/core/cells.d.ts +39 -0
- package/dist/types/core/data-context.d.ts +38 -0
- package/dist/types/core/graph.d.ts +95 -0
- package/dist/types/core/index.d.ts +19 -0
- package/dist/types/core/layout.d.ts +12 -0
- package/dist/types/core/load-page.d.ts +72 -0
- package/dist/types/core/references.d.ts +43 -0
- package/dist/types/core/store/create-store.d.ts +26 -0
- package/dist/types/core/store/persistence.d.ts +9 -0
- package/dist/types/core/store/projection.d.ts +15 -0
- package/dist/types/core/store/scope-keys.d.ts +10 -0
- package/dist/types/core/store/types.d.ts +37 -0
- package/dist/types/core/structure.d.ts +72 -0
- package/dist/types/core/types.d.ts +30 -0
- package/dist/types/core/validate.d.ts +14 -0
- package/dist/types/react/cell-states.d.ts +25 -0
- package/dist/types/react/cell-view.d.ts +31 -0
- package/dist/types/react/index.d.ts +6 -0
- package/dist/types/react/page-renderer.d.ts +30 -0
- package/dist/types/react/structure-view.d.ts +30 -0
- package/dist/types/react/use-cell-store.d.ts +13 -0
- package/dist/types/react/use-container-size.d.ts +11 -0
- package/dist/types/runtime/boot.d.ts +7 -0
- package/dist/types/runtime/index.d.ts +4 -0
- package/dist/types/runtime/install.d.ts +21 -0
- package/dist/types/runtime/shims.d.ts +11 -0
- package/dist/types/runtime/store-export.d.ts +18 -0
- package/dist/types/testing/base-props.d.ts +3 -0
- package/dist/types/testing/components.d.ts +51 -0
- package/dist/types/testing/golden.d.ts +51 -0
- package/dist/types/testing/ids.d.ts +14 -0
- package/dist/types/testing/index.d.ts +5 -0
- package/dist/types/testing/sources.d.ts +25 -0
- package/package.json +51 -0
package/dist/testing.js
ADDED
|
@@ -0,0 +1,944 @@
|
|
|
1
|
+
import { a as projectModule } from "./chunks/load-6zEgvJ6I.js";
|
|
2
|
+
import { a as bundleScope, n as pageBundles, t as pageBundleRefs } from "./chunks/page-bundles-C4VW3dsK.js";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
//#region \0rolldown/runtime.js
|
|
5
|
+
var __defProp = Object.defineProperty;
|
|
6
|
+
var __exportAll = (all, no_symbols) => {
|
|
7
|
+
let target = {};
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
13
|
+
return target;
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region packages/renderer/src/testing/ids.ts
|
|
17
|
+
var fixtureId = (n) => `00000000-0000-4000-8000-${String(n).padStart(12, "0")}`;
|
|
18
|
+
var FIXTURE_ID = /^00000000-0000-4000-8000-\d{12}$/;
|
|
19
|
+
var FIXTURE_ORG_SLUGS = ["example-client", "example-advisor"];
|
|
20
|
+
var FIXTURE_EMAIL_DOMAIN = "example.test";
|
|
21
|
+
var CLIENT_ORG = {
|
|
22
|
+
id: fixtureId(1),
|
|
23
|
+
slug: "example-client"
|
|
24
|
+
};
|
|
25
|
+
var ADVISOR_ORG = {
|
|
26
|
+
id: fixtureId(2),
|
|
27
|
+
slug: "example-advisor"
|
|
28
|
+
};
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region packages/renderer/src/testing/base-props.ts
|
|
31
|
+
var FIXTURE_BASE_PROPS = {
|
|
32
|
+
user: {
|
|
33
|
+
id: fixtureId(3),
|
|
34
|
+
email: `viewer@${FIXTURE_EMAIL_DOMAIN}`,
|
|
35
|
+
fullName: "Example Viewer"
|
|
36
|
+
},
|
|
37
|
+
tenant: {
|
|
38
|
+
id: CLIENT_ORG.id,
|
|
39
|
+
orgSlug: CLIENT_ORG.slug,
|
|
40
|
+
name: "Example Client"
|
|
41
|
+
},
|
|
42
|
+
theme: {
|
|
43
|
+
primaryColor: "#1f4e79",
|
|
44
|
+
secondaryColor: "#c8a13a"
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
//#endregion
|
|
48
|
+
//#region packages/renderer/src/testing/components.tsx
|
|
49
|
+
var components_exports = __exportAll({
|
|
50
|
+
Badge: () => Badge,
|
|
51
|
+
Boom: () => Boom,
|
|
52
|
+
DocumentSection: () => DocumentSection,
|
|
53
|
+
FlowList: () => FlowList,
|
|
54
|
+
KpiCard: () => KpiCard,
|
|
55
|
+
Masthead: () => Masthead,
|
|
56
|
+
OptionList: () => OptionList,
|
|
57
|
+
Prose: () => Prose,
|
|
58
|
+
SectionReference: () => SectionReference,
|
|
59
|
+
SelectionEcho: () => SelectionEcho,
|
|
60
|
+
ThemeProvider: () => ThemeProvider,
|
|
61
|
+
advisorKit: () => advisorKit,
|
|
62
|
+
clientKit: () => clientKit
|
|
63
|
+
});
|
|
64
|
+
function Masthead({ title, subtitle }) {
|
|
65
|
+
return jsxs("header", {
|
|
66
|
+
"data-testid": "masthead",
|
|
67
|
+
children: [jsx("h1", { children: String(title ?? "") }), subtitle !== void 0 && jsx("p", { children: String(subtitle) })]
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
function Prose({ children }) {
|
|
71
|
+
return jsx("div", {
|
|
72
|
+
"data-testid": "prose",
|
|
73
|
+
children
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function DocumentSection({ sectionId, title, body, blocks, children, sectionNumbers, sectionAnchors }) {
|
|
77
|
+
const id = String(sectionId);
|
|
78
|
+
const number = sectionNumbers?.[id];
|
|
79
|
+
const items = Array.isArray(blocks) ? blocks.flatMap((b) => b.kind === "clause" ? b.items ?? [] : []) : [];
|
|
80
|
+
return jsxs("div", {
|
|
81
|
+
id: sectionAnchors?.[id],
|
|
82
|
+
"data-testid": `section-${id}`,
|
|
83
|
+
"data-number": number?.join(".") ?? "",
|
|
84
|
+
children: [
|
|
85
|
+
title !== void 0 && jsx("h2", { children: String(title) }),
|
|
86
|
+
body !== void 0 && jsx("p", { children: String(body) }),
|
|
87
|
+
items.length > 0 && jsx("ol", { children: items.map((i) => jsx("li", { children: i.text }, i.id)) }),
|
|
88
|
+
children
|
|
89
|
+
]
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function SectionReference({ to, sectionReferences }) {
|
|
93
|
+
const ref = sectionReferences?.[String(to)];
|
|
94
|
+
if (!ref) return jsxs("span", {
|
|
95
|
+
"data-testid": "reference",
|
|
96
|
+
children: ["unresolved ", String(to)]
|
|
97
|
+
});
|
|
98
|
+
const clause = ref.element ? ` (${String.fromCharCode(97 + ref.element.index)})` : "";
|
|
99
|
+
return jsxs("a", {
|
|
100
|
+
"data-testid": "reference",
|
|
101
|
+
href: ref.href,
|
|
102
|
+
children: [
|
|
103
|
+
"§",
|
|
104
|
+
ref.number?.join("."),
|
|
105
|
+
" ",
|
|
106
|
+
ref.title,
|
|
107
|
+
clause
|
|
108
|
+
]
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
function KpiCard({ label, value, data, status }) {
|
|
112
|
+
return jsxs("dl", {
|
|
113
|
+
"data-testid": `kpi-${String(label)}`,
|
|
114
|
+
"data-loading": String(status?.isLoading ?? false),
|
|
115
|
+
children: [
|
|
116
|
+
jsx("dt", { children: String(label) }),
|
|
117
|
+
jsx("dd", { children: value === void 0 ? "—" : value === null ? "none" : String(value) }),
|
|
118
|
+
data !== void 0 && jsx("dd", {
|
|
119
|
+
"data-testid": "kpi-data",
|
|
120
|
+
children: JSON.stringify(data)
|
|
121
|
+
})
|
|
122
|
+
]
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
function OptionList({ options, selections }) {
|
|
126
|
+
const s = selections;
|
|
127
|
+
return jsx("ul", {
|
|
128
|
+
"data-testid": "options",
|
|
129
|
+
children: options.map((o) => jsx("li", { children: jsx("button", {
|
|
130
|
+
type: "button",
|
|
131
|
+
"aria-pressed": s?.selected === o,
|
|
132
|
+
onClick: () => s?.setSelected?.(o),
|
|
133
|
+
children: o
|
|
134
|
+
}) }, o))
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
function SelectionEcho({ selections }) {
|
|
138
|
+
return jsx("output", {
|
|
139
|
+
"data-testid": "echo",
|
|
140
|
+
children: String(selections?.selected ?? "nothing")
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
function Boom() {
|
|
144
|
+
throw new Error("fixture crash");
|
|
145
|
+
}
|
|
146
|
+
function FlowList({ nodes, edges }) {
|
|
147
|
+
const list = nodes ?? [];
|
|
148
|
+
return jsx("ul", {
|
|
149
|
+
"data-testid": "flow",
|
|
150
|
+
"data-edges": String((edges ?? []).length),
|
|
151
|
+
children: list.map((n) => jsxs("li", { children: [
|
|
152
|
+
n.name,
|
|
153
|
+
"|",
|
|
154
|
+
n.state.eng_process === void 0 ? "not asked" : n.state.eng_process?.data?.status ?? "no plan",
|
|
155
|
+
"|",
|
|
156
|
+
n.state.eng_data ? "data" : "no data"
|
|
157
|
+
] }, n.name))
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
function Badge({ text }) {
|
|
161
|
+
return jsx("span", {
|
|
162
|
+
"data-testid": "badge",
|
|
163
|
+
children: String(text)
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
function ThemeProvider({ children }) {
|
|
167
|
+
return jsx("div", {
|
|
168
|
+
"data-theme": "example-client",
|
|
169
|
+
children
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
var clientKit = {
|
|
173
|
+
Masthead,
|
|
174
|
+
Prose,
|
|
175
|
+
DocumentSection,
|
|
176
|
+
SectionReference,
|
|
177
|
+
KpiCard,
|
|
178
|
+
OptionList,
|
|
179
|
+
SelectionEcho,
|
|
180
|
+
FlowList,
|
|
181
|
+
Boom,
|
|
182
|
+
ThemeProvider
|
|
183
|
+
};
|
|
184
|
+
var advisorKit = {
|
|
185
|
+
Prose: ({ children }) => jsx("div", {
|
|
186
|
+
"data-testid": "advisor-prose",
|
|
187
|
+
children
|
|
188
|
+
}),
|
|
189
|
+
Badge
|
|
190
|
+
};
|
|
191
|
+
//#endregion
|
|
192
|
+
//#region packages/renderer/src/testing/golden.ts
|
|
193
|
+
var bundle = (n, org, module, contracts) => ({
|
|
194
|
+
row: {
|
|
195
|
+
id: fixtureId(n),
|
|
196
|
+
org_id: org.id,
|
|
197
|
+
org_slug: org.slug,
|
|
198
|
+
bundle_name: "main",
|
|
199
|
+
version: "v_fixture",
|
|
200
|
+
storage_path: `${org.slug}/main/v_fixture/index.js`,
|
|
201
|
+
is_public: false,
|
|
202
|
+
is_live: true
|
|
203
|
+
},
|
|
204
|
+
module,
|
|
205
|
+
contracts
|
|
206
|
+
});
|
|
207
|
+
var CLIENT_MAIN = bundle(100, CLIENT_ORG, clientKit);
|
|
208
|
+
var ADVISOR_MAIN = bundle(101, ADVISOR_ORG, advisorKit);
|
|
209
|
+
var page = (n, over) => ({
|
|
210
|
+
id: fixtureId(n),
|
|
211
|
+
name: null,
|
|
212
|
+
org_id: CLIENT_ORG.id,
|
|
213
|
+
project_id: fixtureId(10),
|
|
214
|
+
process_id: null,
|
|
215
|
+
graph_node_id: null,
|
|
216
|
+
page_type: null,
|
|
217
|
+
status: "published",
|
|
218
|
+
is_template: false,
|
|
219
|
+
content: { cells: [] },
|
|
220
|
+
layout: null,
|
|
221
|
+
metadata: null,
|
|
222
|
+
...over
|
|
223
|
+
});
|
|
224
|
+
var SYSTEM = fixtureId(20);
|
|
225
|
+
var PROCESS = {
|
|
226
|
+
id: fixtureId(21),
|
|
227
|
+
eng_data_system_id: SYSTEM
|
|
228
|
+
};
|
|
229
|
+
var documentPage = {
|
|
230
|
+
name: "document",
|
|
231
|
+
purpose: "an inline document: numbering, anchors, headings, references, child cells and authored children text",
|
|
232
|
+
page: page(200, {
|
|
233
|
+
name: "Example agreement",
|
|
234
|
+
page_type: "agreement",
|
|
235
|
+
metadata: { content_mode: "inline" },
|
|
236
|
+
content: {
|
|
237
|
+
data: { static: { doc: {
|
|
238
|
+
title: "Example agreement",
|
|
239
|
+
subtitle: "Draft for review"
|
|
240
|
+
} } },
|
|
241
|
+
cells: [
|
|
242
|
+
{
|
|
243
|
+
id: "masthead",
|
|
244
|
+
component: "Masthead",
|
|
245
|
+
props: {
|
|
246
|
+
title: "@doc.title",
|
|
247
|
+
subtitle: "@doc.subtitle"
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
id: "intro",
|
|
252
|
+
component: "Prose",
|
|
253
|
+
props: { children: "This agreement is an example." }
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
id: "terms",
|
|
257
|
+
component: "DocumentSection",
|
|
258
|
+
props: {
|
|
259
|
+
sectionId: "terms",
|
|
260
|
+
title: "Terms",
|
|
261
|
+
blocks: [{
|
|
262
|
+
kind: "clause",
|
|
263
|
+
items: [{
|
|
264
|
+
id: "a",
|
|
265
|
+
text: "First term."
|
|
266
|
+
}, {
|
|
267
|
+
id: "b",
|
|
268
|
+
text: "Second term."
|
|
269
|
+
}]
|
|
270
|
+
}]
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
id: "residue",
|
|
275
|
+
component: "DocumentSection",
|
|
276
|
+
props: {
|
|
277
|
+
sectionId: "residue",
|
|
278
|
+
title: "Residue",
|
|
279
|
+
body: "What is left over."
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
id: "residue-cite",
|
|
284
|
+
component: "SectionReference",
|
|
285
|
+
props: { to: "terms#b" }
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
id: "first-item",
|
|
289
|
+
component: "DocumentSection",
|
|
290
|
+
props: {
|
|
291
|
+
sectionId: "first-item",
|
|
292
|
+
title: "First item"
|
|
293
|
+
}
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
id: "closing-cite",
|
|
297
|
+
component: "SectionReference",
|
|
298
|
+
props: { to: "terms#b" }
|
|
299
|
+
}
|
|
300
|
+
]
|
|
301
|
+
},
|
|
302
|
+
layout: {
|
|
303
|
+
type: "document",
|
|
304
|
+
structure: [
|
|
305
|
+
{ cellId: "masthead" },
|
|
306
|
+
{
|
|
307
|
+
kind: "preamble",
|
|
308
|
+
sectionId: "intro",
|
|
309
|
+
title: "About this document",
|
|
310
|
+
cellId: "intro"
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
kind: "article",
|
|
314
|
+
sectionId: "terms",
|
|
315
|
+
title: "Terms",
|
|
316
|
+
cellId: "terms"
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
kind: "article",
|
|
320
|
+
sectionId: "residue",
|
|
321
|
+
title: "Residue",
|
|
322
|
+
cellId: "residue",
|
|
323
|
+
children: ["residue-cite"]
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
kind: "preamble",
|
|
327
|
+
sectionId: "schedule",
|
|
328
|
+
title: "Schedule",
|
|
329
|
+
children: [{
|
|
330
|
+
kind: "article",
|
|
331
|
+
sectionId: "first-item",
|
|
332
|
+
title: "First item",
|
|
333
|
+
cellId: "first-item"
|
|
334
|
+
}]
|
|
335
|
+
},
|
|
336
|
+
{ cellId: "closing-cite" }
|
|
337
|
+
]
|
|
338
|
+
}
|
|
339
|
+
}),
|
|
340
|
+
bundles: [CLIENT_MAIN]
|
|
341
|
+
};
|
|
342
|
+
var dashboardPage = {
|
|
343
|
+
name: "dashboard",
|
|
344
|
+
purpose: "a grid page: declared producers with a field path, a missing producer, conditions, containment, and a shared store channel",
|
|
345
|
+
page: page(201, {
|
|
346
|
+
name: "Example dashboard",
|
|
347
|
+
page_type: "dashboard",
|
|
348
|
+
process_id: PROCESS.id,
|
|
349
|
+
metadata: { content_mode: "inline" },
|
|
350
|
+
content: {
|
|
351
|
+
data: {
|
|
352
|
+
static: { labels: { worth: "Net worth" } },
|
|
353
|
+
queries: {
|
|
354
|
+
twin: {
|
|
355
|
+
graph_node_id: fixtureId(30),
|
|
356
|
+
field: "result.output"
|
|
357
|
+
},
|
|
358
|
+
goals: { graph_node_id: fixtureId(31) },
|
|
359
|
+
gone: { graph_node_id: fixtureId(32) }
|
|
360
|
+
}
|
|
361
|
+
},
|
|
362
|
+
cells: [
|
|
363
|
+
{
|
|
364
|
+
id: "worth",
|
|
365
|
+
component: "KpiCard",
|
|
366
|
+
props: {
|
|
367
|
+
label: "@labels.worth",
|
|
368
|
+
value: "@twin.net_worth"
|
|
369
|
+
},
|
|
370
|
+
layout: {
|
|
371
|
+
span: 6,
|
|
372
|
+
hideWhen: "narrow"
|
|
373
|
+
}
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
id: "rate",
|
|
377
|
+
component: "KpiCard",
|
|
378
|
+
props: {
|
|
379
|
+
label: "Savings rate",
|
|
380
|
+
value: "@twin.savings_rate"
|
|
381
|
+
},
|
|
382
|
+
layout: { span: 6 }
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
id: "missing-producer",
|
|
386
|
+
component: "KpiCard",
|
|
387
|
+
props: {
|
|
388
|
+
label: "Gone",
|
|
389
|
+
value: "@gone"
|
|
390
|
+
},
|
|
391
|
+
layout: { span: 4 }
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
id: "goals",
|
|
395
|
+
component: "KpiCard",
|
|
396
|
+
props: {
|
|
397
|
+
label: "Goals",
|
|
398
|
+
value: "@goals.count"
|
|
399
|
+
},
|
|
400
|
+
conditions: { showIf: "@goals.enabled" },
|
|
401
|
+
layout: { span: 4 }
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
id: "hidden",
|
|
405
|
+
component: "KpiCard",
|
|
406
|
+
props: {
|
|
407
|
+
label: "Hidden",
|
|
408
|
+
value: 1
|
|
409
|
+
},
|
|
410
|
+
conditions: { hideIf: "@goals.enabled" },
|
|
411
|
+
layout: { span: 4 }
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
id: "own-data",
|
|
415
|
+
component: "KpiCard",
|
|
416
|
+
props: { label: "Own data" },
|
|
417
|
+
data: {
|
|
418
|
+
static: { note: "from the cell" },
|
|
419
|
+
queries: { mine: { graph_node_id: fixtureId(34) } }
|
|
420
|
+
},
|
|
421
|
+
layout: { span: 4 }
|
|
422
|
+
},
|
|
423
|
+
{
|
|
424
|
+
id: "crash",
|
|
425
|
+
component: "Boom",
|
|
426
|
+
layout: { span: 4 }
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
id: "unknown",
|
|
430
|
+
component: "NotInAnyBundle",
|
|
431
|
+
layout: { span: 4 }
|
|
432
|
+
},
|
|
433
|
+
{
|
|
434
|
+
id: "options",
|
|
435
|
+
component: "OptionList",
|
|
436
|
+
props: { options: ["low", "high"] },
|
|
437
|
+
selections: { selected: {
|
|
438
|
+
channel: "risk",
|
|
439
|
+
scope: "page",
|
|
440
|
+
writable: true,
|
|
441
|
+
default: "low"
|
|
442
|
+
} },
|
|
443
|
+
layout: { span: 6 }
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
id: "echo",
|
|
447
|
+
component: "SelectionEcho",
|
|
448
|
+
selections: { selected: {
|
|
449
|
+
channel: "risk",
|
|
450
|
+
scope: "page"
|
|
451
|
+
} },
|
|
452
|
+
layout: { span: 6 }
|
|
453
|
+
}
|
|
454
|
+
]
|
|
455
|
+
},
|
|
456
|
+
layout: {
|
|
457
|
+
type: "grid",
|
|
458
|
+
columns: 12,
|
|
459
|
+
gap: 24
|
|
460
|
+
}
|
|
461
|
+
}),
|
|
462
|
+
process: PROCESS,
|
|
463
|
+
states: [
|
|
464
|
+
{
|
|
465
|
+
system_id: SYSTEM,
|
|
466
|
+
graph_node_id: fixtureId(30),
|
|
467
|
+
data: { result: { output: {
|
|
468
|
+
net_worth: 125e4,
|
|
469
|
+
savings_rate: .18
|
|
470
|
+
} } }
|
|
471
|
+
},
|
|
472
|
+
{
|
|
473
|
+
system_id: SYSTEM,
|
|
474
|
+
graph_node_id: fixtureId(31),
|
|
475
|
+
data: {
|
|
476
|
+
enabled: true,
|
|
477
|
+
count: 3
|
|
478
|
+
}
|
|
479
|
+
},
|
|
480
|
+
{
|
|
481
|
+
system_id: SYSTEM,
|
|
482
|
+
graph_node_id: fixtureId(34),
|
|
483
|
+
data: { mine: true }
|
|
484
|
+
}
|
|
485
|
+
],
|
|
486
|
+
bundles: [CLIENT_MAIN]
|
|
487
|
+
};
|
|
488
|
+
var thinRefPage = {
|
|
489
|
+
name: "thin-ref",
|
|
490
|
+
purpose: "a legacy thin-ref page: hydration from cell_config_latest, hoisted declarations, a pending cell",
|
|
491
|
+
page: page(202, {
|
|
492
|
+
name: "Example legacy page",
|
|
493
|
+
page_type: "legacy",
|
|
494
|
+
process_id: PROCESS.id,
|
|
495
|
+
content: { cells: [
|
|
496
|
+
{
|
|
497
|
+
id: "income",
|
|
498
|
+
graph_node_id: fixtureId(40)
|
|
499
|
+
},
|
|
500
|
+
{
|
|
501
|
+
id: "note",
|
|
502
|
+
graph_node_id: fixtureId(41)
|
|
503
|
+
},
|
|
504
|
+
{
|
|
505
|
+
id: "not-configured",
|
|
506
|
+
graph_node_id: fixtureId(42)
|
|
507
|
+
}
|
|
508
|
+
] },
|
|
509
|
+
layout: {
|
|
510
|
+
type: "grid",
|
|
511
|
+
columns: 12
|
|
512
|
+
}
|
|
513
|
+
}),
|
|
514
|
+
process: PROCESS,
|
|
515
|
+
configs: [{
|
|
516
|
+
system_id: SYSTEM,
|
|
517
|
+
graph_node_id: fixtureId(40),
|
|
518
|
+
config: {
|
|
519
|
+
component: "KpiCard",
|
|
520
|
+
props: {
|
|
521
|
+
label: "Income",
|
|
522
|
+
value: "@income.monthly"
|
|
523
|
+
},
|
|
524
|
+
data: { queries: { income: {
|
|
525
|
+
graph_node_id: fixtureId(33),
|
|
526
|
+
field: "cash"
|
|
527
|
+
} } },
|
|
528
|
+
layout: { span: 4 }
|
|
529
|
+
}
|
|
530
|
+
}, {
|
|
531
|
+
system_id: SYSTEM,
|
|
532
|
+
graph_node_id: fixtureId(41),
|
|
533
|
+
config: {
|
|
534
|
+
component: "Prose",
|
|
535
|
+
props: { children: "Configured on the node." },
|
|
536
|
+
layout: { span: 8 }
|
|
537
|
+
}
|
|
538
|
+
}],
|
|
539
|
+
states: [{
|
|
540
|
+
system_id: SYSTEM,
|
|
541
|
+
graph_node_id: fixtureId(33),
|
|
542
|
+
data: { cash: { monthly: 5e3 } }
|
|
543
|
+
}],
|
|
544
|
+
bundles: [CLIENT_MAIN]
|
|
545
|
+
};
|
|
546
|
+
var mixedPage = {
|
|
547
|
+
name: "mixed",
|
|
548
|
+
purpose: "inline, ref and legacy cells on one page: a ref placed by the page, a ref fallback, form 4 (inline wins), the cascade across the advisor org, and the theme",
|
|
549
|
+
page: page(203, {
|
|
550
|
+
name: "Example mixed page",
|
|
551
|
+
page_type: "mixed",
|
|
552
|
+
process_id: PROCESS.id,
|
|
553
|
+
content: { cells: [
|
|
554
|
+
{
|
|
555
|
+
id: "inline",
|
|
556
|
+
component: "Prose",
|
|
557
|
+
props: { children: "Written on the page." }
|
|
558
|
+
},
|
|
559
|
+
{
|
|
560
|
+
id: "thin",
|
|
561
|
+
graph_node_id: fixtureId(43)
|
|
562
|
+
},
|
|
563
|
+
{
|
|
564
|
+
id: "form4",
|
|
565
|
+
component: "Prose",
|
|
566
|
+
graph_node_id: fixtureId(44),
|
|
567
|
+
props: { children: "The page copy." }
|
|
568
|
+
},
|
|
569
|
+
{
|
|
570
|
+
id: "advisor-only",
|
|
571
|
+
component: "Badge",
|
|
572
|
+
props: { text: "From the advisor org" }
|
|
573
|
+
},
|
|
574
|
+
{
|
|
575
|
+
id: "pinned",
|
|
576
|
+
component: "Prose",
|
|
577
|
+
bundle_ref: {
|
|
578
|
+
bundle: "main",
|
|
579
|
+
org_slug: ADVISOR_ORG.slug
|
|
580
|
+
},
|
|
581
|
+
props: { children: "Pinned to the advisor bundle." }
|
|
582
|
+
},
|
|
583
|
+
{
|
|
584
|
+
id: "managed",
|
|
585
|
+
ref: { graph_node_id: fixtureId(45) },
|
|
586
|
+
component: "Prose",
|
|
587
|
+
props: { children: "The page fallback." },
|
|
588
|
+
layout: { span: 6 }
|
|
589
|
+
},
|
|
590
|
+
{
|
|
591
|
+
id: "fallback",
|
|
592
|
+
ref: { graph_node_id: fixtureId(46) },
|
|
593
|
+
component: "Prose",
|
|
594
|
+
props: { children: "Shown until the node has a config." }
|
|
595
|
+
}
|
|
596
|
+
] }
|
|
597
|
+
}),
|
|
598
|
+
process: PROCESS,
|
|
599
|
+
configs: [
|
|
600
|
+
{
|
|
601
|
+
system_id: SYSTEM,
|
|
602
|
+
graph_node_id: fixtureId(43),
|
|
603
|
+
config: {
|
|
604
|
+
component: "KpiCard",
|
|
605
|
+
props: {
|
|
606
|
+
label: "Thin",
|
|
607
|
+
value: 7
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
},
|
|
611
|
+
{
|
|
612
|
+
system_id: SYSTEM,
|
|
613
|
+
graph_node_id: fixtureId(44),
|
|
614
|
+
config: {
|
|
615
|
+
component: "Prose",
|
|
616
|
+
props: { children: "The node copy." }
|
|
617
|
+
}
|
|
618
|
+
},
|
|
619
|
+
{
|
|
620
|
+
system_id: SYSTEM,
|
|
621
|
+
graph_node_id: fixtureId(45),
|
|
622
|
+
config: {
|
|
623
|
+
component: "KpiCard",
|
|
624
|
+
props: {
|
|
625
|
+
label: "Managed",
|
|
626
|
+
value: 3
|
|
627
|
+
},
|
|
628
|
+
layout: { span: 12 }
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
],
|
|
632
|
+
bundles: [CLIENT_MAIN, ADVISOR_MAIN],
|
|
633
|
+
advisorOrgId: ADVISOR_ORG.id
|
|
634
|
+
};
|
|
635
|
+
var PLAN_SYSTEM = fixtureId(23);
|
|
636
|
+
var WALK_PROCESS = {
|
|
637
|
+
id: fixtureId(22),
|
|
638
|
+
eng_data_system_id: SYSTEM,
|
|
639
|
+
eng_process_system_id: PLAN_SYSTEM
|
|
640
|
+
};
|
|
641
|
+
var PAGE_NODE = fixtureId(50);
|
|
642
|
+
var walkNode = (n, name, over = {}) => ({
|
|
643
|
+
id: fixtureId(n + 100),
|
|
644
|
+
graph_node_id: fixtureId(n),
|
|
645
|
+
name,
|
|
646
|
+
node_type: "data_source",
|
|
647
|
+
status: null,
|
|
648
|
+
content: null,
|
|
649
|
+
rank: null,
|
|
650
|
+
updated_at: null,
|
|
651
|
+
depth: 1,
|
|
652
|
+
state: {},
|
|
653
|
+
...over
|
|
654
|
+
});
|
|
655
|
+
var stateIn = (system, n, data) => ({ [system]: {
|
|
656
|
+
id: fixtureId(n + 200),
|
|
657
|
+
system_id: system,
|
|
658
|
+
data,
|
|
659
|
+
status: null,
|
|
660
|
+
created_at: "2026-09-30T00:00:00Z"
|
|
661
|
+
} });
|
|
662
|
+
var walkPage = {
|
|
663
|
+
name: "walk",
|
|
664
|
+
purpose: "walks from the page node: @_traversal with two state systems, cell-scoped labels, explicit beats discovered, lazy walks",
|
|
665
|
+
page: page(204, {
|
|
666
|
+
name: "Example walk page",
|
|
667
|
+
page_type: "walk",
|
|
668
|
+
process_id: WALK_PROCESS.id,
|
|
669
|
+
graph_node_id: PAGE_NODE,
|
|
670
|
+
metadata: { content_mode: "inline" },
|
|
671
|
+
content: {
|
|
672
|
+
data: { queries: { plan: { graph_node_id: fixtureId(60) } } },
|
|
673
|
+
cells: [
|
|
674
|
+
{
|
|
675
|
+
id: "tree",
|
|
676
|
+
component: "FlowList",
|
|
677
|
+
props: {
|
|
678
|
+
nodes: "@_traversal.nodes",
|
|
679
|
+
edges: "@_traversal.edges"
|
|
680
|
+
},
|
|
681
|
+
traversal: {
|
|
682
|
+
edgeTypes: ["data_flow"],
|
|
683
|
+
maxDepth: 2,
|
|
684
|
+
include_state: ["eng_process", "eng_data"]
|
|
685
|
+
}
|
|
686
|
+
},
|
|
687
|
+
{
|
|
688
|
+
id: "total",
|
|
689
|
+
component: "KpiCard",
|
|
690
|
+
props: {
|
|
691
|
+
label: "Total",
|
|
692
|
+
value: "@twin.total"
|
|
693
|
+
},
|
|
694
|
+
traversal: {
|
|
695
|
+
edgeTypes: ["data_flow"],
|
|
696
|
+
maxDepth: 2
|
|
697
|
+
}
|
|
698
|
+
},
|
|
699
|
+
{
|
|
700
|
+
id: "dup",
|
|
701
|
+
component: "KpiCard",
|
|
702
|
+
props: {
|
|
703
|
+
label: "Dup",
|
|
704
|
+
value: "@dup"
|
|
705
|
+
},
|
|
706
|
+
traversal: {
|
|
707
|
+
edgeTypes: ["data_flow"],
|
|
708
|
+
maxDepth: 2
|
|
709
|
+
}
|
|
710
|
+
},
|
|
711
|
+
{
|
|
712
|
+
id: "declared",
|
|
713
|
+
component: "KpiCard",
|
|
714
|
+
props: {
|
|
715
|
+
label: "Plan",
|
|
716
|
+
value: "@plan.x"
|
|
717
|
+
},
|
|
718
|
+
traversal: {
|
|
719
|
+
edgeTypes: ["data_flow"],
|
|
720
|
+
maxDepth: 1
|
|
721
|
+
}
|
|
722
|
+
},
|
|
723
|
+
{
|
|
724
|
+
id: "both",
|
|
725
|
+
component: "KpiCard",
|
|
726
|
+
props: {
|
|
727
|
+
label: "Both",
|
|
728
|
+
value: "@plan.x",
|
|
729
|
+
count: "@_traversal.nodes.length"
|
|
730
|
+
},
|
|
731
|
+
traversal: {
|
|
732
|
+
edgeTypes: ["data_flow"],
|
|
733
|
+
maxDepth: 2
|
|
734
|
+
}
|
|
735
|
+
},
|
|
736
|
+
{
|
|
737
|
+
id: "no-edge-types",
|
|
738
|
+
component: "KpiCard",
|
|
739
|
+
props: {
|
|
740
|
+
label: "No edge types",
|
|
741
|
+
value: "@found"
|
|
742
|
+
},
|
|
743
|
+
traversal: { maxDepth: 2 }
|
|
744
|
+
},
|
|
745
|
+
{
|
|
746
|
+
id: "sibling",
|
|
747
|
+
component: "KpiCard",
|
|
748
|
+
props: {
|
|
749
|
+
label: "Sibling",
|
|
750
|
+
value: "@twin.total"
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
]
|
|
754
|
+
}
|
|
755
|
+
}),
|
|
756
|
+
process: WALK_PROCESS,
|
|
757
|
+
states: [{
|
|
758
|
+
system_id: SYSTEM,
|
|
759
|
+
graph_node_id: fixtureId(60),
|
|
760
|
+
data: { x: "from the declaration" }
|
|
761
|
+
}],
|
|
762
|
+
walks: [{
|
|
763
|
+
start: PAGE_NODE,
|
|
764
|
+
maxDepth: 2,
|
|
765
|
+
result: {
|
|
766
|
+
truncated: false,
|
|
767
|
+
nodes: [
|
|
768
|
+
walkNode(50, "page", {
|
|
769
|
+
node_type: "project_page",
|
|
770
|
+
depth: 0
|
|
771
|
+
}),
|
|
772
|
+
walkNode(51, "artifact", { content: { role: "page" } }),
|
|
773
|
+
walkNode(52, "twin", {
|
|
774
|
+
content: {
|
|
775
|
+
binding_key: "twin",
|
|
776
|
+
field: "result"
|
|
777
|
+
},
|
|
778
|
+
state: {
|
|
779
|
+
...stateIn(SYSTEM, 52, { result: { total: 99 } }),
|
|
780
|
+
...stateIn(PLAN_SYSTEM, 52, { status: "planned" })
|
|
781
|
+
}
|
|
782
|
+
}),
|
|
783
|
+
walkNode(53, "plan-alt", {
|
|
784
|
+
content: { binding_key: "plan" },
|
|
785
|
+
depth: 2,
|
|
786
|
+
state: stateIn(SYSTEM, 53, { x: "from the walk" })
|
|
787
|
+
}),
|
|
788
|
+
walkNode(54, "dup-a", {
|
|
789
|
+
content: { binding_key: "dup" },
|
|
790
|
+
depth: 2
|
|
791
|
+
}),
|
|
792
|
+
walkNode(55, "dup-b", {
|
|
793
|
+
content: { binding_key: "dup" },
|
|
794
|
+
depth: 2
|
|
795
|
+
})
|
|
796
|
+
],
|
|
797
|
+
edges: [
|
|
798
|
+
{
|
|
799
|
+
id: fixtureId(70),
|
|
800
|
+
edge_id: fixtureId(80),
|
|
801
|
+
source: fixtureId(152),
|
|
802
|
+
target: fixtureId(150),
|
|
803
|
+
edge_type: "data_flow"
|
|
804
|
+
},
|
|
805
|
+
{
|
|
806
|
+
id: fixtureId(71),
|
|
807
|
+
edge_id: fixtureId(81),
|
|
808
|
+
source: fixtureId(153),
|
|
809
|
+
target: fixtureId(152),
|
|
810
|
+
edge_type: "data_flow"
|
|
811
|
+
},
|
|
812
|
+
{
|
|
813
|
+
id: fixtureId(72),
|
|
814
|
+
edge_id: fixtureId(82),
|
|
815
|
+
source: fixtureId(154),
|
|
816
|
+
target: fixtureId(152),
|
|
817
|
+
edge_type: "data_flow"
|
|
818
|
+
},
|
|
819
|
+
{
|
|
820
|
+
id: fixtureId(73),
|
|
821
|
+
edge_id: fixtureId(83),
|
|
822
|
+
source: fixtureId(155),
|
|
823
|
+
target: fixtureId(152),
|
|
824
|
+
edge_type: "data_flow"
|
|
825
|
+
}
|
|
826
|
+
]
|
|
827
|
+
}
|
|
828
|
+
}],
|
|
829
|
+
bundles: [CLIENT_MAIN]
|
|
830
|
+
};
|
|
831
|
+
var GOLDEN_PAGES = [
|
|
832
|
+
documentPage,
|
|
833
|
+
dashboardPage,
|
|
834
|
+
thinRefPage,
|
|
835
|
+
mixedPage,
|
|
836
|
+
walkPage
|
|
837
|
+
];
|
|
838
|
+
//#endregion
|
|
839
|
+
//#region packages/renderer/src/testing/sources.ts
|
|
840
|
+
function goldenGraphSource(g) {
|
|
841
|
+
const calls = [];
|
|
842
|
+
const pick = (rows, systemId, ids) => (rows ?? []).filter((r) => r.system_id === systemId && ids.includes(r.graph_node_id));
|
|
843
|
+
return {
|
|
844
|
+
calls,
|
|
845
|
+
async processSystems(processId) {
|
|
846
|
+
calls.push({
|
|
847
|
+
method: "processSystems",
|
|
848
|
+
args: [processId]
|
|
849
|
+
});
|
|
850
|
+
return g.process && g.process.id === processId ? g.process : null;
|
|
851
|
+
},
|
|
852
|
+
async cellConfigs(systemId, ids) {
|
|
853
|
+
calls.push({
|
|
854
|
+
method: "cellConfigs",
|
|
855
|
+
args: [systemId, ids]
|
|
856
|
+
});
|
|
857
|
+
return Object.fromEntries(pick(g.configs, systemId, ids).map((c) => [c.graph_node_id, c.config]));
|
|
858
|
+
},
|
|
859
|
+
async latestStates(systemId, ids) {
|
|
860
|
+
calls.push({
|
|
861
|
+
method: "latestStates",
|
|
862
|
+
args: [systemId, ids]
|
|
863
|
+
});
|
|
864
|
+
return Object.fromEntries(pick(g.states, systemId, ids).map((s) => [s.graph_node_id, s.data]));
|
|
865
|
+
},
|
|
866
|
+
async walk(request) {
|
|
867
|
+
calls.push({
|
|
868
|
+
method: "walk",
|
|
869
|
+
args: [request]
|
|
870
|
+
});
|
|
871
|
+
const w = (g.walks ?? []).find((x) => x.start === request.start.graphNodeId && (x.maxDepth === void 0 || x.maxDepth === request.maxDepth));
|
|
872
|
+
if (!w) return {
|
|
873
|
+
nodes: [],
|
|
874
|
+
edges: [],
|
|
875
|
+
truncated: false
|
|
876
|
+
};
|
|
877
|
+
const systems = request.states.map((s) => s.systemId);
|
|
878
|
+
return {
|
|
879
|
+
...w.result,
|
|
880
|
+
nodes: w.result.nodes.map((n) => ({
|
|
881
|
+
...n,
|
|
882
|
+
state: Object.fromEntries(systems.map((id) => [id, n.state[id] ?? null]))
|
|
883
|
+
}))
|
|
884
|
+
};
|
|
885
|
+
},
|
|
886
|
+
async nodeRecords(ids, systemIds) {
|
|
887
|
+
calls.push({
|
|
888
|
+
method: "nodeRecords",
|
|
889
|
+
args: [ids, systemIds]
|
|
890
|
+
});
|
|
891
|
+
const out = {};
|
|
892
|
+
for (const w of g.walks ?? []) for (const n of w.result.nodes) {
|
|
893
|
+
if (!ids.includes(n.graph_node_id)) continue;
|
|
894
|
+
const { state, depth: _depth, ...rest } = n;
|
|
895
|
+
out[n.graph_node_id] = {
|
|
896
|
+
...rest,
|
|
897
|
+
stateBySystem: Object.fromEntries(systemIds.map((id) => [id, state[id] ?? null]))
|
|
898
|
+
};
|
|
899
|
+
}
|
|
900
|
+
return out;
|
|
901
|
+
}
|
|
902
|
+
};
|
|
903
|
+
}
|
|
904
|
+
function goldenBundleRow(b) {
|
|
905
|
+
const components = Object.keys(b.module).filter((k) => k !== "ThemeProvider").map((k) => ({
|
|
906
|
+
component_name: k,
|
|
907
|
+
exposed_export: k
|
|
908
|
+
}));
|
|
909
|
+
return {
|
|
910
|
+
...b.row,
|
|
911
|
+
components
|
|
912
|
+
};
|
|
913
|
+
}
|
|
914
|
+
function goldenScope(g) {
|
|
915
|
+
return bundleScope({
|
|
916
|
+
pageOrgId: g.page.org_id,
|
|
917
|
+
pageRefs: g.page.metadata?.bundle_refs ?? [],
|
|
918
|
+
orgs: [g.page.org_id, g.advisorOrgId].filter((id) => Boolean(id)).map((id) => ({ id }))
|
|
919
|
+
});
|
|
920
|
+
}
|
|
921
|
+
function matches(ref, row) {
|
|
922
|
+
if (ref.kind === "pinned") return row.id === ref.bundleId;
|
|
923
|
+
if (!row.is_live || row.bundle_name !== ref.bundle) return false;
|
|
924
|
+
return ref.kind === "lineage" ? row.org_slug === ref.orgSlug : row.org_id === ref.orgId;
|
|
925
|
+
}
|
|
926
|
+
function goldenBundles(g, cells, { loaded = true } = {}) {
|
|
927
|
+
const scope = goldenScope(g);
|
|
928
|
+
const refs = pageBundleRefs(scope, cells, g.page.org_id);
|
|
929
|
+
const all = g.bundles.map((b) => ({
|
|
930
|
+
golden: b,
|
|
931
|
+
row: goldenBundleRow(b)
|
|
932
|
+
}));
|
|
933
|
+
const rows = [];
|
|
934
|
+
for (const ref of refs) {
|
|
935
|
+
const found = all.find((b) => matches(ref, b.row));
|
|
936
|
+
if (found && !rows.some((r) => r.id === found.row.id)) rows.push(found.row);
|
|
937
|
+
}
|
|
938
|
+
const modules = loaded ? rows.map((row) => projectModule(row, all.find((b) => b.row.id === row.id).golden.module, all.find((b) => b.row.id === row.id).golden.contracts)) : null;
|
|
939
|
+
return pageBundles(scope, rows, modules, g.page.org_id);
|
|
940
|
+
}
|
|
941
|
+
//#endregion
|
|
942
|
+
export { ADVISOR_ORG, CLIENT_ORG, FIXTURE_BASE_PROPS, FIXTURE_EMAIL_DOMAIN, FIXTURE_ID, FIXTURE_ORG_SLUGS, GOLDEN_PAGES, dashboardPage, documentPage, components_exports as fixtureComponents, fixtureId, goldenBundleRow, goldenBundles, goldenGraphSource, goldenScope, mixedPage, thinRefPage, walkPage };
|
|
943
|
+
|
|
944
|
+
//# sourceMappingURL=testing.js.map
|