@sixb/core 0.2.5 → 0.2.7
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 +36 -35
- 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 +17 -2
- package/dist/agents/execution.d.ts.map +1 -1
- package/dist/agents/index.d.ts +3 -3
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +53 -45
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/model-routing.d.ts +16 -2
- package/dist/agents/model-routing.d.ts.map +1 -1
- package/dist/agents/request.d.ts +45 -4
- package/dist/agents/request.d.ts.map +1 -1
- package/dist/agents/run-events.d.ts +4 -0
- 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-token.d.ts +6 -0
- package/dist/agents/run-token.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 +37 -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/artifacts/live/server.js +19 -18
- package/dist/artifacts/live/server.js.map +1 -1
- package/dist/artifacts/publish/index.js +18 -17
- package/dist/artifacts/publish/index.js.map +1 -1
- package/dist/artifacts/publish/merge.d.ts +2 -1
- package/dist/artifacts/publish/merge.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/index.js +2 -2
- package/dist/bootstrap/discovery.d.ts +6 -0
- package/dist/bootstrap/discovery.d.ts.map +1 -1
- package/dist/bootstrap/index.js +40 -38
- 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-04r2fdsd.js +386 -0
- package/dist/chunk-04r2fdsd.js.map +14 -0
- package/dist/{chunk-gjhrz66x.js → chunk-06kpaqg4.js} +248 -21
- package/dist/{chunk-gjhrz66x.js.map → chunk-06kpaqg4.js.map} +6 -6
- package/dist/{chunk-5a4a52tq.js → chunk-0pmpwn3g.js} +18 -2
- package/dist/chunk-0pmpwn3g.js.map +10 -0
- package/dist/{chunk-nxysqbt0.js → chunk-389ybvw9.js} +6 -2
- package/dist/chunk-389ybvw9.js.map +10 -0
- package/dist/{chunk-xcrnrpfh.js → chunk-394zjzjs.js} +20 -10
- package/dist/{chunk-xcrnrpfh.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-0hkdtwqk.js → chunk-44hrfmbk.js} +5 -5
- package/dist/{chunk-ey1p8w68.js → chunk-5pz3htbe.js} +86 -5
- package/dist/chunk-5pz3htbe.js.map +13 -0
- package/dist/{chunk-s5pj68fa.js → chunk-5sswe5ej.js} +2 -2
- package/dist/{chunk-k3jh8gsg.js → chunk-5xkqasvn.js} +21 -4
- package/dist/chunk-5xkqasvn.js.map +10 -0
- package/dist/{chunk-5t9gm5tt.js → chunk-6md802cc.js} +38 -14
- package/dist/chunk-6md802cc.js.map +22 -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-ewqn51gr.js → chunk-88xeh6zx.js} +6 -4
- package/dist/{chunk-ewqn51gr.js.map → chunk-88xeh6zx.js.map} +4 -4
- package/dist/{chunk-z1njfqqs.js → chunk-8qmp9fpa.js} +783 -171
- package/dist/{chunk-z1njfqqs.js.map → chunk-8qmp9fpa.js.map} +13 -13
- package/dist/{chunk-r2psmn42.js → chunk-95ps0k5q.js} +3 -3
- package/dist/{chunk-r2psmn42.js.map → chunk-95ps0k5q.js.map} +3 -3
- package/dist/{chunk-fpf57gca.js → chunk-9cyq87qa.js} +276 -68
- package/dist/{chunk-fpf57gca.js.map → chunk-9cyq87qa.js.map} +6 -6
- package/dist/{chunk-q9nkpr8k.js → chunk-9tpmfh3n.js} +1 -1
- package/dist/chunk-9wr3yajk.js.map +2 -2
- package/dist/{chunk-naxjka9v.js → chunk-brhp9d97.js} +2 -2
- package/dist/{chunk-8a8k38tz.js → chunk-brybqw5k.js} +1 -1
- package/dist/{chunk-vehcr9eb.js → chunk-cg7cygfj.js} +1 -1
- package/dist/{chunk-b4escq4c.js → chunk-cpy282b8.js} +6 -6
- package/dist/chunk-dq3t5sr3.js +114 -0
- package/dist/chunk-dq3t5sr3.js.map +11 -0
- package/dist/{chunk-68hm50qh.js → chunk-fdk0ks9p.js} +16 -46
- package/dist/chunk-fdk0ks9p.js.map +12 -0
- package/dist/{chunk-fzae1jpq.js → chunk-fycac8e9.js} +50 -16
- package/dist/{chunk-fzae1jpq.js.map → chunk-fycac8e9.js.map} +3 -3
- package/dist/{chunk-zft9bzbc.js → chunk-hkbks1xm.js} +2 -1
- package/dist/{chunk-zft9bzbc.js.map → chunk-hkbks1xm.js.map} +3 -3
- package/dist/{chunk-m3qx2pns.js → chunk-hvq8xs66.js} +28 -12
- package/dist/{chunk-m3qx2pns.js.map → chunk-hvq8xs66.js.map} +5 -5
- package/dist/{chunk-bc3y6gff.js → chunk-jka26v8c.js} +1 -1
- package/dist/{chunk-s1mqyqmm.js → chunk-js9e6487.js} +12 -8
- package/dist/chunk-js9e6487.js.map +18 -0
- package/dist/{chunk-zxhym8tr.js → chunk-k29rdc3h.js} +1 -1
- package/dist/{chunk-rg725hry.js → chunk-m1cwncee.js} +86 -34
- package/dist/{chunk-rg725hry.js.map → chunk-m1cwncee.js.map} +8 -8
- package/dist/{chunk-1yh6jgtz.js → chunk-mrs7jy17.js} +2 -2
- package/dist/{chunk-qavwr628.js → chunk-n1hbwc6y.js} +5 -6
- package/dist/chunk-n1hbwc6y.js.map +12 -0
- package/dist/{chunk-pqvvqc65.js → chunk-pfdq1ga6.js} +3 -3
- package/dist/{chunk-k29n4176.js → chunk-phs5fbff.js} +6 -6
- package/dist/{chunk-wqe9shx2.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-r588h4ev.js +98 -0
- package/dist/chunk-r588h4ev.js.map +10 -0
- package/dist/{chunk-rtdrm592.js → chunk-t58sktr5.js} +12 -4
- package/dist/{chunk-rtdrm592.js.map → chunk-t58sktr5.js.map} +3 -3
- package/dist/{chunk-paxabbqd.js → chunk-tapdssb5.js} +1 -1
- package/dist/{chunk-dhkc9b23.js → chunk-v8a1qjzp.js} +1 -1
- package/dist/{chunk-q8d9p0tb.js → chunk-wzcjhv54.js} +8 -1
- package/dist/{chunk-q8d9p0tb.js.map → chunk-wzcjhv54.js.map} +3 -3
- package/dist/{chunk-pc7kra3k.js → chunk-xavet0qs.js} +1 -1
- package/dist/{chunk-m9ketb51.js → chunk-ygvay56w.js} +1 -1
- package/dist/{chunk-0mvjpgvm.js → chunk-yyj009tv.js} +4 -4
- package/dist/connectors/connections/capability.d.ts +11 -0
- package/dist/connectors/connections/capability.d.ts.map +1 -1
- 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/service.d.ts +9 -1
- package/dist/connectors/connections/service.d.ts.map +1 -1
- package/dist/connectors/execution.d.ts +7 -1
- package/dist/connectors/execution.d.ts.map +1 -1
- package/dist/connectors/service.d.ts +5 -1
- package/dist/connectors/service.d.ts.map +1 -1
- package/dist/deploy/index.d.ts +1 -1
- package/dist/deploy/index.d.ts.map +1 -1
- package/dist/deploy/internal.js +2 -2
- package/dist/deploy/internal.js.map +2 -2
- package/dist/deploy/types.d.ts +12 -59
- package/dist/deploy/types.d.ts.map +1 -1
- package/dist/env/index.d.ts +10 -3
- package/dist/env/index.d.ts.map +1 -1
- package/dist/env/index.js.map +2 -2
- package/dist/events/execution.d.ts +8 -1
- package/dist/events/execution.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 +37 -36
- package/dist/execution/agent.js.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 +36 -35
- 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 +33 -32
- package/dist/execution/request.js.map +3 -3
- package/dist/http/api-routes.d.ts.map +1 -1
- package/dist/http/index.js +1 -1
- package/dist/index.d.ts +7 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +63 -59
- package/dist/index.js.map +1 -1
- package/dist/maintenance/index.js +1 -1
- package/dist/materializer/index.js +22 -21
- package/dist/materializer/index.js.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 +20 -19
- 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 +36 -35
- 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 +19 -18
- 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 +21 -20
- package/dist/pipelines/index.js.map +1 -1
- package/dist/projections/internal.js +20 -19
- package/dist/projections/internal.js.map +1 -1
- package/dist/queues/in-memory.d.ts +1 -1
- package/dist/queues/in-memory.d.ts.map +1 -1
- package/dist/runtime/create.d.ts.map +1 -1
- package/dist/runtime/definitions.d.ts +14 -0
- package/dist/runtime/definitions.d.ts.map +1 -1
- package/dist/runtime/host.d.ts +3 -1
- package/dist/runtime/host.d.ts.map +1 -1
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/internal.js +24 -23
- package/dist/runtime/internal.js.map +2 -2
- package/dist/runtime/locale.d.ts +0 -2
- package/dist/runtime/locale.d.ts.map +1 -1
- package/dist/runtime/resolve-definitions.d.ts +2 -1
- package/dist/runtime/resolve-definitions.d.ts.map +1 -1
- 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/errors.d.ts +19 -0
- package/dist/sandboxes/errors.d.ts.map +1 -1
- package/dist/sandboxes/exec.d.ts +2 -0
- package/dist/sandboxes/exec.d.ts.map +1 -1
- package/dist/sandboxes/index.d.ts +4 -2
- package/dist/sandboxes/index.d.ts.map +1 -1
- package/dist/sandboxes/index.js +13 -7
- package/dist/sandboxes/index.js.map +1 -1
- package/dist/sandboxes/sandbox.d.ts +15 -1
- package/dist/sandboxes/sandbox.d.ts.map +1 -1
- package/dist/security/view-conditions.d.ts.map +1 -1
- package/dist/shares/internal.js +16 -15
- package/dist/shares/internal.js.map +2 -2
- package/dist/storage/agents/in-memory.d.ts +18 -1
- package/dist/storage/agents/in-memory.d.ts.map +1 -1
- package/dist/storage/agents/index.d.ts +1 -1
- package/dist/storage/agents/index.d.ts.map +1 -1
- package/dist/storage/agents/provider.d.ts +43 -9
- package/dist/storage/agents/provider.d.ts.map +1 -1
- package/dist/storage/agents/provider.js +19 -3
- package/dist/storage/agents/provider.js.map +1 -1
- package/dist/storage/agents/types.d.ts +150 -4
- 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.map +1 -1
- package/dist/storage/artifacts/record.d.ts +3 -1
- package/dist/storage/artifacts/record.d.ts.map +1 -1
- package/dist/storage/artifacts/types.d.ts +7 -0
- package/dist/storage/artifacts/types.d.ts.map +1 -1
- package/dist/storage/file-upload-sessions/provider.js +7 -7
- package/dist/storage/index.d.ts +2 -2
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +23 -22
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/internal.js +8 -8
- 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 +22 -21
- 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-inbox-storage-contract.d.ts.map +1 -1
- 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/index.js +1157 -100
- package/dist/testing/index.js.map +9 -9
- package/dist/testing/run-claim-storage-contract.d.ts.map +1 -1
- package/dist/testing/sandboxes-contract.d.ts.map +1 -1
- package/dist/webhooks/internal.js +17 -16
- package/dist/webhooks/internal.js.map +2 -2
- 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/worker.d.ts +8 -0
- package/dist/workers/worker.d.ts.map +1 -1
- package/dist/workflows/index.js +42 -40
- package/dist/workflows/index.js.map +1 -1
- package/package.json +7 -1
- package/src/actions/validation.ts +3 -1
- package/src/agents/children.ts +6 -0
- package/src/agents/errors.ts +3 -0
- package/src/agents/execution.ts +170 -20
- package/src/agents/index.ts +5 -0
- package/src/agents/model-routing.ts +116 -34
- package/src/agents/request.ts +783 -38
- package/src/agents/run-events.ts +235 -38
- package/src/agents/run-session-children.ts +13 -2
- package/src/agents/run-token.ts +7 -0
- package/src/agents/run-turn.ts +140 -23
- package/src/agents/streams/index.ts +2 -0
- package/src/agents/streams/internal.ts +12 -0
- package/src/agents/streams/protocol.ts +69 -1
- package/src/agents/streams/steps.ts +131 -0
- package/src/agents/thread-access.ts +57 -2
- package/src/artifacts/publish/merge.ts +14 -3
- package/src/artifacts/run-query.ts +5 -2
- package/src/bootstrap/discovery.ts +61 -11
- package/src/calendar.ts +195 -0
- package/src/connectors/connections/capability.ts +40 -0
- package/src/connectors/connections/internal.ts +3 -0
- package/src/connectors/connections/service.ts +74 -5
- package/src/connectors/execution.ts +5 -6
- package/src/connectors/service.ts +23 -0
- package/src/deploy/index.ts +0 -5
- package/src/deploy/types.ts +12 -64
- package/src/deploy/validation.ts +1 -1
- package/src/env/index.ts +10 -4
- package/src/events/execution.ts +42 -2
- package/src/events/types/syncs.ts +4 -0
- package/src/execution/authorized-object-reader.ts +33 -5
- package/src/execution/object-reader-ontology.ts +6 -0
- package/src/execution/request.ts +1 -0
- package/src/http/api-routes.ts +8 -0
- package/src/index.ts +21 -2
- 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/runtime/create.ts +1 -0
- package/src/runtime/definitions.ts +25 -0
- package/src/runtime/host.ts +16 -8
- package/src/runtime/index.ts +6 -1
- package/src/runtime/locale.ts +0 -10
- package/src/runtime/resolve-definitions.ts +7 -1
- package/src/runtime/sixb.ts +12 -2
- package/src/sandboxes/README.md +12 -1
- package/src/sandboxes/auth.ts +32 -4
- package/src/sandboxes/errors.ts +27 -0
- package/src/sandboxes/exec.ts +3 -1
- package/src/sandboxes/index.ts +18 -1
- package/src/sandboxes/sandbox.ts +15 -1
- package/src/security/view-conditions.ts +2 -1
- package/src/storage/agents/in-memory.ts +271 -6
- package/src/storage/agents/index.ts +10 -0
- package/src/storage/agents/provider.ts +178 -13
- package/src/storage/agents/types.ts +166 -4
- 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 +20 -5
- package/src/storage/artifacts/record.ts +8 -2
- package/src/storage/artifacts/types.ts +7 -0
- package/src/storage/index.ts +11 -0
- package/src/storage/operation-scope.ts +1 -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-inbox-storage-contract.ts +59 -0
- package/src/testing/agent-storage-contract.ts +794 -8
- package/src/testing/ai-cost-storage-contract.ts +80 -0
- package/src/testing/artifact-storage-contract.ts +139 -0
- package/src/testing/run-claim-storage-contract.ts +116 -0
- package/src/testing/sandboxes-contract.ts +50 -0
- 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/worker.ts +67 -7
- package/dist/chunk-5a4a52tq.js.map +0 -10
- package/dist/chunk-5t9gm5tt.js.map +0 -22
- package/dist/chunk-68hm50qh.js.map +0 -13
- package/dist/chunk-aw1z0gre.js +0 -234
- package/dist/chunk-aw1z0gre.js.map +0 -12
- package/dist/chunk-ey1p8w68.js.map +0 -13
- package/dist/chunk-k3jh8gsg.js.map +0 -10
- package/dist/chunk-nxysqbt0.js.map +0 -10
- package/dist/chunk-qavwr628.js.map +0 -12
- package/dist/chunk-s1mqyqmm.js.map +0 -18
- package/dist/chunk-zeykm8my.js.map +0 -14
- /package/dist/{chunk-stmxh0hv.js.map → chunk-3neam1y5.js.map} +0 -0
- /package/dist/{chunk-0hkdtwqk.js.map → chunk-44hrfmbk.js.map} +0 -0
- /package/dist/{chunk-s5pj68fa.js.map → chunk-5sswe5ej.js.map} +0 -0
- /package/dist/{chunk-q9nkpr8k.js.map → chunk-9tpmfh3n.js.map} +0 -0
- /package/dist/{chunk-naxjka9v.js.map → chunk-brhp9d97.js.map} +0 -0
- /package/dist/{chunk-8a8k38tz.js.map → chunk-brybqw5k.js.map} +0 -0
- /package/dist/{chunk-vehcr9eb.js.map → chunk-cg7cygfj.js.map} +0 -0
- /package/dist/{chunk-b4escq4c.js.map → chunk-cpy282b8.js.map} +0 -0
- /package/dist/{chunk-bc3y6gff.js.map → chunk-jka26v8c.js.map} +0 -0
- /package/dist/{chunk-zxhym8tr.js.map → chunk-k29rdc3h.js.map} +0 -0
- /package/dist/{chunk-1yh6jgtz.js.map → chunk-mrs7jy17.js.map} +0 -0
- /package/dist/{chunk-pqvvqc65.js.map → chunk-pfdq1ga6.js.map} +0 -0
- /package/dist/{chunk-k29n4176.js.map → chunk-phs5fbff.js.map} +0 -0
- /package/dist/{chunk-wqe9shx2.js.map → chunk-qbd282aa.js.map} +0 -0
- /package/dist/{chunk-paxabbqd.js.map → chunk-tapdssb5.js.map} +0 -0
- /package/dist/{chunk-dhkc9b23.js.map → chunk-v8a1qjzp.js.map} +0 -0
- /package/dist/{chunk-pc7kra3k.js.map → chunk-xavet0qs.js.map} +0 -0
- /package/dist/{chunk-m9ketb51.js.map → chunk-ygvay56w.js.map} +0 -0
- /package/dist/{chunk-0mvjpgvm.js.map → chunk-yyj009tv.js.map} +0 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { isRuntimeAllowed } from "../authorization"
|
|
2
|
+
import {
|
|
3
|
+
type ConnectorConnectionMetadata,
|
|
4
|
+
type ConnectorDefinition,
|
|
5
|
+
isOAuthConnectorDefinition,
|
|
6
|
+
type OAuthConnectorAdapter,
|
|
7
|
+
} from "../connectors"
|
|
8
|
+
import type { ConnectorService } from "../connectors/service"
|
|
9
|
+
import type { ExecutionContext } from "../execution"
|
|
10
|
+
import { resolveRuntimeAuthorizationForProject } from "../execution/authorization"
|
|
11
|
+
import type { SixbRuntimeContext } from "../runtime/types"
|
|
12
|
+
import type { SyncDefinition } from "./types"
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The connections a sync of an OAuth connector runs for: every connected one whose owner isn't
|
|
16
|
+
* suspended. Dispatch reads them without an execution, so a host registers them on itself.
|
|
17
|
+
*/
|
|
18
|
+
export interface SyncConnections {
|
|
19
|
+
list(
|
|
20
|
+
definition: ConnectorDefinition<string, OAuthConnectorAdapter>
|
|
21
|
+
): Promise<readonly ConnectorConnectionMetadata[]>
|
|
22
|
+
/** Every connection of the connector, whatever its status: each one a run has read. */
|
|
23
|
+
listAll(
|
|
24
|
+
definition: ConnectorDefinition<string, OAuthConnectorAdapter>
|
|
25
|
+
): Promise<readonly ConnectorConnectionMetadata[]>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const registered = new WeakMap<object, SyncConnections>()
|
|
29
|
+
|
|
30
|
+
export function registerSyncConnections(host: object, connections: SyncConnections): void {
|
|
31
|
+
registered.set(host, connections)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function findSyncConnections(host: object): SyncConnections | undefined {
|
|
35
|
+
return registered.get(host)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function createSyncConnections(
|
|
39
|
+
service: Pick<ConnectorService, "listExecutionConnections" | "listAllConnections">
|
|
40
|
+
): SyncConnections {
|
|
41
|
+
return {
|
|
42
|
+
async list(definition) {
|
|
43
|
+
return (await service.listExecutionConnections(definition)).map(toMetadata)
|
|
44
|
+
},
|
|
45
|
+
async listAll(definition) {
|
|
46
|
+
return (await service.listAllConnections(definition)).map(toMetadata)
|
|
47
|
+
},
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function toMetadata({
|
|
52
|
+
id,
|
|
53
|
+
connectorId,
|
|
54
|
+
owner,
|
|
55
|
+
slot,
|
|
56
|
+
account,
|
|
57
|
+
}: ConnectorConnectionMetadata): ConnectorConnectionMetadata {
|
|
58
|
+
return { id, connectorId, owner, slot, account }
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Whether a caller who may run a sync may run, and see, its runs of this connection. Anyone may
|
|
63
|
+
* run the project's. A person's own connection is theirs, and the connector's managers may act on
|
|
64
|
+
* anyone's: a sync reads into rows its owner owns, as the schedule would. A run no one requested
|
|
65
|
+
* may act on them all.
|
|
66
|
+
*/
|
|
67
|
+
export function mayRunConnection(
|
|
68
|
+
runtime: SixbRuntimeContext,
|
|
69
|
+
execution: ExecutionContext,
|
|
70
|
+
connection: ConnectorConnectionMetadata
|
|
71
|
+
): boolean {
|
|
72
|
+
return connection.owner.type === "project" || seesConnection(runtime, execution, connection)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The connections whose runs of these syncs the caller sees, as `mayRunConnection` decides: one
|
|
77
|
+
* listing per OAuth connector they read. Undefined when nothing is left out: no sync reads an
|
|
78
|
+
* OAuth connector, or the caller sees every run.
|
|
79
|
+
*/
|
|
80
|
+
export async function visibleSyncConnectionIds(
|
|
81
|
+
runtime: SixbRuntimeContext,
|
|
82
|
+
execution: ExecutionContext,
|
|
83
|
+
syncs: readonly (SyncDefinition | null)[],
|
|
84
|
+
connections: SyncConnections | undefined
|
|
85
|
+
): Promise<readonly string[] | undefined> {
|
|
86
|
+
const authority = resolveRuntimeAuthorizationForProject(runtime)
|
|
87
|
+
if (authority.type === "unrestricted" || execution.requestedBy === undefined) return undefined
|
|
88
|
+
|
|
89
|
+
const connectors = new Map<string, ConnectorDefinition<string, OAuthConnectorAdapter>>()
|
|
90
|
+
for (const sync of syncs) {
|
|
91
|
+
if (sync && isOAuthConnectorDefinition(sync.connector)) {
|
|
92
|
+
connectors.set(sync.connector.id, sync.connector)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
if (!connections || connectors.size === 0) return undefined
|
|
96
|
+
|
|
97
|
+
const all = await Promise.all(
|
|
98
|
+
[...connectors.values()].map((connector) => connections.listAll(connector))
|
|
99
|
+
)
|
|
100
|
+
return all
|
|
101
|
+
.flat()
|
|
102
|
+
.filter((connection) => mayRunConnection(runtime, execution, connection))
|
|
103
|
+
.map(({ id }) => id)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Whether the caller sees this connection itself, as the connector's connection views decide: the
|
|
108
|
+
* owner of a personal connection, the connector's managers, and runs no one requested.
|
|
109
|
+
*/
|
|
110
|
+
export function seesConnection(
|
|
111
|
+
runtime: SixbRuntimeContext,
|
|
112
|
+
execution: ExecutionContext,
|
|
113
|
+
connection: ConnectorConnectionMetadata
|
|
114
|
+
): boolean {
|
|
115
|
+
const { owner } = connection
|
|
116
|
+
const requester = execution.requestedBy
|
|
117
|
+
if (requester === undefined) return true
|
|
118
|
+
if (owner.type === "user" && requester.type === "user" && requester.id === owner.id) return true
|
|
119
|
+
return isRuntimeAllowed(runtime, {
|
|
120
|
+
kind: "connector.manage",
|
|
121
|
+
connectorId: connection.connectorId,
|
|
122
|
+
})
|
|
123
|
+
}
|
package/src/syncs/execution.ts
CHANGED
|
@@ -8,27 +8,40 @@ import type {
|
|
|
8
8
|
ListSyncRunsResult,
|
|
9
9
|
SyncRunRecord,
|
|
10
10
|
} from "../storage/sync-runs"
|
|
11
|
+
import { createSyncAccountsRuntime, type SyncAccountsRuntime } from "./accounts"
|
|
12
|
+
import { type SyncConnections, visibleSyncConnectionIds } from "./connections"
|
|
11
13
|
import { SyncValidationError } from "./errors"
|
|
12
|
-
import { type RequestSyncRunInput, requestSyncRun, type
|
|
14
|
+
import { type RequestSyncRunInput, requestSyncRun, type SyncRunRequestResults } from "./request"
|
|
13
15
|
import type { SyncDefinition } from "./types"
|
|
14
16
|
|
|
17
|
+
/**
|
|
18
|
+
* The runs of the syncs you may run. On a sync of an OAuth connector, only the runs of the
|
|
19
|
+
* connections you may run as well: the project's and your own, or everyone's with `can.manage` on
|
|
20
|
+
* the connector.
|
|
21
|
+
*/
|
|
15
22
|
export interface SyncRunsRuntime {
|
|
16
23
|
getById(runId: string): Promise<SyncRunRecord | null>
|
|
17
|
-
list(
|
|
24
|
+
list(
|
|
25
|
+
input?: Omit<ListSyncRunsInput, "projectId" | "syncIds" | "visibleConnectionIds">
|
|
26
|
+
): Promise<ListSyncRunsResult>
|
|
18
27
|
listLatest(syncIds: readonly string[]): Promise<ListLatestSyncRunsResult>
|
|
19
28
|
}
|
|
20
29
|
|
|
21
30
|
export interface SyncsRuntime {
|
|
22
31
|
list(): readonly SyncDefinition[]
|
|
23
32
|
getById(syncId: string): SyncDefinition | null
|
|
24
|
-
|
|
33
|
+
/** Queue a run, or on a sync of an OAuth connector one run per connection the caller may run. */
|
|
34
|
+
request(input: RequestSyncRunInput): Promise<SyncRunRequestResults>
|
|
25
35
|
readonly runs: SyncRunsRuntime
|
|
36
|
+
/** Where each connected account stands, on a sync of an OAuth connector. */
|
|
37
|
+
readonly accounts: SyncAccountsRuntime
|
|
26
38
|
}
|
|
27
39
|
|
|
28
40
|
export function createSyncsRuntime(
|
|
29
41
|
runtime: SixbRuntimeContext,
|
|
30
42
|
execution: ExecutionContext,
|
|
31
|
-
source: Pick<SyncsRuntime, "list" | "getById"
|
|
43
|
+
source: Pick<SyncsRuntime, "list" | "getById">,
|
|
44
|
+
connections?: SyncConnections
|
|
32
45
|
): SyncsRuntime {
|
|
33
46
|
const authority = resolveRuntimeAuthorizationForProject(runtime)
|
|
34
47
|
const allowed = (syncId: string) => isRuntimeAllowed(runtime, { kind: "sync.run", syncId })
|
|
@@ -44,21 +57,34 @@ export function createSyncsRuntime(
|
|
|
44
57
|
? visibleIds()
|
|
45
58
|
: []
|
|
46
59
|
|
|
60
|
+
const getById = (syncId: string) => {
|
|
61
|
+
if (authority.type === "denied" || authority.type === "delegated") return null
|
|
62
|
+
const sync = source.getById(syncId)
|
|
63
|
+
return sync && allowed(syncId) ? sync : null
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
const visibleConnectionIds = (syncs: readonly (SyncDefinition | null)[]) =>
|
|
67
|
+
visibleSyncConnectionIds(runtime, execution, syncs, connections)
|
|
68
|
+
|
|
47
69
|
return {
|
|
48
70
|
list: () =>
|
|
49
71
|
authority.type === "denied" || authority.type === "delegated"
|
|
50
72
|
? []
|
|
51
73
|
: source.list().filter((sync) => allowed(sync.id)),
|
|
52
|
-
getById
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
74
|
+
getById,
|
|
75
|
+
accounts: createSyncAccountsRuntime({
|
|
76
|
+
runtime,
|
|
77
|
+
execution,
|
|
78
|
+
syncs: () => source.list(),
|
|
79
|
+
runnable: getById,
|
|
80
|
+
...(connections === undefined ? {} : { connections }),
|
|
81
|
+
}),
|
|
57
82
|
request: async (input) => {
|
|
58
83
|
assertAuthorized(runtime, { kind: "sync.run", syncId: input.syncId })
|
|
59
84
|
const sync = source.getById(input.syncId)
|
|
60
85
|
if (!sync) throw new SyncValidationError(`[Sixb] Unknown sync '${input.syncId}'`)
|
|
61
|
-
|
|
86
|
+
const { syncId: _syncId, ...options } = input
|
|
87
|
+
return requestSyncRun(runtime, execution, sync, options, connections)
|
|
62
88
|
},
|
|
63
89
|
runs: {
|
|
64
90
|
getById: async (runId) => {
|
|
@@ -68,30 +94,46 @@ export function createSyncsRuntime(
|
|
|
68
94
|
projectId: runtime.projectId,
|
|
69
95
|
id: runId,
|
|
70
96
|
})) ?? null
|
|
71
|
-
|
|
97
|
+
if (!run || !allowed(run.syncId)) return null
|
|
98
|
+
|
|
99
|
+
const visible = await visibleConnectionIds([source.getById(run.syncId)])
|
|
100
|
+
const hidden =
|
|
101
|
+
run.connectionId !== undefined && visible?.includes(run.connectionId) === false
|
|
102
|
+
return hidden ? null : run
|
|
72
103
|
},
|
|
73
|
-
list: (input = {}) => {
|
|
104
|
+
list: async (input = {}) => {
|
|
74
105
|
if (authority.type === "denied" || authority.type === "delegated") {
|
|
75
|
-
return
|
|
106
|
+
return { runs: [], hasMore: false, total: 0 }
|
|
76
107
|
}
|
|
77
108
|
const storage = runtime.storage.syncRuns
|
|
78
|
-
if (!storage) return
|
|
109
|
+
if (!storage) return { runs: [], hasMore: false, total: 0 }
|
|
110
|
+
|
|
111
|
+
const syncs =
|
|
112
|
+
input.syncId === undefined
|
|
113
|
+
? source.list().filter((sync) => allowed(sync.id))
|
|
114
|
+
: [getById(input.syncId)]
|
|
115
|
+
const visible = await visibleConnectionIds(syncs)
|
|
79
116
|
return storage.list({
|
|
80
117
|
...input,
|
|
81
118
|
syncIds: historyFilterIds(),
|
|
119
|
+
...(visible === undefined ? {} : { visibleConnectionIds: visible }),
|
|
82
120
|
projectId: runtime.projectId,
|
|
83
121
|
})
|
|
84
122
|
},
|
|
85
|
-
listLatest: (syncIds) => {
|
|
86
|
-
if (authority.type === "denied" || authority.type === "delegated") {
|
|
87
|
-
return Promise.resolve({ runs: [] })
|
|
88
|
-
}
|
|
123
|
+
listLatest: async (syncIds) => {
|
|
124
|
+
if (authority.type === "denied" || authority.type === "delegated") return { runs: [] }
|
|
89
125
|
const storage = runtime.storage.syncRuns
|
|
90
|
-
if (!storage || syncIds.length === 0) return Promise.resolve({ runs: [] })
|
|
91
126
|
const allowedIds = syncIds.filter(allowed)
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
127
|
+
if (!storage || allowedIds.length === 0) return { runs: [] }
|
|
128
|
+
|
|
129
|
+
const visible = await visibleConnectionIds(
|
|
130
|
+
allowedIds.map((syncId) => source.getById(syncId))
|
|
131
|
+
)
|
|
132
|
+
return storage.listLatestBySyncIds({
|
|
133
|
+
projectId: runtime.projectId,
|
|
134
|
+
syncIds: allowedIds,
|
|
135
|
+
...(visible === undefined ? {} : { visibleConnectionIds: visible }),
|
|
136
|
+
})
|
|
95
137
|
},
|
|
96
138
|
},
|
|
97
139
|
}
|
package/src/syncs/index.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
export type { SyncAccount, SyncAccountsRuntime } from "./accounts"
|
|
1
2
|
export { defineSync } from "./builders"
|
|
2
3
|
export { SyncValidationError } from "./errors"
|
|
3
4
|
export type {
|
|
4
5
|
RequestSyncRunInput,
|
|
6
|
+
RequestSyncRunOptions,
|
|
5
7
|
SyncRunRequestOptions,
|
|
6
8
|
SyncRunRequestResult,
|
|
9
|
+
SyncRunRequestResults,
|
|
7
10
|
} from "./request"
|
|
8
11
|
export { requestSyncRun } from "./request"
|
|
9
12
|
export {
|
package/src/syncs/request.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { assertAuthorized } from "../authorization"
|
|
2
|
+
import { isOAuthConnectorDefinition } from "../connectors"
|
|
2
3
|
import { resolveExecutionScopeAuthorization } from "../execution/authorization"
|
|
3
4
|
import {
|
|
4
5
|
createPrimitiveExecutionRecord,
|
|
@@ -7,6 +8,7 @@ import {
|
|
|
7
8
|
} from "../execution/durable"
|
|
8
9
|
import type { ExecutionContext } from "../execution/types"
|
|
9
10
|
import type { SixbRuntimeContext } from "../runtime/types"
|
|
11
|
+
import { mayRunConnection, type SyncConnections } from "./connections"
|
|
10
12
|
import { SyncValidationError } from "./errors"
|
|
11
13
|
import { dispatchSyncRun } from "./run-dispatch"
|
|
12
14
|
import type { SyncDefinition } from "./types"
|
|
@@ -19,19 +21,34 @@ export interface SyncRunRequestOptions {
|
|
|
19
21
|
readonly commitMessage?: string
|
|
20
22
|
}
|
|
21
23
|
|
|
22
|
-
export interface
|
|
24
|
+
export interface RequestSyncRunOptions extends SyncRunRequestOptions {
|
|
25
|
+
/**
|
|
26
|
+
* The one connection to run, on a sync of an OAuth connector. Without it, the request runs every
|
|
27
|
+
* connection the caller may run.
|
|
28
|
+
*/
|
|
29
|
+
readonly connectionId?: string
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface RequestSyncRunInput extends RequestSyncRunOptions {
|
|
23
33
|
readonly syncId: string
|
|
24
34
|
}
|
|
25
35
|
|
|
26
36
|
export interface SyncRunRequestResult {
|
|
27
37
|
readonly syncId: string
|
|
28
38
|
readonly runId: string
|
|
39
|
+
/** The connection the run reads, on a sync of an OAuth connector. */
|
|
40
|
+
readonly connectionId?: string
|
|
29
41
|
/** Durable time at which the run entered the queue. */
|
|
30
42
|
readonly queuedAt: string
|
|
31
43
|
readonly jobId?: string
|
|
32
44
|
readonly created: boolean
|
|
33
45
|
}
|
|
34
46
|
|
|
47
|
+
/** A static connector's sync queues one run; an OAuth connector's sync one per connection. */
|
|
48
|
+
export interface SyncRunRequestResults {
|
|
49
|
+
readonly runs: readonly SyncRunRequestResult[]
|
|
50
|
+
}
|
|
51
|
+
|
|
35
52
|
/**
|
|
36
53
|
* Authorize and queue a sync run request.
|
|
37
54
|
*
|
|
@@ -44,8 +61,9 @@ export async function requestSyncRun(
|
|
|
44
61
|
runtime: SixbRuntimeContext,
|
|
45
62
|
execution: ExecutionContext,
|
|
46
63
|
sync: SyncDefinition,
|
|
47
|
-
options:
|
|
48
|
-
|
|
64
|
+
options: RequestSyncRunOptions = {},
|
|
65
|
+
connections?: SyncConnections
|
|
66
|
+
): Promise<SyncRunRequestResults> {
|
|
49
67
|
resolveExecutionScopeAuthorization(runtime.projectId, {
|
|
50
68
|
execution,
|
|
51
69
|
authorization: runtime.runtimeAuthorization,
|
|
@@ -60,26 +78,66 @@ export async function requestSyncRun(
|
|
|
60
78
|
throw new SyncValidationError("[Sixb] Sync run queue is not configured.")
|
|
61
79
|
}
|
|
62
80
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
81
|
+
const { connectionId, ...request } = options
|
|
82
|
+
const dispatch = (runId: string | undefined, connection?: string) =>
|
|
83
|
+
dispatchSyncRun({
|
|
84
|
+
errorReporterHost: runtime,
|
|
85
|
+
projectId: runtime.projectId,
|
|
86
|
+
sync,
|
|
87
|
+
storage: runtime.storage,
|
|
88
|
+
queue,
|
|
89
|
+
...request,
|
|
90
|
+
...(runId === undefined ? {} : { runId }),
|
|
91
|
+
// A run that has not started reads its connection when it starts: a request that arrives
|
|
92
|
+
// meanwhile, like a burst of a person's notifications, is already covered by it.
|
|
93
|
+
...(connection === undefined ? {} : { connectionId: connection, joinQueuedRun: true }),
|
|
94
|
+
createExecution: async (executionId, queuedRunId) => {
|
|
95
|
+
const caller = await ensureExecutionRecord(
|
|
96
|
+
runtime.storage.executions,
|
|
97
|
+
executionRecordInputFromRuntime({
|
|
98
|
+
execution,
|
|
99
|
+
runtimeAuthorization: runtime.runtimeAuthorization,
|
|
100
|
+
})
|
|
101
|
+
)
|
|
102
|
+
return createPrimitiveExecutionRecord({
|
|
103
|
+
id: executionId,
|
|
104
|
+
primitive: { kind: "sync", id: sync.id, runId: queuedRunId },
|
|
105
|
+
origin: { type: "execution", parent: caller },
|
|
76
106
|
})
|
|
107
|
+
},
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
if (!isOAuthConnectorDefinition(sync.connector)) {
|
|
111
|
+
if (connectionId !== undefined) {
|
|
112
|
+
throw new SyncValidationError(
|
|
113
|
+
`[Sixb] Sync '${sync.id}' reads static connector '${sync.connector.id}', which has no connections.`
|
|
77
114
|
)
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
115
|
+
}
|
|
116
|
+
return { runs: [await dispatch(request.runId)] }
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (!connections) {
|
|
120
|
+
throw new SyncValidationError(
|
|
121
|
+
`[Sixb] Sync '${sync.id}' reads OAuth connector '${sync.connector.id}', whose connections this runtime cannot list.`
|
|
122
|
+
)
|
|
123
|
+
}
|
|
124
|
+
const runnable = (await connections.list(sync.connector)).filter((connection) =>
|
|
125
|
+
mayRunConnection(runtime, execution, connection)
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
if (connectionId !== undefined) {
|
|
129
|
+
if (!runnable.some((connection) => connection.id === connectionId)) {
|
|
130
|
+
throw new SyncValidationError(
|
|
131
|
+
`[Sixb] Sync '${sync.id}' has no connection '${connectionId}' you can run.`
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
return { runs: [await dispatch(request.runId, connectionId)] }
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const runs: SyncRunRequestResult[] = []
|
|
138
|
+
for (const connection of runnable) {
|
|
139
|
+
const runId = request.runId === undefined ? undefined : `${request.runId}:${connection.id}`
|
|
140
|
+
runs.push(await dispatch(runId, connection.id))
|
|
141
|
+
}
|
|
142
|
+
return { runs }
|
|
85
143
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isOAuthConnectorDefinition } from "../connectors"
|
|
1
2
|
import { reportRunFailure } from "../error-reporting/capability"
|
|
2
3
|
import { toSixbFailure } from "../errors/internal"
|
|
3
4
|
import type { RunDispatcher } from "../execution/dispatch"
|
|
@@ -13,6 +14,7 @@ import {
|
|
|
13
14
|
type QueuedRunStore,
|
|
14
15
|
type RunPublication,
|
|
15
16
|
} from "../workers/queued-run-dispatch"
|
|
17
|
+
import { findSyncConnections } from "./connections"
|
|
16
18
|
import { SyncValidationError } from "./errors"
|
|
17
19
|
import type { SyncRunRequestOptions, SyncRunRequestResult } from "./request"
|
|
18
20
|
import type { SyncDefinition } from "./types"
|
|
@@ -27,9 +29,18 @@ export interface AutomaticSyncRunDispatchInput extends SyncRunRequestOptions {
|
|
|
27
29
|
readonly source: AutomaticSyncExecutionSource
|
|
28
30
|
readonly correlationId: string
|
|
29
31
|
readonly metadata?: Readonly<Record<string, string>>
|
|
32
|
+
/**
|
|
33
|
+
* The connection the triggering event is about. A sync of that connection's connector runs for
|
|
34
|
+
* it alone; any other sync runs for every connection as usual.
|
|
35
|
+
*/
|
|
36
|
+
readonly connection?: { readonly id: string; readonly connectorId: string }
|
|
30
37
|
}
|
|
31
38
|
|
|
32
|
-
|
|
39
|
+
/** A sync of a static connector queues one run; a sync of an OAuth connector one per connection. */
|
|
40
|
+
export type SyncRunDispatchPort = RunDispatcher<
|
|
41
|
+
AutomaticSyncRunDispatchInput,
|
|
42
|
+
readonly SyncRunRequestResult[]
|
|
43
|
+
>
|
|
33
44
|
|
|
34
45
|
export interface SyncRunDispatcherDependencies {
|
|
35
46
|
readonly id: string
|
|
@@ -42,6 +53,8 @@ interface DispatchSyncRunInput extends SyncRunRequestOptions {
|
|
|
42
53
|
readonly errorReporterHost: object
|
|
43
54
|
readonly projectId: string
|
|
44
55
|
readonly sync: SyncDefinition
|
|
56
|
+
/** The connection this run reads, on a sync of an OAuth connector. */
|
|
57
|
+
readonly connectionId?: string
|
|
45
58
|
readonly storage: Storage
|
|
46
59
|
readonly queue: Queues["syncRuns"]
|
|
47
60
|
readonly metadata?: Readonly<Record<string, string>>
|
|
@@ -57,18 +70,45 @@ interface DispatchSyncRunInput extends SyncRunRequestOptions {
|
|
|
57
70
|
export class SyncRunDispatcher implements SyncRunDispatchPort {
|
|
58
71
|
constructor(private readonly dependencies: SyncRunDispatcherDependencies) {}
|
|
59
72
|
|
|
60
|
-
async dispatch(input: AutomaticSyncRunDispatchInput): Promise<SyncRunRequestResult> {
|
|
73
|
+
async dispatch(input: AutomaticSyncRunDispatchInput): Promise<readonly SyncRunRequestResult[]> {
|
|
61
74
|
assertAutomaticDispatchInput(input)
|
|
62
75
|
const sync = this.dependencies.definitions.syncs.getById(input.syncId)
|
|
63
76
|
if (!sync) throw new SyncValidationError(`[Sixb] Unknown sync '${input.syncId}'`)
|
|
64
77
|
|
|
78
|
+
if (!isOAuthConnectorDefinition(sync.connector)) {
|
|
79
|
+
return [await this.dispatchRun(sync, input, input.runId)]
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const connectionIds =
|
|
83
|
+
input.connection?.connectorId === sync.connector.id
|
|
84
|
+
? [input.connection.id]
|
|
85
|
+
: await listSyncConnectionIds(this.dependencies, sync)
|
|
86
|
+
|
|
87
|
+
// Each run id comes from the trigger's and the connection's, so a redelivered trigger, or one
|
|
88
|
+
// retried after some of its runs were queued, queues nothing twice.
|
|
89
|
+
const results: SyncRunRequestResult[] = []
|
|
90
|
+
for (const connectionId of connectionIds) {
|
|
91
|
+
results.push(
|
|
92
|
+
await this.dispatchRun(sync, input, `${input.runId}:${connectionId}`, connectionId)
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
return results
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
private dispatchRun(
|
|
99
|
+
sync: SyncDefinition,
|
|
100
|
+
input: AutomaticSyncRunDispatchInput,
|
|
101
|
+
runId: string,
|
|
102
|
+
connectionId?: string
|
|
103
|
+
): Promise<SyncRunRequestResult> {
|
|
65
104
|
return dispatchSyncRun({
|
|
66
105
|
errorReporterHost: this.dependencies,
|
|
67
106
|
projectId: this.dependencies.id,
|
|
68
107
|
sync,
|
|
108
|
+
...(connectionId === undefined ? {} : { connectionId }),
|
|
69
109
|
storage: this.dependencies.storage,
|
|
70
110
|
queue: this.dependencies.queues.syncRuns,
|
|
71
|
-
runId
|
|
111
|
+
runId,
|
|
72
112
|
expectedLatestVersionId: input.expectedLatestVersionId,
|
|
73
113
|
commitMessage: input.commitMessage,
|
|
74
114
|
metadata: input.metadata,
|
|
@@ -76,10 +116,10 @@ export class SyncRunDispatcher implements SyncRunDispatchPort {
|
|
|
76
116
|
validateExistingRun: (run, storage) =>
|
|
77
117
|
assertAutomaticExecutionIdentity(storage, this.dependencies.id, input, run),
|
|
78
118
|
joinQueuedRun: true,
|
|
79
|
-
createExecution: async (executionId,
|
|
119
|
+
createExecution: async (executionId, queuedRunId) =>
|
|
80
120
|
createPrimitiveExecutionRecord({
|
|
81
121
|
id: executionId,
|
|
82
|
-
primitive: { kind: "sync", id: sync.id, runId },
|
|
122
|
+
primitive: { kind: "sync", id: sync.id, runId: queuedRunId },
|
|
83
123
|
origin: {
|
|
84
124
|
type: "automatic",
|
|
85
125
|
projectId: this.dependencies.id,
|
|
@@ -170,6 +210,7 @@ function syncRunStore(
|
|
|
170
210
|
const { runs: queued } = await runs.list({
|
|
171
211
|
projectId,
|
|
172
212
|
syncId: sync.id,
|
|
213
|
+
connectionId: input.connectionId ?? null,
|
|
173
214
|
statuses: ["queued"],
|
|
174
215
|
order: "asc",
|
|
175
216
|
limit: 1,
|
|
@@ -184,6 +225,7 @@ function syncRunStore(
|
|
|
184
225
|
id: run.id,
|
|
185
226
|
executionId: run.executionId,
|
|
186
227
|
syncId: sync.id,
|
|
228
|
+
...(input.connectionId === undefined ? {} : { connectionId: input.connectionId }),
|
|
187
229
|
datasetId: sync.target.dataset.id,
|
|
188
230
|
mode: sync.config.mode,
|
|
189
231
|
queuedAt: run.queuedAt,
|
|
@@ -197,6 +239,7 @@ function syncRunStore(
|
|
|
197
239
|
id: run.id,
|
|
198
240
|
executionId: run.executionId,
|
|
199
241
|
syncId: run.syncId,
|
|
242
|
+
...(run.connectionId === undefined ? {} : { connectionId: run.connectionId }),
|
|
200
243
|
datasetId: run.datasetId,
|
|
201
244
|
mode: run.mode,
|
|
202
245
|
queuedAt,
|
|
@@ -208,14 +251,18 @@ function syncRunStore(
|
|
|
208
251
|
|
|
209
252
|
/**
|
|
210
253
|
* A run that has not started reads its source when it starts, so it already covers a trigger that
|
|
211
|
-
* arrives now. One queued with another request payload is not joined.
|
|
254
|
+
* arrives now. One queued for another connection, or with another request payload, is not joined.
|
|
212
255
|
*/
|
|
213
256
|
function runMatchesRequest(
|
|
214
257
|
existing: SyncRunRecord,
|
|
215
|
-
input: Pick<
|
|
258
|
+
input: Pick<
|
|
259
|
+
DispatchSyncRunInput,
|
|
260
|
+
"sync" | "connectionId" | "expectedLatestVersionId" | "commitMessage"
|
|
261
|
+
>
|
|
216
262
|
): boolean {
|
|
217
263
|
return (
|
|
218
264
|
existing.syncId === input.sync.id &&
|
|
265
|
+
existing.connectionId === input.connectionId &&
|
|
219
266
|
existing.datasetId === input.sync.target.dataset.id &&
|
|
220
267
|
existing.mode === input.sync.config.mode &&
|
|
221
268
|
existing.expectedLatestVersionId === input.expectedLatestVersionId &&
|
|
@@ -227,12 +274,27 @@ function toRequestResult(run: SyncRunRecord, publication?: RunPublication): Sync
|
|
|
227
274
|
return {
|
|
228
275
|
syncId: run.syncId,
|
|
229
276
|
runId: run.id,
|
|
277
|
+
...(run.connectionId === undefined ? {} : { connectionId: run.connectionId }),
|
|
230
278
|
queuedAt: (publication?.queuedAt ?? run.queuedAt).toISOString(),
|
|
231
279
|
...(publication ? { jobId: publication.jobId } : {}),
|
|
232
280
|
created: publication?.created ?? false,
|
|
233
281
|
}
|
|
234
282
|
}
|
|
235
283
|
|
|
284
|
+
async function listSyncConnectionIds(
|
|
285
|
+
host: object,
|
|
286
|
+
sync: SyncDefinition
|
|
287
|
+
): Promise<readonly string[]> {
|
|
288
|
+
if (!isOAuthConnectorDefinition(sync.connector)) return []
|
|
289
|
+
const connections = findSyncConnections(host)
|
|
290
|
+
if (!connections) {
|
|
291
|
+
throw new SyncValidationError(
|
|
292
|
+
`[Sixb] Sync '${sync.id}' reads OAuth connector '${sync.connector.id}', whose connections this host cannot list.`
|
|
293
|
+
)
|
|
294
|
+
}
|
|
295
|
+
return (await connections.list(sync.connector)).map((connection) => connection.id)
|
|
296
|
+
}
|
|
297
|
+
|
|
236
298
|
function requireSyncRunStorage(storage: Storage): NonNullable<Storage["syncRuns"]> {
|
|
237
299
|
if (!storage.syncRuns) throw new SyncValidationError("[Sixb] Sync run storage is not configured.")
|
|
238
300
|
return storage.syncRuns
|