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,343 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime adapter for the thin, generic Apps Script operation gateway.
|
|
3
|
+
*
|
|
4
|
+
* The current Code.gs exposes a generic signed operation dispatcher. Fast
|
|
5
|
+
* append stays on its low-cost operation, while regular effects and recovery
|
|
6
|
+
* reads use separate operations with their own typed decoders.
|
|
7
|
+
*/
|
|
8
|
+
import { SYNC_GATEWAY_ERROR_CODES, SyncGatewayContractError, } from "../../../../../application/sync/gateway/errors.js";
|
|
9
|
+
import { requireSyncGatewayNonEmptyList, requireSyncGatewayNonNegativeSafeInteger, requireSyncGatewayPositiveSafeInteger, requireSyncGatewayProjection, requireSyncGatewayText, } from "../../../../../application/sync/gateway/validation.js";
|
|
10
|
+
import { isRecord } from "../../../../../shared/encoding/typeGuards.js";
|
|
11
|
+
import { createFastAppendRowsOperation } from "../operations/write/fastAppendOperation.js";
|
|
12
|
+
import { createReadTableRowsOperation } from "../operations/read/tableReadOperation.js";
|
|
13
|
+
import { createApplyEffectsOperation, createReadEffectPostconditionOperation, createReadEffectPostconditionsOperation, } from "../operations/effect/effectOperation.js";
|
|
14
|
+
import { createEnsureRowAnchorsOperation, createObserveSnapshotOperation, createReadSnapshotOperation, } from "../operations/observation/observationOperation.js";
|
|
15
|
+
import { invalidOperationResponse } from "../errors.js";
|
|
16
|
+
/**
|
|
17
|
+
* Adapts the generic Apps Script operation transport to the sync worker's
|
|
18
|
+
* fast and regular effect gateway boundaries.
|
|
19
|
+
*/
|
|
20
|
+
export class AppsScriptOperationSyncGateway {
|
|
21
|
+
operationGateway;
|
|
22
|
+
definitions;
|
|
23
|
+
constructor(options) {
|
|
24
|
+
if (options.definitions.length === 0) {
|
|
25
|
+
throw new SyncGatewayContractError(SYNC_GATEWAY_ERROR_CODES.INVALID_PROVISIONING_DEFINITIONS, "Apps Script operation sync gateway requires a projection definition");
|
|
26
|
+
}
|
|
27
|
+
this.operationGateway = options.operationGateway;
|
|
28
|
+
this.definitions = options.definitions;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Creates or verifies the registered tabs and their header rows remotely.
|
|
32
|
+
*
|
|
33
|
+
* The operation is idempotent: the remote source only creates missing tabs
|
|
34
|
+
* and rejects a nonblank header row that differs from SQLite's schema.
|
|
35
|
+
*/
|
|
36
|
+
async provisionRegistry(registrations) {
|
|
37
|
+
requireSyncGatewayNonEmptyList(registrations, "Apps Script operation provisioning registrations", SYNC_GATEWAY_ERROR_CODES.INVALID_PROVISIONING_DEFINITIONS);
|
|
38
|
+
const operation = {
|
|
39
|
+
fn: PROVISION_SOURCE,
|
|
40
|
+
args: {
|
|
41
|
+
registrations: registrations.map(toProvisionRegistrationWire),
|
|
42
|
+
},
|
|
43
|
+
decode: decodeProvisionResult,
|
|
44
|
+
};
|
|
45
|
+
const [result] = await this.operationGateway.applyOperations([operation]);
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Appends new System_State rows with one remote setValues operation.
|
|
50
|
+
*
|
|
51
|
+
* No row metadata, receipt, snapshot, CAS, or postcondition work is
|
|
52
|
+
* performed here. Reconciliation owns drift detection after this write.
|
|
53
|
+
*/
|
|
54
|
+
async fastAppendRows(request) {
|
|
55
|
+
const definition = this.definitionForPhysicalSheet(request.physicalSheetId);
|
|
56
|
+
validateRoute(request, definition);
|
|
57
|
+
const operation = createFastAppendRowsOperation({
|
|
58
|
+
sheetName: request.sheetName,
|
|
59
|
+
headers: definition.headers,
|
|
60
|
+
rows: request.rows,
|
|
61
|
+
});
|
|
62
|
+
const [result] = await this.operationGateway.applyOperations([operation]);
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
/** Reads one registered table with values only; no metadata, lock, or CAS work is performed. */
|
|
66
|
+
async readRows(request) {
|
|
67
|
+
const [result] = await this.readRowsBatch([request]);
|
|
68
|
+
if (result === undefined) {
|
|
69
|
+
throw new SyncGatewayContractError(SYNC_GATEWAY_ERROR_CODES.INVALID_GATEWAY_RESPONSE, "Apps Script table read returned no result");
|
|
70
|
+
}
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
/** Reads several registered tables through one signed Apps Script request. */
|
|
74
|
+
async readRowsBatch(requests) {
|
|
75
|
+
const operations = requests.map((request) => {
|
|
76
|
+
const definition = this.definitionForPhysicalSheet(request.physicalSheetId);
|
|
77
|
+
validateRoute(request, definition);
|
|
78
|
+
return createReadTableRowsOperation({
|
|
79
|
+
sheetName: request.sheetName,
|
|
80
|
+
registeredRange: request.registeredRange,
|
|
81
|
+
headers: definition.headers,
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
if (operations.length === 0)
|
|
85
|
+
return [];
|
|
86
|
+
const results = await this.operationGateway.applyOperations(operations);
|
|
87
|
+
return results;
|
|
88
|
+
}
|
|
89
|
+
/** Applies regular update/delete effects through the full operation path. */
|
|
90
|
+
async applyEffects(request) {
|
|
91
|
+
const definition = this.definitionForPhysicalSheet(request.physicalSheetId);
|
|
92
|
+
validateRoute(request, definition);
|
|
93
|
+
const operation = createApplyEffectsOperation({
|
|
94
|
+
...request,
|
|
95
|
+
...effectRouteOptions(definition),
|
|
96
|
+
});
|
|
97
|
+
const [result] = await this.operationGateway.applyOperations([operation]);
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
/** Reads one regular-effect postcondition after an uncertain response. */
|
|
101
|
+
async readEffectPostcondition(effect) {
|
|
102
|
+
const definition = this.definitionForPhysicalSheet(effect.physicalSheetId);
|
|
103
|
+
const request = {
|
|
104
|
+
physicalSheetId: effect.physicalSheetId,
|
|
105
|
+
sheetName: effect.payload.sheetName,
|
|
106
|
+
registeredRange: effect.payload.registeredRange,
|
|
107
|
+
projection: effect.projection,
|
|
108
|
+
schemaVersion: effect.payload.schemaVersion,
|
|
109
|
+
effect,
|
|
110
|
+
};
|
|
111
|
+
validateRoute(request, definition);
|
|
112
|
+
const operation = createReadEffectPostconditionOperation({
|
|
113
|
+
...request,
|
|
114
|
+
...effectRouteOptions(definition),
|
|
115
|
+
});
|
|
116
|
+
const [result] = await this.operationGateway.applyOperations([operation]);
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
119
|
+
/** Reads several regular-effect postconditions with one Sheet scan. */
|
|
120
|
+
async readEffectPostconditions(request) {
|
|
121
|
+
const definition = this.definitionForPhysicalSheet(request.physicalSheetId);
|
|
122
|
+
validateRoute(request, definition);
|
|
123
|
+
const operation = createReadEffectPostconditionsOperation({
|
|
124
|
+
...request,
|
|
125
|
+
...effectRouteOptions(definition),
|
|
126
|
+
});
|
|
127
|
+
const [result] = await this.operationGateway.applyOperations([operation]);
|
|
128
|
+
return result;
|
|
129
|
+
}
|
|
130
|
+
/** Assigns missing row anchors through the observation operation. */
|
|
131
|
+
async ensureRowAnchors(request) {
|
|
132
|
+
const definition = this.definitionForPhysicalSheet(request.physicalSheetId);
|
|
133
|
+
validateRoute(request, definition);
|
|
134
|
+
const operation = createEnsureRowAnchorsOperation({
|
|
135
|
+
...request,
|
|
136
|
+
...observationRouteOptions(definition),
|
|
137
|
+
});
|
|
138
|
+
const [result] = await this.operationGateway.applyOperations([operation]);
|
|
139
|
+
return result;
|
|
140
|
+
}
|
|
141
|
+
/** Reads a normalized, anchor-aware snapshot for polling and reconciliation. */
|
|
142
|
+
async readSnapshot(request) {
|
|
143
|
+
const definition = this.definitionForPhysicalSheet(request.physicalSheetId);
|
|
144
|
+
validateRoute(request, definition);
|
|
145
|
+
const operation = createReadSnapshotOperation({
|
|
146
|
+
...request,
|
|
147
|
+
...observationRouteOptions(definition),
|
|
148
|
+
});
|
|
149
|
+
const [result] = await this.operationGateway.applyOperations([operation]);
|
|
150
|
+
return result;
|
|
151
|
+
}
|
|
152
|
+
/** Assigns anchors and reads one snapshot under one remote lock/request. */
|
|
153
|
+
async observeSnapshot(request) {
|
|
154
|
+
const [result] = await this.observeSnapshots([request]);
|
|
155
|
+
if (result === undefined) {
|
|
156
|
+
throw new SyncGatewayContractError(SYNC_GATEWAY_ERROR_CODES.INVALID_GATEWAY_RESPONSE, "Apps Script observation returned no result");
|
|
157
|
+
}
|
|
158
|
+
return result;
|
|
159
|
+
}
|
|
160
|
+
/** Reads several projections through one signed Apps Script request. */
|
|
161
|
+
async observeSnapshots(requests) {
|
|
162
|
+
const operations = requests.map((request) => {
|
|
163
|
+
const definition = this.definitionForPhysicalSheet(request.physicalSheetId);
|
|
164
|
+
validateRoute(request, definition);
|
|
165
|
+
return createObserveSnapshotOperation({
|
|
166
|
+
...request,
|
|
167
|
+
...observationRouteOptions(definition),
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
if (operations.length === 0)
|
|
171
|
+
return [];
|
|
172
|
+
const results = await this.operationGateway.applyOperations(operations);
|
|
173
|
+
return results;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Reads a projection for setup checks and operational verification.
|
|
177
|
+
*
|
|
178
|
+
* This is intentionally not part of the old SyncSheetGateway contract; it
|
|
179
|
+
* is a small read operation for callers that need to verify row counts.
|
|
180
|
+
*/
|
|
181
|
+
async readProjection(sheetName) {
|
|
182
|
+
const operation = {
|
|
183
|
+
fn: READ_PROJECTION_SOURCE,
|
|
184
|
+
args: { sheetName },
|
|
185
|
+
decode: decodeProjectionStatus,
|
|
186
|
+
};
|
|
187
|
+
const [result] = await this.operationGateway.applyOperations([operation]);
|
|
188
|
+
return result;
|
|
189
|
+
}
|
|
190
|
+
definitionForPhysicalSheet(physicalSheetId) {
|
|
191
|
+
const definition = this.definitions.find((candidate) => candidate.sheet.physicalSheetId === physicalSheetId);
|
|
192
|
+
if (definition === undefined) {
|
|
193
|
+
throw new SyncGatewayContractError(SYNC_GATEWAY_ERROR_CODES.INVALID_PROVISIONING_DEFINITIONS, "no projection definition exists for " + physicalSheetId);
|
|
194
|
+
}
|
|
195
|
+
return definition;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function toProvisionRegistrationWire(registration) {
|
|
199
|
+
return {
|
|
200
|
+
sheetName: registration.sheetName,
|
|
201
|
+
registeredRange: registration.registeredRange,
|
|
202
|
+
projection: registration.projection,
|
|
203
|
+
schemaVersion: registration.schemaVersion,
|
|
204
|
+
headers: registration.headers,
|
|
205
|
+
...(registration.identityField === undefined
|
|
206
|
+
? {}
|
|
207
|
+
: { identityField: registration.identityField }),
|
|
208
|
+
...(registration.checkboxHeaders === undefined
|
|
209
|
+
? {}
|
|
210
|
+
: { checkboxHeaders: registration.checkboxHeaders }),
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
function decodeProvisionResult(value) {
|
|
214
|
+
const record = requireRecord(value, "provisioning result");
|
|
215
|
+
if (!Array.isArray(record.registrations)) {
|
|
216
|
+
return invalidOperationResponse("Apps Script operation", "provisioning registrations must be an array");
|
|
217
|
+
}
|
|
218
|
+
return {
|
|
219
|
+
registrations: record.registrations.map((entry, index) => decodeProvisionedRoute(entry, index)),
|
|
220
|
+
createdSheets: requireStringArray(record.createdSheets, "provisioning createdSheets"),
|
|
221
|
+
initializedHeaders: requireStringArray(record.initializedHeaders, "provisioning initializedHeaders"),
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
function decodeProvisionedRoute(value, index) {
|
|
225
|
+
const record = requireRecord(value, "provisioning registrations[" + index + "]");
|
|
226
|
+
const identityField = optionalString(record.identityField, "provisioning registrations[" + index + "].identityField");
|
|
227
|
+
const checkboxHeaders = record.checkboxHeaders === undefined
|
|
228
|
+
? undefined
|
|
229
|
+
: requireStringArray(record.checkboxHeaders, "provisioning registrations[" + index + "].checkboxHeaders");
|
|
230
|
+
return {
|
|
231
|
+
sheetName: requireSyncGatewayText(record.sheetName, "provisioning registrations[" + index + "].sheetName", SYNC_GATEWAY_ERROR_CODES.INVALID_GATEWAY_RESPONSE),
|
|
232
|
+
registeredRange: requireSyncGatewayText(record.registeredRange, "provisioning registrations[" + index + "].registeredRange", SYNC_GATEWAY_ERROR_CODES.INVALID_GATEWAY_RESPONSE),
|
|
233
|
+
projection: requireSyncGatewayProjection(record.projection, "provisioning registrations[" + index + "].projection", SYNC_GATEWAY_ERROR_CODES.INVALID_GATEWAY_RESPONSE),
|
|
234
|
+
schemaVersion: requireSyncGatewayPositiveSafeInteger(record.schemaVersion, "provisioning registrations[" + index + "].schemaVersion", SYNC_GATEWAY_ERROR_CODES.INVALID_GATEWAY_RESPONSE),
|
|
235
|
+
...(identityField === undefined ? {} : { identityField }),
|
|
236
|
+
...(checkboxHeaders === undefined ? {} : { checkboxHeaders }),
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
function decodeProjectionStatus(value) {
|
|
240
|
+
const record = requireRecord(value, "projection result");
|
|
241
|
+
return {
|
|
242
|
+
sheetName: requireSyncGatewayText(record.sheetName, "projection result sheetName", SYNC_GATEWAY_ERROR_CODES.INVALID_GATEWAY_RESPONSE),
|
|
243
|
+
headers: requireStringArray(record.headers, "projection result headers"),
|
|
244
|
+
rowCount: requireSyncGatewayNonNegativeSafeInteger(record.rowCount, "projection result rowCount", SYNC_GATEWAY_ERROR_CODES.INVALID_GATEWAY_RESPONSE),
|
|
245
|
+
ids: requireStringArray(record.ids, "projection result ids"),
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
function requireStringArray(value, label) {
|
|
249
|
+
if (!Array.isArray(value)) {
|
|
250
|
+
return invalidOperationResponse("Apps Script operation", label + " must be an array");
|
|
251
|
+
}
|
|
252
|
+
return value.map((entry, index) => requireSyncGatewayText(entry, label + "[" + index + "]", SYNC_GATEWAY_ERROR_CODES.INVALID_GATEWAY_RESPONSE));
|
|
253
|
+
}
|
|
254
|
+
function optionalString(value, label) {
|
|
255
|
+
if (value === undefined)
|
|
256
|
+
return undefined;
|
|
257
|
+
return requireSyncGatewayText(value, label, SYNC_GATEWAY_ERROR_CODES.INVALID_GATEWAY_RESPONSE);
|
|
258
|
+
}
|
|
259
|
+
function validateRoute(request, definition) {
|
|
260
|
+
if (request.sheetName !== definition.sheet.tabName ||
|
|
261
|
+
request.registeredRange !== definition.sheet.registeredRange ||
|
|
262
|
+
request.projection !== definition.sheet.projection ||
|
|
263
|
+
request.schemaVersion !== definition.sheet.schemaVersion) {
|
|
264
|
+
throw new SyncGatewayContractError(SYNC_GATEWAY_ERROR_CODES.INVALID_EFFECT_PAYLOAD, "sync gateway request does not match the registered projection " +
|
|
265
|
+
request.physicalSheetId);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
function effectRouteOptions(definition) {
|
|
269
|
+
return {
|
|
270
|
+
...(definition.sheet.projection === "system_state"
|
|
271
|
+
? { identityField: definition.sheet.businessKeyField }
|
|
272
|
+
: {}),
|
|
273
|
+
...(definition.checkboxHeaders === undefined
|
|
274
|
+
? {}
|
|
275
|
+
: { checkboxHeaders: definition.checkboxHeaders }),
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
function observationRouteOptions(definition) {
|
|
279
|
+
return definition.checkboxHeaders === undefined
|
|
280
|
+
? {}
|
|
281
|
+
: { checkboxHeaders: definition.checkboxHeaders };
|
|
282
|
+
}
|
|
283
|
+
function requireRecord(value, label) {
|
|
284
|
+
if (!isRecord(value)) {
|
|
285
|
+
return invalidOperationResponse("Apps Script operation", label + " must be an object");
|
|
286
|
+
}
|
|
287
|
+
return value;
|
|
288
|
+
}
|
|
289
|
+
const PROVISION_SOURCE = [
|
|
290
|
+
"function (spreadsheet, args) {",
|
|
291
|
+
" if (!args || !Array.isArray(args.registrations) || args.registrations.length === 0) {",
|
|
292
|
+
' throw new Error("operational provisioning registrations are required");',
|
|
293
|
+
" }",
|
|
294
|
+
" var createdSheets = [];",
|
|
295
|
+
" var initializedHeaders = [];",
|
|
296
|
+
" args.registrations.forEach(function (registration) {",
|
|
297
|
+
" var sheet = spreadsheet.getSheetByName(registration.sheetName);",
|
|
298
|
+
" if (sheet === null) {",
|
|
299
|
+
" sheet = spreadsheet.insertSheet(registration.sheetName);",
|
|
300
|
+
" createdSheets.push(registration.sheetName);",
|
|
301
|
+
" }",
|
|
302
|
+
" if (sheet.getLastRow() === 0 && sheet.getLastColumn() === 0) {",
|
|
303
|
+
" sheet.getRange(1, 1, 1, registration.headers.length).setValues([registration.headers]);",
|
|
304
|
+
" initializedHeaders.push(registration.sheetName);",
|
|
305
|
+
" return;",
|
|
306
|
+
" }",
|
|
307
|
+
" var actual = sheet.getRange(1, 1, 1, registration.headers.length).getValues()[0];",
|
|
308
|
+
" for (var index = 0; index < registration.headers.length; index += 1) {",
|
|
309
|
+
' if (String(actual[index]) !== String(registration.headers[index])) {',
|
|
310
|
+
' throw new Error("operational provisioning header mismatch: " + registration.sheetName);',
|
|
311
|
+
" }",
|
|
312
|
+
" }",
|
|
313
|
+
" });",
|
|
314
|
+
" return {",
|
|
315
|
+
" registrations: args.registrations.map(function (registration) {",
|
|
316
|
+
" return {",
|
|
317
|
+
" sheetName: registration.sheetName,",
|
|
318
|
+
" registeredRange: registration.registeredRange,",
|
|
319
|
+
" projection: registration.projection,",
|
|
320
|
+
" schemaVersion: registration.schemaVersion,",
|
|
321
|
+
" identityField: registration.identityField,",
|
|
322
|
+
" };",
|
|
323
|
+
" }),",
|
|
324
|
+
" createdSheets: createdSheets,",
|
|
325
|
+
" initializedHeaders: initializedHeaders,",
|
|
326
|
+
" };",
|
|
327
|
+
"}",
|
|
328
|
+
].join("\n");
|
|
329
|
+
const READ_PROJECTION_SOURCE = [
|
|
330
|
+
"function (spreadsheet, args) {",
|
|
331
|
+
' var sheet = spreadsheet.getSheetByName(args.sheetName);',
|
|
332
|
+
' if (sheet === null) throw new Error("operational sheet was not found: " + args.sheetName);',
|
|
333
|
+
" var lastRow = sheet.getLastRow();",
|
|
334
|
+
" var lastColumn = sheet.getLastColumn();",
|
|
335
|
+
" var headers = lastColumn === 0 ? [] : sheet.getRange(1, 1, 1, lastColumn).getValues()[0];",
|
|
336
|
+
" var rowCount = Math.max(0, lastRow - 1);",
|
|
337
|
+
" var ids = rowCount === 0",
|
|
338
|
+
" ? []",
|
|
339
|
+
" : sheet.getRange(2, 1, rowCount, 1).getValues().map(function (row) { return String(row[0]); });",
|
|
340
|
+
" return { sheetName: args.sheetName, headers: headers, rowCount: rowCount, ids: ids };",
|
|
341
|
+
"}",
|
|
342
|
+
].join("\n");
|
|
343
|
+
//# sourceMappingURL=operationSyncGateway.js.map
|
package/dist/adapter/sheets/providers/apps-script-gateway/transport/operationSyncGateway.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operationSyncGateway.js","sourceRoot":"","sources":["../../../../../../src/adapter/sheets/providers/apps-script-gateway/transport/operationSyncGateway.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAOH,OAAO,EACL,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,mDAAmD,CAAC;AAC3D,OAAO,EACL,8BAA8B,EAC9B,wCAAwC,EACxC,qCAAqC,EACrC,4BAA4B,EAC5B,sBAAsB,GACvB,MAA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|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/application/index.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public entity-manager facade owned by typed-sheets.
|
|
3
|
+
*
|
|
4
|
+
* The facade keeps the application workflow stable while a replaceable
|
|
5
|
+
* execution engine handles SQLite-specific persistence details underneath.
|
|
6
|
+
*/
|
|
7
|
+
import type { TypedSheetsEntityData, TypedSheetsEntityEngine, TypedSheetsEntityEngineManager, TypedSheetsEntityFilter, TypedSheetsEntityReference, TypedSheetsFindOptions, TypedSheetsForkOptions, TypedSheetsFlushCoordinator } from "./contracts.js";
|
|
8
|
+
/** Options for creating our public typed-sheets ORM around one execution engine. */
|
|
9
|
+
export interface CreateTypedSheetsOrmOptions {
|
|
10
|
+
/** Plans canonical and Sheets outbox work for every durable entity flush. */
|
|
11
|
+
readonly flushCoordinator: TypedSheetsFlushCoordinator;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Root object for typed-sheets entity lifecycle operations.
|
|
15
|
+
*
|
|
16
|
+
* Its `em` property exposes our manager rather than an engine-specific one,
|
|
17
|
+
* so application code cannot bypass the canonical and outbox flush plan.
|
|
18
|
+
*/
|
|
19
|
+
export declare class TypedSheetsOrm {
|
|
20
|
+
private readonly engine;
|
|
21
|
+
private readonly flushCoordinator;
|
|
22
|
+
/** Root entity manager; call `fork()` before request or job-local work. */
|
|
23
|
+
readonly em: TypedSheetsEntityManager;
|
|
24
|
+
constructor(engine: TypedSheetsEntityEngine, flushCoordinator: TypedSheetsFlushCoordinator);
|
|
25
|
+
/** Closes resources owned by the underlying SQLite execution engine. */
|
|
26
|
+
close(force?: boolean): Promise<void>;
|
|
27
|
+
private createEntityManager;
|
|
28
|
+
}
|
|
29
|
+
/** Creates our public entity facade around a replaceable SQLite execution engine. */
|
|
30
|
+
export declare function createTypedSheetsOrm(engine: TypedSheetsEntityEngine, options: CreateTypedSheetsOrmOptions): TypedSheetsOrm;
|
|
31
|
+
/**
|
|
32
|
+
* Entity-manager facade with the familiar entity lifecycle method names.
|
|
33
|
+
*
|
|
34
|
+
* The current public subset intentionally focuses on lifecycle-safe reads and
|
|
35
|
+
* `persist` / `remove` / `flush` operations while mapping metadata is built.
|
|
36
|
+
*/
|
|
37
|
+
export declare class TypedSheetsEntityManager {
|
|
38
|
+
private readonly entityManager;
|
|
39
|
+
private readonly flushCoordinator;
|
|
40
|
+
constructor(entityManager: TypedSheetsEntityEngineManager, flushCoordinator: TypedSheetsFlushCoordinator);
|
|
41
|
+
/** Creates an isolated manager with its own identity map. */
|
|
42
|
+
fork(options?: TypedSheetsForkOptions): TypedSheetsEntityManager;
|
|
43
|
+
/** Creates a managed entity instance without writing it until `flush()`. */
|
|
44
|
+
create<Entity extends object>(entityName: TypedSheetsEntityReference<Entity>, data: TypedSheetsEntityData<Entity>): Entity;
|
|
45
|
+
/** Reads all entities matching one initial equality filter from SQLite. */
|
|
46
|
+
find<Entity extends object>(entityName: TypedSheetsEntityReference<Entity>, where: TypedSheetsEntityFilter<Entity>, options?: TypedSheetsFindOptions): Promise<readonly Entity[]>;
|
|
47
|
+
/** Reads one entity or returns null when no entity matches the filter. */
|
|
48
|
+
findOne<Entity extends object>(entityName: TypedSheetsEntityReference<Entity>, where: TypedSheetsEntityFilter<Entity>, options?: TypedSheetsFindOptions): Promise<Entity | null>;
|
|
49
|
+
/** Marks one entity or iterable of entities for insertion or update at the next flush. */
|
|
50
|
+
persist<Entity extends object>(entity: Entity | Iterable<Entity>): this;
|
|
51
|
+
/** Marks one entity or iterable of entities for removal at the next flush. */
|
|
52
|
+
remove<Entity extends object>(entity: Entity | Iterable<Entity>): this;
|
|
53
|
+
/**
|
|
54
|
+
* Persists all pending entity changes with their typed-sheets sync plan.
|
|
55
|
+
*
|
|
56
|
+
* An existing transaction is reused. Otherwise this method opens a SQLite
|
|
57
|
+
* transaction itself so entity rows and outbox work commit or roll back
|
|
58
|
+
* together.
|
|
59
|
+
*/
|
|
60
|
+
flush(): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Runs entity work in one transaction and flushes it automatically on success.
|
|
63
|
+
*
|
|
64
|
+
* The callback receives another typed-sheets manager, so its flush still
|
|
65
|
+
* coordinates canonical and Sheets outbox work.
|
|
66
|
+
*/
|
|
67
|
+
transactional<Result>(operation: (entityManager: TypedSheetsEntityManager) => Promise<Result>): Promise<Result>;
|
|
68
|
+
/** Detaches every managed entity from this request or job-local manager. */
|
|
69
|
+
clear(): void;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=TypedSheetsOrm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypedSheetsOrm.d.ts","sourceRoot":"","sources":["../../../../src/application/orm/api/TypedSheetsOrm.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EACV,qBAAqB,EACrB,uBAAuB,EACvB,8BAA8B,EAC9B,uBAAuB,EACvB,0BAA0B,EAC1B,sBAAsB,EACtB,sBAAsB,EACtB,2BAA2B,EAC5B,MAAM,gBAAgB,CAAC;AAExB,oFAAoF;AACpF,MAAM,WAAW,2BAA2B;IAC1C,6EAA6E;IAC7E,QAAQ,CAAC,gBAAgB,EAAE,2BAA2B,CAAC;CACxD;AAED;;;;;GAKG;AACH,qBAAa,cAAc;IAKvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IALnC,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,EAAE,wBAAwB,CAAC;gBAGnB,MAAM,EAAE,uBAAuB,EAC/B,gBAAgB,EAAE,2BAA2B;IAKhE,wEAAwE;IAClE,KAAK,CAAC,KAAK,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAIzC,OAAO,CAAC,mBAAmB;CAK5B;AAED,qFAAqF;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CAAC;IAkB5B;;;;;OAKG;IACG,aAAa,CAAC,MAAM,EACxB,SAAS,EAAE,CAAC,aAAa,EAAE,wBAAwB,KAAK,OAAO,CAAC,MAAM,CAAC,GACtE,OAAO,CAAC,MAAM,CAAC;IAUlB,4EAA4E;IAC5E,KAAK,IAAI,IAAI;CAGd"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public entity-manager facade owned by typed-sheets.
|
|
3
|
+
*
|
|
4
|
+
* The facade keeps the application workflow stable while a replaceable
|
|
5
|
+
* execution engine handles SQLite-specific persistence details underneath.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Root object for typed-sheets entity lifecycle operations.
|
|
9
|
+
*
|
|
10
|
+
* Its `em` property exposes our manager rather than an engine-specific one,
|
|
11
|
+
* so application code cannot bypass the canonical and outbox flush plan.
|
|
12
|
+
*/
|
|
13
|
+
export class TypedSheetsOrm {
|
|
14
|
+
engine;
|
|
15
|
+
flushCoordinator;
|
|
16
|
+
/** Root entity manager; call `fork()` before request or job-local work. */
|
|
17
|
+
em;
|
|
18
|
+
constructor(engine, flushCoordinator) {
|
|
19
|
+
this.engine = engine;
|
|
20
|
+
this.flushCoordinator = flushCoordinator;
|
|
21
|
+
this.em = this.createEntityManager(engine.fork());
|
|
22
|
+
}
|
|
23
|
+
/** Closes resources owned by the underlying SQLite execution engine. */
|
|
24
|
+
async close(force = false) {
|
|
25
|
+
await this.engine.close(force);
|
|
26
|
+
}
|
|
27
|
+
createEntityManager(entityManager) {
|
|
28
|
+
return new TypedSheetsEntityManager(entityManager, this.flushCoordinator);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/** Creates our public entity facade around a replaceable SQLite execution engine. */
|
|
32
|
+
export function createTypedSheetsOrm(engine, options) {
|
|
33
|
+
return new TypedSheetsOrm(engine, options.flushCoordinator);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Entity-manager facade with the familiar entity lifecycle method names.
|
|
37
|
+
*
|
|
38
|
+
* The current public subset intentionally focuses on lifecycle-safe reads and
|
|
39
|
+
* `persist` / `remove` / `flush` operations while mapping metadata is built.
|
|
40
|
+
*/
|
|
41
|
+
export class TypedSheetsEntityManager {
|
|
42
|
+
entityManager;
|
|
43
|
+
flushCoordinator;
|
|
44
|
+
constructor(entityManager, flushCoordinator) {
|
|
45
|
+
this.entityManager = entityManager;
|
|
46
|
+
this.flushCoordinator = flushCoordinator;
|
|
47
|
+
this.entityManager.onFlush(async (context) => this.flushCoordinator.onFlush(context));
|
|
48
|
+
}
|
|
49
|
+
/** Creates an isolated manager with its own identity map. */
|
|
50
|
+
fork(options) {
|
|
51
|
+
return new TypedSheetsEntityManager(this.entityManager.fork(options), this.flushCoordinator);
|
|
52
|
+
}
|
|
53
|
+
/** Creates a managed entity instance without writing it until `flush()`. */
|
|
54
|
+
create(entityName, data) {
|
|
55
|
+
return this.entityManager.create(entityName, data);
|
|
56
|
+
}
|
|
57
|
+
/** Reads all entities matching one initial equality filter from SQLite. */
|
|
58
|
+
async find(entityName, where, options) {
|
|
59
|
+
return this.entityManager.find(entityName, where, options);
|
|
60
|
+
}
|
|
61
|
+
/** Reads one entity or returns null when no entity matches the filter. */
|
|
62
|
+
async findOne(entityName, where, options) {
|
|
63
|
+
return this.entityManager.findOne(entityName, where, options);
|
|
64
|
+
}
|
|
65
|
+
/** Marks one entity or iterable of entities for insertion or update at the next flush. */
|
|
66
|
+
persist(entity) {
|
|
67
|
+
this.entityManager.persist(entity);
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
/** Marks one entity or iterable of entities for removal at the next flush. */
|
|
71
|
+
remove(entity) {
|
|
72
|
+
this.entityManager.remove(entity);
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Persists all pending entity changes with their typed-sheets sync plan.
|
|
77
|
+
*
|
|
78
|
+
* An existing transaction is reused. Otherwise this method opens a SQLite
|
|
79
|
+
* transaction itself so entity rows and outbox work commit or roll back
|
|
80
|
+
* together.
|
|
81
|
+
*/
|
|
82
|
+
async flush() {
|
|
83
|
+
if (this.entityManager.isInTransaction()) {
|
|
84
|
+
await this.entityManager.flush();
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
await this.entityManager.begin();
|
|
88
|
+
try {
|
|
89
|
+
await this.entityManager.flush();
|
|
90
|
+
await this.entityManager.commit();
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
if (this.entityManager.isInTransaction()) {
|
|
94
|
+
await this.entityManager.rollback();
|
|
95
|
+
}
|
|
96
|
+
throw error;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Runs entity work in one transaction and flushes it automatically on success.
|
|
101
|
+
*
|
|
102
|
+
* The callback receives another typed-sheets manager, so its flush still
|
|
103
|
+
* coordinates canonical and Sheets outbox work.
|
|
104
|
+
*/
|
|
105
|
+
async transactional(operation) {
|
|
106
|
+
return this.entityManager.transactional(async (transactionalEntityManager) => {
|
|
107
|
+
const manager = new TypedSheetsEntityManager(transactionalEntityManager, this.flushCoordinator);
|
|
108
|
+
return operation(manager);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
/** Detaches every managed entity from this request or job-local manager. */
|
|
112
|
+
clear() {
|
|
113
|
+
this.entityManager.clear();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=TypedSheetsOrm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TypedSheetsOrm.js","sourceRoot":"","sources":["../../../../src/application/orm/api/TypedSheetsOrm.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAmBH;;;;;GAKG;AACH,MAAM,OAAO,cAAc;IAKN;IACA;IALnB,2EAA2E;IAClE,EAAE,CAA2B;IAEtC,YACmB,MAA+B,EAC/B,gBAA6C;QAD7C,WAAM,GAAN,MAAM,CAAyB;QAC/B,qBAAgB,GAAhB,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