@thomasfosterau/pulpit 0.0.0 → 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.
Files changed (143) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1271 -1
  3. package/dist/blobs.d.ts +249 -0
  4. package/dist/blobs.d.ts.map +1 -0
  5. package/dist/blobs.js +193 -0
  6. package/dist/blobs.js.map +1 -0
  7. package/dist/budgets.d.ts +255 -0
  8. package/dist/budgets.d.ts.map +1 -0
  9. package/dist/budgets.js +211 -0
  10. package/dist/budgets.js.map +1 -0
  11. package/dist/cache.d.ts +154 -0
  12. package/dist/cache.d.ts.map +1 -0
  13. package/dist/cache.js +118 -0
  14. package/dist/cache.js.map +1 -0
  15. package/dist/collections.d.ts +242 -0
  16. package/dist/collections.d.ts.map +1 -0
  17. package/dist/collections.js +215 -0
  18. package/dist/collections.js.map +1 -0
  19. package/dist/comments.d.ts +212 -0
  20. package/dist/comments.d.ts.map +1 -0
  21. package/dist/comments.js +192 -0
  22. package/dist/comments.js.map +1 -0
  23. package/dist/content.d.ts +231 -0
  24. package/dist/content.d.ts.map +1 -0
  25. package/dist/content.js +204 -0
  26. package/dist/content.js.map +1 -0
  27. package/dist/documents.d.ts +184 -0
  28. package/dist/documents.d.ts.map +1 -0
  29. package/dist/documents.js +190 -0
  30. package/dist/documents.js.map +1 -0
  31. package/dist/edges.d.ts +645 -0
  32. package/dist/edges.d.ts.map +1 -0
  33. package/dist/edges.js +558 -0
  34. package/dist/edges.js.map +1 -0
  35. package/dist/filter.d.ts +461 -0
  36. package/dist/filter.d.ts.map +1 -0
  37. package/dist/filter.js +387 -0
  38. package/dist/filter.js.map +1 -0
  39. package/dist/index.d.ts +133 -0
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/index.js +133 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/internal/filter-columns.d.ts +8 -0
  44. package/dist/internal/filter-columns.d.ts.map +1 -0
  45. package/dist/internal/filter-columns.js +43 -0
  46. package/dist/internal/filter-columns.js.map +1 -0
  47. package/dist/internal/list-order.d.ts +26 -0
  48. package/dist/internal/list-order.d.ts.map +1 -0
  49. package/dist/internal/list-order.js +92 -0
  50. package/dist/internal/list-order.js.map +1 -0
  51. package/dist/internal/owned-columns.d.ts +93 -0
  52. package/dist/internal/owned-columns.d.ts.map +1 -0
  53. package/dist/internal/owned-columns.js +98 -0
  54. package/dist/internal/owned-columns.js.map +1 -0
  55. package/dist/internal/plain-rows.d.ts +32 -0
  56. package/dist/internal/plain-rows.d.ts.map +1 -0
  57. package/dist/internal/plain-rows.js +32 -0
  58. package/dist/internal/plain-rows.js.map +1 -0
  59. package/dist/internal/reference-columns.d.ts +80 -0
  60. package/dist/internal/reference-columns.d.ts.map +1 -0
  61. package/dist/internal/reference-columns.js +102 -0
  62. package/dist/internal/reference-columns.js.map +1 -0
  63. package/dist/moderation.d.ts +392 -0
  64. package/dist/moderation.d.ts.map +1 -0
  65. package/dist/moderation.js +375 -0
  66. package/dist/moderation.js.map +1 -0
  67. package/dist/paths.d.ts +204 -0
  68. package/dist/paths.d.ts.map +1 -0
  69. package/dist/paths.js +165 -0
  70. package/dist/paths.js.map +1 -0
  71. package/dist/proposals.d.ts +523 -0
  72. package/dist/proposals.d.ts.map +1 -0
  73. package/dist/proposals.js +505 -0
  74. package/dist/proposals.js.map +1 -0
  75. package/dist/publication.d.ts +148 -0
  76. package/dist/publication.d.ts.map +1 -0
  77. package/dist/publication.js +183 -0
  78. package/dist/publication.js.map +1 -0
  79. package/dist/purge.d.ts +224 -0
  80. package/dist/purge.d.ts.map +1 -0
  81. package/dist/purge.js +151 -0
  82. package/dist/purge.js.map +1 -0
  83. package/dist/reactions.d.ts +246 -0
  84. package/dist/reactions.d.ts.map +1 -0
  85. package/dist/reactions.js +183 -0
  86. package/dist/reactions.js.map +1 -0
  87. package/dist/registry.d.ts +316 -0
  88. package/dist/registry.d.ts.map +1 -0
  89. package/dist/registry.js +305 -0
  90. package/dist/registry.js.map +1 -0
  91. package/dist/search.d.ts +366 -0
  92. package/dist/search.d.ts.map +1 -0
  93. package/dist/search.js +273 -0
  94. package/dist/search.js.map +1 -0
  95. package/dist/social.d.ts +311 -0
  96. package/dist/social.d.ts.map +1 -0
  97. package/dist/social.js +205 -0
  98. package/dist/social.js.map +1 -0
  99. package/dist/subtype.d.ts +1613 -0
  100. package/dist/subtype.d.ts.map +1 -0
  101. package/dist/subtype.js +1300 -0
  102. package/dist/subtype.js.map +1 -0
  103. package/dist/testing.d.ts +675 -0
  104. package/dist/testing.d.ts.map +1 -0
  105. package/dist/testing.js +1022 -0
  106. package/dist/testing.js.map +1 -0
  107. package/dist/version-chain.d.ts +702 -0
  108. package/dist/version-chain.d.ts.map +1 -0
  109. package/dist/version-chain.js +489 -0
  110. package/dist/version-chain.js.map +1 -0
  111. package/dist/working-copy.d.ts +116 -0
  112. package/dist/working-copy.d.ts.map +1 -0
  113. package/dist/working-copy.js +95 -0
  114. package/dist/working-copy.js.map +1 -0
  115. package/package.json +138 -4
  116. package/src/blobs.ts +384 -0
  117. package/src/budgets.ts +338 -0
  118. package/src/cache.ts +218 -0
  119. package/src/collections.ts +427 -0
  120. package/src/comments.ts +392 -0
  121. package/src/content.ts +238 -0
  122. package/src/documents.ts +284 -0
  123. package/src/edges.ts +1185 -0
  124. package/src/filter.ts +523 -0
  125. package/src/index.ts +153 -0
  126. package/src/internal/filter-columns.ts +50 -0
  127. package/src/internal/list-order.ts +117 -0
  128. package/src/internal/owned-columns.ts +140 -0
  129. package/src/internal/plain-rows.ts +54 -0
  130. package/src/internal/reference-columns.ts +156 -0
  131. package/src/moderation.ts +728 -0
  132. package/src/paths.ts +267 -0
  133. package/src/proposals.ts +1014 -0
  134. package/src/publication.ts +225 -0
  135. package/src/purge.ts +313 -0
  136. package/src/reactions.ts +347 -0
  137. package/src/registry.ts +524 -0
  138. package/src/search.ts +540 -0
  139. package/src/social.ts +469 -0
  140. package/src/subtype.ts +3095 -0
  141. package/src/testing.ts +1873 -0
  142. package/src/version-chain.ts +1093 -0
  143. package/src/working-copy.ts +192 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version-chain.d.ts","sourceRoot":"","sources":["../src/version-chain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AAKH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAIxC;;;;GAIG;AACH,eAAO,MAAM,aAAa,0DAAkD,CAAC;AAC7E;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAC,IAAI,CAAC;AAEtD;;;;;;;;GAQG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,GAAG,IAAI,GAAG,MAAM,CAAC;AAEtD;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG;IAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,CAAA;CAAE,CAAC;AAEpE;;;;;GAKG;AAEH,MAAM,MAAM,UAAU,GAAG;IAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAAA;CAAE,CAAC;AAEhF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,YAAY,GAAG;IAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,CAAA;CAAE,CAAC;AAErE;;;;;;;GAOG;AAEH,MAAM,MAAM,WAAW,GAAG;IAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS,CAAA;CAAE,CAAC;AAEvF;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,4CAA4C;IAC5C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,6CAA6C;IAC7C,Q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AC;IAC9B;;;;;;OAMG;IAEH,QAAQ,CAAC,YAAY,CAAC,EAClB,CAAC,CAAC,KAAK,EAAE,gBAAgB,KAAK,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAC9D,SAAS,CAAC;IACd;;;;;;OAMG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EACzB,CAAC,CAAC,KAAK,EAAE,gBAAgB,KAAK,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAC/D,SAAS,CAAC;CAEf;AAYD;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,GAAI,CAAC,EAAE,CAAC,QAC/B,MAAM,SACL,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,UACvB,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,KACtB,eAAe,CAAC,CAAC,EAAE,CAAC,CAoPtB,CAAC"}
