@jam-overture/loom 0.1.0 → 0.2.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 +3 -1
- package/dist/application/application.d.ts +109 -0
- package/dist/application/application.js +97 -0
- package/dist/application/memory.d.ts +20 -0
- package/dist/application/memory.js +79 -0
- package/dist/application/store.d.ts +101 -0
- package/dist/application/store.js +25 -0
- package/dist/audience/audience.d.ts +36 -0
- package/dist/audience/audience.js +41 -0
- package/dist/cli/templates.js +19 -0
- package/dist/data/plan.js +0 -0
- package/dist/data/resolution.d.ts +23 -1
- package/dist/data/resolve.d.ts +30 -3
- package/dist/data/resolve.js +11 -3
- package/dist/ids.d.ts +10 -0
- package/dist/ids.js +11 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/patch.d.ts +54 -0
- package/dist/patch.js +44 -0
- package/dist/project/closing.d.ts +51 -0
- package/dist/project/closing.js +53 -0
- package/dist/project/memory.d.ts +20 -0
- package/dist/project/memory.js +97 -0
- package/dist/project/project.d.ts +90 -0
- package/dist/project/project.js +91 -0
- package/dist/project/store.d.ts +135 -0
- package/dist/project/store.js +41 -0
- package/dist/registered.d.ts +64 -0
- package/dist/registered.js +118 -0
- package/dist/render/behaviour-adjust.d.ts +11 -19
- package/dist/render/behaviour-adjust.js +75 -21
- package/dist/render/behaviour-present.d.ts +8 -0
- package/dist/render/behaviour-present.js +57 -6
- package/dist/render/behaviour.d.ts +98 -17
- package/dist/render/behaviour.js +91 -26
- package/dist/render/control-name.d.ts +68 -0
- package/dist/render/control-name.js +37 -0
- package/dist/render/diagnostics.d.ts +72 -0
- package/dist/render/diagnostics.js +7 -0
- package/dist/render/index.d.ts +2 -0
- package/dist/render/index.js +2 -0
- package/dist/render/reads.d.ts +11 -0
- package/dist/render/reads.js +12 -1
- package/dist/render/render.js +102 -7
- package/dist/render/slots.d.ts +52 -0
- package/dist/render/slots.js +24 -0
- package/dist/render/theme.d.ts +54 -1
- package/dist/render/theme.js +23 -1
- package/dist/render/unshown.d.ts +152 -0
- package/dist/render/unshown.js +80 -0
- package/dist/runtime/analysis.d.ts +94 -9
- package/dist/runtime/analysis.js +54 -9
- package/dist/runtime/assessment.d.ts +36 -2
- package/dist/runtime/assessment.js +27 -2
- package/dist/runtime/checks.d.ts +148 -0
- package/dist/runtime/checks.js +112 -0
- package/dist/runtime/disposition.d.ts +96 -0
- package/dist/runtime/disposition.js +46 -0
- package/dist/runtime/gate.js +22 -0
- package/dist/runtime/index.d.ts +3 -0
- package/dist/runtime/index.js +3 -0
- package/dist/runtime/irreversibility.d.ts +64 -0
- package/dist/runtime/irreversibility.js +45 -0
- package/dist/runtime/pipeline.d.ts +43 -0
- package/dist/runtime/pipeline.js +10 -2
- package/dist/runtime/policy-change.d.ts +93 -0
- package/dist/runtime/policy-change.js +299 -0
- package/dist/runtime/policy-log.d.ts +406 -0
- package/dist/runtime/policy-log.js +285 -0
- package/dist/runtime/reversibility.d.ts +11 -9
- package/dist/runtime/stakes.d.ts +129 -1
- package/dist/runtime/stakes.js +240 -26
- package/dist/runtime/vocabulary.d.ts +164 -7
- package/dist/runtime/vocabulary.js +181 -8
- package/dist/sdk/audit.d.ts +174 -3
- package/dist/sdk/audit.js +176 -17
- package/dist/sdk/catalogue.d.ts +9 -1
- package/dist/sdk/conformance.d.ts +37 -3
- package/dist/sdk/conformance.js +25 -4
- package/dist/sdk/definition.d.ts +65 -0
- package/dist/sdk/definition.js +22 -0
- package/dist/sdk/registry.d.ts +29 -2
- package/dist/sdk/registry.js +63 -1
- package/dist/signals/action-change.d.ts +507 -0
- package/dist/signals/action-change.js +265 -0
- package/dist/signals/action.d.ts +331 -0
- package/dist/signals/action.js +182 -0
- package/dist/signals/applied-window.contract.d.ts +23 -0
- package/dist/signals/applied-window.contract.js +160 -0
- package/dist/signals/arriving.d.ts +210 -0
- package/dist/signals/arriving.js +133 -0
- package/dist/signals/audiences.d.ts +528 -0
- package/dist/signals/audiences.js +255 -0
- package/dist/signals/broadcast.d.ts +8 -2
- package/dist/signals/broadcast.js +58 -8
- package/dist/signals/change.d.ts +378 -0
- package/dist/signals/change.js +327 -0
- package/dist/signals/collect.d.ts +41 -0
- package/dist/signals/collect.js +88 -7
- package/dist/signals/copy-change.d.ts +553 -0
- package/dist/signals/copy-change.js +377 -0
- package/dist/signals/copy.d.ts +337 -0
- package/dist/signals/copy.js +211 -0
- package/dist/signals/counters.d.ts +46 -0
- package/dist/signals/counters.js +102 -0
- package/dist/signals/deliver.d.ts +23 -4
- package/dist/signals/deliver.js +34 -6
- package/dist/signals/deployment-change.d.ts +371 -0
- package/dist/signals/deployment-change.js +268 -0
- package/dist/signals/deployment.d.ts +265 -0
- package/dist/signals/deployment.js +152 -0
- package/dist/signals/door.d.ts +92 -0
- package/dist/signals/door.js +53 -0
- package/dist/signals/fold.d.ts +10 -0
- package/dist/signals/fold.js +5 -1
- package/dist/signals/form-action.d.ts +302 -0
- package/dist/signals/form-action.js +169 -0
- package/dist/signals/form-copy.d.ts +523 -0
- package/dist/signals/form-copy.js +346 -0
- package/dist/signals/forms.d.ts +247 -0
- package/dist/signals/forms.js +147 -0
- package/dist/signals/funnel-change.d.ts +548 -0
- package/dist/signals/funnel-change.js +361 -0
- package/dist/signals/funnel.d.ts +532 -0
- package/dist/signals/funnel.js +216 -0
- package/dist/signals/health.d.ts +497 -0
- package/dist/signals/health.js +361 -0
- package/dist/signals/index.d.ts +41 -0
- package/dist/signals/index.js +41 -0
- package/dist/signals/ingest.d.ts +56 -1
- package/dist/signals/ingest.js +91 -1
- package/dist/signals/journal.d.ts +11 -0
- package/dist/signals/kinds.d.ts +8 -6
- package/dist/signals/kinds.js +14 -6
- package/dist/signals/library-action.d.ts +430 -0
- package/dist/signals/library-action.js +336 -0
- package/dist/signals/library-change.d.ts +477 -0
- package/dist/signals/library-change.js +335 -0
- package/dist/signals/library-copy-change.d.ts +498 -0
- package/dist/signals/library-copy-change.js +476 -0
- package/dist/signals/library-pace.d.ts +319 -0
- package/dist/signals/library-pace.js +305 -0
- package/dist/signals/library-reach-change.d.ts +636 -0
- package/dist/signals/library-reach-change.js +534 -0
- package/dist/signals/library-reach.d.ts +377 -0
- package/dist/signals/library-reach.js +227 -0
- package/dist/signals/library-word-reach-change.d.ts +567 -0
- package/dist/signals/library-word-reach-change.js +568 -0
- package/dist/signals/library.d.ts +306 -0
- package/dist/signals/library.js +178 -0
- package/dist/signals/memory.d.ts +9 -0
- package/dist/signals/memory.js +105 -14
- package/dist/signals/migrate.d.ts +17 -2
- package/dist/signals/migrate.js +122 -5
- package/dist/signals/notice.d.ts +334 -0
- package/dist/signals/notice.js +228 -0
- package/dist/signals/pace-change.d.ts +501 -0
- package/dist/signals/pace-change.js +310 -0
- package/dist/signals/pace.d.ts +296 -0
- package/dist/signals/pace.js +291 -0
- package/dist/signals/page-views.d.ts +365 -0
- package/dist/signals/page-views.js +218 -0
- package/dist/signals/parts.d.ts +344 -0
- package/dist/signals/parts.js +273 -0
- package/dist/signals/postgres.d.ts +16 -2
- package/dist/signals/postgres.js +390 -87
- package/dist/signals/progress.d.ts +212 -0
- package/dist/signals/progress.js +150 -0
- package/dist/signals/ratios.d.ts +108 -0
- package/dist/signals/ratios.js +40 -0
- package/dist/signals/reach.d.ts +309 -0
- package/dist/signals/reach.js +93 -0
- package/dist/signals/readable.d.ts +34 -0
- package/dist/signals/readable.js +34 -0
- package/dist/signals/readership.d.ts +381 -0
- package/dist/signals/readership.js +308 -0
- package/dist/signals/region-pages.d.ts +173 -0
- package/dist/signals/region-pages.js +62 -0
- package/dist/signals/region.d.ts +287 -0
- package/dist/signals/region.js +198 -0
- package/dist/signals/retention.d.ts +141 -0
- package/dist/signals/retention.js +58 -0
- package/dist/signals/rollup.d.ts +67 -3
- package/dist/signals/rollup.js +0 -0
- package/dist/signals/schema.d.ts +432 -1
- package/dist/signals/schema.js +157 -3
- package/dist/signals/signal.d.ts +237 -11
- package/dist/signals/signal.js +70 -10
- package/dist/signals/silence-census.d.ts +205 -0
- package/dist/signals/silence-census.js +87 -0
- package/dist/signals/silences.d.ts +848 -0
- package/dist/signals/silences.js +753 -0
- package/dist/signals/tally.d.ts +140 -11
- package/dist/signals/window-figures.d.ts +148 -0
- package/dist/signals/window-figures.js +42 -0
- package/dist/signals/window.d.ts +866 -0
- package/dist/signals/window.js +693 -0
- package/dist/signals/words.d.ts +24 -0
- package/dist/signals/words.js +24 -0
- package/dist/store/index.d.ts +19 -0
- package/dist/store/index.js +19 -0
- package/dist/store/memory.d.ts +2 -1
- package/dist/store/memory.js +48 -12
- package/dist/store/migrate.d.ts +80 -0
- package/dist/store/migrate.js +259 -7
- package/dist/store/postgres-applications.d.ts +4 -0
- package/dist/store/postgres-applications.js +197 -0
- package/dist/store/postgres-holds.d.ts +10 -1
- package/dist/store/postgres-holds.js +116 -101
- package/dist/store/postgres-policy-log.d.ts +14 -0
- package/dist/store/postgres-policy-log.js +240 -0
- package/dist/store/postgres-projects.d.ts +4 -0
- package/dist/store/postgres-projects.js +217 -0
- package/dist/store/postgres.d.ts +16 -1
- package/dist/store/postgres.js +59 -9
- package/dist/store/replay.d.ts +102 -1
- package/dist/store/replay.js +190 -19
- package/dist/store/reseed.d.ts +238 -0
- package/dist/store/reseed.js +308 -0
- package/dist/store/schema.d.ts +450 -2
- package/dist/store/schema.js +141 -5
- package/dist/store/store.d.ts +29 -6
- package/dist/submit/resolve.js +2 -1
- package/dist/telemetry/calibration.d.ts +25 -0
- package/dist/telemetry/calibration.js +27 -1
- package/dist/telemetry/event.d.ts +391 -33
- package/dist/telemetry/event.js +84 -20
- package/dist/telemetry/index.d.ts +1 -0
- package/dist/telemetry/index.js +1 -0
- package/dist/telemetry/journal.d.ts +72 -3
- package/dist/telemetry/journal.js +9 -0
- package/dist/telemetry/lookup.d.ts +27 -0
- package/dist/telemetry/lookup.js +18 -0
- package/dist/telemetry/memory.js +23 -0
- package/dist/telemetry/migrate.js +22 -1
- package/dist/telemetry/postgres.d.ts +10 -1
- package/dist/telemetry/postgres.js +172 -90
- package/dist/telemetry/remeasure.d.ts +78 -0
- package/dist/telemetry/remeasure.js +83 -0
- package/dist/telemetry/retention.d.ts +2 -2
- package/dist/telemetry/schema.d.ts +17 -0
- package/dist/telemetry/schema.js +27 -1
- package/dist/telemetry/sink.d.ts +2 -2
- package/dist/testing/application-contract.d.ts +14 -0
- package/dist/testing/application-contract.js +270 -0
- package/dist/testing/contracts.d.ts +12 -7
- package/dist/testing/contracts.js +12 -7
- package/dist/testing/definitions.d.ts +78 -0
- package/dist/testing/definitions.js +134 -9
- package/dist/testing/doubles.d.ts +103 -0
- package/dist/testing/doubles.js +143 -0
- package/dist/testing/index.d.ts +2 -2
- package/dist/testing/index.js +2 -2
- package/dist/testing/journal-contract.js +140 -2
- package/dist/testing/model-contract.d.ts +110 -0
- package/dist/testing/model-contract.js +150 -0
- package/dist/testing/policy-log-contract.d.ts +26 -0
- package/dist/testing/policy-log-contract.js +344 -0
- package/dist/testing/project-contract.d.ts +14 -0
- package/dist/testing/project-contract.js +266 -0
- package/dist/testing/reader-signal-contract.d.ts +27 -2
- package/dist/testing/reader-signal-contract.js +475 -5
- package/dist/testing/store-contract.d.ts +7 -1
- package/dist/testing/store-contract.js +84 -3
- package/dist/theme/apply.d.ts +20 -1
- package/dist/theme/apply.js +5 -3
- package/dist/theme/derive.d.ts +22 -0
- package/dist/theme/derive.js +54 -1
- package/dist/theme/library.js +1 -1
- package/dist/theme/measure.d.ts +34 -0
- package/dist/theme/measure.js +30 -1
- package/dist/theme/palettes.js +7 -7
- package/dist/theme/ramp.d.ts +64 -0
- package/dist/theme/ramp.js +114 -0
- package/dist/theme/registry.d.ts +9 -0
- package/dist/theme/registry.js +11 -1
- package/dist/theme/separation.d.ts +97 -3
- package/dist/theme/separation.js +75 -0
- package/dist/tree/compare.d.ts +9 -0
- package/dist/tree/compare.js +18 -0
- package/dist/write/computed.d.ts +60 -0
- package/dist/write/computed.js +61 -0
- package/dist/write/held.d.ts +59 -0
- package/dist/write/index.d.ts +5 -2
- package/dist/write/index.js +5 -2
- package/dist/write/reseed.d.ts +151 -0
- package/dist/write/reseed.js +184 -0
- package/dist/write/revert.js +2 -16
- package/package.json +98 -19
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { applicationIdSchema, applicationSchema } from "../application/application.js";
|
|
3
|
+
import { DEFAULT_PROJECT_ID } from "../project/project.js";
|
|
4
|
+
/**
|
|
5
|
+
* One suite, two implementations.
|
|
6
|
+
*
|
|
7
|
+
* `memoryApplicationStore` calls itself the reference implementation; this is what
|
|
8
|
+
* makes that claim checkable rather than aspirational, on the same terms
|
|
9
|
+
* `store-contract.ts` and `hold-contract.ts` already set. The alternative —
|
|
10
|
+
* each store asserted against its own expectations — is how two stores that
|
|
11
|
+
* disagree both stay green.
|
|
12
|
+
*/
|
|
13
|
+
export const applicationFixture = (over = {}) => applicationSchema.parse({
|
|
14
|
+
applicationId: applicationIdSchema.parse("app_fixture"),
|
|
15
|
+
projectId: DEFAULT_PROJECT_ID,
|
|
16
|
+
name: "A fixture",
|
|
17
|
+
createdAt: "2026-10-12T12:00:00.000Z",
|
|
18
|
+
...over,
|
|
19
|
+
});
|
|
20
|
+
export const describeApplicationStoreContract = (name, make) => {
|
|
21
|
+
describe(`${name} — the project store contract`, () => {
|
|
22
|
+
it("reads back what it recorded", async () => {
|
|
23
|
+
const store = await make();
|
|
24
|
+
const project = applicationFixture({ name: "The bakery" });
|
|
25
|
+
expect(await store.create(project)).toEqual({ ok: true, value: project });
|
|
26
|
+
expect(await store.get(project.applicationId)).toEqual({ ok: true, value: project });
|
|
27
|
+
});
|
|
28
|
+
it("keeps a host when one was given, and omits the key when none was", async () => {
|
|
29
|
+
const store = await make();
|
|
30
|
+
const withHost = applicationFixture({
|
|
31
|
+
applicationId: applicationIdSchema.parse("app_hosted"),
|
|
32
|
+
host: "shop.example.com",
|
|
33
|
+
});
|
|
34
|
+
const without = applicationFixture({ applicationId: applicationIdSchema.parse("app_bare") });
|
|
35
|
+
await store.create(withHost);
|
|
36
|
+
await store.create(without);
|
|
37
|
+
const read = await store.get(withHost.applicationId);
|
|
38
|
+
expect(read.ok && read.value.host).toBe("shop.example.com");
|
|
39
|
+
const bare = await store.get(without.applicationId);
|
|
40
|
+
expect(bare.ok && "host" in bare.value).toBe(false);
|
|
41
|
+
});
|
|
42
|
+
it("refuses an id already taken rather than overwriting the rows under it", async () => {
|
|
43
|
+
const store = await make();
|
|
44
|
+
const first = applicationFixture({ name: "The first" });
|
|
45
|
+
await store.create(first);
|
|
46
|
+
const second = await store.create(applicationFixture({ name: "The second" }));
|
|
47
|
+
expect(second).toEqual({
|
|
48
|
+
ok: false,
|
|
49
|
+
error: { code: "already-exists", applicationId: first.applicationId },
|
|
50
|
+
});
|
|
51
|
+
const read = await store.get(first.applicationId);
|
|
52
|
+
expect(read.ok && read.value.name).toBe("The first");
|
|
53
|
+
});
|
|
54
|
+
it("says not-found rather than returning nothing", async () => {
|
|
55
|
+
const store = await make();
|
|
56
|
+
const missing = applicationIdSchema.parse("app_nobody");
|
|
57
|
+
expect(await store.get(missing)).toEqual({
|
|
58
|
+
ok: false,
|
|
59
|
+
error: { code: "not-found", applicationId: missing },
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
it("lists nothing before anything is recorded", async () => {
|
|
63
|
+
const store = await make();
|
|
64
|
+
expect(await store.list()).toEqual({ ok: true, value: [] });
|
|
65
|
+
});
|
|
66
|
+
it("lists oldest first, whatever order they were written in", async () => {
|
|
67
|
+
const store = await make();
|
|
68
|
+
await store.create(applicationFixture({
|
|
69
|
+
applicationId: applicationIdSchema.parse("app_third"),
|
|
70
|
+
createdAt: "2026-10-12T14:00:00.000Z",
|
|
71
|
+
}));
|
|
72
|
+
await store.create(applicationFixture({
|
|
73
|
+
applicationId: applicationIdSchema.parse("app_first"),
|
|
74
|
+
createdAt: "2026-10-12T10:00:00.000Z",
|
|
75
|
+
}));
|
|
76
|
+
await store.create(applicationFixture({
|
|
77
|
+
applicationId: applicationIdSchema.parse("app_second"),
|
|
78
|
+
createdAt: "2026-10-12T12:00:00.000Z",
|
|
79
|
+
}));
|
|
80
|
+
const listed = await store.list();
|
|
81
|
+
expect(listed.ok && listed.value.map((project) => project.applicationId)).toEqual([
|
|
82
|
+
"app_first",
|
|
83
|
+
"app_second",
|
|
84
|
+
"app_third",
|
|
85
|
+
]);
|
|
86
|
+
});
|
|
87
|
+
it("renames without touching anything else", async () => {
|
|
88
|
+
const store = await make();
|
|
89
|
+
const project = applicationFixture({ name: "Before", host: "old.example.com" });
|
|
90
|
+
await store.create(project);
|
|
91
|
+
const renamed = await store.rename(project.applicationId, { name: "After" });
|
|
92
|
+
expect(renamed).toEqual({
|
|
93
|
+
ok: true,
|
|
94
|
+
value: { ...project, name: "After" },
|
|
95
|
+
});
|
|
96
|
+
const read = await store.get(project.applicationId);
|
|
97
|
+
expect(read.ok && read.value.host).toBe("old.example.com");
|
|
98
|
+
});
|
|
99
|
+
it("sets a host on a project that had none", async () => {
|
|
100
|
+
const store = await make();
|
|
101
|
+
const project = applicationFixture();
|
|
102
|
+
await store.create(project);
|
|
103
|
+
const moved = await store.rename(project.applicationId, { host: "shop.example.com" });
|
|
104
|
+
expect(moved.ok && moved.value.host).toBe("shop.example.com");
|
|
105
|
+
});
|
|
106
|
+
/**
|
|
107
|
+
* The three states of a patch, on the one field that has them.
|
|
108
|
+
*
|
|
109
|
+
* A host is the only thing about an application a person can be given and
|
|
110
|
+
* then want taken away, and until a patch could say so the call that meant
|
|
111
|
+
* *remove it* was the same call that meant *leave it alone* — so a settings
|
|
112
|
+
* screen that emptied the box renamed nothing and reported success. Both
|
|
113
|
+
* stores answer this the same way or neither is trustworthy: one holds a
|
|
114
|
+
* `Map` where a missing key is the absence, the other a column where it is
|
|
115
|
+
* `NULL`.
|
|
116
|
+
*/
|
|
117
|
+
it("clears a host on null, leaving an application with none", async () => {
|
|
118
|
+
const store = await make();
|
|
119
|
+
const project = applicationFixture({ host: "old.example.com" });
|
|
120
|
+
await store.create(project);
|
|
121
|
+
const cleared = await store.rename(project.applicationId, { host: null });
|
|
122
|
+
expect(cleared.ok && cleared.value.host).toBeUndefined();
|
|
123
|
+
const read = await store.get(project.applicationId);
|
|
124
|
+
expect(read.ok && read.value.host).toBeUndefined();
|
|
125
|
+
});
|
|
126
|
+
/**
|
|
127
|
+
* A cleared host has to read back as the absence an application that never
|
|
128
|
+
* had one reads back as, rather than as a key holding `undefined`. The two
|
|
129
|
+
* are the same value to a reader and different objects to anything that
|
|
130
|
+
* walks the record — and only one of them is what `applicationSchema`
|
|
131
|
+
* produces.
|
|
132
|
+
*/
|
|
133
|
+
it("clears a host to the same absence an application that never had one has", async () => {
|
|
134
|
+
const store = await make();
|
|
135
|
+
const never = applicationFixture({ applicationId: applicationIdSchema.parse("app_never") });
|
|
136
|
+
const cleared = applicationFixture({
|
|
137
|
+
applicationId: applicationIdSchema.parse("app_cleared"),
|
|
138
|
+
host: "old.example.com",
|
|
139
|
+
});
|
|
140
|
+
await store.create(never);
|
|
141
|
+
await store.create(cleared);
|
|
142
|
+
await store.rename(cleared.applicationId, { host: null });
|
|
143
|
+
const left = await store.get(never.applicationId);
|
|
144
|
+
const right = await store.get(cleared.applicationId);
|
|
145
|
+
expect(left.ok && Object.keys(left.value).sort()).toEqual(right.ok && Object.keys(right.value).sort());
|
|
146
|
+
});
|
|
147
|
+
it("clears a host that was never there without failing", async () => {
|
|
148
|
+
const store = await make();
|
|
149
|
+
const project = applicationFixture();
|
|
150
|
+
await store.create(project);
|
|
151
|
+
const cleared = await store.rename(project.applicationId, { host: null });
|
|
152
|
+
expect(cleared.ok && cleared.value.host).toBeUndefined();
|
|
153
|
+
});
|
|
154
|
+
it("renames and clears the host in one call", async () => {
|
|
155
|
+
const store = await make();
|
|
156
|
+
const project = applicationFixture({ name: "Before", host: "old.example.com" });
|
|
157
|
+
await store.create(project);
|
|
158
|
+
const renamed = await store.rename(project.applicationId, { name: "After", host: null });
|
|
159
|
+
expect(renamed.ok && renamed.value.name).toBe("After");
|
|
160
|
+
expect(renamed.ok && renamed.value.host).toBeUndefined();
|
|
161
|
+
});
|
|
162
|
+
/**
|
|
163
|
+
* Clearing is `null` and nothing else. An empty string is a value the
|
|
164
|
+
* schema refuses, and a store that accepted it as the absence would be a
|
|
165
|
+
* second spelling of nothing for every later field to disagree about.
|
|
166
|
+
*/
|
|
167
|
+
it("refuses an empty host rather than reading it as cleared", async () => {
|
|
168
|
+
const store = await make();
|
|
169
|
+
const project = applicationFixture({ host: "old.example.com" });
|
|
170
|
+
await store.create(project);
|
|
171
|
+
const refused = await store.rename(project.applicationId, { host: "" });
|
|
172
|
+
expect(refused.ok).toBe(false);
|
|
173
|
+
const read = await store.get(project.applicationId);
|
|
174
|
+
expect(read.ok && read.value.host).toBe("old.example.com");
|
|
175
|
+
});
|
|
176
|
+
it("refuses to rename a project that is not there", async () => {
|
|
177
|
+
const store = await make();
|
|
178
|
+
const missing = applicationIdSchema.parse("app_nobody");
|
|
179
|
+
expect(await store.rename(missing, { name: "Anything" })).toEqual({
|
|
180
|
+
ok: false,
|
|
181
|
+
error: { code: "not-found", applicationId: missing },
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
/**
|
|
185
|
+
* The two stores have to agree about what a project is, not merely about
|
|
186
|
+
* what they store. An empty name is the cheapest way to ask: `applicationSchema`
|
|
187
|
+
* refuses it, and a store that spread the change instead of parsing it would
|
|
188
|
+
* accept it here and be refused by the column somewhere else.
|
|
189
|
+
*/
|
|
190
|
+
it("refuses a rename the project schema would not accept", async () => {
|
|
191
|
+
const store = await make();
|
|
192
|
+
const project = applicationFixture();
|
|
193
|
+
await store.create(project);
|
|
194
|
+
const refused = await store.rename(project.applicationId, { name: "" });
|
|
195
|
+
expect(refused.ok).toBe(false);
|
|
196
|
+
const read = await store.get(project.applicationId);
|
|
197
|
+
expect(read.ok && read.value.name).toBe(project.name);
|
|
198
|
+
});
|
|
199
|
+
/**
|
|
200
|
+
* ## Closing (0289)
|
|
201
|
+
*
|
|
202
|
+
* The same shape the project store takes, held here too — an application is
|
|
203
|
+
* closed by its own id or by its project closing, and the two must not be
|
|
204
|
+
* able to disagree about what closed means.
|
|
205
|
+
*/
|
|
206
|
+
describe("closing", () => {
|
|
207
|
+
const AT = "2026-10-16T09:00:00.000Z";
|
|
208
|
+
const LATER = "2026-10-16T10:00:00.000Z";
|
|
209
|
+
it("stamps when it was closed", async () => {
|
|
210
|
+
const store = await make();
|
|
211
|
+
const application = applicationFixture();
|
|
212
|
+
await store.create(application);
|
|
213
|
+
const closed = await store.close(application.applicationId, AT);
|
|
214
|
+
expect(closed.ok && closed.value.closedAt).toBe(AT);
|
|
215
|
+
});
|
|
216
|
+
it("still answers for it by id", async () => {
|
|
217
|
+
const store = await make();
|
|
218
|
+
const application = applicationFixture();
|
|
219
|
+
await store.create(application);
|
|
220
|
+
await store.close(application.applicationId, AT);
|
|
221
|
+
const read = await store.get(application.applicationId);
|
|
222
|
+
expect(read.ok && read.value.closedAt).toBe(AT);
|
|
223
|
+
});
|
|
224
|
+
it("leaves it out of a listing that did not ask for it", async () => {
|
|
225
|
+
const store = await make();
|
|
226
|
+
const application = applicationFixture();
|
|
227
|
+
await store.create(application);
|
|
228
|
+
await store.close(application.applicationId, AT);
|
|
229
|
+
const listed = await store.list();
|
|
230
|
+
expect(listed.ok && listed.value).toEqual([]);
|
|
231
|
+
});
|
|
232
|
+
it("does not move the instant when it is closed again", async () => {
|
|
233
|
+
const store = await make();
|
|
234
|
+
const application = applicationFixture();
|
|
235
|
+
await store.create(application);
|
|
236
|
+
await store.close(application.applicationId, AT);
|
|
237
|
+
const again = await store.close(application.applicationId, LATER);
|
|
238
|
+
expect(again.ok && again.value.closedAt).toBe(AT);
|
|
239
|
+
});
|
|
240
|
+
/**
|
|
241
|
+
* A closed application keeps its host. Closing says it has stopped, not
|
|
242
|
+
* that it was never anywhere — and the host is what a person needs to
|
|
243
|
+
* recognise it by when they come looking for it to reopen.
|
|
244
|
+
*/
|
|
245
|
+
it("keeps the rest of the row exactly as it was", async () => {
|
|
246
|
+
const store = await make();
|
|
247
|
+
const application = applicationFixture({ host: "shop.example.com" });
|
|
248
|
+
await store.create(application);
|
|
249
|
+
const closed = await store.close(application.applicationId, AT);
|
|
250
|
+
expect(closed.ok && closed.value.host).toBe("shop.example.com");
|
|
251
|
+
expect(closed.ok && closed.value.name).toBe(application.name);
|
|
252
|
+
});
|
|
253
|
+
it("opens it again, and the stamp goes rather than emptying", async () => {
|
|
254
|
+
const store = await make();
|
|
255
|
+
const application = applicationFixture();
|
|
256
|
+
await store.create(application);
|
|
257
|
+
await store.close(application.applicationId, AT);
|
|
258
|
+
const reopened = await store.reopen(application.applicationId);
|
|
259
|
+
expect(reopened.ok && reopened.value.closedAt).toBeUndefined();
|
|
260
|
+
});
|
|
261
|
+
it("says so when there is no such application to close", async () => {
|
|
262
|
+
const store = await make();
|
|
263
|
+
const closed = await store.close(applicationIdSchema.parse("app_nothing"), AT);
|
|
264
|
+
expect(closed.ok).toBe(false);
|
|
265
|
+
expect(!closed.ok && closed.error.code).toBe("not-found");
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
};
|
|
270
|
+
//# sourceMappingURL=application-contract.js.map
|
|
@@ -2,13 +2,16 @@
|
|
|
2
2
|
* The suites a host runs against its own implementation, published as
|
|
3
3
|
* `@jam-overture/loom/testing/contracts`.
|
|
4
4
|
*
|
|
5
|
-
* A `TreeStore`, a `HoldStore` and a `
|
|
6
|
-
* an in-memory implementation of each and a Postgres one, and a host
|
|
7
|
-
* expected to be able to write a third.
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
5
|
+
* A `TreeStore`, a `HoldStore`, a `TelemetryJournal` and a `PolicyLog` are seams:
|
|
6
|
+
* Loom ships an in-memory implementation of each and a Postgres one, and a host
|
|
7
|
+
* is expected to be able to write a third. A `ModelClient` is the same kind of
|
|
8
|
+
* thing one step further out — Loom ships *one* implementation of it, and 0005
|
|
9
|
+
* made even that one opt-in so a host could bring its own. What it cannot do from
|
|
10
|
+
* outside this repository is find out whether the third one is *right*. The
|
|
11
|
+
* promises are not in the type — an append is ordered, a hold is exclusive, a
|
|
12
|
+
* journal is append-only, a policy's revisions are dense and attributed — and a
|
|
13
|
+
* host discovering each of them from a production incident is the seam being
|
|
14
|
+
* offered without the thing that makes it safe to take.
|
|
12
15
|
*
|
|
13
16
|
* So the suite this package runs against its own two implementations is the
|
|
14
17
|
* suite it hands anybody writing a third. It is the same code, not a
|
|
@@ -28,7 +31,9 @@
|
|
|
28
31
|
* which the Postgres suites already do.
|
|
29
32
|
*/
|
|
30
33
|
export { describeHoldStoreContract, heldProposalFixture } from "./hold-contract.js";
|
|
34
|
+
export { CONTRACT_REPLY, CONTRACT_SERVED_BY, contractRequest, describeModelClientContract, MODEL_SITUATIONS, type ModelClientContract, type ModelSituation, type ModelSituationClient, } from "./model-contract.js";
|
|
31
35
|
export { describeTelemetryJournalContract, sampleEpisode } from "./journal-contract.js";
|
|
36
|
+
export { describePolicyLogContract, policyNamed, recordingOf } from "./policy-log-contract.js";
|
|
32
37
|
export { rowSecurityOn } from "./row-security.js";
|
|
33
38
|
export { appendOf, describeTreeStoreContract, removalOf, treeNamed, } from "./store-contract.js";
|
|
34
39
|
//# sourceMappingURL=contracts.d.ts.map
|
|
@@ -2,13 +2,16 @@
|
|
|
2
2
|
* The suites a host runs against its own implementation, published as
|
|
3
3
|
* `@jam-overture/loom/testing/contracts`.
|
|
4
4
|
*
|
|
5
|
-
* A `TreeStore`, a `HoldStore` and a `
|
|
6
|
-
* an in-memory implementation of each and a Postgres one, and a host
|
|
7
|
-
* expected to be able to write a third.
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
5
|
+
* A `TreeStore`, a `HoldStore`, a `TelemetryJournal` and a `PolicyLog` are seams:
|
|
6
|
+
* Loom ships an in-memory implementation of each and a Postgres one, and a host
|
|
7
|
+
* is expected to be able to write a third. A `ModelClient` is the same kind of
|
|
8
|
+
* thing one step further out — Loom ships *one* implementation of it, and 0005
|
|
9
|
+
* made even that one opt-in so a host could bring its own. What it cannot do from
|
|
10
|
+
* outside this repository is find out whether the third one is *right*. The
|
|
11
|
+
* promises are not in the type — an append is ordered, a hold is exclusive, a
|
|
12
|
+
* journal is append-only, a policy's revisions are dense and attributed — and a
|
|
13
|
+
* host discovering each of them from a production incident is the seam being
|
|
14
|
+
* offered without the thing that makes it safe to take.
|
|
12
15
|
*
|
|
13
16
|
* So the suite this package runs against its own two implementations is the
|
|
14
17
|
* suite it hands anybody writing a third. It is the same code, not a
|
|
@@ -28,7 +31,9 @@
|
|
|
28
31
|
* which the Postgres suites already do.
|
|
29
32
|
*/
|
|
30
33
|
export { describeHoldStoreContract, heldProposalFixture } from "./hold-contract.js";
|
|
34
|
+
export { CONTRACT_REPLY, CONTRACT_SERVED_BY, contractRequest, describeModelClientContract, MODEL_SITUATIONS, } from "./model-contract.js";
|
|
31
35
|
export { describeTelemetryJournalContract, sampleEpisode } from "./journal-contract.js";
|
|
36
|
+
export { describePolicyLogContract, policyNamed, recordingOf } from "./policy-log-contract.js";
|
|
32
37
|
export { rowSecurityOn } from "./row-security.js";
|
|
33
38
|
export { appendOf, describeTreeStoreContract, removalOf, treeNamed, } from "./store-contract.js";
|
|
34
39
|
//# sourceMappingURL=contracts.js.map
|
|
@@ -12,4 +12,82 @@ export declare const testDefinitions: readonly PrimitiveEntry[];
|
|
|
12
12
|
*/
|
|
13
13
|
export declare const registryOf: (entries: readonly PrimitiveEntry[]) => PrimitiveRegistry;
|
|
14
14
|
export declare const testRegistry: () => PrimitiveRegistry;
|
|
15
|
+
/**
|
|
16
|
+
* The ways a primitive's declaration of what it could not show can fail to be
|
|
17
|
+
* believed, named for what the author's code did rather than for the sentence
|
|
18
|
+
* the runtime writes about it.
|
|
19
|
+
*
|
|
20
|
+
* `throws` is the fault `UnshownFault` calls `threw`. The other six are its
|
|
21
|
+
* `impossible` arm, which is one kind carrying six details — and the details
|
|
22
|
+
* are what a lane demonstrating the diagnostic needs, because the kind is the
|
|
23
|
+
* same word for a declaration that returned a number and one that said it
|
|
24
|
+
* showed thirteen of twelve rows.
|
|
25
|
+
*/
|
|
26
|
+
declare const BREAKAGES: readonly ["throws", "not-an-array", "not-a-reading", "unnamed", "uncountable-given", "uncountable-shown", "more-shown-than-given"];
|
|
27
|
+
export type UnshownBreakage = (typeof BREAKAGES)[number];
|
|
28
|
+
/**
|
|
29
|
+
* Every breakage, in the order `readUnshown` refuses them, so a lane showing
|
|
30
|
+
* the fault once per shape can iterate rather than keep its own list.
|
|
31
|
+
*
|
|
32
|
+
* The list is the type rather than a copy of it: `UnshownBreakage` is read off
|
|
33
|
+
* these entries and `BROKEN_DECLARATIONS` is keyed on the type, so a member
|
|
34
|
+
* added here without a declaration, or a declaration without a member, is a
|
|
35
|
+
* typecheck error rather than a gap.
|
|
36
|
+
*
|
|
37
|
+
* **What is maintained rather than proved is the other direction** — against the
|
|
38
|
+
* runtime. No construction here makes a refusal path added to `readUnshown`
|
|
39
|
+
* with nothing added to this list fail a test, so this door could fall one fault
|
|
40
|
+
* behind the walk it stands in for, silently. `definitions.test.ts` holds the
|
|
41
|
+
* next best thing: every member is refused, no two members produce the same
|
|
42
|
+
* fault, and each detail is pinned to the exact sentence the runtime writes — so
|
|
43
|
+
* a message that moves goes red here and somebody looks at the list.
|
|
44
|
+
*/
|
|
45
|
+
export declare const UNSHOWN_BREAKAGES: readonly UnshownBreakage[];
|
|
46
|
+
/**
|
|
47
|
+
* A primitive that breaks the one declaration no tree and no deployment can
|
|
48
|
+
* break for it, in whichever way the caller names.
|
|
49
|
+
*
|
|
50
|
+
* `unshown-unreadable` is the single member of `RenderDiagnostic` addressed to
|
|
51
|
+
* whoever wrote the component (0206): the declaration lives *inside* the
|
|
52
|
+
* primitive, so only a primitive can break it. Nothing in the starter library
|
|
53
|
+
* does — all five that declare `unshown` compute the figure from the answer
|
|
54
|
+
* they were handed, which is the whole point of declaring the function the
|
|
55
|
+
* component already calls — and neither `testPrimitives` nor
|
|
56
|
+
* `undecoratedPrimitive` stood in for one. So every lane wanting to demonstrate
|
|
57
|
+
* the code wrote its own broken component, and `Loom docs` wrote one for *What
|
|
58
|
+
* a render reports* before filing for this.
|
|
59
|
+
*
|
|
60
|
+
* **One parameterised stand-in rather than a catalogue of broken components**,
|
|
61
|
+
* which is what the filing asked for in those words: a catalogue in the testing
|
|
62
|
+
* door would be a second library to keep true.
|
|
63
|
+
*
|
|
64
|
+
* Well-behaved in every other respect, deliberately. It spreads
|
|
65
|
+
* `loom.editable`, places what it is handed, and declares its props — so the
|
|
66
|
+
* one thing wrong with it is the thing the caller asked to be wrong, and a
|
|
67
|
+
* render of it raises exactly one diagnostic.
|
|
68
|
+
*
|
|
69
|
+
* Its props are declared **open**, where `loom.card` next door is strict, and
|
|
70
|
+
* that is the one place this fixture prefers forgiveness to realism: props the
|
|
71
|
+
* schema refuses omit the node altogether, which would take the declaration
|
|
72
|
+
* with them and hand a lane an empty diagnostic list instead of the fault it
|
|
73
|
+
* asked for. A stand-in that can be silenced by an unrelated prop is a stand-in
|
|
74
|
+
* that will be.
|
|
75
|
+
*
|
|
76
|
+
* The type carries the breakage, so all seven can be registered together and
|
|
77
|
+
* rendered in one tree. Read it off the entry rather than writing it out:
|
|
78
|
+
*
|
|
79
|
+
* ```ts
|
|
80
|
+
* const definition = brokenUnshownDefinition("throws")
|
|
81
|
+
* const registry = registryOf([definition])
|
|
82
|
+
* // …then a node of `definition.type` carrying a `loom:data` declaration.
|
|
83
|
+
* ```
|
|
84
|
+
*
|
|
85
|
+
* It declares no `reads`, and that absence is load-bearing. A declared name the
|
|
86
|
+
* caller did not answer under would add `data-unread` to the render, so the
|
|
87
|
+
* list a lane asserts would depend on which name it chose to answer. Silent
|
|
88
|
+
* unless declared is the bargain `reads` makes, and taking it is what keeps the
|
|
89
|
+
* one-diagnostic promise above true whatever the caller does.
|
|
90
|
+
*/
|
|
91
|
+
export declare const brokenUnshownDefinition: (breakage: UnshownBreakage) => PrimitiveEntry;
|
|
92
|
+
export {};
|
|
15
93
|
//# sourceMappingURL=definitions.d.ts.map
|
|
@@ -12,17 +12,27 @@ import { createPrimitiveRegistry, describeRegistryError } from "../sdk/registry.
|
|
|
12
12
|
* are legitimate choices a primitive author makes and the render seam has to
|
|
13
13
|
* behave correctly for each.
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
/**
|
|
16
|
+
* The body every well-behaved primitive in this file has: it spreads
|
|
17
|
+
* `loom.editable` onto its own root, places every region it was handed in tree
|
|
18
|
+
* order, and adds no element of its own to carry either.
|
|
19
|
+
*
|
|
20
|
+
* Shared so that the stand-in below is well-behaved in the one way that matters
|
|
21
|
+
* to it — a fixture written to break a *declaration* must not also fail the §4
|
|
22
|
+
* probe, or a lane cannot tell which of the two it is looking at.
|
|
23
|
+
*/
|
|
24
|
+
const hostComponent = (label, tag) => {
|
|
16
25
|
const Primitive = ({ loom, props: bag, children }) => createElement(tag, { ...loom.editable, "data-props": JSON.stringify(bag) }, children, Object.keys(loom.slots).map((name) => loom.slots[name]));
|
|
17
|
-
Primitive.displayName =
|
|
18
|
-
return
|
|
19
|
-
type,
|
|
20
|
-
description,
|
|
21
|
-
props,
|
|
22
|
-
component: Primitive,
|
|
23
|
-
...(slots ? { slots } : {}),
|
|
24
|
-
});
|
|
26
|
+
Primitive.displayName = label;
|
|
27
|
+
return Primitive;
|
|
25
28
|
};
|
|
29
|
+
const declared = (type, description, props, tag, slots) => definePrimitive({
|
|
30
|
+
type,
|
|
31
|
+
description,
|
|
32
|
+
props,
|
|
33
|
+
component: hostComponent(`declared(${type})`, tag),
|
|
34
|
+
...(slots ? { slots } : {}),
|
|
35
|
+
});
|
|
26
36
|
export const pageDefinition = declared("loom.page", "The page shell; everything else lives inside it", z.object({ title: z.string(), subtitle: z.string().optional() }), "main", ["main"]);
|
|
27
37
|
export const cardDefinition = declared("loom.card", "A bounded block of related content", z.object({ variant: z.enum(["outlined", "filled"]), elevation: z.number().optional() }).strict(), "article");
|
|
28
38
|
export const headerDefinition = declared("loom.header", "The banner at the top of a page", z.object({}), "header");
|
|
@@ -45,4 +55,119 @@ export const registryOf = (entries) => {
|
|
|
45
55
|
return built.value;
|
|
46
56
|
};
|
|
47
57
|
export const testRegistry = () => registryOf(testDefinitions);
|
|
58
|
+
/**
|
|
59
|
+
* The ways a primitive's declaration of what it could not show can fail to be
|
|
60
|
+
* believed, named for what the author's code did rather than for the sentence
|
|
61
|
+
* the runtime writes about it.
|
|
62
|
+
*
|
|
63
|
+
* `throws` is the fault `UnshownFault` calls `threw`. The other six are its
|
|
64
|
+
* `impossible` arm, which is one kind carrying six details — and the details
|
|
65
|
+
* are what a lane demonstrating the diagnostic needs, because the kind is the
|
|
66
|
+
* same word for a declaration that returned a number and one that said it
|
|
67
|
+
* showed thirteen of twelve rows.
|
|
68
|
+
*/
|
|
69
|
+
const BREAKAGES = [
|
|
70
|
+
"throws",
|
|
71
|
+
"not-an-array",
|
|
72
|
+
"not-a-reading",
|
|
73
|
+
"unnamed",
|
|
74
|
+
"uncountable-given",
|
|
75
|
+
"uncountable-shown",
|
|
76
|
+
"more-shown-than-given",
|
|
77
|
+
];
|
|
78
|
+
/**
|
|
79
|
+
* Every breakage, in the order `readUnshown` refuses them, so a lane showing
|
|
80
|
+
* the fault once per shape can iterate rather than keep its own list.
|
|
81
|
+
*
|
|
82
|
+
* The list is the type rather than a copy of it: `UnshownBreakage` is read off
|
|
83
|
+
* these entries and `BROKEN_DECLARATIONS` is keyed on the type, so a member
|
|
84
|
+
* added here without a declaration, or a declaration without a member, is a
|
|
85
|
+
* typecheck error rather than a gap.
|
|
86
|
+
*
|
|
87
|
+
* **What is maintained rather than proved is the other direction** — against the
|
|
88
|
+
* runtime. No construction here makes a refusal path added to `readUnshown`
|
|
89
|
+
* with nothing added to this list fail a test, so this door could fall one fault
|
|
90
|
+
* behind the walk it stands in for, silently. `definitions.test.ts` holds the
|
|
91
|
+
* next best thing: every member is refused, no two members produce the same
|
|
92
|
+
* fault, and each detail is pinned to the exact sentence the runtime writes — so
|
|
93
|
+
* a message that moves goes red here and somebody looks at the list.
|
|
94
|
+
*/
|
|
95
|
+
export const UNSHOWN_BREAKAGES = BREAKAGES;
|
|
96
|
+
/** The binding name the broken readings claim to have read, so a caller
|
|
97
|
+
* answering under it meets a stand-in that looks like a real bound listing. */
|
|
98
|
+
const BROKEN_READING_BINDING = "entries";
|
|
99
|
+
/**
|
|
100
|
+
* A declaration returning what the type forbids, which is the point rather than
|
|
101
|
+
* a shortcut.
|
|
102
|
+
*
|
|
103
|
+
* `readUnshown` checks what its own types already promise — that the return is
|
|
104
|
+
* an array, that each member is an object — because the code on the other side
|
|
105
|
+
* of that guard belongs to another author and a host's JavaScript need not
|
|
106
|
+
* agree with this package's types (0206). A fixture written in TypeScript
|
|
107
|
+
* cannot stand in for one that was not without saying so once, here.
|
|
108
|
+
*/
|
|
109
|
+
const returning = (value) => () => value;
|
|
110
|
+
const BROKEN_DECLARATIONS = {
|
|
111
|
+
throws: () => {
|
|
112
|
+
throw new Error("the reader of this answer is not written yet");
|
|
113
|
+
},
|
|
114
|
+
"not-an-array": returning(undefined),
|
|
115
|
+
"not-a-reading": returning([BROKEN_READING_BINDING]),
|
|
116
|
+
unnamed: () => [{ name: "", given: 1, shown: 0 }],
|
|
117
|
+
"uncountable-given": () => [{ name: BROKEN_READING_BINDING, given: Number.NaN, shown: 0 }],
|
|
118
|
+
"uncountable-shown": () => [{ name: BROKEN_READING_BINDING, given: 2, shown: 1.5 }],
|
|
119
|
+
"more-shown-than-given": () => [{ name: BROKEN_READING_BINDING, given: 1, shown: 2 }],
|
|
120
|
+
};
|
|
121
|
+
/**
|
|
122
|
+
* A primitive that breaks the one declaration no tree and no deployment can
|
|
123
|
+
* break for it, in whichever way the caller names.
|
|
124
|
+
*
|
|
125
|
+
* `unshown-unreadable` is the single member of `RenderDiagnostic` addressed to
|
|
126
|
+
* whoever wrote the component (0206): the declaration lives *inside* the
|
|
127
|
+
* primitive, so only a primitive can break it. Nothing in the starter library
|
|
128
|
+
* does — all five that declare `unshown` compute the figure from the answer
|
|
129
|
+
* they were handed, which is the whole point of declaring the function the
|
|
130
|
+
* component already calls — and neither `testPrimitives` nor
|
|
131
|
+
* `undecoratedPrimitive` stood in for one. So every lane wanting to demonstrate
|
|
132
|
+
* the code wrote its own broken component, and `Loom docs` wrote one for *What
|
|
133
|
+
* a render reports* before filing for this.
|
|
134
|
+
*
|
|
135
|
+
* **One parameterised stand-in rather than a catalogue of broken components**,
|
|
136
|
+
* which is what the filing asked for in those words: a catalogue in the testing
|
|
137
|
+
* door would be a second library to keep true.
|
|
138
|
+
*
|
|
139
|
+
* Well-behaved in every other respect, deliberately. It spreads
|
|
140
|
+
* `loom.editable`, places what it is handed, and declares its props — so the
|
|
141
|
+
* one thing wrong with it is the thing the caller asked to be wrong, and a
|
|
142
|
+
* render of it raises exactly one diagnostic.
|
|
143
|
+
*
|
|
144
|
+
* Its props are declared **open**, where `loom.card` next door is strict, and
|
|
145
|
+
* that is the one place this fixture prefers forgiveness to realism: props the
|
|
146
|
+
* schema refuses omit the node altogether, which would take the declaration
|
|
147
|
+
* with them and hand a lane an empty diagnostic list instead of the fault it
|
|
148
|
+
* asked for. A stand-in that can be silenced by an unrelated prop is a stand-in
|
|
149
|
+
* that will be.
|
|
150
|
+
*
|
|
151
|
+
* The type carries the breakage, so all seven can be registered together and
|
|
152
|
+
* rendered in one tree. Read it off the entry rather than writing it out:
|
|
153
|
+
*
|
|
154
|
+
* ```ts
|
|
155
|
+
* const definition = brokenUnshownDefinition("throws")
|
|
156
|
+
* const registry = registryOf([definition])
|
|
157
|
+
* // …then a node of `definition.type` carrying a `loom:data` declaration.
|
|
158
|
+
* ```
|
|
159
|
+
*
|
|
160
|
+
* It declares no `reads`, and that absence is load-bearing. A declared name the
|
|
161
|
+
* caller did not answer under would add `data-unread` to the render, so the
|
|
162
|
+
* list a lane asserts would depend on which name it chose to answer. Silent
|
|
163
|
+
* unless declared is the bargain `reads` makes, and taking it is what keeps the
|
|
164
|
+
* one-diagnostic promise above true whatever the caller does.
|
|
165
|
+
*/
|
|
166
|
+
export const brokenUnshownDefinition = (breakage) => definePrimitive({
|
|
167
|
+
type: `test.unshown-${breakage}`,
|
|
168
|
+
description: `A bound listing whose declaration of what it could not show is broken (${breakage}). Written to be wrong.`,
|
|
169
|
+
props: z.object({}),
|
|
170
|
+
unshown: BROKEN_DECLARATIONS[breakage],
|
|
171
|
+
component: hostComponent(`brokenUnshown(${breakage})`, "ul"),
|
|
172
|
+
});
|
|
48
173
|
//# sourceMappingURL=definitions.js.map
|