@smthrs/journal 0.0.0-stage → 1.0.0-rc.3

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 (257) hide show
  1. package/CHANGELOG.md +149 -0
  2. package/LICENSE +21 -0
  3. package/README.md +206 -2
  4. package/dist/cjs/CallFact.d.ts +129 -0
  5. package/dist/cjs/CallFact.d.ts.map +1 -0
  6. package/dist/cjs/CallFact.js +106 -0
  7. package/dist/cjs/CallFact.js.map +7 -0
  8. package/dist/cjs/Consensus.d.ts +440 -0
  9. package/dist/cjs/Consensus.d.ts.map +1 -0
  10. package/dist/cjs/Consensus.js +251 -0
  11. package/dist/cjs/Consensus.js.map +7 -0
  12. package/dist/cjs/EngineEvent.d.ts +890 -0
  13. package/dist/cjs/EngineEvent.d.ts.map +1 -0
  14. package/dist/cjs/EngineEvent.js +383 -0
  15. package/dist/cjs/EngineEvent.js.map +7 -0
  16. package/dist/cjs/ExecutionFact.d.ts +216 -0
  17. package/dist/cjs/ExecutionFact.d.ts.map +1 -0
  18. package/dist/cjs/ExecutionFact.js +303 -0
  19. package/dist/cjs/ExecutionFact.js.map +7 -0
  20. package/dist/cjs/Journal.d.ts +617 -0
  21. package/dist/cjs/Journal.d.ts.map +1 -0
  22. package/dist/cjs/Journal.js +190 -0
  23. package/dist/cjs/Journal.js.map +7 -0
  24. package/dist/cjs/JournalEvent.d.ts +421 -0
  25. package/dist/cjs/JournalEvent.d.ts.map +1 -0
  26. package/dist/cjs/JournalEvent.js +281 -0
  27. package/dist/cjs/JournalEvent.js.map +7 -0
  28. package/dist/cjs/JournalGeneration.d.ts +34 -0
  29. package/dist/cjs/JournalGeneration.d.ts.map +1 -0
  30. package/dist/cjs/JournalGeneration.js +72 -0
  31. package/dist/cjs/JournalGeneration.js.map +7 -0
  32. package/dist/cjs/JournalMetrics.d.ts +72 -0
  33. package/dist/cjs/JournalMetrics.d.ts.map +1 -0
  34. package/dist/cjs/JournalMetrics.js +55 -0
  35. package/dist/cjs/JournalMetrics.js.map +7 -0
  36. package/dist/cjs/Migrations.d.ts +42 -0
  37. package/dist/cjs/Migrations.d.ts.map +1 -0
  38. package/dist/cjs/Migrations.js +58 -0
  39. package/dist/cjs/Migrations.js.map +7 -0
  40. package/dist/cjs/OwnerId.d.ts +40 -0
  41. package/dist/cjs/OwnerId.d.ts.map +1 -0
  42. package/dist/cjs/OwnerId.js +40 -0
  43. package/dist/cjs/OwnerId.js.map +7 -0
  44. package/dist/cjs/Projection.d.ts +29 -0
  45. package/dist/cjs/Projection.d.ts.map +1 -0
  46. package/dist/cjs/Projection.js +25 -0
  47. package/dist/cjs/Projection.js.map +7 -0
  48. package/dist/cjs/RedactedLogger.d.ts +121 -0
  49. package/dist/cjs/RedactedLogger.d.ts.map +1 -0
  50. package/dist/cjs/RedactedLogger.js +235 -0
  51. package/dist/cjs/RedactedLogger.js.map +7 -0
  52. package/dist/cjs/Redaction.d.ts +350 -0
  53. package/dist/cjs/Redaction.d.ts.map +1 -0
  54. package/dist/cjs/Redaction.js +928 -0
  55. package/dist/cjs/Redaction.js.map +7 -0
  56. package/dist/cjs/SqlConsensus.d.ts +44 -0
  57. package/dist/cjs/SqlConsensus.d.ts.map +1 -0
  58. package/dist/cjs/SqlConsensus.js +243 -0
  59. package/dist/cjs/SqlConsensus.js.map +7 -0
  60. package/dist/cjs/SqlJournal.d.ts +173 -0
  61. package/dist/cjs/SqlJournal.d.ts.map +1 -0
  62. package/dist/cjs/SqlJournal.js +1568 -0
  63. package/dist/cjs/SqlJournal.js.map +7 -0
  64. package/dist/cjs/StepFact.d.ts +66 -0
  65. package/dist/cjs/StepFact.d.ts.map +1 -0
  66. package/dist/cjs/StepFact.js +68 -0
  67. package/dist/cjs/StepFact.js.map +7 -0
  68. package/dist/cjs/index.d.ts +95 -0
  69. package/dist/cjs/index.d.ts.map +1 -0
  70. package/dist/cjs/index.js +63 -0
  71. package/dist/cjs/index.js.map +7 -0
  72. package/dist/cjs/internal/JournalInternalFault.d.ts +37 -0
  73. package/dist/cjs/internal/JournalInternalFault.d.ts.map +1 -0
  74. package/dist/cjs/internal/JournalInternalFault.js +43 -0
  75. package/dist/cjs/internal/JournalInternalFault.js.map +7 -0
  76. package/dist/cjs/migrations/0001_initial.d.ts +15 -0
  77. package/dist/cjs/migrations/0001_initial.d.ts.map +1 -0
  78. package/dist/cjs/migrations/0001_initial.js +54 -0
  79. package/dist/cjs/migrations/0001_initial.js.map +7 -0
  80. package/dist/cjs/migrations/0002_checkpoints.d.ts +27 -0
  81. package/dist/cjs/migrations/0002_checkpoints.d.ts.map +1 -0
  82. package/dist/cjs/migrations/0002_checkpoints.js +48 -0
  83. package/dist/cjs/migrations/0002_checkpoints.js.map +7 -0
  84. package/dist/cjs/migrations/0003_startup_index.d.ts +15 -0
  85. package/dist/cjs/migrations/0003_startup_index.d.ts.map +1 -0
  86. package/dist/cjs/migrations/0003_startup_index.js +40 -0
  87. package/dist/cjs/migrations/0003_startup_index.js.map +7 -0
  88. package/dist/cjs/migrations/0004_dedup.d.ts +15 -0
  89. package/dist/cjs/migrations/0004_dedup.d.ts.map +1 -0
  90. package/dist/cjs/migrations/0004_dedup.js +57 -0
  91. package/dist/cjs/migrations/0004_dedup.js.map +7 -0
  92. package/dist/cjs/migrations/0005_run_event_type.d.ts +15 -0
  93. package/dist/cjs/migrations/0005_run_event_type.d.ts.map +1 -0
  94. package/dist/cjs/migrations/0005_run_event_type.js +40 -0
  95. package/dist/cjs/migrations/0005_run_event_type.js.map +7 -0
  96. package/dist/cjs/migrations/0006_consensus.d.ts +22 -0
  97. package/dist/cjs/migrations/0006_consensus.d.ts.map +1 -0
  98. package/dist/cjs/migrations/0006_consensus.js +84 -0
  99. package/dist/cjs/migrations/0006_consensus.js.map +7 -0
  100. package/dist/cjs/package.json +1 -0
  101. package/dist/cjs/test/Notifying.d.ts +65 -0
  102. package/dist/cjs/test/Notifying.d.ts.map +1 -0
  103. package/dist/cjs/test/Notifying.js +62 -0
  104. package/dist/cjs/test/Notifying.js.map +7 -0
  105. package/dist/cjs/test/TestJournal.d.ts +43 -0
  106. package/dist/cjs/test/TestJournal.d.ts.map +1 -0
  107. package/dist/cjs/test/TestJournal.js +43 -0
  108. package/dist/cjs/test/TestJournal.js.map +7 -0
  109. package/dist/esm/CallFact.d.ts +129 -0
  110. package/dist/esm/CallFact.d.ts.map +1 -0
  111. package/dist/esm/CallFact.js +96 -0
  112. package/dist/esm/CallFact.js.map +1 -0
  113. package/dist/esm/Consensus.d.ts +440 -0
  114. package/dist/esm/Consensus.d.ts.map +1 -0
  115. package/dist/esm/Consensus.js +454 -0
  116. package/dist/esm/Consensus.js.map +1 -0
  117. package/dist/esm/EngineEvent.d.ts +890 -0
  118. package/dist/esm/EngineEvent.d.ts.map +1 -0
  119. package/dist/esm/EngineEvent.js +614 -0
  120. package/dist/esm/EngineEvent.js.map +1 -0
  121. package/dist/esm/ExecutionFact.d.ts +216 -0
  122. package/dist/esm/ExecutionFact.d.ts.map +1 -0
  123. package/dist/esm/ExecutionFact.js +374 -0
  124. package/dist/esm/ExecutionFact.js.map +1 -0
  125. package/dist/esm/Journal.d.ts +617 -0
  126. package/dist/esm/Journal.d.ts.map +1 -0
  127. package/dist/esm/Journal.js +323 -0
  128. package/dist/esm/Journal.js.map +1 -0
  129. package/dist/esm/JournalEvent.d.ts +421 -0
  130. package/dist/esm/JournalEvent.d.ts.map +1 -0
  131. package/dist/esm/JournalEvent.js +517 -0
  132. package/dist/esm/JournalEvent.js.map +1 -0
  133. package/dist/esm/JournalGeneration.d.ts +34 -0
  134. package/dist/esm/JournalGeneration.d.ts.map +1 -0
  135. package/dist/esm/JournalGeneration.js +65 -0
  136. package/dist/esm/JournalGeneration.js.map +1 -0
  137. package/dist/esm/JournalMetrics.d.ts +72 -0
  138. package/dist/esm/JournalMetrics.d.ts.map +1 -0
  139. package/dist/esm/JournalMetrics.js +79 -0
  140. package/dist/esm/JournalMetrics.js.map +1 -0
  141. package/dist/esm/Migrations.d.ts +42 -0
  142. package/dist/esm/Migrations.d.ts.map +1 -0
  143. package/dist/esm/Migrations.js +59 -0
  144. package/dist/esm/Migrations.js.map +1 -0
  145. package/dist/esm/OwnerId.d.ts +40 -0
  146. package/dist/esm/OwnerId.d.ts.map +1 -0
  147. package/dist/esm/OwnerId.js +33 -0
  148. package/dist/esm/OwnerId.js.map +1 -0
  149. package/dist/esm/Projection.d.ts +29 -0
  150. package/dist/esm/Projection.d.ts.map +1 -0
  151. package/dist/esm/Projection.js +13 -0
  152. package/dist/esm/Projection.js.map +1 -0
  153. package/dist/esm/RedactedLogger.d.ts +121 -0
  154. package/dist/esm/RedactedLogger.d.ts.map +1 -0
  155. package/dist/esm/RedactedLogger.js +445 -0
  156. package/dist/esm/RedactedLogger.js.map +1 -0
  157. package/dist/esm/Redaction.d.ts +350 -0
  158. package/dist/esm/Redaction.d.ts.map +1 -0
  159. package/dist/esm/Redaction.js +1584 -0
  160. package/dist/esm/Redaction.js.map +1 -0
  161. package/dist/esm/SqlConsensus.d.ts +44 -0
  162. package/dist/esm/SqlConsensus.d.ts.map +1 -0
  163. package/dist/esm/SqlConsensus.js +252 -0
  164. package/dist/esm/SqlConsensus.js.map +1 -0
  165. package/dist/esm/SqlJournal.d.ts +173 -0
  166. package/dist/esm/SqlJournal.d.ts.map +1 -0
  167. package/dist/esm/SqlJournal.js +1858 -0
  168. package/dist/esm/SqlJournal.js.map +1 -0
  169. package/dist/esm/StepFact.d.ts +66 -0
  170. package/dist/esm/StepFact.d.ts.map +1 -0
  171. package/dist/esm/StepFact.js +50 -0
  172. package/dist/esm/StepFact.js.map +1 -0
  173. package/dist/esm/index.d.ts +95 -0
  174. package/dist/esm/index.d.ts.map +1 -0
  175. package/dist/esm/index.js +95 -0
  176. package/dist/esm/index.js.map +1 -0
  177. package/dist/esm/internal/JournalInternalFault.d.ts +37 -0
  178. package/dist/esm/internal/JournalInternalFault.d.ts.map +1 -0
  179. package/dist/esm/internal/JournalInternalFault.js +28 -0
  180. package/dist/esm/internal/JournalInternalFault.js.map +1 -0
  181. package/dist/esm/migrations/0001_initial.d.ts +15 -0
  182. package/dist/esm/migrations/0001_initial.d.ts.map +1 -0
  183. package/dist/esm/migrations/0001_initial.js +32 -0
  184. package/dist/esm/migrations/0001_initial.js.map +1 -0
  185. package/dist/esm/migrations/0002_checkpoints.d.ts +27 -0
  186. package/dist/esm/migrations/0002_checkpoints.d.ts.map +1 -0
  187. package/dist/esm/migrations/0002_checkpoints.js +38 -0
  188. package/dist/esm/migrations/0002_checkpoints.js.map +1 -0
  189. package/dist/esm/migrations/0003_startup_index.d.ts +15 -0
  190. package/dist/esm/migrations/0003_startup_index.d.ts.map +1 -0
  191. package/dist/esm/migrations/0003_startup_index.js +18 -0
  192. package/dist/esm/migrations/0003_startup_index.js.map +1 -0
  193. package/dist/esm/migrations/0004_dedup.d.ts +15 -0
  194. package/dist/esm/migrations/0004_dedup.d.ts.map +1 -0
  195. package/dist/esm/migrations/0004_dedup.js +38 -0
  196. package/dist/esm/migrations/0004_dedup.js.map +1 -0
  197. package/dist/esm/migrations/0005_run_event_type.d.ts +15 -0
  198. package/dist/esm/migrations/0005_run_event_type.d.ts.map +1 -0
  199. package/dist/esm/migrations/0005_run_event_type.js +18 -0
  200. package/dist/esm/migrations/0005_run_event_type.js.map +1 -0
  201. package/dist/esm/migrations/0006_consensus.d.ts +22 -0
  202. package/dist/esm/migrations/0006_consensus.d.ts.map +1 -0
  203. package/dist/esm/migrations/0006_consensus.js +69 -0
  204. package/dist/esm/migrations/0006_consensus.js.map +1 -0
  205. package/dist/esm/test/Notifying.d.ts +65 -0
  206. package/dist/esm/test/Notifying.d.ts.map +1 -0
  207. package/dist/esm/test/Notifying.js +62 -0
  208. package/dist/esm/test/Notifying.js.map +1 -0
  209. package/dist/esm/test/TestJournal.d.ts +43 -0
  210. package/dist/esm/test/TestJournal.d.ts.map +1 -0
  211. package/dist/esm/test/TestJournal.js +27 -0
  212. package/dist/esm/test/TestJournal.js.map +1 -0
  213. package/docs/README.md +164 -0
  214. package/docs/api.md +639 -0
  215. package/docs/concepts/compaction.md +157 -0
  216. package/docs/concepts/idempotency.md +127 -0
  217. package/docs/concepts/owner-fence.md +124 -0
  218. package/docs/concepts/redaction.md +218 -0
  219. package/docs/concepts/state-event-authority.md +159 -0
  220. package/docs/concepts/two-channels.md +167 -0
  221. package/docs/guides/commit-state-and-entry.md +114 -0
  222. package/docs/guides/compact-a-run.md +134 -0
  223. package/docs/guides/fold-a-projection.md +106 -0
  224. package/docs/guides/read-a-run.md +139 -0
  225. package/docs/guides/redact-log-output.md +94 -0
  226. package/docs/guides/testing.md +124 -0
  227. package/docs/guides/write-lifecycle-events.md +110 -0
  228. package/docs/installation.md +133 -0
  229. package/docs/quickstart.md +143 -0
  230. package/docs/troubleshooting.md +214 -0
  231. package/package.json +263 -3
  232. package/src/CallFact.ts +117 -0
  233. package/src/Consensus.ts +683 -0
  234. package/src/EngineEvent.ts +823 -0
  235. package/src/ExecutionFact.ts +433 -0
  236. package/src/Journal.ts +688 -0
  237. package/src/JournalEvent.ts +654 -0
  238. package/src/JournalGeneration.ts +77 -0
  239. package/src/JournalMetrics.ts +89 -0
  240. package/src/Migrations.ts +62 -0
  241. package/src/OwnerId.ts +42 -0
  242. package/src/Projection.ts +31 -0
  243. package/src/RedactedLogger.ts +483 -0
  244. package/src/Redaction.ts +1784 -0
  245. package/src/SqlConsensus.ts +344 -0
  246. package/src/SqlJournal.ts +2732 -0
  247. package/src/StepFact.ts +69 -0
  248. package/src/index.ts +109 -0
  249. package/src/internal/JournalInternalFault.ts +40 -0
  250. package/src/migrations/0001_initial.ts +41 -0
  251. package/src/migrations/0002_checkpoints.ts +46 -0
  252. package/src/migrations/0003_startup_index.ts +19 -0
  253. package/src/migrations/0004_dedup.ts +43 -0
  254. package/src/migrations/0005_run_event_type.ts +19 -0
  255. package/src/migrations/0006_consensus.ts +83 -0
  256. package/src/test/Notifying.ts +101 -0
  257. package/src/test/TestJournal.ts +52 -0
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Durable journal services: the immutable event history and nothing else.
3
+ *
4
+ * Run and attempt state live in `@smthrs/run-store`, sealed step results in
5
+ * `@smthrs/step-cache`, and the durable deferred/clock tables in
6
+ * `@smthrs/engine-store`.
7
+ *
8
+ * This entry point is browser-bundleable: every service here is written
9
+ * against the driver-neutral `@smthrs/database` contract. The test doubles are
10
+ * kept out of it and live under explicit subpaths; of the two, only
11
+ * `TestJournal` binds a Node SQLite database:
12
+ *
13
+ * ```ts
14
+ * import { Journal, SqlJournal } from "@smthrs/journal"
15
+ * import * as TestJournal from "@smthrs/journal/test/TestJournal"
16
+ * import * as Notifying from "@smthrs/journal/test/Notifying"
17
+ * ```
18
+ *
19
+ * @since 0.1.0
20
+ */
21
+ /**
22
+ * @category events
23
+ * @since 0.1.0
24
+ */
25
+ export * as JournalEvent from "./JournalEvent.ts";
26
+ /**
27
+ * @category events
28
+ * @since 1.0.0
29
+ */
30
+ export * as EngineEvent from "./EngineEvent.ts";
31
+ /**
32
+ * @category events
33
+ * @since 1.0.0
34
+ */
35
+ export * as ExecutionFact from "./ExecutionFact.ts";
36
+ /**
37
+ * @category events
38
+ * @since 1.0.0
39
+ */
40
+ export * as CallFact from "./CallFact.ts";
41
+ /**
42
+ * @since 1.0.0
43
+ */
44
+ export * as StepFact from "./StepFact.ts";
45
+ /**
46
+ * @category services
47
+ * @since 0.1.0
48
+ */
49
+ export * as Journal from "./Journal.ts";
50
+ /**
51
+ * @category layers
52
+ * @since 0.1.0
53
+ */
54
+ export * as SqlJournal from "./SqlJournal.ts";
55
+ /**
56
+ * @category services
57
+ * @since 1.0.0
58
+ */
59
+ export * as Consensus from "./Consensus.ts";
60
+ /**
61
+ * @category layers
62
+ * @since 1.0.0
63
+ */
64
+ export * as SqlConsensus from "./SqlConsensus.ts";
65
+ /**
66
+ * @category metrics
67
+ * @since 0.1.0
68
+ */
69
+ export * as JournalMetrics from "./JournalMetrics.ts";
70
+ /**
71
+ * @category redaction
72
+ * @since 0.1.0
73
+ */
74
+ export * as Redaction from "./Redaction.ts";
75
+ /**
76
+ * @category redaction
77
+ * @since 0.1.0
78
+ */
79
+ export * as RedactedLogger from "./RedactedLogger.ts";
80
+ /**
81
+ * @category projections
82
+ * @since 0.1.0
83
+ */
84
+ export * as Projection from "./Projection.ts";
85
+ /**
86
+ * @category models
87
+ * @since 0.1.0
88
+ */
89
+ export * as OwnerId from "./OwnerId.ts";
90
+ /**
91
+ * @category migrations
92
+ * @since 0.1.0
93
+ */
94
+ export * as Migrations from "./Migrations.ts";
95
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;GAGG;AACH,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AAEjD;;;GAGG;AACH,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAA;AAE/C;;;GAGG;AACH,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AAEnD;;;GAGG;AACH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC;;GAEG;AACH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAA;AAEzC;;;GAGG;AACH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAEvC;;;GAGG;AACH,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAE7C;;;GAGG;AACH,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAE3C;;;GAGG;AACH,OAAO,KAAK,YAAY,MAAM,mBAAmB,CAAA;AAEjD;;;GAGG;AACH,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA;AAErD;;;GAGG;AACH,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAA;AAE3C;;;GAGG;AACH,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA;AAErD;;;GAGG;AACH,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA;AAE7C;;;GAGG;AACH,OAAO,KAAK,OAAO,MAAM,cAAc,CAAA;AAEvC;;;GAGG;AACH,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAA"}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var index_exports = {};
30
+ __export(index_exports, {
31
+ CallFact: () => CallFact,
32
+ Consensus: () => Consensus,
33
+ EngineEvent: () => EngineEvent,
34
+ ExecutionFact: () => ExecutionFact,
35
+ Journal: () => Journal,
36
+ JournalEvent: () => JournalEvent,
37
+ JournalMetrics: () => JournalMetrics,
38
+ Migrations: () => Migrations,
39
+ OwnerId: () => OwnerId,
40
+ Projection: () => Projection,
41
+ RedactedLogger: () => RedactedLogger,
42
+ Redaction: () => Redaction,
43
+ SqlConsensus: () => SqlConsensus,
44
+ SqlJournal: () => SqlJournal,
45
+ StepFact: () => StepFact
46
+ });
47
+ module.exports = __toCommonJS(index_exports);
48
+ var JournalEvent = __toESM(require("./JournalEvent.js"), 1);
49
+ var EngineEvent = __toESM(require("./EngineEvent.js"), 1);
50
+ var ExecutionFact = __toESM(require("./ExecutionFact.js"), 1);
51
+ var CallFact = __toESM(require("./CallFact.js"), 1);
52
+ var StepFact = __toESM(require("./StepFact.js"), 1);
53
+ var Journal = __toESM(require("./Journal.js"), 1);
54
+ var SqlJournal = __toESM(require("./SqlJournal.js"), 1);
55
+ var Consensus = __toESM(require("./Consensus.js"), 1);
56
+ var SqlConsensus = __toESM(require("./SqlConsensus.js"), 1);
57
+ var JournalMetrics = __toESM(require("./JournalMetrics.js"), 1);
58
+ var Redaction = __toESM(require("./Redaction.js"), 1);
59
+ var RedactedLogger = __toESM(require("./RedactedLogger.js"), 1);
60
+ var Projection = __toESM(require("./Projection.js"), 1);
61
+ var OwnerId = __toESM(require("./OwnerId.js"), 1);
62
+ var Migrations = __toESM(require("./Migrations.js"), 1);
63
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/index.ts"],
4
+ "sourcesContent": ["/**\n * Durable journal services: the immutable event history and nothing else.\n *\n * Run and attempt state live in `@smthrs/run-store`, sealed step results in\n * `@smthrs/step-cache`, and the durable deferred/clock tables in\n * `@smthrs/engine-store`.\n *\n * This entry point is browser-bundleable: every service here is written\n * against the driver-neutral `@smthrs/database` contract. The test doubles are\n * kept out of it and live under explicit subpaths; of the two, only\n * `TestJournal` binds a Node SQLite database:\n *\n * ```ts\n * import { Journal, SqlJournal } from \"@smthrs/journal\"\n * import * as TestJournal from \"@smthrs/journal/test/TestJournal\"\n * import * as Notifying from \"@smthrs/journal/test/Notifying\"\n * ```\n *\n * @since 0.1.0\n */\n\n/**\n * @category events\n * @since 0.1.0\n */\nexport * as JournalEvent from \"./JournalEvent.ts\"\n\n/**\n * @category events\n * @since 1.0.0\n */\nexport * as EngineEvent from \"./EngineEvent.ts\"\n\n/**\n * @category events\n * @since 1.0.0\n */\nexport * as ExecutionFact from \"./ExecutionFact.ts\"\n\n/**\n * @category events\n * @since 1.0.0\n */\nexport * as CallFact from \"./CallFact.ts\"\n\n/**\n * @since 1.0.0\n */\nexport * as StepFact from \"./StepFact.ts\"\n\n/**\n * @category services\n * @since 0.1.0\n */\nexport * as Journal from \"./Journal.ts\"\n\n/**\n * @category layers\n * @since 0.1.0\n */\nexport * as SqlJournal from \"./SqlJournal.ts\"\n\n/**\n * @category services\n * @since 1.0.0\n */\nexport * as Consensus from \"./Consensus.ts\"\n\n/**\n * @category layers\n * @since 1.0.0\n */\nexport * as SqlConsensus from \"./SqlConsensus.ts\"\n\n/**\n * @category metrics\n * @since 0.1.0\n */\nexport * as JournalMetrics from \"./JournalMetrics.ts\"\n\n/**\n * @category redaction\n * @since 0.1.0\n */\nexport * as Redaction from \"./Redaction.ts\"\n\n/**\n * @category redaction\n * @since 0.1.0\n */\nexport * as RedactedLogger from \"./RedactedLogger.ts\"\n\n/**\n * @category projections\n * @since 0.1.0\n */\nexport * as Projection from \"./Projection.ts\"\n\n/**\n * @category models\n * @since 0.1.0\n */\nexport * as OwnerId from \"./OwnerId.ts\"\n\n/**\n * @category migrations\n * @since 0.1.0\n */\nexport * as Migrations from \"./Migrations.ts\"\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyBA,mBAA8B;AAM9B,kBAA6B;AAM7B,oBAA+B;AAM/B,eAA0B;AAK1B,eAA0B;AAM1B,cAAyB;AAMzB,iBAA4B;AAM5B,gBAA2B;AAM3B,mBAA8B;AAM9B,qBAAgC;AAMhC,gBAA2B;AAM3B,qBAAgC;AAMhC,iBAA4B;AAM5B,cAAyB;AAMzB,iBAA4B;",
6
+ "names": []
7
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Faults of the journal's own background maintenance. They are logged and
3
+ * damped, never surfaced to a caller's write, so a log reader classifies one by
4
+ * `_tag` and `code` instead of a message.
5
+ *
6
+ * @since 1.0.0
7
+ */
8
+ import * as Schema from "effect/Schema";
9
+ /**
10
+ * Which background step refused.
11
+ *
12
+ * @category models
13
+ * @since 1.0.0
14
+ */
15
+ export declare const JournalInternalFaultCode: Schema.Literals<readonly ["compaction_capture_timeout"]>;
16
+ /**
17
+ * The stable code of a {@link JournalInternalFault}.
18
+ *
19
+ * @category models
20
+ * @since 1.0.0
21
+ */
22
+ export type JournalInternalFaultCode = typeof JournalInternalFaultCode.Type;
23
+ declare const JournalInternalFault_base: Schema.Class<JournalInternalFault, Schema.TaggedStruct<"@smthrs/journal/JournalInternalFault", {
24
+ readonly code: Schema.Literals<readonly ["compaction_capture_timeout"]>;
25
+ readonly message: Schema.String;
26
+ }>, import("effect/Cause").YieldableError>;
27
+ /**
28
+ * A post-commit maintenance step that refused.
29
+ *
30
+ * @category errors
31
+ * @since 1.0.0
32
+ */
33
+ export declare class JournalInternalFault extends JournalInternalFault_base {
34
+ readonly name = "JournalInternalFault";
35
+ }
36
+ export {};
37
+ //# sourceMappingURL=JournalInternalFault.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JournalInternalFault.d.ts","sourceRoot":"","sources":["../../../src/internal/JournalInternalFault.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,0DAAkD,CAAA;AAEvF;;;;;GAKG;AACH,MAAM,MAAM,wBAAwB,GAAG,OAAO,wBAAwB,CAAC,IAAI,CAAA;;;;;AAE3E;;;;;GAKG;AACH,qBAAa,oBACX,SAAQ,yBAGN;IAEF,SAAkB,IAAI,0BAAyB;CAChD"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var JournalInternalFault_exports = {};
30
+ __export(JournalInternalFault_exports, {
31
+ JournalInternalFault: () => JournalInternalFault,
32
+ JournalInternalFaultCode: () => JournalInternalFaultCode
33
+ });
34
+ module.exports = __toCommonJS(JournalInternalFault_exports);
35
+ var Schema = __toESM(require("effect/Schema"), 1);
36
+ const JournalInternalFaultCode = Schema.Literals(["compaction_capture_timeout"]);
37
+ class JournalInternalFault extends Schema.TaggedError()("@smthrs/journal/JournalInternalFault", {
38
+ code: JournalInternalFaultCode,
39
+ message: Schema.String
40
+ }) {
41
+ name = "JournalInternalFault";
42
+ }
43
+ //# sourceMappingURL=JournalInternalFault.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/internal/JournalInternalFault.ts"],
4
+ "sourcesContent": ["/**\n * Faults of the journal's own background maintenance. They are logged and\n * damped, never surfaced to a caller's write, so a log reader classifies one by\n * `_tag` and `code` instead of a message.\n *\n * @since 1.0.0\n */\n\nimport * as Schema from \"effect/Schema\"\n\n/**\n * Which background step refused.\n *\n * @category models\n * @since 1.0.0\n */\nexport const JournalInternalFaultCode = Schema.Literals([\"compaction_capture_timeout\"])\n\n/**\n * The stable code of a {@link JournalInternalFault}.\n *\n * @category models\n * @since 1.0.0\n */\nexport type JournalInternalFaultCode = typeof JournalInternalFaultCode.Type\n\n/**\n * A post-commit maintenance step that refused.\n *\n * @category errors\n * @since 1.0.0\n */\nexport class JournalInternalFault\n extends Schema.TaggedError<JournalInternalFault>()(\"@smthrs/journal/JournalInternalFault\", {\n code: JournalInternalFaultCode,\n message: Schema.String\n })\n{\n override readonly name = \"JournalInternalFault\"\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,aAAwB;AAQjB,MAAM,2BAA2B,OAAO,SAAS,CAAC,4BAA4B,CAAC;AAgB/E,MAAM,6BACH,OAAO,YAAkC,EAAE,wCAAwC;AAAA,EACzF,MAAM;AAAA,EACN,SAAS,OAAO;AAClB,CAAC,EACH;AAAA,EACoB,OAAO;AAC3B;",
6
+ "names": []
7
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Initial durable journal event schema.
3
+ *
4
+ * @since 0.1.0
5
+ */
6
+ import * as Effect from "effect/Effect";
7
+ import * as SqlClient from "effect/unstable/sql/SqlClient";
8
+ /**
9
+ * Creates the `flows_journal_events` table and its event-type index.
10
+ *
11
+ * @category migrations
12
+ * @since 0.1.0
13
+ */
14
+ export declare const initial: Effect.Effect<void, unknown, SqlClient.SqlClient>;
15
+ //# sourceMappingURL=0001_initial.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"0001_initial.d.ts","sourceRoot":"","sources":["../../../src/migrations/0001_initial.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,+BAA+B,CAAA;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,SAAS,CAwBpE,CAAA"}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var initial_exports = {};
30
+ __export(initial_exports, {
31
+ initial: () => initial
32
+ });
33
+ module.exports = __toCommonJS(initial_exports);
34
+ var Dialect = __toESM(require("@smthrs/database/Dialect"), 1);
35
+ var Effect = __toESM(require("effect/Effect"), 1);
36
+ var SqlClient = __toESM(require("effect/unstable/sql/SqlClient"), 1);
37
+ const initial = Effect.gen(function* () {
38
+ const sql = yield* SqlClient.SqlClient;
39
+ yield* sql`CREATE TABLE flows_journal_events (
40
+ run_id TEXT NOT NULL CHECK (length(run_id) > 0),
41
+ seq ${Dialect.integer(sql)} NOT NULL CHECK (${Dialect.isInteger(sql, sql`seq`)} AND seq >= 0 AND seq <= 9007199254740991),
42
+ event_id TEXT NOT NULL UNIQUE CHECK (length(event_id) > 0),
43
+ source_id TEXT NOT NULL CHECK (length(source_id) > 0),
44
+ source_seq ${Dialect.integer(sql)} NOT NULL CHECK (${Dialect.isInteger(sql, sql`source_seq`)} AND source_seq >= 0 AND source_seq <= 9007199254740991),
45
+ emitted_at_ms ${Dialect.integer(sql)} NOT NULL CHECK (${Dialect.isInteger(sql, sql`emitted_at_ms`)} AND emitted_at_ms >= 0 AND emitted_at_ms <= 9007199254740991),
46
+ event_type TEXT NOT NULL CHECK (length(event_type) > 0),
47
+ payload_json TEXT NOT NULL CHECK (${Dialect.jsonValid(sql, sql`payload_json`)}),
48
+ meta_json TEXT NOT NULL CHECK (${Dialect.jsonValid(sql, sql`meta_json`)}),
49
+ PRIMARY KEY (run_id, seq),
50
+ UNIQUE (run_id, source_id, source_seq)
51
+ )`;
52
+ yield* sql`CREATE INDEX flows_journal_events_event_type_idx ON flows_journal_events (event_type)`;
53
+ });
54
+ //# sourceMappingURL=0001_initial.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/migrations/0001_initial.ts"],
4
+ "sourcesContent": ["/**\n * Initial durable journal event schema.\n *\n * @since 0.1.0\n */\n\nimport * as Dialect from \"@smthrs/database/Dialect\"\nimport * as Effect from \"effect/Effect\"\nimport * as SqlClient from \"effect/unstable/sql/SqlClient\"\n\n/**\n * Creates the `flows_journal_events` table and its event-type index.\n *\n * @category migrations\n * @since 0.1.0\n */\nexport const initial: Effect.Effect<void, unknown, SqlClient.SqlClient> = Effect.gen(function*() {\n const sql = yield* SqlClient.SqlClient\n\n yield* sql`CREATE TABLE flows_journal_events (\n run_id TEXT NOT NULL CHECK (length(run_id) > 0),\n seq ${Dialect.integer(sql)} NOT NULL CHECK (${\n Dialect.isInteger(sql, sql`seq`)\n } AND seq >= 0 AND seq <= 9007199254740991),\n event_id TEXT NOT NULL UNIQUE CHECK (length(event_id) > 0),\n source_id TEXT NOT NULL CHECK (length(source_id) > 0),\n source_seq ${Dialect.integer(sql)} NOT NULL CHECK (${\n Dialect.isInteger(sql, sql`source_seq`)\n } AND source_seq >= 0 AND source_seq <= 9007199254740991),\n emitted_at_ms ${Dialect.integer(sql)} NOT NULL CHECK (${\n Dialect.isInteger(sql, sql`emitted_at_ms`)\n } AND emitted_at_ms >= 0 AND emitted_at_ms <= 9007199254740991),\n event_type TEXT NOT NULL CHECK (length(event_type) > 0),\n payload_json TEXT NOT NULL CHECK (${Dialect.jsonValid(sql, sql`payload_json`)}),\n meta_json TEXT NOT NULL CHECK (${Dialect.jsonValid(sql, sql`meta_json`)}),\n PRIMARY KEY (run_id, seq),\n UNIQUE (run_id, source_id, source_seq)\n )`\n\n yield* sql`CREATE INDEX flows_journal_events_event_type_idx ON flows_journal_events (event_type)`\n})\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,cAAyB;AACzB,aAAwB;AACxB,gBAA2B;AAQpB,MAAM,UAA6D,OAAO,IAAI,aAAY;AAC/F,QAAM,MAAM,OAAO,UAAU;AAE7B,SAAO;AAAA;AAAA,UAEC,QAAQ,QAAQ,GAAG,CAAC,oBAC1B,QAAQ,UAAU,KAAK,QAAQ,CACjC;AAAA;AAAA;AAAA,iBAGe,QAAQ,QAAQ,GAAG,CAAC,oBACjC,QAAQ,UAAU,KAAK,eAAe,CACxC;AAAA,oBACkB,QAAQ,QAAQ,GAAG,CAAC,oBACpC,QAAQ,UAAU,KAAK,kBAAkB,CAC3C;AAAA;AAAA,wCAEsC,QAAQ,UAAU,KAAK,iBAAiB,CAAC;AAAA,qCAC5C,QAAQ,UAAU,KAAK,cAAc,CAAC;AAAA;AAAA;AAAA;AAKzE,SAAO;AACT,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Durable journal checkpoints and the compaction floor.
3
+ *
4
+ * One row per `(run_id, seq)`: the caller-captured state that replays the run
5
+ * from `seq` without the entries before it. `compacted_at_ms` is NULL until a
6
+ * compaction has truncated the entries strictly below `seq`; the largest
7
+ * compacted `seq` per run is the run's compaction floor, and reads whose
8
+ * cursor starts below it fail with `compacted` instead of returning a
9
+ * silently shortened history.
10
+ *
11
+ * Prior art: Temporal's mutable state is exactly this shape, a durable
12
+ * snapshot pinned to a history offset (`last_first_event_id` in
13
+ * `reference/temporal/proto/internal/temporal/server/api/persistence/v1/executions.proto`),
14
+ * with history below it never replayed.
15
+ *
16
+ * @since 0.1.0
17
+ */
18
+ import * as Effect from "effect/Effect";
19
+ import * as SqlClient from "effect/unstable/sql/SqlClient";
20
+ /**
21
+ * Creates the `flows_journal_checkpoints` table.
22
+ *
23
+ * @category migrations
24
+ * @since 0.1.0
25
+ */
26
+ export declare const checkpoints: Effect.Effect<void, unknown, SqlClient.SqlClient>;
27
+ //# sourceMappingURL=0002_checkpoints.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"0002_checkpoints.d.ts","sourceRoot":"","sources":["../../../src/migrations/0002_checkpoints.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,+BAA+B,CAAA;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,SAAS,CAiBxE,CAAA"}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var checkpoints_exports = {};
30
+ __export(checkpoints_exports, {
31
+ checkpoints: () => checkpoints
32
+ });
33
+ module.exports = __toCommonJS(checkpoints_exports);
34
+ var Dialect = __toESM(require("@smthrs/database/Dialect"), 1);
35
+ var Effect = __toESM(require("effect/Effect"), 1);
36
+ var SqlClient = __toESM(require("effect/unstable/sql/SqlClient"), 1);
37
+ const checkpoints = Effect.gen(function* () {
38
+ const sql = yield* SqlClient.SqlClient;
39
+ yield* sql`CREATE TABLE flows_journal_checkpoints (
40
+ run_id TEXT NOT NULL CHECK (length(run_id) > 0),
41
+ seq ${Dialect.integer(sql)} NOT NULL CHECK (${Dialect.isInteger(sql, sql`seq`)} AND seq >= 0 AND seq <= 9007199254740991),
42
+ state_json TEXT NOT NULL CHECK (${Dialect.jsonValid(sql, sql`state_json`)}),
43
+ created_at_ms ${Dialect.integer(sql)} NOT NULL CHECK (${Dialect.isInteger(sql, sql`created_at_ms`)} AND created_at_ms >= 0 AND created_at_ms <= 9007199254740991),
44
+ compacted_at_ms ${Dialect.integer(sql)} CHECK (compacted_at_ms IS NULL OR (${Dialect.isInteger(sql, sql`compacted_at_ms`)} AND compacted_at_ms >= 0 AND compacted_at_ms <= 9007199254740991)),
45
+ PRIMARY KEY (run_id, seq)
46
+ )`;
47
+ });
48
+ //# sourceMappingURL=0002_checkpoints.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/migrations/0002_checkpoints.ts"],
4
+ "sourcesContent": ["/**\n * Durable journal checkpoints and the compaction floor.\n *\n * One row per `(run_id, seq)`: the caller-captured state that replays the run\n * from `seq` without the entries before it. `compacted_at_ms` is NULL until a\n * compaction has truncated the entries strictly below `seq`; the largest\n * compacted `seq` per run is the run's compaction floor, and reads whose\n * cursor starts below it fail with `compacted` instead of returning a\n * silently shortened history.\n *\n * Prior art: Temporal's mutable state is exactly this shape, a durable\n * snapshot pinned to a history offset (`last_first_event_id` in\n * `reference/temporal/proto/internal/temporal/server/api/persistence/v1/executions.proto`),\n * with history below it never replayed.\n *\n * @since 0.1.0\n */\n\nimport * as Dialect from \"@smthrs/database/Dialect\"\nimport * as Effect from \"effect/Effect\"\nimport * as SqlClient from \"effect/unstable/sql/SqlClient\"\n\n/**\n * Creates the `flows_journal_checkpoints` table.\n *\n * @category migrations\n * @since 0.1.0\n */\nexport const checkpoints: Effect.Effect<void, unknown, SqlClient.SqlClient> = Effect.gen(function*() {\n const sql = yield* SqlClient.SqlClient\n\n yield* sql`CREATE TABLE flows_journal_checkpoints (\n run_id TEXT NOT NULL CHECK (length(run_id) > 0),\n seq ${Dialect.integer(sql)} NOT NULL CHECK (${\n Dialect.isInteger(sql, sql`seq`)\n } AND seq >= 0 AND seq <= 9007199254740991),\n state_json TEXT NOT NULL CHECK (${Dialect.jsonValid(sql, sql`state_json`)}),\n created_at_ms ${Dialect.integer(sql)} NOT NULL CHECK (${\n Dialect.isInteger(sql, sql`created_at_ms`)\n } AND created_at_ms >= 0 AND created_at_ms <= 9007199254740991),\n compacted_at_ms ${Dialect.integer(sql)} CHECK (compacted_at_ms IS NULL OR (${\n Dialect.isInteger(sql, sql`compacted_at_ms`)\n } AND compacted_at_ms >= 0 AND compacted_at_ms <= 9007199254740991)),\n PRIMARY KEY (run_id, seq)\n )`\n})\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBA,cAAyB;AACzB,aAAwB;AACxB,gBAA2B;AAQpB,MAAM,cAAiE,OAAO,IAAI,aAAY;AACnG,QAAM,MAAM,OAAO,UAAU;AAE7B,SAAO;AAAA;AAAA,UAEC,QAAQ,QAAQ,GAAG,CAAC,oBAC1B,QAAQ,UAAU,KAAK,QAAQ,CACjC;AAAA,sCACoC,QAAQ,UAAU,KAAK,eAAe,CAAC;AAAA,oBACzD,QAAQ,QAAQ,GAAG,CAAC,oBACpC,QAAQ,UAAU,KAAK,kBAAkB,CAC3C;AAAA,sBACoB,QAAQ,QAAQ,GAAG,CAAC,uCACtC,QAAQ,UAAU,KAAK,oBAAoB,CAC7C;AAAA;AAAA;AAGF,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Index for the bounded journal source-event startup window.
3
+ *
4
+ * @since 0.1.0
5
+ */
6
+ import * as Effect from "effect/Effect";
7
+ import * as SqlClient from "effect/unstable/sql/SqlClient";
8
+ /**
9
+ * Preserves deterministic timestamp/run/sequence ordering without sorting the retained history.
10
+ *
11
+ * @category migrations
12
+ * @since 0.1.0
13
+ */
14
+ export declare const startupIndex: Effect.Effect<void, import("effect/unstable/sql/SqlError").SqlError, SqlClient.SqlClient>;
15
+ //# sourceMappingURL=0003_startup_index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"0003_startup_index.d.ts","sourceRoot":"","sources":["../../../src/migrations/0003_startup_index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,+BAA+B,CAAA;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,YAAY,2FAGvB,CAAA"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var startup_index_exports = {};
30
+ __export(startup_index_exports, {
31
+ startupIndex: () => startupIndex
32
+ });
33
+ module.exports = __toCommonJS(startup_index_exports);
34
+ var Effect = __toESM(require("effect/Effect"), 1);
35
+ var SqlClient = __toESM(require("effect/unstable/sql/SqlClient"), 1);
36
+ const startupIndex = Effect.gen(function* () {
37
+ const sql = yield* SqlClient.SqlClient;
38
+ yield* sql`CREATE INDEX flows_journal_events_startup_idx ON flows_journal_events (emitted_at_ms DESC, run_id DESC, seq DESC)`;
39
+ });
40
+ //# sourceMappingURL=0003_startup_index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/migrations/0003_startup_index.ts"],
4
+ "sourcesContent": ["/**\n * Index for the bounded journal source-event startup window.\n *\n * @since 0.1.0\n */\n\nimport * as Effect from \"effect/Effect\"\nimport * as SqlClient from \"effect/unstable/sql/SqlClient\"\n\n/**\n * Preserves deterministic timestamp/run/sequence ordering without sorting the retained history.\n *\n * @category migrations\n * @since 0.1.0\n */\nexport const startupIndex = Effect.gen(function*() {\n const sql = yield* SqlClient.SqlClient\n yield* sql`CREATE INDEX flows_journal_events_startup_idx ON flows_journal_events (emitted_at_ms DESC, run_id DESC, seq DESC)`\n})\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,aAAwB;AACxB,gBAA2B;AAQpB,MAAM,eAAe,OAAO,IAAI,aAAY;AACjD,QAAM,MAAM,OAAO,UAAU;AAC7B,SAAO;AACT,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Producer identities retained when compaction deletes event payloads.
3
+ *
4
+ * @since 1.0.0-rc.0
5
+ */
6
+ import * as Effect from "effect/Effect";
7
+ import * as SqlClient from "effect/unstable/sql/SqlClient";
8
+ /**
9
+ * Creates the durable compacted-identity index.
10
+ *
11
+ * @category migrations
12
+ * @since 1.0.0-rc.0
13
+ */
14
+ export declare const dedup: Effect.Effect<void, unknown, SqlClient.SqlClient>;
15
+ //# sourceMappingURL=0004_dedup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"0004_dedup.d.ts","sourceRoot":"","sources":["../../../src/migrations/0004_dedup.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,+BAA+B,CAAA;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,SAAS,CA0BlE,CAAA"}
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var dedup_exports = {};
30
+ __export(dedup_exports, {
31
+ dedup: () => dedup
32
+ });
33
+ module.exports = __toCommonJS(dedup_exports);
34
+ var Dialect = __toESM(require("@smthrs/database/Dialect"), 1);
35
+ var Effect = __toESM(require("effect/Effect"), 1);
36
+ var SqlClient = __toESM(require("effect/unstable/sql/SqlClient"), 1);
37
+ const dedup = Effect.gen(function* () {
38
+ const sql = yield* SqlClient.SqlClient;
39
+ yield* sql`CREATE TABLE flows_journal_dedup (
40
+ run_id TEXT NOT NULL CHECK (length(run_id) > 0),
41
+ source_id TEXT NOT NULL CHECK (length(source_id) > 0),
42
+ source_seq ${Dialect.integer(sql)} NOT NULL CHECK (${Dialect.isInteger(sql, sql`source_seq`)} AND source_seq >= 0 AND source_seq <= 9007199254740991),
43
+ event_id TEXT NOT NULL UNIQUE CHECK (length(event_id) > 0),
44
+ seq ${Dialect.integer(sql)} NOT NULL CHECK (${Dialect.isInteger(sql, sql`seq`)} AND seq >= 0 AND seq <= 9007199254740991),
45
+ content_hash TEXT NOT NULL CHECK (length(content_hash) = 64),
46
+ PRIMARY KEY (run_id, source_id, source_seq)
47
+ )`;
48
+ yield* Dialect.trigger(sql, {
49
+ name: "flows_journal_dedup_insert_guard",
50
+ table: "flows_journal_events",
51
+ event: "BEFORE INSERT",
52
+ when: `EXISTS (SELECT 1 FROM flows_journal_dedup WHERE event_id = NEW.event_id
53
+ OR (run_id = NEW.run_id AND source_id = NEW.source_id AND source_seq = NEW.source_seq))`,
54
+ ignore: true
55
+ });
56
+ });
57
+ //# sourceMappingURL=0004_dedup.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/migrations/0004_dedup.ts"],
4
+ "sourcesContent": ["/**\n * Producer identities retained when compaction deletes event payloads.\n *\n * @since 1.0.0-rc.0\n */\n\nimport * as Dialect from \"@smthrs/database/Dialect\"\nimport * as Effect from \"effect/Effect\"\nimport * as SqlClient from \"effect/unstable/sql/SqlClient\"\n\n/**\n * Creates the durable compacted-identity index.\n *\n * @category migrations\n * @since 1.0.0-rc.0\n */\nexport const dedup: Effect.Effect<void, unknown, SqlClient.SqlClient> = Effect.gen(function*() {\n const sql = yield* SqlClient.SqlClient\n yield* sql`CREATE TABLE flows_journal_dedup (\n run_id TEXT NOT NULL CHECK (length(run_id) > 0),\n source_id TEXT NOT NULL CHECK (length(source_id) > 0),\n source_seq ${Dialect.integer(sql)} NOT NULL CHECK (${\n Dialect.isInteger(sql, sql`source_seq`)\n } AND source_seq >= 0 AND source_seq <= 9007199254740991),\n event_id TEXT NOT NULL UNIQUE CHECK (length(event_id) > 0),\n seq ${Dialect.integer(sql)} NOT NULL CHECK (${\n Dialect.isInteger(sql, sql`seq`)\n } AND seq >= 0 AND seq <= 9007199254740991),\n content_hash TEXT NOT NULL CHECK (length(content_hash) = 64),\n PRIMARY KEY (run_id, source_id, source_seq)\n )`\n // Enforce the same identity constraints after their event rows are removed.\n // RAISE(IGNORE) leaves INSERT ... RETURNING empty, so the existing duplicate\n // path checks the owner fence and then resolves the original receipt.\n yield* Dialect.trigger(sql, {\n name: \"flows_journal_dedup_insert_guard\",\n table: \"flows_journal_events\",\n event: \"BEFORE INSERT\",\n when: `EXISTS (SELECT 1 FROM flows_journal_dedup WHERE event_id = NEW.event_id\n OR (run_id = NEW.run_id AND source_id = NEW.source_id AND source_seq = NEW.source_seq))`,\n ignore: true\n })\n})\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,cAAyB;AACzB,aAAwB;AACxB,gBAA2B;AAQpB,MAAM,QAA2D,OAAO,IAAI,aAAY;AAC7F,QAAM,MAAM,OAAO,UAAU;AAC7B,SAAO;AAAA;AAAA;AAAA,iBAGQ,QAAQ,QAAQ,GAAG,CAAC,oBACjC,QAAQ,UAAU,KAAK,eAAe,CACxC;AAAA;AAAA,UAEQ,QAAQ,QAAQ,GAAG,CAAC,oBAC1B,QAAQ,UAAU,KAAK,QAAQ,CACjC;AAAA;AAAA;AAAA;AAOA,SAAO,QAAQ,QAAQ,KAAK;AAAA,IAC1B,MAAM;AAAA,IACN,OAAO;AAAA,IACP,OAAO;AAAA,IACP,MAAM;AAAA;AAAA,IAEN,QAAQ;AAAA,EACV,CAAC;AACH,CAAC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Indexed exact event-type reads within a run.
3
+ *
4
+ * @since 1.0.0
5
+ */
6
+ import * as Effect from "effect/Effect";
7
+ import * as SqlClient from "effect/unstable/sql/SqlClient";
8
+ /**
9
+ * Keeps filtered cursor reads proportional to the matching entries.
10
+ *
11
+ * @category migrations
12
+ * @since 1.0.0
13
+ */
14
+ export declare const runEventType: Effect.Effect<void, unknown, SqlClient.SqlClient>;
15
+ //# sourceMappingURL=0005_run_event_type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"0005_run_event_type.d.ts","sourceRoot":"","sources":["../../../src/migrations/0005_run_event_type.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,+BAA+B,CAAA;AAE1D;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,SAAS,CAAC,SAAS,CAGzE,CAAA"}