@@ -0,0 +1,489 @@
1
+ /**
2
+ * **The node / version chain discipline** — create, append, tombstone,
3
+ * restore, history and field-level compare over an append-only chain,
4
+ * generic in the leaf.
5
+ *
6
+ * Every node carries an append-only chain of `(version, action, timestamp,
7
+ * actor)` rows (`READ-009` / `PUB-003`): each edit appends a row rather than
8
+ * rewriting in place, and "repointing the current version" is nothing but
9
+ * that append — the current version is the chain's maximum, resolved by the
10
+ * current-version view. The behavioural spec is gardeneria's
11
+ * `packages/database/src/nodes.ts` (`createNodeE` / `updateNodeE` /
12
+ * `deleteNodeE`), the leaf-chain half of `apps/api/src/operations/subtype.ts`
13
+ * (`defineVersionOpsE`, the merge / carry-forward writers) and
14
+ * `version-history.ts`; a `#NNN` here names a gardeneria issue.
15
+ *
16
+ * ## The invariants
17
+ *
18
+ * - **Append-only** (`VERSION-CHAIN-001/002`). Every write lands at
19
+ * `N_max + 1`; no existing version row is ever updated, deleted or
20
+ * reordered. A restore is a new version whose content came from history.
21
+ * The one exception is erasure (`./purge`), which deletes a node's whole
22
+ * chain, never part of one.
23
+ * - **Create is never an upsert.** A caller-supplied id that already belongs
24
+ * to a node fails {@link NodeAlreadyExists} (F-OP-02) rather than minting a
25
+ * version onto it.
26
+ * - **Update carries forward.** A patch is tri-state per column: a value
27
+ * sets, `null` clears, an absent (or `undefined`) key carries the previous
28
+ * version's value forward. Never `input.x ?? null`.
29
+ * - **Delete is a tombstone that carries the state forward**, so a `delete`
30
+ * version is itself a complete snapshot — which is what makes restoring
31
+ * *from* a tombstone possible. It is idempotent: on an already tombstoned
32
+ * node it returns the existing tombstone and writes nothing.
33
+ * - **A plain update never resurrects** (`VERSION-CHAIN-006`). Over a
34
+ * tombstone it fails {@link NodeNotFound}; only the explicit `restore` and
35
+ * `restoreVersion` write over one.
36
+ * - **No partial restore.** `restoreVersion` reads the whole snapshot first
37
+ * and fails {@link VersionNotFound} when any level of the chain has no row
38
+ * at that version — before anything is written.
39
+ * - **Every chain read is bounded** (`PERF-DB-001`): `history` takes a
40
+ * `limit`, capped at {@link MAX_HISTORY_LIMIT}.
41
+ * - **An expected version is a precondition on the append.** A write to an
42
+ * existing node (`update`, `restore`, `delete`, `restoreVersion`) may
43
+ * carry the head version its caller last read ({@link Precondition}); a
44
+ * head that has moved fails {@link StaleVersion} and nothing is written.
45
+ * It is checked against the very head the append extends, and the append
46
+ * lands at that head + 1, so a writer that slips in between the read and
47
+ * the append takes the `(id, version)` key first and this one fails
48
+ * {@link VersionConflict}: the store's primary key is what makes the check
49
+ * atomic. Without one, a write extends whatever the head is (last writer
50
+ * wins on a column two patches both set).
51
+ *
52
+ * ## The seam
53
+ *
54
+ * The chain is read and written through a {@link VersionChainStore} the
55
+ * application supplies — in production, a Drizzle store over
56
+ * effect-drizzle-ext's `./versioned-chain` tables and views, which is not yet
57
+ * published (see the package README → Seams for the expected table shape).
58
+ * The operations here own the discipline; the store owns persistence
59
+ * and nothing else. Authorisation is not this module's concern either: the
60
+ * subtype factory (`./subtype`) gates before it calls in.
61
+ *
62
+ * @copyright Thomas Foster
63
+ * @module pulpit/version-chain
64
+ * @since 0.1.0
65
+ */
66
+ import * as Array from "effect/Array";
67
+ import * as Clock from "effect/Clock";
68
+ import * as DateTime from "effect/DateTime";
69
+ import * as Effect from "effect/Effect";
70
+ import * as Equal from "effect/Equal";
71
+ import * as Option from "effect/Option";
72
+ import * as Record from "effect/Record";
73
+ import * as Schema from "effect/Schema";
74
+ // ── Vocabulary ────────────────────────────────────────────────────────
75
+ /**
76
+ * What one version row recorded: the create, an edit (restores included), or a tombstone.
77
+ *
78
+ * @since 0.1.0
79
+ */
80
+ export const VersionAction = Schema.Literals(["create", "update", "delete"]);
81
+ // ── Errors ────────────────────────────────────────────────────────────
82
+ /**
83
+ * No such node, or (for a plain update) a tombstoned one: the wire's 404.
84
+ *
85
+ * @since 0.1.0
86
+ */
87
+ export class NodeNotFound extends Schema.TaggedError()("NodeNotFound", {
88
+ type: Schema.String,
89
+ id: Schema.String,
90
+ }) {
91
+ }
92
+ /**
93
+ * No reconstructable version at `(id, version)`: an unknown version, or a partial chain.
94
+ *
95
+ * @since 0.1.0
96
+ */
97
+ export class VersionNotFound extends Schema.TaggedError()("VersionNotFound", {
98
+ type: Schema.String,
99
+ id: Schema.String,
100
+ version: Schema.BigInt,
101
+ }) {
102
+ }
103
+ /**
104
+ * A create whose caller-supplied id already belongs to a node — never an upsert: the wire's 409.
105
+ *
106
+ * @since 0.1.0
107
+ */
108
+ export class NodeAlreadyExists extends Schema.TaggedError()("NodeAlreadyExists", { type: Schema.String, id: Schema.String }) {
109
+ }
110
+ /**
111
+ * The store refused an append because `(id, version)` is already taken — a
112
+ * concurrent writer got there first. Raised by the store (the `(id, version)`
113
+ * primary key is what enforces append-only under concurrency); never retried
114
+ * here, because a retry would silently base the write on a version the
115
+ * caller never read.
116
+ *
117
+ * @since 0.1.0
118
+ */
119
+ export class VersionConflict extends Schema.TaggedError()("VersionConflict", {
120
+ id: Schema.String,
121
+ version: Schema.BigInt,
122
+ }) {
123
+ }
124
+ /**
125
+ * An expected-version precondition that no longer holds: the head moved past
126
+ * the version the caller last read, so the write would have overwritten an
127
+ * edit the caller never saw. Nothing was written. Carries the head the write
128
+ * would have extended (`current`), so the caller can re-read and re-apply;
129
+ * the wire's 412 (a failed `If-Match`) or 409.
130
+ *
131
+ * A writer that passes the check but loses the race to the append fails
132
+ * {@link VersionConflict} instead: the same stale read, caught one step later
133
+ * by the store's key.
134
+ *
135
+ * @since 0.1.0
136
+ */
137
+ export class StaleVersion extends Schema.TaggedError()("StaleVersion", {
138
+ type: Schema.String,
139
+ id: Schema.String,
140
+ /** The version the caller expected the head to be. */
141
+ expected: Schema.BigInt,
142
+ /** The head version the write found. */
143
+ current: Schema.BigInt,
144
+ }) {
145
+ }
146
+ /**
147
+ * The chain's head version has no reconstructable state — the store broke its
148
+ * own contract (a head it reports must be readable). A defect, never a typed
149
+ * failure: there is nothing a caller could do about it.
150
+ *
151
+ * @since 0.1.0
152
+ */
153
+ export class BrokenChain extends Schema.TaggedError()("BrokenChain", {
154
+ type: Schema.String,
155
+ id: Schema.String,
156
+ version: Schema.BigInt,
157
+ }) {
158
+ }
159
+ // ── The operations ────────────────────────────────────────────────────
160
+ /**
161
+ * The hard cap on a history read (`PERF-DB-001`): a chain is tiny in practice; this bounds a pathological one.
162
+ *
163
+ * @since 0.1.0
164
+ */
165
+ export const MAX_HISTORY_LIMIT = 1000;
166
+ /**
167
+ * Apply a tri-state patch to a state: a value sets, `null` clears, `undefined` carries forward.
168
+ *
169
+ * @since 0.1.0
170
+ */
171
+ export const applyPatch = (state, patch) => ({
172
+ ...state,
173
+ ...Record.filter(patch, (value) => value !== undefined),
174
+ });
175
+ /**
176
+ * Apply a {@link LocalePatch} to a locale level: a patch updates its locale
177
+ * (from nothing for a locale `locales` lacks) with {@link applyPatch}, `null`
178
+ * drops the locale, `undefined` carries it forward. Pure and total.
179
+ *
180
+ * @example
181
+ * ```ts
182
+ * import { deepStrictEqual } from "node:assert";
183
+ * import { applyLocalePatch } from "@thomasfosterau/pulpit/version-chain";
184
+ *
185
+ * const before = { en: { title: "Hello" }, fr: { title: "Bonjour" } };
186
+ * deepStrictEqual(applyLocalePatch(before, { en: { title: "Hi" }, fr: null, de: { title: "Hallo" } }), {
187
+ * en: { title: "Hi" },
188
+ * de: { title: "Hallo" },
189
+ * });
190
+ * ```
191
+ *
192
+ * @since 0.1.0
193
+ */
194
+ export const applyLocalePatch = (locales, patch) => Record.reduce(patch, locales, (acc, change, locale) => {
195
+ if (change === undefined)
196
+ return acc;
197
+ if (change === null)
198
+ return Record.remove(acc, locale);
199
+ return {
200
+ ...acc,
201
+ [locale]: applyPatch(Option.getOrElse(Record.get(acc, locale), () => ({})), change),
202
+ };
203
+ });
204
+ /**
205
+ * The locale level a snapshot carries, `{}` for none.
206
+ *
207
+ * @since 0.1.0
208
+ */
209
+ export const localesOf = (snapshot) => snapshot.locales ?? {};
210
+ /** One column's change, or none when both sides hold structurally equal values. */
211
+ const changeOf = (before, after) => {
212
+ if (Option.isNone(before)) {
213
+ return Option.map(after, (value) => ({ _tag: "added", after: value }));
214
+ }
215
+ if (Option.isNone(after))
216
+ return Option.some({ _tag: "removed", before: before.value });
217
+ return Equal.equals(before.value, after.value)
218
+ ? Option.none()
219
+ : Option.some({ _tag: "changed", before: before.value, after: after.value });
220
+ };
221
+ /**
222
+ * The field-level change set from state `from` to state `to`: every column
223
+ * that is added, removed or changed, with its before and after values;
224
+ * unchanged columns are omitted. Pure and total, with no error channel.
225
+ *
226
+ * Presence is read per key, so the tri-state distinction survives: a column
227
+ * holding `null` is present (a clear), and only a column with no key is
228
+ * absent. Values compare structurally with `Equal.equals`: JSON objects and
229
+ * arrays by content (key order ignored), a `Date` by its instant, a `bigint`
230
+ * by value, and a `Date` never equals the string of its instant. A
231
+ * content-addressed document is held as its `DocumentHash`, so it compares by
232
+ * hash: changed or unchanged, never a textual diff, which is the UI's job.
233
+ *
234
+ * The diff is directed: swapping the arguments swaps `added` and `removed`
235
+ * and each change's `before` and `after`. A state's values are compared as
236
+ * immutable (Effect caches structural hashes), as a {@link ChainState} is.
237
+ *
238
+ * @since 0.1.0
239
+ */
240
+ export const diffStates = (from, to) => Record.fromEntries(Array.flatMap(Array.dedupe([...Record.keys(from), ...Record.keys(to)]), (column) => Array.fromOption(Option.map(changeOf(Record.get(from, column), Record.get(to, column)), (change) => [column, change]))));
241
+ /** One locale's change, or none when both sides carry it with equal columns (or neither does). */
242
+ const localeChangeOf = (before, after) => {
243
+ if (Option.isNone(before)) {
244
+ return Option.map(after, (state) => ({ _tag: "added", after: state }));
245
+ }
246
+ if (Option.isNone(after))
247
+ return Option.some({ _tag: "removed", before: before.value });
248
+ const changes = diffStates(before.value, after.value);
249
+ return Record.isEmptyRecord(changes) ? Option.none() : Option.some({ _tag: "changed", changes });
250
+ };
251
+ /**
252
+ * The per-locale change set from locale level `from` to locale level `to`
253
+ * (pulpit#56): every locale added, removed, or whose columns changed by
254
+ * {@link diffStates}; an unchanged locale is omitted. Pure and total.
255
+ *
256
+ * @example
257
+ * ```ts
258
+ * import { deepStrictEqual } from "node:assert";
259
+ * import { diffLocales } from "@thomasfosterau/pulpit/version-chain";
260
+ *
261
+ * deepStrictEqual(
262
+ * diffLocales({ en: { title: "Hello" }, fr: { title: "Bonjour" } }, { en: { title: "Hi" }, de: { title: "Hallo" } }),
263
+ * {
264
+ * en: { _tag: "changed", changes: { title: { _tag: "changed", before: "Hello", after: "Hi" } } },
265
+ * fr: { _tag: "removed", before: { title: "Bonjour" } },
266
+ * de: { _tag: "added", after: { title: "Hallo" } },
267
+ * },
268
+ * );
269
+ * ```
270
+ *
271
+ * @since 0.1.0
272
+ */
273
+ export const diffLocales = (from, to) => Record.fromEntries(Array.flatMap(Array.dedupe([...Record.keys(from), ...Record.keys(to)]), (locale) => Array.fromOption(Option.map(localeChangeOf(Record.get(from, locale), Record.get(to, locale)), (change) => [locale, change]))));
274
+ // ── The before-append hook ────────────────────────────────────────────
275
+ /**
276
+ * The write that is about to append: the chain's `action` vocabulary, with
277
+ * the two explicit restore surfaces named apart (`VERSION-CHAIN-006`), so a
278
+ * hook can tell a resurrection from an edit. `restore` and `restoreVersion`
279
+ * still append an `update` row. `publish` and `unpublish` are `./subtype`'s
280
+ * publication operations, which record a publication fact and append no
281
+ * version; the chain itself never emits them.
282
+ *
283
+ * @since 0.1.0
284
+ */
285
+ export const WriteAction = Schema.Literals([
286
+ "create",
287
+ "update",
288
+ "delete",
289
+ "restore",
290
+ "restoreVersion",
291
+ "publish",
292
+ "unpublish",
293
+ ]);
294
+ const isVersionConflict = Schema.is(VersionConflict);
295
+ /** The write clock: the current instant, as the `Date` a version row stores. */
296
+ const now = Effect.map(Clock.currentTimeMillis, (millis) => DateTime.toDate(DateTime.makeUnsafe(millis)));
297
+ /**
298
+ * Bind the chain operations for one leaf `type` to a store. Every produced
299
+ * operation is traced as `${type}.<operation>`. `hooks.beforeAppend`, when
300
+ * given, runs before every append (see {@link ChainHooks}); its failure is
301
+ * each write's `E`.
302
+ *
303
+ * @since 0.1.0
304
+ */
305
+ export const defineVersionChain = (type, store, hooks = {}) => {
306
+ const { beforeAppend, beforeAppendLocales } = hooks;
307
+ /**
308
+ * The state a write stores: the hook's patch (or the caller's, without a
309
+ * hook) over `base`, the prior state or nothing.
310
+ */
311
+ const nextState = (event, base) => Effect.gen(function* () {
312
+ const patch = beforeAppend === undefined ? event.patch : yield* beforeAppend(event);
313
+ const localePatch = beforeAppendLocales === undefined
314
+ ? (event.locales ?? {})
315
+ : yield* beforeAppendLocales(event);
316
+ const state = applyPatch(base.state, patch);
317
+ const locales = applyLocalePatch(localesOf(base), localePatch);
318
+ return Record.isEmptyRecord(locales) ? { state } : { state, locales };
319
+ });
320
+ /**
321
+ * Append at `previous + 1`, after checking the precondition against that
322
+ * same `previous`. The check and the append's version come from one read,
323
+ * so a writer that lands in between takes `previous + 1` first and this
324
+ * append fails the store's `(id, version)` key ({@link VersionConflict}):
325
+ * success means the head was still `expectedVersion` when the row went in.
326
+ */
327
+ const appendNext = (id, previous, action, content, actorId, precondition, proposedBy = Option.none()) => Effect.gen(function* () {
328
+ const expected = precondition.expectedVersion;
329
+ if (expected !== undefined && expected !== previous.version) {
330
+ return yield* new StaleVersion({ type, id, expected, current: previous.version });
331
+ }
332
+ const version = previous.version + 1n;
333
+ const timestamp = yield* now;
334
+ yield* store.append({
335
+ id,
336
+ type,
337
+ version,
338
+ action,
339
+ timestamp,
340
+ ...content,
341
+ actorId,
342
+ proposedBy,
343
+ });
344
+ return { id, version };
345
+ });
346
+ /** The current state: the head's snapshot. A head without a snapshot is a broken chain — a defect, not a miss. */
347
+ const current = (id) => Effect.gen(function* () {
348
+ const head = yield* store.head(id);
349
+ if (Option.isNone(head))
350
+ return Option.none();
351
+ const snapshot = yield* store.snapshot(id, head.value.version);
352
+ if (Option.isNone(snapshot)) {
353
+ return yield* Effect.die(new BrokenChain({ type, id, version: head.value.version }));
354
+ }
355
+ return Option.some(snapshot.value);
356
+ });
357
+ /**
358
+ * The head's full state for a hook to see, read only when there is a hook
359
+ * (`restoreVersion` otherwise needs the head entry alone).
360
+ */
361
+ const hookPrior = (id) => beforeAppend === undefined && beforeAppendLocales === undefined
362
+ ? Effect.succeed(Option.none())
363
+ : current(id);
364
+ const create = Effect.fn(`${type}.create`)(function* (input) {
365
+ const id = Option.isSome(input.id) ? input.id.value : yield* store.mintId;
366
+ if (Option.isSome(input.id) && Option.isSome(yield* store.head(id))) {
367
+ return yield* new NodeAlreadyExists({ type, id });
368
+ }
369
+ const content = yield* nextState({
370
+ action: "create",
371
+ id,
372
+ prior: Option.none(),
373
+ patch: input.state,
374
+ locales: input.locales ?? {},
375
+ actorId: input.actorId,
376
+ }, { state: {} });
377
+ const timestamp = yield* now;
378
+ yield* store
379
+ .append({
380
+ id,
381
+ type,
382
+ version: 0n,
383
+ action: "create",
384
+ timestamp,
385
+ ...content,
386
+ actorId: input.actorId,
387
+ proposedBy: Option.none(),
388
+ })
389
+ .pipe(
390
+ // A racing create that took the id between the check above and this
391
+ // append surfaces as the store's version-0 collision.
392
+ Effect.mapError((error) => isVersionConflict(error) && error.version === 0n
393
+ ? new NodeAlreadyExists({ type, id })
394
+ : error));
395
+ return { id, version: 0n };
396
+ });
397
+ const merge = (input, allowDeleted) => Effect.gen(function* () {
398
+ const head = yield* current(input.id);
399
+ if (Option.isNone(head) || (head.value.action === "delete" && !allowDeleted)) {
400
+ return yield* new NodeNotFound({ type, id: input.id });
401
+ }
402
+ const content = yield* nextState({
403
+ action: allowDeleted ? "restore" : "update",
404
+ id: input.id,
405
+ prior: head,
406
+ patch: input.patch,
407
+ locales: input.locales ?? {},
408
+ actorId: input.actorId,
409
+ }, head.value);
410
+ return yield* appendNext(input.id, head.value, "update", content, input.actorId, input, input.proposedBy);
411
+ });
412
+ const update = Effect.fn(`${type}.update`)(function* (input) {
413
+ return yield* merge(input, false);
414
+ });
415
+ const restore = Effect.fn(`${type}.restore`)(function* (input) {
416
+ return yield* merge(input, true);
417
+ });
418
+ const softDelete = Effect.fn(`${type}.delete`)(function* (id, actorId, precondition = {}) {
419
+ const head = yield* current(id);
420
+ if (Option.isNone(head))
421
+ return yield* new NodeNotFound({ type, id });
422
+ if (head.value.action === "delete") {
423
+ return { id, version: head.value.version, alreadyDeleted: true };
424
+ }
425
+ const content = yield* nextState({ action: "delete", id, prior: head, patch: {}, actorId }, head.value);
426
+ const written = yield* appendNext(id, head.value, "delete", content, actorId, precondition);
427
+ return { ...written, alreadyDeleted: false };
428
+ });
429
+ const getVersion = Effect.fn(`${type}.getVersion`)(function* (id, version) {
430
+ const snapshot = yield* store.snapshot(id, version);
431
+ if (Option.isNone(snapshot))
432
+ return yield* new VersionNotFound({ type, id, version });
433
+ return snapshot.value;
434
+ });
435
+ const compare = Effect.fn(`${type}.compare`)(function* (id, from, to) {
436
+ const before = yield* getVersion(id, from);
437
+ const after = yield* getVersion(id, to);
438
+ return {
439
+ from: before,
440
+ to: after,
441
+ changes: diffStates(before.state, after.state),
442
+ locales: diffLocales(localesOf(before), localesOf(after)),
443
+ };
444
+ });
445
+ const restoreVersion = Effect.fn(`${type}.restoreVersion`)(function* (id, version, actorId, precondition = {}) {
446
+ // Read the whole historical state FIRST, so an unreconstructable version
447
+ // fails before the chain is touched at all.
448
+ const snapshot = yield* store.snapshot(id, version);
449
+ if (Option.isNone(snapshot))
450
+ return yield* new VersionNotFound({ type, id, version });
451
+ const prior = yield* hookPrior(id);
452
+ const head = Option.isSome(prior) ? prior : yield* store.head(id);
453
+ if (Option.isNone(head))
454
+ return yield* new VersionNotFound({ type, id, version });
455
+ // Every locale is restored together with the shared columns: the
456
+ // locale patch is the whole historical level, over nothing.
457
+ const content = yield* nextState({
458
+ action: "restoreVersion",
459
+ id,
460
+ prior,
461
+ patch: snapshot.value.state,
462
+ locales: localesOf(snapshot.value),
463
+ actorId,
464
+ }, { state: {} });
465
+ // `update`, not a fourth action: a restore is an ordinary edit whose
466
+ // content came from history, and `action` stays the currency / tombstone
467
+ // axis every fail-closed view reads (#864 A8).
468
+ return yield* appendNext(id, head.value, "update", content, actorId, precondition);
469
+ });
470
+ const history = Effect.fn(`${type}.history`)(function* (id, limit = MAX_HISTORY_LIMIT) {
471
+ const bounded = Math.max(1, Math.min(Math.trunc(limit), MAX_HISTORY_LIMIT));
472
+ const entries = yield* store.entries(id, bounded);
473
+ return yield* Array.match(entries, {
474
+ onEmpty: () => Effect.fail(new NodeNotFound({ type, id })),
475
+ onNonEmpty: (nonEmpty) => Effect.succeed(nonEmpty),
476
+ });
477
+ });
478
+ return {
479
+ create,
480
+ update,
481
+ restore,
482
+ delete: softDelete,
483
+ getVersion,
484
+ compare,
485
+ restoreVersion,
486
+ history,
487
+ };
488
+ };
489
+ //# sourceMappingURL=version-chain.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version-chain.js","sourceRoot":"","sources":["../src/version-chain.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAg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AAK,EAAE,EAAE,EAAE,CACd,CAAC;QACF,qEAAqE;QACrE,yEAAyE;QACzE,+CAA+C;QAC/C,OAAO,KAAK,CAAC,CAAC,UAAU,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;IACrF,CAAC,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,CAAC,EAAE,CAAC,GAAG,IAAI,UAAU,CAAC,CAAC,QAAQ,CAAC,EACpD,EAAU,EACV,KAAK,GAAW,iBAAiB;QAEjC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC;QAC5E,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;QAClD,OAAO,KAAK,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,EAAE;YACjC,OAAO,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,YAAY,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;YAC1D,UAAU,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAmC,QAAQ,CAAC;SACrF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,MAAM;QACN,MAAM;QACN,OAAO;QACP,MAAM,EAAE,UAAU;QAClB,UAAU;QACV,OAAO;QACP,cAAc;QACd,OAAO;KACR,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,116 @@
1
+ /**
2
+ * **The working copy** — an editor's autosave buffer, kept outside the
3
+ * version chain and overwritten freely, which an explicit save appends as
4
+ * one ordinary `update` version.
5
+ *
6
+ * ## The model (owner decisions on pulpit#46)
7
+ *
8
+ * - **Nothing in a working copy is a version**: saving it writes only the
9
+ * {@link WorkingCopyStore}, so `VERSION-CHAIN-001` is untouched and a
10
+ * hundred autosaves leave no trace in history.
11
+ * - **One copy per (node, editor)**, so two editors never overwrite each
12
+ * other's unsaved work.
13
+ * - **`commit` appends the copy** through the leaf's own `update`, expecting
14
+ * the head the copy was first based on: an edit landing in between fails
15
+ * `StaleVersion` (and keeps the copy), so a commit never silently
16
+ * overwrites work its editor didn't see. A committed copy is cleared.
17
+ * - **Every operation is gated like a write** (the leaf's `authorize`):
18
+ * reading a copy shows unpublished state, so it is gated like the head.
19
+ *
20
+ * @copyright Thomas Foster
21
+ * @module pulpit/working-copy
22
+ * @since 0.1.0
23
+ */
24
+ import * as Effect from "effect/Effect";
25
+ import * as Option from "effect/Option";
26
+ import * as Schema from "effect/Schema";
27
+ import type { Forbidden, SubtypeOps, Unauthorized, WriteRejected } from "./subtype.ts";
28
+ import { NodeNotFound, type ChainPatch, type ChainWrite, type StaleVersion, type VersionChainStore, type VersionConflict } from "./version-chain.ts";
29
+ /**
30
+ * One editor's working copy of one node: the tri-state patch over the head
31
+ * it was based on, and when it was last saved.
32
+ *
33
+ * @since 0.1.0
34
+ */
35
+ export interface WorkingCopy {
36
+ readonly patch: ChainPatch;
37
+ /** The head the copy was first based on; `commit` expects it. */
38
+ readonly baseVersion: bigint;
39
+ readonly savedAt: Date;
40
+ }
41
+ /**
42
+ * Whose copy of which node.
43
+ *
44
+ * @since 0.1.0
45
+ */
46
+ export interface WorkingCopyKey {
47
+ readonly id: string;
48
+ readonly userId: string;
49
+ }
50
+ /**
51
+ * The overwritable buffer an application supplies (a table keyed by
52
+ * `(node_id, user_id)`, or a KV namespace). Applies no policy and fails
53
+ * only with its `E` (README → Seams).
54
+ *
55
+ * @since 0.1.0
56
+ */
57
+ export interface WorkingCopyStore<E, R> {
58
+ /** Write the copy, replacing any earlier one under the key. */
59
+ readonly put: (key: WorkingCopyKey, copy: WorkingCopy) => Effect.Effect<void, E, R>;
60
+ readonly get: (key: WorkingCopyKey) => Effect.Effect<Option.Option<WorkingCopy>, E, R>;
61
+ /** Remove the copy; idempotent. */
62
+ readonly discard: (key: WorkingCopyKey) => Effect.Effect<void, E, R>;
63
+ }
64
+ declare const WorkingCopyNotFound_base: Schema.Class<WorkingCopyNotFound, Schema.TaggedStruct<"WorkingCopyNotFound", {
65
+ readonly type: Schema.String;
66
+ readonly id: Schema.String;
67
+ }>, import("effect/Cause").YieldableError & {
68
+ readonly brand: unique symbol;
69
+ }>;
70
+ /**
71
+ * No working copy to commit: the wire's 404.
72
+ *
73
+ * @since 0.1.0
74
+ */
75
+ export declare class WorkingCopyNotFound extends WorkingCopyNotFound_base {
76
+ }
77
+ type Gate = Unauthorized | Forbidden | NodeNotFound;
78
+ /**
79
+ * The operations {@link defineWorkingCopy} produces, each acting on the
80
+ * calling editor's own copy.
81
+ *
82
+ * @since 0.1.0
83
+ */
84
+ export interface WorkingCopyOps<E, R> {
85
+ /**
86
+ * Save `patch` over the editor's copy (a value sets, `null` clears, an
87
+ * absent key keeps the copy's), based on the head when there was no
88
+ * copy. Fails at the leaf's write gate, and `NodeNotFound` for a missing
89
+ * or tombstoned node.
90
+ */
91
+ readonly save: (id: string, patch: ChainPatch) => Effect.Effect<WorkingCopy, Gate | E, R>;
92
+ /** The editor's copy, or none. Gated like a write. */
93
+ readonly get: (id: string) => Effect.Effect<Option.Option<WorkingCopy>, Gate | E, R>;
94
+ /** Throw the editor's copy away. Gated like a write. */
95
+ readonly discard: (id: string) => Effect.Effect<void, Gate | E, R>;
96
+ /**
97
+ * Append the copy as one `update` version, expecting its base head, and
98
+ * clear it. Fails `WorkingCopyNotFound` without a copy, and as the
99
+ * leaf's `update` does (`StaleVersion` when the head moved since the
100
+ * copy's base, keeping the copy; `WriteRejected` from its hooks).
101
+ */
102
+ readonly commit: (id: string) => Effect.Effect<ChainWrite, Gate | WorkingCopyNotFound | StaleVersion | VersionConflict | WriteRejected | E, R>;
103
+ }
104
+ /**
105
+ * Bind a leaf's working copies: `leaf` gates and commits, `chain` reads
106
+ * the head a new copy is based on, `store` keeps the copies.
107
+ *
108
+ * @since 0.1.0
109
+ */
110
+ export declare const defineWorkingCopy: <Resource, E, R>(definition: {
111
+ readonly leaf: SubtypeOps<Resource, E, R>;
112
+ readonly chain: VersionChainStore<E, R>;
113
+ readonly store: WorkingCopyStore<E, R>;
114
+ }) => WorkingCopyOps<E, R>;
115
+ export {};
116
+ //# sourceMappingURL=working-copy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"working-copy.d.ts","sourceRoot":"","sources":["../src/working-copy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACvF,OAAO,EACL,YAAY,EACZ,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACrB,MAAM,oBAAoB,CAAC;AAE5B;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAC3B,iEAAiE;IACjE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC;CACxB;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB,CAAC,CAAC,EAAE,CAAC;IACpC,+DAA+D;IAC/D,QAAQ,CAAC,GAAG,EAAE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