@sixb/core 0.2.4 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/index.js +41 -40
- package/dist/actions/index.js.map +1 -1
- package/dist/actions/validation.d.ts.map +1 -1
- package/dist/agents/errors.d.ts +1 -1
- package/dist/agents/errors.d.ts.map +1 -1
- package/dist/agents/execution.d.ts +50 -3
- package/dist/agents/execution.d.ts.map +1 -1
- package/dist/agents/ids.d.ts +2 -0
- package/dist/agents/ids.d.ts.map +1 -1
- package/dist/agents/index.d.ts +7 -5
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +74 -50
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/model-routing.d.ts +5 -2
- package/dist/agents/model-routing.d.ts.map +1 -1
- package/dist/agents/queued-turn.d.ts +16 -0
- package/dist/agents/queued-turn.d.ts.map +1 -0
- package/dist/agents/request.d.ts +120 -1
- package/dist/agents/request.d.ts.map +1 -1
- package/dist/agents/run-after-finish.d.ts +10 -0
- package/dist/agents/run-after-finish.d.ts.map +1 -1
- package/dist/agents/run-artifacts.d.ts +0 -38
- package/dist/agents/run-artifacts.d.ts.map +1 -1
- package/dist/agents/run-events.d.ts +10 -1
- package/dist/agents/run-events.d.ts.map +1 -1
- package/dist/agents/run-session-children.d.ts.map +1 -1
- package/dist/agents/run-session-http.d.ts.map +1 -1
- package/dist/agents/run-session-serve.d.ts.map +1 -1
- package/dist/agents/run-session.d.ts +14 -1
- package/dist/agents/run-session.d.ts.map +1 -1
- package/dist/agents/run-turn.d.ts +9 -1
- package/dist/agents/run-turn.d.ts.map +1 -1
- package/dist/agents/streams/index.d.ts +1 -1
- package/dist/agents/streams/index.d.ts.map +1 -1
- package/dist/agents/streams/index.js +1 -1
- package/dist/agents/streams/internal.d.ts +2 -1
- package/dist/agents/streams/internal.d.ts.map +1 -1
- package/dist/agents/streams/internal.js +22 -2
- package/dist/agents/streams/internal.js.map +1 -1
- package/dist/agents/streams/protocol.d.ts +53 -0
- package/dist/agents/streams/protocol.d.ts.map +1 -1
- package/dist/agents/streams/steps.d.ts +24 -0
- package/dist/agents/streams/steps.d.ts.map +1 -0
- package/dist/agents/thread-access.d.ts +44 -2
- package/dist/agents/thread-access.d.ts.map +1 -1
- package/dist/agents/turn-answered.d.ts +7 -0
- package/dist/agents/turn-answered.d.ts.map +1 -0
- package/dist/agents/validation.d.ts +1 -1
- package/dist/agents/validation.d.ts.map +1 -1
- package/dist/artifacts/canvas-display.d.ts +3 -5
- package/dist/artifacts/canvas-display.d.ts.map +1 -1
- package/dist/artifacts/comments.d.ts +14 -3
- package/dist/artifacts/comments.d.ts.map +1 -1
- package/dist/artifacts/document-fill.d.ts +18 -0
- package/dist/artifacts/document-fill.d.ts.map +1 -0
- package/dist/artifacts/errors.d.ts +1 -1
- package/dist/artifacts/errors.d.ts.map +1 -1
- package/dist/artifacts/events.d.ts +3 -2
- package/dist/artifacts/events.d.ts.map +1 -1
- package/dist/artifacts/execution.d.ts +40 -4
- package/dist/artifacts/execution.d.ts.map +1 -1
- package/dist/artifacts/frames/assets.d.ts +8 -1
- package/dist/artifacts/frames/assets.d.ts.map +1 -1
- package/dist/artifacts/frames/document-data.d.ts +98 -0
- package/dist/artifacts/frames/document-data.d.ts.map +1 -0
- package/dist/artifacts/frames/entries.d.ts +12 -7
- package/dist/artifacts/frames/entries.d.ts.map +1 -1
- package/dist/artifacts/frames/index.d.ts +2 -1
- package/dist/artifacts/frames/index.d.ts.map +1 -1
- package/dist/artifacts/frames/index.js +22 -13
- package/dist/artifacts/frames/index.js.map +4 -4
- package/dist/artifacts/frames/kit.d.ts +15 -0
- package/dist/artifacts/frames/kit.d.ts.map +1 -1
- package/dist/artifacts/frames/protocol.d.ts +12 -1
- package/dist/artifacts/frames/protocol.d.ts.map +1 -1
- package/dist/artifacts/frames/runtime.d.ts +24 -4
- package/dist/artifacts/frames/runtime.d.ts.map +1 -1
- package/dist/artifacts/index.d.ts +3 -1
- package/dist/artifacts/index.d.ts.map +1 -1
- package/dist/artifacts/index.js +9 -3
- package/dist/artifacts/index.js.map +3 -3
- package/dist/artifacts/live/blocks.d.ts +62 -0
- package/dist/artifacts/live/blocks.d.ts.map +1 -0
- package/dist/artifacts/live/board.d.ts +6 -0
- package/dist/artifacts/live/board.d.ts.map +1 -1
- package/dist/artifacts/live/document.d.ts +12 -0
- package/dist/artifacts/live/document.d.ts.map +1 -1
- package/dist/artifacts/live/index.d.ts +2 -0
- package/dist/artifacts/live/index.d.ts.map +1 -1
- package/dist/artifacts/live/index.js +148 -44
- package/dist/artifacts/live/index.js.map +3 -3
- package/dist/artifacts/live/page.d.ts +49 -0
- package/dist/artifacts/live/page.d.ts.map +1 -0
- package/dist/artifacts/live/protocol.d.ts +5 -0
- package/dist/artifacts/live/protocol.d.ts.map +1 -1
- package/dist/artifacts/live/server.d.ts +2 -2
- package/dist/artifacts/live/server.d.ts.map +1 -1
- package/dist/artifacts/live/server.js +29 -24
- package/dist/artifacts/live/server.js.map +1 -1
- package/dist/artifacts/live/state.d.ts +4 -1
- package/dist/artifacts/live/state.d.ts.map +1 -1
- package/dist/artifacts/outline.d.ts +16 -0
- package/dist/artifacts/outline.d.ts.map +1 -1
- package/dist/artifacts/paper.d.ts +22 -0
- package/dist/artifacts/paper.d.ts.map +1 -0
- package/dist/artifacts/pdf-job.d.ts +9 -0
- package/dist/artifacts/pdf-job.d.ts.map +1 -0
- package/dist/artifacts/publish/fields.d.ts +25 -0
- package/dist/artifacts/publish/fields.d.ts.map +1 -0
- package/dist/artifacts/publish/index.d.ts +2 -1
- package/dist/artifacts/publish/index.d.ts.map +1 -1
- package/dist/artifacts/publish/index.js +32 -23
- package/dist/artifacts/publish/index.js.map +1 -1
- package/dist/artifacts/publish/merge.d.ts +7 -6
- package/dist/artifacts/publish/merge.d.ts.map +1 -1
- package/dist/artifacts/publish/pdf.d.ts +28 -0
- package/dist/artifacts/publish/pdf.d.ts.map +1 -0
- package/dist/artifacts/publish/previews.d.ts +12 -20
- package/dist/artifacts/publish/previews.d.ts.map +1 -1
- package/dist/artifacts/publish/publish.d.ts.map +1 -1
- package/dist/artifacts/publish/queries.d.ts +6 -1
- package/dist/artifacts/publish/queries.d.ts.map +1 -1
- package/dist/artifacts/publish/query-answers.d.ts +5 -2
- package/dist/artifacts/publish/query-answers.d.ts.map +1 -1
- package/dist/artifacts/publish/validate/document-html.d.ts +24 -0
- package/dist/artifacts/publish/validate/document-html.d.ts.map +1 -0
- package/dist/artifacts/publish/validate/document.d.ts +5 -3
- package/dist/artifacts/publish/validate/document.d.ts.map +1 -1
- package/dist/artifacts/queries.d.ts +16 -2
- package/dist/artifacts/queries.d.ts.map +1 -1
- package/dist/artifacts/run-query.d.ts.map +1 -1
- package/dist/auth/index.js +6 -6
- package/dist/authorization/event-visibility.d.ts.map +1 -1
- package/dist/authorization/index.js +2 -2
- package/dist/blob-storage/index.js +1 -1
- package/dist/bootstrap/index.js +50 -48
- package/dist/bootstrap/index.js.map +2 -2
- package/dist/calendar.d.ts +55 -0
- package/dist/calendar.d.ts.map +1 -0
- package/dist/calendar.js +19 -0
- package/dist/calendar.js.map +9 -0
- package/dist/{chunk-5a4a52tq.js → chunk-0pmpwn3g.js} +18 -2
- package/dist/chunk-0pmpwn3g.js.map +10 -0
- package/dist/{chunk-0k3r5kb3.js → chunk-394zjzjs.js} +20 -10
- package/dist/{chunk-0k3r5kb3.js.map → chunk-394zjzjs.js.map} +5 -5
- package/dist/{chunk-stmxh0hv.js → chunk-3neam1y5.js} +2 -2
- package/dist/{chunk-zeykm8my.js → chunk-3qtk0070.js} +16 -42
- package/dist/chunk-3qtk0070.js.map +14 -0
- package/dist/{chunk-p8pgnq8d.js → chunk-425ydk65.js} +5 -5
- package/dist/{chunk-p351afzm.js → chunk-5sswe5ej.js} +2 -2
- package/dist/{chunk-a6fjkcne.js → chunk-60662fyv.js} +54 -28
- package/dist/{chunk-a6fjkcne.js.map → chunk-60662fyv.js.map} +7 -6
- package/dist/{chunk-e0hnbb1m.js → chunk-61zptves.js} +1 -1
- package/dist/chunk-6hfbz4d0.js +98 -0
- package/dist/chunk-6hfbz4d0.js.map +10 -0
- package/dist/{chunk-3zagkr6w.js → chunk-7mhbs9yy.js} +4 -4
- package/dist/{chunk-3zagkr6w.js.map → chunk-7mhbs9yy.js.map} +1 -1
- package/dist/{chunk-gxwy4c3s.js → chunk-7r9mqpva.js} +570 -104
- package/dist/chunk-7r9mqpva.js.map +47 -0
- package/dist/{chunk-3014rfjz.js → chunk-88xeh6zx.js} +28 -8
- package/dist/{chunk-3014rfjz.js.map → chunk-88xeh6zx.js.map} +4 -4
- package/dist/{chunk-9nsjjd44.js → chunk-8tv3qd65.js} +2 -1
- package/dist/chunk-8tv3qd65.js.map +12 -0
- package/dist/chunk-90nqenq8.js +386 -0
- package/dist/chunk-90nqenq8.js.map +14 -0
- package/dist/{chunk-fe6r7yhg.js → chunk-92wrka15.js} +1 -1
- package/dist/{chunk-w1wq7gfr.js → chunk-9c9yknwt.js} +464 -29
- package/dist/{chunk-w1wq7gfr.js.map → chunk-9c9yknwt.js.map} +7 -7
- package/dist/{chunk-q9nkpr8k.js → chunk-9tpmfh3n.js} +1 -1
- package/dist/chunk-9wr3yajk.js.map +2 -2
- package/dist/{chunk-rtm1jq00.js → chunk-ats8y3d9.js} +1202 -246
- package/dist/{chunk-rtm1jq00.js.map → chunk-ats8y3d9.js.map} +16 -14
- package/dist/{chunk-td26wjr5.js → chunk-bcz9dxtf.js} +17 -47
- package/dist/chunk-bcz9dxtf.js.map +12 -0
- package/dist/chunk-bqr703h4.js +1799 -0
- package/dist/chunk-bqr703h4.js.map +13 -0
- package/dist/{chunk-sysnvjce.js → chunk-brhp9d97.js} +2 -2
- package/dist/{chunk-8a8k38tz.js → chunk-brybqw5k.js} +1 -1
- package/dist/{chunk-rsxb14an.js → chunk-bs1sd0e0.js} +12 -8
- package/dist/chunk-bs1sd0e0.js.map +18 -0
- package/dist/{chunk-eptrvnby.js → chunk-c29729me.js} +42 -3
- package/dist/chunk-c29729me.js.map +12 -0
- package/dist/{chunk-855w9nvw.js → chunk-cg7cygfj.js} +1 -1
- package/dist/chunk-dq3t5sr3.js +114 -0
- package/dist/chunk-dq3t5sr3.js.map +11 -0
- package/dist/{chunk-t24yktqr.js → chunk-dvgc56n2.js} +20 -4
- package/dist/{chunk-t24yktqr.js.map → chunk-dvgc56n2.js.map} +5 -5
- package/dist/{chunk-r2psmn42.js → chunk-eg6xqef7.js} +1 -1
- package/dist/{chunk-7kpqntgw.js → chunk-f05994as.js} +1 -1
- package/dist/{chunk-msyevpp3.js → chunk-fmgf9h5e.js} +38 -14
- package/dist/chunk-fmgf9h5e.js.map +22 -0
- package/dist/{chunk-b9qfh2ya.js → chunk-fzbhybya.js} +29 -2
- package/dist/chunk-fzbhybya.js.map +11 -0
- package/dist/{chunk-t0s7b3d1.js → chunk-gaj8djsw.js} +251 -6
- package/dist/chunk-gaj8djsw.js.map +13 -0
- package/dist/{chunk-2bn6813a.js → chunk-grt2j5vp.js} +2 -2
- package/dist/{chunk-s7xqfxs9.js → chunk-hkbks1xm.js} +3 -1
- package/dist/{chunk-s7xqfxs9.js.map → chunk-hkbks1xm.js.map} +3 -3
- package/dist/chunk-hn2r7z41.js.map +1 -1
- package/dist/{chunk-rtdrm592.js → chunk-htdzx40w.js} +2 -2
- package/dist/{chunk-bc3y6gff.js → chunk-jka26v8c.js} +1 -1
- package/dist/{chunk-yy914zfr.js → chunk-jt012fxq.js} +772 -98
- package/dist/chunk-jt012fxq.js.map +34 -0
- package/dist/{chunk-48c1z8nj.js → chunk-kft7mp7z.js} +28 -3
- package/dist/chunk-kft7mp7z.js.map +10 -0
- package/dist/chunk-mbwsgjn7.js +40 -0
- package/dist/chunk-mbwsgjn7.js.map +11 -0
- package/dist/{chunk-wa05txmk.js → chunk-n1hbwc6y.js} +51 -8
- package/dist/chunk-n1hbwc6y.js.map +12 -0
- package/dist/{chunk-n4zzaf6q.js → chunk-nxysqbt0.js} +4 -2
- package/dist/chunk-nxysqbt0.js.map +10 -0
- package/dist/{chunk-6ef4esq4.js → chunk-pqj8vff9.js} +4 -4
- package/dist/chunk-pvpq483h.js.map +2 -2
- package/dist/{chunk-mzx71snp.js → chunk-q7g9cqwt.js} +7 -2
- package/dist/{chunk-mzx71snp.js.map → chunk-q7g9cqwt.js.map} +3 -3
- package/dist/{chunk-n68vz95m.js → chunk-qbd282aa.js} +2 -2
- package/dist/{chunk-e91fmg6t.js → chunk-qsa7nw6f.js} +2 -1
- package/dist/{chunk-e91fmg6t.js.map → chunk-qsa7nw6f.js.map} +3 -3
- package/dist/{chunk-rsrc7vtw.js → chunk-s8xxef60.js} +240 -46
- package/dist/chunk-s8xxef60.js.map +50 -0
- package/dist/{chunk-r9rtavg9.js → chunk-t19wjmnc.js} +7 -7
- package/dist/{chunk-vzkxqf8h.js → chunk-tapdssb5.js} +50 -6
- package/dist/chunk-tapdssb5.js.map +23 -0
- package/dist/{chunk-dhkc9b23.js → chunk-v8a1qjzp.js} +1 -1
- package/dist/{chunk-hvbvq7p4.js → chunk-vs2s3p8n.js} +731 -10
- package/dist/chunk-vs2s3p8n.js.map +20 -0
- package/dist/chunk-vtjzwymr.js.map +2 -2
- package/dist/{chunk-8t2ynwg0.js → chunk-wzcjhv54.js} +31 -1
- package/dist/{chunk-8t2ynwg0.js.map → chunk-wzcjhv54.js.map} +3 -3
- package/dist/{chunk-8tqnsx3q.js → chunk-xavet0qs.js} +5 -3
- package/dist/{chunk-8tqnsx3q.js.map → chunk-xavet0qs.js.map} +3 -3
- package/dist/{chunk-8bns0y68.js → chunk-xf76csps.js} +5 -5
- package/dist/{chunk-cwdzcv37.js → chunk-xrmbhap8.js} +2 -2
- package/dist/{chunk-cwdzcv37.js.map → chunk-xrmbhap8.js.map} +2 -2
- package/dist/{chunk-f6ahf5gf.js → chunk-xxfj0rr2.js} +20 -5
- package/dist/chunk-xxfj0rr2.js.map +13 -0
- package/dist/{chunk-3hzhcfsv.js → chunk-y8fwm3z2.js} +2 -2
- package/dist/{chunk-3hzhcfsv.js.map → chunk-y8fwm3z2.js.map} +3 -3
- package/dist/{chunk-smnt672s.js → chunk-ygvay56w.js} +20 -4
- package/dist/chunk-ygvay56w.js.map +10 -0
- package/dist/{chunk-evj5jxz3.js → chunk-ykchk644.js} +63 -15
- package/dist/{chunk-evj5jxz3.js.map → chunk-ykchk644.js.map} +7 -7
- package/dist/{chunk-vepea5c3.js → chunk-ym1bqd98.js} +6 -6
- package/dist/{chunk-yv8hv4wq.js → chunk-z4jqb44a.js} +3 -1
- package/dist/chunk-z4jqb44a.js.map +10 -0
- package/dist/connectors/connection-handles.d.ts +9 -0
- package/dist/connectors/connection-handles.d.ts.map +1 -0
- package/dist/connectors/connections/authorizations.d.ts +9 -0
- package/dist/connectors/connections/authorizations.d.ts.map +1 -1
- package/dist/connectors/connections/capability.d.ts +11 -0
- package/dist/connectors/connections/capability.d.ts.map +1 -1
- package/dist/connectors/connections/events.d.ts +17 -0
- package/dist/connectors/connections/events.d.ts.map +1 -0
- package/dist/connectors/connections/internal.d.ts +2 -1
- package/dist/connectors/connections/internal.d.ts.map +1 -1
- package/dist/connectors/connections/internal.js +8 -4
- package/dist/connectors/connections/internal.js.map +1 -1
- package/dist/connectors/connections/runs.d.ts +3 -0
- package/dist/connectors/connections/runs.d.ts.map +1 -1
- package/dist/connectors/connections/service.d.ts +13 -1
- package/dist/connectors/connections/service.d.ts.map +1 -1
- package/dist/connectors/execution.d.ts +14 -2
- package/dist/connectors/execution.d.ts.map +1 -1
- package/dist/connectors/index.d.ts +1 -1
- package/dist/connectors/index.d.ts.map +1 -1
- package/dist/connectors/service.d.ts +5 -1
- package/dist/connectors/service.d.ts.map +1 -1
- package/dist/connectors/types.d.ts +22 -1
- package/dist/connectors/types.d.ts.map +1 -1
- package/dist/datasets/write.js +1 -1
- package/dist/deploy/index.d.ts +1 -1
- package/dist/deploy/index.d.ts.map +1 -1
- package/dist/deploy/internal.js +3 -2
- package/dist/deploy/internal.js.map +3 -3
- package/dist/deploy/services.d.ts.map +1 -1
- package/dist/deploy/types.d.ts +22 -2
- package/dist/deploy/types.d.ts.map +1 -1
- package/dist/events/definitions.d.ts +4 -0
- package/dist/events/definitions.d.ts.map +1 -1
- package/dist/events/execution.d.ts +8 -1
- package/dist/events/execution.d.ts.map +1 -1
- package/dist/events/index.d.ts +2 -2
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +3 -3
- package/dist/events/outbox-dispatcher.d.ts +7 -0
- package/dist/events/outbox-dispatcher.d.ts.map +1 -1
- package/dist/events/scope.d.ts +1 -0
- package/dist/events/scope.d.ts.map +1 -1
- package/dist/events/scope.js +1 -1
- package/dist/events/selectors/builder.d.ts +9 -1
- package/dist/events/selectors/builder.d.ts.map +1 -1
- package/dist/events/selectors/index.d.ts +2 -2
- package/dist/events/selectors/index.d.ts.map +1 -1
- package/dist/events/selectors/index.js +2 -2
- package/dist/events/selectors/predicate.d.ts.map +1 -1
- package/dist/events/selectors/types.d.ts +18 -3
- package/dist/events/selectors/types.d.ts.map +1 -1
- package/dist/events/types/artifacts.d.ts +7 -1
- package/dist/events/types/artifacts.d.ts.map +1 -1
- package/dist/events/types/connectors.d.ts +32 -0
- package/dist/events/types/connectors.d.ts.map +1 -0
- package/dist/events/types/index.d.ts +3 -1
- package/dist/events/types/index.d.ts.map +1 -1
- package/dist/events/types/syncs.d.ts +4 -0
- package/dist/events/types/syncs.d.ts.map +1 -1
- package/dist/execution/agent.js +43 -42
- package/dist/execution/agent.js.map +1 -1
- package/dist/execution/authorization.d.ts +5 -0
- package/dist/execution/authorization.d.ts.map +1 -1
- package/dist/execution/authorized-object-reader.d.ts +4 -0
- package/dist/execution/authorized-object-reader.d.ts.map +1 -1
- package/dist/execution/object-reader-ontology.d.ts +3 -0
- package/dist/execution/object-reader-ontology.d.ts.map +1 -1
- package/dist/execution/primitive.js +41 -40
- package/dist/execution/primitive.js.map +1 -1
- package/dist/execution/request.d.ts +1 -1
- package/dist/execution/request.d.ts.map +1 -1
- package/dist/execution/request.js +39 -38
- package/dist/execution/request.js.map +3 -3
- package/dist/execution/scopes.d.ts +8 -0
- package/dist/execution/scopes.d.ts.map +1 -1
- package/dist/execution/script.d.ts +7 -0
- package/dist/execution/script.d.ts.map +1 -0
- package/dist/execution/types.d.ts +16 -1
- package/dist/execution/types.d.ts.map +1 -1
- package/dist/http/api-routes.d.ts.map +1 -1
- package/dist/http/index.js +1 -1
- package/dist/index.d.ts +13 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +74 -70
- package/dist/index.js.map +1 -1
- package/dist/lake-storage/index.js +1 -1
- package/dist/lineage/executors.d.ts +1 -1
- package/dist/lineage/executors.d.ts.map +1 -1
- package/dist/maintenance/index.js +2 -2
- package/dist/materialization/event-envelopes.d.ts +3 -3
- package/dist/materialization/event-envelopes.d.ts.map +1 -1
- package/dist/materialization/events.d.ts +6 -0
- package/dist/materialization/events.d.ts.map +1 -1
- package/dist/materialization/index.js +1 -1
- package/dist/materialization/model.d.ts +6 -0
- package/dist/materialization/model.d.ts.map +1 -1
- package/dist/materializer/index.js +24 -23
- package/dist/materializer/index.js.map +1 -1
- package/dist/materializer/projections/replace.d.ts.map +1 -1
- package/dist/materializer/projections/replacement-plan.d.ts +2 -0
- package/dist/materializer/projections/replacement-plan.d.ts.map +1 -1
- package/dist/materializer/shared/normalize.d.ts +1 -0
- package/dist/materializer/shared/normalize.d.ts.map +1 -1
- package/dist/models/audio/runtime.d.ts.map +1 -1
- package/dist/models/audio/types.d.ts +19 -0
- package/dist/models/audio/types.d.ts.map +1 -1
- package/dist/models/execution/index.js +22 -21
- package/dist/models/execution/index.js.map +1 -1
- package/dist/models/index.d.ts +1 -1
- package/dist/models/index.d.ts.map +1 -1
- package/dist/objects/index.js +41 -40
- package/dist/objects/index.js.map +1 -1
- package/dist/objects/query/executor.d.ts +3 -1
- package/dist/objects/query/executor.d.ts.map +1 -1
- package/dist/objects/query/explain.d.ts +3 -1
- package/dist/objects/query/explain.d.ts.map +1 -1
- package/dist/objects/query/index.d.ts +1 -1
- package/dist/objects/query/index.d.ts.map +1 -1
- package/dist/objects/query/index.js +21 -20
- package/dist/objects/query/index.js.map +1 -1
- package/dist/objects/query/link-query-clearance.d.ts +3 -0
- package/dist/objects/query/link-query-clearance.d.ts.map +1 -1
- package/dist/objects/query/links.d.ts +1 -1
- package/dist/objects/query/links.d.ts.map +1 -1
- package/dist/objects/query/validate.d.ts +17 -0
- package/dist/objects/query/validate.d.ts.map +1 -1
- package/dist/objects/sdk/runtime-query-executor.d.ts +1 -1
- package/dist/objects/sdk/runtime-query-executor.d.ts.map +1 -1
- package/dist/ontology/index.js +3 -3
- package/dist/ontology/internal.js +3 -3
- package/dist/pipelines/index.js +27 -26
- package/dist/pipelines/index.js.map +1 -1
- package/dist/projections/builders.d.ts +7 -1
- package/dist/projections/builders.d.ts.map +1 -1
- package/dist/projections/index.d.ts +1 -1
- package/dist/projections/index.d.ts.map +1 -1
- package/dist/projections/internal.js +22 -21
- package/dist/projections/internal.js.map +1 -1
- package/dist/projections/types.d.ts +10 -0
- package/dist/projections/types.d.ts.map +1 -1
- package/dist/projections/validation.d.ts.map +1 -1
- package/dist/queues/in-memory.d.ts +3 -2
- package/dist/queues/in-memory.d.ts.map +1 -1
- package/dist/queues/index.d.ts +1 -1
- package/dist/queues/index.d.ts.map +1 -1
- package/dist/queues/index.js +1 -1
- package/dist/queues/types.d.ts +40 -13
- package/dist/queues/types.d.ts.map +1 -1
- package/dist/runtime/host.d.ts +13 -0
- package/dist/runtime/host.d.ts.map +1 -1
- package/dist/runtime/internal.d.ts +1 -0
- package/dist/runtime/internal.d.ts.map +1 -1
- package/dist/runtime/internal.js +47 -25
- package/dist/runtime/internal.js.map +4 -3
- package/dist/runtime/locale.d.ts +0 -2
- package/dist/runtime/locale.d.ts.map +1 -1
- package/dist/runtime/resolve-definitions.d.ts +1 -1
- package/dist/runtime/resolve-definitions.d.ts.map +1 -1
- package/dist/runtime/script.d.ts +39 -0
- package/dist/runtime/script.d.ts.map +1 -0
- package/dist/runtime/sixb.d.ts +2 -2
- package/dist/runtime/sixb.d.ts.map +1 -1
- package/dist/sandboxes/auth.d.ts +26 -4
- package/dist/sandboxes/auth.d.ts.map +1 -1
- package/dist/sandboxes/index.d.ts +3 -1
- package/dist/sandboxes/index.d.ts.map +1 -1
- package/dist/sandboxes/index.js +5 -5
- package/dist/schedules/builders.d.ts.map +1 -1
- package/dist/schedules/index.js +3 -3
- package/dist/schedules/runtime.d.ts.map +1 -1
- package/dist/schedules/validation.d.ts +2 -0
- package/dist/schedules/validation.d.ts.map +1 -1
- package/dist/security/view-conditions.d.ts.map +1 -1
- package/dist/shares/internal.js +19 -18
- package/dist/shares/internal.js.map +2 -2
- package/dist/storage/agents/errors.d.ts +1 -1
- package/dist/storage/agents/errors.d.ts.map +1 -1
- package/dist/storage/agents/in-memory.d.ts +43 -1
- package/dist/storage/agents/in-memory.d.ts.map +1 -1
- package/dist/storage/agents/index.d.ts +2 -2
- package/dist/storage/agents/index.d.ts.map +1 -1
- package/dist/storage/agents/provider.d.ts +54 -11
- package/dist/storage/agents/provider.d.ts.map +1 -1
- package/dist/storage/agents/provider.js +41 -5
- package/dist/storage/agents/provider.js.map +1 -1
- package/dist/storage/agents/types.d.ts +291 -3
- package/dist/storage/agents/types.d.ts.map +1 -1
- package/dist/storage/ai-cost/analytics.d.ts +3 -2
- package/dist/storage/ai-cost/analytics.d.ts.map +1 -1
- package/dist/storage/ai-cost/provider.js +4 -3
- package/dist/storage/ai-cost/provider.js.map +1 -1
- package/dist/storage/ai-cost/types.d.ts +5 -1
- package/dist/storage/ai-cost/types.d.ts.map +1 -1
- package/dist/storage/artifacts/in-memory.d.ts +7 -1
- package/dist/storage/artifacts/in-memory.d.ts.map +1 -1
- package/dist/storage/artifacts/index.d.ts +1 -1
- package/dist/storage/artifacts/index.d.ts.map +1 -1
- package/dist/storage/artifacts/record.d.ts +5 -2
- package/dist/storage/artifacts/record.d.ts.map +1 -1
- package/dist/storage/artifacts/types.d.ts +41 -0
- package/dist/storage/artifacts/types.d.ts.map +1 -1
- package/dist/storage/executions/provider.d.ts +3 -3
- package/dist/storage/executions/provider.d.ts.map +1 -1
- package/dist/storage/executions/provider.js +1 -1
- package/dist/storage/executions/types.d.ts +6 -0
- package/dist/storage/executions/types.d.ts.map +1 -1
- package/dist/storage/executions/validation.d.ts.map +1 -1
- package/dist/storage/file-upload-sessions/provider.js +7 -7
- package/dist/storage/index.d.ts +4 -4
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +30 -25
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/internal.d.ts +1 -1
- package/dist/storage/internal.d.ts.map +1 -1
- package/dist/storage/internal.js +12 -10
- package/dist/storage/internal.js.map +2 -2
- package/dist/storage/ontology/in-memory/replacement-plans.d.ts +2 -0
- package/dist/storage/ontology/in-memory/replacement-plans.d.ts.map +1 -1
- package/dist/storage/ontology/provider.js +1 -1
- package/dist/storage/ontology/replacement-plans.d.ts +8 -0
- package/dist/storage/ontology/replacement-plans.d.ts.map +1 -1
- package/dist/storage/operation-scope.d.ts.map +1 -1
- package/dist/storage/operation-scope.js +1 -1
- package/dist/storage/sync-runs/idempotency.d.ts.map +1 -1
- package/dist/storage/sync-runs/in-memory.d.ts +2 -1
- package/dist/storage/sync-runs/in-memory.d.ts.map +1 -1
- package/dist/storage/sync-runs/index.d.ts +1 -1
- package/dist/storage/sync-runs/index.d.ts.map +1 -1
- package/dist/storage/sync-runs/types.d.ts +27 -2
- package/dist/storage/sync-runs/types.d.ts.map +1 -1
- package/dist/storage/workflow-runs/provider.js +7 -7
- package/dist/syncs/accounts.d.ts +36 -0
- package/dist/syncs/accounts.d.ts.map +1 -0
- package/dist/syncs/builders.d.ts.map +1 -1
- package/dist/syncs/connections.d.ts +36 -0
- package/dist/syncs/connections.d.ts.map +1 -0
- package/dist/syncs/execution.d.ts +14 -4
- package/dist/syncs/execution.d.ts.map +1 -1
- package/dist/syncs/index.d.ts +2 -1
- package/dist/syncs/index.d.ts.map +1 -1
- package/dist/syncs/index.js +28 -27
- package/dist/syncs/index.js.map +1 -1
- package/dist/syncs/request.d.ts +16 -2
- package/dist/syncs/request.d.ts.map +1 -1
- package/dist/syncs/run-dispatch.d.ts +14 -2
- package/dist/syncs/run-dispatch.d.ts.map +1 -1
- package/dist/testing/agent-approval-storage-contract.d.ts.map +1 -1
- package/dist/testing/agent-execution.d.ts +3 -0
- package/dist/testing/agent-execution.d.ts.map +1 -1
- package/dist/testing/agent-inbox-storage-contract.d.ts +15 -0
- package/dist/testing/agent-inbox-storage-contract.d.ts.map +1 -0
- package/dist/testing/agent-storage-contract.d.ts.map +1 -1
- package/dist/testing/ai-cost-storage-contract.d.ts.map +1 -1
- package/dist/testing/artifact-storage-contract.d.ts.map +1 -1
- package/dist/testing/execution-storage-contract.d.ts.map +1 -1
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +6589 -4627
- package/dist/testing/index.js.map +13 -12
- package/dist/testing/materializer-storage-contract.d.ts.map +1 -1
- package/dist/testing/queues-contract.d.ts.map +1 -1
- package/dist/testing/run-claim-storage-contract.d.ts.map +1 -1
- package/dist/webhooks/connections.d.ts +3 -4
- package/dist/webhooks/connections.d.ts.map +1 -1
- package/dist/webhooks/index.d.ts +1 -1
- package/dist/webhooks/index.d.ts.map +1 -1
- package/dist/webhooks/internal.js +22 -54
- package/dist/webhooks/internal.js.map +3 -3
- package/dist/webhooks/types.d.ts +2 -11
- package/dist/webhooks/types.d.ts.map +1 -1
- package/dist/workers/index.js +66 -13
- package/dist/workers/index.js.map +4 -4
- package/dist/workers/queue-worker.d.ts +5 -0
- package/dist/workers/queue-worker.d.ts.map +1 -1
- package/dist/workers/queued-run-dispatch.d.ts.map +1 -1
- package/dist/workers/worker.d.ts +8 -0
- package/dist/workers/worker.d.ts.map +1 -1
- package/dist/workflows/index.js +50 -48
- package/dist/workflows/index.js.map +1 -1
- package/package.json +12 -1
- package/src/actions/validation.ts +3 -1
- package/src/agents/README.md +6 -2
- package/src/agents/children.ts +6 -0
- package/src/agents/errors.ts +3 -0
- package/src/agents/execution.ts +331 -43
- package/src/agents/ids.ts +5 -0
- package/src/agents/index.ts +22 -4
- package/src/agents/model-routing.ts +25 -9
- package/src/agents/queued-turn.ts +46 -0
- package/src/agents/request.ts +1444 -210
- package/src/agents/run-after-finish.ts +259 -2
- package/src/agents/run-artifacts.ts +3 -93
- package/src/agents/run-events.ts +256 -34
- package/src/agents/run-session-children.ts +13 -2
- package/src/agents/run-session-http.ts +9 -2
- package/src/agents/run-session-serve.ts +2 -8
- package/src/agents/run-session.ts +142 -3
- package/src/agents/run-turn.ts +148 -23
- package/src/agents/streams/index.ts +3 -0
- package/src/agents/streams/internal.ts +12 -0
- package/src/agents/streams/protocol.ts +109 -1
- package/src/agents/streams/steps.ts +131 -0
- package/src/agents/thread-access.ts +57 -2
- package/src/agents/turn-answered.ts +31 -0
- package/src/agents/validation.ts +2 -0
- package/src/artifacts/canvas-display.ts +4 -6
- package/src/artifacts/comments.ts +70 -17
- package/src/artifacts/document-fill.ts +103 -0
- package/src/artifacts/errors.ts +2 -0
- package/src/artifacts/events.ts +4 -1
- package/src/artifacts/execution.ts +265 -31
- package/src/artifacts/frames/assets.ts +42 -7
- package/src/artifacts/frames/document-data.ts +353 -0
- package/src/artifacts/frames/entries.ts +22 -16
- package/src/artifacts/frames/grants.ts +2 -2
- package/src/artifacts/frames/index.ts +3 -0
- package/src/artifacts/frames/kit.ts +102 -0
- package/src/artifacts/frames/protocol.ts +12 -1
- package/src/artifacts/frames/runtime.ts +413 -6
- package/src/artifacts/index.ts +3 -0
- package/src/artifacts/live/blocks.ts +889 -0
- package/src/artifacts/live/board.ts +195 -42
- package/src/artifacts/live/document.ts +170 -5
- package/src/artifacts/live/index.ts +7 -0
- package/src/artifacts/live/page.ts +807 -0
- package/src/artifacts/live/protocol.ts +5 -0
- package/src/artifacts/live/server.ts +2 -2
- package/src/artifacts/live/state.ts +9 -4
- package/src/artifacts/outline.ts +17 -0
- package/src/artifacts/paper.ts +173 -0
- package/src/artifacts/pdf-job.ts +11 -0
- package/src/artifacts/publish/fields.ts +177 -0
- package/src/artifacts/publish/index.ts +6 -1
- package/src/artifacts/publish/merge.ts +28 -15
- package/src/artifacts/publish/pdf.ts +82 -0
- package/src/artifacts/publish/previews.ts +24 -34
- package/src/artifacts/publish/publish.ts +26 -3
- package/src/artifacts/publish/queries.ts +20 -4
- package/src/artifacts/publish/query-answers.ts +14 -3
- package/src/artifacts/publish/validate/document-html.ts +245 -0
- package/src/artifacts/publish/validate/document.ts +34 -3
- package/src/artifacts/queries.ts +59 -13
- package/src/artifacts/run-query.ts +5 -2
- package/src/authorization/event-visibility.ts +13 -0
- package/src/calendar.ts +195 -0
- package/src/connectors/connection-handles.ts +71 -0
- package/src/connectors/connections/authorizations.ts +50 -2
- package/src/connectors/connections/capability.ts +40 -0
- package/src/connectors/connections/events.ts +57 -0
- package/src/connectors/connections/internal.ts +3 -0
- package/src/connectors/connections/runs.ts +5 -0
- package/src/connectors/connections/service.ts +93 -6
- package/src/connectors/execution.ts +35 -8
- package/src/connectors/index.ts +3 -0
- package/src/connectors/service.ts +23 -0
- package/src/connectors/types.ts +29 -1
- package/src/deploy/index.ts +1 -0
- package/src/deploy/services.ts +1 -0
- package/src/deploy/types.ts +30 -2
- package/src/events/definitions.ts +14 -0
- package/src/events/execution.ts +51 -4
- package/src/events/index.ts +8 -0
- package/src/events/outbox-dispatcher.ts +12 -2
- package/src/events/scope.ts +3 -0
- package/src/events/selectors/builder.ts +49 -0
- package/src/events/selectors/index.ts +5 -0
- package/src/events/selectors/predicate.ts +2 -0
- package/src/events/selectors/types.ts +30 -1
- package/src/events/types/artifacts.ts +7 -1
- package/src/events/types/connectors.ts +36 -0
- package/src/events/types/index.ts +7 -0
- package/src/events/types/syncs.ts +4 -0
- package/src/execution/authorization.ts +45 -0
- package/src/execution/authorized-object-reader.ts +33 -5
- package/src/execution/durable.ts +2 -0
- package/src/execution/object-reader-ontology.ts +6 -0
- package/src/execution/request.ts +1 -0
- package/src/execution/scopes.ts +24 -0
- package/src/execution/script.ts +27 -0
- package/src/execution/types.ts +7 -1
- package/src/http/api-routes.ts +33 -0
- package/src/index.ts +39 -4
- package/src/lineage/executors.ts +3 -1
- package/src/materialization/event-envelopes.ts +10 -5
- package/src/materialization/events.ts +2 -0
- package/src/materialization/model.ts +6 -0
- package/src/materializer/README.md +10 -0
- package/src/materializer/projections/replace.ts +42 -1
- package/src/materializer/projections/replacement-plan.ts +44 -4
- package/src/materializer/shared/normalize.ts +4 -0
- package/src/models/audio/runtime.ts +57 -14
- package/src/models/audio/types.ts +20 -0
- package/src/models/index.ts +1 -0
- package/src/objects/query/executor.ts +4 -0
- package/src/objects/query/explain.ts +5 -0
- package/src/objects/query/index.ts +1 -0
- package/src/objects/query/link-query-clearance.ts +4 -1
- package/src/objects/query/links.ts +5 -1
- package/src/objects/query/validate.ts +33 -1
- package/src/objects/sdk/runtime-query-executor.ts +7 -3
- package/src/projections/builders.ts +20 -0
- package/src/projections/index.ts +1 -0
- package/src/projections/registry.ts +1 -0
- package/src/projections/revision.ts +2 -0
- package/src/projections/types.ts +11 -0
- package/src/projections/validation.ts +6 -0
- package/src/queues/in-memory.ts +5 -0
- package/src/queues/index.ts +3 -1
- package/src/queues/types.ts +45 -14
- package/src/runtime/host.ts +125 -11
- package/src/runtime/internal.ts +1 -0
- package/src/runtime/locale.ts +0 -10
- package/src/runtime/resolve-definitions.ts +4 -1
- package/src/runtime/script.ts +62 -0
- package/src/runtime/sixb.ts +15 -5
- package/src/sandboxes/README.md +3 -1
- package/src/sandboxes/auth.ts +32 -4
- package/src/sandboxes/index.ts +15 -1
- package/src/schedules/builders.ts +4 -1
- package/src/schedules/runtime.ts +3 -0
- package/src/schedules/validation.ts +20 -2
- package/src/security/view-conditions.ts +2 -1
- package/src/storage/agents/errors.ts +1 -0
- package/src/storage/agents/in-memory.ts +500 -7
- package/src/storage/agents/index.ts +26 -0
- package/src/storage/agents/provider.ts +454 -15
- package/src/storage/agents/types.ts +315 -3
- package/src/storage/ai-cost/analytics.ts +22 -43
- package/src/storage/ai-cost/types.ts +5 -1
- package/src/storage/artifacts/in-memory.ts +52 -6
- package/src/storage/artifacts/index.ts +2 -0
- package/src/storage/artifacts/record.ts +33 -4
- package/src/storage/artifacts/types.ts +44 -0
- package/src/storage/executions/provider.ts +22 -2
- package/src/storage/executions/types.ts +2 -0
- package/src/storage/executions/validation.ts +27 -0
- package/src/storage/index.ts +29 -0
- package/src/storage/internal.ts +1 -0
- package/src/storage/ontology/in-memory/replacement-plans.ts +22 -0
- package/src/storage/ontology/replacement-plans.ts +6 -0
- package/src/storage/operation-scope.ts +2 -0
- package/src/storage/sync-runs/idempotency.ts +1 -0
- package/src/storage/sync-runs/in-memory.ts +43 -1
- package/src/storage/sync-runs/index.ts +1 -0
- package/src/storage/sync-runs/types.ts +30 -1
- package/src/syncs/accounts.ts +85 -0
- package/src/syncs/builders.ts +18 -1
- package/src/syncs/connections.ts +123 -0
- package/src/syncs/execution.ts +64 -22
- package/src/syncs/index.ts +3 -0
- package/src/syncs/request.ts +81 -23
- package/src/syncs/run-dispatch.ts +69 -7
- package/src/testing/agent-approval-storage-contract.ts +123 -0
- package/src/testing/agent-execution.ts +45 -2
- package/src/testing/agent-inbox-storage-contract.ts +874 -0
- package/src/testing/agent-storage-contract.ts +965 -103
- package/src/testing/ai-cost-storage-contract.ts +80 -0
- package/src/testing/artifact-storage-contract.ts +201 -4
- package/src/testing/execution-storage-contract.ts +31 -0
- package/src/testing/index.ts +5 -0
- package/src/testing/materializer-storage-contract.ts +139 -1
- package/src/testing/queues-contract.ts +22 -0
- package/src/testing/run-claim-storage-contract.ts +116 -0
- package/src/webhooks/connections.ts +9 -50
- package/src/webhooks/index.ts +0 -2
- package/src/webhooks/types.ts +2 -13
- package/src/workers/README.md +4 -1
- package/src/workers/lost-runs.ts +1 -0
- package/src/workers/queue-worker.ts +16 -5
- package/src/workers/queued-run-dispatch.ts +8 -1
- package/src/workers/worker.ts +67 -7
- package/dist/chunk-3z1vxzcm.js +0 -234
- package/dist/chunk-3z1vxzcm.js.map +0 -12
- package/dist/chunk-48c1z8nj.js.map +0 -10
- package/dist/chunk-58geavnf.js +0 -29
- package/dist/chunk-58geavnf.js.map +0 -10
- package/dist/chunk-5a4a52tq.js.map +0 -10
- package/dist/chunk-9nsjjd44.js.map +0 -12
- package/dist/chunk-b9qfh2ya.js.map +0 -11
- package/dist/chunk-eptrvnby.js.map +0 -12
- package/dist/chunk-f6ahf5gf.js.map +0 -13
- package/dist/chunk-gxwy4c3s.js.map +0 -47
- package/dist/chunk-hvbvq7p4.js.map +0 -18
- package/dist/chunk-m2jerfef.js +0 -474
- package/dist/chunk-m2jerfef.js.map +0 -11
- package/dist/chunk-msyevpp3.js.map +0 -22
- package/dist/chunk-n4zzaf6q.js.map +0 -10
- package/dist/chunk-rsrc7vtw.js.map +0 -49
- package/dist/chunk-rsxb14an.js.map +0 -18
- package/dist/chunk-smnt672s.js.map +0 -10
- package/dist/chunk-t0s7b3d1.js.map +0 -13
- package/dist/chunk-td26wjr5.js.map +0 -13
- package/dist/chunk-vzkxqf8h.js.map +0 -23
- package/dist/chunk-wa05txmk.js.map +0 -11
- package/dist/chunk-yv8hv4wq.js.map +0 -10
- package/dist/chunk-yy914zfr.js.map +0 -30
- package/dist/chunk-zeykm8my.js.map +0 -14
- /package/dist/{chunk-stmxh0hv.js.map → chunk-3neam1y5.js.map} +0 -0
- /package/dist/{chunk-p8pgnq8d.js.map → chunk-425ydk65.js.map} +0 -0
- /package/dist/{chunk-p351afzm.js.map → chunk-5sswe5ej.js.map} +0 -0
- /package/dist/{chunk-e0hnbb1m.js.map → chunk-61zptves.js.map} +0 -0
- /package/dist/{chunk-fe6r7yhg.js.map → chunk-92wrka15.js.map} +0 -0
- /package/dist/{chunk-q9nkpr8k.js.map → chunk-9tpmfh3n.js.map} +0 -0
- /package/dist/{chunk-sysnvjce.js.map → chunk-brhp9d97.js.map} +0 -0
- /package/dist/{chunk-8a8k38tz.js.map → chunk-brybqw5k.js.map} +0 -0
- /package/dist/{chunk-855w9nvw.js.map → chunk-cg7cygfj.js.map} +0 -0
- /package/dist/{chunk-r2psmn42.js.map → chunk-eg6xqef7.js.map} +0 -0
- /package/dist/{chunk-7kpqntgw.js.map → chunk-f05994as.js.map} +0 -0
- /package/dist/{chunk-2bn6813a.js.map → chunk-grt2j5vp.js.map} +0 -0
- /package/dist/{chunk-rtdrm592.js.map → chunk-htdzx40w.js.map} +0 -0
- /package/dist/{chunk-bc3y6gff.js.map → chunk-jka26v8c.js.map} +0 -0
- /package/dist/{chunk-6ef4esq4.js.map → chunk-pqj8vff9.js.map} +0 -0
- /package/dist/{chunk-n68vz95m.js.map → chunk-qbd282aa.js.map} +0 -0
- /package/dist/{chunk-r9rtavg9.js.map → chunk-t19wjmnc.js.map} +0 -0
- /package/dist/{chunk-dhkc9b23.js.map → chunk-v8a1qjzp.js.map} +0 -0
- /package/dist/{chunk-8bns0y68.js.map → chunk-xf76csps.js.map} +0 -0
- /package/dist/{chunk-vepea5c3.js.map → chunk-ym1bqd98.js.map} +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/events/errors.ts", "../src/events/definitions.ts", "../src/events/outbox-dispatcher.ts", "../src/events/service.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * Error for event runtime invariants and failures (e.g., unknown event\n * types encountered when converting new events to their stored form).\n */\nexport class EventsError extends Error {\n readonly name = \"EventsError\"\n}\n",
|
|
6
|
+
"import { EventsError } from \"./errors\"\nimport type { ArtifactEvent } from \"./types/artifacts\"\nimport type { ConnectorEvent } from \"./types/connectors\"\nimport type { DatasetEvent } from \"./types/datasets\"\nimport type { DomainEvent, DomainEventDraft } from \"./types/index\"\nimport type { LinkEvent } from \"./types/links\"\nimport type { ObjectEvent } from \"./types/objects\"\nimport type { PipelineEvent } from \"./types/pipelines\"\nimport type { RuleEvent } from \"./types/rules\"\nimport type { ScheduleEvent } from \"./types/schedules\"\nimport type { SyncEvent } from \"./types/syncs\"\nimport type { TelemetryEvent } from \"./types/telemetry\"\nimport type { UserEvent } from \"./types/users\"\nimport type { WorkflowEvent } from \"./types/workflows\"\n\nexport type EventDefinition<Event extends DomainEvent = DomainEvent> = {\n readonly topic: Event[\"topic\"]\n readonly partitionKey: (payload: Event[\"payload\"]) => string\n}\n\nexport type EventDefinitionGroup<Event extends DomainEvent> = {\n readonly [Type in Event[\"type\"]]: EventDefinition<Extract<Event, { type: Type }>>\n}\n\nexport type EventDefinitionMap = {\n readonly [Type in DomainEvent[\"type\"]]: EventDefinition<Extract<DomainEvent, { type: Type }>>\n}\n\nfunction defineEventGroup<Event extends DomainEvent>(\n definitions: EventDefinitionGroup<Event>\n): EventDefinitionGroup<Event> {\n return definitions\n}\n\nexport const OBJECT_EVENT_DEFINITIONS = defineEventGroup<ObjectEvent>({\n \"object.created\": {\n topic: \"objects\",\n partitionKey: (payload) => `${payload.objectTypeId}:${payload.primaryId}`,\n },\n \"object.updated\": {\n topic: \"objects\",\n partitionKey: (payload) => `${payload.objectTypeId}:${payload.primaryId}`,\n },\n \"object.deleted\": {\n topic: \"objects\",\n partitionKey: (payload) => `${payload.objectTypeId}:${payload.primaryId}`,\n },\n})\n\nexport const TELEMETRY_EVENT_DEFINITIONS = defineEventGroup<TelemetryEvent>({\n \"telemetry.appended\": {\n topic: \"telemetry\",\n partitionKey: (payload) => `${payload.objectTypeId}:${payload.objectId}:${payload.propertyId}`,\n },\n})\n\nexport const LINK_EVENT_DEFINITIONS = defineEventGroup<LinkEvent>({\n \"link.created\": {\n topic: \"links\",\n partitionKey: (payload) => `${payload.sourceTypeId}:${payload.sourceId}:${payload.linkId}`,\n },\n \"link.updated\": {\n topic: \"links\",\n partitionKey: (payload) => `${payload.sourceTypeId}:${payload.sourceId}:${payload.linkId}`,\n },\n \"link.deleted\": {\n topic: \"links\",\n partitionKey: (payload) => `${payload.sourceTypeId}:${payload.sourceId}:${payload.linkId}`,\n },\n})\n\nexport const SCHEDULE_EVENT_DEFINITIONS = defineEventGroup<ScheduleEvent>({\n \"schedule.triggered\": {\n topic: \"schedules\",\n partitionKey: (payload) => payload.scheduleId,\n },\n})\n\nexport const RULE_EVENT_DEFINITIONS = defineEventGroup<RuleEvent>({\n \"rule.triggered\": {\n topic: \"rules\",\n partitionKey: (payload) =>\n `${payload.ruleId}:${payload.subject.objectTypeId}:${payload.subject.primaryId}`,\n },\n \"rule.resolved\": {\n topic: \"rules\",\n partitionKey: (payload) =>\n `${payload.ruleId}:${payload.subject.objectTypeId}:${payload.subject.primaryId}`,\n },\n})\n\nexport const SYNC_EVENT_DEFINITIONS = defineEventGroup<SyncEvent>({\n \"sync.run.started\": {\n topic: \"syncs\",\n partitionKey: (payload) => `${payload.syncId}:${payload.runId}`,\n },\n \"sync.run.finished\": {\n topic: \"syncs\",\n partitionKey: (payload) => `${payload.syncId}:${payload.runId}`,\n },\n})\n\nexport const PIPELINE_EVENT_DEFINITIONS = defineEventGroup<PipelineEvent>({\n \"pipeline.run.started\": {\n topic: \"pipelines\",\n partitionKey: (payload) => `${payload.pipelineId}:${payload.runId}`,\n },\n \"pipeline.run.step.started\": {\n topic: \"pipelines\",\n partitionKey: (payload) => `${payload.pipelineId}:${payload.runId}`,\n },\n \"pipeline.run.step.finished\": {\n topic: \"pipelines\",\n partitionKey: (payload) => `${payload.pipelineId}:${payload.runId}`,\n },\n \"pipeline.run.finished\": {\n topic: \"pipelines\",\n partitionKey: (payload) => `${payload.pipelineId}:${payload.runId}`,\n },\n})\n\nexport const WORKFLOW_EVENT_DEFINITIONS = defineEventGroup<WorkflowEvent>({\n \"workflow.run.queued\": {\n topic: \"workflows\",\n partitionKey: (payload) => `${payload.workflowId}:${payload.runId}`,\n },\n \"workflow.run.started\": {\n topic: \"workflows\",\n partitionKey: (payload) => `${payload.workflowId}:${payload.runId}`,\n },\n \"workflow.run.node.started\": {\n topic: \"workflows\",\n partitionKey: (payload) => `${payload.workflowId}:${payload.runId}`,\n },\n \"workflow.run.waiting\": {\n topic: \"workflows\",\n partitionKey: (payload) => `${payload.workflowId}:${payload.runId}`,\n },\n \"workflow.run.node.waiting\": {\n topic: \"workflows\",\n partitionKey: (payload) => `${payload.workflowId}:${payload.runId}`,\n },\n \"workflow.run.node.finished\": {\n topic: \"workflows\",\n partitionKey: (payload) => `${payload.workflowId}:${payload.runId}`,\n },\n \"workflow.run.finished\": {\n topic: \"workflows\",\n partitionKey: (payload) => `${payload.workflowId}:${payload.runId}`,\n },\n \"workflow.intervention.requested\": {\n topic: \"workflows\",\n partitionKey: (payload) => `${payload.workflowId}:${payload.runId}`,\n },\n \"workflow.intervention.submitted\": {\n topic: \"workflows\",\n partitionKey: (payload) => `${payload.workflowId}:${payload.runId}`,\n },\n \"workflow.intervention.cancelled\": {\n topic: \"workflows\",\n partitionKey: (payload) => `${payload.workflowId}:${payload.runId}`,\n },\n \"workflow.intervention.expired\": {\n topic: \"workflows\",\n partitionKey: (payload) => `${payload.workflowId}:${payload.runId}`,\n },\n})\n\nexport const DATASET_EVENT_DEFINITIONS = defineEventGroup<DatasetEvent>({\n \"dataset.version.committed\": {\n topic: \"datasets\",\n partitionKey: (payload) => payload.datasetId,\n },\n})\n\n// One stream per member, so their events stay in order. An invitation has no member yet.\nexport const USER_EVENT_DEFINITIONS = defineEventGroup<UserEvent>({\n \"user.joined\": {\n topic: \"users\",\n partitionKey: (payload) => payload.user.id,\n },\n \"user.suspended\": {\n topic: \"users\",\n partitionKey: (payload) => payload.user.id,\n },\n \"user.reactivated\": {\n topic: \"users\",\n partitionKey: (payload) => payload.user.id,\n },\n \"user.invited\": {\n topic: \"users\",\n partitionKey: (payload) => `invitation:${payload.email}`,\n },\n \"user.profile.updated\": {\n topic: \"users\",\n partitionKey: (payload) => payload.user.id,\n },\n})\n\n// One stream per artifact, so its changes stay in order.\nexport const ARTIFACT_EVENT_DEFINITIONS = defineEventGroup<ArtifactEvent>({\n \"artifact.updated\": {\n topic: \"artifacts\",\n partitionKey: (payload) => payload.artifactId,\n },\n \"artifact.commented\": {\n topic: \"artifacts\",\n partitionKey: (payload) => payload.artifactId,\n },\n})\n\n// One stream per connection, so its connects and disconnects stay in order.\nexport const CONNECTOR_EVENT_DEFINITIONS = defineEventGroup<ConnectorEvent>({\n \"connector.connection.connected\": {\n topic: \"connectors\",\n partitionKey: (payload) => payload.connection.id,\n },\n \"connector.connection.disconnected\": {\n topic: \"connectors\",\n partitionKey: (payload) => payload.connection.id,\n },\n})\n\nexport const EVENT_DEFINITIONS = {\n ...OBJECT_EVENT_DEFINITIONS,\n ...TELEMETRY_EVENT_DEFINITIONS,\n ...LINK_EVENT_DEFINITIONS,\n ...SCHEDULE_EVENT_DEFINITIONS,\n ...SYNC_EVENT_DEFINITIONS,\n ...PIPELINE_EVENT_DEFINITIONS,\n ...WORKFLOW_EVENT_DEFINITIONS,\n ...DATASET_EVENT_DEFINITIONS,\n ...RULE_EVENT_DEFINITIONS,\n ...USER_EVENT_DEFINITIONS,\n ...ARTIFACT_EVENT_DEFINITIONS,\n ...CONNECTOR_EVENT_DEFINITIONS,\n} as const satisfies EventDefinitionMap\n\nexport const EVENT_TYPES = Object.keys(EVENT_DEFINITIONS) as readonly DomainEvent[\"type\"][]\nexport const EVENT_TOPICS = [\n ...new Set(\n Object.values(EVENT_DEFINITIONS).map((definition): DomainEvent[\"topic\"] => definition.topic)\n ),\n] as readonly DomainEvent[\"topic\"][]\n\nexport function isDomainEventType(value: string): value is DomainEvent[\"type\"] {\n return Object.hasOwn(EVENT_DEFINITIONS, value)\n}\n\nexport function isOntologyFactType(\n value: string\n): value is ObjectEvent[\"type\"] | LinkEvent[\"type\"] | TelemetryEvent[\"type\"] {\n return (\n Object.hasOwn(OBJECT_EVENT_DEFINITIONS, value) ||\n Object.hasOwn(LINK_EVENT_DEFINITIONS, value) ||\n Object.hasOwn(TELEMETRY_EVENT_DEFINITIONS, value)\n )\n}\n\nexport function resolveEventStorage(event: DomainEventDraft): {\n readonly topic: DomainEvent[\"topic\"]\n readonly partitionKey: string\n} {\n const eventType = event.type as string\n if (!isDomainEventType(eventType)) {\n throw new EventsError(`Unknown event type: ${eventType}`)\n }\n\n const definition = EVENT_DEFINITIONS[eventType] as EventDefinition\n return {\n topic: definition.topic,\n partitionKey: definition.partitionKey(event.payload),\n }\n}\n",
|
|
7
|
+
"import { randomUUID } from \"node:crypto\"\nimport { createSixbError, serializeSixbFailure, toSixbFailure } from \"../errors/internal\"\nimport type {\n ClaimedOntologyOutboxRow,\n OntologyOutboxFailure,\n OntologyOutboxStorage,\n Storage,\n} from \"../storage\"\nimport { ONTOLOGY_OUTBOX_FAILURE_CODES } from \"../storage/ontology/outbox\"\nimport type { StableEventPublisher } from \"./service\"\n\nconst DEFAULT_BATCH_SIZE = 1_000\nconst DEFAULT_LEASE_DURATION_MS = 30_000\nconst DEFAULT_INITIAL_RETRY_DELAY_MS = 1_000\nconst DEFAULT_MAX_RETRY_DELAY_MS = 5 * 60_000\nconst DEFAULT_RETRY_JITTER_RATIO = 0.2\n// Isolating one poison row from a 1,000-row batch needs up to 21 broker calls: one failed call\n// and, at each split depth, one healthy sibling plus the failing half. Keep bounded headroom for\n// uneven splits while rescheduling unresolved groups once this pass reaches the cap.\nconst DEFAULT_MAX_ISOLATION_ATTEMPTS = 32\nconst DEFAULT_MAX_CLAIMS_PER_DRAIN = 10\nconst DEFAULT_SHUTDOWN_TIMEOUT_MS = 30_000\n\nexport interface OntologyOutboxDeliveryFailure {\n readonly occurredAt: string\n /** Exact failure persisted on every envelope represented by this report. */\n readonly failure: OntologyOutboxFailure\n readonly attempts: number\n readonly eventIds: readonly string[]\n /** Types of the undelivered envelopes. The one field both delivery paths can always report. */\n readonly eventTypes: readonly string[]\n}\n\nexport interface OntologyOutboxDispatcherOptions {\n readonly projectId: string\n readonly storage: Storage\n /** Internal publisher port. It cannot author or mutate persisted ontology facts. */\n readonly events: StableEventPublisher\n readonly batchSize?: number\n readonly leaseDurationMs?: number\n readonly initialRetryDelayMs?: number\n readonly maxRetryDelayMs?: number\n /** Symmetric jitter ratio in the inclusive range 0..1. */\n readonly retryJitterRatio?: number\n /** Maximum broker calls used to isolate poison envelopes in one claimed batch. */\n readonly maxIsolationAttempts?: number\n /** Maximum claimed batches handled by one drain pass. */\n readonly maxClaimsPerDrain?: number\n /** Broker grace period. Shutdown still waits for outstanding storage operations afterward. */\n readonly shutdownTimeoutMs?: number\n readonly now?: () => Date\n readonly random?: () => number\n readonly createLeaseId?: () => string\n readonly onDeliveryFailure?: (error: unknown, failure: OntologyOutboxDeliveryFailure) => void\n readonly onError?: (error: unknown) => void\n}\n\n/**\n * One claimed batch whose unsettled rows remain recoverable during shutdown.\n *\n * Rows leave the set immediately before their lease is settled in storage. If storage settlement\n * itself fails, lease expiry remains the durable recovery path.\n */\nclass ClaimedBatch {\n private readonly unsettled = new Map<string, ClaimedOntologyOutboxRow>()\n private closed = false\n\n constructor(rows: readonly ClaimedOntologyOutboxRow[]) {\n for (const row of rows) this.unsettled.set(row.envelope.id, row)\n }\n\n take(rows: readonly ClaimedOntologyOutboxRow[]): readonly ClaimedOntologyOutboxRow[] {\n if (this.closed || rows.some((row) => !this.unsettled.has(row.envelope.id))) return []\n for (const row of rows) this.unsettled.delete(row.envelope.id)\n return rows\n }\n\n close(): readonly ClaimedOntologyOutboxRow[] {\n this.closed = true\n const rows = [...this.unsettled.values()]\n this.unsettled.clear()\n return rows\n }\n}\n\n/** Lease-based, at-least-once publisher for the authoritative ontology outbox. */\nexport class OntologyOutboxDispatcher {\n private readonly projectId: string\n private readonly storage: Storage\n private readonly events: StableEventPublisher\n private readonly batchSize: number\n private readonly leaseDurationMs: number\n private readonly initialRetryDelayMs: number\n private readonly maxRetryDelayMs: number\n private readonly retryJitterRatio: number\n private readonly maxIsolationAttempts: number\n private readonly maxClaimsPerDrain: number\n private readonly shutdownTimeoutMs: number\n private readonly now: () => Date\n private readonly random: () => number\n private readonly createLeaseId: () => string\n private readonly onDeliveryFailure?: OntologyOutboxDispatcherOptions[\"onDeliveryFailure\"]\n private readonly onError: (error: unknown) => void\n private draining: Promise<void> | null = null\n private pendingDrain: Promise<void> | null = null\n private stopping: Promise<void> | null = null\n private closing = false\n private stopRequested = false\n private relinquished = false\n private readonly forcedStop = new AbortController()\n\n constructor(options: OntologyOutboxDispatcherOptions) {\n assertNonblank(options.projectId, \"projectId\")\n this.projectId = options.projectId\n this.storage = options.storage\n this.events = options.events\n this.batchSize = positiveInteger(options.batchSize ?? DEFAULT_BATCH_SIZE, \"batchSize\")\n this.leaseDurationMs = positiveInteger(\n options.leaseDurationMs ?? DEFAULT_LEASE_DURATION_MS,\n \"leaseDurationMs\"\n )\n this.initialRetryDelayMs = positiveInteger(\n options.initialRetryDelayMs ?? DEFAULT_INITIAL_RETRY_DELAY_MS,\n \"initialRetryDelayMs\"\n )\n this.maxRetryDelayMs = positiveInteger(\n options.maxRetryDelayMs ?? DEFAULT_MAX_RETRY_DELAY_MS,\n \"maxRetryDelayMs\"\n )\n if (this.maxRetryDelayMs < this.initialRetryDelayMs) {\n throw new Error(\n \"[Sixb] Ontology outbox dispatcher maxRetryDelayMs must be at least initialRetryDelayMs.\"\n )\n }\n this.retryJitterRatio = options.retryJitterRatio ?? DEFAULT_RETRY_JITTER_RATIO\n if (\n !Number.isFinite(this.retryJitterRatio) ||\n this.retryJitterRatio < 0 ||\n this.retryJitterRatio > 1\n ) {\n throw new Error(\"[Sixb] Ontology outbox dispatcher retryJitterRatio must be between 0 and 1.\")\n }\n this.maxIsolationAttempts = positiveInteger(\n options.maxIsolationAttempts ?? DEFAULT_MAX_ISOLATION_ATTEMPTS,\n \"maxIsolationAttempts\"\n )\n this.maxClaimsPerDrain = positiveInteger(\n options.maxClaimsPerDrain ?? DEFAULT_MAX_CLAIMS_PER_DRAIN,\n \"maxClaimsPerDrain\"\n )\n this.shutdownTimeoutMs = nonnegativeInteger(\n options.shutdownTimeoutMs ?? DEFAULT_SHUTDOWN_TIMEOUT_MS,\n \"shutdownTimeoutMs\"\n )\n this.now = options.now ?? (() => new Date())\n this.random = options.random ?? Math.random\n this.createLeaseId = options.createLeaseId ?? randomUUID\n this.onDeliveryFailure = options.onDeliveryFailure\n this.onError =\n options.onError ?? ((error) => console.error(\"[Sixb] Outbox dispatcher error:\", error))\n }\n\n /**\n * Publishes one bounded pass of currently due rows without starting an idle polling loop.\n *\n * Concurrent callers share one pass and at most one coalesced follow-up pass. This gives every\n * post-commit notification a chance to observe its own rows without serializing one pass per\n * mutation.\n */\n drain(): Promise<void> {\n if (this.closing || this.stopRequested || this.relinquished) return Promise.resolve()\n if (!this.draining) return this.startDrainPass()\n\n this.pendingDrain ??= settled(this.draining).then(() => {\n this.pendingDrain = null\n if (!this.stopRequested) return this.startDrainPass()\n })\n return this.pendingDrain\n }\n\n /** Starts a tracked, best-effort drain without extending mutation latency. */\n notify(): void {\n if (this.closing || this.stopRequested || this.relinquished) return\n void this.drain().catch((error) => this.reportError(error))\n }\n\n /**\n * Never publish from this process again, not even the final drain on `stop()`: another process\n * owns the broker's subscribers and publishes these rows. The claim is scoped by project only, so\n * a drain here would also publish that process's rows into a broker nobody here listens to.\n */\n relinquish(): void {\n this.relinquished = true\n }\n\n stop(): Promise<void> {\n this.stopping ??= this.stopOnce()\n return this.stopping\n }\n\n private async stopOnce(): Promise<void> {\n if (this.stopRequested) return\n\n // Include one final bounded pass so commits whose notifications were coalesced immediately\n // before shutdown are not left pending merely because the process is stopping.\n const gracefulDrain = this.drain().catch((error) => this.reportError(error))\n this.closing = true\n const finished = await settlesWithin(gracefulDrain, this.shutdownTimeoutMs)\n this.stopRequested = true\n if (!finished) this.forcedStop.abort()\n // Storage operations cannot be cancelled by this contract. A late claim must release its\n // lease, and an acknowledgement already started must finish before callers close storage.\n // publishClaim owns settlement, including forced stop; never race a second cleanup against it.\n await gracefulDrain\n if (this.draining) await settled(this.draining)\n if (this.pendingDrain) await settled(this.pendingDrain)\n }\n\n private startDrainPass(): Promise<void> {\n const pass = this.drainAvailable()\n this.draining = pass\n void settled(pass).then(() => {\n if (this.draining === pass) this.draining = null\n })\n return pass\n }\n\n private async drainAvailable(): Promise<void> {\n for (let claimCount = 0; claimCount < this.maxClaimsPerDrain; claimCount += 1) {\n if (this.stopRequested) return\n const rows = await this.claimBatch()\n if (rows.length === 0) return\n const publishedCount = await this.publishClaim(rows)\n if (this.stopRequested || publishedCount === 0 || rows.length < this.batchSize) return\n // In-memory/SQLite can resolve without I/O. Yield between full batches so catch-up cannot\n // monopolize the event loop, while keeping small post-commit deliveries immediate.\n await new Promise<void>((resolve) => setImmediate(resolve))\n }\n\n // A healthy full slice means more due rows may remain. Reuse the existing coalescing path so\n // catch-up continues without recursion, an idle polling loop, or an unbounded individual pass.\n if (!this.closing && !this.stopRequested) this.notify()\n }\n\n private claimBatch(): Promise<readonly ClaimedOntologyOutboxRow[]> {\n const now = this.now().getTime()\n return this.withOutbox((outbox) =>\n outbox.claim({\n projectId: this.projectId,\n now: new Date(now).toISOString(),\n limit: this.batchSize,\n leaseId: this.createLeaseId(),\n leaseExpiresAt: new Date(now + this.leaseDurationMs).toISOString(),\n })\n )\n }\n\n private async publishClaim(rows: readonly ClaimedOntologyOutboxRow[]): Promise<number> {\n const claim = new ClaimedBatch(rows)\n const failures = new DeliveryFailureAccumulator()\n const pending: PublicationGroup[] = [{ rows }]\n let publishAttempts = 0\n let publishedCount = 0\n\n try {\n while (pending.length > 0 && !this.stopRequested) {\n const group = pending.shift()\n if (!group || group.rows.length === 0) continue\n if (publishAttempts >= this.maxIsolationAttempts && group.failure) {\n await this.rescheduleFailed(claim, group.rows, group.failure.error, failures)\n continue\n }\n publishAttempts += 1\n\n try {\n const publication = await publishUntilStopped(\n this.events.publishEnvelopes(group.rows.map((row) => row.envelope)),\n this.forcedStop.signal\n )\n if (publication === \"stopped\") break\n } catch (error) {\n if (group.rows.length > 1 && publishAttempts < this.maxIsolationAttempts) {\n const middle = Math.ceil(group.rows.length / 2)\n pending.unshift(\n { rows: group.rows.slice(middle), failure: { error } },\n { rows: group.rows.slice(0, middle), failure: { error } }\n )\n continue\n }\n await this.rescheduleFailed(claim, group.rows, error, failures)\n continue\n }\n\n await this.markPublished(claim, group.rows)\n publishedCount += group.rows.length\n }\n } finally {\n if (this.stopRequested) {\n await this.rescheduleClaimedForShutdown(claim.close())\n }\n for (const failure of failures.list()) {\n this.reportDeliveryFailure(failure.error, failure.context)\n }\n }\n return publishedCount\n }\n\n private async markPublished(\n claim: ClaimedBatch,\n rows: readonly ClaimedOntologyOutboxRow[]\n ): Promise<void> {\n const settling = claim.take(rows)\n if (settling.length === 0) return\n try {\n await this.withOutbox((outbox) =>\n outbox.markPublished({\n projectId: this.projectId,\n ids: eventIds(settling),\n leaseId: sharedLeaseId(settling),\n publishedAt: this.now().toISOString(),\n })\n )\n } catch (error) {\n this.reportError(error)\n throw error\n }\n }\n\n private async rescheduleFailed(\n claim: ClaimedBatch,\n rows: readonly ClaimedOntologyOutboxRow[],\n error: unknown,\n failures: DeliveryFailureAccumulator\n ): Promise<void> {\n const settling = claim.take(rows)\n if (settling.length === 0) return\n const failedAt = this.now()\n\n for (const [attempts, attemptRows] of rowsByAttempts(settling)) {\n const deliveryError = createEventDeliveryError(error, attempts)\n const failure = toSixbFailure(deliveryError, {\n allowedCodes: ONTOLOGY_OUTBOX_FAILURE_CODES,\n at: failedAt,\n })\n failures.add(deliveryError, failure, failedAt.toISOString(), attempts, attemptRows)\n try {\n await this.withOutbox((outbox) =>\n outbox.reschedule({\n projectId: this.projectId,\n ids: eventIds(attemptRows),\n leaseId: sharedLeaseId(attemptRows),\n availableAt: new Date(failedAt.getTime() + this.retryDelayMs(attempts)).toISOString(),\n failure,\n })\n )\n } catch (rescheduleError) {\n this.reportError(rescheduleError)\n throw rescheduleError\n }\n }\n }\n\n private retryDelayMs(attempts: number): number {\n const exponent = Math.max(0, Math.min(52, attempts - 1))\n const exponential = Math.min(this.maxRetryDelayMs, this.initialRetryDelayMs * 2 ** exponent)\n const random = this.random()\n const unitRandom = Number.isFinite(random) ? Math.max(0, Math.min(1, random)) : 0.5\n const jitterFactor = 1 - this.retryJitterRatio + 2 * this.retryJitterRatio * unitRandom\n return Math.min(this.maxRetryDelayMs, Math.max(0, Math.round(exponential * jitterFactor)))\n }\n\n private async rescheduleClaimedForShutdown(\n rows: readonly ClaimedOntologyOutboxRow[]\n ): Promise<void> {\n if (rows.length === 0) return\n try {\n await this.withOutbox((outbox) =>\n outbox.reschedule({\n projectId: this.projectId,\n ids: eventIds(rows),\n leaseId: sharedLeaseId(rows),\n availableAt: this.now().toISOString(),\n })\n )\n } catch (error) {\n this.reportError(error)\n }\n }\n\n private withOutbox<T>(run: (outbox: OntologyOutboxStorage) => Promise<T> | T): Promise<T> {\n // Every outbox method owns its atomic provider operation. A framework-wide transaction\n // adds no guarantee here and copies the entire InMemoryStorage state for every batch.\n return Promise.resolve(run(this.storage.ontology.outbox))\n }\n\n private reportDeliveryFailure(error: unknown, failure: OntologyOutboxDeliveryFailure): void {\n try {\n this.onDeliveryFailure?.(error, failure)\n } catch {\n // Failure observers cannot stop delivery or create an unhandled rejection.\n }\n }\n\n private reportError(error: unknown): void {\n try {\n this.onError(error)\n } catch {\n // Error observers cannot stop delivery or create an unhandled rejection.\n }\n }\n}\n\ninterface PublicationGroup {\n readonly rows: readonly ClaimedOntologyOutboxRow[]\n readonly failure?: { readonly error: unknown }\n}\n\ninterface AccumulatedDeliveryFailure {\n readonly error: unknown\n readonly context: OntologyOutboxDeliveryFailure\n}\n\n/** Coalesces bisection failures so one claimed row is reported once per delivery attempt. */\nclass DeliveryFailureAccumulator {\n private readonly groups = new Map<\n string,\n {\n error: unknown\n failure: OntologyOutboxFailure\n occurredAt: string\n attempts: number\n eventIds: Set<string>\n eventTypes: Set<string>\n }\n >()\n\n add(\n error: unknown,\n failure: OntologyOutboxFailure,\n occurredAt: string,\n attempts: number,\n rows: readonly ClaimedOntologyOutboxRow[]\n ): void {\n const key = serializeSixbFailure(failure, ONTOLOGY_OUTBOX_FAILURE_CODES)\n const group = this.groups.get(key) ?? {\n error,\n failure,\n occurredAt,\n attempts,\n eventIds: new Set<string>(),\n eventTypes: new Set<string>(),\n }\n for (const row of rows) {\n group.eventIds.add(row.envelope.id)\n group.eventTypes.add(row.envelope.type)\n }\n this.groups.set(key, group)\n }\n\n list(): readonly AccumulatedDeliveryFailure[] {\n return [...this.groups.values()].map((group) => ({\n error: group.error,\n context: {\n occurredAt: group.occurredAt,\n failure: group.failure,\n attempts: group.attempts,\n eventIds: [...group.eventIds].sort(),\n eventTypes: [...group.eventTypes].sort(),\n },\n }))\n }\n}\n\nfunction positiveInteger(value: number, name: string): number {\n if (!Number.isSafeInteger(value) || value <= 0) {\n throw new Error(`[Sixb] Ontology outbox dispatcher ${name} must be a positive integer.`)\n }\n return value\n}\n\nfunction nonnegativeInteger(value: number, name: string): number {\n if (!Number.isSafeInteger(value) || value < 0) {\n throw new Error(`[Sixb] Ontology outbox dispatcher ${name} must be a nonnegative integer.`)\n }\n return value\n}\n\nfunction assertNonblank(value: string, name: string): void {\n if (value.trim().length === 0) {\n throw new Error(`[Sixb] Ontology outbox dispatcher ${name} must not be blank.`)\n }\n}\n\nfunction rowsByAttempts(\n rows: readonly ClaimedOntologyOutboxRow[]\n): ReadonlyMap<number, readonly ClaimedOntologyOutboxRow[]> {\n const groups = new Map<number, ClaimedOntologyOutboxRow[]>()\n for (const row of rows) {\n const group = groups.get(row.attempts) ?? []\n group.push(row)\n groups.set(row.attempts, group)\n }\n return groups\n}\n\nfunction eventIds(rows: readonly ClaimedOntologyOutboxRow[]): string[] {\n return rows.map((row) => row.envelope.id)\n}\n\nfunction sharedLeaseId(rows: readonly ClaimedOntologyOutboxRow[]): string {\n const leaseId = rows[0]?.leaseId\n if (!leaseId || rows.some((row) => row.leaseId !== leaseId)) {\n throw new Error(\"[Sixb] Claimed ontology outbox batch does not share one lease.\")\n }\n return leaseId\n}\n\nfunction createEventDeliveryError(cause: unknown, attempts: number) {\n return createSixbError(\n \"event.delivery_failed\",\n \"[Sixb] Could not deliver persisted ontology events.\",\n {\n cause,\n details: {\n attempts,\n },\n }\n )\n}\n\nasync function publishUntilStopped(\n publication: Promise<unknown>,\n signal: AbortSignal\n): Promise<\"published\" | \"stopped\"> {\n if (signal.aborted) return \"stopped\"\n\n return new Promise((resolve, reject) => {\n const stop = () => finish(() => resolve(\"stopped\"))\n const finish = (settle: () => void) => {\n signal.removeEventListener(\"abort\", stop)\n settle()\n }\n signal.addEventListener(\"abort\", stop, { once: true })\n void publication.then(\n () => finish(() => resolve(\"published\")),\n (error) => finish(() => reject(error))\n )\n })\n}\n\n/** Awaits a pass without adopting its failure, so one failed drain cannot reject the next. */\nfunction settled(promise: Promise<void>): Promise<void> {\n return promise.then(\n () => undefined,\n () => undefined\n )\n}\n\nasync function settlesWithin(promise: Promise<void>, timeoutMs: number): Promise<boolean> {\n let timer: ReturnType<typeof setTimeout> | undefined\n const timedOut = new Promise<false>((resolve) => {\n timer = setTimeout(() => resolve(false), timeoutMs)\n })\n const result = await Promise.race([\n promise.then(\n () => true as const,\n () => true as const\n ),\n timedOut,\n ])\n if (timer !== undefined) clearTimeout(timer)\n return result\n}\n",
|
|
8
|
+
"import { randomUUID } from \"node:crypto\"\nimport type { Broker, BrokerCursor, BrokerRecord, BrokerStreamDefinition } from \"../broker\"\nimport { type ErrorReporter, SixbErrorReporter } from \"../error-reporting/reporter\"\nimport { reportEventDeliveryFailure } from \"../error-reporting/reports\"\nimport { getInvalidJsonValueReason, type JsonValue } from \"../json\"\nimport { objectPartitionKey } from \"../materialization/event-envelopes\"\nimport type { OntologyMaterializationEvent } from \"../materialization/events\"\nimport {\n EVENT_DEFINITIONS,\n EVENT_TYPES,\n isDomainEventType,\n isOntologyFactType,\n resolveEventStorage,\n} from \"./definitions\"\nimport { EventsError } from \"./errors\"\nimport type {\n DomainEvent,\n EventDraft,\n StoredAuthorableEvent,\n StoredDomainEvent,\n StoredObjectDeletedEvent,\n StoredObjectMutationEvent,\n} from \"./types\"\n\n// Keep domain events as a short recent log. This is 2 days in milliseconds.\nexport const DEFAULT_EVENTS_RETENTION_MS = 2 * 24 * 60 * 60 * 1000\n\nexport const EVENTS_STREAM: BrokerStreamDefinition = {\n id: \"__events\",\n retention: { maxAgeMs: DEFAULT_EVENTS_RETENTION_MS },\n}\n\nexport interface DomainEventServiceOptions {\n readonly projectId: string\n readonly broker: Broker\n readonly stream?: BrokerStreamDefinition\n /** Internal failure reporter. Defaults to the console when this runtime is used standalone. */\n readonly errorReporter?: ErrorReporter\n}\n\nexport interface EventsAppendInput {\n readonly correlationId?: string\n readonly causationId?: string\n readonly events: readonly EventDraft[]\n}\n\nexport interface EventsEmitOptions {\n /** Framework component that initiated the emission, such as `SixbPipelineWorker`. */\n readonly source: string\n}\n\nexport interface EventsReadInput {\n readonly afterCursor?: string\n readonly limit?: number\n readonly topics?: readonly DomainEvent[\"topic\"][]\n readonly types?: readonly DomainEvent[\"type\"][]\n}\n\nexport interface EventsSubscribeInput {\n /** Defaults to live-only delivery. `afterCursor` takes precedence when provided. */\n readonly from?: \"latest\" | \"earliest\"\n readonly afterCursor?: BrokerCursor\n readonly types?: readonly DomainEvent[\"type\"][]\n}\n\nexport interface ObjectEventBeforeInput {\n /** The event of the log to look before. */\n readonly cursor: string\n readonly objectTypeId: string\n readonly primaryId: string\n}\n\nconst OBJECT_EVENT_TYPES = EVENT_TYPES.filter((type) => EVENT_DEFINITIONS[type].topic === \"objects\")\n\n/** Exact, already-identified materialization event persisted before broker publication. @internal */\nexport type StableEventEnvelope = OntologyMaterializationEvent\n\n/** Public domain-event log. Stable ontology envelopes are intentionally absent. */\nexport interface DomainEventLog {\n append(input: EventsAppendInput): Promise<readonly StoredDomainEvent[]>\n /**\n * Append events after the work that produced them has already succeeded.\n *\n * Contract: this never rejects. The caller's unit of work is done, so a delivery failure must not\n * turn a successful run into a failed one — the implementation escalates the loss instead.\n */\n emit(input: EventsAppendInput, options: EventsEmitOptions): Promise<void>\n read(input?: EventsReadInput): Promise<readonly StoredDomainEvent[]>\n latestCursor(): Promise<string | undefined>\n subscribe(\n input: EventsSubscribeInput,\n handler: (events: readonly StoredDomainEvent[]) => unknown\n ): Promise<() => void>\n}\n\n/** Internal port that reads the log for what an object held when another event happened. */\nexport interface ObjectEventHistory {\n /**\n * The last event of an object before an event of the log, which carries the state the object\n * held when that event happened. Undefined when the log keeps none.\n */\n lastObjectEventBefore(\n input: ObjectEventBeforeInput\n ): Promise<StoredObjectMutationEvent | StoredObjectDeletedEvent | undefined>\n}\n\n/** Narrow internal port used to publish envelopes already persisted in the ontology outbox. */\nexport interface StableEventPublisher {\n publishEnvelopes(envelopes: readonly StableEventEnvelope[]): Promise<readonly StoredDomainEvent[]>\n}\n\n/** Project-scoped domain event service backed by the shared broker provider. */\nexport class DomainEventService\n implements DomainEventLog, ObjectEventHistory, StableEventPublisher\n{\n private readonly projectId: string\n private readonly broker: Broker\n private readonly stream: BrokerStreamDefinition\n private readonly errorReporter: ErrorReporter\n private readonly ensureStreamPromises = new Map<string, Promise<void>>()\n\n constructor(options: DomainEventServiceOptions) {\n this.projectId = options.projectId\n this.broker = options.broker\n this.stream = options.stream ?? EVENTS_STREAM\n this.errorReporter = options.errorReporter ?? new SixbErrorReporter()\n }\n\n /**\n * Append events after the work that produced them has already succeeded.\n *\n * Unlike `append`, this never rejects: the caller's unit of work is done, so a broker outage must not\n * turn a successful run into a failed one. It is not a swallow either — every event Sixb publishes is\n * a potential trigger edge (a rule's `.when()`, an event schedule, a workflow's wait node), so a lost\n * batch is a handler that silently never runs. The loss is escalated to `onError` as\n * `event.delivery.failed`, or to the default console reporter when no handler was configured.\n *\n * Framework emit sites want this. Application code wants `append`, which reports failure to the\n * caller and returns the stored envelopes.\n */\n async emit(input: EventsAppendInput, _options: EventsEmitOptions): Promise<void> {\n try {\n await this.append(input)\n } catch (error) {\n try {\n const eventTypes = input.events.map((event) => event.type)\n reportEventDeliveryFailure(this.errorReporter, error, {\n projectId: this.projectId,\n eventTypes,\n })\n } catch {\n // The contract above is absolute, so escalation cannot be the thing that breaks it.\n }\n }\n }\n\n async append(input: EventsAppendInput): Promise<readonly StoredDomainEvent[]> {\n if (input.events.length === 0) {\n return []\n }\n for (const event of input.events) {\n if (isOntologyFactType(event.type)) {\n throw new EventsError(\n `Event type '${event.type}' is an authoritative ontology fact and cannot be appended directly.`\n )\n }\n }\n\n const payloads = input.events.map((event) =>\n toStoredEventPayload({\n projectId: this.projectId,\n correlationId: input.correlationId,\n causationId: input.causationId,\n event,\n })\n )\n\n await this.ensureStream()\n const records = await this.broker.append({\n projectId: this.projectId,\n streamId: this.stream.id,\n records: payloads.map((payload) => ({\n name: payload.type,\n key: payload.partitionKey,\n payload: toBrokerRecordPayload(payload),\n idempotencyKey: payload.idempotencyKey,\n })),\n })\n\n if (records.length !== payloads.length) {\n throw new EventsError(\n `Broker returned ${records.length} record(s) for ${payloads.length} appended event(s).`\n )\n }\n\n return records.map(hydrateEventRecord)\n }\n\n /** Publishes persisted envelopes without changing their stable event identity. @internal */\n async publishEnvelopes(\n envelopes: readonly StableEventEnvelope[]\n ): Promise<readonly StoredDomainEvent[]> {\n if (envelopes.length === 0) {\n return []\n }\n\n for (const envelope of envelopes) {\n if (envelope.projectId !== this.projectId) {\n throw new EventsError(\n `Event '${envelope.id}' belongs to project '${envelope.projectId}', not '${this.projectId}'.`\n )\n }\n if (!isDomainEventType(envelope.type)) {\n throw new EventsError(`Event '${envelope.id}' has unknown event type.`)\n }\n if (EVENT_DEFINITIONS[envelope.type].topic !== envelope.topic) {\n throw new EventsError(\n `Event '${envelope.id}' topic '${envelope.topic}' does not match type '${envelope.type}'.`\n )\n }\n }\n\n await this.ensureStream()\n const records = await this.broker.append({\n projectId: this.projectId,\n streamId: this.stream.id,\n records: envelopes.map((envelope) => ({\n name: envelope.type,\n key: envelope.partitionKey,\n payload: toBrokerRecordPayload(envelope),\n idempotencyKey: envelope.id,\n })),\n })\n\n if (records.length !== envelopes.length) {\n throw new EventsError(\n `Broker returned ${records.length} record(s) for ${envelopes.length} published event(s).`\n )\n }\n\n return records.map(hydrateEventRecord)\n }\n\n async read(input: EventsReadInput = {}): Promise<readonly StoredDomainEvent[]> {\n if (input.limit !== undefined && input.limit <= 0) {\n return []\n }\n\n const names = resolveTypeFilter(input)\n if (names && names.length === 0) {\n return []\n }\n\n await this.ensureStream()\n const page = await this.broker.read({\n projectId: this.projectId,\n streamId: this.stream.id,\n afterCursor: input.afterCursor,\n limit: input.limit,\n names,\n })\n\n return page.records.map(hydrateEventRecord)\n }\n\n async lastObjectEventBefore(\n input: ObjectEventBeforeInput\n ): Promise<StoredObjectMutationEvent | StoredObjectDeletedEvent | undefined> {\n await this.ensureStream()\n const page = await this.broker.tail({\n projectId: this.projectId,\n streamId: this.stream.id,\n beforeCursor: input.cursor,\n limit: 1,\n names: OBJECT_EVENT_TYPES,\n keys: [objectPartitionKey(input)],\n })\n\n const [event] = page.records.map(hydrateEventRecord)\n if (event?.topic !== \"objects\") return undefined\n\n // A key joins two ids with a colon, so another object could share it: that one says nothing.\n const { objectTypeId, primaryId } = event.payload\n if (objectTypeId !== input.objectTypeId || primaryId !== input.primaryId) return undefined\n\n return event\n }\n\n async latestCursor(): Promise<string | undefined> {\n await this.ensureStream()\n return this.broker.latestCursor({\n projectId: this.projectId,\n streamId: this.stream.id,\n })\n }\n\n async subscribe(\n input: EventsSubscribeInput,\n handler: (events: readonly StoredDomainEvent[]) => unknown\n ): Promise<() => void> {\n await this.ensureStream()\n return this.broker.subscribe(\n {\n projectId: this.projectId,\n streamId: this.stream.id,\n from: input.from,\n afterCursor: input.afterCursor,\n names: input.types && input.types.length > 0 ? input.types : EVENT_TYPES,\n },\n (records) => {\n const events = records.map(hydrateEventRecord)\n if (events.length === 0) {\n return\n }\n\n try {\n return handler(events)\n } catch {\n // Preserve fire-and-forget subscriber semantics.\n }\n }\n )\n }\n\n private ensureStream(): Promise<void> {\n const key = `${this.projectId}\\0${this.stream.id}`\n let promise = this.ensureStreamPromises.get(key)\n if (!promise) {\n promise = this.broker\n .ensureStream({\n projectId: this.projectId,\n stream: this.stream,\n })\n .catch((error) => {\n if (this.ensureStreamPromises.get(key) === promise) {\n this.ensureStreamPromises.delete(key)\n }\n throw error\n })\n this.ensureStreamPromises.set(key, promise)\n }\n return promise\n }\n}\n\nexport function createDomainEventService(options: DomainEventServiceOptions): DomainEventService {\n return new DomainEventService(options)\n}\n\ntype StoredEventPayload = Omit<StoredAuthorableEvent, \"cursor\">\n\nfunction toStoredEventPayload(params: {\n projectId: string\n correlationId?: string\n causationId?: string\n event: EventDraft\n}): StoredEventPayload {\n const storage = resolveEventStorage(params.event)\n const payload: Record<string, unknown> = {\n id: randomUUID(),\n schemaVersion: 1,\n projectId: params.projectId,\n occurredAt: params.event.occurredAt ?? new Date().toISOString(),\n type: params.event.type,\n topic: storage.topic,\n partitionKey: storage.partitionKey,\n payload: params.event.payload,\n }\n\n setIfDefined(payload, \"correlationId\", params.correlationId)\n setIfDefined(payload, \"causationId\", params.causationId)\n setIfDefined(payload, \"idempotencyKey\", params.event.idempotencyKey)\n setIfDefined(payload, \"origin\", params.event.origin)\n setIfDefined(payload, \"metadata\", params.event.metadata)\n\n return payload as StoredEventPayload\n}\n\nfunction toBrokerRecordPayload(payload: StoredEventPayload | StableEventEnvelope): JsonValue {\n const reason = getInvalidJsonValueReason(payload, `event '${payload.type}' payload`)\n if (reason) {\n throw new EventsError(`Event '${payload.type}' cannot be stored in broker; ${reason}`)\n }\n\n return payload as unknown as JsonValue\n}\n\nfunction hydrateEventRecord(record: BrokerRecord): StoredDomainEvent {\n const payload = record.payload\n if (!isObjectRecord(payload)) {\n throw new EventsError(`Broker record at cursor '${record.cursor}' is not an event object.`)\n }\n\n const eventType = payload.type\n if (typeof eventType !== \"string\" || !isDomainEventType(eventType)) {\n throw new EventsError(`Broker record at cursor '${record.cursor}' has unknown event type.`)\n }\n\n if (record.name !== undefined && record.name !== eventType) {\n throw new EventsError(\n `Broker record name '${record.name}' does not match event type '${eventType}'.`\n )\n }\n\n return {\n ...payload,\n cursor: record.cursor,\n } as StoredDomainEvent\n}\n\nfunction resolveTypeFilter(input: {\n topics?: readonly DomainEvent[\"topic\"][]\n types?: readonly DomainEvent[\"type\"][]\n}): readonly DomainEvent[\"type\"][] {\n const topicTypes =\n input.topics && input.topics.length > 0\n ? EVENT_TYPES.filter((type) => input.topics?.includes(EVENT_DEFINITIONS[type].topic))\n : undefined\n\n if (!topicTypes) {\n return input.types && input.types.length > 0 ? input.types : EVENT_TYPES\n }\n\n if (!input.types || input.types.length === 0) {\n return topicTypes\n }\n\n const requestedTypes = new Set(input.types)\n return topicTypes.filter((type) => requestedTypes.has(type))\n}\n\nfunction isObjectRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null\n}\n\nfunction setIfDefined(target: Record<string, unknown>, key: string, value: unknown): void {\n if (value !== undefined) {\n target[key] = value\n }\n}\n"
|
|
9
|
+
],
|
|
10
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;AAIO,MAAM,qBAAoB,MAAM;AAAA,EAC5B,OAAO;AAClB;;;ACsBA,SAAS,gBAA2C,CAClD,aAC6B;AAAA,EAC7B,OAAO;AAAA;AAGF,IAAM,4BAA2B,iBAA8B;AAAA,EACpE,kBAAkB;AAAA,IAChB,OAAO;AAAA,IACP,cAAc,CAAC,YAAY,GAAG,QAAQ,gBAAgB,QAAQ;AAAA,EAChE;AAAA,EACA,kBAAkB;AAAA,IAChB,OAAO;AAAA,IACP,cAAc,CAAC,YAAY,GAAG,QAAQ,gBAAgB,QAAQ;AAAA,EAChE;AAAA,EACA,kBAAkB;AAAA,IAChB,OAAO;AAAA,IACP,cAAc,CAAC,YAAY,GAAG,QAAQ,gBAAgB,QAAQ;AAAA,EAChE;AACF,CAAC;AAEM,IAAM,+BAA8B,iBAAi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
|
|
13
|
+
}
|
|
@@ -77,7 +77,7 @@ async function reuseRun(input, existing) {
|
|
|
77
77
|
return { publish: true, run, queuedAt, created: false };
|
|
78
78
|
}
|
|
79
79
|
async function assertReusable(input, run, storage) {
|
|
80
|
-
if (!input.primitive.matches(run)) {
|
|
80
|
+
if (!input.automatic && !input.primitive.matches(run)) {
|
|
81
81
|
throw new input.primitive.RunError(`[Sixb] ${input.primitive.label} run '${run.id}' already exists with a different request payload.`);
|
|
82
82
|
}
|
|
83
83
|
await input.validateExistingRun?.(run, storage);
|
|
@@ -136,4 +136,4 @@ function createRunId(input) {
|
|
|
136
136
|
|
|
137
137
|
export { dispatchQueuedRun, hasAutomaticRunProvenance };
|
|
138
138
|
|
|
139
|
-
//# debugId=
|
|
139
|
+
//# debugId=06B7F51E4E08782964756E2164756E21
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/workers/queued-run-dispatch.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import { randomUUID } from \"node:crypto\"\nimport { isDeepStrictEqual } from \"node:util\"\nimport { createSixbError, type SixbCodedError } from \"../errors/internal\"\nimport type { CreateExecutionInput, ExecutionRecord, Storage } from \"../storage\"\nimport { joinJobId } from \"./job-ids\"\n\n/** A durable run that waits for a worker: the part of a Sync or Pipeline run dispatch reads. */\nexport interface QueuedRun {\n readonly id: string\n readonly executionId: string\n readonly status: string\n readonly queuedAt: Date\n readonly error?: { readonly code: string; readonly retryable: boolean }\n}\n\nexport interface QueuedRunStore<TRun extends QueuedRun> {\n getById(params: { projectId: string; id: string }): Promise<TRun | null>\n /** The oldest run of this definition that has not started, whatever its request. */\n oldestQueued(): Promise<TRun | undefined>\n queue(run: {\n readonly id: string\n readonly executionId: string\n readonly queuedAt: Date\n }): Promise<TRun>\n /** Queue again a run whose job could not be published. */\n requeue(run: TRun, queuedAt: Date): Promise<TRun>\n}\n\nexport type RunDispatchProvenance =\n | { readonly type: \"schedule\" | \"event\"; readonly eventId: string }\n | { readonly type: \"datasetVersion\"; readonly datasetId: string; readonly versionId: string }\n\n/** What a primitive supplies to run dispatch: everything else about admission is shared. */\nexport interface QueuedRunPrimitive<TRun extends QueuedRun, TResult> {\n /** Capitalized, as error messages name it. */\n readonly label: string\n /** Details that identify the primitive in a failure, beside the run id. */\n failureDetails(run: TRun): Readonly<Record<string, string>>\n\n /** The primitive's runs, in this storage or in one transaction of it. */\n store(storage: Storage): QueuedRunStore<TRun>\n /** A run of this definition, with this same request, could serve as this one. */\n matches(run: TRun): boolean\n\n enqueue(job: {\n readonly id: string\n readonly runId: string\n readonly metadata?: Readonly<Record<string, string>>\n }): Promise<{ readonly id: string } | undefined>\n /** Record and report that the run's job could not be published. */\n failPublication(run: TRun, failure: SixbCodedError, cause: unknown, at: Date): Promise<void>\n\n result(run: TRun, publication?: RunPublication): TResult\n\n /** Says a run record cannot serve this request. */\n readonly RunError: new (\n message: string\n ) => Error\n /** Says the request itself is malformed. */\n readonly RequestError: new (\n message: string\n ) => Error\n}\n\nexport interface RunPublication {\n readonly queuedAt: Date\n readonly jobId: string\n readonly created: boolean\n}\n\nexport interface DispatchQueuedRunInput<TRun extends QueuedRun, TResult> {\n readonly primitive: QueuedRunPrimitive<TRun, TResult>\n readonly projectId: string\n readonly storage: Storage\n readonly runId?: string\n readonly metadata?: Readonly<Record<string, string>>\n readonly createExecution: (executionId: string, runId: string) => Promise<CreateExecutionInput>\n readonly validateExistingRun?: (run: TRun, storage: Storage) => Promise<void>\n /** Return a matching run that has not started yet instead of queueing another one. */\n readonly joinQueuedRun?: boolean\n /**\n * A trigger, not a caller. It republishes a queued run it finds, and leaves its publication\n * uncertain: its consumer retains the batch and retries, where a caller is told it failed.\n */\n readonly automatic?: boolean\n}\n\ntype PersistedRun<TRun extends QueuedRun> =\n | { readonly publish: false; readonly run: TRun }\n | {\n readonly publish: true\n readonly run: TRun\n readonly queuedAt: Date\n readonly created: boolean\n /** Defaults to the run id. A trigger that joins a run publishes its own job for it. */\n readonly jobId?: string\n }\n\n/** Persist an execution and a queued run before publishing the run's queue job. */\nexport async function dispatchQueuedRun<TRun extends QueuedRun, TResult>(\n input: DispatchQueuedRunInput<TRun, TResult>\n): Promise<TResult> {\n const runId = createRunId(input)\n\n let persisted = await persistRun(input, runId)\n if (!persisted.publish && input.automatic && persisted.run.status === \"queued\") {\n persisted = await reuseRun(input, persisted.run)\n }\n\n if (!persisted.publish) return input.primitive.result(persisted.run)\n return publishRun(input, persisted)\n}\n\nasync function persistRun<TRun extends QueuedRun, TResult>(\n input: DispatchQueuedRunInput<TRun, TResult>,\n runId: string\n): Promise<PersistedRun<TRun>> {\n const { primitive } = input\n\n const store = primitive.store(input.storage)\n\n const existing = await store.getById({ projectId: input.projectId, id: runId })\n if (existing) return reuseRun(input, existing)\n\n const execution = await input.createExecution(`exec_${randomUUID()}`, runId)\n const queuedAt = new Date()\n\n try {\n return await input.storage.transaction(\n (tx) => persistRunInTransaction(input, tx, runId, execution, queuedAt),\n { isolation: \"serializable\" }\n )\n } catch (error) {\n if (!(error instanceof primitive.RunError)) throw error\n\n const raced = await store.getById({ projectId: input.projectId, id: runId })\n if (!raced) throw error\n\n await assertReusable(input, raced, input.storage)\n return { publish: false, run: raced }\n }\n}\n\nasync function persistRunInTransaction<TRun extends QueuedRun, TResult>(\n input: DispatchQueuedRunInput<TRun, TResult>,\n tx: Storage,\n runId: string,\n execution: CreateExecutionInput,\n queuedAt: Date\n): Promise<PersistedRun<TRun>> {\n const store = input.primitive.store(tx)\n\n const raced = await store.getById({ projectId: input.projectId, id: runId })\n if (raced) {\n await assertReusable(input, raced, tx)\n return { publish: false, run: raced }\n }\n\n if (input.joinQueuedRun) {\n const waiting = await store.oldestQueued()\n if (waiting && input.primitive.matches(waiting)) {\n return {\n publish: true,\n run: waiting,\n queuedAt: waiting.queuedAt,\n created: false,\n // The run's own job may be gone, so a joining trigger brings one that can start the run.\n jobId: joinJobId(waiting.id),\n }\n }\n }\n\n await tx.executions.create(execution)\n const run = await store.queue({ id: runId, executionId: execution.id, queuedAt })\n return { publish: true, run, queuedAt, created: true }\n}\n\nasync function reuseRun<TRun extends QueuedRun, TResult>(\n input: DispatchQueuedRunInput<TRun, TResult>,\n existing: TRun\n): Promise<PersistedRun<TRun>> {\n await assertReusable(input, existing, input.storage)\n\n if (input.automatic && existing.status === \"queued\") {\n await requireExecution(input, existing)\n return { publish: true, run: existing, queuedAt: existing.queuedAt, created: false }\n }\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 await requireExecution(input, existing)\n\n const queuedAt = new Date()\n const run = await input.primitive.store(input.storage).requeue(existing, queuedAt)\n return { publish: true, run, queuedAt, created: false }\n}\n\nasync function assertReusable<TRun extends QueuedRun, TResult>(\n input: DispatchQueuedRunInput<TRun, TResult>,\n run: TRun,\n storage: Storage\n): Promise<void> {\n if (!input.primitive.matches(run)) {\n throw new input.primitive.RunError(\n `[Sixb] ${input.primitive.label} run '${run.id}' already exists with a different request payload.`\n )\n }\n\n await input.validateExistingRun?.(run, storage)\n}\n\nasync function requireExecution<TRun extends QueuedRun, TResult>(\n input: DispatchQueuedRunInput<TRun, TResult>,\n run: TRun\n): Promise<void> {\n const execution = await input.storage.executions.getById({\n projectId: input.projectId,\n id: run.executionId,\n })\n if (!execution) {\n throw new input.primitive.RunError(\n `[Sixb] Execution '${run.executionId}' for ${input.primitive.label} run '${run.id}' was not found.`\n )\n }\n}\n\nasync function publishRun<TRun extends QueuedRun, TResult>(\n input: DispatchQueuedRunInput<TRun, TResult>,\n persisted: Extract<PersistedRun<TRun>, { readonly publish: true }>\n): Promise<TResult> {\n const { primitive } = input\n const jobId = persisted.jobId ?? persisted.run.id\n\n try {\n const job = await primitive.enqueue({\n id: jobId,\n runId: persisted.run.id,\n ...(input.metadata === undefined ? {} : { metadata: input.metadata }),\n })\n if (!job || job.id !== jobId) {\n throw new primitive.RunError(\n `[Sixb] Queue did not acknowledge ${primitive.label} run '${persisted.run.id}'.`\n )\n }\n\n return primitive.result(persisted.run, {\n queuedAt: persisted.queuedAt,\n 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.automatic) throw error\n\n await primitive.failPublication(\n persisted.run,\n createSixbError(\n \"queue.enqueue_failed\",\n `[Sixb] Could not enqueue ${primitive.label} run '${persisted.run.id}'.`,\n {\n cause: error,\n details: {\n ...primitive.failureDetails(persisted.run),\n runId: persisted.run.id,\n phase: \"enqueue\",\n },\n }\n ),\n error,\n new Date()\n )\n throw error\n }\n}\n\n/** Whether an execution is the one this automatic trigger would have created for its run. */\nexport function hasAutomaticRunProvenance(\n execution: ExecutionRecord | null,\n input: { readonly source: RunDispatchProvenance; readonly correlationId: string }\n): boolean {\n return (\n execution !== null &&\n isDeepStrictEqual(execution.source, input.source) &&\n execution.correlationId === input.correlationId &&\n execution.requestedBy === undefined\n )\n}\n\nfunction createRunId<TRun extends QueuedRun, TResult>(\n input: DispatchQueuedRunInput<TRun, TResult>\n): string {\n if (input.runId === undefined) return `run_${randomUUID()}`\n\n if (!input.runId.trim()) {\n throw new input.primitive.RequestError(\n `[Sixb] ${input.primitive.label} run id must not be empty`\n )\n }\n\n return input.runId\n}\n"
|
|
5
|
+
"import { randomUUID } from \"node:crypto\"\nimport { isDeepStrictEqual } from \"node:util\"\nimport { createSixbError, type SixbCodedError } from \"../errors/internal\"\nimport type { CreateExecutionInput, ExecutionRecord, Storage } from \"../storage\"\nimport { joinJobId } from \"./job-ids\"\n\n/** A durable run that waits for a worker: the part of a Sync or Pipeline run dispatch reads. */\nexport interface QueuedRun {\n readonly id: string\n readonly executionId: string\n readonly status: string\n readonly queuedAt: Date\n readonly error?: { readonly code: string; readonly retryable: boolean }\n}\n\nexport interface QueuedRunStore<TRun extends QueuedRun> {\n getById(params: { projectId: string; id: string }): Promise<TRun | null>\n /** The oldest run of this definition that has not started, whatever its request. */\n oldestQueued(): Promise<TRun | undefined>\n queue(run: {\n readonly id: string\n readonly executionId: string\n readonly queuedAt: Date\n }): Promise<TRun>\n /** Queue again a run whose job could not be published. */\n requeue(run: TRun, queuedAt: Date): Promise<TRun>\n}\n\nexport type RunDispatchProvenance =\n | { readonly type: \"schedule\" | \"event\"; readonly eventId: string }\n | { readonly type: \"datasetVersion\"; readonly datasetId: string; readonly versionId: string }\n\n/** What a primitive supplies to run dispatch: everything else about admission is shared. */\nexport interface QueuedRunPrimitive<TRun extends QueuedRun, TResult> {\n /** Capitalized, as error messages name it. */\n readonly label: string\n /** Details that identify the primitive in a failure, beside the run id. */\n failureDetails(run: TRun): Readonly<Record<string, string>>\n\n /** The primitive's runs, in this storage or in one transaction of it. */\n store(storage: Storage): QueuedRunStore<TRun>\n /** A run of this definition, with this same request, could serve as this one. */\n matches(run: TRun): boolean\n\n enqueue(job: {\n readonly id: string\n readonly runId: string\n readonly metadata?: Readonly<Record<string, string>>\n }): Promise<{ readonly id: string } | undefined>\n /** Record and report that the run's job could not be published. */\n failPublication(run: TRun, failure: SixbCodedError, cause: unknown, at: Date): Promise<void>\n\n result(run: TRun, publication?: RunPublication): TResult\n\n /** Says a run record cannot serve this request. */\n readonly RunError: new (\n message: string\n ) => Error\n /** Says the request itself is malformed. */\n readonly RequestError: new (\n message: string\n ) => Error\n}\n\nexport interface RunPublication {\n readonly queuedAt: Date\n readonly jobId: string\n readonly created: boolean\n}\n\nexport interface DispatchQueuedRunInput<TRun extends QueuedRun, TResult> {\n readonly primitive: QueuedRunPrimitive<TRun, TResult>\n readonly projectId: string\n readonly storage: Storage\n readonly runId?: string\n readonly metadata?: Readonly<Record<string, string>>\n readonly createExecution: (executionId: string, runId: string) => Promise<CreateExecutionInput>\n readonly validateExistingRun?: (run: TRun, storage: Storage) => Promise<void>\n /** Return a matching run that has not started yet instead of queueing another one. */\n readonly joinQueuedRun?: boolean\n /**\n * A trigger, not a caller. It republishes a queued run it finds, and leaves its publication\n * uncertain: its consumer retains the batch and retries, where a caller is told it failed.\n */\n readonly automatic?: boolean\n}\n\ntype PersistedRun<TRun extends QueuedRun> =\n | { readonly publish: false; readonly run: TRun }\n | {\n readonly publish: true\n readonly run: TRun\n readonly queuedAt: Date\n readonly created: boolean\n /** Defaults to the run id. A trigger that joins a run publishes its own job for it. */\n readonly jobId?: string\n }\n\n/** Persist an execution and a queued run before publishing the run's queue job. */\nexport async function dispatchQueuedRun<TRun extends QueuedRun, TResult>(\n input: DispatchQueuedRunInput<TRun, TResult>\n): Promise<TResult> {\n const runId = createRunId(input)\n\n let persisted = await persistRun(input, runId)\n if (!persisted.publish && input.automatic && persisted.run.status === \"queued\") {\n persisted = await reuseRun(input, persisted.run)\n }\n\n if (!persisted.publish) return input.primitive.result(persisted.run)\n return publishRun(input, persisted)\n}\n\nasync function persistRun<TRun extends QueuedRun, TResult>(\n input: DispatchQueuedRunInput<TRun, TResult>,\n runId: string\n): Promise<PersistedRun<TRun>> {\n const { primitive } = input\n\n const store = primitive.store(input.storage)\n\n const existing = await store.getById({ projectId: input.projectId, id: runId })\n if (existing) return reuseRun(input, existing)\n\n const execution = await input.createExecution(`exec_${randomUUID()}`, runId)\n const queuedAt = new Date()\n\n try {\n return await input.storage.transaction(\n (tx) => persistRunInTransaction(input, tx, runId, execution, queuedAt),\n { isolation: \"serializable\" }\n )\n } catch (error) {\n if (!(error instanceof primitive.RunError)) throw error\n\n const raced = await store.getById({ projectId: input.projectId, id: runId })\n if (!raced) throw error\n\n await assertReusable(input, raced, input.storage)\n return { publish: false, run: raced }\n }\n}\n\nasync function persistRunInTransaction<TRun extends QueuedRun, TResult>(\n input: DispatchQueuedRunInput<TRun, TResult>,\n tx: Storage,\n runId: string,\n execution: CreateExecutionInput,\n queuedAt: Date\n): Promise<PersistedRun<TRun>> {\n const store = input.primitive.store(tx)\n\n const raced = await store.getById({ projectId: input.projectId, id: runId })\n if (raced) {\n await assertReusable(input, raced, tx)\n return { publish: false, run: raced }\n }\n\n if (input.joinQueuedRun) {\n const waiting = await store.oldestQueued()\n if (waiting && input.primitive.matches(waiting)) {\n return {\n publish: true,\n run: waiting,\n queuedAt: waiting.queuedAt,\n created: false,\n // The run's own job may be gone, so a joining trigger brings one that can start the run.\n jobId: joinJobId(waiting.id),\n }\n }\n }\n\n await tx.executions.create(execution)\n const run = await store.queue({ id: runId, executionId: execution.id, queuedAt })\n return { publish: true, run, queuedAt, created: true }\n}\n\nasync function reuseRun<TRun extends QueuedRun, TResult>(\n input: DispatchQueuedRunInput<TRun, TResult>,\n existing: TRun\n): Promise<PersistedRun<TRun>> {\n await assertReusable(input, existing, input.storage)\n\n if (input.automatic && existing.status === \"queued\") {\n await requireExecution(input, existing)\n return { publish: true, run: existing, queuedAt: existing.queuedAt, created: false }\n }\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 await requireExecution(input, existing)\n\n const queuedAt = new Date()\n const run = await input.primitive.store(input.storage).requeue(existing, queuedAt)\n return { publish: true, run, queuedAt, created: false }\n}\n\n/**\n * A request that names an existing run must ask for that same run. A trigger does not have to: the\n * orchestrator replays retained events whenever it restarts, and a deploy in between may change\n * the definition. The run the trigger's id names has already answered it, and the worker fails one\n * that has not started and no longer matches its definition. Rejecting the trigger instead would\n * hold every later event of its type behind it.\n */\nasync function assertReusable<TRun extends QueuedRun, TResult>(\n input: DispatchQueuedRunInput<TRun, TResult>,\n run: TRun,\n storage: Storage\n): Promise<void> {\n if (!input.automatic && !input.primitive.matches(run)) {\n throw new input.primitive.RunError(\n `[Sixb] ${input.primitive.label} run '${run.id}' already exists with a different request payload.`\n )\n }\n\n await input.validateExistingRun?.(run, storage)\n}\n\nasync function requireExecution<TRun extends QueuedRun, TResult>(\n input: DispatchQueuedRunInput<TRun, TResult>,\n run: TRun\n): Promise<void> {\n const execution = await input.storage.executions.getById({\n projectId: input.projectId,\n id: run.executionId,\n })\n if (!execution) {\n throw new input.primitive.RunError(\n `[Sixb] Execution '${run.executionId}' for ${input.primitive.label} run '${run.id}' was not found.`\n )\n }\n}\n\nasync function publishRun<TRun extends QueuedRun, TResult>(\n input: DispatchQueuedRunInput<TRun, TResult>,\n persisted: Extract<PersistedRun<TRun>, { readonly publish: true }>\n): Promise<TResult> {\n const { primitive } = input\n const jobId = persisted.jobId ?? persisted.run.id\n\n try {\n const job = await primitive.enqueue({\n id: jobId,\n runId: persisted.run.id,\n ...(input.metadata === undefined ? {} : { metadata: input.metadata }),\n })\n if (!job || job.id !== jobId) {\n throw new primitive.RunError(\n `[Sixb] Queue did not acknowledge ${primitive.label} run '${persisted.run.id}'.`\n )\n }\n\n return primitive.result(persisted.run, {\n queuedAt: persisted.queuedAt,\n 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.automatic) throw error\n\n await primitive.failPublication(\n persisted.run,\n createSixbError(\n \"queue.enqueue_failed\",\n `[Sixb] Could not enqueue ${primitive.label} run '${persisted.run.id}'.`,\n {\n cause: error,\n details: {\n ...primitive.failureDetails(persisted.run),\n runId: persisted.run.id,\n phase: \"enqueue\",\n },\n }\n ),\n error,\n new Date()\n )\n throw error\n }\n}\n\n/** Whether an execution is the one this automatic trigger would have created for its run. */\nexport function hasAutomaticRunProvenance(\n execution: ExecutionRecord | null,\n input: { readonly source: RunDispatchProvenance; readonly correlationId: string }\n): boolean {\n return (\n execution !== null &&\n isDeepStrictEqual(execution.source, input.source) &&\n execution.correlationId === input.correlationId &&\n execution.requestedBy === undefined\n )\n}\n\nfunction createRunId<TRun extends QueuedRun, TResult>(\n input: DispatchQueuedRunInput<TRun, TResult>\n): string {\n if (input.runId === undefined) return `run_${randomUUID()}`\n\n if (!input.runId.trim()) {\n throw new input.primitive.RequestError(\n `[Sixb] ${input.primitive.label} run id must not be emp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-2,8 +2,12 @@
|
|
|
2
2
|
import {
|
|
3
3
|
createPrincipalRuntimeAuthorization,
|
|
4
4
|
createDisabledRuntimeAuthorization,
|
|
5
|
-
createDelegatedRuntimeAuthorization
|
|
6
|
-
|
|
5
|
+
createDelegatedRuntimeAuthorization,
|
|
6
|
+
createScriptRuntimeAuthorization
|
|
7
|
+
} from "./chunk-tapdssb5.js";
|
|
8
|
+
import {
|
|
9
|
+
assertScriptPath
|
|
10
|
+
} from "./chunk-mbwsgjn7.js";
|
|
7
11
|
|
|
8
12
|
// src/execution/scopes.ts
|
|
9
13
|
import { randomUUID } from "crypto";
|
|
@@ -44,6 +48,18 @@ function createDelegatedRequestScope(input) {
|
|
|
44
48
|
})
|
|
45
49
|
});
|
|
46
50
|
}
|
|
51
|
+
function createScriptScope(input) {
|
|
52
|
+
assertNonEmpty(input.projectId, "Execution project id");
|
|
53
|
+
assertScriptPath(input.path);
|
|
54
|
+
const execution = freezeExecution({
|
|
55
|
+
id: `exec_${randomUUID()}`,
|
|
56
|
+
projectId: input.projectId,
|
|
57
|
+
executor: Object.freeze({ type: "script", runId: `script_${randomUUID()}` }),
|
|
58
|
+
source: Object.freeze({ type: "script", path: input.path }),
|
|
59
|
+
correlationId: `corr_${randomUUID()}`
|
|
60
|
+
});
|
|
61
|
+
return Object.freeze({ execution, authorization: createScriptRuntimeAuthorization(execution) });
|
|
62
|
+
}
|
|
47
63
|
function createTestingScope(input) {
|
|
48
64
|
const context = input.context ? withoutSession(input.context) : undefined;
|
|
49
65
|
const requestId = input.requestId ?? `test_request_${randomUUID()}`;
|
|
@@ -97,6 +113,6 @@ function assertNonEmpty(value, label) {
|
|
|
97
113
|
}
|
|
98
114
|
}
|
|
99
115
|
|
|
100
|
-
export { createPrincipalRequestScope, createDisabledRequestScope, createDelegatedRequestScope, createTestingScope };
|
|
116
|
+
export { createPrincipalRequestScope, createDisabledRequestScope, createDelegatedRequestScope, createScriptScope, createTestingScope };
|
|
101
117
|
|
|
102
|
-
//# debugId=
|
|
118
|
+
//# debugId=91DB78E5FCB8B64B64756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/execution/scopes.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { randomUUID } from \"node:crypto\"\nimport type { AuthorizationContext } from \"../authorization\"\nimport type { ObjectReadExecutionLimits, SelectedObjectReadScope } from \"../storage\"\nimport {\n createDelegatedRuntimeAuthorization,\n createDisabledRuntimeAuthorization,\n createKernelRuntimeAuthorization,\n createPrincipalRuntimeAuthorization,\n createScriptRuntimeAuthorization,\n type DelegatedActionApplyTarget,\n} from \"./authorization\"\nimport { assertScriptPath } from \"./script\"\nimport type {\n AuthorizablePrincipal,\n AuthorizationRef,\n ExecutionContext,\n ExecutionScope,\n ExecutionSource,\n KernelOperation,\n} from \"./types\"\n\nexport function createPrincipalRequestScope(input: {\n readonly projectId: string\n readonly requestId: string\n readonly correlationId: string\n readonly context: AuthorizationContext\n readonly credential?: Extract<AuthorizationRef, { readonly type: \"principal\" }>[\"credential\"]\n}): ExecutionScope {\n const execution = createRequestExecution({\n projectId: input.projectId,\n requestId: input.requestId,\n correlationId: input.correlationId,\n requestedBy: asAuthorizablePrincipal(input.context.principal),\n })\n\n return Object.freeze({\n execution,\n authorization: createPrincipalRuntimeAuthorization({\n execution,\n context: input.context,\n ...(input.credential === undefined ? {} : { credential: input.credential }),\n }),\n })\n}\n\nexport function createDisabledRequestScope(input: {\n readonly projectId: string\n readonly requestId: string\n readonly correlationId: string\n}): ExecutionScope {\n const execution = createRequestExecution(input)\n return Object.freeze({\n execution,\n authorization: createDisabledRuntimeAuthorization(execution),\n })\n}\n\n/** Internal request scope carrying only a finite object-read selection. */\nexport function createDelegatedRequestScope(input: {\n readonly projectId: string\n readonly requestId: string\n readonly correlationId: string\n readonly objectRead: {\n readonly selection: SelectedObjectReadScope\n readonly limits: ObjectReadExecutionLimits\n }\n readonly actionApply?: readonly DelegatedActionApplyTarget[]\n readonly delegation?: Extract<AuthorizationRef, { readonly type: \"delegated\" }>[\"delegation\"]\n}): ExecutionScope {\n const execution = createRequestExecution(input)\n const actionApply = input.actionApply\n const delegation = input.delegation\n return Object.freeze({\n execution,\n authorization: createDelegatedRuntimeAuthorization({\n execution,\n objectRead: input.objectRead,\n ...(actionApply === undefined ? {} : { actionApply }),\n ...(delegation === undefined ? {} : { delegation }),\n }),\n })\n}\n\nexport function createKernelScope(input: {\n readonly projectId: string\n readonly operation: KernelOperation\n readonly source: ExecutionSource\n readonly correlationId?: string\n}): ExecutionScope {\n const operation = Object.freeze({ ...input.operation })\n const execution = createKernelExecution({\n projectId: input.projectId,\n operation,\n source: input.source,\n correlationId: input.correlationId,\n })\n return Object.freeze({\n execution,\n authorization: createKernelRuntimeAuthorization({ execution, operation }),\n })\n}\n\nfunction createKernelExecution(input: {\n readonly projectId: string\n readonly operation: KernelOperation\n readonly source: ExecutionSource\n readonly correlationId?: string\n}): ExecutionContext {\n const source = snapshotExecutionSource(input.source)\n assertNestedProvenance(source, input.correlationId)\n return freezeExecution({\n id: `exec_${randomUUID()}`,\n projectId: input.projectId,\n executor: Object.freeze({ type: \"kernel\", operation: input.operation }),\n source,\n correlationId: input.correlationId ?? `corr_${randomUUID()}`,\n })\n}\n\nfunction assertNestedProvenance(source: ExecutionSource, correlationId: string | undefined): void {\n if (source.type === \"execution\" && correlationId === undefined) {\n throw new Error(\"[Sixb] Nested execution must preserve its parent correlation id.\")\n }\n}\n\n/**\n * The scope of one `sixb run`: unrestricted, requested by nobody, and recorded under the script's\n * project-relative path. Only the CLI creates one; there is no public way to.\n */\nexport function createScriptScope(input: {\n readonly projectId: string\n readonly path: string\n}): ExecutionScope {\n assertNonEmpty(input.projectId, \"Execution project id\")\n assertScriptPath(input.path)\n const execution = freezeExecution({\n id: `exec_${randomUUID()}`,\n projectId: input.projectId,\n executor: Object.freeze({ type: \"script\", runId: `script_${randomUUID()}` }),\n source: Object.freeze({ type: \"script\", path: input.path }),\n correlationId: `corr_${randomUUID()}`,\n })\n return Object.freeze({ execution, authorization: createScriptRuntimeAuthorization(execution) })\n}\n\nexport function createTestingScope(input: {\n readonly projectId: string\n readonly context?: AuthorizationContext\n readonly executionId?: string\n readonly requestId?: string\n readonly correlationId?: string\n}): ExecutionScope {\n const context = input.context ? withoutSession(input.context) : undefined\n const requestId = input.requestId ?? `test_request_${randomUUID()}`\n const execution = createRequestExecution({\n projectId: input.projectId,\n requestId,\n correlationId: input.correlationId ?? `test_correlation_${randomUUID()}`,\n ...(context === undefined ? {} : { requestedBy: asAuthorizablePrincipal(context.principal) }),\n executionId: input.executionId,\n })\n return Object.freeze({\n execution,\n authorization: context\n ? createPrincipalRuntimeAuthorization({ execution, context })\n : createDisabledRuntimeAuthorization(execution),\n })\n}\n\nfunction withoutSession(context: AuthorizationContext): AuthorizationContext {\n const { sessionId: _sessionId, ...withoutSessionId } = context\n return withoutSessionId\n}\n\nfunction createRequestExecution(input: {\n readonly projectId: string\n readonly requestId: string\n readonly correlationId: string\n readonly requestedBy?: AuthorizablePrincipal\n readonly executionId?: string\n}): ExecutionContext {\n assertNonEmpty(input.projectId, \"Execution project id\")\n assertNonEmpty(input.requestId, \"Execution request id\")\n assertNonEmpty(input.correlationId, \"Execution correlation id\")\n const id = input.executionId ?? `exec_${randomUUID()}`\n assertNonEmpty(id, \"Execution id\")\n return freezeExecution({\n id,\n projectId: input.projectId,\n ...(input.requestedBy === undefined ? {} : { requestedBy: input.requestedBy }),\n executor: Object.freeze({ type: \"request\", requestId: input.requestId }),\n source: Object.freeze({ type: \"http\", requestId: input.requestId }),\n correlationId: input.correlationId,\n })\n}\n\nfunction freezeExecution(execution: ExecutionContext): ExecutionContext {\n assertNonEmpty(execution.id, \"Execution id\")\n assertNonEmpty(execution.projectId, \"Execution project id\")\n assertNonEmpty(execution.correlationId, \"Execution correlation id\")\n return Object.freeze(execution)\n}\n\nfunction snapshotExecutionSource(source: ExecutionSource): ExecutionSource {\n const field = sourceIdentifier(source)\n assertNonEmpty(field.value, field.label)\n if (source.type === \"datasetVersion\") {\n assertNonEmpty(source.datasetId, \"Execution source dataset id\")\n }\n return Object.freeze({ ...source })\n}\n\nfunction sourceIdentifier(source: ExecutionSource): {\n readonly label: string\n readonly value: string\n} {\n switch (source.type) {\n case \"ontologyCommit\":\n return { label: \"Execution source commit id\", value: source.commitId }\n case \"http\":\n return { label: \"Execution source request id\", value: source.requestId }\n case \"webhook\":\n return { label: \"Execution source delivery id\", value: source.deliveryId }\n case \"schedule\":\n case \"event\":\n return { label: \"Execution source event id\", value: source.eventId }\n case \"datasetVersion\":\n return { label: \"Execution source dataset version id\", value: source.versionId }\n case \"execution\":\n return { label: \"Execution source execution id\", value: source.executionId }\n case \"script\":\n return { label: \"Execution source script path\", value: source.path }\n }\n}\n\nfunction asAuthorizablePrincipal(\n principal: AuthorizationContext[\"principal\"]\n): AuthorizablePrincipal {\n if (principal.type !== \"user\" && principal.type !== \"serviceAccount\") {\n throw new Error(`[Sixb] Principal type '${principal.type}' cannot hold runtime authorization.`)\n }\n assertNonEmpty(principal.id, \"Execution principal id\")\n return Object.freeze({ type: principal.type, id: principal.id })\n}\n\nfunction assertNonEmpty(value: string, label: string): void {\n if (!value.trim()) {\n throw new Error(`[Sixb] ${label} must not be empty.`)\n }\n}\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";;;;;;;;;;;;AAAA;AAqBO,SAAS,2BAA2B,CAAC,OAMzB;AAAA,EACjB,MAAM,YAAY,uBAAuB;AAAA,IACvC,WAAW,MAAM;AAAA,IACjB,WAAW,MAAM;AAAA,IACjB,eAAe,MAAM;AAAA,IACrB,aAAa,wBAAwB,MAAM,QAAQ,SAAS;AAAA,EAC9D,CAAC;AAAA,EAED,OAAO,OAAO,OAAO;AAAA,IACnB;AAAA,IACA,eAAe,oCAAoC;AAAA,MACjD;AAAA,MACA,SAAS,MAAM;AAAA,SACX,MAAM,eAAe,YAAY,CAAC,IAA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,uBAAuB,CAC9B,WACuB;AAAA,EACvB,IAAI,UAAU,SAAS,UAAU,UAAU,SAAS,kBAAkB;AAAA,IACpE,MAAM,IAAI,MAAM,0BAA0B,UAAU,0CAA0C;AAAA,EAChG;AAAA,EACA,eAAe,UAAU,IAAI,wBAAwB;AAAA,EACrD,OAAO,OAAO,OAAO,EAAE,MAAM,UAAU,MAAM,IAAI,UAAU,GAAG,CAAC;AAAA;AAGjE,SAAS,cAAc,CAAC,OAAe,OAAqB;AAAA,EAC1D,IAAI,CAAC,MAAM,KAAK,GAAG;AAAA,IACjB,MAAM,IAAI,MAAM,UAAU,0BAA0B;AAAA,EACtD;AAAA;",
|
|
8
|
+
"debugId": "91DB78E5FCB8B64B64756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -39,7 +39,7 @@ import {
|
|
|
39
39
|
normalizeLinkProperties2,
|
|
40
40
|
validateLinkProperties2,
|
|
41
41
|
validateTelemetryUnit2
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-7mhbs9yy.js";
|
|
43
43
|
import {
|
|
44
44
|
materializationEventKindOrdinal2,
|
|
45
45
|
sha256Canonical2,
|
|
@@ -50,29 +50,29 @@ import {
|
|
|
50
50
|
vectorConfiguration,
|
|
51
51
|
vectorSources,
|
|
52
52
|
normalizeVector2
|
|
53
|
-
} from "./chunk-
|
|
53
|
+
} from "./chunk-394zjzjs.js";
|
|
54
54
|
import {
|
|
55
55
|
resolveExecutionScopeAuthorization,
|
|
56
56
|
ProjectionValidationError2,
|
|
57
57
|
validateProjectionsAtStartup,
|
|
58
58
|
isProjectionDefinition2
|
|
59
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-tapdssb5.js";
|
|
60
60
|
import {
|
|
61
61
|
isStorageSerializationFailure2
|
|
62
|
-
} from "./chunk-
|
|
62
|
+
} from "./chunk-88xeh6zx.js";
|
|
63
63
|
import {
|
|
64
64
|
objectBatchKey2
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-9c9yknwt.js";
|
|
66
66
|
import {
|
|
67
67
|
materializationApplyPhase2
|
|
68
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-61zptves.js";
|
|
69
69
|
import {
|
|
70
70
|
parseDatasetTimestamp2
|
|
71
71
|
} from "./chunk-z667z3sg.js";
|
|
72
72
|
import {
|
|
73
73
|
executionRecordInputFromRuntime,
|
|
74
74
|
ensureExecutionRecord2
|
|
75
|
-
} from "./chunk-
|
|
75
|
+
} from "./chunk-xavet0qs.js";
|
|
76
76
|
import {
|
|
77
77
|
assertPinnedDatasetWatermark2
|
|
78
78
|
} from "./chunk-n8q5j6y5.js";
|
|
@@ -237,7 +237,8 @@ function normalizeProjectionDefinition(projection) {
|
|
|
237
237
|
targetObjectTypeId: link.targetObjectTypeId
|
|
238
238
|
}
|
|
239
239
|
])),
|
|
240
|
-
conflictResolution: projection.conflictResolution ?? { strategy: "editsWin" }
|
|
240
|
+
conflictResolution: projection.conflictResolution ?? { strategy: "editsWin" },
|
|
241
|
+
...projection.missing ? { missing: projection.missing } : {}
|
|
241
242
|
};
|
|
242
243
|
}
|
|
243
244
|
if (projection._tag === "LinkProjectionDefinition") {
|
|
@@ -519,7 +520,8 @@ function cloneObjectProjectionDefinition(projection) {
|
|
|
519
520
|
conflictResolution: projection.conflictResolution?.strategy === "mostRecent" ? {
|
|
520
521
|
strategy: "mostRecent",
|
|
521
522
|
sourceTimestamp: projection.conflictResolution.sourceTimestamp
|
|
522
|
-
} : { strategy: "editsWin" }
|
|
523
|
+
} : { strategy: "editsWin" },
|
|
524
|
+
...projection.missing ? { missing: projection.missing } : {}
|
|
523
525
|
};
|
|
524
526
|
}
|
|
525
527
|
function cloneLinkProjectionDefinition(projection) {
|
|
@@ -1179,6 +1181,9 @@ function normalizePinnedDatasetVersion(version) {
|
|
|
1179
1181
|
createdAt: normalizeTimestamp(version.createdAt, "Dataset version createdAt")
|
|
1180
1182
|
});
|
|
1181
1183
|
}
|
|
1184
|
+
function normalizeSourceReadAt(value) {
|
|
1185
|
+
return normalizeTimestamp(value, "Projection source read time");
|
|
1186
|
+
}
|
|
1182
1187
|
function normalizeProjectionRunId(runId) {
|
|
1183
1188
|
return normalizeNonblank(runId, "Projection run id");
|
|
1184
1189
|
}
|
|
@@ -3842,7 +3847,9 @@ async function stagePlanned(context, plans, plan, planned) {
|
|
|
3842
3847
|
}
|
|
3843
3848
|
}
|
|
3844
3849
|
function planReplacementObject(context, input, state) {
|
|
3845
|
-
const
|
|
3850
|
+
const withdrawn = withdrawnCreate(input, state);
|
|
3851
|
+
const override = withdrawn ? withdrawn.value : state.override?.value ?? null;
|
|
3852
|
+
const resolved = resolveReplacementObject(context, state, override);
|
|
3846
3853
|
if (resolved)
|
|
3847
3854
|
validateEffectiveObject(context.ontology, resolved.ref, resolved.properties);
|
|
3848
3855
|
const change = diffEffectiveObject({
|
|
@@ -3864,6 +3871,9 @@ function planReplacementObject(context, input, state) {
|
|
|
3864
3871
|
if (Boolean(state.effective) !== Boolean(resolved)) {
|
|
3865
3872
|
work.push({ kind: "incident-object", recordKey: `incident:${sortKey}`, ref: state.ref });
|
|
3866
3873
|
}
|
|
3874
|
+
if (withdrawn) {
|
|
3875
|
+
work.push(planWork({ kind: "object-override-upsert", value: withdrawn }, sortKey));
|
|
3876
|
+
}
|
|
3867
3877
|
if (!change)
|
|
3868
3878
|
return work;
|
|
3869
3879
|
appendObjectChangeWork(context, work, sortKey, change);
|
|
@@ -3950,12 +3960,28 @@ function appendLinkChangeWork(work, sortKey, change) {
|
|
|
3950
3960
|
work.push(planWork(item, sortKey));
|
|
3951
3961
|
work.push(eventWork(buildLinkMaterializationEventDraft(change)));
|
|
3952
3962
|
}
|
|
3953
|
-
function
|
|
3963
|
+
function withdrawnCreate(input, state) {
|
|
3964
|
+
const { withdrawCreatesBefore } = input;
|
|
3965
|
+
const override = state.override;
|
|
3966
|
+
if (!withdrawCreatesBefore || state.candidateSource)
|
|
3967
|
+
return null;
|
|
3968
|
+
if (override?.value.kind !== "create" || override.updatedAt >= withdrawCreatesBefore)
|
|
3969
|
+
return null;
|
|
3970
|
+
return {
|
|
3971
|
+
ref: state.ref,
|
|
3972
|
+
value: { kind: "patch", set: override.value.properties, unset: [] },
|
|
3973
|
+
editedAt: storedObjectEditedAt(override),
|
|
3974
|
+
expectedLastCommitId: override.lastCommitId,
|
|
3975
|
+
lastCommitId: input.commit.id,
|
|
3976
|
+
updatedAt: input.commit.committedAt
|
|
3977
|
+
};
|
|
3978
|
+
}
|
|
3979
|
+
function resolveReplacementObject(context, state, override) {
|
|
3954
3980
|
return resolveEffectiveObject({
|
|
3955
3981
|
ref: state.ref,
|
|
3956
3982
|
primaryPropertyId: context.ontology.getPrimaryPropertyId(state.ref.objectTypeId),
|
|
3957
3983
|
source: state.candidateSource,
|
|
3958
|
-
override
|
|
3984
|
+
override,
|
|
3959
3985
|
editedAt: storedObjectEditedAt(state.override),
|
|
3960
3986
|
latestTelemetry: state.latestTelemetry
|
|
3961
3987
|
});
|
|
@@ -4056,12 +4082,14 @@ function prepareProjectionReplacement(context, raw) {
|
|
|
4056
4082
|
idempotencyKey: createProjectionIdempotencyKey2(runIdentity),
|
|
4057
4083
|
normalizedCallerIntent: { source, datasetVersion }
|
|
4058
4084
|
});
|
|
4085
|
+
const withdrawCreatesBefore = missingRemovalReadAt(resolved, raw.input.sourceReadAt);
|
|
4059
4086
|
const command = {
|
|
4060
4087
|
source,
|
|
4061
4088
|
datasetVersion,
|
|
4062
4089
|
execution,
|
|
4063
4090
|
entries: raw.input.entries,
|
|
4064
4091
|
...raw.input.base ? { base: Object.freeze({ ...raw.input.base }) } : {},
|
|
4092
|
+
...withdrawCreatesBefore ? { withdrawCreatesBefore } : {},
|
|
4065
4093
|
resolved,
|
|
4066
4094
|
projectionKind,
|
|
4067
4095
|
runIdentity,
|
|
@@ -4072,6 +4100,15 @@ function prepareProjectionReplacement(context, raw) {
|
|
|
4072
4100
|
return command;
|
|
4073
4101
|
return { ...command, signal: raw.input.signal };
|
|
4074
4102
|
}
|
|
4103
|
+
function missingRemovalReadAt(resolved, sourceReadAt) {
|
|
4104
|
+
if (sourceReadAt === undefined)
|
|
4105
|
+
return;
|
|
4106
|
+
if (resolved.definition._tag !== "ObjectProjectionDefinition")
|
|
4107
|
+
return;
|
|
4108
|
+
if (resolved.definition.missing !== "remove")
|
|
4109
|
+
return;
|
|
4110
|
+
return normalizeSourceReadAt(sourceReadAt);
|
|
4111
|
+
}
|
|
4075
4112
|
function validateProjectionDataset(resolved, datasetVersion) {
|
|
4076
4113
|
if (datasetVersion.datasetId === resolved.datasetId)
|
|
4077
4114
|
return;
|
|
@@ -4202,7 +4239,8 @@ async function commitProjectionCandidate(context, command, ready) {
|
|
|
4202
4239
|
};
|
|
4203
4240
|
const { committedAt } = await plans.open({
|
|
4204
4241
|
...plan,
|
|
4205
|
-
commit: projectionCommit(context.projectId, command, ready.identity)
|
|
4242
|
+
commit: projectionCommit(context.projectId, command, ready.identity),
|
|
4243
|
+
...createdObjectsToPlan(command)
|
|
4206
4244
|
});
|
|
4207
4245
|
const commit = projectionCommit(context.projectId, command, { ...ready.identity, committedAt });
|
|
4208
4246
|
for (let round = 1;; round += 1) {
|
|
@@ -4301,8 +4339,18 @@ function projectionCommit(projectId, command, identity) {
|
|
|
4301
4339
|
committedAt: identity.committedAt
|
|
4302
4340
|
};
|
|
4303
4341
|
}
|
|
4342
|
+
function createdObjectsToPlan(command) {
|
|
4343
|
+
const { definition } = command.resolved;
|
|
4344
|
+
if (!command.withdrawCreatesBefore || definition._tag !== "ObjectProjectionDefinition")
|
|
4345
|
+
return {};
|
|
4346
|
+
return { createdObjects: { objectTypeId: definition.objectTypeId } };
|
|
4347
|
+
}
|
|
4304
4348
|
function planInput(command, commit) {
|
|
4305
|
-
const input = {
|
|
4349
|
+
const input = {
|
|
4350
|
+
projectionKind: command.projectionKind,
|
|
4351
|
+
commit,
|
|
4352
|
+
...command.withdrawCreatesBefore ? { withdrawCreatesBefore: command.withdrawCreatesBefore } : {}
|
|
4353
|
+
};
|
|
4306
4354
|
return command.signal === undefined ? input : { ...input, signal: command.signal };
|
|
4307
4355
|
}
|
|
4308
4356
|
function projectionActivation(command, ready, commit) {
|
|
@@ -4858,4 +4906,4 @@ function createOntologyMaterializer2(input) {
|
|
|
4858
4906
|
}
|
|
4859
4907
|
export { computeOntologyRevision2, computeProjectionRevision2, computeProjectionOwnershipHash2, ProjectionRegistry2, createActionIdempotencyKey2, createRuntimeIdempotencyKey2, createProjectionIdempotencyKey2, createRuntimeTelemetryIdempotencyKey2, createProjectionTelemetryIdempotencyKey2, createCommitIdentity2, timestampCommitIdentity2, createTimedCommitIdentity2, createProjectionMaterializationId2, createLinkScopeFingerprint2, normalizeJsonProperties2, normalizeOntologyEditCommit2, normalizeProjectionExecution2, normalizeProjectionSourceEntry2, normalizeTelemetryAppend2, usableLinkSlotOverride, explainEffectiveObject, storedObjectEditedAt, resolveEffectiveLink, resolveEffectiveLinkSlotMember, linkCardinality, OntologyMaterializer2, createOntologyMaterializer2 };
|
|
4860
4908
|
|
|
4861
|
-
//# debugId=
|
|
4909
|
+
//# debugId=4D8B149FCD5FA6E664756E2164756E21
|