@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
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The footprint — every object Ablo leaves inside a customer's own database,
|
|
3
|
+
* declared once.
|
|
4
|
+
*
|
|
5
|
+
* Four things need this list and each used to carry its own copy: the setup SQL
|
|
6
|
+
* that creates the objects, the replication runtime that reads them, the audit
|
|
7
|
+
* that tells a customer what Ablo put there, and (eventually) the teardown that
|
|
8
|
+
* removes them. They drifted, as hand-maintained copies do — `ABLO_PUBLICATION`
|
|
9
|
+
* was declared twice, under a comment insisting the literals "MUST equal the
|
|
10
|
+
* CLI's" and pointing at a file that no longer held it, and the audit went on
|
|
11
|
+
* looking for a footprint from an earlier era while seeing none of what Ablo
|
|
12
|
+
* installs today.
|
|
13
|
+
*
|
|
14
|
+
* The audit is the copy that matters most. A customer runs it to answer "what is
|
|
15
|
+
* still in my database", and a stale list answers "nothing" — which reads as
|
|
16
|
+
* clean rather than as unexamined. So the list lives here, every consumer
|
|
17
|
+
* derives from it, and an object added to Ablo's setup is visible to the audit
|
|
18
|
+
* because it could not have been added anywhere else.
|
|
19
|
+
*
|
|
20
|
+
* Retired objects stay in the list, marked {@link FootprintArtifact.retired}.
|
|
21
|
+
* They are no longer installed, but a database connected to an older Ablo still
|
|
22
|
+
* holds them, and those are precisely the ones a customer would never think to
|
|
23
|
+
* look for.
|
|
24
|
+
*/
|
|
25
|
+
/** The Postgres object class, which decides how the audit looks it up. */
|
|
26
|
+
export type FootprintKind = 'publication' | 'slot' | 'role' | 'table' | 'type';
|
|
27
|
+
export interface FootprintArtifact {
|
|
28
|
+
readonly kind: FootprintKind;
|
|
29
|
+
readonly name: string;
|
|
30
|
+
/** What it is for, in the words a customer reading an audit would want. */
|
|
31
|
+
readonly purpose: string;
|
|
32
|
+
/**
|
|
33
|
+
* Installed only for a data source that reports through the signed endpoint
|
|
34
|
+
* rather than the write-ahead log.
|
|
35
|
+
*/
|
|
36
|
+
readonly endpointOnly?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* No longer installed by any current version. A database that once ran an
|
|
39
|
+
* older Ablo still holds it; the audit reports it so it can be cleaned up.
|
|
40
|
+
*/
|
|
41
|
+
readonly retired?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* What it costs to leave behind, when leaving it behind costs something. The
|
|
44
|
+
* audit leads with this, because "you still have an object named X" is not a
|
|
45
|
+
* reason to act and "this one is retaining your write-ahead log" is.
|
|
46
|
+
*/
|
|
47
|
+
readonly hazard?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The publication Ablo's replication reads from. Constant by design: a
|
|
51
|
+
* publication declares what streams, and several readers are meant to share one
|
|
52
|
+
* (`publication_names` is a per-stream option, not slot state).
|
|
53
|
+
*/
|
|
54
|
+
export declare const ABLO_PUBLICATION = "ablo_publication";
|
|
55
|
+
/**
|
|
56
|
+
* The replication slot that holds Ablo's position in the write-ahead log.
|
|
57
|
+
*
|
|
58
|
+
* Constant, and it should not be — a slot stores ONE position, so two
|
|
59
|
+
* connections sharing this name compete for the same marker. It is why a
|
|
60
|
+
* database can be connected to one plane at a time. ADR 0020 derives it per
|
|
61
|
+
* connection; {@link isValidReplicationSlotName} is the check a derived name
|
|
62
|
+
* has to pass.
|
|
63
|
+
*/
|
|
64
|
+
export declare const ABLO_REPLICATION_SLOT = "ablo_slot";
|
|
65
|
+
/** The least-privilege login Ablo reads with. Per-connection under ADR 0020. */
|
|
66
|
+
export declare const ABLO_REPLICATION_ROLE = "ablo_replicator";
|
|
67
|
+
/** The separate least-privilege login used only for row writes. */
|
|
68
|
+
export declare const ABLO_WRITE_ROLE = "ablo_writer";
|
|
69
|
+
/** The bookkeeping table that makes a retried write land once. */
|
|
70
|
+
export declare const ABLO_IDEMPOTENCY_TABLE = "ablo_idempotency";
|
|
71
|
+
/** The transactional outbox an endpoint source reports through. */
|
|
72
|
+
export declare const ABLO_OUTBOX_TABLE = "ablo_outbox";
|
|
73
|
+
/**
|
|
74
|
+
* Postgres will not accept a replication slot name outside this shape — the
|
|
75
|
+
* check is in `ReplicationSlotValidateNameInternal`, and identifier quoting does
|
|
76
|
+
* not exempt a name from it. Anything derived into a slot name is validated
|
|
77
|
+
* here, at the point it is derived, rather than failing at the point it is used.
|
|
78
|
+
*/
|
|
79
|
+
export declare const REPLICATION_SLOT_NAME: RegExp;
|
|
80
|
+
export declare function isValidReplicationSlotName(name: string): boolean;
|
|
81
|
+
/** The four plane axes a connection is identified by. */
|
|
82
|
+
export interface FootprintPlane {
|
|
83
|
+
readonly organizationId: string;
|
|
84
|
+
readonly environment: string;
|
|
85
|
+
/** '' for the organization-default project. */
|
|
86
|
+
readonly projectId?: string;
|
|
87
|
+
/** '' for the default sandbox. */
|
|
88
|
+
readonly sandboxId?: string;
|
|
89
|
+
}
|
|
90
|
+
/** The names one connection owns. Nothing here is shared with another plane. */
|
|
91
|
+
export interface FootprintNames {
|
|
92
|
+
readonly slot: string;
|
|
93
|
+
readonly publication: string;
|
|
94
|
+
readonly replicationRole: string;
|
|
95
|
+
readonly writeRole: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* The objects this connection owns, named so no other connection can claim them.
|
|
99
|
+
*
|
|
100
|
+
* A slot stores ONE position, so two connections sharing a name compete for the
|
|
101
|
+
* same marker and Postgres reports nothing — which is why the constants these
|
|
102
|
+
* replace made a database connectable to one plane at a time. The publication
|
|
103
|
+
* and roles are derived from the same digest so a database's footprint reads as
|
|
104
|
+
* one set per connection rather than a mix of shared and private objects.
|
|
105
|
+
*
|
|
106
|
+
* Stable: the same plane always derives the same names, so re-running setup is a
|
|
107
|
+
* no-op rather than a second installation.
|
|
108
|
+
*/
|
|
109
|
+
export declare function footprintNamesFor(plane: FootprintPlane): FootprintNames;
|
|
110
|
+
/** Everything Ablo has ever put in a customer's database, current and retired. */
|
|
111
|
+
export declare const ABLO_FOOTPRINT: readonly FootprintArtifact[];
|
|
Binary file
|
|
@@ -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 './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 './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.
|
|
@@ -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)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* A local, IndexedDB-backed store for the sync actions (change deltas) the
|
|
3
3
|
* server sends. See {@link SyncActionStore}.
|
|
4
4
|
*/
|
|
5
|
-
import type
|
|
5
|
+
import { type SyncAction } from './syncAction.js';
|
|
6
6
|
/**
|
|
7
7
|
* Stores the sync actions (the change deltas) the server sends, keyed by
|
|
8
8
|
* their sync id, and tracks which ones have been applied. It keeps a
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* server sends. See {@link SyncActionStore}.
|
|
4
4
|
*/
|
|
5
5
|
// Uses native IndexedDB for maximum performance
|
|
6
|
-
import { z } from 'zod';
|
|
7
6
|
import { getContext } from '../context.js';
|
|
7
|
+
import { syncActionSchema } from './syncAction.js';
|
|
8
8
|
/**
|
|
9
9
|
* The validation boundary for rows read back from the store. A row may have
|
|
10
10
|
* been written by an earlier session, so this build cannot assume its shape.
|
|
@@ -13,17 +13,9 @@ import { getContext } from '../context.js';
|
|
|
13
13
|
* {@link SyncAction}. A row that fails to parse is dropped and logged rather
|
|
14
14
|
* than replayed as a malformed delta.
|
|
15
15
|
*/
|
|
16
|
-
const storedSyncActionSchema = z.object({
|
|
17
|
-
id: z.number(),
|
|
18
|
-
modelName: z.string(),
|
|
19
|
-
modelId: z.string(),
|
|
20
|
-
action: z.enum(['I', 'U', 'A', 'D', 'C', 'G', 'S', 'V']),
|
|
21
|
-
data: z.unknown(),
|
|
22
|
-
__class: z.literal('SyncAction').default('SyncAction'),
|
|
23
|
-
});
|
|
24
16
|
/** Parse one stored row into a SyncAction, or `null` (dropped + logged). */
|
|
25
17
|
function toSyncAction(row) {
|
|
26
|
-
const parsed =
|
|
18
|
+
const parsed = syncActionSchema.safeParse(row);
|
|
27
19
|
if (!parsed.success) {
|
|
28
20
|
getContext().logger.debug('[SyncActionStore] Dropping malformed stored sync action', {
|
|
29
21
|
issues: parsed.error.issues.map((i) => i.path.join('.')).join(', '),
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The persisted local action record consumed by `SyncActionStore`. It is a
|
|
3
|
+
* client materialization artifact, not a transaction-layer wire shape: the
|
|
4
|
+
* authoritative broadcast vocabulary is the settlement core's delta wire
|
|
5
|
+
* schema, while this one adds the local `__class` discriminator IndexedDB uses.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
export declare const syncActionSchema: z.ZodObject<{
|
|
9
|
+
id: z.ZodNumber;
|
|
10
|
+
modelName: z.ZodString;
|
|
11
|
+
modelId: z.ZodString;
|
|
12
|
+
action: z.ZodEnum<{
|
|
13
|
+
I: "I";
|
|
14
|
+
U: "U";
|
|
15
|
+
D: "D";
|
|
16
|
+
A: "A";
|
|
17
|
+
V: "V";
|
|
18
|
+
C: "C";
|
|
19
|
+
G: "G";
|
|
20
|
+
S: "S";
|
|
21
|
+
}>;
|
|
22
|
+
data: z.ZodUnknown;
|
|
23
|
+
__class: z.ZodDefault<z.ZodLiteral<"SyncAction">>;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
export type SyncAction = z.infer<typeof syncActionSchema>;
|
|
26
|
+
export type SyncActionType = SyncAction['action'];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The persisted local action record consumed by `SyncActionStore`. It is a
|
|
3
|
+
* client materialization artifact, not a transaction-layer wire shape: the
|
|
4
|
+
* authoritative broadcast vocabulary is the settlement core's delta wire
|
|
5
|
+
* schema, while this one adds the local `__class` discriminator IndexedDB uses.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import { syncDeltaActionSchema } from '../transaction/wire/delta.js';
|
|
9
|
+
export const syncActionSchema = z.object({
|
|
10
|
+
id: z.number(),
|
|
11
|
+
modelName: z.string(),
|
|
12
|
+
modelId: z.string(),
|
|
13
|
+
action: syncDeltaActionSchema,
|
|
14
|
+
data: z.unknown(),
|
|
15
|
+
__class: z.literal('SyncAction').default('SyncAction'),
|
|
16
|
+
});
|
package/dist/surface.d.ts
CHANGED
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
* tuple, so it is the one list of model-verb names a generated summary can
|
|
20
20
|
* describe.
|
|
21
21
|
*/
|
|
22
|
-
export declare const PUBLIC_MODEL_VERBS: readonly ["retrieve", "list", "
|
|
22
|
+
export declare const PUBLIC_MODEL_VERBS: readonly ["retrieve", "list", "local", "create", "update", "delete", "claim", "track", "join", "onChange"];
|
|
23
23
|
/**
|
|
24
|
-
* The option keys accepted by `list
|
|
24
|
+
* The option keys accepted by `local.list` and `onChange`, matching the
|
|
25
25
|
* keys of {@link LocalReadOptions}. Note that the lifecycle filter is named
|
|
26
26
|
* `state`, not `scope`.
|
|
27
27
|
*/
|
|
@@ -30,7 +30,7 @@ export declare const PUBLIC_LIST_OPTION_KEYS: readonly ["where", "filter", "orde
|
|
|
30
30
|
* The keys of the client constructor options, {@link AbloOptions}. Only
|
|
31
31
|
* `schema` is required; every other key is optional.
|
|
32
32
|
*/
|
|
33
|
-
export declare const PUBLIC_ABLO_OPTION_KEYS: readonly ["schema", "apiKey", "authEndpoint", "persistence", "durableWrites", "commitOutbox", "commitOutboxScope", "transport", "debug", "logLevel", "authToken", "baseURL", "fetch", "defaultHeaders", "defaultQuery", "dangerouslyAllowBrowser"];
|
|
33
|
+
export declare const PUBLIC_ABLO_OPTION_KEYS: readonly ["schema", "apiKey", "authEndpoint", "persistence", "durableWrites", "commitOutbox", "commitOutboxScope", "transport", "debug", "logLevel", "logger", "authToken", "baseURL", "fetch", "defaultHeaders", "defaultQuery", "dangerouslyAllowBrowser", "collaborationEvents", "plugins", "wait"];
|
|
34
34
|
export type ModelVerb = (typeof PUBLIC_MODEL_VERBS)[number];
|
|
35
35
|
export type ListOptionKey = (typeof PUBLIC_LIST_OPTION_KEYS)[number];
|
|
36
36
|
export type AbloOptionKey = (typeof PUBLIC_ABLO_OPTION_KEYS)[number];
|
package/dist/surface.js
CHANGED
|
@@ -23,9 +23,7 @@
|
|
|
23
23
|
export const PUBLIC_MODEL_VERBS = [
|
|
24
24
|
'retrieve',
|
|
25
25
|
'list',
|
|
26
|
-
'
|
|
27
|
-
'getAll',
|
|
28
|
-
'getCount',
|
|
26
|
+
'local',
|
|
29
27
|
'create',
|
|
30
28
|
'update',
|
|
31
29
|
'delete',
|
|
@@ -36,7 +34,7 @@ export const PUBLIC_MODEL_VERBS = [
|
|
|
36
34
|
];
|
|
37
35
|
// ── the read/list query option surface ─────────────────────────────────────
|
|
38
36
|
/**
|
|
39
|
-
* The option keys accepted by `list
|
|
37
|
+
* The option keys accepted by `local.list` and `onChange`, matching the
|
|
40
38
|
* keys of {@link LocalReadOptions}. Note that the lifecycle filter is named
|
|
41
39
|
* `state`, not `scope`.
|
|
42
40
|
*/
|
|
@@ -64,10 +62,14 @@ export const PUBLIC_ABLO_OPTION_KEYS = [
|
|
|
64
62
|
'transport',
|
|
65
63
|
'debug',
|
|
66
64
|
'logLevel',
|
|
65
|
+
'logger',
|
|
67
66
|
'authToken',
|
|
68
67
|
'baseURL',
|
|
69
68
|
'fetch',
|
|
70
69
|
'defaultHeaders',
|
|
71
70
|
'defaultQuery',
|
|
72
71
|
'dangerouslyAllowBrowser',
|
|
72
|
+
'collaborationEvents',
|
|
73
|
+
'plugins',
|
|
74
|
+
'wait',
|
|
73
75
|
];
|
|
@@ -27,6 +27,12 @@ export interface BootstrapData {
|
|
|
27
27
|
* when the app's schema and the deployed schema have drifted apart.
|
|
28
28
|
*/
|
|
29
29
|
schemaHash?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Present when a paged single-model request stopped at its row limit with
|
|
32
|
+
* rows remaining: pass it back as the next page's `cursor`. Absent on the
|
|
33
|
+
* final page, on unpaged responses, and from servers that predate paging.
|
|
34
|
+
*/
|
|
35
|
+
nextCursor?: string;
|
|
30
36
|
}
|
|
31
37
|
export interface BootstrapFetchResult {
|
|
32
38
|
notModified: boolean;
|
|
@@ -58,8 +64,23 @@ export interface BootstrapOptions {
|
|
|
58
64
|
syncGroups?: string[];
|
|
59
65
|
maxRetries?: number;
|
|
60
66
|
retryDelay?: number;
|
|
61
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* How long to wait for the server to START responding (response headers), in
|
|
69
|
+
* milliseconds. Default 20000 (20 seconds).
|
|
70
|
+
*
|
|
71
|
+
* Deliberately NOT a bound on the whole download: a cold-start snapshot can
|
|
72
|
+
* be tens of megabytes, and its transfer time depends on the connection. A
|
|
73
|
+
* healthy download that is actively delivering bytes is never aborted, no
|
|
74
|
+
* matter how long it takes — {@link stallTimeout} guards the body instead.
|
|
75
|
+
*/
|
|
62
76
|
fetchTimeout?: number;
|
|
77
|
+
/**
|
|
78
|
+
* The longest quiet gap allowed between body chunks while downloading, in
|
|
79
|
+
* milliseconds. Default 15000 (15 seconds). This is the progress watchdog:
|
|
80
|
+
* it aborts a download whose stream has gone silent (dead connection,
|
|
81
|
+
* hung proxy) without ever penalizing a slow-but-moving transfer.
|
|
82
|
+
*/
|
|
83
|
+
stallTimeout?: number;
|
|
63
84
|
/**
|
|
64
85
|
* The model names to request. When set, the server returns only these models
|
|
65
86
|
* and skips the rest. This is derived from each model's `load` strategy: only
|
|
@@ -74,13 +95,48 @@ export interface BootstrapOptions {
|
|
|
74
95
|
*/
|
|
75
96
|
getAuthToken?: AuthTokenGetter;
|
|
76
97
|
}
|
|
77
|
-
import { type AuthTokenGetter } from '../auth/credentialSource.js';
|
|
98
|
+
import { type AuthTokenGetter } from '../transaction/auth/credentialSource.js';
|
|
78
99
|
import { type ValidatedServerDelta } from './schemas.js';
|
|
79
100
|
export declare class BootstrapFetcher {
|
|
80
101
|
private options;
|
|
81
|
-
|
|
102
|
+
/**
|
|
103
|
+
* Every in-flight request's controller, tagged with the lane it belongs to. A
|
|
104
|
+
* registry rather than a single field because a chunked cold start runs
|
|
105
|
+
* several model fetches concurrently — aborting one request (its own
|
|
106
|
+
* TTFB/stall watchdog) must never take its siblings down, while
|
|
107
|
+
* {@link abort} takes down all of them.
|
|
108
|
+
*/
|
|
109
|
+
private readonly activeControllers;
|
|
110
|
+
/**
|
|
111
|
+
* Non-scoped bootstraps currently running, keyed by request identity. A
|
|
112
|
+
* second call for the same snapshot joins the one already in flight rather
|
|
113
|
+
* than cancelling and restarting it — see {@link fetchBootstrap}.
|
|
114
|
+
*/
|
|
115
|
+
private readonly flights;
|
|
82
116
|
/** Warn about schema drift at most once per helper. */
|
|
83
117
|
private schemaDriftWarned;
|
|
118
|
+
/**
|
|
119
|
+
* Abort every in-flight request in `lane` — or in every lane when none is
|
|
120
|
+
* given — with an explicit reason.
|
|
121
|
+
*
|
|
122
|
+
* The reason is load-bearing, not decoration. `fetch` rejects with the exact
|
|
123
|
+
* value handed to `abort()`, so passing a typed error is what lets the retry
|
|
124
|
+
* loop below tell a deliberate cancellation apart from a dead connection. A
|
|
125
|
+
* bare `abort()` produces an `AbortError` indistinguishable from the one the
|
|
126
|
+
* browser's stop button produces, and a retry loop that cannot tell them
|
|
127
|
+
* apart re-issues the requests it just killed.
|
|
128
|
+
*/
|
|
129
|
+
private cancelActive;
|
|
130
|
+
/**
|
|
131
|
+
* The longest a single bootstrap can run before every watchdog below has
|
|
132
|
+
* necessarily fired, derived from those watchdogs rather than guessed. A
|
|
133
|
+
* caller wanting an outer deadline reads this instead of picking a number,
|
|
134
|
+
* so it cannot set one shorter than the work it wraps. A cold start pages
|
|
135
|
+
* through its models {@link CHUNK_CONCURRENCY} at a time; each request may
|
|
136
|
+
* spend `fetchTimeout` waiting for response headers and `stallTimeout`
|
|
137
|
+
* waiting for the next body chunk, and may be retried `maxRetries` times.
|
|
138
|
+
*/
|
|
139
|
+
get budgetMs(): number;
|
|
84
140
|
get baseUrl(): string;
|
|
85
141
|
/**
|
|
86
142
|
* Advisory schema-drift check: compare the server's active schema hash (on the
|
|
@@ -100,6 +156,10 @@ export declare class BootstrapFetcher {
|
|
|
100
156
|
* common wrong-target and version-skew cases.
|
|
101
157
|
*/
|
|
102
158
|
private warnOnSchemaDrift;
|
|
159
|
+
/** Fetch the server's per-model schema surface and warn precisely — or stay
|
|
160
|
+
* silent when every model this client declares matches (additive lead). */
|
|
161
|
+
private resolveSemanticDrift;
|
|
162
|
+
private warnWholeHashDrift;
|
|
103
163
|
constructor(options: BootstrapOptions);
|
|
104
164
|
/**
|
|
105
165
|
* Update the offline-cache namespace once auth has resolved the server-side
|
|
@@ -127,14 +187,54 @@ export declare class BootstrapFetcher {
|
|
|
127
187
|
* request.
|
|
128
188
|
*/
|
|
129
189
|
syncGroupsOverride?: readonly string[]): Promise<BootstrapData>;
|
|
190
|
+
/**
|
|
191
|
+
* The identity of a bootstrap request: everything that determines its answer.
|
|
192
|
+
* Two calls with the same key are asking the same question, so the second can
|
|
193
|
+
* take the first's result.
|
|
194
|
+
*/
|
|
195
|
+
private flightKey;
|
|
196
|
+
/** One bootstrap, start to finish. {@link fetchBootstrap} owns whether it runs. */
|
|
197
|
+
private runBootstrap;
|
|
198
|
+
/**
|
|
199
|
+
* One bootstrap URL, fetched with backoff. Session errors and other
|
|
200
|
+
* non-retryable failures throw immediately; only transient failures
|
|
201
|
+
* (5xx, 429, timeouts, network blips) consume attempts. A cancellation is
|
|
202
|
+
* deliberate and therefore non-retryable — it leaves through the same gate.
|
|
203
|
+
*/
|
|
204
|
+
private fetchWithRetries;
|
|
205
|
+
/**
|
|
206
|
+
* Cold-start bootstrap, one request per instant model with a small
|
|
207
|
+
* concurrency cap. Any chunk's terminal failure fails the whole
|
|
208
|
+
* bootstrap (a partial snapshot must never masquerade as a full one)
|
|
209
|
+
* and cancels its siblings.
|
|
210
|
+
*/
|
|
211
|
+
private fetchChunkedBootstrap;
|
|
130
212
|
/**
|
|
131
213
|
* Fetch bootstrap with ETag, returning 304 hints
|
|
132
214
|
*/
|
|
133
215
|
fetchBootstrapWithETag(): Promise<BootstrapFetchResult>;
|
|
216
|
+
private fetchWithETagUsing;
|
|
217
|
+
/**
|
|
218
|
+
* Read a response body as a stream under a progress watchdog: the stall
|
|
219
|
+
* timer re-arms on every chunk, so only a silent stream is aborted — a
|
|
220
|
+
* slow-but-moving download is never killed for total duration. A cold-start
|
|
221
|
+
* snapshot can be tens of megabytes; bounding its total transfer time was
|
|
222
|
+
* what trapped large orgs in an endless full-bootstrap retry loop.
|
|
223
|
+
*
|
|
224
|
+
* Falls back to `response.json()` when the response exposes no readable
|
|
225
|
+
* stream (empty bodies, some test doubles).
|
|
226
|
+
*/
|
|
227
|
+
private readJsonWithStallGuard;
|
|
134
228
|
/**
|
|
135
|
-
* Perform
|
|
229
|
+
* Perform one fetch. The timeout here bounds time to response headers
|
|
230
|
+
* only; the body download is guarded by the stall watchdog in
|
|
231
|
+
* {@link readJsonWithStallGuard}. Superseding an older in-flight
|
|
232
|
+
* bootstrap is the caller's job ({@link fetchBootstrap} cancels the
|
|
233
|
+
* registry) — chunk requests run through here concurrently and must
|
|
234
|
+
* not cancel each other.
|
|
136
235
|
*/
|
|
137
|
-
private
|
|
236
|
+
private fetchOnce;
|
|
237
|
+
private fetchOnceWith;
|
|
138
238
|
/**
|
|
139
239
|
* Fetch a single entity by ID (on-demand self-healing).
|
|
140
240
|
* Returns `null` for 404 (entity deleted) — this is an expected state, not an error.
|
|
@@ -149,7 +249,12 @@ export declare class BootstrapFetcher {
|
|
|
149
249
|
private saveCachedBootstrap;
|
|
150
250
|
private loadCachedBootstrap;
|
|
151
251
|
/**
|
|
152
|
-
* Abort ongoing
|
|
252
|
+
* Abort every ongoing bootstrap request (including all chunks of a
|
|
253
|
+
* chunked cold start). Entity self-heal fetches are unaffected.
|
|
254
|
+
*
|
|
255
|
+
* The flight registry is cleared first and synchronously, so a caller that
|
|
256
|
+
* bootstraps again in the same tick starts a fresh request rather than
|
|
257
|
+
* joining the one being torn down.
|
|
153
258
|
*/
|
|
154
259
|
abort(): void;
|
|
155
260
|
/**
|
|
@@ -161,3 +266,15 @@ export declare class BootstrapFetcher {
|
|
|
161
266
|
*/
|
|
162
267
|
checkHealth(): Promise<boolean>;
|
|
163
268
|
}
|
|
269
|
+
/**
|
|
270
|
+
* Assemble per-model chunk responses into one full snapshot.
|
|
271
|
+
*
|
|
272
|
+
* Each chunk is internally consistent at its own sync position, and the
|
|
273
|
+
* positions differ (the chunks were served seconds apart). Anchoring the
|
|
274
|
+
* merged snapshot at the MINIMUM position turns that skew into an ordinary
|
|
275
|
+
* "briefly offline client": the WS catch-up replays every delta from the
|
|
276
|
+
* anchor, and since deltas carry full rows, re-applying one a later chunk
|
|
277
|
+
* already reflects converges to the same state. Anchoring at anything later
|
|
278
|
+
* would silently skip deltas for the earliest-fetched models.
|
|
279
|
+
*/
|
|
280
|
+
export declare function mergeBootstrapChunks(chunks: readonly BootstrapData[]): BootstrapData;
|