hikoutei 0.2.0
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/LICENSE +21 -0
- package/README.ja.md +135 -0
- package/README.ko.md +138 -0
- package/README.md +143 -0
- package/apps-script/gateway/Code.gs +412 -0
- package/dist/adapter/persistence/contracts/index.d.ts +3 -0
- package/dist/adapter/persistence/contracts/index.d.ts.map +1 -0
- package/dist/adapter/persistence/contracts/index.js +3 -0
- package/dist/adapter/persistence/contracts/index.js.map +1 -0
- package/dist/adapter/persistence/contracts/sql.d.ts +50 -0
- package/dist/adapter/persistence/contracts/sql.d.ts.map +1 -0
- package/dist/adapter/persistence/contracts/sql.js +9 -0
- package/dist/adapter/persistence/contracts/sql.js.map +1 -0
- package/dist/adapter/persistence/index.d.ts +2 -0
- package/dist/adapter/persistence/index.d.ts.map +1 -0
- package/dist/adapter/persistence/index.js +2 -0
- package/dist/adapter/persistence/index.js.map +1 -0
- package/dist/adapter/persistence/providers/mikro-orm/api/MikroOrmTypedSheetsEntityManager.d.ts +53 -0
- package/dist/adapter/persistence/providers/mikro-orm/api/MikroOrmTypedSheetsEntityManager.d.ts.map +1 -0
- package/dist/adapter/persistence/providers/mikro-orm/api/MikroOrmTypedSheetsEntityManager.js +105 -0
- package/dist/adapter/persistence/providers/mikro-orm/api/MikroOrmTypedSheetsEntityManager.js.map +1 -0
- package/dist/adapter/persistence/providers/mikro-orm/engine/MikroOrmMappedTypedSheets.d.ts +39 -0
- package/dist/adapter/persistence/providers/mikro-orm/engine/MikroOrmMappedTypedSheets.d.ts.map +1 -0
- package/dist/adapter/persistence/providers/mikro-orm/engine/MikroOrmMappedTypedSheets.js +54 -0
- package/dist/adapter/persistence/providers/mikro-orm/engine/MikroOrmMappedTypedSheets.js.map +1 -0
- package/dist/adapter/persistence/providers/mikro-orm/engine/MikroOrmTypedSheetsEngine.d.ts +38 -0
- package/dist/adapter/persistence/providers/mikro-orm/engine/MikroOrmTypedSheetsEngine.d.ts.map +1 -0
- package/dist/adapter/persistence/providers/mikro-orm/engine/MikroOrmTypedSheetsEngine.js +55 -0
- package/dist/adapter/persistence/providers/mikro-orm/engine/MikroOrmTypedSheetsEngine.js.map +1 -0
- package/dist/adapter/persistence/providers/mikro-orm/index.d.ts +16 -0
- package/dist/adapter/persistence/providers/mikro-orm/index.d.ts.map +1 -0
- package/dist/adapter/persistence/providers/mikro-orm/index.js +9 -0
- package/dist/adapter/persistence/providers/mikro-orm/index.js.map +1 -0
- package/dist/adapter/persistence/providers/mikro-orm/observation/MikroOrmMappedObservation.d.ts +27 -0
- package/dist/adapter/persistence/providers/mikro-orm/observation/MikroOrmMappedObservation.d.ts.map +1 -0
- package/dist/adapter/persistence/providers/mikro-orm/observation/MikroOrmMappedObservation.js +67 -0
- package/dist/adapter/persistence/providers/mikro-orm/observation/MikroOrmMappedObservation.js.map +1 -0
- package/dist/adapter/persistence/providers/mikro-orm/storage/MikroOrmFlushChanges.d.ts +19 -0
- package/dist/adapter/persistence/providers/mikro-orm/storage/MikroOrmFlushChanges.d.ts.map +1 -0
- package/dist/adapter/persistence/providers/mikro-orm/storage/MikroOrmFlushChanges.js +67 -0
- package/dist/adapter/persistence/providers/mikro-orm/storage/MikroOrmFlushChanges.js.map +1 -0
- package/dist/adapter/persistence/providers/mikro-orm/storage/MikroOrmSqliteAdapter.d.ts +78 -0
- package/dist/adapter/persistence/providers/mikro-orm/storage/MikroOrmSqliteAdapter.d.ts.map +1 -0
- package/dist/adapter/persistence/providers/mikro-orm/storage/MikroOrmSqliteAdapter.js +121 -0
- package/dist/adapter/persistence/providers/mikro-orm/storage/MikroOrmSqliteAdapter.js.map +1 -0
- package/dist/adapter/persistence/providers/mikro-orm/storage/MikroOrmSqliteSchema.d.ts +20 -0
- package/dist/adapter/persistence/providers/mikro-orm/storage/MikroOrmSqliteSchema.d.ts.map +1 -0
- package/dist/adapter/persistence/providers/mikro-orm/storage/MikroOrmSqliteSchema.js +125 -0
- package/dist/adapter/persistence/providers/mikro-orm/storage/MikroOrmSqliteSchema.js.map +1 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/errors.d.ts +42 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/errors.d.ts.map +1 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/errors.js +51 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/errors.js.map +1 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/index.d.ts +22 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/index.d.ts.map +1 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/index.js +12 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/index.js.map +1 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/operations/effect/effectOperation.d.ts +42 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/operations/effect/effectOperation.d.ts.map +1 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/operations/effect/effectOperation.js +161 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/operations/effect/effectOperation.js.map +1 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/operations/effect/effectOperationScript.d.ts +3 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/operations/effect/effectOperationScript.d.ts.map +1 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/operations/effect/effectOperationScript.js +692 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/operations/effect/effectOperationScript.js.map +1 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/operations/observation/observationOperation.d.ts +29 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/operations/observation/observationOperation.d.ts.map +1 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/operations/observation/observationOperation.js +538 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/operations/observation/observationOperation.js.map +1 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/operations/read/tableReadOperation.d.ts +12 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/operations/read/tableReadOperation.d.ts.map +1 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/operations/read/tableReadOperation.js +190 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/operations/read/tableReadOperation.js.map +1 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/operations/write/fastAppendOperation.d.ts +23 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/operations/write/fastAppendOperation.d.ts.map +1 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/operations/write/fastAppendOperation.js +166 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/operations/write/fastAppendOperation.js.map +1 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/protocol/codeGsProtocol.d.ts +50 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/protocol/codeGsProtocol.d.ts.map +1 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/protocol/codeGsProtocol.js +60 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/protocol/codeGsProtocol.js.map +1 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/protocol/constants.d.ts +44 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/protocol/constants.d.ts.map +1 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/protocol/constants.js +40 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/protocol/constants.js.map +1 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/protocol/syncProtocol.d.ts +7 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/protocol/syncProtocol.d.ts.map +1 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/protocol/syncProtocol.js +47 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/protocol/syncProtocol.js.map +1 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/protocol/timing.d.ts +5 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/protocol/timing.d.ts.map +1 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/protocol/timing.js +54 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/protocol/timing.js.map +1 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/protocol/types.d.ts +5 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/protocol/types.d.ts.map +1 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/protocol/types.js +2 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/protocol/types.js.map +1 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/protocol/validation.d.ts +10 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/protocol/validation.d.ts.map +1 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/protocol/validation.js +35 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/protocol/validation.js.map +1 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/transport/operationClient.d.ts +67 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/transport/operationClient.d.ts.map +1 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/transport/operationClient.js +204 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/transport/operationClient.js.map +1 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/transport/operationSyncGateway.d.ts +78 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/transport/operationSyncGateway.d.ts.map +1 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/transport/operationSyncGateway.js +343 -0
- package/dist/adapter/sheets/providers/apps-script-gateway/transport/operationSyncGateway.js.map +1 -0
- package/dist/application/index.d.ts +4 -0
- package/dist/application/index.d.ts.map +1 -0
- package/dist/application/index.js +4 -0
- package/dist/application/index.js.map +1 -0
- package/dist/application/orm/api/TypedSheetsOrm.d.ts +71 -0
- package/dist/application/orm/api/TypedSheetsOrm.d.ts.map +1 -0
- package/dist/application/orm/api/TypedSheetsOrm.js +116 -0
- package/dist/application/orm/api/TypedSheetsOrm.js.map +1 -0
- package/dist/application/orm/api/contracts.d.ts +118 -0
- package/dist/application/orm/api/contracts.d.ts.map +1 -0
- package/dist/application/orm/api/contracts.js +21 -0
- package/dist/application/orm/api/contracts.js.map +1 -0
- package/dist/application/orm/errors.d.ts +35 -0
- package/dist/application/orm/errors.d.ts.map +1 -0
- package/dist/application/orm/errors.js +35 -0
- package/dist/application/orm/errors.js.map +1 -0
- package/dist/application/orm/index.d.ts +13 -0
- package/dist/application/orm/index.d.ts.map +1 -0
- package/dist/application/orm/index.js +7 -0
- package/dist/application/orm/index.js.map +1 -0
- package/dist/application/orm/mapping/contracts.d.ts +113 -0
- package/dist/application/orm/mapping/contracts.d.ts.map +1 -0
- package/dist/application/orm/mapping/contracts.js +8 -0
- package/dist/application/orm/mapping/contracts.js.map +1 -0
- package/dist/application/orm/mapping/definition.d.ts +16 -0
- package/dist/application/orm/mapping/definition.d.ts.map +1 -0
- package/dist/application/orm/mapping/definition.js +145 -0
- package/dist/application/orm/mapping/definition.js.map +1 -0
- package/dist/application/orm/mapping/entityMapping.d.ts +13 -0
- package/dist/application/orm/mapping/entityMapping.d.ts.map +1 -0
- package/dist/application/orm/mapping/entityMapping.js +13 -0
- package/dist/application/orm/mapping/entityMapping.js.map +1 -0
- package/dist/application/orm/mapping/identity.d.ts +14 -0
- package/dist/application/orm/mapping/identity.d.ts.map +1 -0
- package/dist/application/orm/mapping/identity.js +37 -0
- package/dist/application/orm/mapping/identity.js.map +1 -0
- package/dist/application/orm/mapping/observationMapping.d.ts +42 -0
- package/dist/application/orm/mapping/observationMapping.d.ts.map +1 -0
- package/dist/application/orm/mapping/observationMapping.js +65 -0
- package/dist/application/orm/mapping/observationMapping.js.map +1 -0
- package/dist/application/orm/mapping/projection.d.ts +22 -0
- package/dist/application/orm/mapping/projection.d.ts.map +1 -0
- package/dist/application/orm/mapping/projection.js +74 -0
- package/dist/application/orm/mapping/projection.js.map +1 -0
- package/dist/application/orm/mapping/registry.d.ts +15 -0
- package/dist/application/orm/mapping/registry.d.ts.map +1 -0
- package/dist/application/orm/mapping/registry.js +38 -0
- package/dist/application/orm/mapping/registry.js.map +1 -0
- package/dist/application/orm/mapping/values.d.ts +17 -0
- package/dist/application/orm/mapping/values.d.ts.map +1 -0
- package/dist/application/orm/mapping/values.js +141 -0
- package/dist/application/orm/mapping/values.js.map +1 -0
- package/dist/application/orm/persistence/flush/flushCoordinator.d.ts +28 -0
- package/dist/application/orm/persistence/flush/flushCoordinator.d.ts.map +1 -0
- package/dist/application/orm/persistence/flush/flushCoordinator.js +170 -0
- package/dist/application/orm/persistence/flush/flushCoordinator.js.map +1 -0
- package/dist/application/orm/persistence/flush/mappedFlushCoordinator.d.ts +9 -0
- package/dist/application/orm/persistence/flush/mappedFlushCoordinator.d.ts.map +1 -0
- package/dist/application/orm/persistence/flush/mappedFlushCoordinator.js +8 -0
- package/dist/application/orm/persistence/flush/mappedFlushCoordinator.js.map +1 -0
- package/dist/application/orm/persistence/lifecycle/entityLifecycle.d.ts +12 -0
- package/dist/application/orm/persistence/lifecycle/entityLifecycle.d.ts.map +1 -0
- package/dist/application/orm/persistence/lifecycle/entityLifecycle.js +134 -0
- package/dist/application/orm/persistence/lifecycle/entityLifecycle.js.map +1 -0
- package/dist/application/orm/persistence/projection/projectionEffects.d.ts +21 -0
- package/dist/application/orm/persistence/projection/projectionEffects.d.ts.map +1 -0
- package/dist/application/orm/persistence/projection/projectionEffects.js +203 -0
- package/dist/application/orm/persistence/projection/projectionEffects.js.map +1 -0
- package/dist/application/orm/persistence/support/businessKeys.d.ts +17 -0
- package/dist/application/orm/persistence/support/businessKeys.d.ts.map +1 -0
- package/dist/application/orm/persistence/support/businessKeys.js +72 -0
- package/dist/application/orm/persistence/support/businessKeys.js.map +1 -0
- package/dist/application/orm/persistence/support/canonicalState.d.ts +22 -0
- package/dist/application/orm/persistence/support/canonicalState.d.ts.map +1 -0
- package/dist/application/orm/persistence/support/canonicalState.js +88 -0
- package/dist/application/orm/persistence/support/canonicalState.js.map +1 -0
- package/dist/application/orm/persistence/support/contracts.d.ts +139 -0
- package/dist/application/orm/persistence/support/contracts.d.ts.map +1 -0
- package/dist/application/orm/persistence/support/contracts.js +93 -0
- package/dist/application/orm/persistence/support/contracts.js.map +1 -0
- package/dist/application/orm/persistence/support/helpers.d.ts +32 -0
- package/dist/application/orm/persistence/support/helpers.d.ts.map +1 -0
- package/dist/application/orm/persistence/support/helpers.js +66 -0
- package/dist/application/orm/persistence/support/helpers.js.map +1 -0
- package/dist/application/orm/persistence/support/timing.d.ts +20 -0
- package/dist/application/orm/persistence/support/timing.d.ts.map +1 -0
- package/dist/application/orm/persistence/support/timing.js +55 -0
- package/dist/application/orm/persistence/support/timing.js.map +1 -0
- package/dist/application/sync/gateway/SyncGatewayBootstrap.d.ts +46 -0
- package/dist/application/sync/gateway/SyncGatewayBootstrap.d.ts.map +1 -0
- package/dist/application/sync/gateway/SyncGatewayBootstrap.js +93 -0
- package/dist/application/sync/gateway/SyncGatewayBootstrap.js.map +1 -0
- package/dist/application/sync/gateway/constants.d.ts +65 -0
- package/dist/application/sync/gateway/constants.d.ts.map +1 -0
- package/dist/application/sync/gateway/constants.js +57 -0
- package/dist/application/sync/gateway/constants.js.map +1 -0
- package/dist/application/sync/gateway/errors.d.ts +15 -0
- package/dist/application/sync/gateway/errors.d.ts.map +1 -0
- package/dist/application/sync/gateway/errors.js +16 -0
- package/dist/application/sync/gateway/errors.js.map +1 -0
- package/dist/application/sync/gateway/syncGateway.d.ts +313 -0
- package/dist/application/sync/gateway/syncGateway.d.ts.map +1 -0
- package/dist/application/sync/gateway/syncGateway.js +202 -0
- package/dist/application/sync/gateway/syncGateway.js.map +1 -0
- package/dist/application/sync/gateway/validation.d.ts +17 -0
- package/dist/application/sync/gateway/validation.d.ts.map +1 -0
- package/dist/application/sync/gateway/validation.js +60 -0
- package/dist/application/sync/gateway/validation.js.map +1 -0
- package/dist/application/sync/inbound/polling/SimpleSheetPolling.d.ts +72 -0
- package/dist/application/sync/inbound/polling/SimpleSheetPolling.d.ts.map +1 -0
- package/dist/application/sync/inbound/polling/SimpleSheetPolling.js +272 -0
- package/dist/application/sync/inbound/polling/SimpleSheetPolling.js.map +1 -0
- package/dist/application/sync/index.d.ts +16 -0
- package/dist/application/sync/index.d.ts.map +1 -0
- package/dist/application/sync/index.js +9 -0
- package/dist/application/sync/index.js.map +1 -0
- package/dist/application/sync/outbound/effects/SyncEffectSupervisor.d.ts +106 -0
- package/dist/application/sync/outbound/effects/SyncEffectSupervisor.d.ts.map +1 -0
- package/dist/application/sync/outbound/effects/SyncEffectSupervisor.js +297 -0
- package/dist/application/sync/outbound/effects/SyncEffectSupervisor.js.map +1 -0
- package/dist/application/sync/outbound/effects/SyncEffectWorker.d.ts +100 -0
- package/dist/application/sync/outbound/effects/SyncEffectWorker.d.ts.map +1 -0
- package/dist/application/sync/outbound/effects/SyncEffectWorker.js +345 -0
- package/dist/application/sync/outbound/effects/SyncEffectWorker.js.map +1 -0
- package/dist/application/sync/outbound/effects/SyncEffectWorkerConstants.d.ts +46 -0
- package/dist/application/sync/outbound/effects/SyncEffectWorkerConstants.d.ts.map +1 -0
- package/dist/application/sync/outbound/effects/SyncEffectWorkerConstants.js +63 -0
- package/dist/application/sync/outbound/effects/SyncEffectWorkerConstants.js.map +1 -0
- package/dist/application/sync/outbound/effects/SyncEffectWorkerDispatch.d.ts +20 -0
- package/dist/application/sync/outbound/effects/SyncEffectWorkerDispatch.d.ts.map +1 -0
- package/dist/application/sync/outbound/effects/SyncEffectWorkerDispatch.js +102 -0
- package/dist/application/sync/outbound/effects/SyncEffectWorkerDispatch.js.map +1 -0
- package/dist/application/sync/outbound/effects/SyncEffectWorkerHelpers.d.ts +19 -0
- package/dist/application/sync/outbound/effects/SyncEffectWorkerHelpers.d.ts.map +1 -0
- package/dist/application/sync/outbound/effects/SyncEffectWorkerHelpers.js +32 -0
- package/dist/application/sync/outbound/effects/SyncEffectWorkerHelpers.js.map +1 -0
- package/dist/application/sync/outbound/effects/SyncEffectWorkerRouting.d.ts +30 -0
- package/dist/application/sync/outbound/effects/SyncEffectWorkerRouting.d.ts.map +1 -0
- package/dist/application/sync/outbound/effects/SyncEffectWorkerRouting.js +202 -0
- package/dist/application/sync/outbound/effects/SyncEffectWorkerRouting.js.map +1 -0
- package/dist/application/sync/outbound/effects/SyncEffectWorkerTiming.d.ts +17 -0
- package/dist/application/sync/outbound/effects/SyncEffectWorkerTiming.d.ts.map +1 -0
- package/dist/application/sync/outbound/effects/SyncEffectWorkerTiming.js +80 -0
- package/dist/application/sync/outbound/effects/SyncEffectWorkerTiming.js.map +1 -0
- package/dist/application/sync/outbound/effects/SyncEffectWorkerTransitions.d.ts +13 -0
- package/dist/application/sync/outbound/effects/SyncEffectWorkerTransitions.d.ts.map +1 -0
- package/dist/application/sync/outbound/effects/SyncEffectWorkerTransitions.js +205 -0
- package/dist/application/sync/outbound/effects/SyncEffectWorkerTransitions.js.map +1 -0
- package/dist/application/sync/outbound/projection/ProjectionEffectFactory.d.ts +81 -0
- package/dist/application/sync/outbound/projection/ProjectionEffectFactory.d.ts.map +1 -0
- package/dist/application/sync/outbound/projection/ProjectionEffectFactory.js +245 -0
- package/dist/application/sync/outbound/projection/ProjectionEffectFactory.js.map +1 -0
- package/dist/application/sync/outbound/reconciliation/ReconciliationScanner.d.ts +77 -0
- package/dist/application/sync/outbound/reconciliation/ReconciliationScanner.d.ts.map +1 -0
- package/dist/application/sync/outbound/reconciliation/ReconciliationScanner.js +518 -0
- package/dist/application/sync/outbound/reconciliation/ReconciliationScanner.js.map +1 -0
- package/dist/application/sync/telemetry/syncTiming.d.ts +50 -0
- package/dist/application/sync/telemetry/syncTiming.d.ts.map +1 -0
- package/dist/application/sync/telemetry/syncTiming.js +22 -0
- package/dist/application/sync/telemetry/syncTiming.js.map +1 -0
- package/dist/domain/conflict/errors.d.ts +42 -0
- package/dist/domain/conflict/errors.d.ts.map +1 -0
- package/dist/domain/conflict/errors.js +36 -0
- package/dist/domain/conflict/errors.js.map +1 -0
- package/dist/domain/conflict/index.d.ts +5 -0
- package/dist/domain/conflict/index.d.ts.map +1 -0
- package/dist/domain/conflict/index.js +3 -0
- package/dist/domain/conflict/index.js.map +1 -0
- package/dist/domain/conflict/transitions.d.ts +52 -0
- package/dist/domain/conflict/transitions.d.ts.map +1 -0
- package/dist/domain/conflict/transitions.js +115 -0
- package/dist/domain/conflict/transitions.js.map +1 -0
- package/dist/domain/errors/evaluation.d.ts +13 -0
- package/dist/domain/errors/evaluation.d.ts.map +1 -0
- package/dist/domain/errors/evaluation.js +14 -0
- package/dist/domain/errors/evaluation.js.map +1 -0
- package/dist/domain/errors/identity.d.ts +12 -0
- package/dist/domain/errors/identity.d.ts.map +1 -0
- package/dist/domain/errors/identity.js +15 -0
- package/dist/domain/errors/identity.js.map +1 -0
- package/dist/domain/errors/index.d.ts +7 -0
- package/dist/domain/errors/index.d.ts.map +1 -0
- package/dist/domain/errors/index.js +5 -0
- package/dist/domain/errors/index.js.map +1 -0
- package/dist/domain/errors/stableEncoding.d.ts +7 -0
- package/dist/domain/errors/stableEncoding.d.ts.map +1 -0
- package/dist/domain/errors/stableEncoding.js +8 -0
- package/dist/domain/errors/stableEncoding.js.map +1 -0
- package/dist/domain/errors/types.d.ts +20 -0
- package/dist/domain/errors/types.d.ts.map +1 -0
- package/dist/domain/errors/types.js +18 -0
- package/dist/domain/errors/types.js.map +1 -0
- package/dist/domain/evaluate/constants.d.ts +55 -0
- package/dist/domain/evaluate/constants.d.ts.map +1 -0
- package/dist/domain/evaluate/constants.js +41 -0
- package/dist/domain/evaluate/constants.js.map +1 -0
- package/dist/domain/evaluate/contracts.d.ts +125 -0
- package/dist/domain/evaluate/contracts.d.ts.map +1 -0
- package/dist/domain/evaluate/contracts.js +8 -0
- package/dist/domain/evaluate/contracts.js.map +1 -0
- package/dist/domain/evaluate/evaluateBatch.d.ts +11 -0
- package/dist/domain/evaluate/evaluateBatch.d.ts.map +1 -0
- package/dist/domain/evaluate/evaluateBatch.js +91 -0
- package/dist/domain/evaluate/evaluateBatch.js.map +1 -0
- package/dist/domain/evaluate/fieldEvaluation.d.ts +14 -0
- package/dist/domain/evaluate/fieldEvaluation.d.ts.map +1 -0
- package/dist/domain/evaluate/fieldEvaluation.js +133 -0
- package/dist/domain/evaluate/fieldEvaluation.js.map +1 -0
- package/dist/domain/evaluate/identity.d.ts +21 -0
- package/dist/domain/evaluate/identity.d.ts.map +1 -0
- package/dist/domain/evaluate/identity.js +72 -0
- package/dist/domain/evaluate/identity.js.map +1 -0
- package/dist/domain/evaluate/index.d.ts +4 -0
- package/dist/domain/evaluate/index.d.ts.map +1 -0
- package/dist/domain/evaluate/index.js +3 -0
- package/dist/domain/evaluate/index.js.map +1 -0
- package/dist/domain/evaluate/preconditions.d.ts +30 -0
- package/dist/domain/evaluate/preconditions.d.ts.map +1 -0
- package/dist/domain/evaluate/preconditions.js +389 -0
- package/dist/domain/evaluate/preconditions.js.map +1 -0
- package/dist/domain/evaluate/quarantine.d.ts +15 -0
- package/dist/domain/evaluate/quarantine.d.ts.map +1 -0
- package/dist/domain/evaluate/quarantine.js +185 -0
- package/dist/domain/evaluate/quarantine.js.map +1 -0
- package/dist/domain/index.d.ts +7 -0
- package/dist/domain/index.d.ts.map +1 -0
- package/dist/domain/index.js +7 -0
- package/dist/domain/index.js.map +1 -0
- package/dist/domain/model/constants.d.ts +73 -0
- package/dist/domain/model/constants.d.ts.map +1 -0
- package/dist/domain/model/constants.js +59 -0
- package/dist/domain/model/constants.js.map +1 -0
- package/dist/domain/model/index.d.ts +3 -0
- package/dist/domain/model/index.d.ts.map +1 -0
- package/dist/domain/model/index.js +2 -0
- package/dist/domain/model/index.js.map +1 -0
- package/dist/domain/model/types.d.ts +330 -0
- package/dist/domain/model/types.d.ts.map +1 -0
- package/dist/domain/model/types.js +8 -0
- package/dist/domain/model/types.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/infrastructure/index.d.ts +3 -0
- package/dist/infrastructure/index.d.ts.map +1 -0
- package/dist/infrastructure/index.js +3 -0
- package/dist/infrastructure/index.js.map +1 -0
- package/dist/infrastructure/storage/constants.d.ts +4 -0
- package/dist/infrastructure/storage/constants.d.ts.map +1 -0
- package/dist/infrastructure/storage/constants.js +4 -0
- package/dist/infrastructure/storage/constants.js.map +1 -0
- package/dist/infrastructure/storage/errors.d.ts +55 -0
- package/dist/infrastructure/storage/errors.d.ts.map +1 -0
- package/dist/infrastructure/storage/errors.js +58 -0
- package/dist/infrastructure/storage/errors.js.map +1 -0
- package/dist/infrastructure/storage/index.d.ts +23 -0
- package/dist/infrastructure/storage/index.d.ts.map +1 -0
- package/dist/infrastructure/storage/index.js +13 -0
- package/dist/infrastructure/storage/index.js.map +1 -0
- package/dist/infrastructure/storage/recovery/restoreRecovery.d.ts +64 -0
- package/dist/infrastructure/storage/recovery/restoreRecovery.d.ts.map +1 -0
- package/dist/infrastructure/storage/recovery/restoreRecovery.js +148 -0
- package/dist/infrastructure/storage/recovery/restoreRecovery.js.map +1 -0
- package/dist/infrastructure/storage/sqlite/schema.d.ts +49 -0
- package/dist/infrastructure/storage/sqlite/schema.d.ts.map +1 -0
- package/dist/infrastructure/storage/sqlite/schema.js +529 -0
- package/dist/infrastructure/storage/sqlite/schema.js.map +1 -0
- package/dist/infrastructure/storage/sqlite/schemaTypes.d.ts +5 -0
- package/dist/infrastructure/storage/sqlite/schemaTypes.d.ts.map +1 -0
- package/dist/infrastructure/storage/sqlite/schemaTypes.js +2 -0
- package/dist/infrastructure/storage/sqlite/schemaTypes.js.map +1 -0
- package/dist/infrastructure/storage/sqlite/sqlScript.d.ts +9 -0
- package/dist/infrastructure/storage/sqlite/sqlScript.d.ts.map +1 -0
- package/dist/infrastructure/storage/sqlite/sqlScript.js +122 -0
- package/dist/infrastructure/storage/sqlite/sqlScript.js.map +1 -0
- package/dist/infrastructure/storage/sqlite/sqlState.d.ts +6 -0
- package/dist/infrastructure/storage/sqlite/sqlState.d.ts.map +1 -0
- package/dist/infrastructure/storage/sqlite/sqlState.js +14 -0
- package/dist/infrastructure/storage/sqlite/sqlState.js.map +1 -0
- package/dist/infrastructure/storage/sqlite/sqlTransaction.d.ts +6 -0
- package/dist/infrastructure/storage/sqlite/sqlTransaction.d.ts.map +1 -0
- package/dist/infrastructure/storage/sqlite/sqlTransaction.js +24 -0
- package/dist/infrastructure/storage/sqlite/sqlTransaction.js.map +1 -0
- package/dist/infrastructure/storage/sqlite/sqliteBridge.d.ts +44 -0
- package/dist/infrastructure/storage/sqlite/sqliteBridge.d.ts.map +1 -0
- package/dist/infrastructure/storage/sqlite/sqliteBridge.js +66 -0
- package/dist/infrastructure/storage/sqlite/sqliteBridge.js.map +1 -0
- package/dist/infrastructure/storage/state/canonical/canonicalCommit.d.ts +101 -0
- package/dist/infrastructure/storage/state/canonical/canonicalCommit.d.ts.map +1 -0
- package/dist/infrastructure/storage/state/canonical/canonicalCommit.js +417 -0
- package/dist/infrastructure/storage/state/canonical/canonicalCommit.js.map +1 -0
- package/dist/infrastructure/storage/state/observation/observationAudit.d.ts +16 -0
- package/dist/infrastructure/storage/state/observation/observationAudit.d.ts.map +1 -0
- package/dist/infrastructure/storage/state/observation/observationAudit.js +85 -0
- package/dist/infrastructure/storage/state/observation/observationAudit.js.map +1 -0
- package/dist/infrastructure/storage/state/observation/observationCanonical.d.ts +31 -0
- package/dist/infrastructure/storage/state/observation/observationCanonical.d.ts.map +1 -0
- package/dist/infrastructure/storage/state/observation/observationCanonical.js +439 -0
- package/dist/infrastructure/storage/state/observation/observationCanonical.js.map +1 -0
- package/dist/infrastructure/storage/state/observation/observationConstants.d.ts +53 -0
- package/dist/infrastructure/storage/state/observation/observationConstants.d.ts.map +1 -0
- package/dist/infrastructure/storage/state/observation/observationConstants.js +41 -0
- package/dist/infrastructure/storage/state/observation/observationConstants.js.map +1 -0
- package/dist/infrastructure/storage/state/observation/observationLedger.d.ts +49 -0
- package/dist/infrastructure/storage/state/observation/observationLedger.d.ts.map +1 -0
- package/dist/infrastructure/storage/state/observation/observationLedger.js +537 -0
- package/dist/infrastructure/storage/state/observation/observationLedger.js.map +1 -0
- package/dist/infrastructure/storage/state/observation/observationQuarantine.d.ts +15 -0
- package/dist/infrastructure/storage/state/observation/observationQuarantine.d.ts.map +1 -0
- package/dist/infrastructure/storage/state/observation/observationQuarantine.js +100 -0
- package/dist/infrastructure/storage/state/observation/observationQuarantine.js.map +1 -0
- package/dist/infrastructure/storage/state/observation/observationTypes.d.ts +124 -0
- package/dist/infrastructure/storage/state/observation/observationTypes.d.ts.map +1 -0
- package/dist/infrastructure/storage/state/observation/observationTypes.js +13 -0
- package/dist/infrastructure/storage/state/observation/observationTypes.js.map +1 -0
- package/dist/infrastructure/storage/state/observation/observationValidation.d.ts +28 -0
- package/dist/infrastructure/storage/state/observation/observationValidation.d.ts.map +1 -0
- package/dist/infrastructure/storage/state/observation/observationValidation.js +223 -0
- package/dist/infrastructure/storage/state/observation/observationValidation.js.map +1 -0
- package/dist/infrastructure/storage/state/observation/observationWriter.d.ts +28 -0
- package/dist/infrastructure/storage/state/observation/observationWriter.d.ts.map +1 -0
- package/dist/infrastructure/storage/state/observation/observationWriter.js +293 -0
- package/dist/infrastructure/storage/state/observation/observationWriter.js.map +1 -0
- package/dist/infrastructure/storage/state/readonly/readOnlyObservation.d.ts +58 -0
- package/dist/infrastructure/storage/state/readonly/readOnlyObservation.d.ts.map +1 -0
- package/dist/infrastructure/storage/state/readonly/readOnlyObservation.js +195 -0
- package/dist/infrastructure/storage/state/readonly/readOnlyObservation.js.map +1 -0
- package/dist/infrastructure/storage/state/resolution/resolutionWriter.d.ts +31 -0
- package/dist/infrastructure/storage/state/resolution/resolutionWriter.d.ts.map +1 -0
- package/dist/infrastructure/storage/state/resolution/resolutionWriter.js +563 -0
- package/dist/infrastructure/storage/state/resolution/resolutionWriter.js.map +1 -0
- package/dist/infrastructure/storage/state/resolution/resolutionWriterContracts.d.ts +118 -0
- package/dist/infrastructure/storage/state/resolution/resolutionWriterContracts.d.ts.map +1 -0
- package/dist/infrastructure/storage/state/resolution/resolutionWriterContracts.js +18 -0
- package/dist/infrastructure/storage/state/resolution/resolutionWriterContracts.js.map +1 -0
- package/dist/infrastructure/storage/state/resolution/resolutionWriterHelpers.d.ts +23 -0
- package/dist/infrastructure/storage/state/resolution/resolutionWriterHelpers.d.ts.map +1 -0
- package/dist/infrastructure/storage/state/resolution/resolutionWriterHelpers.js +84 -0
- package/dist/infrastructure/storage/state/resolution/resolutionWriterHelpers.js.map +1 -0
- package/dist/infrastructure/storage/state/resolution/resolutionWriterSql.d.ts +16 -0
- package/dist/infrastructure/storage/state/resolution/resolutionWriterSql.d.ts.map +1 -0
- package/dist/infrastructure/storage/state/resolution/resolutionWriterSql.js +97 -0
- package/dist/infrastructure/storage/state/resolution/resolutionWriterSql.js.map +1 -0
- package/dist/infrastructure/storage/sync/outbound/effectOutbox.d.ts +137 -0
- package/dist/infrastructure/storage/sync/outbound/effectOutbox.d.ts.map +1 -0
- package/dist/infrastructure/storage/sync/outbound/effectOutbox.js +396 -0
- package/dist/infrastructure/storage/sync/outbound/effectOutbox.js.map +1 -0
- package/dist/infrastructure/storage/sync/outbound/effectOutboxContracts.d.ts +101 -0
- package/dist/infrastructure/storage/sync/outbound/effectOutboxContracts.d.ts.map +1 -0
- package/dist/infrastructure/storage/sync/outbound/effectOutboxContracts.js +9 -0
- package/dist/infrastructure/storage/sync/outbound/effectOutboxContracts.js.map +1 -0
- package/dist/infrastructure/storage/sync/outbound/effectOutboxSql.d.ts +21 -0
- package/dist/infrastructure/storage/sync/outbound/effectOutboxSql.d.ts.map +1 -0
- package/dist/infrastructure/storage/sync/outbound/effectOutboxSql.js +184 -0
- package/dist/infrastructure/storage/sync/outbound/effectOutboxSql.js.map +1 -0
- package/dist/infrastructure/storage/sync/outbound/effectOutboxSupport.d.ts +25 -0
- package/dist/infrastructure/storage/sync/outbound/effectOutboxSupport.d.ts.map +1 -0
- package/dist/infrastructure/storage/sync/outbound/effectOutboxSupport.js +158 -0
- package/dist/infrastructure/storage/sync/outbound/effectOutboxSupport.js.map +1 -0
- package/dist/infrastructure/storage/sync/shared/syncRegistry.d.ts +69 -0
- package/dist/infrastructure/storage/sync/shared/syncRegistry.d.ts.map +1 -0
- package/dist/infrastructure/storage/sync/shared/syncRegistry.js +272 -0
- package/dist/infrastructure/storage/sync/shared/syncRegistry.js.map +1 -0
- package/dist/infrastructure/storage/sync/shared/writerLease.d.ts +90 -0
- package/dist/infrastructure/storage/sync/shared/writerLease.d.ts.map +1 -0
- package/dist/infrastructure/storage/sync/shared/writerLease.js +282 -0
- package/dist/infrastructure/storage/sync/shared/writerLease.js.map +1 -0
- package/dist/shared/constants.d.ts +8 -0
- package/dist/shared/constants.d.ts.map +1 -0
- package/dist/shared/constants.js +8 -0
- package/dist/shared/constants.js.map +1 -0
- package/dist/shared/encoding/constants.d.ts +45 -0
- package/dist/shared/encoding/constants.d.ts.map +1 -0
- package/dist/shared/encoding/constants.js +37 -0
- package/dist/shared/encoding/constants.js.map +1 -0
- package/dist/shared/encoding/index.d.ts +6 -0
- package/dist/shared/encoding/index.d.ts.map +1 -0
- package/dist/shared/encoding/index.js +4 -0
- package/dist/shared/encoding/index.js.map +1 -0
- package/dist/shared/encoding/stableEncode.d.ts +34 -0
- package/dist/shared/encoding/stableEncode.d.ts.map +1 -0
- package/dist/shared/encoding/stableEncode.js +210 -0
- package/dist/shared/encoding/stableEncode.js.map +1 -0
- package/dist/shared/encoding/typeGuards.d.ts +15 -0
- package/dist/shared/encoding/typeGuards.d.ts.map +1 -0
- package/dist/shared/encoding/typeGuards.js +11 -0
- package/dist/shared/encoding/typeGuards.js.map +1 -0
- package/dist/shared/encoding/types.d.ts +52 -0
- package/dist/shared/encoding/types.d.ts.map +1 -0
- package/dist/shared/encoding/types.js +8 -0
- package/dist/shared/encoding/types.js.map +1 -0
- package/dist/shared/index.d.ts +6 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/index.js +6 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/shared/state/constants.d.ts +16 -0
- package/dist/shared/state/constants.d.ts.map +1 -0
- package/dist/shared/state/constants.js +16 -0
- package/dist/shared/state/constants.js.map +1 -0
- package/dist/shared/state/index.d.ts +3 -0
- package/dist/shared/state/index.d.ts.map +1 -0
- package/dist/shared/state/index.js +2 -0
- package/dist/shared/state/index.js.map +1 -0
- package/dist/shared/state/types.d.ts +23 -0
- package/dist/shared/state/types.d.ts.map +1 -0
- package/dist/shared/state/types.js +2 -0
- package/dist/shared/state/types.js.map +1 -0
- package/dist/shared/validation.d.ts +9 -0
- package/dist/shared/validation.d.ts.map +1 -0
- package/dist/shared/validation.js +25 -0
- package/dist/shared/validation.js.map +1 -0
- package/docs/architecture.md +72 -0
- package/docs/code-guidelines.md +256 -0
- package/docs/development.md +48 -0
- package/docs/git-workflow.md +224 -0
- package/docs/mikro-orm-adapter-spike.md +248 -0
- package/docs/quick-start.md +102 -0
- package/docs/sql-layer-plan.md +59 -0
- package/docs/sync-bulk-write-benchmark.md +1036 -0
- package/docs/sync-observability.md +71 -0
- package/docs/task-queue-write-model.md +640 -0
- package/docs/typed-sheets-mvp-scope-2026-06-29.md +490 -0
- package/docs/typed-sheets-plan.md +417 -0
- package/docs/write-and-synchronization-flow.md +71 -0
- package/package.json +68 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared contracts for pure batch evaluation.
|
|
3
|
+
*
|
|
4
|
+
* These types keep evaluator inputs and outcomes independent from SQLite,
|
|
5
|
+
* gateway transport, and any repository implementation.
|
|
6
|
+
*/
|
|
7
|
+
import type { NormalizedCell } from "../../shared/encoding/types.js";
|
|
8
|
+
import type { CanonicalResolution, OwnershipManifest, ObservedRowChange, Projection, QuarantinePlan, QuarantineReason, RepairPlan, RowBindingContext, RowOperation, SyncConflict } from "../model/types.js";
|
|
9
|
+
import { PRECONDITION_RESULTS } from "../model/constants.js";
|
|
10
|
+
import { QUARANTINE_REPAIR_STATUSES, ROW_OUTCOMES } from "./constants.js";
|
|
11
|
+
import type { QuarantineRepairNotPlannedReason, RowOutcome } from "./constants.js";
|
|
12
|
+
export type { RowOutcome } from "./constants.js";
|
|
13
|
+
/** Result shared by operation-specific precondition validators. */
|
|
14
|
+
export type PreconditionResult = {
|
|
15
|
+
readonly status: typeof PRECONDITION_RESULTS.VALID;
|
|
16
|
+
} | {
|
|
17
|
+
readonly status: typeof PRECONDITION_RESULTS.INVALID;
|
|
18
|
+
readonly reason: QuarantineReason;
|
|
19
|
+
};
|
|
20
|
+
/** Result that either promotes raw input to a typed row or explains rejection. */
|
|
21
|
+
export type StructuralPreconditionResult = {
|
|
22
|
+
readonly status: typeof PRECONDITION_RESULTS.VALID;
|
|
23
|
+
readonly row: ObservedRowChange;
|
|
24
|
+
} | {
|
|
25
|
+
readonly status: typeof PRECONDITION_RESULTS.INVALID;
|
|
26
|
+
readonly reason: QuarantineReason;
|
|
27
|
+
};
|
|
28
|
+
/** One accepted canonical field write produced by a row evaluation. */
|
|
29
|
+
export interface AcceptedField {
|
|
30
|
+
readonly fieldName: string;
|
|
31
|
+
readonly nextValue: NormalizedCell;
|
|
32
|
+
readonly nextFieldRevision: number;
|
|
33
|
+
}
|
|
34
|
+
/** A field-level stale-write conflict that requires explicit resolution. */
|
|
35
|
+
export interface FieldConflict {
|
|
36
|
+
readonly fieldName: string;
|
|
37
|
+
readonly userValue: NormalizedCell;
|
|
38
|
+
readonly userBaseRevision: number;
|
|
39
|
+
readonly canonicalValue: NormalizedCell;
|
|
40
|
+
readonly canonicalRevision: number;
|
|
41
|
+
}
|
|
42
|
+
/** A row result that applies one or more fields to canonical state. */
|
|
43
|
+
export interface AppliedRowEvaluationResult {
|
|
44
|
+
readonly rowBindingId: string;
|
|
45
|
+
readonly outcome: typeof ROW_OUTCOMES.ACCEPTED | typeof ROW_OUTCOMES.PARTIALLY_ACCEPTED;
|
|
46
|
+
readonly acceptedFields: readonly AcceptedField[];
|
|
47
|
+
readonly conflicts: readonly FieldConflict[];
|
|
48
|
+
readonly nextEntityRevision: number;
|
|
49
|
+
}
|
|
50
|
+
/** A row result that records conflicts without changing canonical state. */
|
|
51
|
+
export interface ConflictRowEvaluationResult {
|
|
52
|
+
readonly rowBindingId: string;
|
|
53
|
+
readonly outcome: typeof ROW_OUTCOMES.CONFLICT;
|
|
54
|
+
readonly acceptedFields: readonly [];
|
|
55
|
+
readonly conflicts: readonly FieldConflict[];
|
|
56
|
+
}
|
|
57
|
+
/** Explicit repair state for a quarantined row. */
|
|
58
|
+
export type QuarantineRepairDecision = {
|
|
59
|
+
readonly status: typeof QUARANTINE_REPAIR_STATUSES.NOT_PLANNED;
|
|
60
|
+
readonly reason: QuarantineRepairNotPlannedReason;
|
|
61
|
+
} | {
|
|
62
|
+
readonly status: typeof QUARANTINE_REPAIR_STATUSES.PLANNED;
|
|
63
|
+
readonly plan: RepairPlan;
|
|
64
|
+
};
|
|
65
|
+
/** A terminal row result that preserves evidence without canonical mutation. */
|
|
66
|
+
export interface QuarantineRowEvaluationResult {
|
|
67
|
+
readonly rowBindingId: string;
|
|
68
|
+
readonly outcome: typeof ROW_OUTCOMES.QUARANTINE;
|
|
69
|
+
readonly acceptedFields: readonly [];
|
|
70
|
+
readonly conflicts: readonly [];
|
|
71
|
+
readonly quarantine: QuarantinePlan;
|
|
72
|
+
readonly repair: QuarantineRepairDecision;
|
|
73
|
+
}
|
|
74
|
+
/** Full immutable decision for one row in an observation batch. */
|
|
75
|
+
export type RowEvaluationResult = AppliedRowEvaluationResult | ConflictRowEvaluationResult | QuarantineRowEvaluationResult;
|
|
76
|
+
/** Aggregate classification for a row-independent observation batch. */
|
|
77
|
+
export type BatchOutcome = RowOutcome;
|
|
78
|
+
/** Result returned by the pure batch evaluator. */
|
|
79
|
+
export interface BatchEvaluationResult {
|
|
80
|
+
readonly batchId: string;
|
|
81
|
+
readonly rowResults: readonly RowEvaluationResult[];
|
|
82
|
+
readonly overallOutcome: BatchOutcome;
|
|
83
|
+
}
|
|
84
|
+
/** Canonical and active-candidate context supplied by the storage boundary. */
|
|
85
|
+
export interface EvaluationContext {
|
|
86
|
+
readonly manifest: OwnershipManifest;
|
|
87
|
+
readonly canonicalByBindingId: ReadonlyMap<string, CanonicalResolution>;
|
|
88
|
+
readonly bindingByBindingId: ReadonlyMap<string, RowBindingContext>;
|
|
89
|
+
readonly activeConflictsByBindingAndField: ReadonlyMap<string, ReadonlyMap<string, SyncConflict>>;
|
|
90
|
+
/** Active unique keys by manifest field and stable normalized-cell hash. */
|
|
91
|
+
readonly businessKeyEntityIdsByField: ReadonlyMap<string, ReadonlyMap<string, string>>;
|
|
92
|
+
readonly schemaVersion: number;
|
|
93
|
+
}
|
|
94
|
+
/** Common field identity material that distinguishes ABA and revision attempts. */
|
|
95
|
+
interface EventKeyFieldBase {
|
|
96
|
+
readonly fieldName: string;
|
|
97
|
+
readonly candidateEpoch: number;
|
|
98
|
+
readonly beforeHash: string;
|
|
99
|
+
readonly afterHash: string;
|
|
100
|
+
readonly nextValue: NormalizedCell;
|
|
101
|
+
}
|
|
102
|
+
/** Identity material for an inserted field without a prior revision. */
|
|
103
|
+
export interface InsertEventKeyField extends EventKeyFieldBase {
|
|
104
|
+
readonly baseFieldRevision?: never;
|
|
105
|
+
}
|
|
106
|
+
/** Identity material for a versioned field with a required prior revision. */
|
|
107
|
+
export interface VersionedEventKeyField extends EventKeyFieldBase {
|
|
108
|
+
readonly baseFieldRevision: number;
|
|
109
|
+
}
|
|
110
|
+
/** Field identity material whose shape is determined by row state. */
|
|
111
|
+
export type EventKeyField = InsertEventKeyField | VersionedEventKeyField;
|
|
112
|
+
/** Normalized row-change material used to compute a source-independent event key. */
|
|
113
|
+
export interface EventKeyInput {
|
|
114
|
+
readonly schemaVersion: number;
|
|
115
|
+
readonly sheetId: string;
|
|
116
|
+
readonly projection: Projection;
|
|
117
|
+
readonly rowBindingId: string;
|
|
118
|
+
readonly baseVisibleRevision: number;
|
|
119
|
+
readonly baseSnapshotHash: string;
|
|
120
|
+
readonly operation: RowOperation;
|
|
121
|
+
readonly beforeRowHash: string;
|
|
122
|
+
readonly afterRowHash: string;
|
|
123
|
+
readonly changedFields: readonly EventKeyField[];
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=contracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../../src/domain/evaluate/contracts.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,KAAK,EACV,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,UAAU,EACV,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,0BAA0B,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,KAAK,EACV,gCAAgC,EAChC,UAAU,EACX,MAAM,gBAAgB,CAAC;AAExB,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,mEAAmE;AACnE,MAAM,MAAM,kBAAkB,GAC1B;IAAE,QAAQ,CAAC,MAAM,EAAE,OAAO,oBAAoB,CAAC,KAAK,CAAA;CAAE,GACtD;IACE,QAAQ,CAAC,MAAM,EAAE,OAAO,oBAAoB,CAAC,OAAO,CAAC;IACrD,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;CACnC,CAAC;AAEN,kFAAkF;AAClF,MAAM,MAAM,4BAA4B,GACpC;IACE,QAAQ,CAAC,MAAM,EAAE,OAAO,oBAAoB,CAAC,KAAK,CAAC;IACnD,QAAQ,CAAC,GAAG,EAAE,iBAAiB,CAAC;CACjC,GACD;IACE,QAAQ,CAAC,MAAM,EAAE,OAAO,oBAAoB,CAAC,OAAO,CAAC;IACrD,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC;CACnC,CAAC;AAEN,uEAAuE;AACvE,MAAM,WAAW,aAAa;IAC5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@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure row-independent observation evaluator.
|
|
3
|
+
*
|
|
4
|
+
* It composes the precondition, ownership, quarantine, and field-CAS modules
|
|
5
|
+
* without performing I/O or mutating canonical state.
|
|
6
|
+
*/
|
|
7
|
+
import type { ObservedEditBatch } from "../model/types.js";
|
|
8
|
+
import type { BatchEvaluationResult, EvaluationContext } from "./contracts.js";
|
|
9
|
+
/** Evaluates each normalized row independently against the supplied canonical context. */
|
|
10
|
+
export declare function evaluateBatch(batch: ObservedEditBatch, context: EvaluationContext): BatchEvaluationResult;
|
|
11
|
+
//# sourceMappingURL=evaluateBatch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluateBatch.d.ts","sourceRoot":"","sources":["../../../src/domain/evaluate/evaluateBatch.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAGV,iBAAiB,EAGlB,MAAM,mBAAmB,CAAC;AAW3B,OAAO,KAAK,EACV,qBAAqB,EAErB,iBAAiB,EAElB,MAAM,gBAAgB,CAAC;AAYxB,0FAA0F;AAC1F,wBAAgB,aAAa,CAC3B,KAAK,EAAE,iBAAiB,EACxB,OAAO,EAAE,iBAAiB,GACzB,qBAAqB,CAevB"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure row-independent observation evaluator.
|
|
3
|
+
*
|
|
4
|
+
* It composes the precondition, ownership, quarantine, and field-CAS modules
|
|
5
|
+
* without performing I/O or mutating canonical state.
|
|
6
|
+
*/
|
|
7
|
+
import { EVALUATION_ERROR_CODES, EvaluationContractError, } from "../errors/index.js";
|
|
8
|
+
import { CANONICAL_RESOLUTION_STATUSES, PRECONDITION_RESULTS, QUARANTINE_REASONS, ROW_OPERATIONS, } from "../model/constants.js";
|
|
9
|
+
import { ROW_OUTCOMES } from "./constants.js";
|
|
10
|
+
import { acceptedDelete, evaluateUserFields } from "./fieldEvaluation.js";
|
|
11
|
+
import { inspectOwnership, validateBindingState, validateManifestFields, validateOperationPreconditions, validateStructuralPreconditions, } from "./preconditions.js";
|
|
12
|
+
import { quarantineRow, quarantineSystemRow } from "./quarantine.js";
|
|
13
|
+
/** Evaluates each normalized row independently against the supplied canonical context. */
|
|
14
|
+
export function evaluateBatch(batch, context) {
|
|
15
|
+
if (batch.schemaVersion !== context.schemaVersion) {
|
|
16
|
+
return {
|
|
17
|
+
batchId: batch.batchId,
|
|
18
|
+
rowResults: batch.rows.map((row) => quarantineRow(row, QUARANTINE_REASONS.SCHEMA_DRIFT)),
|
|
19
|
+
overallOutcome: ROW_OUTCOMES.QUARANTINE,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const rowResults = batch.rows.map((row) => evaluateRow(row, context));
|
|
23
|
+
return {
|
|
24
|
+
batchId: batch.batchId,
|
|
25
|
+
rowResults,
|
|
26
|
+
overallOutcome: summarizeBatch(rowResults),
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function evaluateRow(row, context) {
|
|
30
|
+
const structuralResult = validateStructuralPreconditions(row);
|
|
31
|
+
if (structuralResult.status === PRECONDITION_RESULTS.INVALID) {
|
|
32
|
+
return quarantineRow(row, structuralResult.reason);
|
|
33
|
+
}
|
|
34
|
+
const normalizedRow = structuralResult.row;
|
|
35
|
+
const binding = context.bindingByBindingId.get(normalizedRow.rowBindingId);
|
|
36
|
+
if (binding === undefined) {
|
|
37
|
+
return quarantineRow(normalizedRow, QUARANTINE_REASONS.AMBIGUOUS_IDENTITY);
|
|
38
|
+
}
|
|
39
|
+
const bindingResult = validateBindingState(normalizedRow.operation, binding);
|
|
40
|
+
if (bindingResult.status === PRECONDITION_RESULTS.INVALID) {
|
|
41
|
+
return quarantineRow(normalizedRow, bindingResult.reason);
|
|
42
|
+
}
|
|
43
|
+
const canonical = resolveCanonical(normalizedRow.rowBindingId, binding, context);
|
|
44
|
+
if (hasEntityBinding(binding) && canonical.status === CANONICAL_RESOLUTION_STATUSES.MISSING) {
|
|
45
|
+
return quarantineRow(normalizedRow, QUARANTINE_REASONS.AMBIGUOUS_IDENTITY);
|
|
46
|
+
}
|
|
47
|
+
const manifestResult = validateManifestFields(normalizedRow.fields, context.manifest);
|
|
48
|
+
if (manifestResult.status === PRECONDITION_RESULTS.INVALID) {
|
|
49
|
+
return quarantineRow(normalizedRow, manifestResult.reason);
|
|
50
|
+
}
|
|
51
|
+
const operationResult = validateOperationPreconditions(normalizedRow, binding, canonical, context);
|
|
52
|
+
if (operationResult.status === PRECONDITION_RESULTS.INVALID) {
|
|
53
|
+
return quarantineRow(normalizedRow, operationResult.reason);
|
|
54
|
+
}
|
|
55
|
+
const ownership = inspectOwnership(normalizedRow.fields, context.manifest);
|
|
56
|
+
if (ownership.hasSystemField) {
|
|
57
|
+
return quarantineSystemRow(normalizedRow, canonical, ownership);
|
|
58
|
+
}
|
|
59
|
+
return normalizedRow.operation === ROW_OPERATIONS.DELETE
|
|
60
|
+
? acceptedDelete(normalizedRow, requireCanonical(canonical))
|
|
61
|
+
: evaluateUserFields(normalizedRow, canonical, context);
|
|
62
|
+
}
|
|
63
|
+
function summarizeBatch(results) {
|
|
64
|
+
if (results.some((result) => result.outcome === ROW_OUTCOMES.QUARANTINE)) {
|
|
65
|
+
return ROW_OUTCOMES.QUARANTINE;
|
|
66
|
+
}
|
|
67
|
+
if (results.some((result) => result.outcome === ROW_OUTCOMES.CONFLICT)) {
|
|
68
|
+
return ROW_OUTCOMES.CONFLICT;
|
|
69
|
+
}
|
|
70
|
+
return results.some((result) => result.outcome === ROW_OUTCOMES.PARTIALLY_ACCEPTED)
|
|
71
|
+
? ROW_OUTCOMES.PARTIALLY_ACCEPTED
|
|
72
|
+
: ROW_OUTCOMES.ACCEPTED;
|
|
73
|
+
}
|
|
74
|
+
function resolveCanonical(rowBindingId, binding, context) {
|
|
75
|
+
if (!hasEntityBinding(binding)) {
|
|
76
|
+
return { status: CANONICAL_RESOLUTION_STATUSES.MISSING };
|
|
77
|
+
}
|
|
78
|
+
return context.canonicalByBindingId.get(rowBindingId) ?? {
|
|
79
|
+
status: CANONICAL_RESOLUTION_STATUSES.MISSING,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function hasEntityBinding(binding) {
|
|
83
|
+
return "entityId" in binding;
|
|
84
|
+
}
|
|
85
|
+
function requireCanonical(canonical) {
|
|
86
|
+
if (canonical.status === CANONICAL_RESOLUTION_STATUSES.MISSING) {
|
|
87
|
+
throw new EvaluationContractError(EVALUATION_ERROR_CODES.CANONICAL_STATE_REQUIRED, "delete evaluation requires canonical state");
|
|
88
|
+
}
|
|
89
|
+
return canonical.entity;
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=evaluateBatch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluateBatch.js","sourceRoot":"","sources":["../../../src/domain/evaluate/evaluateBatch.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH,OAAO,EACL,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,6BAA6B,EAC7B,oBAAoB,EACpB,kBAAkB,EAClB,cAAc,GACf,MAAM,uBAAuB,CAAC;AAO/B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,EACtB,8BAA8B,EAC9B,+BAA+B,GAChC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAErE,0FAA0F;AAC1F,MAAM,UAAU,aAAa,CAC3B,KAAwB,EACxB,OAA0B;IAE1B,IAAI,KAAK,CAAC,aAAa,KAAK,OAAO,CAAC,aAAa,EAAE,CAAC;QAClD,OAAO;YACL,OAAO,EAAE,KAAK,CA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
|
|
|
1
|
+
/**
|
|
2
|
+
* Field-level canonical compare-and-set evaluation.
|
|
3
|
+
*
|
|
4
|
+
* This module never mutates canonical state. It classifies each user-owned
|
|
5
|
+
* field as accepted or conflicting so the storage writer can commit one
|
|
6
|
+
* row-independent decision atomically later.
|
|
7
|
+
*/
|
|
8
|
+
import type { CanonicalEntityState, CanonicalResolution, ObservedDeleteRowChange, ObservedRowChange } from "../model/types.js";
|
|
9
|
+
import type { AppliedRowEvaluationResult, EvaluationContext, RowEvaluationResult } from "./contracts.js";
|
|
10
|
+
/** Evaluates all user-owned fields after structural/ownership checks passed. */
|
|
11
|
+
export declare function evaluateUserFields(row: ObservedRowChange, canonical: CanonicalResolution, context: EvaluationContext): RowEvaluationResult;
|
|
12
|
+
/** Produces an accepted tombstone without treating delete fields as updates. */
|
|
13
|
+
export declare function acceptedDelete(row: ObservedDeleteRowChange, canonical: CanonicalEntityState): AppliedRowEvaluationResult;
|
|
14
|
+
//# sourceMappingURL=fieldEvaluation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fieldEvaluation.d.ts","sourceRoot":"","sources":["../../../src/domain/evaluate/fieldEvaluation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAWH,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACnB,uBAAuB,EAEvB,iBAAiB,EAElB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAEV,0BAA0B,EAE1B,iBAAiB,EAEjB,mBAAmB,EACpB,MAAM,gBAAgB,CAAC;AAGxB,gFAAgF;AAChF,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,iBAAiB,EACtB,SAAS,EAAE,mBAAmB,EAC9B,OAAO,EAAE,iBAAiB,GACzB,mBAAmB,CAkCrB;AAED,gFAAgF;AAChF,wBAAgB,cAAc,CAC5B,GAAG,EAAE,uBAAuB,EAC5B,SAAS,EAAE,oBAAoB,GAC9B,0BAA0B,CAQ5B"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Field-level canonical compare-and-set evaluation.
|
|
3
|
+
*
|
|
4
|
+
* This module never mutates canonical state. It classifies each user-owned
|
|
5
|
+
* field as accepted or conflicting so the storage writer can commit one
|
|
6
|
+
* row-independent decision atomically later.
|
|
7
|
+
*/
|
|
8
|
+
import { CANONICAL_RESOLUTION_STATUSES, CONFLICT_STATUSES, ROW_OPERATIONS, } from "../model/constants.js";
|
|
9
|
+
import { EVALUATION_ERROR_CODES, EvaluationContractError, } from "../errors/index.js";
|
|
10
|
+
import { ROW_OUTCOMES } from "./constants.js";
|
|
11
|
+
/** Evaluates all user-owned fields after structural/ownership checks passed. */
|
|
12
|
+
export function evaluateUserFields(row, canonical, context) {
|
|
13
|
+
const accepted = [];
|
|
14
|
+
const conflicts = [];
|
|
15
|
+
const canonicalEntity = canonical.status === CANONICAL_RESOLUTION_STATUSES.AVAILABLE
|
|
16
|
+
? canonical.entity
|
|
17
|
+
: undefined;
|
|
18
|
+
for (const fieldChange of row.fields) {
|
|
19
|
+
const result = evaluateSingleUserField(fieldChange, canonicalEntity, row, context);
|
|
20
|
+
if (result.kind === ROW_OUTCOMES.ACCEPTED) {
|
|
21
|
+
accepted.push(result.field);
|
|
22
|
+
}
|
|
23
|
+
else
|
|
24
|
+
conflicts.push(result.conflict);
|
|
25
|
+
}
|
|
26
|
+
const outcome = classifyFieldOutcome(accepted, conflicts);
|
|
27
|
+
if (outcome === ROW_OUTCOMES.CONFLICT) {
|
|
28
|
+
const conflictResult = {
|
|
29
|
+
rowBindingId: row.rowBindingId,
|
|
30
|
+
outcome,
|
|
31
|
+
acceptedFields: [],
|
|
32
|
+
conflicts,
|
|
33
|
+
};
|
|
34
|
+
return conflictResult;
|
|
35
|
+
}
|
|
36
|
+
const appliedResult = {
|
|
37
|
+
rowBindingId: row.rowBindingId,
|
|
38
|
+
outcome,
|
|
39
|
+
acceptedFields: accepted,
|
|
40
|
+
conflicts,
|
|
41
|
+
nextEntityRevision: nextEntityRevisionFor(row, canonicalEntity),
|
|
42
|
+
};
|
|
43
|
+
return appliedResult;
|
|
44
|
+
}
|
|
45
|
+
/** Produces an accepted tombstone without treating delete fields as updates. */
|
|
46
|
+
export function acceptedDelete(row, canonical) {
|
|
47
|
+
return {
|
|
48
|
+
rowBindingId: row.rowBindingId,
|
|
49
|
+
outcome: ROW_OUTCOMES.ACCEPTED,
|
|
50
|
+
acceptedFields: [],
|
|
51
|
+
conflicts: [],
|
|
52
|
+
nextEntityRevision: canonical.entityRevision + 1,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function evaluateSingleUserField(fieldChange, canonical, row, context) {
|
|
56
|
+
if (row.operation === ROW_OPERATIONS.INSERT) {
|
|
57
|
+
return {
|
|
58
|
+
kind: ROW_OUTCOMES.ACCEPTED,
|
|
59
|
+
field: {
|
|
60
|
+
fieldName: fieldChange.fieldName,
|
|
61
|
+
nextValue: fieldChange.nextValue,
|
|
62
|
+
nextFieldRevision: 1,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const existingFieldChange = requireVersionedFieldChange(fieldChange);
|
|
67
|
+
const existingCanonical = requireCanonicalEntity(canonical);
|
|
68
|
+
if (hasActiveConflict(context, row.rowBindingId, fieldChange.fieldName)) {
|
|
69
|
+
return conflictResult(existingFieldChange, existingCanonical);
|
|
70
|
+
}
|
|
71
|
+
const currentField = existingCanonical.fields.get(fieldChange.fieldName);
|
|
72
|
+
if (currentField === undefined ||
|
|
73
|
+
existingFieldChange.baseFieldRevision !== currentField.fieldRevision) {
|
|
74
|
+
return conflictResult(existingFieldChange, existingCanonical);
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
kind: ROW_OUTCOMES.ACCEPTED,
|
|
78
|
+
field: {
|
|
79
|
+
fieldName: fieldChange.fieldName,
|
|
80
|
+
nextValue: fieldChange.nextValue,
|
|
81
|
+
nextFieldRevision: currentField.fieldRevision + 1,
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function classifyFieldOutcome(accepted, conflicts) {
|
|
86
|
+
if (conflicts.length === 0)
|
|
87
|
+
return ROW_OUTCOMES.ACCEPTED;
|
|
88
|
+
return accepted.length > 0
|
|
89
|
+
? ROW_OUTCOMES.PARTIALLY_ACCEPTED
|
|
90
|
+
: ROW_OUTCOMES.CONFLICT;
|
|
91
|
+
}
|
|
92
|
+
function conflictResult(fieldChange, canonical) {
|
|
93
|
+
const currentField = canonical.fields.get(fieldChange.fieldName);
|
|
94
|
+
if (currentField === undefined) {
|
|
95
|
+
throw new EvaluationContractError(EVALUATION_ERROR_CODES.CANONICAL_FIELD_REQUIRED, `existing row evaluation requires canonical field ${fieldChange.fieldName}`);
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
kind: ROW_OUTCOMES.CONFLICT,
|
|
99
|
+
conflict: {
|
|
100
|
+
fieldName: fieldChange.fieldName,
|
|
101
|
+
userValue: fieldChange.nextValue,
|
|
102
|
+
userBaseRevision: fieldChange.baseFieldRevision,
|
|
103
|
+
canonicalValue: currentField.value,
|
|
104
|
+
canonicalRevision: currentField.fieldRevision,
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function hasActiveConflict(context, rowBindingId, fieldName) {
|
|
109
|
+
const conflict = context.activeConflictsByBindingAndField.get(rowBindingId)?.get(fieldName);
|
|
110
|
+
return conflict?.status === CONFLICT_STATUSES.OPEN ||
|
|
111
|
+
conflict?.status === CONFLICT_STATUSES.NEEDS_REBASE;
|
|
112
|
+
}
|
|
113
|
+
function nextEntityRevisionFor(row, canonical) {
|
|
114
|
+
if (row.operation === ROW_OPERATIONS.INSERT)
|
|
115
|
+
return 1;
|
|
116
|
+
return requireCanonicalEntity(canonical).entityRevision + 1;
|
|
117
|
+
}
|
|
118
|
+
function requireCanonicalEntity(canonical) {
|
|
119
|
+
if (canonical === undefined) {
|
|
120
|
+
throw new EvaluationContractError(EVALUATION_ERROR_CODES.CANONICAL_STATE_REQUIRED, "existing row evaluation requires canonical state");
|
|
121
|
+
}
|
|
122
|
+
return canonical;
|
|
123
|
+
}
|
|
124
|
+
function requireVersionedFieldChange(fieldChange) {
|
|
125
|
+
if (!isVersionedFieldChange(fieldChange)) {
|
|
126
|
+
throw new EvaluationContractError(EVALUATION_ERROR_CODES.BASE_FIELD_REVISION_REQUIRED, "existing row evaluation requires a base field revision");
|
|
127
|
+
}
|
|
128
|
+
return fieldChange;
|
|
129
|
+
}
|
|
130
|
+
function isVersionedFieldChange(fieldChange) {
|
|
131
|
+
return fieldChange.baseFieldRevision !== undefined;
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=fieldEvaluation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fieldEvaluation.js","sourceRoot":"","sources":["../../../src/domain/evaluate/fieldEvaluation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,6BAA6B,EAC7B,iBAAiB,EACjB,cAAc,GACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,oBAAoB,CAAC;AAiB5B,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,gFAAgF;AAChF,MAAM,UAAU,kBAAkB,CAChC,GAAsB,EACtB,SAA8B,EAC9B,OAA0B;IAE1B,MAAM,QAAQ,GAAoB,EAAE,CAAC;IACrC,MAAM,SAAS,GAAoB,EAAE,CAAC;IACtC,MAAM,eAAe,GAAG,SAAS,CAAC,MAAM,KAAK,6BAA6B,CAAC,SAAS;QAClF,CAAC,CAAC,SAAS,CAAC,MAAM;QAClB,CAAC,CAAC,SAAS,CAAC;IAEd,KAAK,MAAM,WAAW,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;QACrC,MAAM,MAAM,GAAG,uBAAuB,CAAC,WAAW,EAAE,eAAe,EAAE,GAAG,EAAE,OAAO,CAA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gC;IAEhC,IAAI,CAAC,sBAAsB,CAAC,WAAW,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,uBAAuB,CAC/B,sBAAsB,CAAC,4BAA4B,EACnD,wDAAwD,CACzD,CAAC;IACJ,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,SAAS,sBAAsB,CAC7B,WAAgC;IAEhC,OAAO,WAAW,CAAC,iBAAiB,KAAK,SAAS,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic identity helpers for observed rows, events, and repairs.
|
|
3
|
+
*
|
|
4
|
+
* Storage records the resulting values but does not choose their contents;
|
|
5
|
+
* identical normalized input must always produce the same identity.
|
|
6
|
+
*/
|
|
7
|
+
import type { NormalizedCell } from "../../shared/encoding/types.js";
|
|
8
|
+
import type { EventKeyInput } from "./contracts.js";
|
|
9
|
+
/**
|
|
10
|
+
* Computes the source-independent event key for a normalized row change.
|
|
11
|
+
*
|
|
12
|
+
* @throws {DuplicateChangedFieldError} when the event lists one field twice.
|
|
13
|
+
*/
|
|
14
|
+
export declare function computeEventKey(input: EventKeyInput): string;
|
|
15
|
+
/** Computes a stable hash for a normalized row's field values. */
|
|
16
|
+
export declare function computeRowHash(rowBindingId: string, fields: ReadonlyMap<string, {
|
|
17
|
+
readonly cell: NormalizedCell;
|
|
18
|
+
}>): string;
|
|
19
|
+
/** Computes the visible-state guard used by a system-field repair effect. */
|
|
20
|
+
export declare function computeRepairGuardHash(rowBindingId: string, illegalFields: ReadonlyArray<readonly [string, NormalizedCell]>): string;
|
|
21
|
+
//# sourceMappingURL=identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../../src/domain/evaluate/identity.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAe,MAAM,gCAAgC,CAAC;AAGlF,OAAO,KAAK,EAAiB,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEnE;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CAoB5D;AAgBD,kEAAkE;AAClE,wBAAgB,cAAc,CAC5B,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAA;CAAE,CAAC,GAC7D,MAAM,CAMR;AAED,6EAA6E;AAC7E,wBAAgB,sBAAsB,CACpC,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,GAC9D,MAAM,CAKR"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic identity helpers for observed rows, events, and repairs.
|
|
3
|
+
*
|
|
4
|
+
* Storage records the resulting values but does not choose their contents;
|
|
5
|
+
* identical normalized input must always produce the same identity.
|
|
6
|
+
*/
|
|
7
|
+
import { stableHash } from "../../shared/encoding/stableEncode.js";
|
|
8
|
+
import { DuplicateChangedFieldError } from "../errors/identity.js";
|
|
9
|
+
/**
|
|
10
|
+
* Computes the source-independent event key for a normalized row change.
|
|
11
|
+
*
|
|
12
|
+
* @throws {DuplicateChangedFieldError} when the event lists one field twice.
|
|
13
|
+
*/
|
|
14
|
+
export function computeEventKey(input) {
|
|
15
|
+
const changedFields = sortByFieldName(input.changedFields, (field) => field.fieldName);
|
|
16
|
+
for (let index = 1; index < changedFields.length; index += 1) {
|
|
17
|
+
if (changedFields[index - 1].fieldName === changedFields[index].fieldName) {
|
|
18
|
+
throw new DuplicateChangedFieldError(changedFields[index].fieldName);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return stableHash({
|
|
22
|
+
schemaVersion: input.schemaVersion,
|
|
23
|
+
sheetId: input.sheetId,
|
|
24
|
+
projection: input.projection,
|
|
25
|
+
rowBindingId: input.rowBindingId,
|
|
26
|
+
baseVisibleRevision: input.baseVisibleRevision,
|
|
27
|
+
baseSnapshotHash: input.baseSnapshotHash,
|
|
28
|
+
operation: input.operation,
|
|
29
|
+
beforeRowHash: input.beforeRowHash,
|
|
30
|
+
afterRowHash: input.afterRowHash,
|
|
31
|
+
changedFields: changedFields.map(makeEventKeyFieldIdentity),
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
/** Omits the absent revision marker so event identity has no undefined state. */
|
|
35
|
+
function makeEventKeyFieldIdentity(field) {
|
|
36
|
+
const base = {
|
|
37
|
+
fieldName: field.fieldName,
|
|
38
|
+
candidateEpoch: field.candidateEpoch,
|
|
39
|
+
beforeHash: field.beforeHash,
|
|
40
|
+
afterHash: field.afterHash,
|
|
41
|
+
nextValue: field.nextValue,
|
|
42
|
+
};
|
|
43
|
+
return field.baseFieldRevision === undefined
|
|
44
|
+
? base
|
|
45
|
+
: { ...base, baseFieldRevision: field.baseFieldRevision };
|
|
46
|
+
}
|
|
47
|
+
/** Computes a stable hash for a normalized row's field values. */
|
|
48
|
+
export function computeRowHash(rowBindingId, fields) {
|
|
49
|
+
const entries = sortByFieldName([...fields.entries()], ([fieldName]) => fieldName);
|
|
50
|
+
return stableHash({
|
|
51
|
+
rowBindingId,
|
|
52
|
+
fields: entries.map(([name, field]) => [name, field.cell]),
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/** Computes the visible-state guard used by a system-field repair effect. */
|
|
56
|
+
export function computeRepairGuardHash(rowBindingId, illegalFields) {
|
|
57
|
+
return stableHash({
|
|
58
|
+
rowBindingId,
|
|
59
|
+
illegalFields: sortByFieldName(illegalFields, ([fieldName]) => fieldName),
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Returns a field-name-ordered copy so identity hashes ignore input order.
|
|
64
|
+
* The caller's array is never mutated because observations may be reused.
|
|
65
|
+
*/
|
|
66
|
+
function sortByFieldName(values, getFieldName) {
|
|
67
|
+
return [...values].sort((left, right) => compareText(getFieldName(left), getFieldName(right)));
|
|
68
|
+
}
|
|
69
|
+
function compareText(left, right) {
|
|
70
|
+
return left < right ? -1 : left > right ? 1 : 0;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../../src/domain/evaluate/identity.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAGnE;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,KAAoB;IAClD,MAAM,aAAa,GAAG,eAAe,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACvF,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,aAAa,CAAC,MAAM,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;QAC7D,IAAI,aAAa,CAAC,KAAK,GAAG,CAAC,CAAE,CAAC,SAAS,KAAK,aAAa,CAAC,KAAK,CAAE,CAAC,SAAS,EAAE,CAAC;YAC5E,MAAM,IAAI,0BAA0B,CAAC,aAAa,CAAC,KAAK,CAAE,CAAC,SAAS,CAAC,CAAC;QACxE,CAAC;IACH,CAAC;IAED,OAAO,UAAU,CAAC;QAChB,aAAa,EAAE,KAAK,CAAC,aAAa;QAClC,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,mBAAmB,EAAE,KAAK,CAAC,mBAAmB;QAC9C,gBAAgB,EAAE,KAAK,CAAC,gBAAgB;QACxC,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,aAAa,EAAE,KAAK,CAAC,aAAa;QAClC,YAAY,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tB,MAAoB,EACpB,YAAkC;IAElC,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CACtC,WAAW,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC,KAAK,CAAC,CAAC,CACrD,CAAC;AACJ,CAAC;AAED,SAAS,WAAW,CAAC,IAAY,EAAE,KAAa;IAC9C,OAAO,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClD,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { evaluateBatch, } from "./evaluateBatch.js";
|
|
2
|
+
export { computeEventKey, computeRowHash, computeRepairGuardHash, } from "./identity.js";
|
|
3
|
+
export type { BatchEvaluationResult, RowEvaluationResult, RowOutcome, BatchOutcome, AcceptedField, FieldConflict, EvaluationContext, EventKeyField, } from "./contracts.js";
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/domain/evaluate/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,GACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,eAAe,EACf,cAAc,EACd,sBAAsB,GACvB,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,qBAAqB,EACrB,mBAAmB,EACnB,UAAU,EACV,YAAY,EACZ,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,aAAa,GACd,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/domain/evaluate/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,GACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,eAAe,EACf,cAAc,EACd,sBAAsB,GACvB,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fail-closed validation before field-level conflict evaluation.
|
|
3
|
+
*
|
|
4
|
+
* These checks reject ambiguous identity, invalid normalized values, schema
|
|
5
|
+
* drift, and unsupported operation shapes before any canonical field CAS is
|
|
6
|
+
* considered.
|
|
7
|
+
*/
|
|
8
|
+
import type { NormalizedCell } from "../../shared/encoding/types.js";
|
|
9
|
+
import type { CanonicalResolution, ObservedFieldChange, ObservedRowChange, OwnershipManifest, RowOperation, RowBindingContext } from "../model/types.js";
|
|
10
|
+
import type { EvaluationContext, PreconditionResult, StructuralPreconditionResult } from "./contracts.js";
|
|
11
|
+
/** Summary of editable and system-owned fields in one observed row. */
|
|
12
|
+
export interface OwnershipCheckResult {
|
|
13
|
+
readonly hasSystemField: boolean;
|
|
14
|
+
readonly hasUserField: boolean;
|
|
15
|
+
readonly systemFields: readonly {
|
|
16
|
+
fieldName: string;
|
|
17
|
+
value: NormalizedCell;
|
|
18
|
+
}[];
|
|
19
|
+
}
|
|
20
|
+
/** Validates raw input and promotes it to an operation-specific row type. */
|
|
21
|
+
export declare function validateStructuralPreconditions(input: unknown): StructuralPreconditionResult;
|
|
22
|
+
/** Checks whether the operation is legal for the row binding's current state. */
|
|
23
|
+
export declare function validateBindingState(operation: RowOperation, binding: RowBindingContext): PreconditionResult;
|
|
24
|
+
/** Rejects a row that references a field absent from the ownership manifest. */
|
|
25
|
+
export declare function validateManifestFields(fields: readonly ObservedFieldChange[], manifest: OwnershipManifest): PreconditionResult;
|
|
26
|
+
/** Applies operation-specific evidence, required-field, and unique-key checks. */
|
|
27
|
+
export declare function validateOperationPreconditions(row: ObservedRowChange, binding: RowBindingContext, canonical: CanonicalResolution, context: EvaluationContext): PreconditionResult;
|
|
28
|
+
/** Separates illegal system fields from user-owned fields without resolving them. */
|
|
29
|
+
export declare function inspectOwnership(fields: readonly ObservedFieldChange[], manifest: OwnershipManifest): OwnershipCheckResult;
|
|
30
|
+
//# sourceMappingURL=preconditions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preconditions.d.ts","sourceRoot":"","sources":["../../../src/domain/evaluate/preconditions.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAgBrE,OAAO,KAAK,EACV,mBAAmB,EAEnB,mBAAmB,EASnB,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,iBAAiB,EAClB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EACV,iBAAiB,EACjB,kBAAkB,EAClB,4BAA4B,EAC7B,MAAM,gBAAgB,CAAC;AAExB,uEAAuE;AACvE,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC;IACjC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,YAAY,EAAE,SAAS;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,cAAc,CAAA;KAAE,EAAE,CAAC;CAChF;AAED,6EAA6E;AAC7E,wBAAgB,+BAA+B,CAC7C,KAAK,EAAE,OAAO,GACb,4BAA4B,CAsC9B;AAED,iFAAiF;AACjF,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,YAAY,EACvB,OAAO,EAAE,iBAAiB,GACzB,kBAAkB,CAepB;AAED,gFAAgF;AAChF,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,SAAS,mBAAmB,EAAE,EACtC,QAAQ,EAAE,iBAAiB,GAC1B,kBAAkB,CAIpB;AAED,kFAAkF;AAClF,wBAAgB,8BAA8B,CAC5C,GAAG,EAAE,iBAAiB,EACtB,OAAO,EAAE,iBAAiB,EAC1B,SAAS,EAAE,mBAAmB,EAC9B,OAAO,EAAE,iBAAiB,GACzB,kBAAkB,CA4BpB;AAED,qFA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