@sixb/core 0.1.9 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/actions/index.js +9 -9
- package/dist/agents/index.js +17 -16
- package/dist/agents/index.js.map +1 -1
- package/dist/blob-storage/types.d.ts +4 -1
- package/dist/blob-storage/types.d.ts.map +1 -1
- package/dist/bootstrap/index.js +21 -20
- package/dist/bootstrap/index.js.map +1 -1
- package/dist/broker/in-memory.d.ts +8 -2
- package/dist/broker/in-memory.d.ts.map +1 -1
- package/dist/broker/index.d.ts +4 -2
- package/dist/broker/index.d.ts.map +1 -1
- package/dist/broker/index.js +7 -3
- package/dist/broker/index.js.map +1 -1
- package/dist/broker/retention.d.ts +4 -0
- package/dist/broker/retention.d.ts.map +1 -0
- package/dist/broker/subscriber.d.ts +10 -0
- package/dist/broker/subscriber.d.ts.map +1 -0
- package/dist/broker/types.d.ts +14 -1
- package/dist/broker/types.d.ts.map +1 -1
- package/dist/{chunk-ypbtykv6.js → chunk-01kj2pbh.js} +1 -1
- package/dist/{chunk-k3cqkkn2.js → chunk-1824gssz.js} +30 -65
- package/dist/chunk-1824gssz.js.map +12 -0
- package/dist/{chunk-xyr8kppc.js → chunk-1yefycb1.js} +1 -1
- package/dist/chunk-2c4j899j.js.map +1 -1
- package/dist/{chunk-ppytyr6w.js → chunk-358caqf5.js} +4 -4
- package/dist/chunk-358caqf5.js.map +12 -0
- package/dist/{chunk-m3z3x9v0.js → chunk-3ckk0xfj.js} +2 -2
- package/dist/{chunk-kxwa347f.js → chunk-3qms4nax.js} +2 -2
- package/dist/{chunk-kxwa347f.js.map → chunk-3qms4nax.js.map} +3 -3
- package/dist/{chunk-52hbv0ak.js → chunk-4zhmdsx6.js} +141 -55
- package/dist/chunk-4zhmdsx6.js.map +36 -0
- package/dist/{chunk-zcnq6105.js → chunk-85cd7e8c.js} +2 -1
- package/dist/chunk-85cd7e8c.js.map +10 -0
- package/dist/{chunk-3f7veca0.js → chunk-9x8dybsb.js} +3 -3
- package/dist/chunk-9x8dybsb.js.map +10 -0
- package/dist/{chunk-0w35wavj.js → chunk-a0e6x5hd.js} +1 -1
- package/dist/{chunk-r29fxdhn.js → chunk-aa6z4a19.js} +160 -44
- package/dist/chunk-aa6z4a19.js.map +12 -0
- package/dist/{chunk-emyyk7dx.js → chunk-cfvakeax.js} +22 -145
- package/dist/chunk-cfvakeax.js.map +12 -0
- package/dist/chunk-d62kjtbg.js.map +1 -1
- package/dist/{chunk-h1gfhhbh.js → chunk-d63nnr5b.js} +2 -2
- package/dist/{chunk-r4tfx1sf.js → chunk-fh8kgex1.js} +5 -5
- package/dist/{chunk-an5tt9y0.js → chunk-ftv470j8.js} +42 -4
- package/dist/{chunk-an5tt9y0.js.map → chunk-ftv470j8.js.map} +7 -7
- package/dist/{chunk-jjy0fhrn.js → chunk-g91qxjj0.js} +20 -3
- package/dist/chunk-g91qxjj0.js.map +12 -0
- package/dist/{chunk-hpr1r6av.js → chunk-gq8vhakp.js} +51 -40
- package/dist/{chunk-hpr1r6av.js.map → chunk-gq8vhakp.js.map} +6 -6
- package/dist/{chunk-x57ycxq0.js → chunk-gqh45d2n.js} +42 -3
- package/dist/{chunk-x57ycxq0.js.map → chunk-gqh45d2n.js.map} +3 -3
- package/dist/{chunk-mjbk2djy.js → chunk-gqm76kse.js} +231 -125
- package/dist/{chunk-mjbk2djy.js.map → chunk-gqm76kse.js.map} +9 -8
- package/dist/{chunk-e0d1rzef.js → chunk-jsy70480.js} +16 -3
- package/dist/chunk-jsy70480.js.map +15 -0
- package/dist/{chunk-0rdrecsb.js → chunk-kfee1h52.js} +116 -32
- package/dist/chunk-kfee1h52.js.map +13 -0
- package/dist/{chunk-3frsnm7x.js → chunk-qma80ych.js} +4 -6
- package/dist/chunk-qma80ych.js.map +11 -0
- package/dist/{chunk-vf691g1r.js → chunk-sepyxgpc.js} +3 -3
- package/dist/chunk-v2vcg0w6.js +151 -0
- package/dist/chunk-v2vcg0w6.js.map +11 -0
- package/dist/{chunk-3tgwrcyh.js → chunk-wf88w4kp.js} +17 -23
- package/dist/chunk-wf88w4kp.js.map +14 -0
- package/dist/{chunk-xfbydgzy.js → chunk-x9m9x2eq.js} +7 -8
- package/dist/{chunk-xfbydgzy.js.map → chunk-x9m9x2eq.js.map} +3 -3
- package/dist/{chunk-qhcpj9wc.js → chunk-z0271qkp.js} +98 -2
- package/dist/chunk-z0271qkp.js.map +15 -0
- package/dist/{chunk-1enhpacz.js → chunk-z0s4axeh.js} +6 -6
- package/dist/connectors/connections/authorizations.d.ts.map +1 -1
- package/dist/connectors/connections/command-context.d.ts +2 -0
- package/dist/connectors/connections/command-context.d.ts.map +1 -1
- package/dist/connectors/connections/contracts.d.ts +4 -1
- package/dist/connectors/connections/contracts.d.ts.map +1 -1
- package/dist/connectors/connections/execution.d.ts +1 -0
- package/dist/connectors/connections/execution.d.ts.map +1 -1
- package/dist/connectors/connections/internal.js +1 -1
- package/dist/connectors/connections/request.d.ts +3 -1
- package/dist/connectors/connections/request.d.ts.map +1 -1
- package/dist/connectors/connections/runs.d.ts +1 -0
- package/dist/connectors/connections/runs.d.ts.map +1 -1
- package/dist/connectors/connections/service.d.ts +2 -0
- package/dist/connectors/connections/service.d.ts.map +1 -1
- package/dist/connectors/connections/tokens.d.ts.map +1 -1
- package/dist/connectors/connections/validation.d.ts +5 -1
- package/dist/connectors/connections/validation.d.ts.map +1 -1
- package/dist/connectors/types.d.ts +19 -4
- package/dist/connectors/types.d.ts.map +1 -1
- package/dist/events/execution.d.ts +1 -1
- package/dist/events/execution.d.ts.map +1 -1
- package/dist/events/index.js +1 -1
- package/dist/events/outbox-dispatcher.d.ts +2 -2
- package/dist/events/outbox-dispatcher.d.ts.map +1 -1
- package/dist/events/service.d.ts +2 -2
- package/dist/events/service.d.ts.map +1 -1
- package/dist/execution/agent.js +17 -16
- package/dist/execution/agent.js.map +1 -1
- package/dist/execution/primitive.js +17 -16
- package/dist/execution/primitive.js.map +2 -2
- package/dist/execution/request.js +17 -16
- package/dist/execution/request.js.map +2 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +31 -29
- package/dist/index.js.map +1 -1
- package/dist/lake-storage/changes.d.ts +5 -0
- package/dist/lake-storage/changes.d.ts.map +1 -0
- package/dist/lake-storage/in-memory.d.ts +2 -1
- package/dist/lake-storage/in-memory.d.ts.map +1 -1
- package/dist/lake-storage/index.d.ts +2 -1
- package/dist/lake-storage/index.d.ts.map +1 -1
- package/dist/lake-storage/index.js +4 -2
- package/dist/lake-storage/index.js.map +1 -1
- package/dist/lake-storage/types.d.ts +38 -0
- package/dist/lake-storage/types.d.ts.map +1 -1
- package/dist/logging/internal.js +1 -1
- package/dist/maintenance/ontology-maintenance.d.ts.map +1 -1
- package/dist/maintenance/types.d.ts +1 -1
- package/dist/maintenance/types.d.ts.map +1 -1
- package/dist/materialization/index.d.ts +1 -1
- package/dist/materialization/index.d.ts.map +1 -1
- package/dist/materialization/model.d.ts +12 -1
- package/dist/materialization/model.d.ts.map +1 -1
- package/dist/materializer/index.d.ts +1 -1
- package/dist/materializer/index.d.ts.map +1 -1
- package/dist/materializer/index.js +6 -6
- package/dist/materializer/materializer.d.ts +5 -1
- package/dist/materializer/materializer.d.ts.map +1 -1
- package/dist/materializer/projections/entry-validator.d.ts +2 -1
- package/dist/materializer/projections/entry-validator.d.ts.map +1 -1
- package/dist/materializer/projections/replace.d.ts.map +1 -1
- package/dist/materializer/projections/source-materialization.d.ts +4 -3
- package/dist/materializer/projections/source-materialization.d.ts.map +1 -1
- package/dist/materializer/shared/normalize.d.ts +2 -1
- package/dist/materializer/shared/normalize.d.ts.map +1 -1
- package/dist/models/definitions.d.ts +7 -0
- package/dist/models/definitions.d.ts.map +1 -1
- package/dist/models/execution/index.js +6 -6
- package/dist/models/index.js +1 -1
- package/dist/objects/index.js +10 -10
- package/dist/objects/query/index.js +6 -6
- package/dist/pipelines/index.js +7 -7
- package/dist/pipelines/run-dispatch.d.ts.map +1 -1
- package/dist/projections/internal.js +7 -9
- package/dist/projections/internal.js.map +1 -1
- package/dist/projections/run-dispatch.d.ts.map +1 -1
- package/dist/queues/in-memory.d.ts +7 -3
- package/dist/queues/in-memory.d.ts.map +1 -1
- package/dist/queues/index.js +1 -1
- package/dist/queues/indexed-heap.d.ts +15 -0
- package/dist/queues/indexed-heap.d.ts.map +1 -0
- package/dist/runtime/host.d.ts.map +1 -1
- package/dist/runtime/internal.js +1 -1
- package/dist/runtime/ontology-mutations.d.ts +3 -1
- package/dist/runtime/ontology-mutations.d.ts.map +1 -1
- package/dist/shares/internal.js +5 -5
- package/dist/storage/agents/provider.js +1 -1
- package/dist/storage/connector-connections/in-memory.d.ts +1 -0
- package/dist/storage/connector-connections/in-memory.d.ts.map +1 -1
- package/dist/storage/connector-connections/provider/connections.d.ts.map +1 -1
- package/dist/storage/connector-connections/provider/runs.d.ts +1 -0
- package/dist/storage/connector-connections/provider/runs.d.ts.map +1 -1
- package/dist/storage/connector-connections/provider/shared.d.ts +1 -0
- package/dist/storage/connector-connections/provider/shared.d.ts.map +1 -1
- package/dist/storage/connector-connections/provider.d.ts +1 -0
- package/dist/storage/connector-connections/provider.d.ts.map +1 -1
- package/dist/storage/connector-connections/provider.js +11 -17
- package/dist/storage/connector-connections/provider.js.map +6 -6
- package/dist/storage/connector-connections/types.d.ts +6 -3
- package/dist/storage/connector-connections/types.d.ts.map +1 -1
- package/dist/storage/index.d.ts +1 -1
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +5 -5
- package/dist/storage/internal.js +1 -1
- package/dist/storage/ontology/in-memory/materializations-state.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/materializations.d.ts +1 -1
- package/dist/storage/ontology/in-memory/materializations.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/shared-state.d.ts +15 -2
- package/dist/storage/ontology/in-memory/shared-state.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/source-roots.d.ts +6 -0
- package/dist/storage/ontology/in-memory/source-roots.d.ts.map +1 -0
- package/dist/storage/ontology/in-memory/sources.d.ts.map +1 -1
- package/dist/storage/ontology/index.d.ts +1 -1
- package/dist/storage/ontology/index.d.ts.map +1 -1
- package/dist/storage/ontology/outbox.d.ts +1 -0
- package/dist/storage/ontology/outbox.d.ts.map +1 -1
- package/dist/storage/ontology/provider.d.ts +16 -0
- package/dist/storage/ontology/provider.d.ts.map +1 -1
- package/dist/storage/ontology/provider.js +4 -2
- package/dist/storage/ontology/provider.js.map +1 -1
- package/dist/storage/ontology/sources.d.ts +13 -4
- package/dist/storage/ontology/sources.d.ts.map +1 -1
- package/dist/storage/projection-runs/lifecycle.d.ts.map +1 -1
- package/dist/storage/projection-runs/provider.js +2 -2
- package/dist/storage/projection-runs/types.d.ts +2 -0
- package/dist/storage/projection-runs/types.d.ts.map +1 -1
- package/dist/syncs/index.js +9 -8
- package/dist/syncs/index.js.map +1 -1
- package/dist/syncs/run-dispatch.d.ts.map +1 -1
- package/dist/testing/broker-contract.d.ts.map +1 -1
- package/dist/testing/connector-connection-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 +1499 -963
- package/dist/testing/index.js.map +10 -9
- package/dist/testing/lake-changes-contract.d.ts +6 -0
- package/dist/testing/lake-changes-contract.d.ts.map +1 -0
- package/dist/testing/lake-storage-contract.d.ts.map +1 -1
- package/dist/testing/materializer-storage-contract.d.ts.map +1 -1
- package/dist/testing/ontology-storage-contract.d.ts.map +1 -1
- package/dist/testing/projection-run-storage-contract.d.ts.map +1 -1
- package/dist/webhooks/connections.d.ts +6 -0
- package/dist/webhooks/connections.d.ts.map +1 -0
- package/dist/webhooks/index.d.ts +1 -1
- package/dist/webhooks/index.d.ts.map +1 -1
- package/dist/webhooks/internal.d.ts +2 -0
- package/dist/webhooks/internal.d.ts.map +1 -1
- package/dist/webhooks/internal.js +55 -10
- package/dist/webhooks/internal.js.map +4 -3
- package/dist/webhooks/registry.d.ts +1 -1
- package/dist/webhooks/registry.d.ts.map +1 -1
- package/dist/webhooks/types.d.ts +15 -4
- package/dist/webhooks/types.d.ts.map +1 -1
- package/dist/workflows/index.js +18 -17
- package/dist/workflows/index.js.map +1 -1
- package/dist/workflows/run-dispatch.d.ts +3 -1
- package/dist/workflows/run-dispatch.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/agents/model-loop.ts +7 -0
- package/src/blob-storage/types.ts +4 -1
- package/src/broker/in-memory.ts +104 -39
- package/src/broker/index.ts +4 -1
- package/src/broker/retention.ts +28 -0
- package/src/broker/subscriber.ts +21 -0
- package/src/broker/types.ts +15 -1
- package/src/connectors/builders.ts +0 -6
- package/src/connectors/connections/authorizations.ts +11 -5
- package/src/connectors/connections/command-context.ts +21 -4
- package/src/connectors/connections/contracts.ts +7 -1
- package/src/connectors/connections/execution.ts +3 -0
- package/src/connectors/connections/request.ts +56 -22
- package/src/connectors/connections/runs.ts +39 -1
- package/src/connectors/connections/service.ts +6 -0
- package/src/connectors/connections/tokens.ts +4 -0
- package/src/connectors/connections/validation.ts +91 -5
- package/src/connectors/types.ts +19 -4
- package/src/events/execution.ts +2 -2
- package/src/events/outbox-dispatcher.ts +20 -26
- package/src/events/service.ts +3 -3
- package/src/index.ts +10 -2
- package/src/lake-storage/changes.ts +43 -0
- package/src/lake-storage/in-memory.ts +75 -0
- package/src/lake-storage/index.ts +4 -0
- package/src/lake-storage/types.ts +42 -0
- package/src/logging/service.ts +1 -1
- package/src/maintenance/ontology-maintenance.ts +6 -2
- package/src/maintenance/types.ts +1 -1
- package/src/materialization/index.ts +2 -0
- package/src/materialization/model.ts +14 -1
- package/src/materializer/README.md +1 -1
- package/src/materializer/index.ts +2 -0
- package/src/materializer/materializer.ts +10 -0
- package/src/materializer/projections/entry-validator.ts +19 -1
- package/src/materializer/projections/replace.ts +36 -1
- package/src/materializer/projections/source-materialization.ts +26 -6
- package/src/materializer/shared/normalize.ts +1 -1
- package/src/models/definitions.ts +19 -0
- package/src/models/pricing.ts +6 -2
- package/src/pipelines/run-dispatch.ts +21 -1
- package/src/projections/run-dispatch.ts +30 -68
- package/src/queues/in-memory.ts +105 -62
- package/src/queues/indexed-heap.ts +74 -0
- package/src/runtime/host.ts +0 -14
- package/src/runtime/ontology-mutations.ts +4 -0
- package/src/storage/connector-connections/in-memory.ts +19 -19
- package/src/storage/connector-connections/provider/connections.ts +1 -15
- package/src/storage/connector-connections/provider/runs.ts +9 -1
- package/src/storage/connector-connections/provider/shared.ts +2 -3
- package/src/storage/connector-connections/provider.ts +6 -0
- package/src/storage/connector-connections/types.ts +8 -3
- package/src/storage/index.ts +1 -0
- package/src/storage/ontology/in-memory/materializations-state.ts +5 -18
- package/src/storage/ontology/in-memory/materializations.ts +73 -92
- package/src/storage/ontology/in-memory/shared-state.ts +36 -4
- package/src/storage/ontology/in-memory/source-roots.ts +123 -0
- package/src/storage/ontology/in-memory/sources.ts +78 -23
- package/src/storage/ontology/index.ts +1 -0
- package/src/storage/ontology/outbox.ts +1 -0
- package/src/storage/ontology/provider.ts +70 -0
- package/src/storage/ontology/sources.ts +14 -3
- package/src/storage/projection-runs/lifecycle.ts +5 -2
- package/src/storage/projection-runs/types.ts +4 -3
- package/src/syncs/run-dispatch.ts +19 -1
- package/src/testing/broker-contract.ts +95 -0
- package/src/testing/connector-connection-storage-contract.ts +29 -12
- package/src/testing/index.ts +1 -0
- package/src/testing/lake-changes-contract.ts +240 -0
- package/src/testing/lake-storage-contract.ts +29 -0
- package/src/testing/materializer-storage-contract.ts +172 -1
- package/src/testing/ontology-storage-contract.ts +15 -3
- package/src/testing/projection-run-storage-contract.ts +34 -0
- package/src/webhooks/connections.ts +56 -0
- package/src/webhooks/index.ts +2 -0
- package/src/webhooks/internal.ts +2 -0
- package/src/webhooks/registry.ts +3 -4
- package/src/webhooks/types.ts +17 -4
- package/src/workflows/run-dispatch.ts +42 -29
- package/dist/chunk-0rdrecsb.js.map +0 -11
- package/dist/chunk-3f7veca0.js.map +0 -10
- package/dist/chunk-3frsnm7x.js.map +0 -11
- package/dist/chunk-3tgwrcyh.js.map +0 -14
- package/dist/chunk-52hbv0ak.js.map +0 -36
- package/dist/chunk-e0d1rzef.js.map +0 -15
- package/dist/chunk-emyyk7dx.js.map +0 -14
- package/dist/chunk-jjy0fhrn.js.map +0 -12
- package/dist/chunk-k3cqkkn2.js.map +0 -12
- package/dist/chunk-ppytyr6w.js.map +0 -12
- package/dist/chunk-qhcpj9wc.js.map +0 -14
- package/dist/chunk-r29fxdhn.js.map +0 -11
- package/dist/chunk-zcnq6105.js.map +0 -10
- /package/dist/{chunk-ypbtykv6.js.map → chunk-01kj2pbh.js.map} +0 -0
- /package/dist/{chunk-xyr8kppc.js.map → chunk-1yefycb1.js.map} +0 -0
- /package/dist/{chunk-m3z3x9v0.js.map → chunk-3ckk0xfj.js.map} +0 -0
- /package/dist/{chunk-0w35wavj.js.map → chunk-a0e6x5hd.js.map} +0 -0
- /package/dist/{chunk-h1gfhhbh.js.map → chunk-d63nnr5b.js.map} +0 -0
- /package/dist/{chunk-r4tfx1sf.js.map → chunk-fh8kgex1.js.map} +0 -0
- /package/dist/{chunk-vf691g1r.js.map → chunk-sepyxgpc.js.map} +0 -0
- /package/dist/{chunk-1enhpacz.js.map → chunk-z0s4axeh.js.map} +0 -0
|
@@ -123,6 +123,7 @@ import {
|
|
|
123
123
|
finishScopeAccumulator2,
|
|
124
124
|
ProviderMaterializationTransactionLifecycle2,
|
|
125
125
|
uniqueSorted2,
|
|
126
|
+
sourceStageRoots2,
|
|
126
127
|
sourceMaterializationIdentity2,
|
|
127
128
|
assertSourceBeginInput2,
|
|
128
129
|
assertSourceWriteIdentity2,
|
|
@@ -132,7 +133,7 @@ import {
|
|
|
132
133
|
assertSourceStagedRow2,
|
|
133
134
|
isExactStagingManifest2,
|
|
134
135
|
sourceConflict2
|
|
135
|
-
} from "./chunk-
|
|
136
|
+
} from "./chunk-gqh45d2n.js";
|
|
136
137
|
import {
|
|
137
138
|
createStorageOperationScope2,
|
|
138
139
|
createOperationScopedFacade2,
|
|
@@ -148,7 +149,7 @@ import {
|
|
|
148
149
|
} from "./chunk-mmagke4x.js";
|
|
149
150
|
import {
|
|
150
151
|
projectionRunObjectTypesVisible2
|
|
151
|
-
} from "./chunk-
|
|
152
|
+
} from "./chunk-qma80ych.js";
|
|
152
153
|
import {
|
|
153
154
|
ProjectionRunError2,
|
|
154
155
|
assertProjectionRunNonEmpty2,
|
|
@@ -174,7 +175,7 @@ import {
|
|
|
174
175
|
assertProjectionMissingTarget2,
|
|
175
176
|
requireTelemetryProjectionRun2,
|
|
176
177
|
assertProjectionRunDurableExecution2
|
|
177
|
-
} from "./chunk-
|
|
178
|
+
} from "./chunk-358caqf5.js";
|
|
178
179
|
import {
|
|
179
180
|
SyncRunError2,
|
|
180
181
|
assertSyncRunExecution2
|
|
@@ -1619,7 +1620,7 @@ class InMemoryConnectorConnectionStorage2 {
|
|
|
1619
1620
|
slot: input.slot,
|
|
1620
1621
|
initiatedByExecutionId: input.initiatedByExecutionId,
|
|
1621
1622
|
stateHash: input.stateHash,
|
|
1622
|
-
codeVerifier: structuredClone(input.codeVerifier),
|
|
1623
|
+
...input.codeVerifier === undefined ? {} : { codeVerifier: structuredClone(input.codeVerifier) },
|
|
1623
1624
|
redirectUri: input.redirectUri,
|
|
1624
1625
|
...input.connectionRunId === undefined ? {} : { connectionRunId: input.connectionRunId },
|
|
1625
1626
|
...input.returnTo === undefined ? {} : { returnTo: input.returnTo },
|
|
@@ -1793,6 +1794,9 @@ class InMemoryConnectorConnectionStorage2 {
|
|
|
1793
1794
|
this.connectionRuns.set(run.id, finished);
|
|
1794
1795
|
return structuredClone(finished);
|
|
1795
1796
|
}
|
|
1797
|
+
async listPendingConnectionRuns(input) {
|
|
1798
|
+
return [...this.connectionRuns.values()].filter((run) => run.projectId === input.projectId && run.connectorId === input.connectorId && (run.status === "running" || run.status === "waiting" && run.waitingFor === "account_selection")).map((run) => structuredClone(run));
|
|
1799
|
+
}
|
|
1796
1800
|
async getConnectionRun(input) {
|
|
1797
1801
|
const run = this.currentConnectionRun(input.runId);
|
|
1798
1802
|
return sameConnectionRunScope(run, input) ? structuredClone(run) : null;
|
|
@@ -2104,21 +2108,10 @@ class InMemoryConnectorConnectionStorage2 {
|
|
|
2104
2108
|
return { ...result, run: structuredClone(succeeded) };
|
|
2105
2109
|
}
|
|
2106
2110
|
putConnectionNow(input, now) {
|
|
2107
|
-
|
|
2111
|
+
const authorization = this.authorizations.get(input.authorizationId);
|
|
2108
2112
|
if (!sameAuthorizationScope(authorization, input) || !isSelectable(authorization.status) || authorization.credentialMutation?.kind === "reauthorization") {
|
|
2109
2113
|
throw authorizationConflict();
|
|
2110
2114
|
}
|
|
2111
|
-
if (authorization.status === "pending_selection" && authorization.selectionExpiresAt.getTime() <= now.getTime()) {
|
|
2112
|
-
authorization = {
|
|
2113
|
-
...authorization,
|
|
2114
|
-
status: "revocation_pending",
|
|
2115
|
-
selectionExpiresAt: undefined,
|
|
2116
|
-
revision: authorization.revision + 1,
|
|
2117
|
-
updatedAt: now
|
|
2118
|
-
};
|
|
2119
|
-
this.authorizations.set(authorization.id, authorization);
|
|
2120
|
-
throw authorizationConflict();
|
|
2121
|
-
}
|
|
2122
2115
|
const account = authorization.accounts.find((candidate) => candidate.id === input.account.id);
|
|
2123
2116
|
if (!account) {
|
|
2124
2117
|
throw new ConnectorConnectionStorageError2("authorization_conflict", "[Sixb] Connector connection account is not exposed by its authorization.");
|
|
@@ -2256,6 +2249,8 @@ class InMemoryConnectorConnectionStorage2 {
|
|
|
2256
2249
|
const run = this.connectionRuns.get(runId);
|
|
2257
2250
|
if (!run || run.status !== "waiting" && run.status !== "running")
|
|
2258
2251
|
return run;
|
|
2252
|
+
if (run.status === "waiting" && run.waitingFor === "account_selection")
|
|
2253
|
+
return run;
|
|
2259
2254
|
const now = this.now();
|
|
2260
2255
|
if (run.expiresAt.getTime() > now.getTime())
|
|
2261
2256
|
return run;
|
|
@@ -2265,9 +2260,6 @@ class InMemoryConnectorConnectionStorage2 {
|
|
|
2265
2260
|
this.attempts.delete(attempt.id);
|
|
2266
2261
|
}
|
|
2267
2262
|
if (run.status === "waiting") {
|
|
2268
|
-
if (run.kind === "connect" && run.waitingFor === "account_selection") {
|
|
2269
|
-
this.markPendingAuthorizationForCleanup(run.connectorId, run.authorizationId, now);
|
|
2270
|
-
}
|
|
2271
2263
|
const expired = expireConnectionRun(run, now);
|
|
2272
2264
|
this.connectionRuns.set(run.id, expired);
|
|
2273
2265
|
return expired;
|
|
@@ -3866,6 +3858,10 @@ function createInMemoryOntologyState() {
|
|
|
3866
3858
|
commitIdByIdempotency: new Map,
|
|
3867
3859
|
commitIdByOrigin: new Map,
|
|
3868
3860
|
sourceMaterializations: new Map,
|
|
3861
|
+
activeSourceHeads: new Map,
|
|
3862
|
+
activeSourceRoots: new Map,
|
|
3863
|
+
activeSourceRows: new Map,
|
|
3864
|
+
activeSourceLinkScopes: new Map,
|
|
3869
3865
|
objectOverrides: new Map,
|
|
3870
3866
|
linkOverrides: new Map,
|
|
3871
3867
|
linkSlotOverrides: new Map,
|
|
@@ -3883,6 +3879,7 @@ function sourceMaterializationRecord(materialization) {
|
|
|
3883
3879
|
rowsByEntity: _rows,
|
|
3884
3880
|
rootOrdinals: _roots,
|
|
3885
3881
|
ordinalRoots: _ordinals,
|
|
3882
|
+
roots: _sourceRoots,
|
|
3886
3883
|
...record
|
|
3887
3884
|
} = materialization;
|
|
3888
3885
|
return structuredClone(record);
|
|
@@ -3934,10 +3931,20 @@ function restoreOntologyState(target, snapshot) {
|
|
|
3934
3931
|
}
|
|
3935
3932
|
}
|
|
3936
3933
|
function insertBounded(values, value, limit, compare) {
|
|
3937
|
-
|
|
3938
|
-
|
|
3939
|
-
|
|
3940
|
-
|
|
3934
|
+
if (limit <= 0)
|
|
3935
|
+
return;
|
|
3936
|
+
if (values.length >= limit && compare(value, values[values.length - 1]) >= 0)
|
|
3937
|
+
return;
|
|
3938
|
+
let low = 0;
|
|
3939
|
+
let high = values.length;
|
|
3940
|
+
while (low < high) {
|
|
3941
|
+
const middle = low + high >>> 1;
|
|
3942
|
+
if (compare(value, values[middle]) < 0)
|
|
3943
|
+
high = middle;
|
|
3944
|
+
else
|
|
3945
|
+
low = middle + 1;
|
|
3946
|
+
}
|
|
3947
|
+
values.splice(low, 0, value);
|
|
3941
3948
|
if (values.length > limit)
|
|
3942
3949
|
values.pop();
|
|
3943
3950
|
}
|
|
@@ -4224,17 +4231,8 @@ function storedPoint(point) {
|
|
|
4224
4231
|
};
|
|
4225
4232
|
}
|
|
4226
4233
|
function findActiveSourceMaterialization(state, projectId, sourceId) {
|
|
4227
|
-
|
|
4228
|
-
|
|
4229
|
-
if (materialization.projectId !== projectId || materialization.source.projectionId !== sourceId || materialization.status !== "active") {
|
|
4230
|
-
continue;
|
|
4231
|
-
}
|
|
4232
|
-
if (active) {
|
|
4233
|
-
throw new MaterializationConflictError2("source-materialization", `Source '${sourceId}' has more than one active materialization.`);
|
|
4234
|
-
}
|
|
4235
|
-
active = materialization;
|
|
4236
|
-
}
|
|
4237
|
-
return active;
|
|
4234
|
+
const id = state.activeSourceHeads.get(projectEntityKey(projectId, sourceId));
|
|
4235
|
+
return id ? state.sourceMaterializations.get(sourceMaterializationKey(projectId, sourceId, id)) : undefined;
|
|
4238
4236
|
}
|
|
4239
4237
|
function storedSource(sourceId, materializationId, row) {
|
|
4240
4238
|
return {
|
|
@@ -4581,6 +4579,81 @@ function assertTimestampNotBefore(value, minimum, message) {
|
|
|
4581
4579
|
invalidCorrelation2(message);
|
|
4582
4580
|
}
|
|
4583
4581
|
|
|
4582
|
+
// src/storage/ontology/in-memory/source-roots.ts
|
|
4583
|
+
function* previousSourceRows(state, candidate) {
|
|
4584
|
+
const sourceKey = projectEntityKey(candidate.projectId, candidate.source.projectionId);
|
|
4585
|
+
const active = state.activeSourceRoots.get(sourceKey);
|
|
4586
|
+
if (!active)
|
|
4587
|
+
return;
|
|
4588
|
+
for (const rootKey of candidate.base ? candidate.roots.keys() : active.keys()) {
|
|
4589
|
+
const materializationId = active.get(rootKey);
|
|
4590
|
+
if (!materializationId)
|
|
4591
|
+
continue;
|
|
4592
|
+
const materialization = state.sourceMaterializations.get(sourceMaterializationKey(candidate.projectId, candidate.source.projectionId, materializationId));
|
|
4593
|
+
for (const entityKey of materialization.roots.get(rootKey).entityKeys) {
|
|
4594
|
+
yield storedSource(candidate.source.projectionId, materializationId, materialization.rowsByEntity.get(entityKey));
|
|
4595
|
+
}
|
|
4596
|
+
}
|
|
4597
|
+
}
|
|
4598
|
+
function activateSourceRoots(state, candidate, activation) {
|
|
4599
|
+
if (candidate.base && (candidate.base.materializationId !== activation.expected.activeMaterializationId || candidate.base.lastCommitId !== activation.expected.lastCommitId)) {
|
|
4600
|
+
throw new MaterializationConflictError2("projection-fence", "Source delta base changed before activation.");
|
|
4601
|
+
}
|
|
4602
|
+
const sourceKey = projectEntityKey(candidate.projectId, candidate.source.projectionId);
|
|
4603
|
+
const active = state.activeSourceRoots.get(sourceKey) ?? new Map;
|
|
4604
|
+
for (const key of candidate.base ? candidate.roots.keys() : [...active.keys()]) {
|
|
4605
|
+
const materializationId = active.get(key);
|
|
4606
|
+
if (!materializationId)
|
|
4607
|
+
continue;
|
|
4608
|
+
const old = state.sourceMaterializations.get(sourceMaterializationKey(candidate.projectId, candidate.source.projectionId, materializationId));
|
|
4609
|
+
const root = old.roots.get(key);
|
|
4610
|
+
root.active = false;
|
|
4611
|
+
root.retiredAt = activation.updatedAt;
|
|
4612
|
+
active.delete(key);
|
|
4613
|
+
for (const entityKey of root.entityKeys) {
|
|
4614
|
+
const row = old.rowsByEntity.get(entityKey);
|
|
4615
|
+
const indexKey = projectEntityKey(candidate.projectId, entityKey);
|
|
4616
|
+
const sources = state.activeSourceRows.get(indexKey);
|
|
4617
|
+
sources.delete(candidate.source.projectionId);
|
|
4618
|
+
if (sources.size === 0)
|
|
4619
|
+
state.activeSourceRows.delete(indexKey);
|
|
4620
|
+
if (row.assertion.kind === "link") {
|
|
4621
|
+
const scopeKey = projectEntityKey(candidate.projectId, linkScopeSortKey2(row.assertion.ref.source, row.assertion.ref.linkId));
|
|
4622
|
+
const scope = state.activeSourceLinkScopes.get(scopeKey);
|
|
4623
|
+
scope.delete(JSON.stringify([candidate.source.projectionId, entityKey]));
|
|
4624
|
+
if (scope.size === 0)
|
|
4625
|
+
state.activeSourceLinkScopes.delete(scopeKey);
|
|
4626
|
+
}
|
|
4627
|
+
}
|
|
4628
|
+
}
|
|
4629
|
+
for (const [rootKey, root] of candidate.roots) {
|
|
4630
|
+
root.active = !root.deleted;
|
|
4631
|
+
root.retiredAt = root.deleted ? activation.updatedAt : null;
|
|
4632
|
+
if (root.deleted)
|
|
4633
|
+
continue;
|
|
4634
|
+
active.set(rootKey, candidate.materializationId);
|
|
4635
|
+
for (const entityKey of root.entityKeys) {
|
|
4636
|
+
const row = {
|
|
4637
|
+
source: candidate.source,
|
|
4638
|
+
materializationId: candidate.materializationId,
|
|
4639
|
+
...candidate.rowsByEntity.get(entityKey)
|
|
4640
|
+
};
|
|
4641
|
+
const indexKey = projectEntityKey(candidate.projectId, projectionEntityKey2(row.assertion));
|
|
4642
|
+
const sources = state.activeSourceRows.get(indexKey) ?? new Map;
|
|
4643
|
+
sources.set(candidate.source.projectionId, row);
|
|
4644
|
+
state.activeSourceRows.set(indexKey, sources);
|
|
4645
|
+
if (row.assertion.kind === "link") {
|
|
4646
|
+
const scopeKey = projectEntityKey(candidate.projectId, linkScopeSortKey2(row.assertion.ref.source, row.assertion.ref.linkId));
|
|
4647
|
+
const scope = state.activeSourceLinkScopes.get(scopeKey) ?? new Map;
|
|
4648
|
+
scope.set(JSON.stringify([candidate.source.projectionId, entityKey]), row);
|
|
4649
|
+
state.activeSourceLinkScopes.set(scopeKey, scope);
|
|
4650
|
+
}
|
|
4651
|
+
}
|
|
4652
|
+
}
|
|
4653
|
+
state.activeSourceRoots.set(sourceKey, active);
|
|
4654
|
+
state.activeSourceHeads.set(sourceKey, candidate.materializationId);
|
|
4655
|
+
}
|
|
4656
|
+
|
|
4584
4657
|
// src/storage/ontology/in-memory/materializations.ts
|
|
4585
4658
|
class InMemoryOntologyMaterializationStorage {
|
|
4586
4659
|
state;
|
|
@@ -4794,7 +4867,7 @@ class InMemoryOntologyMaterializationStorage {
|
|
|
4794
4867
|
for (const entry of selected) {
|
|
4795
4868
|
const key = projectionEntityKey2({ kind: "link", ref: entry.ref });
|
|
4796
4869
|
const base = await this.linkState(session, entry.ref);
|
|
4797
|
-
const ownedByReplacement = replacement.
|
|
4870
|
+
const ownedByReplacement = replacement.owned.has(key);
|
|
4798
4871
|
links.push({
|
|
4799
4872
|
ref: base.ref,
|
|
4800
4873
|
candidateSource: ownedByReplacement ? storedSourceLink(input.source.projectionId, replacement.candidate.materializationId, replacement.candidate.rowsByEntity.get(key)) : base.source,
|
|
@@ -5044,6 +5117,7 @@ class InMemoryOntologyMaterializationStorage {
|
|
|
5044
5117
|
updatedAt: activation.updatedAt
|
|
5045
5118
|
});
|
|
5046
5119
|
}
|
|
5120
|
+
activateSourceRoots(this.state, candidate, activation);
|
|
5047
5121
|
this.state.sourceMaterializations.set(candidateKey, {
|
|
5048
5122
|
...candidate,
|
|
5049
5123
|
status: "active",
|
|
@@ -5093,7 +5167,7 @@ class InMemoryOntologyMaterializationStorage {
|
|
|
5093
5167
|
const replacement = {
|
|
5094
5168
|
sourceId,
|
|
5095
5169
|
candidateMaterializationId: input.candidateMaterializationId,
|
|
5096
|
-
|
|
5170
|
+
owned: new Set,
|
|
5097
5171
|
candidate,
|
|
5098
5172
|
objects: new Map,
|
|
5099
5173
|
links: new Map,
|
|
@@ -5107,10 +5181,12 @@ class InMemoryOntologyMaterializationStorage {
|
|
|
5107
5181
|
linkStreamCompleted: false,
|
|
5108
5182
|
linksExpanded: false
|
|
5109
5183
|
};
|
|
5110
|
-
for (const
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5184
|
+
for (const rows of [
|
|
5185
|
+
previousSourceRows(this.state, candidate),
|
|
5186
|
+
candidate.rowsByEntity.values()
|
|
5187
|
+
]) {
|
|
5188
|
+
for (const row of rows) {
|
|
5189
|
+
replacement.owned.add(projectionEntityKey2(row.assertion));
|
|
5114
5190
|
if (row.assertion.kind === "object") {
|
|
5115
5191
|
const ref = row.assertion.ref;
|
|
5116
5192
|
replacement.objects.set(objectRefKey2(ref), { ref, sortKey: objectRefSortKey2(ref) });
|
|
@@ -5130,52 +5206,53 @@ class InMemoryOntologyMaterializationStorage {
|
|
|
5130
5206
|
const incident = replacement.incidentObjects;
|
|
5131
5207
|
const touchesIncident = (ref) => incident.has(objectRefKey2(ref.source)) || incident.has(objectRefKey2(ref.target));
|
|
5132
5208
|
const adapter = getInMemoryObjectMaterializerAdapter(this.objects);
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
for (const override of this.state.linkSlotOverrides.values()) {
|
|
5145
|
-
if (override.projectId !== projectId)
|
|
5146
|
-
continue;
|
|
5147
|
-
const ref = {
|
|
5148
|
-
source: override.ref.source,
|
|
5149
|
-
linkId: override.ref.linkId,
|
|
5150
|
-
target: override.value.target
|
|
5151
|
-
};
|
|
5152
|
-
if (touchesIncident(ref))
|
|
5153
|
-
addReplacementLink(replacement, ref, true);
|
|
5154
|
-
}
|
|
5155
|
-
for (const active of this.state.sourceMaterializations.values()) {
|
|
5156
|
-
if (active.projectId !== projectId || active.status !== "active")
|
|
5157
|
-
continue;
|
|
5158
|
-
for (const row of active.rowsByEntity.values()) {
|
|
5159
|
-
if (row.assertion.kind === "link" && touchesIncident(row.assertion.ref)) {
|
|
5160
|
-
addReplacementLink(replacement, row.assertion.ref, true);
|
|
5161
|
-
}
|
|
5162
|
-
}
|
|
5163
|
-
}
|
|
5164
|
-
adapter.visitExactLinks(projectId, (row) => {
|
|
5165
|
-
const ref = linkRef(row);
|
|
5166
|
-
if (replacement.affectedScopes.has(linkScopeSortKey2(ref.source, ref.linkId))) {
|
|
5167
|
-
addReplacementLink(replacement, ref, false);
|
|
5209
|
+
if (incident.size > 0) {
|
|
5210
|
+
adapter.visitExactLinks(projectId, (row) => {
|
|
5211
|
+
const ref = linkRef(row);
|
|
5212
|
+
if (touchesIncident(ref))
|
|
5213
|
+
addReplacementLink(replacement, ref, true);
|
|
5214
|
+
});
|
|
5215
|
+
for (const override of this.state.linkOverrides.values()) {
|
|
5216
|
+
if (override.projectId !== projectId)
|
|
5217
|
+
continue;
|
|
5218
|
+
if (touchesIncident(override.ref))
|
|
5219
|
+
addReplacementLink(replacement, override.ref, true);
|
|
5168
5220
|
}
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
|
|
5221
|
+
for (const override of this.state.linkSlotOverrides.values()) {
|
|
5222
|
+
if (override.projectId !== projectId)
|
|
5223
|
+
continue;
|
|
5224
|
+
const ref = {
|
|
5173
5225
|
source: override.ref.source,
|
|
5174
5226
|
linkId: override.ref.linkId,
|
|
5175
5227
|
target: override.value.target
|
|
5176
|
-
}
|
|
5228
|
+
};
|
|
5229
|
+
if (touchesIncident(ref))
|
|
5230
|
+
addReplacementLink(replacement, ref, true);
|
|
5231
|
+
}
|
|
5232
|
+
for (const [scopeKey, rows] of this.state.activeSourceLinkScopes) {
|
|
5233
|
+
if (JSON.parse(scopeKey)[0] !== projectId)
|
|
5234
|
+
continue;
|
|
5235
|
+
for (const row of rows.values()) {
|
|
5236
|
+
if (row.assertion.kind === "link" && touchesIncident(row.assertion.ref)) {
|
|
5237
|
+
addReplacementLink(replacement, row.assertion.ref, true);
|
|
5238
|
+
}
|
|
5239
|
+
}
|
|
5177
5240
|
}
|
|
5178
5241
|
}
|
|
5242
|
+
const scopes = new Map;
|
|
5243
|
+
for (const { ref } of replacement.links.values()) {
|
|
5244
|
+
const key = linkScopeSortKey2(ref.source, ref.linkId);
|
|
5245
|
+
if (replacement.affectedScopes.has(key))
|
|
5246
|
+
scopes.set(key, ref);
|
|
5247
|
+
}
|
|
5248
|
+
for (const scope of scopes.values()) {
|
|
5249
|
+
adapter.visitExactScopeLinks(projectId, scope.source.objectTypeId, scope.source.primaryId, scope.linkId, (row) => {
|
|
5250
|
+
addReplacementLink(replacement, linkRef(row), false);
|
|
5251
|
+
});
|
|
5252
|
+
const override = this.state.linkSlotOverrides.get(projectEntityKey(projectId, linkScopeKey(scope.source, scope.linkId)));
|
|
5253
|
+
if (override)
|
|
5254
|
+
addReplacementLink(replacement, { ...scope, target: override.value.target }, false);
|
|
5255
|
+
}
|
|
5179
5256
|
replacement.linksExpanded = true;
|
|
5180
5257
|
replacement.orderedLinks = null;
|
|
5181
5258
|
}
|
|
@@ -5306,21 +5383,10 @@ class InMemoryOntologyMaterializationStorage {
|
|
|
5306
5383
|
};
|
|
5307
5384
|
}
|
|
5308
5385
|
findActiveLinkScopeSource(projectId, source, linkId) {
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
|
|
5313
|
-
for (const row of active.rowsByEntity.values()) {
|
|
5314
|
-
if (row.assertion.kind !== "link" || objectRefKey2(row.assertion.ref.source) !== objectRefKey2(source) || row.assertion.ref.linkId !== linkId) {
|
|
5315
|
-
continue;
|
|
5316
|
-
}
|
|
5317
|
-
if (found) {
|
|
5318
|
-
throw new MaterializationConflictError2("source-materialization", `Multiple active source links assert cardinality-one scope '${source.objectTypeId}.${linkId}'.`);
|
|
5319
|
-
}
|
|
5320
|
-
found = storedSource(active.source.projectionId, active.materializationId, row);
|
|
5321
|
-
}
|
|
5322
|
-
}
|
|
5323
|
-
return structuredClone(found);
|
|
5386
|
+
const rows = this.state.activeSourceLinkScopes.get(projectEntityKey(projectId, linkScopeSortKey2(source, linkId)));
|
|
5387
|
+
if (rows && rows.size > 1)
|
|
5388
|
+
throw new MaterializationConflictError2("source-materialization", `Multiple active source links assert cardinality-one scope '${source.objectTypeId}.${linkId}'.`);
|
|
5389
|
+
return structuredClone(rows?.values().next().value ?? null);
|
|
5324
5390
|
}
|
|
5325
5391
|
findActiveObjectSource(projectId, ref) {
|
|
5326
5392
|
const found = this.findActiveSource(projectId, projectionEntityKey2({ kind: "object", ref }));
|
|
@@ -5331,18 +5397,10 @@ class InMemoryOntologyMaterializationStorage {
|
|
|
5331
5397
|
return found?.assertion.kind === "link" ? found : null;
|
|
5332
5398
|
}
|
|
5333
5399
|
findActiveSource(projectId, entityKey) {
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
|
|
5337
|
-
|
|
5338
|
-
const row = active.rowsByEntity.get(entityKey);
|
|
5339
|
-
if (!row)
|
|
5340
|
-
continue;
|
|
5341
|
-
if (found)
|
|
5342
|
-
throw new MaterializationConflictError2("source-materialization", `Multiple active sources assert ${entityKey}.`);
|
|
5343
|
-
found = storedSource(active.source.projectionId, active.materializationId, row);
|
|
5344
|
-
}
|
|
5345
|
-
return structuredClone(found);
|
|
5400
|
+
const rows = this.state.activeSourceRows.get(projectEntityKey(projectId, entityKey));
|
|
5401
|
+
if (rows && rows.size > 1)
|
|
5402
|
+
throw new MaterializationConflictError2("source-materialization", `Multiple active sources assert ${entityKey}.`);
|
|
5403
|
+
return structuredClone(rows?.values().next().value ?? null);
|
|
5346
5404
|
}
|
|
5347
5405
|
incidentLinkRefs(session, objects) {
|
|
5348
5406
|
if (objects.length === 0)
|
|
@@ -5381,10 +5439,10 @@ class InMemoryOntologyMaterializationStorage {
|
|
|
5381
5439
|
target: override.value.target
|
|
5382
5440
|
});
|
|
5383
5441
|
}
|
|
5384
|
-
for (const
|
|
5385
|
-
if (
|
|
5442
|
+
for (const [scopeKey, rows] of this.state.activeSourceLinkScopes) {
|
|
5443
|
+
if (JSON.parse(scopeKey)[0] !== projectId)
|
|
5386
5444
|
continue;
|
|
5387
|
-
for (const row of
|
|
5445
|
+
for (const row of rows.values()) {
|
|
5388
5446
|
if (row.assertion.kind === "link")
|
|
5389
5447
|
consider(row.assertion.ref);
|
|
5390
5448
|
}
|
|
@@ -5590,6 +5648,7 @@ class InMemoryOntologySourceStorage {
|
|
|
5590
5648
|
projectionRevision: input.projectionRevision,
|
|
5591
5649
|
ownershipHash: input.ownershipHash,
|
|
5592
5650
|
ontologyRevision: input.ontologyRevision,
|
|
5651
|
+
...input.base ? { base: structuredClone(input.base) } : {},
|
|
5593
5652
|
rootCount: null,
|
|
5594
5653
|
assertionCount: null,
|
|
5595
5654
|
createdAt: input.createdAt,
|
|
@@ -5599,6 +5658,7 @@ class InMemoryOntologySourceStorage {
|
|
|
5599
5658
|
lastCommitId: null,
|
|
5600
5659
|
updatedAt: input.createdAt,
|
|
5601
5660
|
rowsByEntity: new Map,
|
|
5661
|
+
roots: new Map,
|
|
5602
5662
|
rootOrdinals: new Map,
|
|
5603
5663
|
ordinalRoots: new Map
|
|
5604
5664
|
};
|
|
@@ -5615,7 +5675,7 @@ class InMemoryOntologySourceStorage {
|
|
|
5615
5675
|
if (materialization.status !== "staging") {
|
|
5616
5676
|
throw sourceConflict2(`Source materialization '${input.materializationId}' is '${materialization.status}' and cannot accept rows.`);
|
|
5617
5677
|
}
|
|
5618
|
-
return stageRowsAtomically(materialization, input
|
|
5678
|
+
return stageRowsAtomically(materialization, input);
|
|
5619
5679
|
});
|
|
5620
5680
|
}
|
|
5621
5681
|
async markReady(input) {
|
|
@@ -5653,11 +5713,8 @@ class InMemoryOntologySourceStorage {
|
|
|
5653
5713
|
async getActive(input) {
|
|
5654
5714
|
return this.runRootOperation(() => {
|
|
5655
5715
|
assertSourceProject2(input);
|
|
5656
|
-
const active =
|
|
5657
|
-
|
|
5658
|
-
throw sourceConflict2(`Source '${input.source.projectionId}' has more than one active materialization.`);
|
|
5659
|
-
}
|
|
5660
|
-
return active[0] ? sourceMaterializationRecord(active[0]) : null;
|
|
5716
|
+
const active = findActiveSourceMaterialization(this.state, input.projectId, input.source.projectionId);
|
|
5717
|
+
return active ? sourceMaterializationRecord(active) : null;
|
|
5661
5718
|
});
|
|
5662
5719
|
}
|
|
5663
5720
|
async abandon(input) {
|
|
@@ -5682,6 +5739,8 @@ class InMemoryOntologySourceStorage {
|
|
|
5682
5739
|
if (materialization.projectId !== input.projectId || materialization.status !== "superseded" && materialization.status !== "abandoned" || materialization.terminalAt === null || materialization.terminalAt >= input.terminalBefore) {
|
|
5683
5740
|
continue;
|
|
5684
5741
|
}
|
|
5742
|
+
if (materialization.roots.size > 0 && ![...materialization.roots.values()].some((root) => !root.active && root.retiredAt !== null && root.retiredAt < input.terminalBefore))
|
|
5743
|
+
continue;
|
|
5685
5744
|
insertBounded(candidates, entry, input.limit, compareTerminalMaterializations);
|
|
5686
5745
|
}
|
|
5687
5746
|
let remaining = input.limit;
|
|
@@ -5695,14 +5754,28 @@ class InMemoryOntologySourceStorage {
|
|
|
5695
5754
|
continue;
|
|
5696
5755
|
current.rootOrdinals.clear();
|
|
5697
5756
|
current.ordinalRoots.clear();
|
|
5698
|
-
for (const
|
|
5757
|
+
for (const [rootKey, root] of current.roots) {
|
|
5699
5758
|
if (remaining === 0)
|
|
5700
5759
|
break;
|
|
5701
|
-
|
|
5702
|
-
|
|
5703
|
-
|
|
5760
|
+
if (root.active || root.retiredAt === null || root.retiredAt >= input.terminalBefore)
|
|
5761
|
+
continue;
|
|
5762
|
+
for (const entityKey of root.entityKeys) {
|
|
5763
|
+
if (remaining === 0)
|
|
5764
|
+
break;
|
|
5765
|
+
current.rowsByEntity.delete(entityKey);
|
|
5766
|
+
root.entityKeys.delete(entityKey);
|
|
5767
|
+
rowsDeleted += 1;
|
|
5768
|
+
remaining -= 1;
|
|
5769
|
+
}
|
|
5770
|
+
if (root.entityKeys.size === 0 && remaining > 0) {
|
|
5771
|
+
current.roots.delete(rootKey);
|
|
5772
|
+
current.rootOrdinals.delete(rootKey);
|
|
5773
|
+
current.ordinalRoots.delete(root.stagingOrdinal);
|
|
5774
|
+
rowsDeleted += 1;
|
|
5775
|
+
remaining -= 1;
|
|
5776
|
+
}
|
|
5704
5777
|
}
|
|
5705
|
-
if (current.rowsByEntity.size === 0 && remaining > 0) {
|
|
5778
|
+
if (current.roots.size === 0 && current.rowsByEntity.size === 0 && remaining > 0) {
|
|
5706
5779
|
this.state.sourceMaterializations.delete(key);
|
|
5707
5780
|
materializationsDeleted += 1;
|
|
5708
5781
|
remaining -= 1;
|
|
@@ -5773,6 +5846,8 @@ class InMemoryOntologySourceStorage {
|
|
|
5773
5846
|
if (materialization.readyAt !== null) {
|
|
5774
5847
|
assertNotBefore(abandonedAt, materialization.readyAt, "Source abandonedAt", "readyAt");
|
|
5775
5848
|
}
|
|
5849
|
+
for (const root of materialization.roots.values())
|
|
5850
|
+
root.retiredAt = abandonedAt;
|
|
5776
5851
|
const abandoned = {
|
|
5777
5852
|
...materialization,
|
|
5778
5853
|
status: "abandoned",
|
|
@@ -5787,13 +5862,26 @@ class InMemoryOntologySourceStorage {
|
|
|
5787
5862
|
return [...this.state.sourceMaterializations.entries()].filter(([, materialization]) => materialization.projectId === projectId && materialization.source.projectionId === sourceId && materialization.projectionRunId === projectionRunId && (materialization.status === "staging" || materialization.status === "ready"));
|
|
5788
5863
|
}
|
|
5789
5864
|
}
|
|
5790
|
-
function stageRowsAtomically(materialization,
|
|
5865
|
+
function stageRowsAtomically(materialization, input) {
|
|
5791
5866
|
let inserted = 0;
|
|
5792
5867
|
let unchanged = 0;
|
|
5793
5868
|
const newRows = new Map;
|
|
5794
5869
|
const newRootOrdinals = new Map;
|
|
5795
5870
|
const newOrdinalRoots = new Map;
|
|
5796
|
-
|
|
5871
|
+
const roots = sourceStageRoots2(materialization.projectionKind, input);
|
|
5872
|
+
if (!materialization.base && roots.some((root) => root.deleted)) {
|
|
5873
|
+
throw new MaterializationValidationError2("Root deletions require a source delta base.");
|
|
5874
|
+
}
|
|
5875
|
+
for (const root of roots) {
|
|
5876
|
+
const previous = materialization.roots.get(root.rootKey);
|
|
5877
|
+
const otherRoot = materialization.ordinalRoots.get(root.stagingOrdinal);
|
|
5878
|
+
if (previous && (previous.deleted !== root.deleted || previous.stagingOrdinal !== root.stagingOrdinal) || otherRoot !== undefined && otherRoot !== root.rootKey) {
|
|
5879
|
+
throw new MaterializationValidationError2("Source materialization repeats root or stream ordinal with different content.");
|
|
5880
|
+
}
|
|
5881
|
+
newRootOrdinals.set(root.rootKey, root.stagingOrdinal);
|
|
5882
|
+
newOrdinalRoots.set(root.stagingOrdinal, root.rootKey);
|
|
5883
|
+
}
|
|
5884
|
+
for (const row of input.rows) {
|
|
5797
5885
|
assertSourceStagedRow2(materialization.projectionKind, row);
|
|
5798
5886
|
const rootKey = projectionEntityKey2(row.root);
|
|
5799
5887
|
const existingOrdinal = materialization.rootOrdinals.get(rootKey) ?? newRootOrdinals.get(rootKey);
|
|
@@ -5824,8 +5912,21 @@ function stageRowsAtomically(materialization, rows) {
|
|
|
5824
5912
|
for (const [ordinal, rootKey] of newOrdinalRoots) {
|
|
5825
5913
|
materialization.ordinalRoots.set(ordinal, rootKey);
|
|
5826
5914
|
}
|
|
5827
|
-
for (const
|
|
5915
|
+
for (const root of roots) {
|
|
5916
|
+
if (!materialization.roots.has(root.rootKey))
|
|
5917
|
+
materialization.roots.set(root.rootKey, {
|
|
5918
|
+
root: structuredClone(root.root),
|
|
5919
|
+
stagingOrdinal: root.stagingOrdinal,
|
|
5920
|
+
deleted: root.deleted,
|
|
5921
|
+
entityKeys: new Set,
|
|
5922
|
+
active: false,
|
|
5923
|
+
retiredAt: null
|
|
5924
|
+
});
|
|
5925
|
+
}
|
|
5926
|
+
for (const [entityKey, row] of newRows) {
|
|
5828
5927
|
materialization.rowsByEntity.set(entityKey, row);
|
|
5928
|
+
materialization.roots.get(projectionEntityKey2(row.root)).entityKeys.add(entityKey);
|
|
5929
|
+
}
|
|
5829
5930
|
return { inserted, unchanged };
|
|
5830
5931
|
}
|
|
5831
5932
|
function assertReadyCounts(materialization, rootCount, assertionCount) {
|
|
@@ -5849,6 +5950,11 @@ function assertReadyTopology(materialization) {
|
|
|
5849
5950
|
}
|
|
5850
5951
|
for (const rootKey of materialization.rootOrdinals.keys()) {
|
|
5851
5952
|
const rows = rowsByRoot.get(rootKey) ?? [];
|
|
5953
|
+
if (materialization.roots.get(rootKey)?.deleted) {
|
|
5954
|
+
if (rows.length > 0)
|
|
5955
|
+
throw new MaterializationValidationError2("Deleted source roots cannot contain assertions.");
|
|
5956
|
+
continue;
|
|
5957
|
+
}
|
|
5852
5958
|
const first = rows[0];
|
|
5853
5959
|
if (!first) {
|
|
5854
5960
|
throw new MaterializationValidationError2(`Source root ${rootKey} has no staged assertions.`);
|
|
@@ -8216,4 +8322,4 @@ function assertAppliedPrefix(migrations, rows) {
|
|
|
8216
8322
|
}
|
|
8217
8323
|
export { InMemoryActionRunStorage2, AGENT_MESSAGE_CONTENT_VERSION2, InMemoryAgentStorage2, AiCostStorageError2, InMemoryAiCostStorage2, InMemoryAiLimitStorage2, InMemoryConnectorConnectionStorage2, FileUploadSessionError2, InMemoryFileUploadSessions2, objectBatchKey2, linkBatchKey2, objectLinkCursor2, compareQueryScalarValues, queryScalarValuesEqual, PIPELINE_RUN_FAILURE_CODES2, InMemoryPipelineRunStorage2, InMemoryProjectionRunStorage2, InMemoryRulesStorage2, InMemoryShareGrantStorage2, InMemoryShareSessionStorage2, SYNC_RUN_FAILURE_CODES2, InMemorySyncRunStorage2, WEBHOOK_RUN_FAILURE_CODES2, canRetryWebhookRun2, InMemoryWebhookRunStorage2, WorkflowInterventionError2, InMemoryWorkflowInterventionStorage2, WORKFLOW_RUN_FAILURE_CODES2, InMemoryWorkflowRunStorage2, InMemoryWorkflowNodeRunStorage2, InMemoryWorkflowAgentNodeRunStorage2, InMemoryStorage2, isMigrationCapableStorage2, migrateStorage2, checkStorageSchema2, step2, defineMigrations2, runMigrationSet2, describeMigrationHistory2 };
|
|
8218
8324
|
|
|
8219
|
-
//# debugId=
|
|
8325
|
+
//# debugId=1AE2F63489E4A4EB64756E2164756E21
|