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,396 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Effect outbox claim, apply, and recovery operations.
|
|
3
|
+
*
|
|
4
|
+
* Per design concurrency/writer-rpc.md and storage-schema.md:
|
|
5
|
+
* - Effects are claimed atomically (CAS on status = 'pending').
|
|
6
|
+
* - Only one worker can claim an effect at a time.
|
|
7
|
+
* - Apply results must pass fencing validation (epoch + token).
|
|
8
|
+
* - Supersede/replan atomically closes old effect and inserts new one.
|
|
9
|
+
*/
|
|
10
|
+
import { STORAGE_ERROR_CODES, StorageError } from "../../errors.js";
|
|
11
|
+
import { withSqlSavepoint } from "../../sqlite/sqlTransaction.js";
|
|
12
|
+
import { isFencingValid, isFencingValidWithSql, } from "../shared/writerLease.js";
|
|
13
|
+
import { toSqlNullable } from "../../sqlite/sqlState.js";
|
|
14
|
+
import { APPLY_EFFECT_RESULT_SQL, CLAIM_EFFECT_SQL, COUNT_PENDING_OR_PROCESSING_EFFECTS_SQL, INSERT_PENDING_EFFECT_SQL, INSERT_REPLANNED_EFFECT_SQL, RECOVER_EXPIRED_LEASES_SQL, REQUEUE_CLAIMED_EFFECT_SQL, RELEASE_UNPROCESSED_EFFECT_SQL, SELECT_PENDING_EFFECTS_BY_TARGET_SQL, SELECT_READY_EFFECTS_SQL, SUPERSEDE_EFFECT_SQL, } from "./effectOutboxSql.js";
|
|
15
|
+
import { applyEffectResultParameters, AsyncFenceLostError, claimEffectParameters, fenceParameters, pendingEffectParameters, replannedEffectParameters, requireCurrentFence, requireCurrentFenceWithSql, validateApplyResultOptions, validateEffectLeaseDuration, validateReadyEffectLimit, writeProjectionConfirmation, writeProjectionConfirmationWithSql, } from "./effectOutboxSupport.js";
|
|
16
|
+
export { SYNC_EFFECT_RECOVERY_ERROR_CODES } from "./effectOutboxContracts.js";
|
|
17
|
+
export function claimEffect(db, options) {
|
|
18
|
+
if (!isFencingValid(db, options)) {
|
|
19
|
+
return {
|
|
20
|
+
effectId: options.effectId,
|
|
21
|
+
claimToken: options.claimToken,
|
|
22
|
+
success: false,
|
|
23
|
+
reason: "stale_fencing",
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
validateEffectLeaseDuration(options.leaseDurationMs);
|
|
27
|
+
const result = db
|
|
28
|
+
.prepare(CLAIM_EFFECT_SQL)
|
|
29
|
+
.run(options.claimToken, options.writerEpoch, options.now + options.leaseDurationMs, options.effectId, ...fenceParameters(options));
|
|
30
|
+
const success = result.changes > 0;
|
|
31
|
+
return {
|
|
32
|
+
effectId: options.effectId,
|
|
33
|
+
claimToken: options.claimToken,
|
|
34
|
+
success,
|
|
35
|
+
reason: success
|
|
36
|
+
? "claimed"
|
|
37
|
+
: isFencingValid(db, options) ? "not_claimable" : "stale_fencing",
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Claims a pending effect through an already-active async SQL context.
|
|
42
|
+
*
|
|
43
|
+
* The compare-and-set query and both fencing checks use the same connection,
|
|
44
|
+
* so a MikroORM-backed worker cannot accidentally claim through a second
|
|
45
|
+
* SQLite connection.
|
|
46
|
+
*/
|
|
47
|
+
export async function claimEffectWithSql(sql, options) {
|
|
48
|
+
if (!(await isFencingValidWithSql(sql, options))) {
|
|
49
|
+
return {
|
|
50
|
+
effectId: options.effectId,
|
|
51
|
+
claimToken: options.claimToken,
|
|
52
|
+
success: false,
|
|
53
|
+
reason: "stale_fencing",
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
validateEffectLeaseDuration(options.leaseDurationMs);
|
|
57
|
+
const result = await sql.run(CLAIM_EFFECT_SQL, claimEffectParameters(options));
|
|
58
|
+
const success = result.changes > 0;
|
|
59
|
+
return {
|
|
60
|
+
effectId: options.effectId,
|
|
61
|
+
claimToken: options.claimToken,
|
|
62
|
+
success,
|
|
63
|
+
reason: success
|
|
64
|
+
? "claimed"
|
|
65
|
+
: await isFencingValidWithSql(sql, options) ? "not_claimable" : "stale_fencing",
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/** Claims one effect inside an adapter-owned transaction. */
|
|
69
|
+
export async function claimEffectWithAdapter(storage, options) {
|
|
70
|
+
return storage.transaction(({ sql }) => claimEffectWithSql(sql, options));
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Appends pending effects under the supplied writer fence.
|
|
74
|
+
*
|
|
75
|
+
* This is used for conflict/quarantine effects that do not accompany a
|
|
76
|
+
* canonical field commit. It owns a savepoint so a duplicate dedupe key or a
|
|
77
|
+
* lost fence cannot leave only part of an effect set behind.
|
|
78
|
+
*/
|
|
79
|
+
export function appendPendingEffects(db, fence, effects) {
|
|
80
|
+
if (effects.length === 0)
|
|
81
|
+
return isFencingValid(db, fence);
|
|
82
|
+
if (!isFencingValid(db, fence))
|
|
83
|
+
return false;
|
|
84
|
+
db.exec("SAVEPOINT append_pending_effects");
|
|
85
|
+
try {
|
|
86
|
+
for (const effect of effects) {
|
|
87
|
+
const result = db.prepare(INSERT_PENDING_EFFECT_SQL).run(effect.effectId, effect.effectKind, effect.commitId, effect.logicalSheetId, effect.physicalSheetId, effect.projection, toSqlNullable(effect.rowBindingId), toSqlNullable(effect.conflictId), effect.targetKind, effect.targetId, toSqlNullable(effect.targetEntityRevision), toSqlNullable(effect.targetFieldRevisionHash), toSqlNullable(effect.targetCanonicalCommitId), effect.expectedVisibleRevision, effect.expectedVisibleHash, toSqlNullable(effect.repairGuardHash), toSqlNullable(effect.sourceQuarantineId), effect.payloadJson, effect.payloadHash, effect.effectDedupeKey, effect.streamSequence, fence.now, ...fenceParameters(fence));
|
|
88
|
+
if (result.changes !== 1) {
|
|
89
|
+
if (!isFencingValid(db, fence)) {
|
|
90
|
+
db.exec("ROLLBACK TO append_pending_effects");
|
|
91
|
+
db.exec("RELEASE append_pending_effects");
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
throw new StorageError(STORAGE_ERROR_CODES.EFFECT_WRITE_FAILED, `could not insert effect ${effect.effectId}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
db.exec("RELEASE append_pending_effects");
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
db.exec("ROLLBACK TO append_pending_effects");
|
|
102
|
+
db.exec("RELEASE append_pending_effects");
|
|
103
|
+
throw error;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Appends pending effects inside an already-active async SQL transaction.
|
|
108
|
+
*
|
|
109
|
+
* This is the MikroORM-compatible path used when an entity mutation and its
|
|
110
|
+
* Sheets outbox records must commit or roll back together.
|
|
111
|
+
*/
|
|
112
|
+
export async function appendPendingEffectsWithSql(sql, fence, effects) {
|
|
113
|
+
if (effects.length === 0)
|
|
114
|
+
return isFencingValidWithSql(sql, fence);
|
|
115
|
+
if (!(await isFencingValidWithSql(sql, fence)))
|
|
116
|
+
return false;
|
|
117
|
+
try {
|
|
118
|
+
return await withSqlSavepoint(sql, "append_pending_effects", async () => {
|
|
119
|
+
for (const effect of effects) {
|
|
120
|
+
const result = await sql.run(INSERT_PENDING_EFFECT_SQL, pendingEffectParameters(effect, fence));
|
|
121
|
+
if (result.changes === 1)
|
|
122
|
+
continue;
|
|
123
|
+
if (!(await isFencingValidWithSql(sql, fence))) {
|
|
124
|
+
throw new AsyncFenceLostError();
|
|
125
|
+
}
|
|
126
|
+
throw new StorageError(STORAGE_ERROR_CODES.EFFECT_WRITE_FAILED, `could not insert effect ${effect.effectId}`);
|
|
127
|
+
}
|
|
128
|
+
return true;
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
if (error instanceof AsyncFenceLostError)
|
|
133
|
+
return false;
|
|
134
|
+
throw error;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
/** Appends pending effects in one adapter-owned transaction. */
|
|
138
|
+
export async function appendPendingEffectsWithAdapter(storage, fence, effects) {
|
|
139
|
+
return storage.transaction(({ sql }) => appendPendingEffectsWithSql(sql, fence, effects));
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Applies a result to a claimed effect.
|
|
143
|
+
* Validates fencing (claim token + writer epoch) before applying.
|
|
144
|
+
* Returns true if the result was applied, false if fencing failed.
|
|
145
|
+
*/
|
|
146
|
+
export function applyEffectResult(db, options) {
|
|
147
|
+
if (!isFencingValid(db, options)) {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
validateApplyResultOptions(options);
|
|
151
|
+
db.exec("SAVEPOINT apply_effect_result");
|
|
152
|
+
try {
|
|
153
|
+
const result = db
|
|
154
|
+
.prepare(APPLY_EFFECT_RESULT_SQL)
|
|
155
|
+
.run(options.status, toSqlNullable(options.lastErrorCode), toSqlNullable(options.lastErrorMessage), options.effectId, options.claimToken, options.writerEpoch, options.now, ...fenceParameters(options));
|
|
156
|
+
if (result.changes !== 1) {
|
|
157
|
+
db.exec("ROLLBACK TO apply_effect_result");
|
|
158
|
+
db.exec("RELEASE apply_effect_result");
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
if (options.projectionConfirmation !== undefined) {
|
|
162
|
+
writeProjectionConfirmation(db, options.projectionConfirmation);
|
|
163
|
+
}
|
|
164
|
+
db.exec("RELEASE apply_effect_result");
|
|
165
|
+
return true;
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
try {
|
|
169
|
+
db.exec("ROLLBACK TO apply_effect_result");
|
|
170
|
+
db.exec("RELEASE apply_effect_result");
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
// Preserve the storage error that caused the result write to fail.
|
|
174
|
+
}
|
|
175
|
+
throw error;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Applies a claimed effect result through an already-active async SQL context.
|
|
180
|
+
*
|
|
181
|
+
* If projection confirmation fails, the savepoint rolls the effect transition
|
|
182
|
+
* back too; confirmed visible state can never advance without its outbox row.
|
|
183
|
+
*/
|
|
184
|
+
export async function applyEffectResultWithSql(sql, options) {
|
|
185
|
+
if (!(await isFencingValidWithSql(sql, options)))
|
|
186
|
+
return false;
|
|
187
|
+
validateApplyResultOptions(options);
|
|
188
|
+
return withSqlSavepoint(sql, "apply_effect_result", async () => {
|
|
189
|
+
const result = await sql.run(APPLY_EFFECT_RESULT_SQL, applyEffectResultParameters(options));
|
|
190
|
+
if (result.changes !== 1)
|
|
191
|
+
return false;
|
|
192
|
+
if (options.projectionConfirmation !== undefined) {
|
|
193
|
+
await writeProjectionConfirmationWithSql(sql, options.projectionConfirmation);
|
|
194
|
+
}
|
|
195
|
+
return true;
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
/** Applies one effect result inside an adapter-owned transaction. */
|
|
199
|
+
export async function applyEffectResultWithAdapter(storage, options) {
|
|
200
|
+
return storage.transaction(({ sql }) => applyEffectResultWithSql(sql, options));
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Supersedes an old effect and inserts a new replacement effect atomically.
|
|
204
|
+
* Used for repair replan when the canonical target has advanced.
|
|
205
|
+
*
|
|
206
|
+
* Per design: the old effect is marked 'superseded', a new effect with a new
|
|
207
|
+
* effect_id and new dedupe_key is inserted, and the new effect's
|
|
208
|
+
* predecessor_effect_id links to the old one.
|
|
209
|
+
*/
|
|
210
|
+
export function supersedeAndReplan(db, fence, oldEffectId, newEffect) {
|
|
211
|
+
requireCurrentFence(db, fence);
|
|
212
|
+
db.exec("SAVEPOINT replan");
|
|
213
|
+
try {
|
|
214
|
+
const superseded = db.prepare(SUPERSEDE_EFFECT_SQL)
|
|
215
|
+
.run(newEffect.effectId, oldEffectId, ...fenceParameters(fence));
|
|
216
|
+
if (superseded.changes !== 1) {
|
|
217
|
+
requireCurrentFence(db, fence);
|
|
218
|
+
throw new StorageError(STORAGE_ERROR_CODES.EFFECT_REPLAN_CONFLICT, `effect ${oldEffectId} cannot be replanned from its current status`);
|
|
219
|
+
}
|
|
220
|
+
const inserted = db.prepare(INSERT_REPLANNED_EFFECT_SQL).run(newEffect.effectId, newEffect.effectKind, newEffect.commitId, newEffect.logicalSheetId, newEffect.physicalSheetId, newEffect.projection, toSqlNullable(newEffect.rowBindingId), toSqlNullable(newEffect.conflictId), newEffect.targetKind, newEffect.targetId, toSqlNullable(newEffect.targetEntityRevision), toSqlNullable(newEffect.targetFieldRevisionHash), toSqlNullable(newEffect.targetCanonicalCommitId), newEffect.expectedVisibleRevision, newEffect.expectedVisibleHash, toSqlNullable(newEffect.repairGuardHash), toSqlNullable(newEffect.sourceQuarantineId), newEffect.payloadJson, newEffect.payloadHash, newEffect.effectDedupeKey, newEffect.streamSequence, oldEffectId, fence.now, ...fenceParameters(fence));
|
|
221
|
+
if (inserted.changes !== 1) {
|
|
222
|
+
requireCurrentFence(db, fence);
|
|
223
|
+
throw new StorageError(STORAGE_ERROR_CODES.EFFECT_WRITE_FAILED, `effect ${newEffect.effectId} could not be inserted during replan`);
|
|
224
|
+
}
|
|
225
|
+
db.exec("RELEASE replan");
|
|
226
|
+
}
|
|
227
|
+
catch (error) {
|
|
228
|
+
db.exec("ROLLBACK TO replan");
|
|
229
|
+
db.exec("RELEASE replan");
|
|
230
|
+
throw error;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
/** Supersedes and replans an effect through an already-active async SQL context. */
|
|
234
|
+
export async function supersedeAndReplanWithSql(sql, fence, oldEffectId, newEffect) {
|
|
235
|
+
await requireCurrentFenceWithSql(sql, fence);
|
|
236
|
+
await withSqlSavepoint(sql, "replan", async () => {
|
|
237
|
+
const superseded = await sql.run(SUPERSEDE_EFFECT_SQL, [
|
|
238
|
+
newEffect.effectId,
|
|
239
|
+
oldEffectId,
|
|
240
|
+
...fenceParameters(fence),
|
|
241
|
+
]);
|
|
242
|
+
if (superseded.changes !== 1) {
|
|
243
|
+
await requireCurrentFenceWithSql(sql, fence);
|
|
244
|
+
throw new StorageError(STORAGE_ERROR_CODES.EFFECT_REPLAN_CONFLICT, `effect ${oldEffectId} cannot be replanned from its current status`);
|
|
245
|
+
}
|
|
246
|
+
const inserted = await sql.run(INSERT_REPLANNED_EFFECT_SQL, replannedEffectParameters(newEffect, oldEffectId, fence));
|
|
247
|
+
if (inserted.changes !== 1) {
|
|
248
|
+
await requireCurrentFenceWithSql(sql, fence);
|
|
249
|
+
throw new StorageError(STORAGE_ERROR_CODES.EFFECT_WRITE_FAILED, `effect ${newEffect.effectId} could not be inserted during replan`);
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
/** Supersedes and replans an effect inside an adapter-owned transaction. */
|
|
254
|
+
export async function supersedeAndReplanWithAdapter(storage, fence, oldEffectId, newEffect) {
|
|
255
|
+
await storage.transaction(({ sql }) => supersedeAndReplanWithSql(sql, fence, oldEffectId, newEffect));
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Marks expired processing effects as requiring postcondition recovery.
|
|
259
|
+
*
|
|
260
|
+
* The worker must read the remote postcondition before it schedules a retry;
|
|
261
|
+
* an expired lease is not evidence that the remote write did not happen.
|
|
262
|
+
*/
|
|
263
|
+
export function recoverExpiredLeases(db, fence) {
|
|
264
|
+
requireCurrentFence(db, fence);
|
|
265
|
+
const result = db
|
|
266
|
+
.prepare(RECOVER_EXPIRED_LEASES_SQL)
|
|
267
|
+
.run(fence.now, ...fenceParameters(fence));
|
|
268
|
+
return result.changes;
|
|
269
|
+
}
|
|
270
|
+
/** Marks expired effect leases through an already-active async SQL context. */
|
|
271
|
+
export async function recoverExpiredLeasesWithSql(sql, fence) {
|
|
272
|
+
await requireCurrentFenceWithSql(sql, fence);
|
|
273
|
+
const result = await sql.run(RECOVER_EXPIRED_LEASES_SQL, [
|
|
274
|
+
fence.now,
|
|
275
|
+
...fenceParameters(fence),
|
|
276
|
+
]);
|
|
277
|
+
return result.changes;
|
|
278
|
+
}
|
|
279
|
+
/** Marks expired effect leases inside an adapter-owned transaction. */
|
|
280
|
+
export async function recoverExpiredLeasesWithAdapter(storage, fence) {
|
|
281
|
+
return storage.transaction(({ sql }) => recoverExpiredLeasesWithSql(sql, fence));
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Returns an acknowledged-but-unprocessed batch suffix to pending.
|
|
285
|
+
*
|
|
286
|
+
* This is intentionally narrower than a generic redrive: it may be used only
|
|
287
|
+
* after a valid gateway response explicitly says the batch budget stopped
|
|
288
|
+
* before this effect. Unknown response loss remains failed until read-back.
|
|
289
|
+
*/
|
|
290
|
+
export function releaseUnprocessedEffect(db, options) {
|
|
291
|
+
if (!isFencingValid(db, options))
|
|
292
|
+
return false;
|
|
293
|
+
const result = db.prepare(RELEASE_UNPROCESSED_EFFECT_SQL).run(options.effectId, options.claimToken, options.writerEpoch, options.now, ...fenceParameters(options));
|
|
294
|
+
return result.changes === 1;
|
|
295
|
+
}
|
|
296
|
+
/** Returns one acknowledged-but-unprocessed effect through an async SQL context. */
|
|
297
|
+
export async function releaseUnprocessedEffectWithSql(sql, options) {
|
|
298
|
+
if (!(await isFencingValidWithSql(sql, options)))
|
|
299
|
+
return false;
|
|
300
|
+
const result = await sql.run(RELEASE_UNPROCESSED_EFFECT_SQL, [
|
|
301
|
+
options.effectId,
|
|
302
|
+
options.claimToken,
|
|
303
|
+
options.writerEpoch,
|
|
304
|
+
options.now,
|
|
305
|
+
...fenceParameters(options),
|
|
306
|
+
]);
|
|
307
|
+
return result.changes === 1;
|
|
308
|
+
}
|
|
309
|
+
/** Returns one acknowledged-but-unprocessed effect inside an adapter transaction. */
|
|
310
|
+
export async function releaseUnprocessedEffectWithAdapter(storage, options) {
|
|
311
|
+
return storage.transaction(({ sql }) => releaseUnprocessedEffectWithSql(sql, options));
|
|
312
|
+
}
|
|
313
|
+
/** Input for returning a claimed effect to the redrive queue after read-back. */
|
|
314
|
+
/** Requeues a claimed effect only after the current fence still owns it. */
|
|
315
|
+
export function retryClaimedEffect(db, options) {
|
|
316
|
+
if (!isFencingValid(db, options))
|
|
317
|
+
return false;
|
|
318
|
+
const result = db.prepare(REQUEUE_CLAIMED_EFFECT_SQL).run(options.lastErrorCode, options.lastErrorMessage, options.effectId, options.claimToken, options.writerEpoch, options.now, ...fenceParameters(options));
|
|
319
|
+
return result.changes === 1;
|
|
320
|
+
}
|
|
321
|
+
/** Requeues a claimed effect through an already-active async SQL context. */
|
|
322
|
+
export async function retryClaimedEffectWithSql(sql, options) {
|
|
323
|
+
if (!(await isFencingValidWithSql(sql, options)))
|
|
324
|
+
return false;
|
|
325
|
+
const result = await sql.run(REQUEUE_CLAIMED_EFFECT_SQL, [
|
|
326
|
+
options.lastErrorCode,
|
|
327
|
+
options.lastErrorMessage,
|
|
328
|
+
options.effectId,
|
|
329
|
+
options.claimToken,
|
|
330
|
+
options.writerEpoch,
|
|
331
|
+
options.now,
|
|
332
|
+
...fenceParameters(options),
|
|
333
|
+
]);
|
|
334
|
+
return result.changes === 1;
|
|
335
|
+
}
|
|
336
|
+
/** Requeues a claimed effect inside an adapter-owned transaction. */
|
|
337
|
+
export async function retryClaimedEffectWithAdapter(storage, options) {
|
|
338
|
+
return storage.transaction(({ sql }) => retryClaimedEffectWithSql(sql, options));
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Finds pending effects for a given stream (target), ordered by stream_sequence.
|
|
342
|
+
* Returns the head-of-line effects for a target stream.
|
|
343
|
+
*/
|
|
344
|
+
export function findPendingEffectsByTarget(db, logicalSheetId, targetKind, targetId) {
|
|
345
|
+
return db
|
|
346
|
+
.prepare(SELECT_PENDING_EFFECTS_BY_TARGET_SQL)
|
|
347
|
+
.all(logicalSheetId, targetKind, targetId);
|
|
348
|
+
}
|
|
349
|
+
/** Reads one target stream through an already-active async SQL context. */
|
|
350
|
+
export async function findPendingEffectsByTargetWithSql(sql, logicalSheetId, targetKind, targetId) {
|
|
351
|
+
return sql.all(SELECT_PENDING_EFFECTS_BY_TARGET_SQL, [
|
|
352
|
+
logicalSheetId,
|
|
353
|
+
targetKind,
|
|
354
|
+
targetId,
|
|
355
|
+
]);
|
|
356
|
+
}
|
|
357
|
+
/** Reads one target stream through a fresh adapter read context. */
|
|
358
|
+
export async function findPendingEffectsByTargetWithAdapter(storage, logicalSheetId, targetKind, targetId) {
|
|
359
|
+
return storage.read(({ sql }) => {
|
|
360
|
+
return findPendingEffectsByTargetWithSql(sql, logicalSheetId, targetKind, targetId);
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Returns ordered head-of-line effects across streams for one bounded worker pass.
|
|
365
|
+
*
|
|
366
|
+
* Claiming still performs the authoritative CAS, so a concurrent worker can
|
|
367
|
+
* safely race this advisory selection without processing a later stream item.
|
|
368
|
+
*/
|
|
369
|
+
export function listReadyEffects(db, limit) {
|
|
370
|
+
validateReadyEffectLimit(limit);
|
|
371
|
+
return db.prepare(SELECT_READY_EFFECTS_SQL).all(limit);
|
|
372
|
+
}
|
|
373
|
+
/** Reads bounded head-of-line effects through an already-active async SQL context. */
|
|
374
|
+
export async function listReadyEffectsWithSql(sql, limit) {
|
|
375
|
+
validateReadyEffectLimit(limit);
|
|
376
|
+
return sql.all(SELECT_READY_EFFECTS_SQL, [limit]);
|
|
377
|
+
}
|
|
378
|
+
/** Reads bounded head-of-line effects through a fresh adapter read context. */
|
|
379
|
+
export async function listReadyEffectsWithAdapter(storage, limit) {
|
|
380
|
+
return storage.read(({ sql }) => listReadyEffectsWithSql(sql, limit));
|
|
381
|
+
}
|
|
382
|
+
/** Returns whether normal outbox work is still pending or actively processing. */
|
|
383
|
+
export function hasPendingOrProcessingEffects(db) {
|
|
384
|
+
const row = db.prepare(COUNT_PENDING_OR_PROCESSING_EFFECTS_SQL).get();
|
|
385
|
+
return row !== undefined && row.count > 0;
|
|
386
|
+
}
|
|
387
|
+
/** Checks whether the durable outbox still has pending or processing work. */
|
|
388
|
+
export async function hasPendingOrProcessingEffectsWithSql(sql) {
|
|
389
|
+
const row = await sql.get(COUNT_PENDING_OR_PROCESSING_EFFECTS_SQL);
|
|
390
|
+
return row !== undefined && row.count > 0;
|
|
391
|
+
}
|
|
392
|
+
/** Checks outbox activity through a fresh adapter read context. */
|
|
393
|
+
export async function hasPendingOrProcessingEffectsWithAdapter(storage) {
|
|
394
|
+
return storage.read(({ sql }) => hasPendingOrProcessingEffectsWithSql(sql));
|
|
395
|
+
}
|
|
396
|
+
//# sourceMappingURL=effectOutbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effectOutbox.js","sourceRoot":"","sources":["../../../../../src/infrastructure/storage/sync/outbound/effectOutbox.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EACL,cAAc,EACd,qBAAqB,GACtB,MAAM,0BAA0B,CAAC;AA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E1B,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,oCAAoC,CAAC,GAAG,CAAC,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/** Public contracts for durable effect outbox rows and transitions. */
|
|
2
|
+
import type { Applicability, EffectKind, EffectTargetKind, Presence } from "../../../../domain/index.js";
|
|
3
|
+
import type { FencingContext } from "../shared/writerLease.js";
|
|
4
|
+
export declare const SYNC_EFFECT_RECOVERY_ERROR_CODES: {
|
|
5
|
+
readonly LEASE_EXPIRED_REQUIRES_POSTCONDITION: "lease_expired_requires_postcondition";
|
|
6
|
+
readonly GATEWAY_RETRYABLE_ERROR: "gateway_retryable_error";
|
|
7
|
+
readonly POSTCONDITION_READ_FAILED: "postcondition_read_failed";
|
|
8
|
+
readonly POSTCONDITION_UNAVAILABLE: "postcondition_unavailable";
|
|
9
|
+
readonly POSTCONDITION_UNAPPLIED_REQUIRES_REDRIVE: "postcondition_unapplied_requires_redrive";
|
|
10
|
+
};
|
|
11
|
+
export interface ClaimResult {
|
|
12
|
+
readonly effectId: string;
|
|
13
|
+
readonly claimToken: string;
|
|
14
|
+
readonly success: boolean;
|
|
15
|
+
readonly reason: "claimed" | "stale_fencing" | "not_claimable";
|
|
16
|
+
}
|
|
17
|
+
/** Input required to claim an effect with the current worker fence. */
|
|
18
|
+
export interface ClaimEffectOptions extends FencingContext {
|
|
19
|
+
readonly effectId: string;
|
|
20
|
+
readonly claimToken: string;
|
|
21
|
+
readonly leaseDurationMs: number;
|
|
22
|
+
}
|
|
23
|
+
export interface ApplyResultOptions extends FencingContext {
|
|
24
|
+
readonly effectId: string;
|
|
25
|
+
readonly claimToken: string;
|
|
26
|
+
readonly status: "applied" | "blocked_candidate" | "superseded" | "conflict" | "failed";
|
|
27
|
+
readonly lastErrorCode: Presence<string>;
|
|
28
|
+
readonly lastErrorMessage: Presence<string>;
|
|
29
|
+
/**
|
|
30
|
+
* Gateway read-back evidence that advances confirmed projection state in the
|
|
31
|
+
* same savepoint as an applied outbox result. It is intentionally optional
|
|
32
|
+
* for legacy callers that do not materialize a projection row.
|
|
33
|
+
*/
|
|
34
|
+
readonly projectionConfirmation?: EffectProjectionConfirmation;
|
|
35
|
+
}
|
|
36
|
+
/** Confirmed projection state returned only after a gateway postcondition read. */
|
|
37
|
+
export interface EffectProjectionConfirmation {
|
|
38
|
+
readonly physicalSheetId: string;
|
|
39
|
+
readonly projection: string;
|
|
40
|
+
readonly rowBindingId: string;
|
|
41
|
+
readonly visibleRevision: number;
|
|
42
|
+
readonly visibleHash: string;
|
|
43
|
+
readonly entityRevision: Applicability<number>;
|
|
44
|
+
readonly fieldHashes: Readonly<Record<string, string>>;
|
|
45
|
+
}
|
|
46
|
+
/** A pending outbox row prepared by the writer transaction. */
|
|
47
|
+
export interface NewEffect {
|
|
48
|
+
readonly effectId: string;
|
|
49
|
+
readonly effectKind: EffectKind;
|
|
50
|
+
readonly commitId: string;
|
|
51
|
+
readonly logicalSheetId: string;
|
|
52
|
+
readonly physicalSheetId: string;
|
|
53
|
+
readonly projection: string;
|
|
54
|
+
readonly rowBindingId: Presence<string>;
|
|
55
|
+
readonly conflictId: Presence<string>;
|
|
56
|
+
readonly targetKind: EffectTargetKind;
|
|
57
|
+
readonly targetId: string;
|
|
58
|
+
readonly targetEntityRevision: Applicability<number>;
|
|
59
|
+
readonly targetFieldRevisionHash: Applicability<string>;
|
|
60
|
+
readonly targetCanonicalCommitId: Applicability<string>;
|
|
61
|
+
readonly expectedVisibleRevision: number;
|
|
62
|
+
readonly expectedVisibleHash: string;
|
|
63
|
+
readonly repairGuardHash: Presence<string>;
|
|
64
|
+
readonly sourceQuarantineId: Presence<string>;
|
|
65
|
+
readonly payloadJson: string;
|
|
66
|
+
readonly payloadHash: string;
|
|
67
|
+
readonly effectDedupeKey: string;
|
|
68
|
+
readonly streamSequence: number;
|
|
69
|
+
}
|
|
70
|
+
export interface RetryClaimedEffectOptions extends Pick<FencingContext, "role" | "writerEpoch" | "fencingToken" | "now"> {
|
|
71
|
+
readonly effectId: string;
|
|
72
|
+
readonly claimToken: string;
|
|
73
|
+
readonly lastErrorCode: string;
|
|
74
|
+
readonly lastErrorMessage: string;
|
|
75
|
+
}
|
|
76
|
+
export interface PendingEffect {
|
|
77
|
+
readonly effect_id: string;
|
|
78
|
+
readonly effect_kind: string;
|
|
79
|
+
readonly commit_id: string;
|
|
80
|
+
readonly logical_sheet_id: string;
|
|
81
|
+
readonly physical_sheet_id: string;
|
|
82
|
+
readonly projection: string;
|
|
83
|
+
readonly row_binding_id: string | null;
|
|
84
|
+
readonly conflict_id: string | null;
|
|
85
|
+
readonly target_kind: string;
|
|
86
|
+
readonly target_id: string;
|
|
87
|
+
readonly target_entity_revision: number | null;
|
|
88
|
+
readonly target_field_revision_hash: string | null;
|
|
89
|
+
readonly target_canonical_commit_id: string | null;
|
|
90
|
+
readonly expected_visible_revision: number;
|
|
91
|
+
readonly expected_visible_hash: string;
|
|
92
|
+
readonly repair_guard_hash: string | null;
|
|
93
|
+
readonly source_quarantine_id: string | null;
|
|
94
|
+
readonly payload_json: string;
|
|
95
|
+
readonly payload_hash: string;
|
|
96
|
+
readonly effect_dedupe_key: string;
|
|
97
|
+
readonly stream_sequence: number;
|
|
98
|
+
readonly created_at: number;
|
|
99
|
+
readonly status: string;
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=effectOutboxContracts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effectOutboxContracts.d.ts","sourceRoot":"","sources":["../../../../../src/infrastructure/storage/sync/outbound/effectOutboxContracts.ts"],"names":[],"mappings":"AAAA,uEAAuE;AAEvE,OAAO,KAAK,EACV,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,QAAQ,EACT,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE/D,eAAO,M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AC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Public contracts for durable effect outbox rows and transitions. */
|
|
2
|
+
export const SYNC_EFFECT_RECOVERY_ERROR_CODES = {
|
|
3
|
+
LEASE_EXPIRED_REQUIRES_POSTCONDITION: "lease_expired_requires_postcondition",
|
|
4
|
+
GATEWAY_RETRYABLE_ERROR: "gateway_retryable_error",
|
|
5
|
+
POSTCONDITION_READ_FAILED: "postcondition_read_failed",
|
|
6
|
+
POSTCONDITION_UNAVAILABLE: "postcondition_unavailable",
|
|
7
|
+
POSTCONDITION_UNAPPLIED_REQUIRES_REDRIVE: "postcondition_unapplied_requires_redrive",
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=effectOutboxContracts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effectOutboxContracts.js","sourceRoot":"","sources":["../../../../../src/infrastructure/storage/sync/outbound/effectOutboxContracts.ts"],"names":[],"mappings":"AAAA,uEAAuE;AAUvE,MAAM,CAAC,MAAM,gCAAgC,GAAG;IAC9C,oCAAoC,EAAE,sCAAsC;IAC5E,uBAAuB,EAAE,yBAAyB;IAClD,yBAAyB,EAAE,2BAA2B;IACtD,yBAAyB,EAAE,2BAA2B;IACtD,wCAAwC,EAAE,0CAA0C;CAC5E,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** SQL statements used by the effect outbox state machine. */
|
|
2
|
+
export declare const RECOVERABLE_EFFECT_ERROR_CODE_SQL: string;
|
|
3
|
+
export declare const FENCE_EXISTS_SQL = "\n SELECT 1 FROM writer_lease\n WHERE role = ? AND writer_epoch = ? AND fencing_token = ? AND lease_until > ?\n";
|
|
4
|
+
export declare const CLAIM_EFFECT_SQL = "\n UPDATE sheet_effect_outbox AS candidate\n SET status = 'processing', claim_token = ?, writer_epoch = ?, lease_until = ?,\n attempts = attempts + 1\n WHERE candidate.effect_id = ?\n AND candidate.status IN ('pending', 'failed')\n AND EXISTS (\n SELECT 1 FROM writer_lease\n WHERE role = ? AND writer_epoch = ? AND fencing_token = ? AND lease_until > ?\n)\n AND NOT EXISTS (\n SELECT 1\n FROM sheet_effect_outbox AS predecessor\n WHERE predecessor.logical_sheet_id = candidate.logical_sheet_id\n AND predecessor.target_kind = candidate.target_kind\n AND predecessor.target_id = candidate.target_id\n AND predecessor.stream_sequence < candidate.stream_sequence\n AND predecessor.status NOT IN ('applied', 'superseded')\n )\n";
|
|
5
|
+
export declare const INSERT_PENDING_EFFECT_SQL = "\n INSERT INTO sheet_effect_outbox (\n effect_id, effect_kind, commit_id, logical_sheet_id, physical_sheet_id,\n projection, row_binding_id, conflict_id, target_kind, target_id,\n target_entity_revision, target_field_revision_hash, target_canonical_commit_id,\n expected_visible_revision, expected_visible_hash, repair_guard_hash,\n source_quarantine_id, payload_json, payload_hash, effect_dedupe_key,\n stream_sequence, created_at, status\n )\n SELECT ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'pending'\n WHERE EXISTS (\n SELECT 1 FROM writer_lease\n WHERE role = ? AND writer_epoch = ? AND fencing_token = ? AND lease_until > ?\n)\n";
|
|
6
|
+
export declare const APPLY_EFFECT_RESULT_SQL = "\n UPDATE sheet_effect_outbox\n SET status = ?, last_error_code = ?, last_error_message = ?,\n claim_token = NULL, lease_until = NULL\n WHERE effect_id = ?\n AND status = 'processing'\n AND claim_token = ?\n AND writer_epoch = ?\n AND lease_until IS NOT NULL\n AND lease_until > ?\n AND EXISTS (\n SELECT 1 FROM writer_lease\n WHERE role = ? AND writer_epoch = ? AND fencing_token = ? AND lease_until > ?\n)\n";
|
|
7
|
+
export declare const SUPERSEDE_EFFECT_SQL = "\n UPDATE sheet_effect_outbox\n SET status = 'superseded', supersedes_effect_id = ?\n WHERE effect_id = ?\n AND status IN ('pending', 'processing', 'blocked_candidate', 'conflict', 'failed')\n AND EXISTS (\n SELECT 1 FROM writer_lease\n WHERE role = ? AND writer_epoch = ? AND fencing_token = ? AND lease_until > ?\n)\n";
|
|
8
|
+
export declare const INSERT_REPLANNED_EFFECT_SQL = "\n INSERT INTO sheet_effect_outbox (\n effect_id, effect_kind, commit_id, logical_sheet_id, physical_sheet_id,\n projection, row_binding_id, conflict_id, target_kind, target_id,\n target_entity_revision, target_field_revision_hash, target_canonical_commit_id,\n expected_visible_revision, expected_visible_hash, repair_guard_hash,\n source_quarantine_id, payload_json, payload_hash, effect_dedupe_key,\n stream_sequence, predecessor_effect_id, created_at, status\n )\n SELECT ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'pending'\n WHERE EXISTS (\n SELECT 1 FROM writer_lease\n WHERE role = ? AND writer_epoch = ? AND fencing_token = ? AND lease_until > ?\n)\n";
|
|
9
|
+
export declare const RECOVER_EXPIRED_LEASES_SQL: string;
|
|
10
|
+
export declare const REQUEUE_CLAIMED_EFFECT_SQL = "\n UPDATE sheet_effect_outbox\n SET status = 'pending', claim_token = NULL, lease_until = NULL,\n last_error_code = ?, last_error_message = ?\n WHERE effect_id = ? AND status = 'processing' AND claim_token = ?\n AND writer_epoch = ? AND lease_until IS NOT NULL AND lease_until > ?\n AND EXISTS (\n SELECT 1 FROM writer_lease\n WHERE role = ? AND writer_epoch = ? AND fencing_token = ? AND lease_until > ?\n)\n";
|
|
11
|
+
export declare const RELEASE_UNPROCESSED_EFFECT_SQL = "\n UPDATE sheet_effect_outbox\n SET status = 'pending', claim_token = NULL, lease_until = NULL,\n last_error_code = 'gateway_batch_deferred',\n last_error_message = 'Gateway acknowledged a bounded batch before this effect.'\n WHERE effect_id = ? AND status = 'processing' AND claim_token = ?\n AND writer_epoch = ? AND lease_until IS NOT NULL AND lease_until > ?\n AND EXISTS (\n SELECT 1 FROM writer_lease\n WHERE role = ? AND writer_epoch = ? AND fencing_token = ? AND lease_until > ?\n)\n";
|
|
12
|
+
export declare const SELECT_PENDING_EFFECTS_BY_TARGET_SQL = "\n SELECT effect_id, effect_kind, commit_id, logical_sheet_id, physical_sheet_id,\n projection, row_binding_id, conflict_id, target_kind, target_id,\n target_entity_revision, target_field_revision_hash, target_canonical_commit_id,\n expected_visible_revision, expected_visible_hash, repair_guard_hash,\n source_quarantine_id, payload_json, payload_hash, effect_dedupe_key,\n stream_sequence, created_at, status\n FROM sheet_effect_outbox\n WHERE logical_sheet_id = ? AND target_kind = ? AND target_id = ?\n AND status = 'pending'\n AND NOT EXISTS (\n SELECT 1\n FROM sheet_effect_outbox AS predecessor\n WHERE predecessor.logical_sheet_id = sheet_effect_outbox.logical_sheet_id\n AND predecessor.target_kind = sheet_effect_outbox.target_kind\n AND predecessor.target_id = sheet_effect_outbox.target_id\n AND predecessor.stream_sequence < sheet_effect_outbox.stream_sequence\n AND predecessor.status NOT IN ('applied', 'superseded')\n )\n ORDER BY stream_sequence\n";
|
|
13
|
+
export declare const SELECT_READY_EFFECTS_SQL: string;
|
|
14
|
+
export declare const COUNT_PENDING_OR_PROCESSING_EFFECTS_SQL = "\n SELECT COUNT(*) AS count\n FROM sheet_effect_outbox\n WHERE status IN ('pending', 'processing')\n";
|
|
15
|
+
export declare const UPSERT_VISIBLE_STATE_SQL = "\n INSERT INTO sheet_visible_state (\n physical_sheet_id, projection, row_binding_id, confirmed_snapshot_hash,\n confirmed_visible_revision, confirmed_entity_revision, last_observed_hash\n ) VALUES (?, ?, ?, ?, ?, ?, ?)\n ON CONFLICT(physical_sheet_id, projection, row_binding_id)\n DO UPDATE SET\n confirmed_snapshot_hash = excluded.confirmed_snapshot_hash,\n confirmed_visible_revision = excluded.confirmed_visible_revision,\n confirmed_entity_revision = excluded.confirmed_entity_revision,\n last_observed_hash = excluded.last_observed_hash\n WHERE sheet_visible_state.confirmed_visible_revision <= excluded.confirmed_visible_revision\n";
|
|
16
|
+
export declare const UPSERT_VISIBLE_FIELD_STATE_SQL = "\n INSERT INTO sheet_visible_field_state (\n physical_sheet_id, projection, row_binding_id, field_name,\n confirmed_field_hash, confirmed_visible_revision, candidate_epoch,\n last_observed_field_hash\n ) VALUES (?, ?, ?, ?, ?, ?, 0, ?)\n ON CONFLICT(physical_sheet_id, projection, row_binding_id, field_name)\n DO UPDATE SET\n confirmed_field_hash = excluded.confirmed_field_hash,\n confirmed_visible_revision = excluded.confirmed_visible_revision,\n last_observed_field_hash = excluded.last_observed_field_hash\n WHERE sheet_visible_field_state.confirmed_visible_revision <= excluded.confirmed_visible_revision\n";
|
|
17
|
+
/**
|
|
18
|
+
* Claims a pending effect for processing.
|
|
19
|
+
* Uses CAS on status to ensure only one worker wins.
|
|
20
|
+
*/
|
|
21
|
+
//# sourceMappingURL=effectOutboxSql.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effectOutboxSql.d.ts","sourceRoot":"","sources":["../../../../../src/infrastructure/storage/sync/outbound/effectOutboxSql.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAI9D,eAAO,MAAM,iCAAiC,QAOjC,CAAC;AAEd,eAAO,MAAM,gBAAgB,sHAG5B,CAAC;AAEF,eAAO,MAAM,gBAAgB,0xBAgB5B,CAAC;AAEF,eAAO,MAAM,yBAAyB,grBAWrC,CAAC;AAEF,eAAO,MAAM,uBAAuB,0bAWnC,CAAC;AAEF,eAAO,MAAM,oBAAoB,+UAMhC,CAAC;AAEF,eAAO,MAAM,2BAA2B,0sBAWvC,CAAC;AAEF,eAAO,MAAM,0BAA0B,QAOtC,CAAC;AAEF,eAAO,MAAM,0BAA0B,8aAOtC,CAAC;AAEF,eAAO,MAAM,8BAA8B,qgBAQ1C,CAAC;AAEF,eAAO,MAAM,oCAAoC,yiCAoBhD,CAAC;AAEF,eAAO,MAAM,wBAAwB,QA2BpC,CAAC;AAEF,eAAO,MAAM,uCAAuC,4GAInD,CAAC;AAEF,eAAO,MAAM,wBAAwB,2pBAYpC,CAAC;AAEF,eAAO,MAAM,8BAA8B,ioBAY1C,CAAC;AAGF;;;GAGG"}
|