@sixb/core 0.1.9 → 0.1.11

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 (328) hide show
  1. package/dist/actions/index.js +9 -9
  2. package/dist/agents/index.js +17 -16
  3. package/dist/agents/index.js.map +1 -1
  4. package/dist/blob-storage/types.d.ts +4 -1
  5. package/dist/blob-storage/types.d.ts.map +1 -1
  6. package/dist/bootstrap/index.js +21 -20
  7. package/dist/bootstrap/index.js.map +1 -1
  8. package/dist/broker/in-memory.d.ts +8 -2
  9. package/dist/broker/in-memory.d.ts.map +1 -1
  10. package/dist/broker/index.d.ts +4 -2
  11. package/dist/broker/index.d.ts.map +1 -1
  12. package/dist/broker/index.js +7 -3
  13. package/dist/broker/index.js.map +1 -1
  14. package/dist/broker/retention.d.ts +4 -0
  15. package/dist/broker/retention.d.ts.map +1 -0
  16. package/dist/broker/subscriber.d.ts +10 -0
  17. package/dist/broker/subscriber.d.ts.map +1 -0
  18. package/dist/broker/types.d.ts +14 -1
  19. package/dist/broker/types.d.ts.map +1 -1
  20. package/dist/{chunk-ypbtykv6.js → chunk-01kj2pbh.js} +1 -1
  21. package/dist/{chunk-k3cqkkn2.js → chunk-1824gssz.js} +30 -65
  22. package/dist/chunk-1824gssz.js.map +12 -0
  23. package/dist/{chunk-xyr8kppc.js → chunk-1yefycb1.js} +1 -1
  24. package/dist/chunk-2c4j899j.js.map +1 -1
  25. package/dist/{chunk-ppytyr6w.js → chunk-358caqf5.js} +4 -4
  26. package/dist/chunk-358caqf5.js.map +12 -0
  27. package/dist/{chunk-m3z3x9v0.js → chunk-3ckk0xfj.js} +2 -2
  28. package/dist/{chunk-kxwa347f.js → chunk-3qms4nax.js} +2 -2
  29. package/dist/{chunk-kxwa347f.js.map → chunk-3qms4nax.js.map} +3 -3
  30. package/dist/{chunk-52hbv0ak.js → chunk-4zhmdsx6.js} +141 -55
  31. package/dist/chunk-4zhmdsx6.js.map +36 -0
  32. package/dist/{chunk-zcnq6105.js → chunk-85cd7e8c.js} +2 -1
  33. package/dist/chunk-85cd7e8c.js.map +10 -0
  34. package/dist/{chunk-3f7veca0.js → chunk-9x8dybsb.js} +3 -3
  35. package/dist/chunk-9x8dybsb.js.map +10 -0
  36. package/dist/{chunk-0w35wavj.js → chunk-a0e6x5hd.js} +1 -1
  37. package/dist/{chunk-r29fxdhn.js → chunk-aa6z4a19.js} +160 -44
  38. package/dist/chunk-aa6z4a19.js.map +12 -0
  39. package/dist/{chunk-emyyk7dx.js → chunk-cfvakeax.js} +22 -145
  40. package/dist/chunk-cfvakeax.js.map +12 -0
  41. package/dist/chunk-d62kjtbg.js.map +1 -1
  42. package/dist/{chunk-h1gfhhbh.js → chunk-d63nnr5b.js} +2 -2
  43. package/dist/{chunk-r4tfx1sf.js → chunk-fh8kgex1.js} +5 -5
  44. package/dist/{chunk-an5tt9y0.js → chunk-ftv470j8.js} +42 -4
  45. package/dist/{chunk-an5tt9y0.js.map → chunk-ftv470j8.js.map} +7 -7
  46. package/dist/{chunk-jjy0fhrn.js → chunk-g91qxjj0.js} +20 -3
  47. package/dist/chunk-g91qxjj0.js.map +12 -0
  48. package/dist/{chunk-hpr1r6av.js → chunk-gq8vhakp.js} +51 -40
  49. package/dist/{chunk-hpr1r6av.js.map → chunk-gq8vhakp.js.map} +6 -6
  50. package/dist/{chunk-x57ycxq0.js → chunk-gqh45d2n.js} +42 -3
  51. package/dist/{chunk-x57ycxq0.js.map → chunk-gqh45d2n.js.map} +3 -3
  52. package/dist/{chunk-mjbk2djy.js → chunk-gqm76kse.js} +231 -125
  53. package/dist/{chunk-mjbk2djy.js.map → chunk-gqm76kse.js.map} +9 -8
  54. package/dist/{chunk-e0d1rzef.js → chunk-jsy70480.js} +16 -3
  55. package/dist/chunk-jsy70480.js.map +15 -0
  56. package/dist/{chunk-0rdrecsb.js → chunk-kfee1h52.js} +116 -32
  57. package/dist/chunk-kfee1h52.js.map +13 -0
  58. package/dist/{chunk-3frsnm7x.js → chunk-qma80ych.js} +4 -6
  59. package/dist/chunk-qma80ych.js.map +11 -0
  60. package/dist/{chunk-vf691g1r.js → chunk-sepyxgpc.js} +3 -3
  61. package/dist/chunk-v2vcg0w6.js +151 -0
  62. package/dist/chunk-v2vcg0w6.js.map +11 -0
  63. package/dist/{chunk-3tgwrcyh.js → chunk-wf88w4kp.js} +17 -23
  64. package/dist/chunk-wf88w4kp.js.map +14 -0
  65. package/dist/{chunk-xfbydgzy.js → chunk-x9m9x2eq.js} +7 -8
  66. package/dist/{chunk-xfbydgzy.js.map → chunk-x9m9x2eq.js.map} +3 -3
  67. package/dist/{chunk-qhcpj9wc.js → chunk-z0271qkp.js} +98 -2
  68. package/dist/chunk-z0271qkp.js.map +15 -0
  69. package/dist/{chunk-1enhpacz.js → chunk-z0s4axeh.js} +6 -6
  70. package/dist/connectors/connections/authorizations.d.ts.map +1 -1
  71. package/dist/connectors/connections/command-context.d.ts +2 -0
  72. package/dist/connectors/connections/command-context.d.ts.map +1 -1
  73. package/dist/connectors/connections/contracts.d.ts +4 -1
  74. package/dist/connectors/connections/contracts.d.ts.map +1 -1
  75. package/dist/connectors/connections/execution.d.ts +1 -0
  76. package/dist/connectors/connections/execution.d.ts.map +1 -1
  77. package/dist/connectors/connections/internal.js +1 -1
  78. package/dist/connectors/connections/request.d.ts +3 -1
  79. package/dist/connectors/connections/request.d.ts.map +1 -1
  80. package/dist/connectors/connections/runs.d.ts +1 -0
  81. package/dist/connectors/connections/runs.d.ts.map +1 -1
  82. package/dist/connectors/connections/service.d.ts +2 -0
  83. package/dist/connectors/connections/service.d.ts.map +1 -1
  84. package/dist/connectors/connections/tokens.d.ts.map +1 -1
  85. package/dist/connectors/connections/validation.d.ts +5 -1
  86. package/dist/connectors/connections/validation.d.ts.map +1 -1
  87. package/dist/connectors/types.d.ts +19 -4
  88. package/dist/connectors/types.d.ts.map +1 -1
  89. package/dist/events/execution.d.ts +1 -1
  90. package/dist/events/execution.d.ts.map +1 -1
  91. package/dist/events/index.js +1 -1
  92. package/dist/events/outbox-dispatcher.d.ts +2 -2
  93. package/dist/events/outbox-dispatcher.d.ts.map +1 -1
  94. package/dist/events/service.d.ts +2 -2
  95. package/dist/events/service.d.ts.map +1 -1
  96. package/dist/execution/agent.js +17 -16
  97. package/dist/execution/agent.js.map +1 -1
  98. package/dist/execution/primitive.js +17 -16
  99. package/dist/execution/primitive.js.map +2 -2
  100. package/dist/execution/request.js +17 -16
  101. package/dist/execution/request.js.map +2 -2
  102. package/dist/index.d.ts +3 -3
  103. package/dist/index.d.ts.map +1 -1
  104. package/dist/index.js +31 -29
  105. package/dist/index.js.map +1 -1
  106. package/dist/lake-storage/changes.d.ts +5 -0
  107. package/dist/lake-storage/changes.d.ts.map +1 -0
  108. package/dist/lake-storage/in-memory.d.ts +2 -1
  109. package/dist/lake-storage/in-memory.d.ts.map +1 -1
  110. package/dist/lake-storage/index.d.ts +2 -1
  111. package/dist/lake-storage/index.d.ts.map +1 -1
  112. package/dist/lake-storage/index.js +4 -2
  113. package/dist/lake-storage/index.js.map +1 -1
  114. package/dist/lake-storage/types.d.ts +38 -0
  115. package/dist/lake-storage/types.d.ts.map +1 -1
  116. package/dist/logging/internal.js +1 -1
  117. package/dist/maintenance/ontology-maintenance.d.ts.map +1 -1
  118. package/dist/maintenance/types.d.ts +1 -1
  119. package/dist/maintenance/types.d.ts.map +1 -1
  120. package/dist/materialization/index.d.ts +1 -1
  121. package/dist/materialization/index.d.ts.map +1 -1
  122. package/dist/materialization/model.d.ts +12 -1
  123. package/dist/materialization/model.d.ts.map +1 -1
  124. package/dist/materializer/index.d.ts +1 -1
  125. package/dist/materializer/index.d.ts.map +1 -1
  126. package/dist/materializer/index.js +6 -6
  127. package/dist/materializer/materializer.d.ts +5 -1
  128. package/dist/materializer/materializer.d.ts.map +1 -1
  129. package/dist/materializer/projections/entry-validator.d.ts +2 -1
  130. package/dist/materializer/projections/entry-validator.d.ts.map +1 -1
  131. package/dist/materializer/projections/replace.d.ts.map +1 -1
  132. package/dist/materializer/projections/source-materialization.d.ts +4 -3
  133. package/dist/materializer/projections/source-materialization.d.ts.map +1 -1
  134. package/dist/materializer/shared/normalize.d.ts +2 -1
  135. package/dist/materializer/shared/normalize.d.ts.map +1 -1
  136. package/dist/models/definitions.d.ts +7 -0
  137. package/dist/models/definitions.d.ts.map +1 -1
  138. package/dist/models/execution/index.js +6 -6
  139. package/dist/models/index.js +1 -1
  140. package/dist/objects/index.js +10 -10
  141. package/dist/objects/query/index.js +6 -6
  142. package/dist/pipelines/index.js +7 -7
  143. package/dist/pipelines/run-dispatch.d.ts.map +1 -1
  144. package/dist/projections/internal.js +7 -9
  145. package/dist/projections/internal.js.map +1 -1
  146. package/dist/projections/run-dispatch.d.ts.map +1 -1
  147. package/dist/queues/in-memory.d.ts +7 -3
  148. package/dist/queues/in-memory.d.ts.map +1 -1
  149. package/dist/queues/index.js +1 -1
  150. package/dist/queues/indexed-heap.d.ts +15 -0
  151. package/dist/queues/indexed-heap.d.ts.map +1 -0
  152. package/dist/runtime/host.d.ts.map +1 -1
  153. package/dist/runtime/internal.js +1 -1
  154. package/dist/runtime/ontology-mutations.d.ts +3 -1
  155. package/dist/runtime/ontology-mutations.d.ts.map +1 -1
  156. package/dist/shares/internal.js +5 -5
  157. package/dist/storage/agents/provider.js +1 -1
  158. package/dist/storage/connector-connections/in-memory.d.ts +1 -0
  159. package/dist/storage/connector-connections/in-memory.d.ts.map +1 -1
  160. package/dist/storage/connector-connections/provider/connections.d.ts.map +1 -1
  161. package/dist/storage/connector-connections/provider/runs.d.ts +1 -0
  162. package/dist/storage/connector-connections/provider/runs.d.ts.map +1 -1
  163. package/dist/storage/connector-connections/provider/shared.d.ts +1 -0
  164. package/dist/storage/connector-connections/provider/shared.d.ts.map +1 -1
  165. package/dist/storage/connector-connections/provider.d.ts +1 -0
  166. package/dist/storage/connector-connections/provider.d.ts.map +1 -1
  167. package/dist/storage/connector-connections/provider.js +11 -17
  168. package/dist/storage/connector-connections/provider.js.map +6 -6
  169. package/dist/storage/connector-connections/types.d.ts +6 -3
  170. package/dist/storage/connector-connections/types.d.ts.map +1 -1
  171. package/dist/storage/index.d.ts +1 -1
  172. package/dist/storage/index.d.ts.map +1 -1
  173. package/dist/storage/index.js +5 -5
  174. package/dist/storage/internal.js +1 -1
  175. package/dist/storage/ontology/in-memory/materializations-state.d.ts.map +1 -1
  176. package/dist/storage/ontology/in-memory/materializations.d.ts +1 -1
  177. package/dist/storage/ontology/in-memory/materializations.d.ts.map +1 -1
  178. package/dist/storage/ontology/in-memory/shared-state.d.ts +15 -2
  179. package/dist/storage/ontology/in-memory/shared-state.d.ts.map +1 -1
  180. package/dist/storage/ontology/in-memory/source-roots.d.ts +6 -0
  181. package/dist/storage/ontology/in-memory/source-roots.d.ts.map +1 -0
  182. package/dist/storage/ontology/in-memory/sources.d.ts.map +1 -1
  183. package/dist/storage/ontology/index.d.ts +1 -1
  184. package/dist/storage/ontology/index.d.ts.map +1 -1
  185. package/dist/storage/ontology/outbox.d.ts +1 -0
  186. package/dist/storage/ontology/outbox.d.ts.map +1 -1
  187. package/dist/storage/ontology/provider.d.ts +16 -0
  188. package/dist/storage/ontology/provider.d.ts.map +1 -1
  189. package/dist/storage/ontology/provider.js +4 -2
  190. package/dist/storage/ontology/provider.js.map +1 -1
  191. package/dist/storage/ontology/sources.d.ts +13 -4
  192. package/dist/storage/ontology/sources.d.ts.map +1 -1
  193. package/dist/storage/projection-runs/lifecycle.d.ts.map +1 -1
  194. package/dist/storage/projection-runs/provider.js +2 -2
  195. package/dist/storage/projection-runs/types.d.ts +2 -0
  196. package/dist/storage/projection-runs/types.d.ts.map +1 -1
  197. package/dist/syncs/index.js +9 -8
  198. package/dist/syncs/index.js.map +1 -1
  199. package/dist/syncs/run-dispatch.d.ts.map +1 -1
  200. package/dist/testing/broker-contract.d.ts.map +1 -1
  201. package/dist/testing/connector-connection-storage-contract.d.ts.map +1 -1
  202. package/dist/testing/index.d.ts +1 -0
  203. package/dist/testing/index.d.ts.map +1 -1
  204. package/dist/testing/index.js +1499 -963
  205. package/dist/testing/index.js.map +10 -9
  206. package/dist/testing/lake-changes-contract.d.ts +6 -0
  207. package/dist/testing/lake-changes-contract.d.ts.map +1 -0
  208. package/dist/testing/lake-storage-contract.d.ts.map +1 -1
  209. package/dist/testing/materializer-storage-contract.d.ts.map +1 -1
  210. package/dist/testing/ontology-storage-contract.d.ts.map +1 -1
  211. package/dist/testing/projection-run-storage-contract.d.ts.map +1 -1
  212. package/dist/webhooks/connections.d.ts +6 -0
  213. package/dist/webhooks/connections.d.ts.map +1 -0
  214. package/dist/webhooks/index.d.ts +1 -1
  215. package/dist/webhooks/index.d.ts.map +1 -1
  216. package/dist/webhooks/internal.d.ts +2 -0
  217. package/dist/webhooks/internal.d.ts.map +1 -1
  218. package/dist/webhooks/internal.js +55 -10
  219. package/dist/webhooks/internal.js.map +4 -3
  220. package/dist/webhooks/registry.d.ts +1 -1
  221. package/dist/webhooks/registry.d.ts.map +1 -1
  222. package/dist/webhooks/types.d.ts +15 -4
  223. package/dist/webhooks/types.d.ts.map +1 -1
  224. package/dist/workflows/index.js +18 -17
  225. package/dist/workflows/index.js.map +1 -1
  226. package/dist/workflows/run-dispatch.d.ts +3 -1
  227. package/dist/workflows/run-dispatch.d.ts.map +1 -1
  228. package/package.json +1 -1
  229. package/src/agents/model-loop.ts +7 -0
  230. package/src/blob-storage/types.ts +4 -1
  231. package/src/broker/in-memory.ts +104 -39
  232. package/src/broker/index.ts +4 -1
  233. package/src/broker/retention.ts +28 -0
  234. package/src/broker/subscriber.ts +21 -0
  235. package/src/broker/types.ts +15 -1
  236. package/src/connectors/builders.ts +0 -6
  237. package/src/connectors/connections/authorizations.ts +11 -5
  238. package/src/connectors/connections/command-context.ts +21 -4
  239. package/src/connectors/connections/contracts.ts +7 -1
  240. package/src/connectors/connections/execution.ts +3 -0
  241. package/src/connectors/connections/request.ts +56 -22
  242. package/src/connectors/connections/runs.ts +39 -1
  243. package/src/connectors/connections/service.ts +6 -0
  244. package/src/connectors/connections/tokens.ts +4 -0
  245. package/src/connectors/connections/validation.ts +91 -5
  246. package/src/connectors/types.ts +19 -4
  247. package/src/events/execution.ts +2 -2
  248. package/src/events/outbox-dispatcher.ts +20 -26
  249. package/src/events/service.ts +3 -3
  250. package/src/index.ts +10 -2
  251. package/src/lake-storage/changes.ts +43 -0
  252. package/src/lake-storage/in-memory.ts +75 -0
  253. package/src/lake-storage/index.ts +4 -0
  254. package/src/lake-storage/types.ts +42 -0
  255. package/src/logging/service.ts +1 -1
  256. package/src/maintenance/ontology-maintenance.ts +6 -2
  257. package/src/maintenance/types.ts +1 -1
  258. package/src/materialization/index.ts +2 -0
  259. package/src/materialization/model.ts +14 -1
  260. package/src/materializer/README.md +1 -1
  261. package/src/materializer/index.ts +2 -0
  262. package/src/materializer/materializer.ts +10 -0
  263. package/src/materializer/projections/entry-validator.ts +19 -1
  264. package/src/materializer/projections/replace.ts +36 -1
  265. package/src/materializer/projections/source-materialization.ts +26 -6
  266. package/src/materializer/shared/normalize.ts +1 -1
  267. package/src/models/definitions.ts +19 -0
  268. package/src/models/pricing.ts +6 -2
  269. package/src/pipelines/run-dispatch.ts +21 -1
  270. package/src/projections/run-dispatch.ts +30 -68
  271. package/src/queues/in-memory.ts +105 -62
  272. package/src/queues/indexed-heap.ts +74 -0
  273. package/src/runtime/host.ts +0 -14
  274. package/src/runtime/ontology-mutations.ts +4 -0
  275. package/src/storage/connector-connections/in-memory.ts +19 -19
  276. package/src/storage/connector-connections/provider/connections.ts +1 -15
  277. package/src/storage/connector-connections/provider/runs.ts +9 -1
  278. package/src/storage/connector-connections/provider/shared.ts +2 -3
  279. package/src/storage/connector-connections/provider.ts +6 -0
  280. package/src/storage/connector-connections/types.ts +8 -3
  281. package/src/storage/index.ts +1 -0
  282. package/src/storage/ontology/in-memory/materializations-state.ts +5 -18
  283. package/src/storage/ontology/in-memory/materializations.ts +73 -92
  284. package/src/storage/ontology/in-memory/shared-state.ts +36 -4
  285. package/src/storage/ontology/in-memory/source-roots.ts +123 -0
  286. package/src/storage/ontology/in-memory/sources.ts +78 -23
  287. package/src/storage/ontology/index.ts +1 -0
  288. package/src/storage/ontology/outbox.ts +1 -0
  289. package/src/storage/ontology/provider.ts +70 -0
  290. package/src/storage/ontology/sources.ts +14 -3
  291. package/src/storage/projection-runs/lifecycle.ts +5 -2
  292. package/src/storage/projection-runs/types.ts +4 -3
  293. package/src/syncs/run-dispatch.ts +19 -1
  294. package/src/testing/broker-contract.ts +95 -0
  295. package/src/testing/connector-connection-storage-contract.ts +29 -12
  296. package/src/testing/index.ts +1 -0
  297. package/src/testing/lake-changes-contract.ts +240 -0
  298. package/src/testing/lake-storage-contract.ts +29 -0
  299. package/src/testing/materializer-storage-contract.ts +172 -1
  300. package/src/testing/ontology-storage-contract.ts +15 -3
  301. package/src/testing/projection-run-storage-contract.ts +34 -0
  302. package/src/webhooks/connections.ts +56 -0
  303. package/src/webhooks/index.ts +2 -0
  304. package/src/webhooks/internal.ts +2 -0
  305. package/src/webhooks/registry.ts +3 -4
  306. package/src/webhooks/types.ts +17 -4
  307. package/src/workflows/run-dispatch.ts +42 -29
  308. package/dist/chunk-0rdrecsb.js.map +0 -11
  309. package/dist/chunk-3f7veca0.js.map +0 -10
  310. package/dist/chunk-3frsnm7x.js.map +0 -11
  311. package/dist/chunk-3tgwrcyh.js.map +0 -14
  312. package/dist/chunk-52hbv0ak.js.map +0 -36
  313. package/dist/chunk-e0d1rzef.js.map +0 -15
  314. package/dist/chunk-emyyk7dx.js.map +0 -14
  315. package/dist/chunk-jjy0fhrn.js.map +0 -12
  316. package/dist/chunk-k3cqkkn2.js.map +0 -12
  317. package/dist/chunk-ppytyr6w.js.map +0 -12
  318. package/dist/chunk-qhcpj9wc.js.map +0 -14
  319. package/dist/chunk-r29fxdhn.js.map +0 -11
  320. package/dist/chunk-zcnq6105.js.map +0 -10
  321. /package/dist/{chunk-ypbtykv6.js.map → chunk-01kj2pbh.js.map} +0 -0
  322. /package/dist/{chunk-xyr8kppc.js.map → chunk-1yefycb1.js.map} +0 -0
  323. /package/dist/{chunk-m3z3x9v0.js.map → chunk-3ckk0xfj.js.map} +0 -0
  324. /package/dist/{chunk-0w35wavj.js.map → chunk-a0e6x5hd.js.map} +0 -0
  325. /package/dist/{chunk-h1gfhhbh.js.map → chunk-d63nnr5b.js.map} +0 -0
  326. /package/dist/{chunk-r4tfx1sf.js.map → chunk-fh8kgex1.js.map} +0 -0
  327. /package/dist/{chunk-vf691g1r.js.map → chunk-sepyxgpc.js.map} +0 -0
  328. /package/dist/{chunk-1enhpacz.js.map → chunk-z0s4axeh.js.map} +0 -0
