@abloatai/ablo 0.34.1 → 0.36.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/AGENTS.md +2 -1
- package/CHANGELOG.md +758 -5
- package/README.md +56 -502
- package/bin/ablo.cjs +39 -0
- package/dist/BaseSyncedStore.d.ts +176 -48
- package/dist/BaseSyncedStore.js +346 -214
- package/dist/Database.d.ts +17 -44
- package/dist/Database.js +96 -79
- package/dist/InstanceCache.d.ts +31 -6
- package/dist/InstanceCache.js +65 -30
- package/dist/LazyReferenceCollection.d.ts +3 -3
- package/dist/LazyReferenceCollection.js +4 -4
- package/dist/Model.d.ts +23 -13
- package/dist/Model.js +27 -17
- package/dist/ModelRegistry.d.ts +8 -4
- package/dist/ModelRegistry.js +20 -18
- package/dist/NetworkMonitor.d.ts +3 -1
- package/dist/NetworkMonitor.js +7 -5
- package/dist/{SyncEngineContext.d.ts → RuntimeContext.d.ts} +20 -13
- package/dist/{SyncEngineContext.js → RuntimeContext.js} +11 -12
- package/dist/SyncClient.d.ts +47 -47
- package/dist/SyncClient.js +215 -156
- package/dist/ai-sdk/coordinatedTool.d.ts +2 -2
- package/dist/ai-sdk/coordinatedTool.js +1 -1
- package/dist/ai-sdk/coordinationContext.d.ts +2 -2
- package/dist/ai-sdk/coordinationContext.js +1 -1
- package/dist/ai-sdk/wrap.d.ts +3 -3
- package/dist/ai-sdk/wrap.js +2 -2
- package/dist/auth/index.d.ts +1 -156
- package/dist/auth/index.js +8 -301
- package/dist/client/Ablo.d.ts +42 -287
- package/dist/client/Ablo.js +129 -963
- package/dist/client/abloClient.d.ts +309 -0
- package/dist/client/abloClient.js +13 -0
- package/dist/client/clientPrelude.d.ts +52 -0
- package/dist/client/clientPrelude.js +60 -0
- package/dist/client/consoleLogger.d.ts +2 -2
- package/dist/client/coreClient.d.ts +60 -0
- package/dist/client/coreClient.js +118 -0
- package/dist/client/createInternalComponents.d.ts +8 -4
- package/dist/client/createInternalComponents.js +17 -10
- package/dist/client/createModelProxy.d.ts +98 -373
- package/dist/client/createModelProxy.js +233 -139
- package/dist/client/humans.d.ts +69 -0
- package/dist/client/humans.js +78 -0
- package/dist/client/modelRegistration.d.ts +1 -1
- package/dist/client/modelRegistration.js +9 -9
- package/dist/client/options.d.ts +73 -17
- package/dist/client/reactiveEngine.d.ts +53 -0
- package/dist/client/reactiveEngine.js +688 -0
- package/dist/client/resourceTypes.d.ts +9 -250
- package/dist/client/resourceTypes.js +8 -5
- package/dist/client/schemaConfig.d.ts +4 -4
- package/dist/client/schemaConfig.js +6 -2
- package/dist/client/storeCluster.d.ts +47 -0
- package/dist/client/storeCluster.js +118 -0
- package/dist/client/storeLifecycle.d.ts +61 -0
- package/dist/client/storeLifecycle.js +231 -0
- package/dist/client/validateAbloOptions.d.ts +3 -2
- package/dist/client/validateAbloOptions.js +1 -1
- package/dist/client/wsMutationExecutor.d.ts +3 -3
- package/dist/client/wsMutationExecutor.js +3 -3
- package/dist/context.d.ts +22 -9
- package/dist/context.js +33 -9
- package/dist/coordination/ClaimLog.d.ts +26 -0
- package/dist/coordination/ClaimLog.js +32 -0
- package/dist/coordination/index.d.ts +1 -15
- package/dist/coordination/index.js +8 -31
- package/dist/core/index.d.ts +3 -3
- package/dist/core/index.js +2 -2
- package/dist/docs/catalog.d.ts +72 -0
- package/dist/docs/catalog.js +230 -0
- package/dist/docs/index.d.ts +10 -0
- package/dist/docs/index.js +10 -0
- package/dist/environment.d.ts +1 -40
- package/dist/environment.js +8 -37
- package/dist/index.d.ts +44 -36
- package/dist/index.js +30 -22
- package/dist/interfaces/index.d.ts +44 -134
- package/dist/keys/index.d.ts +1 -77
- package/dist/keys/index.js +8 -190
- package/dist/mutators/{RecordingTransaction.d.ts → RecordingMutation.d.ts} +4 -4
- package/dist/mutators/{RecordingTransaction.js → RecordingMutation.js} +2 -2
- package/dist/mutators/Transaction.d.ts +1 -1
- package/dist/mutators/Transaction.js +1 -1
- package/dist/mutators/UndoManager.d.ts +6 -6
- package/dist/mutators/UndoManager.js +5 -5
- package/dist/mutators/defineMutators.d.ts +3 -3
- package/dist/mutators/defineMutators.js +1 -1
- package/dist/mutators/inverseOp.js +2 -2
- package/dist/mutators/mutateActions.d.ts +3 -3
- package/dist/mutators/mutateActions.js +1 -1
- package/dist/mutators/readerActions.d.ts +1 -1
- package/dist/mutators/undoApply.d.ts +1 -1
- package/dist/mutators/undoApply.js +1 -1
- package/dist/policy/index.d.ts +2 -2
- package/dist/policy/index.js +1 -1
- package/dist/query/client.d.ts +5 -2
- package/dist/query/client.js +10 -9
- package/dist/query/types.d.ts +6 -41
- package/dist/query/types.js +2 -2
- package/dist/react/AbloProvider.d.ts +18 -8
- package/dist/react/AbloProvider.js +10 -9
- package/dist/react/context.d.ts +3 -3
- package/dist/react/context.js +1 -1
- package/dist/react/createAbloReact.d.ts +56 -0
- package/dist/react/createAbloReact.js +51 -0
- package/dist/react/index.d.ts +6 -5
- package/dist/react/index.js +6 -3
- package/dist/react/internalContext.d.ts +1 -1
- package/dist/react/useAblo.d.ts +12 -5
- package/dist/react/useAblo.js +26 -8
- package/dist/react/useCurrentUserId.js +1 -1
- package/dist/react/useErrorListener.js +1 -1
- package/dist/react/useMutationFailureListener.d.ts +2 -2
- package/dist/react/useMutationFailureListener.js +1 -1
- package/dist/react/useMutators.d.ts +3 -3
- package/dist/react/useMutators.js +3 -3
- package/dist/react/useUndoScope.d.ts +5 -5
- package/dist/react/useUndoScope.js +1 -1
- package/dist/schema/coordination.d.ts +69 -10
- package/dist/schema/coordination.js +90 -9
- package/dist/schema/ddl.js +2 -2
- package/dist/schema/diff.d.ts +1 -1
- package/dist/schema/generate.js +1 -1
- package/dist/schema/index.d.ts +11 -10
- package/dist/schema/index.js +22 -18
- package/dist/schema/queries.d.ts +27 -27
- package/dist/schema/queries.js +23 -23
- package/dist/schema/select.d.ts +3 -3
- package/dist/schema/select.js +6 -3
- package/dist/schema/serialize.d.ts +15 -6
- package/dist/schema/serialize.js +20 -3
- package/dist/schema/sugar.d.ts +6 -7
- package/dist/schema/sugar.js +9 -12
- package/dist/schema/syncDeltaRow.d.ts +4 -152
- package/dist/schema/syncDeltaRow.js +4 -105
- package/dist/server/adapter.d.ts +18 -1
- package/dist/server/commit.d.ts +10 -16
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/readConfig.d.ts +1 -1
- package/dist/source/adapter.d.ts +7 -5
- package/dist/source/adapter.js +7 -5
- package/dist/source/adapters/drizzle.d.ts +1 -1
- package/dist/source/adapters/drizzle.js +2 -2
- package/dist/source/adapters/kysely.d.ts +1 -1
- package/dist/source/adapters/kysely.js +1 -1
- package/dist/source/adapters/kyselyMutationCore.d.ts +1 -1
- package/dist/source/adapters/kyselyMutationCore.js +2 -2
- package/dist/source/adapters/memory.js +1 -1
- package/dist/source/adapters/prisma.d.ts +8 -3
- package/dist/source/adapters/prisma.js +1 -1
- package/dist/source/connector.js +1 -1
- package/dist/source/connectorProtocol.d.ts +2 -8
- package/dist/source/connectorProtocol.js +3 -2
- package/dist/source/contract.d.ts +29 -17
- package/dist/source/contract.js +27 -22
- package/dist/source/factory.d.ts +1 -1
- package/dist/source/idempotency.js +2 -2
- package/dist/source/index.d.ts +1 -0
- package/dist/source/index.js +3 -0
- package/dist/source/next.d.ts +1 -1
- package/dist/source/signing.d.ts +9 -2
- package/dist/source/signing.js +4 -1
- package/dist/source/types.d.ts +6 -4
- package/dist/source/types.js +1 -1
- package/dist/{core/storeContract.d.ts → storeContract.d.ts} +6 -6
- package/dist/{core → stores}/DatabaseManager.d.ts +3 -1
- package/dist/{core → stores}/DatabaseManager.js +14 -13
- package/dist/stores/ObjectStore.d.ts +1 -1
- package/dist/{core → stores}/StoreManager.d.ts +9 -26
- package/dist/{core → stores}/StoreManager.js +29 -77
- package/dist/stores/SyncActionStore.d.ts +4 -2
- package/dist/stores/SyncActionStore.js +11 -17
- package/dist/stores/syncAction.d.ts +26 -0
- package/dist/stores/syncAction.js +16 -0
- package/dist/surface.d.ts +3 -3
- package/dist/surface.js +6 -4
- package/dist/sync/BootstrapFetcher.d.ts +127 -6
- package/dist/sync/BootstrapFetcher.js +511 -83
- package/dist/sync/ConnectionManager.d.ts +6 -198
- package/dist/sync/ConnectionManager.js +6 -677
- package/dist/sync/OnDemandLoader.d.ts +5 -2
- package/dist/sync/OnDemandLoader.js +61 -21
- package/dist/sync/SubscriptionManager.d.ts +13 -2
- package/dist/sync/SubscriptionManager.js +23 -5
- package/dist/sync/SyncWebSocket.d.ts +27 -510
- package/dist/sync/SyncWebSocket.js +76 -954
- package/dist/sync/awaitClaimGrant.d.ts +4 -44
- package/dist/sync/awaitClaimGrant.js +4 -109
- package/dist/sync/bootstrapApply.d.ts +3 -0
- package/dist/sync/bootstrapApply.js +2 -2
- package/dist/sync/commitFrames.d.ts +6 -40
- package/dist/sync/commitFrames.js +6 -97
- package/dist/sync/contextPorts.d.ts +18 -0
- package/dist/sync/contextPorts.js +31 -0
- package/dist/sync/createClaimStream.d.ts +5 -49
- package/dist/sync/createClaimStream.js +5 -469
- package/dist/sync/createPresenceStream.d.ts +26 -4
- package/dist/sync/createPresenceStream.js +28 -20
- package/dist/sync/createSnapshot.d.ts +2 -2
- package/dist/sync/createSnapshot.js +1 -1
- package/dist/sync/credentialLifecycle.d.ts +5 -173
- package/dist/sync/credentialLifecycle.js +5 -320
- package/dist/sync/deltaPipeline.d.ts +13 -12
- package/dist/sync/deltaPipeline.js +21 -4
- package/dist/sync/groupChange.d.ts +3 -0
- package/dist/sync/groupChange.js +16 -14
- package/dist/sync/participants.d.ts +24 -6
- package/dist/sync/participants.js +32 -23
- package/dist/sync/schemaDrift.d.ts +55 -0
- package/dist/sync/schemaDrift.js +53 -0
- package/dist/sync/schemas.d.ts +23 -33
- package/dist/sync/schemas.js +29 -20
- package/dist/sync/syncPlan.d.ts +3 -3
- package/dist/sync/wsFrameHandlers.d.ts +6 -114
- package/dist/sync/wsFrameHandlers.js +6 -392
- package/dist/syncLog/contract.d.ts +20 -0
- package/dist/syncLog/contract.js +19 -0
- package/dist/syncLog/index.d.ts +1 -0
- package/dist/syncLog/index.js +1 -0
- package/dist/transaction/ablo.d.ts +88 -0
- package/dist/transaction/ablo.js +33 -0
- package/dist/{client/auth.d.ts → transaction/auth/apiKey.d.ts} +43 -8
- package/dist/{client/auth.js → transaction/auth/apiKey.js} +19 -0
- package/dist/transaction/auth/bootstrapScope.d.ts +15 -0
- package/dist/transaction/auth/bootstrapScope.js +1 -0
- package/dist/transaction/auth/capability.d.ts +212 -0
- package/dist/transaction/auth/capability.js +224 -0
- package/dist/{auth → transaction/auth}/credentialSource.d.ts +8 -1
- package/dist/{client → transaction/auth}/identity.d.ts +8 -7
- package/dist/{client → transaction/auth}/identity.js +1 -1
- package/dist/transaction/auth/index.d.ts +162 -0
- package/dist/transaction/auth/index.js +304 -0
- package/dist/{auth → transaction/auth}/schemas.d.ts +1 -1
- package/dist/{auth → transaction/auth}/schemas.js +13 -13
- package/dist/{client → transaction/auth}/sessionMint.d.ts +8 -8
- package/dist/{client → transaction/auth}/sessionMint.js +4 -7
- package/dist/transaction/coordination/awaitClaimGrant.d.ts +56 -0
- package/dist/transaction/coordination/awaitClaimGrant.js +124 -0
- package/dist/{client → transaction/coordination}/claimHeartbeatLoop.d.ts +34 -0
- package/dist/{client → transaction/coordination}/claimHeartbeatLoop.js +20 -0
- package/dist/transaction/coordination/claimMeta.d.ts +49 -0
- package/dist/transaction/coordination/claimMeta.js +52 -0
- package/dist/transaction/coordination/createClaimStream.d.ts +64 -0
- package/dist/transaction/coordination/createClaimStream.js +475 -0
- package/dist/transaction/coordination/events.d.ts +74 -0
- package/dist/transaction/coordination/events.js +7 -0
- package/dist/transaction/coordination/index.d.ts +19 -0
- package/dist/transaction/coordination/index.js +45 -0
- package/dist/transaction/coordination/locator.d.ts +104 -0
- package/dist/transaction/coordination/locator.js +102 -0
- package/dist/transaction/coordination/schema.d.ts +1536 -0
- package/dist/transaction/coordination/schema.js +1177 -0
- package/dist/transaction/coordination/targetConflict.d.ts +2 -0
- package/dist/transaction/coordination/targetConflict.js +107 -0
- package/dist/{coordination → transaction/coordination}/trace.d.ts +7 -18
- package/dist/{coordination → transaction/coordination}/trace.js +18 -25
- package/dist/transaction/durableWrites.d.ts +62 -0
- package/dist/{client → transaction}/durableWrites.js +28 -3
- package/dist/transaction/environment.d.ts +105 -0
- package/dist/transaction/environment.js +108 -0
- package/dist/{errorCodes.d.ts → transaction/errorCodes.d.ts} +12 -12
- package/dist/{errorCodes.js → transaction/errorCodes.js} +45 -18
- package/dist/{errors.d.ts → transaction/errors.d.ts} +37 -13
- package/dist/{errors.js → transaction/errors.js} +85 -16
- package/dist/transaction/footprint.d.ts +111 -0
- package/dist/transaction/footprint.js +0 -0
- package/dist/transaction/index.d.ts +20 -0
- package/dist/transaction/index.js +20 -0
- package/dist/transaction/keys/index.d.ts +87 -0
- package/dist/transaction/keys/index.js +207 -0
- package/dist/transaction/log/syncDeltaRow.d.ts +158 -0
- package/dist/transaction/log/syncDeltaRow.js +95 -0
- package/dist/{sync/syncPosition.d.ts → transaction/logPosition.d.ts} +22 -8
- package/dist/{sync/syncPosition.js → transaction/logPosition.js} +15 -6
- package/dist/transaction/logger.d.ts +16 -0
- package/dist/transaction/logger.js +7 -0
- package/dist/transaction/observability.d.ts +53 -0
- package/dist/transaction/observability.js +19 -0
- package/dist/transaction/plugin.d.ts +285 -0
- package/dist/transaction/plugin.js +106 -0
- package/dist/{policy → transaction/policy}/types.d.ts +3 -3
- package/dist/{policy → transaction/policy}/types.js +2 -0
- package/dist/transaction/resources/httpResources.d.ts +321 -0
- package/dist/transaction/resources/httpResources.js +7 -0
- package/dist/transaction/resources/modelOperations.d.ts +427 -0
- package/dist/transaction/resources/modelOperations.js +12 -0
- package/dist/transaction/resources/mutationOptions.d.ts +66 -0
- package/dist/transaction/resources/mutationOptions.js +9 -0
- package/dist/transaction/resources/where.d.ts +101 -0
- package/dist/transaction/resources/where.js +115 -0
- package/dist/{client → transaction/resources}/writeOptionsSchema.d.ts +2 -6
- package/dist/{client → transaction/resources}/writeOptionsSchema.js +9 -5
- package/dist/{schema → transaction/schema}/field.d.ts +17 -23
- package/dist/{schema → transaction/schema}/field.js +5 -5
- package/dist/transaction/schema/fieldRef.d.ts +38 -0
- package/dist/transaction/schema/fieldRef.js +11 -0
- package/dist/transaction/schema/loadStrategy.d.ts +45 -0
- package/dist/transaction/schema/loadStrategy.js +46 -0
- package/dist/{schema → transaction/schema}/model.d.ts +50 -35
- package/dist/{schema → transaction/schema}/model.js +30 -20
- package/dist/transaction/schema/openapi.d.ts +58 -0
- package/dist/transaction/schema/openapi.js +501 -0
- package/dist/{schema → transaction/schema}/relation.d.ts +21 -16
- package/dist/{schema → transaction/schema}/relation.js +7 -7
- package/dist/{schema → transaction/schema}/residency.d.ts +0 -9
- package/dist/{schema → transaction/schema}/residency.js +0 -5
- package/dist/{schema → transaction/schema}/roles.d.ts +5 -5
- package/dist/{schema → transaction/schema}/roles.js +5 -5
- package/dist/{schema → transaction/schema}/schema.d.ts +39 -10
- package/dist/{schema → transaction/schema}/schema.js +24 -3
- package/dist/{schema → transaction/schema}/tenancy.d.ts +1 -1
- package/dist/{schema → transaction/schema}/tenancy.js +7 -4
- package/dist/transaction/transactionLayer.d.ts +82 -0
- package/dist/transaction/transactionLayer.js +24 -0
- package/dist/{transactions → transaction/transactions/settlement}/commitEnvelope.d.ts +5 -6
- package/dist/{transactions → transaction/transactions/settlement}/commitEnvelope.js +9 -13
- package/dist/{transactions → transaction/transactions/settlement}/httpCommitEnvelope.d.ts +9 -2
- package/dist/{transactions → transaction/transactions/settlement}/httpCommitEnvelope.js +5 -9
- package/dist/{transactions/durableWriteStore.d.ts → transaction/transactions/settlement/pendingWrite.d.ts} +11 -37
- package/dist/transaction/transactions/settlement/pendingWrite.js +20 -0
- package/dist/transaction/transport/commitFrames.d.ts +90 -0
- package/dist/transaction/transport/commitFrames.js +134 -0
- package/dist/transaction/transport/connectionManager.d.ts +215 -0
- package/dist/transaction/transport/connectionManager.js +673 -0
- package/dist/transaction/transport/credentialLifecycle.d.ts +177 -0
- package/dist/transaction/transport/credentialLifecycle.js +324 -0
- package/dist/{sync → transaction/transport}/heartbeat.d.ts +3 -1
- package/dist/{sync → transaction/transport}/heartbeat.js +6 -4
- package/dist/transaction/transport/httpClient.d.ts +131 -0
- package/dist/{client → transaction/transport}/httpClient.js +6 -5
- package/dist/transaction/transport/httpOptions.d.ts +33 -0
- package/dist/transaction/transport/httpOptions.js +12 -0
- package/dist/{client → transaction/transport}/httpTransport.js +295 -97
- package/dist/{sync/NetworkProbe.d.ts → transaction/transport/networkProbe.d.ts} +7 -4
- package/dist/{sync/NetworkProbe.js → transaction/transport/networkProbe.js} +14 -13
- package/dist/transaction/transport/wsFrameHandlers.d.ts +128 -0
- package/dist/transaction/transport/wsFrameHandlers.js +429 -0
- package/dist/transaction/transport/wsTransport.d.ts +574 -0
- package/dist/transaction/transport/wsTransport.js +1023 -0
- package/dist/transaction/types/assertExact.d.ts +17 -0
- package/dist/transaction/types/assertExact.js +1 -0
- package/dist/{types → transaction/types}/global.d.ts +17 -2
- package/dist/{types → transaction/types}/global.js +2 -1
- package/dist/{types → transaction/types}/index.d.ts +14 -46
- package/dist/{types → transaction/types}/index.js +7 -16
- package/dist/{types → transaction/types}/streams.d.ts +73 -45
- package/dist/transaction/utils/duration.d.ts +50 -0
- package/dist/{utils → transaction/utils}/duration.js +32 -0
- package/dist/{utils → transaction/utils}/json.d.ts +18 -0
- package/dist/transaction/utils/json.js +276 -0
- package/dist/transaction/wire/accountResponses.d.ts +420 -0
- package/dist/transaction/wire/accountResponses.js +290 -0
- package/dist/transaction/wire/auth.d.ts +56 -0
- package/dist/transaction/wire/auth.js +63 -0
- package/dist/transaction/wire/claimEvent.d.ts +76 -0
- package/dist/transaction/wire/claimEvent.js +73 -0
- package/dist/transaction/wire/claims.d.ts +530 -0
- package/dist/transaction/wire/claims.js +327 -0
- package/dist/{wire → transaction/wire}/commit.d.ts +125 -193
- package/dist/{wire → transaction/wire}/commit.js +68 -47
- package/dist/{wire → transaction/wire}/delta.d.ts +66 -17
- package/dist/{wire → transaction/wire}/delta.js +37 -13
- package/dist/transaction/wire/errorEnvelope.d.ts +72 -0
- package/dist/{wire → transaction/wire}/errorEnvelope.js +36 -5
- package/dist/transaction/wire/feedCursor.d.ts +60 -0
- package/dist/transaction/wire/feedCursor.js +82 -0
- package/dist/transaction/wire/feedEvent.d.ts +204 -0
- package/dist/transaction/wire/feedEvent.js +65 -0
- package/dist/transaction/wire/frames.d.ts +194 -0
- package/dist/transaction/wire/frames.js +50 -0
- package/dist/transaction/wire/inboundFrames.d.ts +562 -0
- package/dist/transaction/wire/inboundFrames.js +116 -0
- package/dist/transaction/wire/index.d.ts +54 -0
- package/dist/transaction/wire/index.js +83 -0
- package/dist/{wire → transaction/wire}/listEnvelope.d.ts +13 -14
- package/dist/transaction/wire/listEnvelope.js +42 -0
- package/dist/transaction/wire/modelMutations.d.ts +31 -0
- package/dist/transaction/wire/modelMutations.js +52 -0
- package/dist/transaction/wire/modelResponses.d.ts +85 -0
- package/dist/transaction/wire/modelResponses.js +43 -0
- package/dist/transaction/wire/modelShape.d.ts +78 -0
- package/dist/transaction/wire/modelShape.js +74 -0
- package/dist/transactions/{TransactionQueue.d.ts → mutations/MutationQueue.d.ts} +85 -38
- package/dist/transactions/{TransactionQueue.js → mutations/MutationQueue.js} +141 -80
- package/dist/transactions/{TransactionStore.d.ts → mutations/MutationStore.d.ts} +8 -8
- package/dist/transactions/{TransactionStore.js → mutations/MutationStore.js} +2 -2
- package/dist/transactions/{coalesceRules.d.ts → mutations/coalesceRules.d.ts} +10 -10
- package/dist/transactions/{coalesceRules.js → mutations/coalesceRules.js} +1 -1
- package/dist/transactions/mutations/commitLatency.d.ts +52 -0
- package/dist/transactions/mutations/commitLatency.js +130 -0
- package/dist/transactions/{commitOutboxStore.d.ts → mutations/commitOutboxStore.d.ts} +1 -5
- package/dist/transactions/{commitOutboxStore.js → mutations/commitOutboxStore.js} +1 -1
- package/dist/transactions/{commitPayload.d.ts → mutations/commitPayload.d.ts} +18 -16
- package/dist/transactions/{commitPayload.js → mutations/commitPayload.js} +15 -15
- package/dist/transactions/{deltaConfirmation.d.ts → mutations/deltaConfirmation.d.ts} +15 -11
- package/dist/transactions/{deltaConfirmation.js → mutations/deltaConfirmation.js} +14 -12
- package/dist/transactions/mutations/durableWriteStore.d.ts +14 -0
- package/dist/transactions/mutations/durableWriteStore.js +12 -0
- package/dist/transactions/{optimisticApply.d.ts → mutations/optimisticApply.d.ts} +7 -7
- package/dist/transactions/{replayValidation.d.ts → mutations/replayValidation.d.ts} +4 -3
- package/dist/transactions/{replayValidation.js → mutations/replayValidation.js} +7 -5
- package/dist/utils/mobxSetup.d.ts +1 -1
- package/dist/utils/mobxSetup.js +5 -2
- package/dist/{core → views}/QueryView.d.ts +2 -2
- package/dist/{core → views}/QueryView.js +2 -2
- package/dist/{core → views}/ViewRegistry.d.ts +1 -1
- package/dist/{core/queryUtils.d.ts → views/incrementalView.d.ts} +6 -6
- package/dist/{core/queryUtils.js → views/incrementalView.js} +6 -6
- package/dist/webhooks/events.d.ts +2 -2
- package/dist/wire/index.d.ts +1 -34
- package/dist/wire/index.js +8 -49
- package/docs/agent-messaging.md +3 -3
- package/docs/agents.md +20 -13
- package/docs/api-keys.md +14 -10
- package/docs/api.md +27 -61
- package/docs/audit.md +6 -3
- package/docs/cli.md +41 -13
- package/docs/client-behavior.md +11 -9
- package/docs/concurrency-convention.md +49 -57
- package/docs/coordination.md +283 -121
- package/docs/data-sources.md +7 -5
- package/docs/debugging.md +39 -15
- package/docs/deployment.md +267 -0
- package/docs/examples/agent-human.md +49 -42
- package/docs/examples/ai-sdk-tool.md +69 -44
- package/docs/examples/existing-python-backend.md +8 -6
- package/docs/examples/nextjs.md +129 -47
- package/docs/examples/scoped-agent.md +46 -45
- package/docs/examples/server-agent.md +46 -26
- package/docs/groups.md +87 -30
- package/docs/guarantees.md +41 -12
- package/docs/how-it-works.md +38 -12
- package/docs/idempotency.md +126 -0
- package/docs/identity.md +77 -74
- package/docs/index.md +172 -86
- package/docs/integration-guide.md +31 -19
- package/docs/mcp.md +46 -21
- package/docs/migration.md +95 -18
- package/docs/operating-on-your-database.md +3 -1
- package/docs/projects.md +3 -1
- package/docs/quickstart.md +22 -5
- package/docs/react.md +31 -18
- package/docs/schema-contract.md +5 -3
- package/docs/session-settings.md +108 -0
- package/docs/sessions.md +4 -2
- package/docs/webhooks.md +12 -10
- package/llms.txt +48 -18
- package/package.json +21 -26
- package/dist/agent/Agent.d.ts +0 -366
- package/dist/agent/Agent.js +0 -514
- package/dist/agent/index.d.ts +0 -115
- package/dist/agent/index.js +0 -128
- package/dist/agent/session.d.ts +0 -93
- package/dist/agent/session.js +0 -149
- package/dist/agent/types.d.ts +0 -68
- package/dist/agent/types.js +0 -9
- package/dist/cli.cjs +0 -286329
- package/dist/client/durableWrites.d.ts +0 -21
- package/dist/client/httpClient.d.ts +0 -80
- package/dist/coordination/schema.d.ts +0 -722
- package/dist/coordination/schema.js +0 -578
- package/dist/schema/openapi.d.ts +0 -29
- package/dist/schema/openapi.js +0 -124
- package/dist/testing/fixtures/bootstrap.d.ts +0 -49
- package/dist/testing/fixtures/bootstrap.js +0 -59
- package/dist/testing/fixtures/deltas.d.ts +0 -83
- package/dist/testing/fixtures/deltas.js +0 -136
- package/dist/testing/fixtures/models.d.ts +0 -83
- package/dist/testing/fixtures/models.js +0 -272
- package/dist/testing/helpers/reactWrapper.d.ts +0 -69
- package/dist/testing/helpers/reactWrapper.js +0 -67
- package/dist/testing/helpers/syncEngineHarness.d.ts +0 -54
- package/dist/testing/helpers/syncEngineHarness.js +0 -73
- package/dist/testing/helpers/wait.d.ts +0 -30
- package/dist/testing/helpers/wait.js +0 -49
- package/dist/testing/index.d.ts +0 -23
- package/dist/testing/index.js +0 -33
- package/dist/testing/mocks/FakeDatabase.d.ts +0 -18
- package/dist/testing/mocks/FakeDatabase.js +0 -10
- package/dist/testing/mocks/MockMutationExecutor.d.ts +0 -87
- package/dist/testing/mocks/MockMutationExecutor.js +0 -192
- package/dist/testing/mocks/MockNetworkMonitor.d.ts +0 -20
- package/dist/testing/mocks/MockNetworkMonitor.js +0 -46
- package/dist/testing/mocks/MockSyncContext.d.ts +0 -51
- package/dist/testing/mocks/MockSyncContext.js +0 -71
- package/dist/testing/mocks/MockSyncStore.d.ts +0 -88
- package/dist/testing/mocks/MockSyncStore.js +0 -171
- package/dist/testing/mocks/MockWebSocket.d.ts +0 -71
- package/dist/testing/mocks/MockWebSocket.js +0 -118
- package/dist/transactions/durableWriteStore.js +0 -30
- package/dist/utils/duration.d.ts +0 -25
- package/dist/utils/json.js +0 -88
- package/dist/wire/errorEnvelope.d.ts +0 -55
- package/dist/wire/frames.d.ts +0 -197
- package/dist/wire/frames.js +0 -49
- package/dist/wire/listEnvelope.js +0 -18
- package/docs/interaction-model.md +0 -97
- /package/dist/{core → query}/QueryProcessor.d.ts +0 -0
- /package/dist/{core → query}/QueryProcessor.js +0 -0
- /package/dist/{core/storeContract.js → storeContract.js} +0 -0
- /package/dist/{core → stores}/openIDBWithTimeout.d.ts +0 -0
- /package/dist/{core → stores}/openIDBWithTimeout.js +0 -0
- /package/dist/{client → transaction/auth}/credentialEndpoint.d.ts +0 -0
- /package/dist/{client → transaction/auth}/credentialEndpoint.js +0 -0
- /package/dist/{auth → transaction/auth}/credentialPolicy.d.ts +0 -0
- /package/dist/{auth → transaction/auth}/credentialPolicy.js +0 -0
- /package/dist/{auth → transaction/auth}/credentialSource.js +0 -0
- /package/dist/{client → transaction/auth}/hostedEndpoints.d.ts +0 -0
- /package/dist/{client → transaction/auth}/hostedEndpoints.js +0 -0
- /package/dist/{client → transaction}/persistence.d.ts +0 -0
- /package/dist/{client → transaction}/persistence.js +0 -0
- /package/dist/{client → transaction/resources}/functionalUpdate.d.ts +0 -0
- /package/dist/{client → transaction/resources}/functionalUpdate.js +0 -0
- /package/dist/{transactions → transaction/transactions/settlement}/idempotencyKey.d.ts +0 -0
- /package/dist/{transactions → transaction/transactions/settlement}/idempotencyKey.js +0 -0
- /package/dist/{client → transaction/transport}/httpTransport.d.ts +0 -0
- /package/dist/{types → transaction/types}/modelData.d.ts +0 -0
- /package/dist/{types → transaction/types}/modelData.js +0 -0
- /package/dist/{types → transaction/types}/participant.d.ts +0 -0
- /package/dist/{types → transaction/types}/participant.js +0 -0
- /package/dist/{types → transaction/types}/streams.js +0 -0
- /package/dist/{utils → transaction/utils}/asyncIterator.d.ts +0 -0
- /package/dist/{utils → transaction/utils}/asyncIterator.js +0 -0
- /package/dist/{wire → transaction/wire}/bootstrapReason.d.ts +0 -0
- /package/dist/{wire → transaction/wire}/bootstrapReason.js +0 -0
- /package/dist/{wire → transaction/wire}/protocol.d.ts +0 -0
- /package/dist/{wire → transaction/wire}/protocol.js +0 -0
- /package/dist/{wire → transaction/wire}/protocolVersion.d.ts +0 -0
- /package/dist/{wire → transaction/wire}/protocolVersion.js +0 -0
- /package/dist/transactions/{UnconfirmedWrites.d.ts → mutations/UnconfirmedWrites.d.ts} +0 -0
- /package/dist/transactions/{UnconfirmedWrites.js → mutations/UnconfirmedWrites.js} +0 -0
- /package/dist/transactions/{optimisticApply.js → mutations/optimisticApply.js} +0 -0
- /package/dist/{core → views}/ViewRegistry.js +0 -0
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* If the owner rolls back, the waiter acquires the reservation and performs the
|
|
17
17
|
* mutation. This gives same-key concurrency one database arbiter and one effect.
|
|
18
18
|
*/
|
|
19
|
-
import type { Schema, SchemaRecord } from '../../schema/schema.js';
|
|
19
|
+
import type { Schema, SchemaRecord } from '../../transaction/schema/schema.js';
|
|
20
20
|
import type { DataSourceAdapter, MutationAdapter } from '../adapter.js';
|
|
21
21
|
import { type KyselyLike, type KyselyMutationCore } from './kyselyMutationCore.js';
|
|
22
22
|
export { createKyselyMutationCore, kyselyOperationRowId, type KyselyCompiledQuery, type KyselyDeleteBuilder, type KyselyInsertBuilder, type KyselyInsertValuesBuilder, type KyselyLike, type KyselyMutationCore, type KyselyReturningExecutable, type KyselySelectBuilder, type KyselyTransactionBuilder, type KyselyUpdateBuilder, type KyselyUpdateSetBuilder, } from './kyselyMutationCore.js';
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* If the owner rolls back, the waiter acquires the reservation and performs the
|
|
17
17
|
* mutation. This gives same-key concurrency one database arbiter and one effect.
|
|
18
18
|
*/
|
|
19
|
-
import { AbloValidationError } from '../../errors.js';
|
|
19
|
+
import { AbloValidationError } from '../../transaction/errors.js';
|
|
20
20
|
import { changeSetSchema, outboxEventSchema, sourceCommitEchoMarkerSchema, } from '../contract.js';
|
|
21
21
|
import { assertSourceIdempotencyIntent, assertSourceIdempotencyRetention, sourceChangeIntentHash, SOURCE_IDEMPOTENCY_RETENTION, } from '../idempotency.js';
|
|
22
22
|
import { adapterTableMigrations, idempotencyLedgerMigrations, } from '../migrations.js';
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* the same `applyOperation` implementation, so direct and endpoint DML cannot
|
|
8
8
|
* drift into separate hand-written mappers.
|
|
9
9
|
*/
|
|
10
|
-
import type { Schema, SchemaRecord } from '../../schema/schema.js';
|
|
10
|
+
import type { Schema, SchemaRecord } from '../../transaction/schema/schema.js';
|
|
11
11
|
import type { AdapterReadRequest, Row } from '../adapter.js';
|
|
12
12
|
import type { Operation } from '../contract.js';
|
|
13
13
|
/** The subset of a Kysely instance, or transaction handle, used by the core. */
|
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
* the same `applyOperation` implementation, so direct and endpoint DML cannot
|
|
8
8
|
* drift into separate hand-written mappers.
|
|
9
9
|
*/
|
|
10
|
-
import { AbloValidationError } from '../../errors.js';
|
|
10
|
+
import { AbloValidationError } from '../../transaction/errors.js';
|
|
11
11
|
import { toSchemaJSON } from '../../schema/serialize.js';
|
|
12
12
|
import { camelToSnake, snakeToCamel } from '../../schema/ddl.js';
|
|
13
|
-
import { tenancyColumn } from '../../schema/tenancy.js';
|
|
13
|
+
import { tenancyColumn } from '../../transaction/schema/tenancy.js';
|
|
14
14
|
function buildColumnMaps(schema) {
|
|
15
15
|
const json = toSchemaJSON(schema);
|
|
16
16
|
const out = new Map();
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* idempotency ledger keyed by scoped correlation, and an append-only outbox with a
|
|
10
10
|
* monotonic cursor.
|
|
11
11
|
*/
|
|
12
|
-
import { AbloValidationError } from '../../errors.js';
|
|
12
|
+
import { AbloValidationError } from '../../transaction/errors.js';
|
|
13
13
|
import { assertSourceIdempotencyIntent, sourceChangeIntentHash, } from '../idempotency.js';
|
|
14
14
|
function rowId(op) {
|
|
15
15
|
const id = op.id ?? op.input?.id;
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* call site.
|
|
15
15
|
*/
|
|
16
16
|
import type { DataSourceAdapter, Row } from '../adapter.js';
|
|
17
|
-
import type { SchemaRecord, Schema } from '../../schema/schema.js';
|
|
17
|
+
import type { SchemaRecord, Schema } from '../../transaction/schema/schema.js';
|
|
18
18
|
/** A Prisma model delegate — the subset of its methods the adapter calls. */
|
|
19
19
|
export interface PrismaDelegate {
|
|
20
20
|
findUnique(args: {
|
|
@@ -47,9 +47,14 @@ export interface PrismaRaw {
|
|
|
47
47
|
$executeRawUnsafe(query: string, ...values: unknown[]): Promise<number>;
|
|
48
48
|
$queryRawUnsafe<T = unknown>(query: string, ...values: unknown[]): Promise<T>;
|
|
49
49
|
}
|
|
50
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* A Prisma client as a structural shape that needs no `@prisma/client` import.
|
|
52
|
+
* The interactive-transaction callback receives only {@link PrismaRaw}: Prisma's
|
|
53
|
+
* own tx client strips `$transaction` (no nesting), so requiring it there made
|
|
54
|
+
* a real `PrismaClient` unassignable to this shape.
|
|
55
|
+
*/
|
|
51
56
|
export interface PrismaLike extends PrismaRaw {
|
|
52
|
-
$transaction<T>(fn: (tx:
|
|
57
|
+
$transaction<T>(fn: (tx: PrismaRaw) => Promise<T>): Promise<T>;
|
|
53
58
|
}
|
|
54
59
|
export interface PrismaDataSourceOptions {
|
|
55
60
|
/** Map a schema model name → its Prisma delegate name. Default: lower-first-letter. */
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* be tested with a fake, while a real `PrismaClient` satisfies the shape at the
|
|
14
14
|
* call site.
|
|
15
15
|
*/
|
|
16
|
-
import { AbloValidationError } from '../../errors.js';
|
|
16
|
+
import { AbloValidationError } from '../../transaction/errors.js';
|
|
17
17
|
import { outboxEventSchema } from '../contract.js';
|
|
18
18
|
import { adapterTableMigrations } from '../migrations.js';
|
|
19
19
|
import { assertSourceIdempotencyIntent, assertSourceIdempotencyRetention, SOURCE_IDEMPOTENCY_RETENTION, sourceChangeIntentHash, } from '../idempotency.js';
|
package/dist/source/connector.js
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
* the trust model does not.
|
|
25
25
|
*/
|
|
26
26
|
import { SOURCE_CONNECTOR_PROTOCOL_VERSION, SOURCE_CONNECTOR_WS_PATH, sourceConnectorSubprotocols, encodeFrame, decodeFrame, ConnectorProtocolError, } from './connectorProtocol.js';
|
|
27
|
-
import { ABLO_HOSTED_HTTP_BASE_URL } from '../
|
|
27
|
+
import { ABLO_HOSTED_HTTP_BASE_URL } from '../transaction/auth/hostedEndpoints.js';
|
|
28
28
|
/**
|
|
29
29
|
* The default Ablo base URL the connector dials, to which it appends
|
|
30
30
|
* `SOURCE_CONNECTOR_WS_PATH`.
|
|
@@ -64,10 +64,7 @@ export declare const readyFrameSchema: z.ZodObject<{
|
|
|
64
64
|
protocolVersion: z.ZodNumber;
|
|
65
65
|
sourceId: z.ZodOptional<z.ZodString>;
|
|
66
66
|
organizationId: z.ZodOptional<z.ZodString>;
|
|
67
|
-
environment: z.ZodOptional<z.
|
|
68
|
-
production: "production";
|
|
69
|
-
sandbox: "sandbox";
|
|
70
|
-
}>>;
|
|
67
|
+
environment: z.ZodOptional<z.ZodString>;
|
|
71
68
|
}, z.core.$strip>;
|
|
72
69
|
export type ReadyFrame = z.infer<typeof readyFrameSchema>;
|
|
73
70
|
/**
|
|
@@ -120,10 +117,7 @@ export declare const connectorFrameSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
|
|
|
120
117
|
protocolVersion: z.ZodNumber;
|
|
121
118
|
sourceId: z.ZodOptional<z.ZodString>;
|
|
122
119
|
organizationId: z.ZodOptional<z.ZodString>;
|
|
123
|
-
environment: z.ZodOptional<z.
|
|
124
|
-
production: "production";
|
|
125
|
-
sandbox: "sandbox";
|
|
126
|
-
}>>;
|
|
120
|
+
environment: z.ZodOptional<z.ZodString>;
|
|
127
121
|
}, z.core.$strip>, z.ZodObject<{
|
|
128
122
|
type: z.ZodLiteral<"request">;
|
|
129
123
|
id: z.ZodString;
|
|
@@ -20,7 +20,8 @@
|
|
|
20
20
|
* sides infer every wire type from one schema so they cannot silently drift.
|
|
21
21
|
*/
|
|
22
22
|
import { z } from 'zod';
|
|
23
|
-
import {
|
|
23
|
+
import { environmentSchema } from '../transaction/environment.js';
|
|
24
|
+
import { WS_BEARER_SUBPROTOCOL_PREFIX } from '../transaction/auth/credentialSource.js';
|
|
24
25
|
/**
|
|
25
26
|
* The wire-protocol version. It increases on any breaking change to a frame's
|
|
26
27
|
* shape, so a connector and server on mismatched versions fail fast during
|
|
@@ -71,7 +72,7 @@ export const readyFrameSchema = z.object({
|
|
|
71
72
|
protocolVersion: z.number().int(),
|
|
72
73
|
sourceId: z.string().optional(),
|
|
73
74
|
organizationId: z.string().optional(),
|
|
74
|
-
environment:
|
|
75
|
+
environment: environmentSchema.optional(),
|
|
75
76
|
});
|
|
76
77
|
/**
|
|
77
78
|
* A single load, list, or commit request the server forwards to the connector.
|
|
@@ -6,14 +6,20 @@
|
|
|
6
6
|
* one schema that validates it.
|
|
7
7
|
*
|
|
8
8
|
* These schemas describe the adapter's own contract: the change set it commits,
|
|
9
|
-
* the outbox row it stores, and the table migrations it ships.
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
9
|
+
* the outbox row it stores, and the table migrations it ships. The operation
|
|
10
|
+
* vocabulary is not restated here — `operationSchema` is projected from the
|
|
11
|
+
* core's `commitOperationSchema`, so an action or field added to the commit
|
|
12
|
+
* contract reaches a data source by construction. The assertion at the end of
|
|
13
|
+
* this file then pins the published `SourceOperation` interface to that
|
|
14
|
+
* projection, which is what keeps the interface tied to the core rather than
|
|
15
|
+
* merely tied to a second local copy of it.
|
|
14
16
|
*/
|
|
15
17
|
import { z } from 'zod';
|
|
16
|
-
/**
|
|
18
|
+
/**
|
|
19
|
+
* Served, not mirrored. The commit vocabulary is declared once in the core; a
|
|
20
|
+
* data source speaks the same five actions, so it re-exports them rather than
|
|
21
|
+
* listing them again under a second name.
|
|
22
|
+
*/
|
|
17
23
|
export declare const operationTypeSchema: z.ZodEnum<{
|
|
18
24
|
CREATE: "CREATE";
|
|
19
25
|
UPDATE: "UPDATE";
|
|
@@ -23,9 +29,15 @@ export declare const operationTypeSchema: z.ZodEnum<{
|
|
|
23
29
|
}>;
|
|
24
30
|
export type OperationType = z.infer<typeof operationTypeSchema>;
|
|
25
31
|
/**
|
|
26
|
-
* A single operation within a change set, and the runtime validator for it.
|
|
27
|
-
*
|
|
28
|
-
*
|
|
32
|
+
* A single operation within a change set, and the runtime validator for it.
|
|
33
|
+
*
|
|
34
|
+
* The field set is projected from `commitOperationSchema` — an operation
|
|
35
|
+
* reaching a data source is a commit operation minus the two fields the core
|
|
36
|
+
* settles internally (`bypass`, `fenceToken`). The two `min(1)` overrides are
|
|
37
|
+
* deliberate and local: this is a customer-implemented boundary, so an empty
|
|
38
|
+
* model name or row id is rejected here rather than forwarded. Stating them as
|
|
39
|
+
* an extension keeps the tightening visible as a choice instead of hiding it
|
|
40
|
+
* inside a second copy of the shape.
|
|
29
41
|
*/
|
|
30
42
|
export declare const operationSchema: z.ZodObject<{
|
|
31
43
|
type: z.ZodEnum<{
|
|
@@ -35,16 +47,16 @@ export declare const operationSchema: z.ZodObject<{
|
|
|
35
47
|
ARCHIVE: "ARCHIVE";
|
|
36
48
|
UNARCHIVE: "UNARCHIVE";
|
|
37
49
|
}>;
|
|
38
|
-
model: z.ZodString;
|
|
39
|
-
id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
40
|
-
input: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
41
|
-
transactionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
42
50
|
readAt: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
43
51
|
onStale: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
44
52
|
reject: "reject";
|
|
45
53
|
overwrite: "overwrite";
|
|
46
54
|
notify: "notify";
|
|
47
55
|
}>>>;
|
|
56
|
+
transactionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
57
|
+
model: z.ZodString;
|
|
58
|
+
id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
59
|
+
input: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
48
60
|
}, z.core.$strip>;
|
|
49
61
|
export type Operation = z.infer<typeof operationSchema>;
|
|
50
62
|
/** The supported customer-transaction echo mechanism. */
|
|
@@ -92,16 +104,16 @@ export declare const changeSetSchema: z.ZodObject<{
|
|
|
92
104
|
ARCHIVE: "ARCHIVE";
|
|
93
105
|
UNARCHIVE: "UNARCHIVE";
|
|
94
106
|
}>;
|
|
95
|
-
model: z.ZodString;
|
|
96
|
-
id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
97
|
-
input: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
98
|
-
transactionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
99
107
|
readAt: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
100
108
|
onStale: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
101
109
|
reject: "reject";
|
|
102
110
|
overwrite: "overwrite";
|
|
103
111
|
notify: "notify";
|
|
104
112
|
}>>>;
|
|
113
|
+
transactionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
114
|
+
model: z.ZodString;
|
|
115
|
+
id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
116
|
+
input: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
105
117
|
}, z.core.$strip>>;
|
|
106
118
|
correlationId: z.ZodString;
|
|
107
119
|
intentHash: z.ZodOptional<z.ZodString>;
|
package/dist/source/contract.js
CHANGED
|
@@ -6,37 +6,42 @@
|
|
|
6
6
|
* one schema that validates it.
|
|
7
7
|
*
|
|
8
8
|
* These schemas describe the adapter's own contract: the change set it commits,
|
|
9
|
-
* the outbox row it stores, and the table migrations it ships.
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
9
|
+
* the outbox row it stores, and the table migrations it ships. The operation
|
|
10
|
+
* vocabulary is not restated here — `operationSchema` is projected from the
|
|
11
|
+
* core's `commitOperationSchema`, so an action or field added to the commit
|
|
12
|
+
* contract reaches a data source by construction. The assertion at the end of
|
|
13
|
+
* this file then pins the published `SourceOperation` interface to that
|
|
14
|
+
* projection, which is what keeps the interface tied to the core rather than
|
|
15
|
+
* merely tied to a second local copy of it.
|
|
14
16
|
*/
|
|
15
17
|
import { z } from 'zod';
|
|
16
|
-
import { correlationIdSchema } from '../wire/commit.js';
|
|
18
|
+
import { correlationIdSchema } from '../transaction/wire/commit.js';
|
|
19
|
+
import { commitOperationSchema, commitOperationTypeSchema, } from '../transaction/coordination/schema.js';
|
|
17
20
|
import { ABLO_SOURCE_CLIENT_TX_ID_MAX_LENGTH, ABLO_SOURCE_ECHO_MAX_OPERATIONS, ABLO_SOURCE_ECHO_MAX_PAYLOAD_BYTES, } from './types.js';
|
|
18
21
|
const jsonObject = z.record(z.string(), z.unknown());
|
|
19
|
-
/** Mirrors `SourceOperation['type']`. */
|
|
20
|
-
export const operationTypeSchema = z.enum([
|
|
21
|
-
'CREATE',
|
|
22
|
-
'UPDATE',
|
|
23
|
-
'DELETE',
|
|
24
|
-
'ARCHIVE',
|
|
25
|
-
'UNARCHIVE',
|
|
26
|
-
]);
|
|
27
22
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
23
|
+
* Served, not mirrored. The commit vocabulary is declared once in the core; a
|
|
24
|
+
* data source speaks the same five actions, so it re-exports them rather than
|
|
25
|
+
* listing them again under a second name.
|
|
31
26
|
*/
|
|
32
|
-
export const
|
|
33
|
-
|
|
27
|
+
export const operationTypeSchema = commitOperationTypeSchema;
|
|
28
|
+
/**
|
|
29
|
+
* A single operation within a change set, and the runtime validator for it.
|
|
30
|
+
*
|
|
31
|
+
* The field set is projected from `commitOperationSchema` — an operation
|
|
32
|
+
* reaching a data source is a commit operation minus the two fields the core
|
|
33
|
+
* settles internally (`bypass`, `fenceToken`). The two `min(1)` overrides are
|
|
34
|
+
* deliberate and local: this is a customer-implemented boundary, so an empty
|
|
35
|
+
* model name or row id is rejected here rather than forwarded. Stating them as
|
|
36
|
+
* an extension keeps the tightening visible as a choice instead of hiding it
|
|
37
|
+
* inside a second copy of the shape.
|
|
38
|
+
*/
|
|
39
|
+
export const operationSchema = commitOperationSchema
|
|
40
|
+
.omit({ bypass: true, fenceToken: true })
|
|
41
|
+
.extend({
|
|
34
42
|
model: z.string().min(1),
|
|
35
43
|
id: z.string().min(1).nullish(),
|
|
36
44
|
input: jsonObject.nullish(),
|
|
37
|
-
transactionId: z.string().nullish(),
|
|
38
|
-
readAt: z.number().nullish(),
|
|
39
|
-
onStale: z.enum(['reject', 'overwrite', 'notify']).nullish(),
|
|
40
45
|
});
|
|
41
46
|
/** The supported customer-transaction echo mechanism. */
|
|
42
47
|
export const sourceCommitEchoSchema = z.object({
|
package/dist/source/factory.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* enforces the per-key scopes, and routes the four wire operations (`load`,
|
|
6
6
|
* `list`, `commit`, and `events`) to whichever handlers you configured.
|
|
7
7
|
*/
|
|
8
|
-
import type { Schema, SchemaRecord, InferCreate } from '../schema/schema.js';
|
|
8
|
+
import type { Schema, SchemaRecord, InferCreate } from '../transaction/schema/schema.js';
|
|
9
9
|
import type { DataSourceAdapter } from './adapter.js';
|
|
10
10
|
import type { SourceApiKey, SourceAuthorizeContext, SourceCommitHandler, SourceEventsHandler, SourceModelHandlers, SourceRequest, SourceScope } from './types.js';
|
|
11
11
|
type SourceModels<S extends SchemaRecord, TAuth> = Partial<{
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { createHash } from 'node:crypto';
|
|
13
13
|
import { z } from 'zod';
|
|
14
|
-
import { AbloValidationError } from '../errors.js';
|
|
15
|
-
import { COMMIT_CORRELATION_ID_MAX_LENGTH, correlationIdSchema, } from '../wire/commit.js';
|
|
14
|
+
import { AbloValidationError } from '../transaction/errors.js';
|
|
15
|
+
import { COMMIT_CORRELATION_ID_MAX_LENGTH, correlationIdSchema, } from '../transaction/wire/commit.js';
|
|
16
16
|
const SOURCE_ECHO_TRANSACTION_ID_PREFIX = 'ablo_echo_tx_v1:';
|
|
17
17
|
const sourceOperationTransactionIdSchema = z
|
|
18
18
|
.string()
|
package/dist/source/index.d.ts
CHANGED
|
@@ -20,3 +20,4 @@ export { prismaDataSource, type PrismaLike, type PrismaDataSourceOptions } from
|
|
|
20
20
|
export { adapterTableMigrations, endpointOutboxMigrations, idempotencyLedgerMigrations, } from './migrations.js';
|
|
21
21
|
export { createKyselyMutationAdapter, createKyselyMutationCore, kyselyDataSource, kyselyDirectMutation, kyselyOperationRowId, type KyselyCompiledQuery, type KyselyDeleteBuilder, type KyselyInsertBuilder, type KyselyInsertValuesBuilder, type KyselyLike, type KyselyMutationCore, type KyselyReturningExecutable, type KyselySelectBuilder, type KyselyTransactionBuilder, type KyselyUpdateBuilder, type KyselyUpdateSetBuilder, } from './adapters/kysely.js';
|
|
22
22
|
export { sourceOperationsIntentHash, sourceChangeIntentHash, assertSourceIdempotencyIntent, assertSourceIdempotencyRetention, sourceEchoTransactionIdSchema, encodeSourceEchoTransactionId, decodeSourceEchoTransactionId, type SourceEchoTransactionId, } from './idempotency.js';
|
|
23
|
+
export { ABLO_FOOTPRINT, ABLO_PUBLICATION, ABLO_REPLICATION_SLOT, ABLO_REPLICATION_ROLE, ABLO_WRITE_ROLE, ABLO_IDEMPOTENCY_TABLE, ABLO_OUTBOX_TABLE, REPLICATION_SLOT_NAME, isValidReplicationSlotName, footprintNamesFor, type FootprintArtifact, type FootprintKind, type FootprintNames, type FootprintPlane, } from '../transaction/footprint.js';
|
package/dist/source/index.js
CHANGED
|
@@ -25,3 +25,6 @@ export { prismaDataSource } from './adapters/prisma.js';
|
|
|
25
25
|
export { adapterTableMigrations, endpointOutboxMigrations, idempotencyLedgerMigrations, } from './migrations.js';
|
|
26
26
|
export { createKyselyMutationAdapter, createKyselyMutationCore, kyselyDataSource, kyselyDirectMutation, kyselyOperationRowId, } from './adapters/kysely.js';
|
|
27
27
|
export { sourceOperationsIntentHash, sourceChangeIntentHash, assertSourceIdempotencyIntent, assertSourceIdempotencyRetention, sourceEchoTransactionIdSchema, encodeSourceEchoTransactionId, decodeSourceEchoTransactionId, } from './idempotency.js';
|
|
28
|
+
// What Ablo leaves inside a customer's database, declared once — read by the
|
|
29
|
+
// setup SQL, the replication runtime, and the audit that reports it back.
|
|
30
|
+
export { ABLO_FOOTPRINT, ABLO_PUBLICATION, ABLO_REPLICATION_SLOT, ABLO_REPLICATION_ROLE, ABLO_WRITE_ROLE, ABLO_IDEMPOTENCY_TABLE, ABLO_OUTBOX_TABLE, REPLICATION_SLOT_NAME, isValidReplicationSlotName, footprintNamesFor, } from '../transaction/footprint.js';
|
package/dist/source/next.d.ts
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* For hand-written handlers, or another framework, call the core `dataSource()`
|
|
20
20
|
* directly and export its result however that framework expects.
|
|
21
21
|
*/
|
|
22
|
-
import type { SchemaRecord } from '../schema/schema.js';
|
|
22
|
+
import type { SchemaRecord } from '../transaction/schema/schema.js';
|
|
23
23
|
import { type DataSourceOptions } from './factory.js';
|
|
24
24
|
/**
|
|
25
25
|
* The options for `dataSourceNext`, which are exactly the core
|
package/dist/source/signing.d.ts
CHANGED
|
@@ -25,8 +25,15 @@ export interface SourceSignatureOptions {
|
|
|
25
25
|
}
|
|
26
26
|
/** Inputs to {@link verifyAbloSourceRequest}. */
|
|
27
27
|
export interface SourceSignatureVerificationOptions {
|
|
28
|
-
/**
|
|
29
|
-
|
|
28
|
+
/**
|
|
29
|
+
* The incoming request, whose headers carry the signature to check. Any
|
|
30
|
+
* request-shaped object works: a fetch `Request` (its `Headers` is read with
|
|
31
|
+
* `.get`), or a plain header record like Node's `req.headers` — matching
|
|
32
|
+
* what the runtime has always accepted.
|
|
33
|
+
*/
|
|
34
|
+
readonly request: {
|
|
35
|
+
readonly headers?: Headers | Record<string, string | string[] | undefined>;
|
|
36
|
+
};
|
|
30
37
|
/** The request body, which must match what was signed. */
|
|
31
38
|
readonly body: string;
|
|
32
39
|
/** The API key to verify against. */
|
package/dist/source/signing.js
CHANGED
|
@@ -43,7 +43,10 @@ function getHeader(request, name) {
|
|
|
43
43
|
return headers.get(name);
|
|
44
44
|
}
|
|
45
45
|
const record = headers;
|
|
46
|
-
|
|
46
|
+
const value = record[name] ?? record[name.toLowerCase()] ?? null;
|
|
47
|
+
// Node folds repeated headers into an array; the signature headers are
|
|
48
|
+
// single-valued, so the first entry is the one that was signed.
|
|
49
|
+
return Array.isArray(value) ? (value[0] ?? null) : value;
|
|
47
50
|
}
|
|
48
51
|
/**
|
|
49
52
|
* Parse a `webhook-signature` header per the Standard Webhooks spec.
|
package/dist/source/types.d.ts
CHANGED
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
* and context types your source implements. {@link sourceEventForOperation}
|
|
10
10
|
* builds a change-event marker from an operation.
|
|
11
11
|
*/
|
|
12
|
-
import type { Environment } from '../environment.js';
|
|
12
|
+
import type { Environment } from '../transaction/environment.js';
|
|
13
|
+
import type { CommitOperationType, OnStaleMode } from '../transaction/coordination/schema.js';
|
|
14
|
+
import type { ParticipantKind } from '../transaction/types/participant.js';
|
|
13
15
|
/** A scalar value that can appear in a source filter. */
|
|
14
16
|
export type SourcePrimitive = string | number | boolean | null;
|
|
15
17
|
/**
|
|
@@ -58,7 +60,7 @@ export type SourceListResult<Row> = readonly Row[] | SourceListPage<Row>;
|
|
|
58
60
|
*/
|
|
59
61
|
export interface SourceRequestContext {
|
|
60
62
|
readonly participantId?: string;
|
|
61
|
-
readonly participantKind?:
|
|
63
|
+
readonly participantKind?: ParticipantKind;
|
|
62
64
|
readonly organizationId?: string;
|
|
63
65
|
/** Trusted project plane selected by the authenticating credential. */
|
|
64
66
|
readonly projectId?: string;
|
|
@@ -83,13 +85,13 @@ export interface SourceRequestContext {
|
|
|
83
85
|
* do when the row changed since it was read at `readAt`.
|
|
84
86
|
*/
|
|
85
87
|
export interface SourceOperation {
|
|
86
|
-
readonly type:
|
|
88
|
+
readonly type: CommitOperationType;
|
|
87
89
|
readonly model: string;
|
|
88
90
|
readonly id?: string | null;
|
|
89
91
|
readonly input?: Record<string, unknown> | null;
|
|
90
92
|
readonly transactionId?: string | null;
|
|
91
93
|
readonly readAt?: number | null;
|
|
92
|
-
readonly onStale?:
|
|
94
|
+
readonly onStale?: OnStaleMode | null;
|
|
93
95
|
}
|
|
94
96
|
/**
|
|
95
97
|
* A computed change to one row, ready to append to the change log. Your
|
package/dist/source/types.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* and context types your source implements. {@link sourceEventForOperation}
|
|
10
10
|
* builds a change-event marker from an operation.
|
|
11
11
|
*/
|
|
12
|
-
import { AbloValidationError } from '../errors.js';
|
|
12
|
+
import { AbloValidationError } from '../transaction/errors.js';
|
|
13
13
|
/**
|
|
14
14
|
* Build the {@link SourceEvent} marker you should record in your outbox table,
|
|
15
15
|
* within the same transaction as the row change it describes.
|
|
@@ -9,11 +9,11 @@
|
|
|
9
9
|
* This module is type-only: it has no runtime imports and contributes nothing to
|
|
10
10
|
* the runtime bundle beyond the erased interface declarations.
|
|
11
11
|
*/
|
|
12
|
-
import type { Model } from '
|
|
13
|
-
import type { ModelScope } from '
|
|
14
|
-
import type { QueryView, QueryViewOptions } from './QueryView.js';
|
|
15
|
-
import type { ViewRegistry } from './ViewRegistry.js';
|
|
16
|
-
import type { ParticipantScope } from '
|
|
12
|
+
import type { Model } from './Model.js';
|
|
13
|
+
import type { ModelScope } from './transaction/types/index.js';
|
|
14
|
+
import type { QueryView, QueryViewOptions } from './views/QueryView.js';
|
|
15
|
+
import type { ViewRegistry } from './views/ViewRegistry.js';
|
|
16
|
+
import type { ParticipantScope } from './sync/participants.js';
|
|
17
17
|
/**
|
|
18
18
|
* A snapshot of the client's synchronization state, shaped for binding to UI.
|
|
19
19
|
* {@link SyncStoreContract.syncStatus} exposes a reactive instance of this, and
|
|
@@ -42,7 +42,7 @@ export interface SyncStatus {
|
|
|
42
42
|
*/
|
|
43
43
|
export interface LocalMutation {
|
|
44
44
|
type: 'create' | 'update' | 'delete' | 'archive' | 'unarchive';
|
|
45
|
-
/** The registered name of the mutated model, for example `'
|
|
45
|
+
/** The registered name of the mutated model, for example `'Block'`. */
|
|
46
46
|
modelName: string;
|
|
47
47
|
modelId: string;
|
|
48
48
|
/** The new field values, for a create or an update. */
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* then gets its own data database, named `ablo_<hash>`, that holds the synced
|
|
6
6
|
* rows. {@link DatabaseManager} creates, versions, and deletes both tiers.
|
|
7
7
|
*/
|
|
8
|
+
import type { RuntimeContext } from '../RuntimeContext.js';
|
|
8
9
|
export interface DatabaseInfo {
|
|
9
10
|
name: string;
|
|
10
11
|
userId: string;
|
|
@@ -34,9 +35,10 @@ export interface WorkspaceMetadata {
|
|
|
34
35
|
* - Provides database info and metadata management
|
|
35
36
|
*/
|
|
36
37
|
export declare class DatabaseManager {
|
|
38
|
+
private readonly runtime;
|
|
37
39
|
private metaDb;
|
|
38
40
|
private readonly metaDbName;
|
|
39
|
-
constructor();
|
|
41
|
+
constructor(runtime?: RuntimeContext);
|
|
40
42
|
/**
|
|
41
43
|
* Initialize the meta database (ablo_databases)
|
|
42
44
|
*/
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* then gets its own data database, named `ablo_<hash>`, that holds the synced
|
|
6
6
|
* rows. {@link DatabaseManager} creates, versions, and deletes both tiers.
|
|
7
7
|
*/
|
|
8
|
-
import {
|
|
8
|
+
import { globalRuntime } from '../context.js';
|
|
9
9
|
import { openIDBWithTimeout, deleteIDBWithTimeout, IDBOpenTimeoutError, } from './openIDBWithTimeout.js';
|
|
10
|
-
import { AbloConnectionError } from '../errors.js';
|
|
10
|
+
import { AbloConnectionError } from '../transaction/errors.js';
|
|
11
11
|
import { getActiveRegistry, hasActiveRegistry } from '../ModelRegistry.js';
|
|
12
12
|
/**
|
|
13
13
|
* DatabaseManager - Manages Ablo's two-tier database architecture
|
|
@@ -19,10 +19,11 @@ import { getActiveRegistry, hasActiveRegistry } from '../ModelRegistry.js';
|
|
|
19
19
|
* - Provides database info and metadata management
|
|
20
20
|
*/
|
|
21
21
|
export class DatabaseManager {
|
|
22
|
+
runtime;
|
|
22
23
|
metaDb = null;
|
|
23
24
|
metaDbName = 'ablo_databases';
|
|
24
|
-
constructor() {
|
|
25
|
-
|
|
25
|
+
constructor(runtime = globalRuntime) {
|
|
26
|
+
this.runtime = runtime;
|
|
26
27
|
}
|
|
27
28
|
/**
|
|
28
29
|
* Initialize the meta database (ablo_databases)
|
|
@@ -53,8 +54,8 @@ export class DatabaseManager {
|
|
|
53
54
|
// safe to delete and re-create. Try exactly once: delete, then re-open.
|
|
54
55
|
if (!(error instanceof IDBOpenTimeoutError))
|
|
55
56
|
throw error;
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
this.runtime.logger.debug('[sync-engine] meta DB open timed out — attempting self-heal (delete + retry)', { db: this.metaDbName, reason: error.reason });
|
|
58
|
+
this.runtime.observability.captureBootstrapFailure(error, {
|
|
58
59
|
type: 'meta-db-open-timeout',
|
|
59
60
|
});
|
|
60
61
|
const deleted = await deleteIDBWithTimeout(this.metaDbName);
|
|
@@ -66,7 +67,7 @@ export class DatabaseManager {
|
|
|
66
67
|
}
|
|
67
68
|
// Fresh store — this open creates `ablo_databases` from scratch.
|
|
68
69
|
this.metaDb = await open();
|
|
69
|
-
|
|
70
|
+
this.runtime.logger.info('[sync-engine] meta DB self-heal succeeded');
|
|
70
71
|
}
|
|
71
72
|
}
|
|
72
73
|
/**
|
|
@@ -92,7 +93,7 @@ export class DatabaseManager {
|
|
|
92
93
|
const allUserDatabases = await this.getDatabasesForUser(userId);
|
|
93
94
|
const allIndexedDBs = (await indexedDB.databases?.()) || [];
|
|
94
95
|
const abloDatabases = allIndexedDBs.filter((db) => db.name?.startsWith('ablo_'));
|
|
95
|
-
|
|
96
|
+
this.runtime.observability.breadcrumb('Database info calculated', 'sync.database', 'info', {
|
|
96
97
|
dbName,
|
|
97
98
|
schemaVersion,
|
|
98
99
|
existingDbCount: allUserDatabases.length,
|
|
@@ -192,13 +193,13 @@ export class DatabaseManager {
|
|
|
192
193
|
if (createStoresFn && tx) {
|
|
193
194
|
try {
|
|
194
195
|
void createStoresFn(db, tx).catch((err) => {
|
|
195
|
-
|
|
196
|
+
this.runtime.observability.captureBootstrapFailure(err, {
|
|
196
197
|
type: 'store-creation',
|
|
197
198
|
});
|
|
198
199
|
});
|
|
199
200
|
}
|
|
200
201
|
catch (err) {
|
|
201
|
-
|
|
202
|
+
this.runtime.observability.captureBootstrapFailure(err, {
|
|
202
203
|
type: 'store-creation',
|
|
203
204
|
});
|
|
204
205
|
}
|
|
@@ -207,7 +208,7 @@ export class DatabaseManager {
|
|
|
207
208
|
});
|
|
208
209
|
}
|
|
209
210
|
catch (error) {
|
|
210
|
-
|
|
211
|
+
this.runtime.observability.captureBootstrapFailure(error, {
|
|
211
212
|
type: 'database-open',
|
|
212
213
|
});
|
|
213
214
|
throw error;
|
|
@@ -329,11 +330,11 @@ export class DatabaseManager {
|
|
|
329
330
|
resolve();
|
|
330
331
|
};
|
|
331
332
|
deleteRequest.onerror = () => {
|
|
332
|
-
|
|
333
|
+
this.runtime.observability.breadcrumb(`Failed to delete workspace database: ${dbInfo.name}`, 'sync.database', 'error');
|
|
333
334
|
reject(deleteRequest.error);
|
|
334
335
|
};
|
|
335
336
|
deleteRequest.onblocked = () => {
|
|
336
|
-
|
|
337
|
+
this.runtime.observability.breadcrumb(`Database deletion blocked: ${dbInfo.name}`, 'sync.database', 'warning');
|
|
337
338
|
// Could implement retry logic or user notification
|
|
338
339
|
};
|
|
339
340
|
});
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* The IndexedDB-backed object store: durable, per-model record storage for
|
|
3
3
|
* the browser. See {@link ObjectStore}.
|
|
4
4
|
*/
|
|
5
|
-
import type { ModelMetadata } from '../types/index.js';
|
|
5
|
+
import type { ModelMetadata } from '../transaction/types/index.js';
|
|
6
6
|
import type { ObjectStoreContract } from './ObjectStoreContract.js';
|
|
7
7
|
/**
|
|
8
8
|
* IDB transaction options type (TypeScript's lib.dom.d.ts may be outdated)
|