@sixb/core 0.1.9 → 0.1.10
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 +8 -8
- package/dist/agents/index.js +16 -15
- package/dist/agents/index.js.map +1 -1
- package/dist/bootstrap/index.js +20 -19
- 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-k3cqkkn2.js → chunk-1824gssz.js} +30 -65
- package/dist/chunk-1824gssz.js.map +12 -0
- package/dist/{chunk-h1gfhhbh.js → chunk-28ja2cjs.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-kxwa347f.js → chunk-3qms4nax.js} +2 -2
- package/dist/{chunk-kxwa347f.js.map → chunk-3qms4nax.js.map} +3 -3
- package/dist/{chunk-emyyk7dx.js → chunk-5c7ga8zz.js} +22 -145
- package/dist/chunk-5c7ga8zz.js.map +12 -0
- package/dist/{chunk-hpr1r6av.js → chunk-5p1v802y.js} +46 -39
- package/dist/{chunk-hpr1r6av.js.map → chunk-5p1v802y.js.map} +4 -4
- package/dist/{chunk-zcnq6105.js → chunk-85cd7e8c.js} +2 -1
- package/dist/chunk-85cd7e8c.js.map +10 -0
- package/dist/{chunk-1enhpacz.js → chunk-976rxdpx.js} +5 -5
- package/dist/{chunk-3f7veca0.js → chunk-9x8dybsb.js} +3 -3
- package/dist/chunk-9x8dybsb.js.map +10 -0
- package/dist/{chunk-r29fxdhn.js → chunk-aa6z4a19.js} +160 -44
- package/dist/chunk-aa6z4a19.js.map +12 -0
- package/dist/{chunk-r4tfx1sf.js → chunk-agbbygvh.js} +4 -4
- package/dist/{chunk-jjy0fhrn.js → chunk-b0ec55a1.js} +20 -3
- package/dist/chunk-b0ec55a1.js.map +12 -0
- package/dist/{chunk-xfbydgzy.js → chunk-bn138h9w.js} +7 -8
- package/dist/{chunk-xfbydgzy.js.map → chunk-bn138h9w.js.map} +3 -3
- 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-0w35wavj.js → chunk-g7knyczr.js} +1 -1
- 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-0rdrecsb.js → chunk-kfee1h52.js} +116 -32
- package/dist/chunk-kfee1h52.js.map +13 -0
- package/dist/{chunk-ypbtykv6.js → chunk-nmbxcaqx.js} +1 -1
- package/dist/{chunk-3tgwrcyh.js → chunk-nt99sxd6.js} +2 -2
- package/dist/{chunk-3tgwrcyh.js.map → chunk-nt99sxd6.js.map} +3 -3
- package/dist/{chunk-vf691g1r.js → chunk-p5vcsw9c.js} +2 -2
- package/dist/{chunk-mjbk2djy.js → chunk-p6a4npdx.js} +211 -106
- package/dist/{chunk-mjbk2djy.js.map → chunk-p6a4npdx.js.map} +9 -8
- package/dist/{chunk-3frsnm7x.js → chunk-qma80ych.js} +4 -6
- package/dist/chunk-qma80ych.js.map +11 -0
- package/dist/{chunk-qhcpj9wc.js → chunk-qyeptdyv.js} +96 -2
- package/dist/chunk-qyeptdyv.js.map +15 -0
- package/dist/{chunk-52hbv0ak.js → chunk-r7fj830t.js} +101 -48
- package/dist/chunk-r7fj830t.js.map +36 -0
- package/dist/{chunk-xyr8kppc.js → chunk-rtk71jzp.js} +1 -1
- package/dist/{chunk-m3z3x9v0.js → chunk-t1f4f1ve.js} +1 -1
- package/dist/chunk-v2vcg0w6.js +151 -0
- package/dist/chunk-v2vcg0w6.js.map +11 -0
- package/dist/connectors/connections/authorizations.d.ts.map +1 -1
- package/dist/connectors/connections/contracts.d.ts +3 -0
- package/dist/connectors/connections/contracts.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.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/service.d.ts +2 -2
- package/dist/events/service.d.ts.map +1 -1
- package/dist/execution/agent.js +16 -15
- package/dist/execution/agent.js.map +1 -1
- package/dist/execution/primitive.js +16 -15
- package/dist/execution/primitive.js.map +2 -2
- package/dist/execution/request.js +16 -15
- 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 +30 -28
- 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 +36 -0
- package/dist/lake-storage/types.d.ts.map +1 -1
- package/dist/logging/internal.js +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 +5 -5
- 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/execution/index.js +5 -5
- package/dist/objects/index.js +9 -9
- package/dist/objects/query/index.js +5 -5
- package/dist/pipelines/index.js +6 -6
- package/dist/pipelines/run-dispatch.d.ts.map +1 -1
- package/dist/projections/internal.js +6 -8
- 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 +4 -4
- package/dist/storage/connector-connections/in-memory.d.ts.map +1 -1
- package/dist/storage/connector-connections/provider/runs.d.ts.map +1 -1
- package/dist/storage/connector-connections/provider.js +2 -2
- package/dist/storage/connector-connections/provider.js.map +3 -3
- package/dist/storage/connector-connections/types.d.ts +3 -2
- 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 +4 -4
- 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/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 +8 -7
- 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 +1459 -951
- package/dist/testing/index.js.map +9 -8
- package/dist/testing/lake-changes-contract.d.ts +6 -0
- package/dist/testing/lake-changes-contract.d.ts.map +1 -0
- 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 +54 -9
- 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 +17 -16
- 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/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/contracts.ts +3 -0
- package/src/connectors/connections/request.ts +56 -22
- package/src/connectors/connections/runs.ts +1 -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/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 +73 -0
- package/src/lake-storage/index.ts +4 -0
- package/src/lake-storage/types.ts +40 -0
- package/src/logging/service.ts +1 -1
- package/src/materialization/index.ts +2 -0
- package/src/materialization/model.ts +14 -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/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 +3 -1
- package/src/storage/connector-connections/provider/runs.ts +3 -1
- package/src/storage/connector-connections/types.ts +3 -2
- 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 +26 -1
- 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/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 +18 -1
- package/src/testing/index.ts +1 -0
- package/src/testing/lake-changes-contract.ts +240 -0
- package/src/testing/materializer-storage-contract.ts +172 -1
- package/src/testing/ontology-storage-contract.ts +7 -0
- 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-52hbv0ak.js.map +0 -36
- 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-h1gfhhbh.js.map → chunk-28ja2cjs.js.map} +0 -0
- /package/dist/{chunk-1enhpacz.js.map → chunk-976rxdpx.js.map} +0 -0
- /package/dist/{chunk-r4tfx1sf.js.map → chunk-agbbygvh.js.map} +0 -0
- /package/dist/{chunk-0w35wavj.js.map → chunk-g7knyczr.js.map} +0 -0
- /package/dist/{chunk-ypbtykv6.js.map → chunk-nmbxcaqx.js.map} +0 -0
- /package/dist/{chunk-vf691g1r.js.map → chunk-p5vcsw9c.js.map} +0 -0
- /package/dist/{chunk-xyr8kppc.js.map → chunk-rtk71jzp.js.map} +0 -0
- /package/dist/{chunk-m3z3x9v0.js.map → chunk-t1f4f1ve.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 },
|
|
@@ -3866,6 +3867,10 @@ function createInMemoryOntologyState() {
|
|
|
3866
3867
|
commitIdByIdempotency: new Map,
|
|
3867
3868
|
commitIdByOrigin: new Map,
|
|
3868
3869
|
sourceMaterializations: new Map,
|
|
3870
|
+
activeSourceHeads: new Map,
|
|
3871
|
+
activeSourceRoots: new Map,
|
|
3872
|
+
activeSourceRows: new Map,
|
|
3873
|
+
activeSourceLinkScopes: new Map,
|
|
3869
3874
|
objectOverrides: new Map,
|
|
3870
3875
|
linkOverrides: new Map,
|
|
3871
3876
|
linkSlotOverrides: new Map,
|
|
@@ -3883,6 +3888,7 @@ function sourceMaterializationRecord(materialization) {
|
|
|
3883
3888
|
rowsByEntity: _rows,
|
|
3884
3889
|
rootOrdinals: _roots,
|
|
3885
3890
|
ordinalRoots: _ordinals,
|
|
3891
|
+
roots: _sourceRoots,
|
|
3886
3892
|
...record
|
|
3887
3893
|
} = materialization;
|
|
3888
3894
|
return structuredClone(record);
|
|
@@ -4224,17 +4230,8 @@ function storedPoint(point) {
|
|
|
4224
4230
|
};
|
|
4225
4231
|
}
|
|
4226
4232
|
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;
|
|
4233
|
+
const id = state.activeSourceHeads.get(projectEntityKey(projectId, sourceId));
|
|
4234
|
+
return id ? state.sourceMaterializations.get(sourceMaterializationKey(projectId, sourceId, id)) : undefined;
|
|
4238
4235
|
}
|
|
4239
4236
|
function storedSource(sourceId, materializationId, row) {
|
|
4240
4237
|
return {
|
|
@@ -4581,6 +4578,81 @@ function assertTimestampNotBefore(value, minimum, message) {
|
|
|
4581
4578
|
invalidCorrelation2(message);
|
|
4582
4579
|
}
|
|
4583
4580
|
|
|
4581
|
+
// src/storage/ontology/in-memory/source-roots.ts
|
|
4582
|
+
function* previousSourceRows(state, candidate) {
|
|
4583
|
+
const sourceKey = projectEntityKey(candidate.projectId, candidate.source.projectionId);
|
|
4584
|
+
const active = state.activeSourceRoots.get(sourceKey);
|
|
4585
|
+
if (!active)
|
|
4586
|
+
return;
|
|
4587
|
+
for (const rootKey of candidate.base ? candidate.roots.keys() : active.keys()) {
|
|
4588
|
+
const materializationId = active.get(rootKey);
|
|
4589
|
+
if (!materializationId)
|
|
4590
|
+
continue;
|
|
4591
|
+
const materialization = state.sourceMaterializations.get(sourceMaterializationKey(candidate.projectId, candidate.source.projectionId, materializationId));
|
|
4592
|
+
for (const entityKey of materialization.roots.get(rootKey).entityKeys) {
|
|
4593
|
+
yield storedSource(candidate.source.projectionId, materializationId, materialization.rowsByEntity.get(entityKey));
|
|
4594
|
+
}
|
|
4595
|
+
}
|
|
4596
|
+
}
|
|
4597
|
+
function activateSourceRoots(state, candidate, activation) {
|
|
4598
|
+
if (candidate.base && (candidate.base.materializationId !== activation.expected.activeMaterializationId || candidate.base.lastCommitId !== activation.expected.lastCommitId)) {
|
|
4599
|
+
throw new MaterializationConflictError2("projection-fence", "Source delta base changed before activation.");
|
|
4600
|
+
}
|
|
4601
|
+
const sourceKey = projectEntityKey(candidate.projectId, candidate.source.projectionId);
|
|
4602
|
+
const active = state.activeSourceRoots.get(sourceKey) ?? new Map;
|
|
4603
|
+
for (const key of candidate.base ? candidate.roots.keys() : [...active.keys()]) {
|
|
4604
|
+
const materializationId = active.get(key);
|
|
4605
|
+
if (!materializationId)
|
|
4606
|
+
continue;
|
|
4607
|
+
const old = state.sourceMaterializations.get(sourceMaterializationKey(candidate.projectId, candidate.source.projectionId, materializationId));
|
|
4608
|
+
const root = old.roots.get(key);
|
|
4609
|
+
root.active = false;
|
|
4610
|
+
root.retiredAt = activation.updatedAt;
|
|
4611
|
+
active.delete(key);
|
|
4612
|
+
for (const entityKey of root.entityKeys) {
|
|
4613
|
+
const row = old.rowsByEntity.get(entityKey);
|
|
4614
|
+
const indexKey = projectEntityKey(candidate.projectId, entityKey);
|
|
4615
|
+
const sources = state.activeSourceRows.get(indexKey);
|
|
4616
|
+
sources.delete(candidate.source.projectionId);
|
|
4617
|
+
if (sources.size === 0)
|
|
4618
|
+
state.activeSourceRows.delete(indexKey);
|
|
4619
|
+
if (row.assertion.kind === "link") {
|
|
4620
|
+
const scopeKey = projectEntityKey(candidate.projectId, linkScopeSortKey2(row.assertion.ref.source, row.assertion.ref.linkId));
|
|
4621
|
+
const scope = state.activeSourceLinkScopes.get(scopeKey);
|
|
4622
|
+
scope.delete(JSON.stringify([candidate.source.projectionId, entityKey]));
|
|
4623
|
+
if (scope.size === 0)
|
|
4624
|
+
state.activeSourceLinkScopes.delete(scopeKey);
|
|
4625
|
+
}
|
|
4626
|
+
}
|
|
4627
|
+
}
|
|
4628
|
+
for (const [rootKey, root] of candidate.roots) {
|
|
4629
|
+
root.active = !root.deleted;
|
|
4630
|
+
root.retiredAt = root.deleted ? activation.updatedAt : null;
|
|
4631
|
+
if (root.deleted)
|
|
4632
|
+
continue;
|
|
4633
|
+
active.set(rootKey, candidate.materializationId);
|
|
4634
|
+
for (const entityKey of root.entityKeys) {
|
|
4635
|
+
const row = {
|
|
4636
|
+
source: candidate.source,
|
|
4637
|
+
materializationId: candidate.materializationId,
|
|
4638
|
+
...candidate.rowsByEntity.get(entityKey)
|
|
4639
|
+
};
|
|
4640
|
+
const indexKey = projectEntityKey(candidate.projectId, projectionEntityKey2(row.assertion));
|
|
4641
|
+
const sources = state.activeSourceRows.get(indexKey) ?? new Map;
|
|
4642
|
+
sources.set(candidate.source.projectionId, row);
|
|
4643
|
+
state.activeSourceRows.set(indexKey, sources);
|
|
4644
|
+
if (row.assertion.kind === "link") {
|
|
4645
|
+
const scopeKey = projectEntityKey(candidate.projectId, linkScopeSortKey2(row.assertion.ref.source, row.assertion.ref.linkId));
|
|
4646
|
+
const scope = state.activeSourceLinkScopes.get(scopeKey) ?? new Map;
|
|
4647
|
+
scope.set(JSON.stringify([candidate.source.projectionId, entityKey]), row);
|
|
4648
|
+
state.activeSourceLinkScopes.set(scopeKey, scope);
|
|
4649
|
+
}
|
|
4650
|
+
}
|
|
4651
|
+
}
|
|
4652
|
+
state.activeSourceRoots.set(sourceKey, active);
|
|
4653
|
+
state.activeSourceHeads.set(sourceKey, candidate.materializationId);
|
|
4654
|
+
}
|
|
4655
|
+
|
|
4584
4656
|
// src/storage/ontology/in-memory/materializations.ts
|
|
4585
4657
|
class InMemoryOntologyMaterializationStorage {
|
|
4586
4658
|
state;
|
|
@@ -4794,7 +4866,7 @@ class InMemoryOntologyMaterializationStorage {
|
|
|
4794
4866
|
for (const entry of selected) {
|
|
4795
4867
|
const key = projectionEntityKey2({ kind: "link", ref: entry.ref });
|
|
4796
4868
|
const base = await this.linkState(session, entry.ref);
|
|
4797
|
-
const ownedByReplacement = replacement.
|
|
4869
|
+
const ownedByReplacement = replacement.owned.has(key);
|
|
4798
4870
|
links.push({
|
|
4799
4871
|
ref: base.ref,
|
|
4800
4872
|
candidateSource: ownedByReplacement ? storedSourceLink(input.source.projectionId, replacement.candidate.materializationId, replacement.candidate.rowsByEntity.get(key)) : base.source,
|
|
@@ -5044,6 +5116,7 @@ class InMemoryOntologyMaterializationStorage {
|
|
|
5044
5116
|
updatedAt: activation.updatedAt
|
|
5045
5117
|
});
|
|
5046
5118
|
}
|
|
5119
|
+
activateSourceRoots(this.state, candidate, activation);
|
|
5047
5120
|
this.state.sourceMaterializations.set(candidateKey, {
|
|
5048
5121
|
...candidate,
|
|
5049
5122
|
status: "active",
|
|
@@ -5093,7 +5166,7 @@ class InMemoryOntologyMaterializationStorage {
|
|
|
5093
5166
|
const replacement = {
|
|
5094
5167
|
sourceId,
|
|
5095
5168
|
candidateMaterializationId: input.candidateMaterializationId,
|
|
5096
|
-
|
|
5169
|
+
owned: new Set,
|
|
5097
5170
|
candidate,
|
|
5098
5171
|
objects: new Map,
|
|
5099
5172
|
links: new Map,
|
|
@@ -5107,10 +5180,12 @@ class InMemoryOntologyMaterializationStorage {
|
|
|
5107
5180
|
linkStreamCompleted: false,
|
|
5108
5181
|
linksExpanded: false
|
|
5109
5182
|
};
|
|
5110
|
-
for (const
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5183
|
+
for (const rows of [
|
|
5184
|
+
previousSourceRows(this.state, candidate),
|
|
5185
|
+
candidate.rowsByEntity.values()
|
|
5186
|
+
]) {
|
|
5187
|
+
for (const row of rows) {
|
|
5188
|
+
replacement.owned.add(projectionEntityKey2(row.assertion));
|
|
5114
5189
|
if (row.assertion.kind === "object") {
|
|
5115
5190
|
const ref = row.assertion.ref;
|
|
5116
5191
|
replacement.objects.set(objectRefKey2(ref), { ref, sortKey: objectRefSortKey2(ref) });
|
|
@@ -5130,51 +5205,52 @@ class InMemoryOntologyMaterializationStorage {
|
|
|
5130
5205
|
const incident = replacement.incidentObjects;
|
|
5131
5206
|
const touchesIncident = (ref) => incident.has(objectRefKey2(ref.source)) || incident.has(objectRefKey2(ref.target));
|
|
5132
5207
|
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);
|
|
5208
|
+
if (incident.size > 0) {
|
|
5209
|
+
adapter.visitExactLinks(projectId, (row) => {
|
|
5210
|
+
const ref = linkRef(row);
|
|
5211
|
+
if (touchesIncident(ref))
|
|
5212
|
+
addReplacementLink(replacement, ref, true);
|
|
5213
|
+
});
|
|
5214
|
+
for (const override of this.state.linkOverrides.values()) {
|
|
5215
|
+
if (override.projectId !== projectId)
|
|
5216
|
+
continue;
|
|
5217
|
+
if (touchesIncident(override.ref))
|
|
5218
|
+
addReplacementLink(replacement, override.ref, true);
|
|
5168
5219
|
}
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
|
|
5172
|
-
|
|
5220
|
+
for (const override of this.state.linkSlotOverrides.values()) {
|
|
5221
|
+
if (override.projectId !== projectId)
|
|
5222
|
+
continue;
|
|
5223
|
+
const ref = {
|
|
5173
5224
|
source: override.ref.source,
|
|
5174
5225
|
linkId: override.ref.linkId,
|
|
5175
5226
|
target: override.value.target
|
|
5176
|
-
}
|
|
5227
|
+
};
|
|
5228
|
+
if (touchesIncident(ref))
|
|
5229
|
+
addReplacementLink(replacement, ref, true);
|
|
5177
5230
|
}
|
|
5231
|
+
for (const [scopeKey, rows] of this.state.activeSourceLinkScopes) {
|
|
5232
|
+
if (JSON.parse(scopeKey)[0] !== projectId)
|
|
5233
|
+
continue;
|
|
5234
|
+
for (const row of rows.values()) {
|
|
5235
|
+
if (row.assertion.kind === "link" && touchesIncident(row.assertion.ref)) {
|
|
5236
|
+
addReplacementLink(replacement, row.assertion.ref, true);
|
|
5237
|
+
}
|
|
5238
|
+
}
|
|
5239
|
+
}
|
|
5240
|
+
}
|
|
5241
|
+
const scopes = new Map;
|
|
5242
|
+
for (const { ref } of replacement.links.values()) {
|
|
5243
|
+
const key = linkScopeSortKey2(ref.source, ref.linkId);
|
|
5244
|
+
if (replacement.affectedScopes.has(key))
|
|
5245
|
+
scopes.set(key, ref);
|
|
5246
|
+
}
|
|
5247
|
+
for (const scope of scopes.values()) {
|
|
5248
|
+
adapter.visitExactScopeLinks(projectId, scope.source.objectTypeId, scope.source.primaryId, scope.linkId, (row) => {
|
|
5249
|
+
addReplacementLink(replacement, linkRef(row), false);
|
|
5250
|
+
});
|
|
5251
|
+
const override = this.state.linkSlotOverrides.get(projectEntityKey(projectId, linkScopeKey(scope.source, scope.linkId)));
|
|
5252
|
+
if (override)
|
|
5253
|
+
addReplacementLink(replacement, { ...scope, target: override.value.target }, false);
|
|
5178
5254
|
}
|
|
5179
5255
|
replacement.linksExpanded = true;
|
|
5180
5256
|
replacement.orderedLinks = null;
|
|
@@ -5306,21 +5382,10 @@ class InMemoryOntologyMaterializationStorage {
|
|
|
5306
5382
|
};
|
|
5307
5383
|
}
|
|
5308
5384
|
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);
|
|
5385
|
+
const rows = this.state.activeSourceLinkScopes.get(projectEntityKey(projectId, linkScopeSortKey2(source, linkId)));
|
|
5386
|
+
if (rows && rows.size > 1)
|
|
5387
|
+
throw new MaterializationConflictError2("source-materialization", `Multiple active source links assert cardinality-one scope '${source.objectTypeId}.${linkId}'.`);
|
|
5388
|
+
return structuredClone(rows?.values().next().value ?? null);
|
|
5324
5389
|
}
|
|
5325
5390
|
findActiveObjectSource(projectId, ref) {
|
|
5326
5391
|
const found = this.findActiveSource(projectId, projectionEntityKey2({ kind: "object", ref }));
|
|
@@ -5331,18 +5396,10 @@ class InMemoryOntologyMaterializationStorage {
|
|
|
5331
5396
|
return found?.assertion.kind === "link" ? found : null;
|
|
5332
5397
|
}
|
|
5333
5398
|
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);
|
|
5399
|
+
const rows = this.state.activeSourceRows.get(projectEntityKey(projectId, entityKey));
|
|
5400
|
+
if (rows && rows.size > 1)
|
|
5401
|
+
throw new MaterializationConflictError2("source-materialization", `Multiple active sources assert ${entityKey}.`);
|
|
5402
|
+
return structuredClone(rows?.values().next().value ?? null);
|
|
5346
5403
|
}
|
|
5347
5404
|
incidentLinkRefs(session, objects) {
|
|
5348
5405
|
if (objects.length === 0)
|
|
@@ -5381,10 +5438,10 @@ class InMemoryOntologyMaterializationStorage {
|
|
|
5381
5438
|
target: override.value.target
|
|
5382
5439
|
});
|
|
5383
5440
|
}
|
|
5384
|
-
for (const
|
|
5385
|
-
if (
|
|
5441
|
+
for (const [scopeKey, rows] of this.state.activeSourceLinkScopes) {
|
|
5442
|
+
if (JSON.parse(scopeKey)[0] !== projectId)
|
|
5386
5443
|
continue;
|
|
5387
|
-
for (const row of
|
|
5444
|
+
for (const row of rows.values()) {
|
|
5388
5445
|
if (row.assertion.kind === "link")
|
|
5389
5446
|
consider(row.assertion.ref);
|
|
5390
5447
|
}
|
|
@@ -5590,6 +5647,7 @@ class InMemoryOntologySourceStorage {
|
|
|
5590
5647
|
projectionRevision: input.projectionRevision,
|
|
5591
5648
|
ownershipHash: input.ownershipHash,
|
|
5592
5649
|
ontologyRevision: input.ontologyRevision,
|
|
5650
|
+
...input.base ? { base: structuredClone(input.base) } : {},
|
|
5593
5651
|
rootCount: null,
|
|
5594
5652
|
assertionCount: null,
|
|
5595
5653
|
createdAt: input.createdAt,
|
|
@@ -5599,6 +5657,7 @@ class InMemoryOntologySourceStorage {
|
|
|
5599
5657
|
lastCommitId: null,
|
|
5600
5658
|
updatedAt: input.createdAt,
|
|
5601
5659
|
rowsByEntity: new Map,
|
|
5660
|
+
roots: new Map,
|
|
5602
5661
|
rootOrdinals: new Map,
|
|
5603
5662
|
ordinalRoots: new Map
|
|
5604
5663
|
};
|
|
@@ -5615,7 +5674,7 @@ class InMemoryOntologySourceStorage {
|
|
|
5615
5674
|
if (materialization.status !== "staging") {
|
|
5616
5675
|
throw sourceConflict2(`Source materialization '${input.materializationId}' is '${materialization.status}' and cannot accept rows.`);
|
|
5617
5676
|
}
|
|
5618
|
-
return stageRowsAtomically(materialization, input
|
|
5677
|
+
return stageRowsAtomically(materialization, input);
|
|
5619
5678
|
});
|
|
5620
5679
|
}
|
|
5621
5680
|
async markReady(input) {
|
|
@@ -5653,11 +5712,8 @@ class InMemoryOntologySourceStorage {
|
|
|
5653
5712
|
async getActive(input) {
|
|
5654
5713
|
return this.runRootOperation(() => {
|
|
5655
5714
|
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;
|
|
5715
|
+
const active = findActiveSourceMaterialization(this.state, input.projectId, input.source.projectionId);
|
|
5716
|
+
return active ? sourceMaterializationRecord(active) : null;
|
|
5661
5717
|
});
|
|
5662
5718
|
}
|
|
5663
5719
|
async abandon(input) {
|
|
@@ -5682,6 +5738,8 @@ class InMemoryOntologySourceStorage {
|
|
|
5682
5738
|
if (materialization.projectId !== input.projectId || materialization.status !== "superseded" && materialization.status !== "abandoned" || materialization.terminalAt === null || materialization.terminalAt >= input.terminalBefore) {
|
|
5683
5739
|
continue;
|
|
5684
5740
|
}
|
|
5741
|
+
if (materialization.roots.size > 0 && ![...materialization.roots.values()].some((root) => !root.active && root.retiredAt !== null && root.retiredAt < input.terminalBefore))
|
|
5742
|
+
continue;
|
|
5685
5743
|
insertBounded(candidates, entry, input.limit, compareTerminalMaterializations);
|
|
5686
5744
|
}
|
|
5687
5745
|
let remaining = input.limit;
|
|
@@ -5695,14 +5753,28 @@ class InMemoryOntologySourceStorage {
|
|
|
5695
5753
|
continue;
|
|
5696
5754
|
current.rootOrdinals.clear();
|
|
5697
5755
|
current.ordinalRoots.clear();
|
|
5698
|
-
for (const
|
|
5756
|
+
for (const [rootKey, root] of current.roots) {
|
|
5699
5757
|
if (remaining === 0)
|
|
5700
5758
|
break;
|
|
5701
|
-
|
|
5702
|
-
|
|
5703
|
-
|
|
5759
|
+
if (root.active || root.retiredAt === null || root.retiredAt >= input.terminalBefore)
|
|
5760
|
+
continue;
|
|
5761
|
+
for (const entityKey of root.entityKeys) {
|
|
5762
|
+
if (remaining === 0)
|
|
5763
|
+
break;
|
|
5764
|
+
current.rowsByEntity.delete(entityKey);
|
|
5765
|
+
root.entityKeys.delete(entityKey);
|
|
5766
|
+
rowsDeleted += 1;
|
|
5767
|
+
remaining -= 1;
|
|
5768
|
+
}
|
|
5769
|
+
if (root.entityKeys.size === 0 && remaining > 0) {
|
|
5770
|
+
current.roots.delete(rootKey);
|
|
5771
|
+
current.rootOrdinals.delete(rootKey);
|
|
5772
|
+
current.ordinalRoots.delete(root.stagingOrdinal);
|
|
5773
|
+
rowsDeleted += 1;
|
|
5774
|
+
remaining -= 1;
|
|
5775
|
+
}
|
|
5704
5776
|
}
|
|
5705
|
-
if (current.rowsByEntity.size === 0 && remaining > 0) {
|
|
5777
|
+
if (current.roots.size === 0 && current.rowsByEntity.size === 0 && remaining > 0) {
|
|
5706
5778
|
this.state.sourceMaterializations.delete(key);
|
|
5707
5779
|
materializationsDeleted += 1;
|
|
5708
5780
|
remaining -= 1;
|
|
@@ -5773,6 +5845,8 @@ class InMemoryOntologySourceStorage {
|
|
|
5773
5845
|
if (materialization.readyAt !== null) {
|
|
5774
5846
|
assertNotBefore(abandonedAt, materialization.readyAt, "Source abandonedAt", "readyAt");
|
|
5775
5847
|
}
|
|
5848
|
+
for (const root of materialization.roots.values())
|
|
5849
|
+
root.retiredAt = abandonedAt;
|
|
5776
5850
|
const abandoned = {
|
|
5777
5851
|
...materialization,
|
|
5778
5852
|
status: "abandoned",
|
|
@@ -5787,13 +5861,26 @@ class InMemoryOntologySourceStorage {
|
|
|
5787
5861
|
return [...this.state.sourceMaterializations.entries()].filter(([, materialization]) => materialization.projectId === projectId && materialization.source.projectionId === sourceId && materialization.projectionRunId === projectionRunId && (materialization.status === "staging" || materialization.status === "ready"));
|
|
5788
5862
|
}
|
|
5789
5863
|
}
|
|
5790
|
-
function stageRowsAtomically(materialization,
|
|
5864
|
+
function stageRowsAtomically(materialization, input) {
|
|
5791
5865
|
let inserted = 0;
|
|
5792
5866
|
let unchanged = 0;
|
|
5793
5867
|
const newRows = new Map;
|
|
5794
5868
|
const newRootOrdinals = new Map;
|
|
5795
5869
|
const newOrdinalRoots = new Map;
|
|
5796
|
-
|
|
5870
|
+
const roots = sourceStageRoots2(materialization.projectionKind, input);
|
|
5871
|
+
if (!materialization.base && roots.some((root) => root.deleted)) {
|
|
5872
|
+
throw new MaterializationValidationError2("Root deletions require a source delta base.");
|
|
5873
|
+
}
|
|
5874
|
+
for (const root of roots) {
|
|
5875
|
+
const previous = materialization.roots.get(root.rootKey);
|
|
5876
|
+
const otherRoot = materialization.ordinalRoots.get(root.stagingOrdinal);
|
|
5877
|
+
if (previous && (previous.deleted !== root.deleted || previous.stagingOrdinal !== root.stagingOrdinal) || otherRoot !== undefined && otherRoot !== root.rootKey) {
|
|
5878
|
+
throw new MaterializationValidationError2("Source materialization repeats root or stream ordinal with different content.");
|
|
5879
|
+
}
|
|
5880
|
+
newRootOrdinals.set(root.rootKey, root.stagingOrdinal);
|
|
5881
|
+
newOrdinalRoots.set(root.stagingOrdinal, root.rootKey);
|
|
5882
|
+
}
|
|
5883
|
+
for (const row of input.rows) {
|
|
5797
5884
|
assertSourceStagedRow2(materialization.projectionKind, row);
|
|
5798
5885
|
const rootKey = projectionEntityKey2(row.root);
|
|
5799
5886
|
const existingOrdinal = materialization.rootOrdinals.get(rootKey) ?? newRootOrdinals.get(rootKey);
|
|
@@ -5824,8 +5911,21 @@ function stageRowsAtomically(materialization, rows) {
|
|
|
5824
5911
|
for (const [ordinal, rootKey] of newOrdinalRoots) {
|
|
5825
5912
|
materialization.ordinalRoots.set(ordinal, rootKey);
|
|
5826
5913
|
}
|
|
5827
|
-
for (const
|
|
5914
|
+
for (const root of roots) {
|
|
5915
|
+
if (!materialization.roots.has(root.rootKey))
|
|
5916
|
+
materialization.roots.set(root.rootKey, {
|
|
5917
|
+
root: structuredClone(root.root),
|
|
5918
|
+
stagingOrdinal: root.stagingOrdinal,
|
|
5919
|
+
deleted: root.deleted,
|
|
5920
|
+
entityKeys: new Set,
|
|
5921
|
+
active: false,
|
|
5922
|
+
retiredAt: null
|
|
5923
|
+
});
|
|
5924
|
+
}
|
|
5925
|
+
for (const [entityKey, row] of newRows) {
|
|
5828
5926
|
materialization.rowsByEntity.set(entityKey, row);
|
|
5927
|
+
materialization.roots.get(projectionEntityKey2(row.root)).entityKeys.add(entityKey);
|
|
5928
|
+
}
|
|
5829
5929
|
return { inserted, unchanged };
|
|
5830
5930
|
}
|
|
5831
5931
|
function assertReadyCounts(materialization, rootCount, assertionCount) {
|
|
@@ -5849,6 +5949,11 @@ function assertReadyTopology(materialization) {
|
|
|
5849
5949
|
}
|
|
5850
5950
|
for (const rootKey of materialization.rootOrdinals.keys()) {
|
|
5851
5951
|
const rows = rowsByRoot.get(rootKey) ?? [];
|
|
5952
|
+
if (materialization.roots.get(rootKey)?.deleted) {
|
|
5953
|
+
if (rows.length > 0)
|
|
5954
|
+
throw new MaterializationValidationError2("Deleted source roots cannot contain assertions.");
|
|
5955
|
+
continue;
|
|
5956
|
+
}
|
|
5852
5957
|
const first = rows[0];
|
|
5853
5958
|
if (!first) {
|
|
5854
5959
|
throw new MaterializationValidationError2(`Source root ${rootKey} has no staged assertions.`);
|
|
@@ -8216,4 +8321,4 @@ function assertAppliedPrefix(migrations, rows) {
|
|
|
8216
8321
|
}
|
|
8217
8322
|
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
8323
|
|
|
8219
|
-
//# debugId=
|
|
8324
|
+
//# debugId=E15B3DF7CD823E3C64756E2164756E21
|