@@ -1,7 +1,6 @@
1
1
  // @bun
2
2
  import {
3
3
  createSixbError2,
4
- isSixbError2,
5
4
  toSixbFailure2
6
5
  } from "./chunk-f4w3yp4f.js";
7
6
  import {
@@ -9,82 +8,19 @@ import {
9
8
  } from "./chunk-7apz6hg4.js";
10
9
  import {
11
10
  resolveExecutionScopeAuthorization,
12
- AuthorizationError2,
13
- assertAuthorized2,
14
- assertProviderAccess2
11
+ assertAuthorized2
15
12
  } from "./chunk-dz5h08xv.js";
16
13
  import {
17
14
  SYNC_RUN_FAILURE_CODES2
18
- } from "./chunk-mjbk2djy.js";
15
+ } from "./chunk-gqm76kse.js";
19
16
  import {
20
17
  SyncRunError2
21
18
  } from "./chunk-jmfet9r4.js";
22
- import {
23
- isOAuthConnectorDefinition2
24
- } from "./chunk-3f7veca0.js";
25
19
  import {
26
20
  executionRecordInputFromRuntime,
27
21
  ensureExecutionRecord2,
28
22
  createPrimitiveExecutionRecord
29
23
  } from "./chunk-17kfctj6.js";
30
- import {
31
- ConnectorConnectionStorageError2
32
- } from "./chunk-2c4j899j.js";
33
-
34
- // src/connectors/errors.ts
35
- class ConnectorError2 extends Error {
36
- name = "ConnectorError";
37
- }
38
-
39
- class ConnectorNotFoundError2 extends ConnectorError2 {
40
- connectorId;
41
- name = "ConnectorNotFoundError";
42
- constructor(connectorId) {
43
- super(`Unknown connector '${connectorId}'`);
44
- this.connectorId = connectorId;
45
- }
46
- }
47
-
48
- class ConnectorOAuthError2 extends ConnectorError2 {
49
- kind;
50
- name = "ConnectorOAuthError";
51
- constructor(kind, message, options) {
52
- super(message, options);
53
- this.kind = kind;
54
- }
55
- }
56
- function createConnectorCodedError(code, message, options = {}) {
57
- return createSixbError2(code, message.startsWith("[Sixb]") ? message : `[Sixb] ${message}`, options);
58
- }
59
- function createAmbiguousProviderOperationError(options = {}) {
60
- return createConnectorCodedError("connector.provider_failed", "Connector provider operation outcome is ambiguous.", options);
61
- }
62
- function oauthErrorKind(error) {
63
- return error instanceof ConnectorOAuthError2 ? error.kind : "ambiguous";
64
- }
65
- function providerFailureCode(error) {
66
- return oauthErrorKind(error) === "retryable" ? "connector.provider_unavailable" : "connector.provider_failed";
67
- }
68
- function providerBoundaryError(error, code, message) {
69
- if (isSixbError2(error) && error.code.startsWith("connector."))
70
- return error;
71
- return createConnectorCodedError(code, message, { cause: error });
72
- }
73
- function isConnectorStorageError(error, code) {
74
- return error instanceof ConnectorConnectionStorageError2 && (code === undefined || error.code === code);
75
- }
76
- function storageBoundaryError(error, message) {
77
- return createConnectorCodedError("internal.unexpected", message, { cause: error });
78
- }
79
- async function recoverConnectorFailure(primaryError, message, recovery) {
80
- try {
81
- return await recovery();
82
- } catch (recoveryError) {
83
- throw createConnectorCodedError("internal.unexpected", message, {
84
- cause: new AggregateError([primaryError, recoveryError], message)
85
- });
86
- }
87
- }
88
24
 
