@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,266 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { projectIdSchema, projectSchema } from "../project/project.js";
|
|
3
|
+
/**
|
|
4
|
+
* One suite, two implementations.
|
|
5
|
+
*
|
|
6
|
+
* `memoryProjectStore` calls itself the reference implementation; this is what
|
|
7
|
+
* makes that claim checkable rather than aspirational, on the same terms
|
|
8
|
+
* `store-contract.ts` and `hold-contract.ts` already set. The alternative —
|
|
9
|
+
* each store asserted against its own expectations — is how two stores that
|
|
10
|
+
* disagree both stay green.
|
|
11
|
+
*/
|
|
12
|
+
export const projectFixture = (over = {}) => projectSchema.parse({
|
|
13
|
+
projectId: projectIdSchema.parse("prj_fixture"),
|
|
14
|
+
name: "A fixture",
|
|
15
|
+
createdAt: "2026-10-12T12:00:00.000Z",
|
|
16
|
+
...over,
|
|
17
|
+
});
|
|
18
|
+
export const describeProjectStoreContract = (name, make) => {
|
|
19
|
+
describe(`${name} — the project store contract`, () => {
|
|
20
|
+
it("reads back what it recorded", async () => {
|
|
21
|
+
const store = await make();
|
|
22
|
+
const project = projectFixture({ name: "The bakery" });
|
|
23
|
+
expect(await store.create(project)).toEqual({ ok: true, value: project });
|
|
24
|
+
expect(await store.get(project.projectId)).toEqual({ ok: true, value: project });
|
|
25
|
+
});
|
|
26
|
+
it("refuses an id already taken rather than overwriting the rows under it", async () => {
|
|
27
|
+
const store = await make();
|
|
28
|
+
const first = projectFixture({ name: "The first" });
|
|
29
|
+
await store.create(first);
|
|
30
|
+
const second = await store.create(projectFixture({ name: "The second" }));
|
|
31
|
+
expect(second).toEqual({
|
|
32
|
+
ok: false,
|
|
33
|
+
error: { code: "already-exists", projectId: first.projectId },
|
|
34
|
+
});
|
|
35
|
+
const read = await store.get(first.projectId);
|
|
36
|
+
expect(read.ok && read.value.name).toBe("The first");
|
|
37
|
+
});
|
|
38
|
+
it("says not-found rather than returning nothing", async () => {
|
|
39
|
+
const store = await make();
|
|
40
|
+
const missing = projectIdSchema.parse("prj_nobody");
|
|
41
|
+
expect(await store.get(missing)).toEqual({
|
|
42
|
+
ok: false,
|
|
43
|
+
error: { code: "not-found", projectId: missing },
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
it("lists nothing before anything is recorded", async () => {
|
|
47
|
+
const store = await make();
|
|
48
|
+
expect(await store.list()).toEqual({ ok: true, value: [] });
|
|
49
|
+
});
|
|
50
|
+
it("lists oldest first, whatever order they were written in", async () => {
|
|
51
|
+
const store = await make();
|
|
52
|
+
await store.create(projectFixture({
|
|
53
|
+
projectId: projectIdSchema.parse("prj_third"),
|
|
54
|
+
createdAt: "2026-10-12T14:00:00.000Z",
|
|
55
|
+
}));
|
|
56
|
+
await store.create(projectFixture({
|
|
57
|
+
projectId: projectIdSchema.parse("prj_first"),
|
|
58
|
+
createdAt: "2026-10-12T10:00:00.000Z",
|
|
59
|
+
}));
|
|
60
|
+
await store.create(projectFixture({
|
|
61
|
+
projectId: projectIdSchema.parse("prj_second"),
|
|
62
|
+
createdAt: "2026-10-12T12:00:00.000Z",
|
|
63
|
+
}));
|
|
64
|
+
const listed = await store.list();
|
|
65
|
+
expect(listed.ok && listed.value.map((project) => project.projectId)).toEqual([
|
|
66
|
+
"prj_first",
|
|
67
|
+
"prj_second",
|
|
68
|
+
"prj_third",
|
|
69
|
+
]);
|
|
70
|
+
});
|
|
71
|
+
it("renames without touching anything else", async () => {
|
|
72
|
+
const store = await make();
|
|
73
|
+
const project = projectFixture({ name: "Before" });
|
|
74
|
+
await store.create(project);
|
|
75
|
+
const renamed = await store.rename(project.projectId, { name: "After" });
|
|
76
|
+
expect(renamed).toEqual({
|
|
77
|
+
ok: true,
|
|
78
|
+
value: { ...project, name: "After" },
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
it("refuses to rename a project that is not there", async () => {
|
|
82
|
+
const store = await make();
|
|
83
|
+
const missing = projectIdSchema.parse("prj_nobody");
|
|
84
|
+
expect(await store.rename(missing, { name: "Anything" })).toEqual({
|
|
85
|
+
ok: false,
|
|
86
|
+
error: { code: "not-found", projectId: missing },
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
/**
|
|
90
|
+
* The two stores have to agree about what a project is, not merely about
|
|
91
|
+
* what they store. An empty name is the cheapest way to ask: `projectSchema`
|
|
92
|
+
* refuses it, and a store that spread the change instead of parsing it would
|
|
93
|
+
* accept it here and be refused by the column somewhere else.
|
|
94
|
+
*/
|
|
95
|
+
it("refuses a rename the project schema would not accept", async () => {
|
|
96
|
+
const store = await make();
|
|
97
|
+
const project = projectFixture();
|
|
98
|
+
await store.create(project);
|
|
99
|
+
const refused = await store.rename(project.projectId, { name: "" });
|
|
100
|
+
expect(refused.ok).toBe(false);
|
|
101
|
+
const read = await store.get(project.projectId);
|
|
102
|
+
expect(read.ok && read.value.name).toBe(project.name);
|
|
103
|
+
});
|
|
104
|
+
/**
|
|
105
|
+
* ## The repository (0292)
|
|
106
|
+
*
|
|
107
|
+
* At most one per project, and at most one project per repository. The
|
|
108
|
+
* second half is the one with teeth: two projects naming one repository
|
|
109
|
+
* would be two write-back destinations for one pull request, and nothing
|
|
110
|
+
* afterwards could say which was meant.
|
|
111
|
+
*/
|
|
112
|
+
describe("the repository", () => {
|
|
113
|
+
it("keeps the repository it was given", async () => {
|
|
114
|
+
const store = await make();
|
|
115
|
+
const project = projectFixture({ repository: "jam-overture/loom" });
|
|
116
|
+
expect(await store.create(project)).toEqual({ ok: true, value: project });
|
|
117
|
+
const read = await store.get(project.projectId);
|
|
118
|
+
expect(read.ok && read.value.repository).toBe("jam-overture/loom");
|
|
119
|
+
});
|
|
120
|
+
it("takes a project with no repository, which is the ordinary first state", async () => {
|
|
121
|
+
const store = await make();
|
|
122
|
+
const project = projectFixture();
|
|
123
|
+
expect(await store.create(project)).toEqual({ ok: true, value: project });
|
|
124
|
+
const read = await store.get(project.projectId);
|
|
125
|
+
expect(read.ok && read.value.repository).toBeUndefined();
|
|
126
|
+
});
|
|
127
|
+
it("refuses a repository another project already names", async () => {
|
|
128
|
+
const store = await make();
|
|
129
|
+
await store.create(projectFixture({
|
|
130
|
+
projectId: projectIdSchema.parse("prj_first"),
|
|
131
|
+
repository: "jam-overture/loom",
|
|
132
|
+
}));
|
|
133
|
+
const second = await store.create(projectFixture({
|
|
134
|
+
projectId: projectIdSchema.parse("prj_second"),
|
|
135
|
+
repository: "jam-overture/loom",
|
|
136
|
+
}));
|
|
137
|
+
expect(second.ok).toBe(false);
|
|
138
|
+
expect(!second.ok && second.error.code).toBe("repository-taken");
|
|
139
|
+
});
|
|
140
|
+
/**
|
|
141
|
+
* The partial index's reason. A plain unique index would admit exactly
|
|
142
|
+
* one project with no repository, which is the state almost every
|
|
143
|
+
* project starts in.
|
|
144
|
+
*/
|
|
145
|
+
it("lets any number of projects have none", async () => {
|
|
146
|
+
const store = await make();
|
|
147
|
+
await store.create(projectFixture({ projectId: projectIdSchema.parse("prj_a") }));
|
|
148
|
+
await store.create(projectFixture({ projectId: projectIdSchema.parse("prj_b") }));
|
|
149
|
+
const listed = await store.list();
|
|
150
|
+
expect(listed.ok && listed.value).toHaveLength(2);
|
|
151
|
+
});
|
|
152
|
+
/**
|
|
153
|
+
* An id collision with a repository set must not be reported as a taken
|
|
154
|
+
* repository. They are different faults and a screen puts them on
|
|
155
|
+
* different inputs.
|
|
156
|
+
*/
|
|
157
|
+
it("calls an id collision an id collision, even with a repository set", async () => {
|
|
158
|
+
const store = await make();
|
|
159
|
+
const first = projectFixture({ repository: "jam-overture/loom" });
|
|
160
|
+
await store.create(first);
|
|
161
|
+
const again = await store.create({ ...first, name: "A second" });
|
|
162
|
+
expect(again.ok).toBe(false);
|
|
163
|
+
expect(!again.ok && again.error.code).toBe("already-exists");
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
/**
|
|
167
|
+
* ## Closing (0289)
|
|
168
|
+
*
|
|
169
|
+
* What this store has instead of a delete. The failure these guard is the
|
|
170
|
+
* one a soft delete usually ships with: a row that has stopped according to
|
|
171
|
+
* one read and is still there according to another.
|
|
172
|
+
*/
|
|
173
|
+
describe("closing", () => {
|
|
174
|
+
const AT = "2026-10-16T09:00:00.000Z";
|
|
175
|
+
const LATER = "2026-10-16T10:00:00.000Z";
|
|
176
|
+
it("stamps when it was closed", async () => {
|
|
177
|
+
const store = await make();
|
|
178
|
+
const project = projectFixture();
|
|
179
|
+
await store.create(project);
|
|
180
|
+
const closed = await store.close(project.projectId, AT);
|
|
181
|
+
expect(closed.ok && closed.value.closedAt).toBe(AT);
|
|
182
|
+
});
|
|
183
|
+
/**
|
|
184
|
+
* A closed project is still there, and `get` says so. A store that
|
|
185
|
+
* answered `not-found` about a row it is holding would be lying about its
|
|
186
|
+
* contents, and the first casualty is the audit that goes looking for
|
|
187
|
+
* exactly those rows.
|
|
188
|
+
*/
|
|
189
|
+
it("still answers for it by id", async () => {
|
|
190
|
+
const store = await make();
|
|
191
|
+
const project = projectFixture();
|
|
192
|
+
await store.create(project);
|
|
193
|
+
await store.close(project.projectId, AT);
|
|
194
|
+
const read = await store.get(project.projectId);
|
|
195
|
+
expect(read.ok && read.value.projectId).toBe(project.projectId);
|
|
196
|
+
expect(read.ok && read.value.closedAt).toBe(AT);
|
|
197
|
+
});
|
|
198
|
+
it("leaves it out of a listing that did not ask for it", async () => {
|
|
199
|
+
const store = await make();
|
|
200
|
+
const project = projectFixture();
|
|
201
|
+
await store.create(project);
|
|
202
|
+
await store.close(project.projectId, AT);
|
|
203
|
+
const listed = await store.list();
|
|
204
|
+
expect(listed.ok && listed.value).toEqual([]);
|
|
205
|
+
});
|
|
206
|
+
it("lists it when asked for closed, and not the open ones", async () => {
|
|
207
|
+
const store = await make();
|
|
208
|
+
const open = projectFixture({ projectId: projectIdSchema.parse("prj_open") });
|
|
209
|
+
const shut = projectFixture({ projectId: projectIdSchema.parse("prj_shut") });
|
|
210
|
+
await store.create(open);
|
|
211
|
+
await store.create(shut);
|
|
212
|
+
await store.close(shut.projectId, AT);
|
|
213
|
+
const listed = await store.list({ closed: true });
|
|
214
|
+
expect(listed.ok && listed.value.map((project) => project.projectId)).toEqual([
|
|
215
|
+
shut.projectId,
|
|
216
|
+
]);
|
|
217
|
+
});
|
|
218
|
+
it("lists both when asked for everything", async () => {
|
|
219
|
+
const store = await make();
|
|
220
|
+
const open = projectFixture({ projectId: projectIdSchema.parse("prj_open") });
|
|
221
|
+
const shut = projectFixture({ projectId: projectIdSchema.parse("prj_shut") });
|
|
222
|
+
await store.create(open);
|
|
223
|
+
await store.create(shut);
|
|
224
|
+
await store.close(shut.projectId, AT);
|
|
225
|
+
const listed = await store.list({ closed: "all" });
|
|
226
|
+
expect(listed.ok && listed.value).toHaveLength(2);
|
|
227
|
+
});
|
|
228
|
+
/**
|
|
229
|
+
* The instant must not move. *When did this stop* is the question a
|
|
230
|
+
* closed project is asked, and a second press is not a second stopping.
|
|
231
|
+
*/
|
|
232
|
+
it("does not move the instant when it is closed again", async () => {
|
|
233
|
+
const store = await make();
|
|
234
|
+
const project = projectFixture();
|
|
235
|
+
await store.create(project);
|
|
236
|
+
await store.close(project.projectId, AT);
|
|
237
|
+
const again = await store.close(project.projectId, LATER);
|
|
238
|
+
expect(again.ok && again.value.closedAt).toBe(AT);
|
|
239
|
+
});
|
|
240
|
+
it("opens it again, and the stamp goes rather than emptying", async () => {
|
|
241
|
+
const store = await make();
|
|
242
|
+
const project = projectFixture();
|
|
243
|
+
await store.create(project);
|
|
244
|
+
await store.close(project.projectId, AT);
|
|
245
|
+
const reopened = await store.reopen(project.projectId);
|
|
246
|
+
expect(reopened.ok && reopened.value.closedAt).toBeUndefined();
|
|
247
|
+
const listed = await store.list();
|
|
248
|
+
expect(listed.ok && listed.value).toHaveLength(1);
|
|
249
|
+
});
|
|
250
|
+
it("reopens one that was never closed without complaining", async () => {
|
|
251
|
+
const store = await make();
|
|
252
|
+
const project = projectFixture();
|
|
253
|
+
await store.create(project);
|
|
254
|
+
const reopened = await store.reopen(project.projectId);
|
|
255
|
+
expect(reopened.ok && reopened.value.closedAt).toBeUndefined();
|
|
256
|
+
});
|
|
257
|
+
it("says so when there is no such project to close", async () => {
|
|
258
|
+
const store = await make();
|
|
259
|
+
const closed = await store.close(projectIdSchema.parse("prj_nothing"), AT);
|
|
260
|
+
expect(closed.ok).toBe(false);
|
|
261
|
+
expect(!closed.ok && closed.error.code).toBe("not-found");
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
};
|
|
266
|
+
//# sourceMappingURL=project-contract.js.map
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import { type AudienceId } from "../audience/audience.js";
|
|
1
2
|
import { type NodeId, type TreeId } from "../ids.js";
|
|
2
3
|
import { type PrimitiveType } from "../primitive-type.js";
|
|
3
4
|
import type { ReaderSignalJournal } from "../signals/journal.js";
|
|
5
|
+
import { type ReaderRegion, type ReaderRegionStore } from "../signals/region.js";
|
|
4
6
|
import type { ReaderSignal, ReaderSignalBatch, ViewKey } from "../signals/signal.js";
|
|
5
7
|
import type { ReaderTallyStore } from "../signals/tally.js";
|
|
6
8
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
+
* Three suites, run against every implementation of the buffer, the counters and
|
|
10
|
+
* the regions.
|
|
9
11
|
*
|
|
10
12
|
* The same argument as `store-contract.ts` and `journal-contract.ts`: an
|
|
11
13
|
* interface is only tested once a second implementation exists, and a
|
|
@@ -19,6 +21,17 @@ export declare const nodeId: (name: string) => NodeId;
|
|
|
19
21
|
export declare const primitiveType: (name: string) => PrimitiveType;
|
|
20
22
|
/** A key of the right shape, spelled so a failing assertion says which view it was. */
|
|
21
23
|
export declare const viewKey: (nth: number) => ViewKey;
|
|
24
|
+
export declare const region: (code: string) => ReaderRegion;
|
|
25
|
+
/**
|
|
26
|
+
* Two audiences to tell apart, and neither of them the default.
|
|
27
|
+
*
|
|
28
|
+
* Named rather than reusing `aud_everyone` for one side, because a test whose
|
|
29
|
+
* two audiences are *everyone* and *somebody* passes on a store that quietly
|
|
30
|
+
* files everything under the default — which is exactly the failure these are
|
|
31
|
+
* here to catch (0284).
|
|
32
|
+
*/
|
|
33
|
+
export declare const SKIERS: AudienceId;
|
|
34
|
+
export declare const RIDERS: AudienceId;
|
|
22
35
|
export declare const batchOf: (signals: readonly ReaderSignal[], overrides?: Partial<Omit<ReaderSignalBatch, "signals">>) => ReaderSignalBatch;
|
|
23
36
|
export declare const viewed: (name: string) => ReaderSignal;
|
|
24
37
|
export declare const activated: (name: string) => ReaderSignal;
|
|
@@ -32,7 +45,19 @@ export declare const activated: (name: string) => ReaderSignal;
|
|
|
32
45
|
*/
|
|
33
46
|
export declare const activatedIn: (name: string, ...regions: readonly string[]) => ReaderSignal;
|
|
34
47
|
export declare const disclosedIn: (name: string, open: boolean, ...regions: readonly string[]) => ReaderSignal;
|
|
48
|
+
export declare const completed: (name: string) => ReaderSignal;
|
|
49
|
+
/** A form let go, and the bands it was the end of — nearest first, like a press. */
|
|
50
|
+
export declare const completedIn: (name: string, ...regions: readonly string[]) => ReaderSignal;
|
|
35
51
|
export declare const dwelled: (name: string, ms: number) => ReaderSignal;
|
|
36
52
|
export declare const describeReaderSignalJournalContract: (name: string, make: () => ReaderSignalJournal | Promise<ReaderSignalJournal>) => void;
|
|
37
53
|
export declare const describeReaderTallyStoreContract: (name: string, make: () => ReaderTallyStore | Promise<ReaderTallyStore>) => void;
|
|
54
|
+
/**
|
|
55
|
+
* Where readers were, against every implementation.
|
|
56
|
+
*
|
|
57
|
+
* Shorter than the other two suites because the table is narrower, and the
|
|
58
|
+
* properties it does assert are the ones a wrong implementation would be
|
|
59
|
+
* plausible without: that a second delivery adds to the first, that two
|
|
60
|
+
* countries are two rows, and that a revision is part of the key.
|
|
61
|
+
*/
|
|
62
|
+
export declare const describeReaderRegionStoreContract: (name: string, make: () => ReaderRegionStore | Promise<ReaderRegionStore>) => void;
|
|
38
63
|
//# sourceMappingURL=reader-signal-contract.d.ts.map
|