storyStore
uses tcmts.store.test.history.open, which uses node:path
A store with a history of every kind of change an entry can make, for the web UI's tests: edits, a definition re-hashed only because what it uses changed, a rename, an alias, a type changing beside a value of the same name, a conflict, a removal and an addition. Its entries, oldest first.
import type { DefKind } from "#codebase/tcmts/core/types"; import type { Store } from "#codebase/tcmts/store"; import { open, stored } from "#codebase/tcmts/store/test/history"; export function storyStore(): { store: Store; entries: string[] } { const s = open(); const def = (hash: string, ir: unknown, kind: DefKind = "term") => ({ ...stored(hash, hash), kind, ir: JSON.stringify(ir), }); s.putDefs( [ def("a1", ["Num", "1"]), def("a2", ["Num", "2"]), def("b1", ["Call", ["Ref", "a1"]]), def("b2", ["Call", ["Ref", "a2"]]), def("c1", ["Call", ["Ref", "a1"], "x"]), def("c2", ["Call", ["Ref", "a2"], "y"]), def("T1", ["Type", "1"], "type"), def("T2", ["Type", "2"], "type"), def("t1", ["Num", "t"]), def("s1", ["Str", "s"]), def("e1", ["Str", "e"]), ], "5", 2, ); const entries: string[] = []; const entry = (f: () => void) => { s.transaction(f); s.endBatch(); entries.push(s.head()); }; entry(() => { for (const [path, hash] of [ ["lib.a", "a1"], ["lib.b", "b1"], ["lib.c", "c1"], ["lib.T", "t1"], ["lib.s", "s1"], ]) s.addName(path!, hash!, "term", "add"); s.addName("lib.T", "T1", "type", "add"); }); entry(() => { s.replaceName("lib.a", "a1", "a2", "term", "update"); s.replaceName("lib.b", "b1", "b2", "term", "update"); s.replaceName("lib.c", "c1", "c2", "term", "update"); }); entry(() => { s.removeName("lib.s", "s1", "mv"); s.addName("lib.sub.s", "s1", "term", "mv"); }); entry(() => s.addName("lib.alias", "b2", "term", "alias")); entry(() => s.replaceName("lib.T", "T1", "T2", "type", "update")); entry(() => s.addName("lib.a", "a1", "term", "merge")); entry(() => { s.removeName("lib.c", "c2", "rm"); s.addName("lib.sub.deep.d", "b2", "term", "add"); s.addName("lib.e", "e1", "term", "add"); }); return { store: s, entries }; }
uses
- tcmts.core.types.DefKind
- tcmts.store.Store
- tcmts.store.test.history.open
- tcmts.store.test.history.stored