89
25
  // src/syncs/errors.ts
90
26
  class SyncValidationError2 extends Error {
@@ -129,7 +65,10 @@ class SyncRunDispatcher2 {
129
65
  }
130
66
  async function dispatchSyncRun(input) {
131
67
  const runId = createSyncRunId(input.runId);
132
- const persisted = await persistSyncRun(input, runId);
68
+ let persisted = await persistSyncRun(input, runId);
69
+ if (!persisted.publish && input.validateExistingRun && persisted.run.status === "queued") {
70
+ persisted = await reuseSyncRun(input, persisted.run);
71
+ }
133
72
  if (!persisted.publish)
134
73
  return existingSyncRunResult(persisted.run);
135
74
  return publishSyncRun(input, persisted);
@@ -178,6 +117,15 @@ async function persistSyncRun(input, runId) {
178
117
  async function reuseSyncRun(input, existing) {
179
118
  assertExistingRunMatchesRequest(existing, input);
180
119
  await input.validateExistingRun?.(existing, input.storage);
120
+ if (input.validateExistingRun && existing.status === "queued") {
121
+ const execution = await input.storage.executions.getById({
122
+ projectId: input.projectId,
123
+ id: existing.executionId
124
+ });
125
+ if (!execution)
126
+ throw new SyncRunError2(`[Sixb] Execution '${existing.executionId}' was not found.`);
127
+ return { publish: true, run: existing, execution, queuedAt: existing.queuedAt, created: false };
128
+ }
181
129
  if (existing.status !== "failed" || existing.error?.code !== "queue.enqueue_failed" || !existing.error.retryable) {
182
130
  return { publish: false, run: existing };
183
131
  }
@@ -215,6 +163,9 @@ async function publishSyncRun(input, persisted) {
215
163
  }
216
164
  ]
217
165
  });
166
+ if (!job || job.id !== persisted.run.id) {
167
+ throw new SyncRunError2(`[Sixb] Queue did not acknowledge Sync run '${persisted.run.id}'.`);
168
+ }
218
169
  return {
219
170
  syncId: persisted.run.syncId,
220
171
  runId: persisted.run.id,
@@ -223,6 +174,8 @@ async function publishSyncRun(input, persisted) {
223
174
  created: persisted.created
224
175
  };
225
176
  } catch (error) {
177
+ if (input.validateExistingRun)
178
+ throw error;
226
179
  const failedAt = new Date;
227
180
  const failure = toEnqueueFailure(error, persisted.run, failedAt);
228
181
  const failed = await requireSyncRunStorage(input.storage).finish({
@@ -325,82 +278,6 @@ async function requestSyncRun2(runtime, execution, sync, options = {}) {
325
278
  });
326
279
  }
327
280
 
328
- // src/connectors/execution.ts
329
- var sourceResolvers = new WeakMap;
330
- function createConnectorRuntime(runtime, execution, service) {
331
- const connector = (definition, selector) => {
332
- if (isOAuthConnectorDefinition2(definition)) {
333
- assertConnectorConnectionAccess(runtime, execution);
334
- if (!selector) {
335
- throw createConnectorCodedError("connector.configuration_invalid", `[Sixb] Connector '${definition.id}' uses persistent connections and requires an explicit owner and slot.`);
336
- }
337
- return service.connectConnection(definition, selector);
338
- }
339
- if (selector) {
340
- throw createConnectorCodedError("connector.configuration_invalid", `[Sixb] Static connector '${definition.id}' does not accept a connection.`);
341
- }
342
- assertProviderAccess2(runtime, execution, "connector.connect");
343
- return service.connect(definition);
344
- };
345
- registerConnectorExecutionSourceResolver(connector, {
346
- async list(definition) {
347
- if (!isOAuthConnectorDefinition2(definition)) {
348
- return [
349
- {
350
- connect: (_signal) => connector(definition)
351
- }
352
- ];
353
- }
354
- assertConnectorConnectionAccess(runtime, execution);
355
- const connections = await service.listExecutionConnections(definition);
356
- return connections.map((connection) => ({
357
- connection: {
358
- id: connection.id,
359
- connectorId: connection.connectorId,
360
- owner: connection.owner,
361
- slot: connection.slot,
362
- account: connection.account
363
- },
364
- connect: (signal) => service.connectExecutionConnection(definition, connection, signal)
365
- }));
366
- }
367
- });
368
- return connector;
369
- }
370
- function registerConnectorExecutionSourceResolver(connector, resolver) {
371
- const registered = sourceResolvers.get(connector);
372
- if (registered && registered !== resolver) {
373
- throw new Error("[Sixb] Connector source resolver is already registered for this execution.");
374
- }
375
- sourceResolvers.set(connector, resolver);
376
- }
377
- function getConnectorExecutionSourceResolver(connector) {
378
- const resolver = sourceResolvers.get(connector);
379
- if (resolver)
380
- return resolver;
381
- return {
382
- async list(definition) {
383
- if (isOAuthConnectorDefinition2(definition)) {
384
- throw createConnectorCodedError("connector.configuration_invalid", `[Sixb] OAuth connector '${definition.id}' cannot be resolved without the managed connection runtime.`);
385
- }
386
- return [
387
- {
388
- connect: (_signal) => connector(definition)
389
- }
390
- ];
391
- }
392
- };
393
- }
394
- function assertConnectorConnectionAccess(runtime, execution) {
395
- const resolved = resolveExecutionScopeAuthorization(runtime.projectId, {
396
- execution,
397
- authorization: runtime.runtimeAuthorization
398
- });
399
- if (resolved.type === "unrestricted" && resolved.ref.type === "trustedPrimitive")
400
- return;
401
- throw new AuthorizationError2("privileged:connector-connection.connect", "[Sixb] Connector connection clients are restricted to trusted primitive executions.");
402
- }
403
-
404
- export { ConnectorError2, ConnectorNotFoundError2, ConnectorOAuthError2, createConnectorCodedError, createAmbiguousProviderOperationError, oauthErrorKind, providerFailureCode, providerBoundaryError, isConnectorStorageError, storageBoundaryError, recoverConnectorFailure, createConnectorRuntime, getConnectorExecutionSourceResolver, SyncValidationError2, SyncRunDispatcher2, requestSyncRun2 };
281
+ export { SyncValidationError2, SyncRunDispatcher2, requestSyncRun2 };
405
282
 
406
- //# debugId=98A5F7B5136CE1F764756E2164756E21
283
+ //# debugId=145F9F0BA5C3020C64756E2164756E21
@@ -0,0 +1,12 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/syncs/errors.ts", "../src/syncs/run-dispatch.ts", "../src/syncs/request.ts"],
4
+ "sourcesContent": [
5
+ "export class SyncValidationError extends Error {\n readonly name = \"SyncValidationError\"\n}\n",
6
+ "import { randomUUID } from \"node:crypto\"\nimport { reportRunFailure } from \"../error-reporting/capability\"\nimport { createSixbError, toSixbFailure } from \"../errors/internal\"\nimport type { SixbFailure } from \"../errors/types\"\nimport type { RunDispatcher } from \"../execution/dispatch\"\nimport { createPrimitiveExecutionRecord } from \"../execution/durable\"\nimport type { Queues } from \"../queues\"\nimport type { SixbDefinitions } from \"../runtime/definitions\"\nimport type { CreateExecutionInput, Storage, SyncRunFailureCode, SyncRunRecord } from \"../storage\"\nimport { SYNC_RUN_FAILURE_CODES, SyncRunError } from \"../storage\"\nimport { SyncValidationError } from \"./errors\"\nimport type { SyncRunRequestOptions, SyncRunRequestResult } from \"./request\"\nimport type { SyncDefinition } from \"./types\"\n\nexport type AutomaticSyncExecutionSource =\n | { readonly type: \"schedule\"; readonly eventId: string }\n | { readonly type: \"event\"; readonly eventId: string }\n\nexport interface AutomaticSyncRunDispatchInput extends SyncRunRequestOptions {\n readonly syncId: string\n readonly runId: string\n readonly source: AutomaticSyncExecutionSource\n readonly correlationId: string\n readonly metadata?: Readonly<Record<string, string>>\n}\n\nexport type SyncRunDispatchPort = RunDispatcher<AutomaticSyncRunDispatchInput, SyncRunRequestResult>\n\nexport interface SyncRunDispatcherDependencies {\n readonly id: string\n readonly definitions: Pick<SixbDefinitions, \"syncs\">\n readonly storage: Storage\n readonly queues: Pick<Queues, \"syncRuns\">\n}\n\ninterface DispatchSyncRunInput extends SyncRunRequestOptions {\n readonly errorReporterHost: object\n readonly projectId: string\n readonly sync: SyncDefinition\n readonly storage: Storage\n readonly queue: Queues[\"syncRuns\"]\n readonly metadata?: Readonly<Record<string, string>>\n readonly createExecution: (executionId: string, runId: string) => Promise<CreateExecutionInput>\n readonly validateExistingRun?: (run: SyncRunRecord, storage: Storage) => Promise<void>\n}\n\ntype PersistedSyncRun =\n | { readonly publish: false; readonly run: SyncRunRecord }\n | {\n readonly publish: true\n readonly run: SyncRunRecord\n readonly execution: CreateExecutionInput\n readonly queuedAt: Date\n readonly created: boolean\n }\n\n/** Core-owned durable dispatch boundary used by automatic Sync triggers. */\nexport class SyncRunDispatcher implements SyncRunDispatchPort {\n constructor(private readonly dependencies: SyncRunDispatcherDependencies) {}\n\n async dispatch(input: AutomaticSyncRunDispatchInput): Promise<SyncRunRequestResult> {\n assertAutomaticDispatchInput(input)\n const sync = this.dependencies.definitions.syncs.getById(input.syncId)\n if (!sync) throw new SyncValidationError(`[Sixb] Unknown sync '${input.syncId}'`)\n\n return dispatchSyncRun({\n errorReporterHost: this.dependencies,\n projectId: this.dependencies.id,\n sync,\n storage: this.dependencies.storage,\n queue: this.dependencies.queues.syncRuns,\n runId: input.runId,\n expectedLatestVersionId: input.expectedLatestVersionId,\n commitMessage: input.commitMessage,\n metadata: input.metadata,\n validateExistingRun: (run, storage) =>\n assertAutomaticExecutionIdentity(storage, this.dependencies.id, input, run),\n createExecution: async (executionId, runId) =>\n createPrimitiveExecutionRecord({\n id: executionId,\n primitive: { kind: \"sync\", id: sync.id, runId },\n origin: {\n type: \"automatic\",\n projectId: this.dependencies.id,\n source: input.source,\n correlationId: input.correlationId,\n },\n }),\n })\n }\n}\n\n/** Persist a Sync execution and queued run before publishing its queue job. */\nexport async function dispatchSyncRun(input: DispatchSyncRunInput): Promise<SyncRunRequestResult> {\n const runId = createSyncRunId(input.runId)\n let persisted = await persistSyncRun(input, runId)\n if (!persisted.publish && input.validateExistingRun && persisted.run.status === \"queued\") {\n persisted = await reuseSyncRun(input, persisted.run)\n }\n if (!persisted.publish) return existingSyncRunResult(persisted.run)\n return publishSyncRun(input, persisted)\n}\n\nasync function persistSyncRun(\n input: DispatchSyncRunInput,\n runId: string\n): Promise<PersistedSyncRun> {\n const syncRuns = requireSyncRunStorage(input.storage)\n const existing = await syncRuns.getById({ projectId: input.projectId, id: runId })\n if (existing) return reuseSyncRun(input, existing)\n\n const execution = await input.createExecution(`exec_${randomUUID()}`, runId)\n const queuedAt = new Date()\n try {\n return await input.storage.transaction(\n async (tx): Promise<PersistedSyncRun> => {\n const transactionalRuns = requireSyncRunStorage(tx)\n const raced = await transactionalRuns.getById({ projectId: input.projectId, id: runId })\n if (raced) {\n assertExistingRunMatchesRequest(raced, input)\n await input.validateExistingRun?.(raced, tx)\n return { publish: false, run: raced }\n }\n\n await tx.executions.create(execution)\n const run = await transactionalRuns.queue({\n projectId: input.projectId,\n id: runId,\n executionId: execution.id,\n syncId: input.sync.id,\n datasetId: input.sync.target.dataset.id,\n mode: input.sync.config.mode,\n queuedAt,\n expectedLatestVersionId: input.expectedLatestVersionId,\n commitMessage: input.commitMessage,\n })\n return { publish: true, run, execution, queuedAt, created: true }\n },\n { isolation: \"serializable\" }\n )\n } catch (error) {\n if (!(error instanceof SyncRunError)) throw error\n const raced = await syncRuns.getById({ projectId: input.projectId, id: runId })\n if (!raced) throw error\n assertExistingRunMatchesRequest(raced, input)\n await input.validateExistingRun?.(raced, input.storage)\n return { publish: false, run: raced }\n }\n}\n\nasync function reuseSyncRun(\n input: DispatchSyncRunInput,\n existing: SyncRunRecord\n): Promise<PersistedSyncRun> {\n assertExistingRunMatchesRequest(existing, input)\n await input.validateExistingRun?.(existing, input.storage)\n if (input.validateExistingRun && existing.status === \"queued\") {\n const execution = await input.storage.executions.getById({\n projectId: input.projectId,\n id: existing.executionId,\n })\n if (!execution)\n throw new SyncRunError(`[Sixb] Execution '${existing.executionId}' was not found.`)\n return { publish: true, run: existing, execution, queuedAt: existing.queuedAt, created: false }\n }\n if (\n existing.status !== \"failed\" ||\n existing.error?.code !== \"queue.enqueue_failed\" ||\n !existing.error.retryable\n ) {\n return { publish: false, run: existing }\n }\n\n const execution = await input.storage.executions.getById({\n projectId: input.projectId,\n id: existing.executionId,\n })\n if (!execution) {\n throw new SyncRunError(\n `[Sixb] Execution '${existing.executionId}' for Sync run '${existing.id}' was not found.`\n )\n }\n\n const queuedAt = new Date()\n const run = await requireSyncRunStorage(input.storage).queue({\n projectId: input.projectId,\n id: existing.id,\n executionId: existing.executionId,\n syncId: existing.syncId,\n datasetId: existing.datasetId,\n mode: existing.mode,\n queuedAt,\n expectedLatestVersionId: existing.expectedLatestVersionId,\n commitMessage: existing.commitMessage,\n })\n return { publish: true, run, execution, queuedAt, created: false }\n}\n\nasync function publishSyncRun(\n input: DispatchSyncRunInput,\n persisted: Extract<PersistedSyncRun, { readonly publish: true }>\n): Promise<SyncRunRequestResult> {\n try {\n const [job] = await input.queue.enqueue({\n projectId: input.projectId,\n jobs: [\n {\n id: persisted.run.id,\n type: \"sync.run.requested\",\n payload: { runId: persisted.run.id },\n ...(input.metadata === undefined ? {} : { metadata: input.metadata }),\n },\n ],\n })\n if (!job || job.id !== persisted.run.id) {\n throw new SyncRunError(`[Sixb] Queue did not acknowledge Sync run '${persisted.run.id}'.`)\n }\n return {\n syncId: persisted.run.syncId,\n runId: persisted.run.id,\n queuedAt: persisted.queuedAt.toISOString(),\n ...(job?.id ? { jobId: job.id } : {}),\n created: persisted.created,\n }\n } catch (error) {\n // Automatic consumers retain the batch and retry. Keep uncertain delivery queued:\n // a lost reply does not prove that the queue rejected the job.\n if (input.validateExistingRun) throw error\n const failedAt = new Date()\n const failure = toEnqueueFailure(error, persisted.run, failedAt)\n const failed = await requireSyncRunStorage(input.storage).finish({\n projectId: input.projectId,\n id: persisted.run.id,\n status: \"failed\",\n finishedAt: failedAt,\n error: failure,\n })\n reportRunFailure(input.errorReporterHost, error, {\n projectId: input.projectId,\n runKind: \"sync\",\n run: { runId: failed.id, syncId: failed.syncId },\n failure,\n })\n throw error\n }\n}\n\nfunction assertExistingRunMatchesRequest(\n existing: SyncRunRecord,\n input: Pick<DispatchSyncRunInput, \"sync\" | \"expectedLatestVersionId\" | \"commitMessage\">\n): void {\n if (\n existing.syncId !== input.sync.id ||\n existing.datasetId !== input.sync.target.dataset.id ||\n existing.mode !== input.sync.config.mode ||\n existing.expectedLatestVersionId !== input.expectedLatestVersionId ||\n existing.commitMessage !== input.commitMessage\n ) {\n throw new SyncRunError(\n `[Sixb] Sync run '${existing.id}' already exists with a different request payload.`\n )\n }\n}\n\nfunction existingSyncRunResult(existing: SyncRunRecord): SyncRunRequestResult {\n return {\n syncId: existing.syncId,\n runId: existing.id,\n queuedAt: existing.queuedAt.toISOString(),\n created: false,\n }\n}\n\nfunction requireSyncRunStorage(storage: Storage): NonNullable<Storage[\"syncRuns\"]> {\n if (!storage.syncRuns) throw new SyncValidationError(\"[Sixb] Sync run storage is not configured.\")\n return storage.syncRuns\n}\n\nfunction createSyncRunId(runId: string | undefined): string {\n if (runId === undefined) return `run_${randomUUID()}`\n if (!runId.trim()) throw new SyncValidationError(\"[Sixb] Sync run id must not be empty\")\n return runId\n}\n\nfunction assertAutomaticDispatchInput(input: AutomaticSyncRunDispatchInput): void {\n assertNonBlank(input.syncId, \"Sync id\")\n assertNonBlank(input.runId, \"Sync run id\")\n assertNonBlank(input.source.eventId, \"Sync source event id\")\n assertNonBlank(input.correlationId, \"Sync correlation id\")\n}\n\nasync function assertAutomaticExecutionIdentity(\n storage: Storage,\n projectId: string,\n input: AutomaticSyncRunDispatchInput,\n run: SyncRunRecord\n): Promise<void> {\n const execution = await storage.executions.getById({ projectId, id: run.executionId })\n if (\n !execution ||\n execution.source.type !== input.source.type ||\n execution.source.eventId !== input.source.eventId ||\n execution.correlationId !== input.correlationId ||\n execution.requestedBy !== undefined\n ) {\n throw new SyncValidationError(\n `[Sixb] Sync run '${run.id}' already exists with different automatic provenance.`\n )\n }\n}\n\nfunction toEnqueueFailure(\n error: unknown,\n run: SyncRunRecord,\n at: Date\n): SixbFailure<SyncRunFailureCode> {\n const enqueueError = createSixbError(\n \"queue.enqueue_failed\",\n `[Sixb] Could not enqueue Sync run '${run.id}'.`,\n {\n cause: error,\n details: { syncId: run.syncId, runId: run.id, phase: \"enqueue\" },\n }\n )\n return toSixbFailure(enqueueError, { allowedCodes: SYNC_RUN_FAILURE_CODES, at })\n}\n\nfunction assertNonBlank(value: string, label: string): void {\n if (!value.trim()) throw new SyncValidationError(`[Sixb] ${label} must not be empty.`)\n}\n",
7
+ "import { assertAuthorized } from \"../authorization\"\nimport { resolveExecutionScopeAuthorization } from \"../execution/authorization\"\nimport {\n createPrimitiveExecutionRecord,\n ensureExecutionRecord,\n executionRecordInputFromRuntime,\n} from \"../execution/durable\"\nimport type { ExecutionContext } from \"../execution/types\"\nimport type { SixbRuntimeContext } from \"../runtime/types\"\nimport { SyncValidationError } from \"./errors\"\nimport { dispatchSyncRun } from \"./run-dispatch\"\nimport type { SyncDefinition } from \"./types\"\n\nexport interface SyncRunRequestOptions {\n /** Stable identity used to make dispatch idempotent. */\n readonly runId?: string\n /** Optimistic concurrency guard: fail the run if the dataset moved past this version. */\n readonly expectedLatestVersionId?: string\n readonly commitMessage?: string\n}\n\nexport interface RequestSyncRunInput extends SyncRunRequestOptions {\n readonly syncId: string\n}\n\nexport interface SyncRunRequestResult {\n readonly syncId: string\n readonly runId: string\n /** Durable time at which the run entered the queue. */\n readonly queuedAt: string\n readonly jobId?: string\n readonly created: boolean\n}\n\n/**\n * Authorize and queue a sync run request.\n *\n * Operates on an already-resolved definition and the shared runtime context, so the HTTP route and\n * the runtime verb cannot drift apart.\n *\n * The immutable child execution and queued run are persisted before queue publication.\n */\nexport async function requestSyncRun(\n runtime: SixbRuntimeContext,\n execution: ExecutionContext,\n sync: SyncDefinition,\n options: SyncRunRequestOptions = {}\n): Promise<SyncRunRequestResult> {\n resolveExecutionScopeAuthorization(runtime.projectId, {\n execution,\n authorization: runtime.runtimeAuthorization,\n })\n assertAuthorized(runtime, { kind: \"sync.run\", syncId: sync.id })\n if (!runtime.storage.syncRuns) {\n throw new SyncValidationError(\"[Sixb] Sync run storage is not configured.\")\n }\n\n const queue = runtime.queues.syncRuns\n if (!queue) {\n throw new SyncValidationError(\"[Sixb] Sync run queue is not configured.\")\n }\n\n return dispatchSyncRun({\n errorReporterHost: runtime,\n projectId: runtime.projectId,\n sync,\n storage: runtime.storage,\n queue,\n ...options,\n createExecution: async (executionId, runId) => {\n const caller = await ensureExecutionRecord(\n runtime.storage.executions,\n executionRecordInputFromRuntime({\n execution,\n runtimeAuthorization: runtime.runtimeAuthorization,\n })\n )\n return createPrimitiveExecutionRecord({\n id: executionId,\n primitive: { kind: \"sync\", id: sync.id, runId },\n origin: { type: \"execution\", parent: caller },\n })\n },\n })\n}\n"
8
+ ],
9
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAO,MAAM,6BAA4B,MAAM;AAAA,EACpC,OAAO;AAClB;;;ACFA;AAyDO,MAAM,mBAAiD;AAAA,EAC/B;AAAA,EAA7B,WAAW,CAAkB,cAA6C;AAAA,IAA7C;AAAA;AAAA,OAEvB,SAAQ,CAAC,OAAqE;AAAA,IAClF,6BAA6B,KAAK;AAAA,IAClC,MAAM,OAAO,KAAK,aAAa,YAAY,MAAM,QAAQ,MAAM,MAAM;AAAA,IACrE,IAAI,CAAC;AAAA,MAAM,MAAM,IAAI,qBAAoB,wBAAwB,MAAM,SAAS;AAAA,IAEhF,OAAO,gBAAgB;AAAA,MACrB,mBAAmB,KAAK;AAAA,MACxB,WAAW,KAAK,aAAa;AAAA,MAC7B;AAAA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;AAAA,QACJ,WAAW,EAAE,MAAM,QAAQ,IAAI,KAAK,IAAI,MAAM;AAAA,QAC9C,QAAQ,EAAE,MAAM,aAAa,QAAQ,OAAO;AAAA,MAC9C,CAAC;AAAA;AAAA,EAEL,CAAC;AAAA;",
10
+ "debugId": "145F9F0BA5C3020C64756E2164756E21",
11
+ "names": []
12
+ }
@@ -2,7 +2,7 @@
2
2
  "version": 3,
3
3
  "sources": ["../src/storage/ontology/outbox.ts"],
4
4
  "sourcesContent": [
5
- "import type { SixbErrorCode, SixbFailure } from \"../../errors/types\"\nimport type { OntologyMaterializationEvent } from \"../../materialization/events\"\n\nexport type {\n OntologyMaterializationEvent,\n OntologyMaterializationEventDraft,\n} from \"../../materialization/events\"\n\nexport interface OntologyOutboxWrite {\n /** Providers may index envelope identity fields, but the envelope remains authoritative. */\n readonly envelope: OntologyMaterializationEvent\n readonly availableAt: string\n readonly createdAt: string\n}\n\n/** Error codes a durable ontology outbox delivery can persist. */\nexport const ONTOLOGY_OUTBOX_FAILURE_CODES = [\"event.delivery_failed\"] as const satisfies readonly [\n SixbErrorCode,\n ...SixbErrorCode[],\n]\n\nexport type OntologyOutboxFailureCode = (typeof ONTOLOGY_OUTBOX_FAILURE_CODES)[number]\nexport type OntologyOutboxFailure = SixbFailure<OntologyOutboxFailureCode>\n\nexport interface OntologyOutboxRecord {\n readonly envelope: OntologyMaterializationEvent\n readonly availableAt: string\n readonly attempts: number\n readonly leaseId: string | null\n readonly leaseExpiresAt: string | null\n readonly publishedAt: string | null\n readonly lastFailure: OntologyOutboxFailure | null\n readonly createdAt: string\n}\n\nexport interface ClaimOntologyOutboxInput {\n readonly projectId: string\n readonly now: string\n readonly limit: number\n readonly leaseId: string\n readonly leaseExpiresAt: string\n}\n\nexport interface ClaimedOntologyOutboxRow extends OntologyOutboxRecord {\n readonly leaseId: string\n readonly leaseExpiresAt: string\n}\n\nexport interface CompleteOntologyOutboxLeaseInput {\n readonly projectId: string\n readonly ids: readonly string[]\n readonly leaseId: string\n readonly publishedAt: string\n}\n\nexport interface RescheduleOntologyOutboxLeaseInput {\n readonly projectId: string\n readonly ids: readonly string[]\n readonly leaseId: string\n readonly availableAt: string\n /** The delivery failure that caused this retry. Omitted for lifecycle-only rescheduling. */\n readonly failure?: OntologyOutboxFailure\n}\n\nexport interface PurgePublishedOntologyOutboxInput {\n readonly projectId: string\n readonly publishedBefore: string\n readonly limit: number\n}\n\nexport interface SummarizeOntologyOutboxInput {\n readonly projectId: string\n}\n\nexport interface OntologyOutboxSummary {\n readonly pendingCount: number\n readonly oldestPendingAt: string | null\n /** Pending rows that have already been claimed at least once. */\n readonly retryingCount: number\n readonly maxAttempts: number\n}\n\nexport interface OntologyOutboxStorage {\n /** Selects each claimed batch deterministically; concurrent publishers may complete out of order. */\n claim(input: ClaimOntologyOutboxInput): Promise<readonly ClaimedOntologyOutboxRow[]>\n markPublished(input: CompleteOntologyOutboxLeaseInput): Promise<void>\n reschedule(input: RescheduleOntologyOutboxLeaseInput): Promise<void>\n purgePublished(input: PurgePublishedOntologyOutboxInput): Promise<number>\n summarize(input: SummarizeOntologyOutboxInput): Promise<OntologyOutboxSummary>\n}\n"
5
+ "import type { SixbErrorCode, SixbFailure } from \"../../errors/types\"\nimport type { OntologyMaterializationEvent } from \"../../materialization/events\"\n\nexport type {\n OntologyMaterializationEvent,\n OntologyMaterializationEventDraft,\n} from \"../../materialization/events\"\n\nexport interface OntologyOutboxWrite {\n /** Providers may index envelope identity fields, but the envelope remains authoritative. */\n readonly envelope: OntologyMaterializationEvent\n readonly availableAt: string\n readonly createdAt: string\n}\n\n/** Error codes a durable ontology outbox delivery can persist. */\nexport const ONTOLOGY_OUTBOX_FAILURE_CODES = [\"event.delivery_failed\"] as const satisfies readonly [\n SixbErrorCode,\n ...SixbErrorCode[],\n]\n\nexport type OntologyOutboxFailureCode = (typeof ONTOLOGY_OUTBOX_FAILURE_CODES)[number]\nexport type OntologyOutboxFailure = SixbFailure<OntologyOutboxFailureCode>\n\nexport interface OntologyOutboxRecord {\n readonly envelope: OntologyMaterializationEvent\n readonly availableAt: string\n readonly attempts: number\n readonly leaseId: string | null\n readonly leaseExpiresAt: string | null\n readonly publishedAt: string | null\n readonly lastFailure: OntologyOutboxFailure | null\n readonly createdAt: string\n}\n\nexport interface ClaimOntologyOutboxInput {\n readonly projectId: string\n readonly now: string\n readonly limit: number\n readonly leaseId: string\n readonly leaseExpiresAt: string\n}\n\nexport interface ClaimedOntologyOutboxRow extends OntologyOutboxRecord {\n readonly leaseId: string\n readonly leaseExpiresAt: string\n}\n\nexport interface CompleteOntologyOutboxLeaseInput {\n readonly projectId: string\n readonly ids: readonly string[]\n readonly leaseId: string\n readonly publishedAt: string\n}\n\nexport interface RescheduleOntologyOutboxLeaseInput {\n readonly projectId: string\n readonly ids: readonly string[]\n readonly leaseId: string\n readonly availableAt: string\n /** The delivery failure that caused this retry. Omitted for lifecycle-only rescheduling. */\n readonly failure?: OntologyOutboxFailure\n}\n\nexport interface PurgePublishedOntologyOutboxInput {\n readonly projectId: string\n readonly publishedBefore: string\n readonly limit: number\n}\n\nexport interface SummarizeOntologyOutboxInput {\n readonly projectId: string\n}\n\nexport interface OntologyOutboxSummary {\n readonly pendingCount: number\n readonly oldestPendingAt: string | null\n /** Pending rows that have already been claimed at least once. */\n readonly retryingCount: number\n readonly maxAttempts: number\n}\n\n/** Each method is atomic on its own, including validation of the entire lease batch. */\nexport interface OntologyOutboxStorage {\n /** Selects each claimed batch deterministically; concurrent publishers may complete out of order. */\n claim(input: ClaimOntologyOutboxInput): Promise<readonly ClaimedOntologyOutboxRow[]>\n markPublished(input: CompleteOntologyOutboxLeaseInput): Promise<void>\n reschedule(input: RescheduleOntologyOutboxLeaseInput): Promise<void>\n purgePublished(input: PurgePublishedOntologyOutboxInput): Promise<number>\n summarize(input: SummarizeOntologyOutboxInput): Promise<OntologyOutboxSummary>\n}\n"
6
6
  ],
7
7
  "mappings": ";;AAgBO,IAAM,iCAAgC,CAAC,uBAAuB;",
8
8
  "debugId": "6CB44AB153CCE5CD64756E2164756E21",
@@ -15,7 +15,7 @@ import {
15
15
  import {
16
16
  defineLanguageModel2,
17
17
  ModelCatalogUnavailableError2
18
- } from "./chunk-e0d1rzef.js";
18
+ } from "./chunk-jsy70480.js";
19
19
  import {
20
20
  AiUsageStorageError2,
21
21
  normalizeAiModelCallCostRecord2,
@@ -23,7 +23,7 @@ import {
23
23
  } from "./chunk-g53f0e4j.js";
24
24
  import {
25
25
  AiCostStorageError2
26
- } from "./chunk-mjbk2djy.js";
26
+ } from "./chunk-gqm76kse.js";
27
27
  import {
28
28
  normalizeAiModelCallRecord2
29
29
  } from "./chunk-s3csryxe.js";
@@ -13,13 +13,13 @@ import {
13
13
  } from "./chunk-g00bfdq6.js";
14
14
  import {
15
15
  RuntimeError2
16
- } from "./chunk-e0d1rzef.js";
16
+ } from "./chunk-jsy70480.js";
17
17
  import {
18
18
  isDatasetDefinition2
19
19
  } from "./chunk-860dwwy0.js";
