@abloatai/ablo 0.34.1 → 0.35.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 +674 -5
- package/README.md +39 -22
- package/dist/BaseSyncedStore.d.ts +152 -44
- package/dist/BaseSyncedStore.js +300 -184
- package/dist/Database.d.ts +9 -24
- package/dist/Database.js +37 -22
- package/dist/InstanceCache.d.ts +25 -4
- package/dist/InstanceCache.js +48 -15
- package/dist/LazyReferenceCollection.d.ts +3 -3
- package/dist/LazyReferenceCollection.js +4 -4
- package/dist/Model.d.ts +6 -6
- package/dist/Model.js +10 -10
- package/dist/ModelRegistry.d.ts +4 -4
- package/dist/ModelRegistry.js +3 -3
- package/dist/{SyncEngineContext.d.ts → RuntimeContext.d.ts} +20 -13
- package/dist/{SyncEngineContext.js → RuntimeContext.js} +11 -12
- package/dist/SyncClient.d.ts +42 -32
- package/dist/SyncClient.js +166 -110
- 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/cli.cjs +3344 -1073
- package/dist/client/Ablo.d.ts +42 -287
- package/dist/client/Ablo.js +118 -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 +4 -4
- package/dist/client/createInternalComponents.js +9 -8
- package/dist/client/createModelProxy.d.ts +78 -373
- package/dist/client/createModelProxy.js +114 -86
- package/dist/client/humans.d.ts +48 -0
- package/dist/client/humans.js +52 -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 +48 -0
- package/dist/client/reactiveEngine.js +910 -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/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 +9 -9
- package/dist/context.js +10 -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/DatabaseManager.js +1 -1
- package/dist/core/QueryView.d.ts +1 -1
- package/dist/core/QueryView.js +1 -1
- package/dist/core/StoreManager.d.ts +4 -23
- package/dist/core/StoreManager.js +5 -55
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +2 -2
- package/dist/core/storeContract.d.ts +2 -2
- package/dist/docs/catalog.d.ts +72 -0
- package/dist/docs/catalog.js +227 -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 +40 -34
- package/dist/index.js +26 -20
- 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 +2 -2
- package/dist/query/client.js +4 -4
- package/dist/query/types.d.ts +6 -41
- package/dist/query/types.js +2 -2
- package/dist/react/AbloProvider.d.ts +6 -8
- package/dist/react/AbloProvider.js +5 -7
- package/dist/react/context.d.ts +1 -1
- package/dist/react/context.js +1 -1
- package/dist/react/index.d.ts +5 -5
- package/dist/react/index.js +3 -3
- package/dist/react/internalContext.d.ts +1 -1
- package/dist/react/useAblo.d.ts +3 -3
- package/dist/react/useAblo.js +1 -1
- 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 +86 -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 +10 -10
- package/dist/schema/index.js +18 -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 +3 -3
- package/dist/schema/serialize.d.ts +15 -6
- package/dist/schema/serialize.js +17 -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/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/footprint.d.ts +111 -0
- package/dist/source/footprint.js +0 -0
- 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/stores/ObjectStore.d.ts +1 -1
- package/dist/stores/SyncActionStore.d.ts +1 -1
- package/dist/stores/SyncActionStore.js +2 -10
- 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 +123 -6
- package/dist/sync/BootstrapFetcher.js +492 -66
- package/dist/sync/ConnectionManager.d.ts +6 -198
- package/dist/sync/ConnectionManager.js +6 -677
- package/dist/sync/OnDemandLoader.d.ts +2 -2
- package/dist/sync/OnDemandLoader.js +60 -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/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 +1 -1
- package/dist/sync/participants.d.ts +5 -4
- package/dist/sync/participants.js +29 -22
- package/dist/sync/schemaDrift.d.ts +55 -0
- package/dist/sync/schemaDrift.js +53 -0
- package/dist/sync/schemas.d.ts +21 -32
- package/dist/sync/schemas.js +26 -17
- 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/testing/fixtures/bootstrap.d.ts +1 -1
- package/dist/testing/fixtures/deltas.d.ts +1 -1
- package/dist/testing/fixtures/httpResponses.d.ts +70 -0
- package/dist/testing/fixtures/httpResponses.js +90 -0
- package/dist/testing/fixtures/models.js +1 -1
- package/dist/testing/helpers/wait.js +1 -1
- package/dist/testing/mocks/MockMutationExecutor.d.ts +2 -2
- package/dist/testing/mocks/MockMutationExecutor.js +8 -14
- package/dist/testing/mocks/MockSyncContext.d.ts +11 -11
- package/dist/testing/mocks/MockSyncContext.js +10 -9
- package/dist/testing/mocks/MockSyncStore.js +1 -1
- package/dist/testing/mocks/MockWebSocket.d.ts +2 -2
- 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 +177 -0
- package/dist/transaction/auth/capability.js +199 -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 +49 -0
- package/dist/transaction/coordination/awaitClaimGrant.js +112 -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 +44 -0
- package/dist/transaction/coordination/locator.d.ts +83 -0
- package/dist/transaction/coordination/locator.js +82 -0
- package/dist/transaction/coordination/schema.d.ts +1473 -0
- package/dist/{coordination → transaction/coordination}/schema.js +490 -55
- package/dist/transaction/coordination/targetConflict.d.ts +2 -0
- package/dist/transaction/coordination/targetConflict.js +103 -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} +11 -11
- package/dist/{errorCodes.js → transaction/errorCodes.js} +35 -12
- package/dist/{errors.d.ts → transaction/errors.d.ts} +37 -13
- package/dist/{errors.js → transaction/errors.js} +85 -16
- 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 +192 -0
- package/dist/transaction/plugin.js +87 -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 +266 -0
- package/dist/transaction/resources/httpResources.js +7 -0
- package/dist/transaction/resources/modelOperations.d.ts +319 -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 +85 -0
- package/dist/transaction/resources/where.js +70 -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 +5 -5
- package/dist/{schema → transaction/schema}/field.js +5 -5
- 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 +57 -0
- package/dist/transaction/schema/openapi.js +340 -0
- package/dist/{schema → transaction/schema}/relation.d.ts +14 -14
- 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 +12 -10
- package/dist/{schema → transaction/schema}/schema.js +4 -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 +4 -5
- 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} +10 -36
- 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/{client → transaction/transport}/httpClient.d.ts +59 -16
- package/dist/{client → transaction/transport}/httpClient.js +5 -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 +171 -85
- 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 +576 -0
- package/dist/transaction/transport/wsTransport.js +1017 -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 +63 -45
- 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 +351 -0
- package/dist/transaction/wire/accountResponses.js +255 -0
- package/dist/transaction/wire/auth.d.ts +49 -0
- package/dist/transaction/wire/auth.js +57 -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 +463 -0
- package/dist/transaction/wire/claims.js +229 -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 +177 -0
- package/dist/transaction/wire/feedEvent.js +39 -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 +552 -0
- package/dist/transaction/wire/inboundFrames.js +116 -0
- package/dist/transaction/wire/index.d.ts +50 -0
- package/dist/transaction/wire/index.js +74 -0
- package/dist/{wire → transaction/wire}/listEnvelope.d.ts +13 -14
- package/dist/transaction/wire/listEnvelope.js +42 -0
- package/dist/transaction/wire/modelResponses.d.ts +85 -0
- package/dist/transaction/wire/modelResponses.js +43 -0
- package/dist/transactions/{TransactionQueue.d.ts → mutations/MutationQueue.d.ts} +79 -38
- package/dist/transactions/{TransactionQueue.js → mutations/MutationQueue.js} +110 -59
- 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} +16 -15
- package/dist/transactions/{commitPayload.js → mutations/commitPayload.js} +12 -12
- package/dist/transactions/{deltaConfirmation.d.ts → mutations/deltaConfirmation.d.ts} +11 -11
- package/dist/transactions/{deltaConfirmation.js → mutations/deltaConfirmation.js} +7 -7
- 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} +3 -3
- package/dist/transactions/{replayValidation.js → mutations/replayValidation.js} +4 -3
- package/dist/utils/mobxSetup.d.ts +1 -1
- package/dist/utils/mobxSetup.js +5 -2
- 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 +19 -12
- package/docs/api-keys.md +8 -4
- package/docs/api.md +22 -18
- package/docs/audit.md +2 -0
- package/docs/cli.md +31 -3
- package/docs/client-behavior.md +8 -6
- package/docs/concurrency-convention.md +30 -24
- package/docs/coordination.md +48 -38
- package/docs/data-sources.md +3 -1
- package/docs/debugging.md +5 -3
- 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 +45 -44
- package/docs/examples/server-agent.md +46 -26
- package/docs/groups.md +32 -29
- package/docs/guarantees.md +4 -2
- package/docs/how-it-works.md +9 -7
- package/docs/idempotency.md +126 -0
- package/docs/identity.md +58 -54
- package/docs/index.md +172 -86
- package/docs/integration-guide.md +17 -16
- package/docs/interaction-model.md +6 -4
- package/docs/mcp.md +41 -16
- package/docs/migration.md +63 -5
- package/docs/operating-on-your-database.md +3 -1
- package/docs/projects.md +2 -0
- package/docs/quickstart.md +22 -5
- package/docs/react.md +12 -10
- package/docs/schema-contract.md +5 -3
- package/docs/session-settings.md +108 -0
- package/docs/sessions.md +3 -1
- package/docs/webhooks.md +3 -1
- package/llms.txt +47 -17
- package/package.json +10 -8
- 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/client/durableWrites.d.ts +0 -21
- package/dist/coordination/schema.d.ts +0 -722
- package/dist/schema/openapi.d.ts +0 -29
- package/dist/schema/openapi.js +0 -124
- package/dist/transactions/durableWriteStore.js +0 -30
- 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/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/coordination}/claimHeartbeatLoop.d.ts +0 -0
- /package/dist/{client → transaction/coordination}/claimHeartbeatLoop.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/{utils → transaction/utils}/duration.d.ts +0 -0
- /package/dist/{utils → transaction/utils}/duration.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
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import { z } from 'zod';
|
|
20
20
|
import type { ErrorCode } from '../errorCodes.js';
|
|
21
|
-
import type { RequiredCapability } from '../errors.js';
|
|
22
21
|
/** Matches the permanent source/idempotency-key ceiling. */
|
|
23
22
|
export declare const COMMIT_CORRELATION_ID_MAX_LENGTH = 255;
|
|
24
23
|
/** Opaque server-authored identity shared by a queued receipt and its authoritative source delta. */
|
|
@@ -29,6 +28,24 @@ export declare const commitStatusSchema: z.ZodEnum<{
|
|
|
29
28
|
confirmed: "confirmed";
|
|
30
29
|
}>;
|
|
31
30
|
export type CommitStatus = z.infer<typeof commitStatusSchema>;
|
|
31
|
+
/**
|
|
32
|
+
* The settlement states a write may block on — extracted from the reported
|
|
33
|
+
* vocabulary above, never restated beside it. `commitStatusSchema` is every
|
|
34
|
+
* state a server can report; this is the subset a caller can usefully wait for,
|
|
35
|
+
* and the two are not the same question: one describes an outcome, the other a
|
|
36
|
+
* request.
|
|
37
|
+
*
|
|
38
|
+
* `.extract` keeps the relationship mechanical in both directions. Renaming a
|
|
39
|
+
* settlement state breaks this line at build time, and adding one that nobody
|
|
40
|
+
* can block on — a commit parked for a human, say — does not become a legal
|
|
41
|
+
* `wait` merely by being added above. Both the `wait` option's runtime
|
|
42
|
+
* validator and its interface derive from here, so they cannot disagree.
|
|
43
|
+
*/
|
|
44
|
+
export declare const commitWaitSchema: z.ZodEnum<{
|
|
45
|
+
queued: "queued";
|
|
46
|
+
confirmed: "confirmed";
|
|
47
|
+
}>;
|
|
48
|
+
export type CommitWait = z.infer<typeof commitWaitSchema>;
|
|
32
49
|
/** The one settlement discriminant shared by every commit boundary. */
|
|
33
50
|
export declare const commitSettlementSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
34
51
|
status: z.ZodLiteral<"queued">;
|
|
@@ -104,72 +121,6 @@ export declare const commitReceiptSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
104
121
|
missingIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
105
122
|
}, z.core.$strip>], "status">;
|
|
106
123
|
export type CommitReceiptWire = z.infer<typeof commitReceiptSchema>;
|
|
107
|
-
/**
|
|
108
|
-
* Compatibility decoder for pre-contract WebSocket acknowledgements. It
|
|
109
|
-
* supplies fields old servers omitted and normalizes their string sync ids,
|
|
110
|
-
* then hands the result to the exact same canonical receipt schema. It never
|
|
111
|
-
* invents a source correlation: an old/malformed queued receipt still fails
|
|
112
|
-
* closed.
|
|
113
|
-
*/
|
|
114
|
-
export declare const legacyCompatibleCommitReceiptSchema: z.ZodPreprocess<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
115
|
-
status: z.ZodLiteral<"queued">;
|
|
116
|
-
correlationId: z.ZodString;
|
|
117
|
-
object: z.ZodLiteral<"commit_receipt">;
|
|
118
|
-
id: z.ZodOptional<z.ZodString>;
|
|
119
|
-
clientTxId: z.ZodString;
|
|
120
|
-
serverTxId: z.ZodString;
|
|
121
|
-
success: z.ZodLiteral<true>;
|
|
122
|
-
lastSyncId: z.ZodNumber;
|
|
123
|
-
ops: z.ZodNumber;
|
|
124
|
-
notifications: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
125
|
-
object: z.ZodOptional<z.ZodLiteral<"stale_notification">>;
|
|
126
|
-
model: z.ZodString;
|
|
127
|
-
id: z.ZodString;
|
|
128
|
-
readAt: z.ZodNumber;
|
|
129
|
-
observedSyncId: z.ZodNumber;
|
|
130
|
-
conflictingFields: z.ZodArray<z.ZodString>;
|
|
131
|
-
currentValues: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
132
|
-
writtenBy: z.ZodObject<{
|
|
133
|
-
kind: z.ZodEnum<{
|
|
134
|
-
user: "user";
|
|
135
|
-
agent: "agent";
|
|
136
|
-
system: "system";
|
|
137
|
-
}>;
|
|
138
|
-
id: z.ZodString;
|
|
139
|
-
}, z.core.$strip>;
|
|
140
|
-
group: z.ZodOptional<z.ZodString>;
|
|
141
|
-
}, z.core.$strip>>>;
|
|
142
|
-
missingIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
143
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
144
|
-
status: z.ZodLiteral<"confirmed">;
|
|
145
|
-
correlationId: z.ZodOptional<z.ZodString>;
|
|
146
|
-
object: z.ZodLiteral<"commit_receipt">;
|
|
147
|
-
id: z.ZodOptional<z.ZodString>;
|
|
148
|
-
clientTxId: z.ZodString;
|
|
149
|
-
serverTxId: z.ZodString;
|
|
150
|
-
success: z.ZodLiteral<true>;
|
|
151
|
-
lastSyncId: z.ZodNumber;
|
|
152
|
-
ops: z.ZodNumber;
|
|
153
|
-
notifications: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
154
|
-
object: z.ZodOptional<z.ZodLiteral<"stale_notification">>;
|
|
155
|
-
model: z.ZodString;
|
|
156
|
-
id: z.ZodString;
|
|
157
|
-
readAt: z.ZodNumber;
|
|
158
|
-
observedSyncId: z.ZodNumber;
|
|
159
|
-
conflictingFields: z.ZodArray<z.ZodString>;
|
|
160
|
-
currentValues: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
161
|
-
writtenBy: z.ZodObject<{
|
|
162
|
-
kind: z.ZodEnum<{
|
|
163
|
-
user: "user";
|
|
164
|
-
agent: "agent";
|
|
165
|
-
system: "system";
|
|
166
|
-
}>;
|
|
167
|
-
id: z.ZodString;
|
|
168
|
-
}, z.core.$strip>;
|
|
169
|
-
group: z.ZodOptional<z.ZodString>;
|
|
170
|
-
}, z.core.$strip>>>;
|
|
171
|
-
missingIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
172
|
-
}, z.core.$strip>], "status">>;
|
|
173
124
|
/** The failure arm is separate: queued/confirmed always imply `success:true`. */
|
|
174
125
|
export declare const rejectedCommitReceiptSchema: z.ZodObject<{
|
|
175
126
|
object: z.ZodLiteral<"commit_receipt">;
|
|
@@ -183,7 +134,13 @@ export declare const rejectedCommitReceiptSchema: z.ZodObject<{
|
|
|
183
134
|
code: z.ZodCustom<ErrorCode, ErrorCode>;
|
|
184
135
|
message: z.ZodString;
|
|
185
136
|
field: z.ZodOptional<z.ZodString>;
|
|
186
|
-
requiredCapability: z.ZodOptional<z.
|
|
137
|
+
requiredCapability: z.ZodOptional<z.ZodObject<{
|
|
138
|
+
scope: z.ZodString;
|
|
139
|
+
constraints: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodString]>>>;
|
|
140
|
+
issuer: z.ZodPreprocess<z.ZodOptional<z.ZodString>>;
|
|
141
|
+
ttlSeconds: z.ZodPreprocess<z.ZodOptional<z.ZodNumber>>;
|
|
142
|
+
nonce: z.ZodPreprocess<z.ZodOptional<z.ZodString>>;
|
|
143
|
+
}, z.core.$loose>>;
|
|
187
144
|
}, z.core.$strip>;
|
|
188
145
|
}, z.core.$strip>;
|
|
189
146
|
export type RejectedCommitReceiptWire = z.infer<typeof rejectedCommitReceiptSchema>;
|
|
@@ -257,7 +214,13 @@ export declare const mutationResultPayloadSchema: z.ZodUnion<readonly [z.ZodDisc
|
|
|
257
214
|
code: z.ZodCustom<ErrorCode, ErrorCode>;
|
|
258
215
|
message: z.ZodString;
|
|
259
216
|
field: z.ZodOptional<z.ZodString>;
|
|
260
|
-
requiredCapability: z.ZodOptional<z.
|
|
217
|
+
requiredCapability: z.ZodOptional<z.ZodObject<{
|
|
218
|
+
scope: z.ZodString;
|
|
219
|
+
constraints: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodString]>>>;
|
|
220
|
+
issuer: z.ZodPreprocess<z.ZodOptional<z.ZodString>>;
|
|
221
|
+
ttlSeconds: z.ZodPreprocess<z.ZodOptional<z.ZodNumber>>;
|
|
222
|
+
nonce: z.ZodPreprocess<z.ZodOptional<z.ZodString>>;
|
|
223
|
+
}, z.core.$loose>>;
|
|
261
224
|
}, z.core.$strip>;
|
|
262
225
|
}, z.core.$strip>]>;
|
|
263
226
|
export type MutationResultPayload = z.infer<typeof mutationResultPayloadSchema>;
|
|
@@ -333,7 +296,13 @@ export declare const mutationResultMessageSchema: z.ZodObject<{
|
|
|
333
296
|
code: z.ZodCustom<ErrorCode, ErrorCode>;
|
|
334
297
|
message: z.ZodString;
|
|
335
298
|
field: z.ZodOptional<z.ZodString>;
|
|
336
|
-
requiredCapability: z.ZodOptional<z.
|
|
299
|
+
requiredCapability: z.ZodOptional<z.ZodObject<{
|
|
300
|
+
scope: z.ZodString;
|
|
301
|
+
constraints: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodString]>>>;
|
|
302
|
+
issuer: z.ZodPreprocess<z.ZodOptional<z.ZodString>>;
|
|
303
|
+
ttlSeconds: z.ZodPreprocess<z.ZodOptional<z.ZodNumber>>;
|
|
304
|
+
nonce: z.ZodPreprocess<z.ZodOptional<z.ZodString>>;
|
|
305
|
+
}, z.core.$loose>>;
|
|
337
306
|
}, z.core.$strip>;
|
|
338
307
|
}, z.core.$strip>]>;
|
|
339
308
|
}, z.core.$strip>;
|
|
@@ -461,11 +430,12 @@ export declare const commitAckSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
461
430
|
}, z.core.$strict>], "status">;
|
|
462
431
|
export type CommitAck = z.infer<typeof commitAckSchema>;
|
|
463
432
|
/**
|
|
464
|
-
*
|
|
465
|
-
*
|
|
466
|
-
*
|
|
433
|
+
* The boundary an injected mutation executor returns through. It is the
|
|
434
|
+
* acknowledgement schema itself: settlement is declared, never inferred from
|
|
435
|
+
* an omission, so a transport cannot report a write as landed by staying
|
|
436
|
+
* silent about how it landed.
|
|
467
437
|
*/
|
|
468
|
-
export declare const mutationCommitResultSchema: z.
|
|
438
|
+
export declare const mutationCommitResultSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
469
439
|
status: z.ZodLiteral<"queued">;
|
|
470
440
|
correlationId: z.ZodString;
|
|
471
441
|
lastSyncId: z.ZodNumber;
|
|
@@ -511,125 +481,7 @@ export declare const mutationCommitResultSchema: z.ZodPipe<z.ZodUnion<readonly [
|
|
|
511
481
|
group: z.ZodOptional<z.ZodString>;
|
|
512
482
|
}, z.core.$strip>>>;
|
|
513
483
|
missingIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
514
|
-
}, z.core.$strict>], "status"
|
|
515
|
-
status: z.ZodOptional<z.ZodUndefined>;
|
|
516
|
-
correlationId: z.ZodOptional<z.ZodUndefined>;
|
|
517
|
-
lastSyncId: z.ZodNumber;
|
|
518
|
-
notifications: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
519
|
-
object: z.ZodOptional<z.ZodLiteral<"stale_notification">>;
|
|
520
|
-
model: z.ZodString;
|
|
521
|
-
id: z.ZodString;
|
|
522
|
-
readAt: z.ZodNumber;
|
|
523
|
-
observedSyncId: z.ZodNumber;
|
|
524
|
-
conflictingFields: z.ZodArray<z.ZodString>;
|
|
525
|
-
currentValues: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
526
|
-
writtenBy: z.ZodObject<{
|
|
527
|
-
kind: z.ZodEnum<{
|
|
528
|
-
user: "user";
|
|
529
|
-
agent: "agent";
|
|
530
|
-
system: "system";
|
|
531
|
-
}>;
|
|
532
|
-
id: z.ZodString;
|
|
533
|
-
}, z.core.$strip>;
|
|
534
|
-
group: z.ZodOptional<z.ZodString>;
|
|
535
|
-
}, z.core.$strip>>>;
|
|
536
|
-
missingIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
537
|
-
}, z.core.$strict>]>, z.ZodTransform<{
|
|
538
|
-
status: "queued";
|
|
539
|
-
correlationId: string;
|
|
540
|
-
lastSyncId: number;
|
|
541
|
-
notifications?: {
|
|
542
|
-
model: string;
|
|
543
|
-
id: string;
|
|
544
|
-
readAt: number;
|
|
545
|
-
observedSyncId: number;
|
|
546
|
-
conflictingFields: string[];
|
|
547
|
-
currentValues: Record<string, unknown>;
|
|
548
|
-
writtenBy: {
|
|
549
|
-
kind: "user" | "agent" | "system";
|
|
550
|
-
id: string;
|
|
551
|
-
};
|
|
552
|
-
object?: "stale_notification" | undefined;
|
|
553
|
-
group?: string | undefined;
|
|
554
|
-
}[] | undefined;
|
|
555
|
-
missingIds?: string[] | undefined;
|
|
556
|
-
} | {
|
|
557
|
-
status: "confirmed";
|
|
558
|
-
lastSyncId: number;
|
|
559
|
-
correlationId?: string | undefined;
|
|
560
|
-
notifications?: {
|
|
561
|
-
model: string;
|
|
562
|
-
id: string;
|
|
563
|
-
readAt: number;
|
|
564
|
-
observedSyncId: number;
|
|
565
|
-
conflictingFields: string[];
|
|
566
|
-
currentValues: Record<string, unknown>;
|
|
567
|
-
writtenBy: {
|
|
568
|
-
kind: "user" | "agent" | "system";
|
|
569
|
-
id: string;
|
|
570
|
-
};
|
|
571
|
-
object?: "stale_notification" | undefined;
|
|
572
|
-
group?: string | undefined;
|
|
573
|
-
}[] | undefined;
|
|
574
|
-
missingIds?: string[] | undefined;
|
|
575
|
-
}, {
|
|
576
|
-
status: "queued";
|
|
577
|
-
correlationId: string;
|
|
578
|
-
lastSyncId: number;
|
|
579
|
-
notifications?: {
|
|
580
|
-
model: string;
|
|
581
|
-
id: string;
|
|
582
|
-
readAt: number;
|
|
583
|
-
observedSyncId: number;
|
|
584
|
-
conflictingFields: string[];
|
|
585
|
-
currentValues: Record<string, unknown>;
|
|
586
|
-
writtenBy: {
|
|
587
|
-
kind: "user" | "agent" | "system";
|
|
588
|
-
id: string;
|
|
589
|
-
};
|
|
590
|
-
object?: "stale_notification" | undefined;
|
|
591
|
-
group?: string | undefined;
|
|
592
|
-
}[] | undefined;
|
|
593
|
-
missingIds?: string[] | undefined;
|
|
594
|
-
} | {
|
|
595
|
-
status: "confirmed";
|
|
596
|
-
lastSyncId: number;
|
|
597
|
-
correlationId?: string | undefined;
|
|
598
|
-
notifications?: {
|
|
599
|
-
model: string;
|
|
600
|
-
id: string;
|
|
601
|
-
readAt: number;
|
|
602
|
-
observedSyncId: number;
|
|
603
|
-
conflictingFields: string[];
|
|
604
|
-
currentValues: Record<string, unknown>;
|
|
605
|
-
writtenBy: {
|
|
606
|
-
kind: "user" | "agent" | "system";
|
|
607
|
-
id: string;
|
|
608
|
-
};
|
|
609
|
-
object?: "stale_notification" | undefined;
|
|
610
|
-
group?: string | undefined;
|
|
611
|
-
}[] | undefined;
|
|
612
|
-
missingIds?: string[] | undefined;
|
|
613
|
-
} | {
|
|
614
|
-
lastSyncId: number;
|
|
615
|
-
status?: undefined;
|
|
616
|
-
correlationId?: undefined;
|
|
617
|
-
notifications?: {
|
|
618
|
-
model: string;
|
|
619
|
-
id: string;
|
|
620
|
-
readAt: number;
|
|
621
|
-
observedSyncId: number;
|
|
622
|
-
conflictingFields: string[];
|
|
623
|
-
currentValues: Record<string, unknown>;
|
|
624
|
-
writtenBy: {
|
|
625
|
-
kind: "user" | "agent" | "system";
|
|
626
|
-
id: string;
|
|
627
|
-
};
|
|
628
|
-
object?: "stale_notification" | undefined;
|
|
629
|
-
group?: string | undefined;
|
|
630
|
-
}[] | undefined;
|
|
631
|
-
missingIds?: string[] | undefined;
|
|
632
|
-
}>>;
|
|
484
|
+
}, z.core.$strict>], "status">;
|
|
633
485
|
export type MutationCommitResultInput = z.input<typeof mutationCommitResultSchema>;
|
|
634
486
|
export type MutationCommitResult = z.infer<typeof mutationCommitResultSchema>;
|
|
635
487
|
/**
|
|
@@ -669,3 +521,83 @@ export declare const clientCommitReceiptSchema: z.ZodObject<{
|
|
|
669
521
|
missingIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
670
522
|
}, z.core.$strict>;
|
|
671
523
|
export type ClientCommitReceipt = z.infer<typeof clientCommitReceiptSchema>;
|
|
524
|
+
/** Control fields any operation in a commit may carry. */
|
|
525
|
+
export declare const commitOperationControlShape: {
|
|
526
|
+
id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
527
|
+
transactionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
528
|
+
readAt: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
529
|
+
onStale: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
530
|
+
reject: "reject";
|
|
531
|
+
overwrite: "overwrite";
|
|
532
|
+
notify: "notify";
|
|
533
|
+
}>>>;
|
|
534
|
+
fenceToken: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
535
|
+
};
|
|
536
|
+
/** One write inside a commit, in the canonical spelling. */
|
|
537
|
+
export declare const commitOperationBodySchema: z.ZodObject<{
|
|
538
|
+
action: z.ZodString;
|
|
539
|
+
model: z.ZodString;
|
|
540
|
+
data: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
541
|
+
id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
542
|
+
transactionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
543
|
+
readAt: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
544
|
+
onStale: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
545
|
+
reject: "reject";
|
|
546
|
+
overwrite: "overwrite";
|
|
547
|
+
notify: "notify";
|
|
548
|
+
}>>>;
|
|
549
|
+
fenceToken: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
550
|
+
}, z.core.$strip>;
|
|
551
|
+
export type CommitOperationBody = z.infer<typeof commitOperationBodySchema>;
|
|
552
|
+
/**
|
|
553
|
+
* The `POST /v1/commits` request body.
|
|
554
|
+
*
|
|
555
|
+
* `operations` carries the writes; `track` registers durable premises.
|
|
556
|
+
* Neither is required on its own, because a body with `track` and no
|
|
557
|
+
* `operations` is how a caller starts watching a row without writing to it.
|
|
558
|
+
* Request identity travels in the `Idempotency-Key` header.
|
|
559
|
+
*/
|
|
560
|
+
export declare const commitRequestSchema: z.ZodObject<{
|
|
561
|
+
operations: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
562
|
+
action: z.ZodString;
|
|
563
|
+
model: z.ZodString;
|
|
564
|
+
data: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
565
|
+
id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
566
|
+
transactionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
567
|
+
readAt: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
568
|
+
onStale: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
569
|
+
reject: "reject";
|
|
570
|
+
overwrite: "overwrite";
|
|
571
|
+
notify: "notify";
|
|
572
|
+
}>>>;
|
|
573
|
+
fenceToken: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
574
|
+
}, z.core.$strip>>>;
|
|
575
|
+
reads: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
576
|
+
model: z.ZodString;
|
|
577
|
+
id: z.ZodString;
|
|
578
|
+
readAt: z.ZodNumber;
|
|
579
|
+
fields: z.ZodOptional<z.ZodReadonly<z.ZodArray<z.ZodString>>>;
|
|
580
|
+
onStale: z.ZodOptional<z.ZodEnum<{
|
|
581
|
+
reject: "reject";
|
|
582
|
+
overwrite: "overwrite";
|
|
583
|
+
notify: "notify";
|
|
584
|
+
}>>;
|
|
585
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
586
|
+
group: z.ZodString;
|
|
587
|
+
readAt: z.ZodNumber;
|
|
588
|
+
onStale: z.ZodOptional<z.ZodEnum<{
|
|
589
|
+
reject: "reject";
|
|
590
|
+
overwrite: "overwrite";
|
|
591
|
+
notify: "notify";
|
|
592
|
+
}>>;
|
|
593
|
+
}, z.core.$strip>]>>>>;
|
|
594
|
+
track: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
595
|
+
model: z.ZodString;
|
|
596
|
+
id: z.ZodString;
|
|
597
|
+
readAt: z.ZodOptional<z.ZodNumber>;
|
|
598
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
599
|
+
group: z.ZodString;
|
|
600
|
+
readAt: z.ZodOptional<z.ZodNumber>;
|
|
601
|
+
}, z.core.$strip>]>>>>;
|
|
602
|
+
}, z.core.$strip>;
|
|
603
|
+
export type CommitRequest = z.infer<typeof commitRequestSchema>;
|
|
@@ -17,12 +17,27 @@
|
|
|
17
17
|
* one giant object.
|
|
18
18
|
*/
|
|
19
19
|
import { z } from 'zod';
|
|
20
|
-
import { staleNotificationSchema } from '../coordination/schema.js';
|
|
20
|
+
import { onStaleModeSchema, readDependencySchema, staleNotificationSchema, trackDependencySchema, } from '../coordination/schema.js';
|
|
21
|
+
import { requiredCapabilityWireSchema } from '../errors.js';
|
|
21
22
|
/** Matches the permanent source/idempotency-key ceiling. */
|
|
22
23
|
export const COMMIT_CORRELATION_ID_MAX_LENGTH = 255;
|
|
23
24
|
/** Opaque server-authored identity shared by a queued receipt and its authoritative source delta. */
|
|
24
25
|
export const correlationIdSchema = z.string().min(1).max(COMMIT_CORRELATION_ID_MAX_LENGTH);
|
|
25
26
|
export const commitStatusSchema = z.enum(['queued', 'confirmed']);
|
|
27
|
+
/**
|
|
28
|
+
* The settlement states a write may block on — extracted from the reported
|
|
29
|
+
* vocabulary above, never restated beside it. `commitStatusSchema` is every
|
|
30
|
+
* state a server can report; this is the subset a caller can usefully wait for,
|
|
31
|
+
* and the two are not the same question: one describes an outcome, the other a
|
|
32
|
+
* request.
|
|
33
|
+
*
|
|
34
|
+
* `.extract` keeps the relationship mechanical in both directions. Renaming a
|
|
35
|
+
* settlement state breaks this line at build time, and adding one that nobody
|
|
36
|
+
* can block on — a commit parked for a human, say — does not become a legal
|
|
37
|
+
* `wait` merely by being added above. Both the `wait` option's runtime
|
|
38
|
+
* validator and its interface derive from here, so they cannot disagree.
|
|
39
|
+
*/
|
|
40
|
+
export const commitWaitSchema = commitStatusSchema.extract(['queued', 'confirmed']);
|
|
26
41
|
const queuedSettlementShape = {
|
|
27
42
|
status: z.literal('queued'),
|
|
28
43
|
correlationId: correlationIdSchema,
|
|
@@ -91,41 +106,13 @@ export const commitReceiptSchema = z.discriminatedUnion('status', [
|
|
|
91
106
|
confirmedCommitReceiptSchema,
|
|
92
107
|
]);
|
|
93
108
|
/**
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
109
|
+
* The rejection code is deliberately not narrowed to the {@link ErrorCode}
|
|
110
|
+
* registry. A newer server may reject a commit with a code this build predates,
|
|
111
|
+
* and failing the whole receipt over an unrecognized string would turn a
|
|
112
|
+
* readable rejection into an opaque parse error. `errorCodes.ts` sanctions this
|
|
113
|
+
* single boundary cast; every code *producer* is constrained at the
|
|
114
|
+
* `AbloError` constructor instead.
|
|
99
115
|
*/
|
|
100
|
-
export const legacyCompatibleCommitReceiptSchema = z.preprocess((value) => {
|
|
101
|
-
if (typeof value !== 'object' || value === null)
|
|
102
|
-
return value;
|
|
103
|
-
const receipt = value;
|
|
104
|
-
if (receipt.success !== true)
|
|
105
|
-
return value;
|
|
106
|
-
const rawLastSyncId = receipt.lastSyncId;
|
|
107
|
-
const numericLastSyncId = typeof rawLastSyncId === 'string' && rawLastSyncId.trim().length > 0
|
|
108
|
-
? Number(rawLastSyncId)
|
|
109
|
-
: rawLastSyncId;
|
|
110
|
-
const normalizedLastSyncId = typeof numericLastSyncId === 'number' &&
|
|
111
|
-
Number.isSafeInteger(numericLastSyncId) &&
|
|
112
|
-
numericLastSyncId >= 0
|
|
113
|
-
? numericLastSyncId
|
|
114
|
-
: undefined;
|
|
115
|
-
return {
|
|
116
|
-
...receipt,
|
|
117
|
-
object: receipt.object ?? 'commit_receipt',
|
|
118
|
-
status: receipt.status ?? 'confirmed',
|
|
119
|
-
serverTxId: typeof receipt.serverTxId === 'string'
|
|
120
|
-
? receipt.serverTxId
|
|
121
|
-
: String(normalizedLastSyncId ?? 0),
|
|
122
|
-
ops: typeof receipt.ops === 'number' && Number.isSafeInteger(receipt.ops) ? receipt.ops : 0,
|
|
123
|
-
lastSyncId: normalizedLastSyncId ?? 0,
|
|
124
|
-
};
|
|
125
|
-
}, commitReceiptSchema);
|
|
126
|
-
const requiredCapabilitySchema = z.custom((value) => typeof value === 'object' &&
|
|
127
|
-
value !== null &&
|
|
128
|
-
typeof value.scope === 'string', { message: 'requiredCapability must contain a scope' });
|
|
129
116
|
const errorCodeSchema = z.custom((value) => typeof value === 'string' && value.length > 0, { message: 'commit rejection code must be a non-empty string' });
|
|
130
117
|
/** The failure arm is separate: queued/confirmed always imply `success:true`. */
|
|
131
118
|
export const rejectedCommitReceiptSchema = z.object({
|
|
@@ -140,7 +127,7 @@ export const rejectedCommitReceiptSchema = z.object({
|
|
|
140
127
|
code: errorCodeSchema,
|
|
141
128
|
message: z.string(),
|
|
142
129
|
field: z.string().optional(),
|
|
143
|
-
requiredCapability:
|
|
130
|
+
requiredCapability: requiredCapabilityWireSchema.optional(),
|
|
144
131
|
}),
|
|
145
132
|
});
|
|
146
133
|
export const mutationResultPayloadSchema = z.union([
|
|
@@ -269,19 +256,13 @@ export const commitAckSchema = z.discriminatedUnion('status', [
|
|
|
269
256
|
message: 'A source-confirmed acknowledgement requires a sync watermark',
|
|
270
257
|
}),
|
|
271
258
|
]);
|
|
272
|
-
const legacyMutationCommitResultSchema = z.strictObject({
|
|
273
|
-
...ackCommonShape,
|
|
274
|
-
status: z.undefined().optional(),
|
|
275
|
-
correlationId: z.undefined().optional(),
|
|
276
|
-
});
|
|
277
259
|
/**
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
*
|
|
260
|
+
* The boundary an injected mutation executor returns through. It is the
|
|
261
|
+
* acknowledgement schema itself: settlement is declared, never inferred from
|
|
262
|
+
* an omission, so a transport cannot report a write as landed by staying
|
|
263
|
+
* silent about how it landed.
|
|
281
264
|
*/
|
|
282
|
-
export const mutationCommitResultSchema =
|
|
283
|
-
.union([commitAckSchema, legacyMutationCommitResultSchema])
|
|
284
|
-
.transform((result) => (result.status ? result : { ...result, status: 'confirmed' }));
|
|
265
|
+
export const mutationCommitResultSchema = commitAckSchema;
|
|
285
266
|
/**
|
|
286
267
|
* Public SDK projection returned by `ablo.commits` and model mutations.
|
|
287
268
|
*
|
|
@@ -298,3 +279,43 @@ export const clientCommitReceiptSchema = z.strictObject({
|
|
|
298
279
|
notifications: notificationsSchema.optional(),
|
|
299
280
|
missingIds: missingIdsSchema.optional(),
|
|
300
281
|
});
|
|
282
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
283
|
+
// The request side of the commit boundary
|
|
284
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
285
|
+
//
|
|
286
|
+
// `POST /v1/commits` is the chokepoint every write passes through, so its
|
|
287
|
+
// request shape is a boundary contract and belongs here beside the receipt it
|
|
288
|
+
// answers with — not in a route handler. The published OpenAPI reference is
|
|
289
|
+
// derived from these schemas rather than describing them separately, so the
|
|
290
|
+
// documented surface cannot drift from the validated one.
|
|
291
|
+
//
|
|
292
|
+
// The server layers its own decoder-only compatibility spellings on top for
|
|
293
|
+
// already-shipped clients; those are a rollout concern, not the contract.
|
|
294
|
+
/** Control fields any operation in a commit may carry. */
|
|
295
|
+
export const commitOperationControlShape = {
|
|
296
|
+
id: z.string().nullish(),
|
|
297
|
+
transactionId: z.string().nullish(),
|
|
298
|
+
readAt: z.number().nullish(),
|
|
299
|
+
onStale: onStaleModeSchema.nullish(),
|
|
300
|
+
fenceToken: z.number().nullish(),
|
|
301
|
+
};
|
|
302
|
+
/** One write inside a commit, in the canonical spelling. */
|
|
303
|
+
export const commitOperationBodySchema = z.object({
|
|
304
|
+
...commitOperationControlShape,
|
|
305
|
+
action: z.string(),
|
|
306
|
+
model: z.string(),
|
|
307
|
+
data: z.record(z.string(), z.unknown()).nullish(),
|
|
308
|
+
});
|
|
309
|
+
/**
|
|
310
|
+
* The `POST /v1/commits` request body.
|
|
311
|
+
*
|
|
312
|
+
* `operations` carries the writes; `track` registers durable premises.
|
|
313
|
+
* Neither is required on its own, because a body with `track` and no
|
|
314
|
+
* `operations` is how a caller starts watching a row without writing to it.
|
|
315
|
+
* Request identity travels in the `Idempotency-Key` header.
|
|
316
|
+
*/
|
|
317
|
+
export const commitRequestSchema = z.object({
|
|
318
|
+
operations: z.array(commitOperationBodySchema).min(1).optional(),
|
|
319
|
+
reads: z.array(readDependencySchema).nullish(),
|
|
320
|
+
track: z.array(trackDependencySchema).nullish(),
|
|
321
|
+
});
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* one definition and cannot drift apart. This is the delta's home in the wire
|
|
6
6
|
* layer, alongside the other protocol shapes in `wire/`.
|
|
7
7
|
*
|
|
8
|
-
* The wire delta is a projection of the stored `sync_deltas` row (
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* The wire delta is a projection of the stored `sync_deltas` row (the
|
|
9
|
+
* `syncDeltaRowSchema` in `../log/syncDeltaRow.ts`) and differs from it
|
|
10
|
+
* in three ways: it omits `organizationId` (the tenant-isolation predicate is
|
|
11
11
|
* never broadcast), it uses the full action vocabulary (see
|
|
12
12
|
* {@link syncDeltaActionSchema}) rather than plain create, update, and delete, and
|
|
13
13
|
* it carries attribution as nested {@link ParticipantRef}s instead of flat columns.
|
|
@@ -18,19 +18,18 @@
|
|
|
18
18
|
* - {@link serverSyncDeltaSchema} — the core plus the audit attribution the server
|
|
19
19
|
* adds to each broadcast, which the client ignores.
|
|
20
20
|
*
|
|
21
|
-
* The
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
21
|
+
* The participant vocabulary the delta carries is declared once elsewhere and
|
|
22
|
+
* re-served here: the actor union lives in `types/participant.ts` and its
|
|
23
|
+
* runtime validator in `coordination/schema.ts`. Only `confirmationState` has
|
|
24
|
+
* its home in this module, since the approval stage of a committed change is
|
|
25
|
+
* delta attribution and nothing else. All three mirror Postgres enums.
|
|
25
26
|
*/
|
|
26
27
|
import { z } from 'zod';
|
|
27
|
-
/** `participant_kind` — who a delta is attributed to.
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}>;
|
|
33
|
-
export type ParticipantKind = z.infer<typeof participantKindSchema>;
|
|
28
|
+
/** `participant_kind` — who a delta is attributed to. Declared in
|
|
29
|
+
* `coordination/schema.ts`; re-exported so the wire subpath serves the
|
|
30
|
+
* vocabulary its delta shapes carry. */
|
|
31
|
+
export { participantKindSchema } from '../coordination/schema.js';
|
|
32
|
+
export type { ParticipantKind } from '../types/participant.js';
|
|
34
33
|
/** `confirmation_state` — the approval stage a committed change was in. */
|
|
35
34
|
export declare const confirmationStateSchema: z.ZodEnum<{
|
|
36
35
|
auto: "auto";
|
|
@@ -69,7 +68,9 @@ export type WireDeltaData = z.infer<typeof wireDeltaDataSchema>;
|
|
|
69
68
|
/**
|
|
70
69
|
* A participant reference as carried on a broadcast delta. The server expands the
|
|
71
70
|
* flat `actor_id` and `actor_kind` stored columns into this nested `{ kind, id }`
|
|
72
|
-
* shape.
|
|
71
|
+
* shape. The type is the canonical {@link ParticipantRef} from
|
|
72
|
+
* `types/participant.ts`; the pin below fails to compile if this schema and the
|
|
73
|
+
* canonical shape ever drift.
|
|
73
74
|
*/
|
|
74
75
|
export declare const participantRefSchema: z.ZodObject<{
|
|
75
76
|
kind: z.ZodEnum<{
|
|
@@ -79,7 +80,7 @@ export declare const participantRefSchema: z.ZodObject<{
|
|
|
79
80
|
}>;
|
|
80
81
|
id: z.ZodString;
|
|
81
82
|
}, z.core.$strip>;
|
|
82
|
-
export type ParticipantRef
|
|
83
|
+
export type { ParticipantRef } from '../types/participant.js';
|
|
83
84
|
/**
|
|
84
85
|
* The fields the server and client agree on for a broadcast delta — the shared core
|
|
85
86
|
* both projections extend. `transactionId` is typed as the client sees it (an
|
|
@@ -196,6 +197,54 @@ export declare const serverSyncDeltaSchema: z.ZodObject<{
|
|
|
196
197
|
required_human_approval: "required_human_approval";
|
|
197
198
|
auto_historical: "auto_historical";
|
|
198
199
|
}>>;
|
|
199
|
-
causedByTaskId: z.ZodNullable<z.ZodString>;
|
|
200
200
|
}, z.core.$strip>;
|
|
201
201
|
export type ServerSyncDelta = z.infer<typeof serverSyncDeltaSchema>;
|
|
202
|
+
/**
|
|
203
|
+
* The transaction-layer seam's transport-neutral projection of a broadcast
|
|
204
|
+
* delta. It removes delivery plumbing (`syncGroups`, `transactionId`, and
|
|
205
|
+
* `correlationId`) while retaining the row change and optional audit
|
|
206
|
+
* attribution. `TransactionLayer.observe()` yields this shape.
|
|
207
|
+
*/
|
|
208
|
+
export declare const deltaSchema: z.ZodObject<{
|
|
209
|
+
id: z.ZodNumber;
|
|
210
|
+
data: z.ZodNullable<z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodString]>>;
|
|
211
|
+
actionType: z.ZodEnum<{
|
|
212
|
+
I: "I";
|
|
213
|
+
U: "U";
|
|
214
|
+
D: "D";
|
|
215
|
+
A: "A";
|
|
216
|
+
V: "V";
|
|
217
|
+
C: "C";
|
|
218
|
+
G: "G";
|
|
219
|
+
S: "S";
|
|
220
|
+
}>;
|
|
221
|
+
modelName: z.ZodString;
|
|
222
|
+
modelId: z.ZodString;
|
|
223
|
+
previousData: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodRecord<z.ZodString, z.ZodUnknown>, z.ZodString]>>>;
|
|
224
|
+
createdAt: z.ZodString;
|
|
225
|
+
actor: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
226
|
+
kind: z.ZodEnum<{
|
|
227
|
+
user: "user";
|
|
228
|
+
agent: "agent";
|
|
229
|
+
system: "system";
|
|
230
|
+
}>;
|
|
231
|
+
id: z.ZodString;
|
|
232
|
+
}, z.core.$strip>>>;
|
|
233
|
+
onBehalfOf: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
234
|
+
kind: z.ZodEnum<{
|
|
235
|
+
user: "user";
|
|
236
|
+
agent: "agent";
|
|
237
|
+
system: "system";
|
|
238
|
+
}>;
|
|
239
|
+
id: z.ZodString;
|
|
240
|
+
}, z.core.$strip>>>;
|
|
241
|
+
capabilityId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
242
|
+
confirmationState: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
243
|
+
auto: "auto";
|
|
244
|
+
previewed: "previewed";
|
|
245
|
+
approved: "approved";
|
|
246
|
+
required_human_approval: "required_human_approval";
|
|
247
|
+
auto_historical: "auto_historical";
|
|
248
|
+
}>>>;
|
|
249
|
+
}, z.core.$strip>;
|
|
250
|
+
export type Delta = z.infer<typeof deltaSchema>;
|