20
20
  import {
21
21
  isPipelineDefinition2
22
- } from "./chunk-xyr8kppc.js";
22
+ } from "./chunk-1yefycb1.js";
23
23
  import {
24
24
  assertPredicateShape,
25
25
  createPropertyPredicateBuilder,
@@ -34,13 +34,13 @@ import {
34
34
  } from "./chunk-awbhdqyc.js";
35
35
  import {
36
36
  isSyncDefinition2
37
- } from "./chunk-xfbydgzy.js";
37
+ } from "./chunk-x9m9x2eq.js";
38
38
  import {
39
39
  isWorkflowDefinition2
40
- } from "./chunk-hpr1r6av.js";
40
+ } from "./chunk-gq8vhakp.js";
41
41
  import {
42
42
  isConnectorDefinition
43
- } from "./chunk-3f7veca0.js";
43
+ } from "./chunk-9x8dybsb.js";
44
44
 
45
45
  // src/bootstrap/discovery.ts
46
46
  import { AsyncLocalStorage } from "async_hooks";
@@ -34,7 +34,7 @@ import {
34
34
  createCommitId2,
35
35
  createEventId2,
36
36
  materializationApplyPhase
37
- } from "./chunk-x57ycxq0.js";
37
+ } from "./chunk-gqh45d2n.js";
38
38
  import {
39
39
  ProjectionValidationError2,
40
40
  validateProjectionsAtStartup,
@@ -3122,6 +3122,12 @@ function createProjectionEntryValidator(ontology, resolved) {
3122
3122
  const policy = createValidationPolicy(resolved);
3123
3123
  return (entry) => validateProjectionEntry(ontology, resolved, policy, entry);
3124
3124
  }
3125
+ function validateProjectionRootRef(resolved, root) {
3126
+ const definition = resolved.definition;
3127
+ const owned = definition._tag === "ObjectProjectionDefinition" ? root.kind === "object" && root.ref.objectTypeId === definition.objectTypeId : root.kind === "link" && root.ref.source.objectTypeId === definition.sourceObjectTypeId && root.ref.target.objectTypeId === definition.targetObjectTypeId && root.ref.linkId === definition.linkId;
3128
+ if (!owned)
3129
+ throw new MaterializationValidationError2("Projection root is outside its owned type or link scope.");
3130
+ }
3125
3131
  function createValidationPolicy(resolved) {
3126
3132
  const ownedProperties = new Map(resolved.ownership.objects.map((object) => [object.objectTypeId, new Set(object.propertyIds)]));
3127
3133
  const ownedLinks = new Set(resolved.ownership.links.map((link) => linkOwnershipKey(link.sourceObjectTypeId, link.linkId)));
@@ -3478,13 +3484,23 @@ async function stageProjectionMaterialization(context, input) {
3478
3484
  projectionRevision: input.projectionRevision,
3479
3485
  ownershipHash: input.ownershipHash,
3480
3486
  ontologyRevision: context.projectionRegistry.ontologyRevision,
3481
- createdAt: input.createdAt
3487
+ createdAt: input.createdAt,
3488
+ ...input.base ? { base: input.base } : {}
3482
3489
  });
3483
3490
  let rootCount = 0;
3484
3491
  let assertionCount = 0;
3485
3492
  async function* assertions() {
3486
3493
  for await (const rawEntry of input.entries) {
3487
3494
  throwIfAborted(input.signal);
3495
+ if ("deleted" in rawEntry) {
3496
+ if (!input.base || rawEntry.deleted !== true) {
3497
+ throw new MaterializationValidationError2("Explicit root deletions require a pinned source base.");
3498
+ }
3499
+ const root = normalizeProjectionEntity(rawEntry.root);
3500
+ validateProjectionRootRef(context.projectionRegistry.resolveSource(input.source.projectionId), root);
3501
+ yield { root, stagingOrdinal: rootCount++ };
3502
+ continue;
3503
+ }
3488
3504
  const entry = input.validateEntry(normalizeProjectionSourceEntry2(rawEntry));
3489
3505
  const stagingOrdinal = rootCount;
3490
3506
  for (const assertion of entry.assertions) {
@@ -3505,7 +3521,8 @@ async function stageProjectionMaterialization(context, input) {
3505
3521
  source: input.source,
3506
3522
  materializationId: input.materializationId,
3507
3523
  execution: input.execution,
3508
- rows
3524
+ rows: rows.filter((row) => ("assertion" in row)),
3525
+ deletions: rows.filter((row) => !("assertion" in row))
3509
3526
  });
3510
3527
  }
3511
3528
  await context.storage.ontology.sources.markReady({
@@ -3557,6 +3574,7 @@ function prepareProjectionReplacement(context, raw) {
3557
3574
  datasetVersion,
3558
3575
  execution,
3559
3576
  entries: raw.input.entries,
3577
+ ...raw.input.base ? { base: Object.freeze({ ...raw.input.base }) } : {},
3560
3578
  resolved,
3561
3579
  projectionKind,
3562
3580
  runIdentity,
@@ -3622,6 +3640,7 @@ async function prepareProjectionCandidate(context, command) {
3622
3640
  source: command.source
3623
3641
  });
3624
3642
  validateProjectionWatermark(active, command.datasetVersion);
3643
+ assertDeltaBase(active, command);
3625
3644
  return {
3626
3645
  materializationId: context.materializationId(),
3627
3646
  createdAt: context.clock().toISOString(),
@@ -3643,6 +3662,7 @@ async function stageProjectionCandidate(context, command, candidate) {
3643
3662
  ownershipHash: command.resolved.ownershipHash,
3644
3663
  createdAt: candidate.createdAt,
3645
3664
  entries: command.entries,
3665
+ ...command.base ? { base: command.base } : {},
3646
3666
  validateEntry: createProjectionEntryValidator(context.ontology, command.resolved)
3647
3667
  };
3648
3668
  const staged = await stageCandidateEntries(context, input, command.signal);
@@ -3666,6 +3686,14 @@ async function executeProjectionTransaction(context, storage, command, ready) {
3666
3686
  const replay = await replayCommitRecord(context, command.identity, command.scopeExecution.executionId, storage);
3667
3687
  if (replay)
3668
3688
  return projectionReplayResult(replay, command);
3689
+ if (command.base) {
3690
+ const active = await storage.ontology.sources.getActive({
3691
+ projectId: context.projectId,
3692
+ source: command.source
3693
+ });
3694
+ validateProjectionWatermark(active, command.datasetVersion);
3695
+ assertDeltaBase(active, command);
3696
+ }
3669
3697
  const origin = projectionOrigin(command);
3670
3698
  throwIfAborted(command.signal);
3671
3699
  const session = await storage.ontology.materializations.begin({
@@ -3783,6 +3811,11 @@ function validateProjectionWatermark(active, next) {
3783
3811
  return;
3784
3812
  assertPinnedDatasetWatermark2(active.datasetVersion, next, "Projection replacement");
3785
3813
  }
3814
+ function assertDeltaBase(active, command) {
3815
+ if (command.base && (!active || active.materializationId !== command.base.materializationId || active.lastCommitId !== command.base.lastCommitId || active.projectionRevision !== command.runIdentity.projectionRevision || active.ontologyRevision !== command.runIdentity.ontologyRevision || active.ownershipHash !== command.runIdentity.ownershipHash)) {
3816
+ throw new MaterializationConflictError2("source-materialization", "Projection delta no longer matches the active source or its definition.");
3817
+ }
3818
+ }
3786
3819
 
3787
3820
  // src/materializer/telemetry/plan.ts
3788
3821
  async function planTelemetryAppend(context, storage, session, input, identity, origin, event) {
@@ -4292,6 +4325,10 @@ class OntologyMaterializer2 {
4292
4325
  commit: (command) => commitEdits(this.context, command)
4293
4326
  };
4294
4327
  projections = {
4328
+ getActive: (source) => this.context.storage.ontology.sources.getActive({
4329
+ projectId: this.context.projectId,
4330
+ source
4331
+ }),
4295
4332
  replace: (command) => replaceProjection(this.context, command),
4296
4333
  finishRun: (command) => finishProjectionRun(this.context, command)
4297
4334
  };
@@ -4304,6 +4341,7 @@ class OntologyMaterializer2 {
4304
4341
  commit: (input) => this.edits.commit({ scope, input })
4305
4342
  }),
4306
4343
  projections: Object.freeze({
4344
+ getActive: (source) => this.projections.getActive(source),
4307
4345
  replace: (input) => this.projections.replace({ scope, input }),
4308
4346
  finishRun: (input) => this.projections.finishRun({ scope, input })
4309
4347
  }),
@@ -4328,4 +4366,4 @@ function createOntologyMaterializer2(input) {
4328
4366
  }
4329
4367
  export { computeOntologyRevision2, computeProjectionRevision2, computeProjectionOwnershipHash2, ProjectionRegistry2, createActionIdempotencyKey2, createRuntimeIdempotencyKey2, createProjectionIdempotencyKey2, createRuntimeTelemetryIdempotencyKey2, createProjectionTelemetryIdempotencyKey2, createCommitIdentity2, timestampCommitIdentity2, createTimedCommitIdentity2, createProjectionMaterializationId2, createLinkScopeFingerprint2, normalizeJsonProperties2, normalizeOntologyEditCommit2, normalizeProjectionExecution2, normalizeProjectionSourceEntry2, normalizeTelemetryAppend2, OntologyMaterializer2, createOntologyMaterializer2 };
4330
4368
 
4331
- //# debugId=D5AC53F589D39D7164756E2164756E21
4369
+ //# debugId=45B690D58E462D3C64756E2164756E21