@abloatai/ablo 0.36.0 → 0.37.1
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 -2
- package/CHANGELOG.md +55 -2014
- package/NOTICE +2 -2
- package/README.md +45 -63
- package/assets/banner.png +0 -0
- package/dist/auth.d.ts +2 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +2 -0
- package/dist/auth.js.map +1 -0
- package/dist/client.d.ts +3 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +3 -0
- package/dist/client.js.map +1 -0
- package/dist/coordination.d.ts +2 -0
- package/dist/coordination.d.ts.map +1 -0
- package/dist/coordination.js +2 -0
- package/dist/coordination.js.map +1 -0
- package/dist/index.d.ts +3 -114
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -163
- package/dist/index.js.map +1 -0
- package/dist/react.d.ts +4 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +3 -0
- package/dist/react.js.map +1 -0
- package/dist/schema.d.ts +2 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +2 -0
- package/dist/schema.js.map +1 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +2 -0
- package/dist/server.js.map +1 -0
- package/dist/source-conformance.d.ts +2 -0
- package/dist/source-conformance.d.ts.map +1 -0
- package/dist/source-conformance.js +2 -0
- package/dist/source-conformance.js.map +1 -0
- package/dist/source-drizzle.d.ts +2 -0
- package/dist/source-drizzle.d.ts.map +1 -0
- package/dist/source-drizzle.js +2 -0
- package/dist/source-drizzle.js.map +1 -0
- package/dist/source-kysely.d.ts +2 -0
- package/dist/source-kysely.d.ts.map +1 -0
- package/dist/source-kysely.js +2 -0
- package/dist/source-kysely.js.map +1 -0
- package/dist/source-next.d.ts +2 -0
- package/dist/source-next.d.ts.map +1 -0
- package/dist/source-next.js +2 -0
- package/dist/source-next.js.map +1 -0
- package/dist/source.d.ts +2 -0
- package/dist/source.d.ts.map +1 -0
- package/dist/source.js +2 -0
- package/dist/source.js.map +1 -0
- package/dist/wire.d.ts +2 -0
- package/dist/wire.d.ts.map +1 -0
- package/dist/wire.js +2 -0
- package/dist/wire.js.map +1 -0
- package/docs/agents.md +1 -1
- package/docs/api-keys.md +7 -6
- package/docs/api.md +10 -10
- package/docs/client-behavior.md +5 -5
- package/docs/coordination.md +52 -62
- package/docs/data-sources.md +1 -1
- package/docs/examples/agent-human.md +4 -4
- package/docs/examples/ai-sdk-tool.md +1 -1
- package/docs/examples/existing-python-backend.md +15 -4
- package/docs/examples/nextjs.md +27 -6
- package/docs/examples/server-agent.md +2 -2
- package/docs/how-it-works.md +4 -4
- package/docs/identity.md +2 -1
- package/docs/integration-guide.md +24 -13
- package/docs/internal/README.md +18 -0
- package/docs/internal/agent-fleet-coordination-design.md +171 -0
- package/docs/internal/agent-orchestration.md +58 -0
- package/docs/internal/commit-identifiers.md +91 -0
- package/docs/internal/concurrency-open-decisions.md +37 -0
- package/docs/internal/data-source-reverse-channel.md +150 -0
- package/docs/internal/per-field-conflict-detection.md +165 -0
- package/docs/internal/postgres-replication.md +64 -0
- package/docs/internal/serializable-schema.md +119 -0
- package/docs/internal/structure.md +32 -0
- package/docs/mcp.md +2 -2
- package/docs/migration.md +3 -3
- package/docs/quickstart.md +2 -2
- package/docs/react.md +5 -5
- package/docs/schema-contract.md +3 -3
- package/docs/sessions.md +91 -37
- package/examples/README.md +2 -2
- package/examples/data-source/README.md +1 -1
- package/examples/data-source/ablo-driver.ts +1 -1
- package/examples/data-source/customer-server.ts +1 -1
- package/examples/data-source/run.ts +1 -1
- package/examples/data-source/schema.ts +1 -1
- package/examples/quickstart.ts +2 -2
- package/llms.txt +8 -8
- package/package.json +63 -166
- package/bin/ablo.cjs +0 -39
- package/dist/BaseSyncedStore.d.ts +0 -843
- package/dist/BaseSyncedStore.js +0 -1971
- package/dist/Database.d.ts +0 -323
- package/dist/Database.js +0 -1502
- package/dist/InstanceCache.d.ts +0 -237
- package/dist/InstanceCache.js +0 -1166
- package/dist/LazyReferenceCollection.d.ts +0 -177
- package/dist/LazyReferenceCollection.js +0 -461
- package/dist/Model.d.ts +0 -454
- package/dist/Model.js +0 -919
- package/dist/ModelRegistry.d.ts +0 -225
- package/dist/ModelRegistry.js +0 -539
- package/dist/NetworkMonitor.d.ts +0 -28
- package/dist/NetworkMonitor.js +0 -79
- package/dist/RuntimeContext.d.ts +0 -52
- package/dist/RuntimeContext.js +0 -80
- package/dist/SyncClient.d.ts +0 -541
- package/dist/SyncClient.js +0 -2202
- package/dist/adapters/alwaysOnline.d.ts +0 -14
- package/dist/adapters/alwaysOnline.js +0 -17
- package/dist/adapters/inMemoryStorage.d.ts +0 -31
- package/dist/adapters/inMemoryStorage.js +0 -110
- package/dist/ai-sdk/coordinatedTool.d.ts +0 -120
- package/dist/ai-sdk/coordinatedTool.js +0 -134
- package/dist/ai-sdk/coordinationContext.d.ts +0 -46
- package/dist/ai-sdk/coordinationContext.js +0 -106
- package/dist/ai-sdk/index.d.ts +0 -121
- package/dist/ai-sdk/index.js +0 -121
- package/dist/ai-sdk/wrap.d.ts +0 -65
- package/dist/ai-sdk/wrap.js +0 -39
- package/dist/auth/index.d.ts +0 -1
- package/dist/auth/index.js +0 -8
- package/dist/batching/index.d.ts +0 -55
- package/dist/batching/index.js +0 -147
- package/dist/client/Ablo.d.ts +0 -231
- package/dist/client/Ablo.js +0 -160
- package/dist/client/abloClient.d.ts +0 -309
- package/dist/client/abloClient.js +0 -13
- package/dist/client/clientPrelude.d.ts +0 -52
- package/dist/client/clientPrelude.js +0 -60
- package/dist/client/consoleLogger.d.ts +0 -35
- package/dist/client/consoleLogger.js +0 -44
- package/dist/client/coreClient.d.ts +0 -60
- package/dist/client/coreClient.js +0 -118
- package/dist/client/createInternalComponents.d.ts +0 -50
- package/dist/client/createInternalComponents.js +0 -98
- package/dist/client/createModelProxy.d.ts +0 -248
- package/dist/client/createModelProxy.js +0 -884
- package/dist/client/humans.d.ts +0 -69
- package/dist/client/humans.js +0 -78
- package/dist/client/modelRegistration.d.ts +0 -10
- package/dist/client/modelRegistration.js +0 -312
- package/dist/client/options.d.ts +0 -461
- package/dist/client/options.js +0 -7
- package/dist/client/reactiveEngine.d.ts +0 -53
- package/dist/client/reactiveEngine.js +0 -688
- package/dist/client/resourceTypes.d.ts +0 -12
- package/dist/client/resourceTypes.js +0 -10
- package/dist/client/schemaConfig.d.ts +0 -44
- package/dist/client/schemaConfig.js +0 -185
- package/dist/client/storeCluster.d.ts +0 -47
- package/dist/client/storeCluster.js +0 -118
- package/dist/client/storeLifecycle.d.ts +0 -61
- package/dist/client/storeLifecycle.js +0 -231
- package/dist/client/validateAbloOptions.d.ts +0 -42
- package/dist/client/validateAbloOptions.js +0 -43
- package/dist/client/wsMutationExecutor.d.ts +0 -27
- package/dist/client/wsMutationExecutor.js +0 -72
- package/dist/context.d.ts +0 -42
- package/dist/context.js +0 -81
- package/dist/coordination/ClaimLog.d.ts +0 -26
- package/dist/coordination/ClaimLog.js +0 -32
- package/dist/coordination/index.d.ts +0 -1
- package/dist/coordination/index.js +0 -8
- package/dist/core/index.d.ts +0 -33
- package/dist/core/index.js +0 -48
- package/dist/docs/catalog.d.ts +0 -72
- package/dist/docs/catalog.js +0 -230
- package/dist/docs/index.d.ts +0 -10
- package/dist/docs/index.js +0 -10
- package/dist/environment.d.ts +0 -1
- package/dist/environment.js +0 -8
- package/dist/interfaces/index.d.ts +0 -311
- package/dist/interfaces/index.js +0 -9
- package/dist/keys/index.d.ts +0 -1
- package/dist/keys/index.js +0 -8
- package/dist/mutators/RecordingMutation.d.ts +0 -36
- package/dist/mutators/RecordingMutation.js +0 -182
- package/dist/mutators/Transaction.d.ts +0 -40
- package/dist/mutators/Transaction.js +0 -58
- package/dist/mutators/UndoManager.d.ts +0 -258
- package/dist/mutators/UndoManager.js +0 -658
- package/dist/mutators/defineMutators.d.ts +0 -60
- package/dist/mutators/defineMutators.js +0 -18
- package/dist/mutators/inverseOp.d.ts +0 -126
- package/dist/mutators/inverseOp.js +0 -71
- package/dist/mutators/mutateActions.d.ts +0 -45
- package/dist/mutators/mutateActions.js +0 -105
- package/dist/mutators/readerActions.d.ts +0 -33
- package/dist/mutators/readerActions.js +0 -57
- package/dist/mutators/undoApply.d.ts +0 -51
- package/dist/mutators/undoApply.js +0 -117
- package/dist/policy/index.d.ts +0 -21
- package/dist/policy/index.js +0 -20
- package/dist/query/QueryProcessor.d.ts +0 -75
- package/dist/query/QueryProcessor.js +0 -255
- package/dist/query/client.d.ts +0 -64
- package/dist/query/client.js +0 -138
- package/dist/query/types.d.ts +0 -85
- package/dist/query/types.js +0 -16
- package/dist/react/AbloProvider.d.ts +0 -242
- package/dist/react/AbloProvider.js +0 -458
- package/dist/react/ClientSideSuspense.d.ts +0 -36
- package/dist/react/ClientSideSuspense.js +0 -17
- package/dist/react/DefaultFallback.d.ts +0 -24
- package/dist/react/DefaultFallback.js +0 -43
- package/dist/react/context.d.ts +0 -55
- package/dist/react/context.js +0 -29
- package/dist/react/createAbloReact.d.ts +0 -56
- package/dist/react/createAbloReact.js +0 -51
- package/dist/react/index.d.ts +0 -62
- package/dist/react/index.js +0 -69
- package/dist/react/internalContext.d.ts +0 -33
- package/dist/react/internalContext.js +0 -3
- package/dist/react/useAblo.d.ts +0 -82
- package/dist/react/useAblo.js +0 -120
- package/dist/react/useCurrentUserId.d.ts +0 -22
- package/dist/react/useCurrentUserId.js +0 -34
- package/dist/react/useErrorListener.d.ts +0 -20
- package/dist/react/useErrorListener.js +0 -38
- package/dist/react/useMutationFailureListener.d.ts +0 -26
- package/dist/react/useMutationFailureListener.js +0 -38
- package/dist/react/useMutators.d.ts +0 -56
- package/dist/react/useMutators.js +0 -84
- package/dist/react/useReactive.d.ts +0 -35
- package/dist/react/useReactive.js +0 -123
- package/dist/react/useSyncStatus.d.ts +0 -59
- package/dist/react/useSyncStatus.js +0 -76
- package/dist/react/useUndoScope.d.ts +0 -34
- package/dist/react/useUndoScope.js +0 -81
- package/dist/schema/coordination.d.ts +0 -112
- package/dist/schema/coordination.js +0 -133
- package/dist/schema/ddl.d.ts +0 -97
- package/dist/schema/ddl.js +0 -491
- package/dist/schema/ddlLock.d.ts +0 -35
- package/dist/schema/ddlLock.js +0 -46
- package/dist/schema/diff.d.ts +0 -225
- package/dist/schema/diff.js +0 -289
- package/dist/schema/generate.d.ts +0 -19
- package/dist/schema/generate.js +0 -86
- package/dist/schema/index.d.ts +0 -42
- package/dist/schema/index.js +0 -80
- package/dist/schema/queries.d.ts +0 -201
- package/dist/schema/queries.js +0 -144
- package/dist/schema/select.d.ts +0 -40
- package/dist/schema/select.js +0 -90
- package/dist/schema/serialize.d.ts +0 -115
- package/dist/schema/serialize.js +0 -265
- package/dist/schema/sugar.d.ts +0 -109
- package/dist/schema/sugar.js +0 -83
- package/dist/schema/syncDeltaRow.d.ts +0 -6
- package/dist/schema/syncDeltaRow.js +0 -6
- package/dist/server/adapter.d.ts +0 -173
- package/dist/server/adapter.js +0 -18
- package/dist/server/commit.d.ts +0 -107
- package/dist/server/commit.js +0 -1
- package/dist/server/index.d.ts +0 -14
- package/dist/server/index.js +0 -2
- package/dist/server/readConfig.d.ts +0 -80
- package/dist/server/readConfig.js +0 -8
- package/dist/server/storageMode.d.ts +0 -23
- package/dist/server/storageMode.js +0 -17
- package/dist/source/adapter.d.ts +0 -83
- package/dist/source/adapter.js +0 -24
- package/dist/source/adapters/drizzle.d.ts +0 -48
- package/dist/source/adapters/drizzle.js +0 -219
- package/dist/source/adapters/kysely.d.ts +0 -42
- package/dist/source/adapters/kysely.js +0 -205
- package/dist/source/adapters/kyselyMutationCore.d.ts +0 -76
- package/dist/source/adapters/kyselyMutationCore.js +0 -125
- package/dist/source/adapters/memory.d.ts +0 -13
- package/dist/source/adapters/memory.js +0 -130
- package/dist/source/adapters/prisma.d.ts +0 -63
- package/dist/source/adapters/prisma.js +0 -202
- package/dist/source/conformance.d.ts +0 -37
- package/dist/source/conformance.js +0 -215
- package/dist/source/connector.d.ts +0 -95
- package/dist/source/connector.js +0 -266
- package/dist/source/connectorProtocol.d.ts +0 -154
- package/dist/source/connectorProtocol.js +0 -163
- package/dist/source/contract.d.ts +0 -195
- package/dist/source/contract.js +0 -164
- package/dist/source/factory.d.ts +0 -92
- package/dist/source/factory.js +0 -286
- package/dist/source/idempotency.d.ts +0 -61
- package/dist/source/idempotency.js +0 -144
- package/dist/source/index.d.ts +0 -23
- package/dist/source/index.js +0 -30
- package/dist/source/migrations.d.ts +0 -21
- package/dist/source/migrations.js +0 -103
- package/dist/source/next.d.ts +0 -32
- package/dist/source/next.js +0 -25
- package/dist/source/pushQueue.d.ts +0 -134
- package/dist/source/pushQueue.js +0 -256
- package/dist/source/signing.d.ts +0 -92
- package/dist/source/signing.js +0 -162
- package/dist/source/types.d.ts +0 -401
- package/dist/source/types.js +0 -59
- package/dist/storeContract.d.ts +0 -145
- package/dist/storeContract.js +0 -12
- package/dist/stores/DatabaseManager.d.ts +0 -107
- package/dist/stores/DatabaseManager.js +0 -388
- package/dist/stores/ObjectStore.d.ts +0 -115
- package/dist/stores/ObjectStore.js +0 -393
- package/dist/stores/ObjectStoreContract.d.ts +0 -38
- package/dist/stores/ObjectStoreContract.js +0 -1
- package/dist/stores/StoreManager.d.ts +0 -114
- package/dist/stores/StoreManager.js +0 -304
- package/dist/stores/SyncActionStore.d.ts +0 -99
- package/dist/stores/SyncActionStore.js +0 -506
- package/dist/stores/openIDBWithTimeout.d.ts +0 -65
- package/dist/stores/openIDBWithTimeout.js +0 -153
- package/dist/stores/syncAction.d.ts +0 -26
- package/dist/stores/syncAction.js +0 -16
- package/dist/surface.d.ts +0 -36
- package/dist/surface.js +0 -75
- package/dist/sync/BootstrapFetcher.d.ts +0 -284
- package/dist/sync/BootstrapFetcher.js +0 -964
- package/dist/sync/ConnectionManager.d.ts +0 -8
- package/dist/sync/ConnectionManager.js +0 -8
- package/dist/sync/OnDemandLoader.d.ts +0 -231
- package/dist/sync/OnDemandLoader.js +0 -743
- package/dist/sync/SubscriptionManager.d.ts +0 -159
- package/dist/sync/SubscriptionManager.js +0 -243
- package/dist/sync/SyncWebSocket.d.ts +0 -173
- package/dist/sync/SyncWebSocket.js +0 -438
- package/dist/sync/awaitClaimGrant.d.ts +0 -6
- package/dist/sync/awaitClaimGrant.js +0 -6
- package/dist/sync/bootstrapApply.d.ts +0 -73
- package/dist/sync/bootstrapApply.js +0 -73
- package/dist/sync/commitFrames.d.ts +0 -8
- package/dist/sync/commitFrames.js +0 -8
- package/dist/sync/contextPorts.d.ts +0 -18
- package/dist/sync/contextPorts.js +0 -31
- package/dist/sync/createClaimStream.d.ts +0 -7
- package/dist/sync/createClaimStream.js +0 -7
- package/dist/sync/createPresenceStream.d.ts +0 -69
- package/dist/sync/createPresenceStream.js +0 -200
- package/dist/sync/createSnapshot.d.ts +0 -29
- package/dist/sync/createSnapshot.js +0 -118
- package/dist/sync/credentialLifecycle.d.ts +0 -7
- package/dist/sync/credentialLifecycle.js +0 -7
- package/dist/sync/deltaPipeline.d.ts +0 -114
- package/dist/sync/deltaPipeline.js +0 -278
- package/dist/sync/groupChange.d.ts +0 -116
- package/dist/sync/groupChange.js +0 -244
- package/dist/sync/participants.d.ts +0 -132
- package/dist/sync/participants.js +0 -346
- package/dist/sync/persistedPrefix.d.ts +0 -12
- package/dist/sync/persistedPrefix.js +0 -22
- package/dist/sync/schemaDrift.d.ts +0 -55
- package/dist/sync/schemaDrift.js +0 -53
- package/dist/sync/schemas.d.ts +0 -71
- package/dist/sync/schemas.js +0 -94
- package/dist/sync/syncCursor.d.ts +0 -40
- package/dist/sync/syncCursor.js +0 -55
- package/dist/sync/syncPlan.d.ts +0 -54
- package/dist/sync/syncPlan.js +0 -50
- package/dist/sync/wsFrameHandlers.d.ts +0 -8
- package/dist/sync/wsFrameHandlers.js +0 -8
- package/dist/syncLog/contract.d.ts +0 -20
- package/dist/syncLog/contract.js +0 -19
- package/dist/syncLog/index.d.ts +0 -1
- package/dist/syncLog/index.js +0 -1
- package/dist/transaction/ablo.d.ts +0 -88
- package/dist/transaction/ablo.js +0 -33
- package/dist/transaction/auth/apiKey.d.ts +0 -152
- package/dist/transaction/auth/apiKey.js +0 -419
- package/dist/transaction/auth/bootstrapScope.d.ts +0 -15
- package/dist/transaction/auth/bootstrapScope.js +0 -1
- package/dist/transaction/auth/capability.d.ts +0 -212
- package/dist/transaction/auth/capability.js +0 -224
- package/dist/transaction/auth/credentialEndpoint.d.ts +0 -61
- package/dist/transaction/auth/credentialEndpoint.js +0 -86
- package/dist/transaction/auth/credentialPolicy.d.ts +0 -148
- package/dist/transaction/auth/credentialPolicy.js +0 -125
- package/dist/transaction/auth/credentialSource.d.ts +0 -30
- package/dist/transaction/auth/credentialSource.js +0 -55
- package/dist/transaction/auth/hostedEndpoints.d.ts +0 -21
- package/dist/transaction/auth/hostedEndpoints.js +0 -21
- package/dist/transaction/auth/identity.d.ts +0 -55
- package/dist/transaction/auth/identity.js +0 -210
- package/dist/transaction/auth/index.d.ts +0 -162
- package/dist/transaction/auth/index.js +0 -304
- package/dist/transaction/auth/schemas.d.ts +0 -59
- package/dist/transaction/auth/schemas.js +0 -85
- package/dist/transaction/auth/sessionMint.d.ts +0 -28
- package/dist/transaction/auth/sessionMint.js +0 -85
- package/dist/transaction/coordination/awaitClaimGrant.d.ts +0 -56
- package/dist/transaction/coordination/awaitClaimGrant.js +0 -124
- package/dist/transaction/coordination/claimHeartbeatLoop.d.ts +0 -84
- package/dist/transaction/coordination/claimHeartbeatLoop.js +0 -108
- package/dist/transaction/coordination/claimMeta.d.ts +0 -49
- package/dist/transaction/coordination/claimMeta.js +0 -52
- package/dist/transaction/coordination/createClaimStream.d.ts +0 -64
- package/dist/transaction/coordination/createClaimStream.js +0 -475
- package/dist/transaction/coordination/events.d.ts +0 -74
- package/dist/transaction/coordination/events.js +0 -7
- package/dist/transaction/coordination/index.d.ts +0 -19
- package/dist/transaction/coordination/index.js +0 -45
- package/dist/transaction/coordination/locator.d.ts +0 -104
- package/dist/transaction/coordination/locator.js +0 -102
- package/dist/transaction/coordination/schema.d.ts +0 -1536
- package/dist/transaction/coordination/schema.js +0 -1177
- package/dist/transaction/coordination/targetConflict.d.ts +0 -2
- package/dist/transaction/coordination/targetConflict.js +0 -107
- package/dist/transaction/coordination/trace.d.ts +0 -78
- package/dist/transaction/coordination/trace.js +0 -138
- package/dist/transaction/durableWrites.d.ts +0 -62
- package/dist/transaction/durableWrites.js +0 -71
- package/dist/transaction/environment.d.ts +0 -105
- package/dist/transaction/environment.js +0 -108
- package/dist/transaction/errorCodes.d.ts +0 -403
- package/dist/transaction/errorCodes.js +0 -484
- package/dist/transaction/errors.d.ts +0 -428
- package/dist/transaction/errors.js +0 -686
- package/dist/transaction/footprint.d.ts +0 -111
- package/dist/transaction/footprint.js +0 -0
- package/dist/transaction/index.d.ts +0 -20
- package/dist/transaction/index.js +0 -20
- package/dist/transaction/keys/index.d.ts +0 -87
- package/dist/transaction/keys/index.js +0 -207
- package/dist/transaction/log/syncDeltaRow.d.ts +0 -158
- package/dist/transaction/log/syncDeltaRow.js +0 -95
- package/dist/transaction/logPosition.d.ts +0 -97
- package/dist/transaction/logPosition.js +0 -125
- package/dist/transaction/logger.d.ts +0 -16
- package/dist/transaction/logger.js +0 -7
- package/dist/transaction/observability.d.ts +0 -53
- package/dist/transaction/observability.js +0 -19
- package/dist/transaction/persistence.d.ts +0 -12
- package/dist/transaction/persistence.js +0 -11
- package/dist/transaction/plugin.d.ts +0 -285
- package/dist/transaction/plugin.js +0 -106
- package/dist/transaction/policy/types.d.ts +0 -217
- package/dist/transaction/policy/types.js +0 -126
- package/dist/transaction/resources/functionalUpdate.d.ts +0 -79
- package/dist/transaction/resources/functionalUpdate.js +0 -87
- package/dist/transaction/resources/httpResources.d.ts +0 -321
- package/dist/transaction/resources/httpResources.js +0 -7
- package/dist/transaction/resources/modelOperations.d.ts +0 -427
- package/dist/transaction/resources/modelOperations.js +0 -12
- package/dist/transaction/resources/mutationOptions.d.ts +0 -66
- package/dist/transaction/resources/mutationOptions.js +0 -9
- package/dist/transaction/resources/where.d.ts +0 -101
- package/dist/transaction/resources/where.js +0 -115
- package/dist/transaction/resources/writeOptionsSchema.d.ts +0 -47
- package/dist/transaction/resources/writeOptionsSchema.js +0 -73
- package/dist/transaction/schema/field.d.ts +0 -120
- package/dist/transaction/schema/field.js +0 -265
- package/dist/transaction/schema/fieldRef.d.ts +0 -38
- package/dist/transaction/schema/fieldRef.js +0 -11
- package/dist/transaction/schema/loadStrategy.d.ts +0 -45
- package/dist/transaction/schema/loadStrategy.js +0 -46
- package/dist/transaction/schema/model.d.ts +0 -379
- package/dist/transaction/schema/model.js +0 -123
- package/dist/transaction/schema/openapi.d.ts +0 -58
- package/dist/transaction/schema/openapi.js +0 -501
- package/dist/transaction/schema/relation.d.ts +0 -204
- package/dist/transaction/schema/relation.js +0 -104
- package/dist/transaction/schema/residency.d.ts +0 -29
- package/dist/transaction/schema/residency.js +0 -25
- package/dist/transaction/schema/roles.d.ts +0 -249
- package/dist/transaction/schema/roles.js +0 -230
- package/dist/transaction/schema/schema.d.ts +0 -351
- package/dist/transaction/schema/schema.js +0 -325
- package/dist/transaction/schema/tenancy.d.ts +0 -139
- package/dist/transaction/schema/tenancy.js +0 -190
- package/dist/transaction/transactionLayer.d.ts +0 -82
- package/dist/transaction/transactionLayer.js +0 -24
- package/dist/transaction/transactions/settlement/commitEnvelope.d.ts +0 -143
- package/dist/transaction/transactions/settlement/commitEnvelope.js +0 -161
- package/dist/transaction/transactions/settlement/httpCommitEnvelope.d.ts +0 -53
- package/dist/transaction/transactions/settlement/httpCommitEnvelope.js +0 -207
- package/dist/transaction/transactions/settlement/idempotencyKey.d.ts +0 -10
- package/dist/transaction/transactions/settlement/idempotencyKey.js +0 -9
- package/dist/transaction/transactions/settlement/pendingWrite.d.ts +0 -112
- package/dist/transaction/transactions/settlement/pendingWrite.js +0 -20
- package/dist/transaction/transport/commitFrames.d.ts +0 -90
- package/dist/transaction/transport/commitFrames.js +0 -134
- package/dist/transaction/transport/connectionManager.d.ts +0 -215
- package/dist/transaction/transport/connectionManager.js +0 -673
- package/dist/transaction/transport/credentialLifecycle.d.ts +0 -177
- package/dist/transaction/transport/credentialLifecycle.js +0 -324
- package/dist/transaction/transport/heartbeat.d.ts +0 -65
- package/dist/transaction/transport/heartbeat.js +0 -93
- package/dist/transaction/transport/httpClient.d.ts +0 -131
- package/dist/transaction/transport/httpClient.js +0 -146
- package/dist/transaction/transport/httpOptions.d.ts +0 -33
- package/dist/transaction/transport/httpOptions.js +0 -12
- package/dist/transaction/transport/httpTransport.d.ts +0 -8
- package/dist/transaction/transport/httpTransport.js +0 -1388
- package/dist/transaction/transport/networkProbe.d.ts +0 -84
- package/dist/transaction/transport/networkProbe.js +0 -207
- package/dist/transaction/transport/wsFrameHandlers.d.ts +0 -128
- package/dist/transaction/transport/wsFrameHandlers.js +0 -429
- package/dist/transaction/transport/wsTransport.d.ts +0 -574
- package/dist/transaction/transport/wsTransport.js +0 -1023
- package/dist/transaction/types/assertExact.d.ts +0 -17
- package/dist/transaction/types/assertExact.js +0 -1
- package/dist/transaction/types/global.d.ts +0 -107
- package/dist/transaction/types/global.js +0 -40
- package/dist/transaction/types/index.d.ts +0 -205
- package/dist/transaction/types/index.js +0 -56
- package/dist/transaction/types/modelData.d.ts +0 -10
- package/dist/transaction/types/modelData.js +0 -9
- package/dist/transaction/types/participant.d.ts +0 -20
- package/dist/transaction/types/participant.js +0 -10
- package/dist/transaction/types/streams.d.ts +0 -550
- package/dist/transaction/types/streams.js +0 -11
- package/dist/transaction/utils/asyncIterator.d.ts +0 -34
- package/dist/transaction/utils/asyncIterator.js +0 -135
- package/dist/transaction/utils/duration.d.ts +0 -50
- package/dist/transaction/utils/duration.js +0 -77
- package/dist/transaction/utils/json.d.ts +0 -57
- package/dist/transaction/utils/json.js +0 -276
- package/dist/transaction/wire/accountResponses.d.ts +0 -420
- package/dist/transaction/wire/accountResponses.js +0 -290
- package/dist/transaction/wire/auth.d.ts +0 -56
- package/dist/transaction/wire/auth.js +0 -63
- package/dist/transaction/wire/bootstrapReason.d.ts +0 -9
- package/dist/transaction/wire/bootstrapReason.js +0 -8
- package/dist/transaction/wire/claimEvent.d.ts +0 -76
- package/dist/transaction/wire/claimEvent.js +0 -73
- package/dist/transaction/wire/claims.d.ts +0 -530
- package/dist/transaction/wire/claims.js +0 -327
- package/dist/transaction/wire/commit.d.ts +0 -603
- package/dist/transaction/wire/commit.js +0 -321
- package/dist/transaction/wire/delta.d.ts +0 -250
- package/dist/transaction/wire/delta.js +0 -147
- package/dist/transaction/wire/errorEnvelope.d.ts +0 -72
- package/dist/transaction/wire/errorEnvelope.js +0 -123
- package/dist/transaction/wire/feedCursor.d.ts +0 -60
- package/dist/transaction/wire/feedCursor.js +0 -82
- package/dist/transaction/wire/feedEvent.d.ts +0 -204
- package/dist/transaction/wire/feedEvent.js +0 -65
- package/dist/transaction/wire/frames.d.ts +0 -194
- package/dist/transaction/wire/frames.js +0 -50
- package/dist/transaction/wire/inboundFrames.d.ts +0 -562
- package/dist/transaction/wire/inboundFrames.js +0 -116
- package/dist/transaction/wire/index.d.ts +0 -54
- package/dist/transaction/wire/index.js +0 -83
- package/dist/transaction/wire/listEnvelope.d.ts +0 -37
- package/dist/transaction/wire/listEnvelope.js +0 -42
- package/dist/transaction/wire/modelMutations.d.ts +0 -31
- package/dist/transaction/wire/modelMutations.js +0 -52
- package/dist/transaction/wire/modelResponses.d.ts +0 -85
- package/dist/transaction/wire/modelResponses.js +0 -43
- package/dist/transaction/wire/modelShape.d.ts +0 -78
- package/dist/transaction/wire/modelShape.js +0 -74
- package/dist/transaction/wire/protocol.d.ts +0 -38
- package/dist/transaction/wire/protocol.js +0 -38
- package/dist/transaction/wire/protocolVersion.d.ts +0 -73
- package/dist/transaction/wire/protocolVersion.js +0 -83
- package/dist/transactions/mutations/MutationQueue.d.ts +0 -661
- package/dist/transactions/mutations/MutationQueue.js +0 -2807
- package/dist/transactions/mutations/MutationStore.d.ts +0 -20
- package/dist/transactions/mutations/MutationStore.js +0 -53
- package/dist/transactions/mutations/UnconfirmedWrites.d.ts +0 -82
- package/dist/transactions/mutations/UnconfirmedWrites.js +0 -104
- package/dist/transactions/mutations/coalesceRules.d.ts +0 -58
- package/dist/transactions/mutations/coalesceRules.js +0 -140
- package/dist/transactions/mutations/commitLatency.d.ts +0 -52
- package/dist/transactions/mutations/commitLatency.js +0 -130
- package/dist/transactions/mutations/commitOutboxStore.d.ts +0 -28
- package/dist/transactions/mutations/commitOutboxStore.js +0 -26
- package/dist/transactions/mutations/commitPayload.d.ts +0 -165
- package/dist/transactions/mutations/commitPayload.js +0 -152
- package/dist/transactions/mutations/deltaConfirmation.d.ts +0 -63
- package/dist/transactions/mutations/deltaConfirmation.js +0 -235
- package/dist/transactions/mutations/durableWriteStore.d.ts +0 -14
- package/dist/transactions/mutations/durableWriteStore.js +0 -12
- package/dist/transactions/mutations/optimisticApply.d.ts +0 -49
- package/dist/transactions/mutations/optimisticApply.js +0 -65
- package/dist/transactions/mutations/replayValidation.d.ts +0 -187
- package/dist/transactions/mutations/replayValidation.js +0 -164
- package/dist/utils/mobxSetup.d.ts +0 -53
- package/dist/utils/mobxSetup.js +0 -330
- package/dist/views/QueryView.d.ts +0 -79
- package/dist/views/QueryView.js +0 -218
- package/dist/views/ViewRegistry.d.ts +0 -20
- package/dist/views/ViewRegistry.js +0 -55
- package/dist/views/incrementalView.d.ts +0 -45
- package/dist/views/incrementalView.js +0 -69
- package/dist/webhooks/events.d.ts +0 -43
- package/dist/webhooks/events.js +0 -42
- package/dist/webhooks/index.d.ts +0 -8
- package/dist/webhooks/index.js +0 -8
- package/dist/wire/index.d.ts +0 -1
- package/dist/wire/index.js +0 -8
|
@@ -1,843 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The base class that application-specific sync stores extend. It supplies the
|
|
3
|
-
* shared orchestration for reads, writes, delta processing, and bootstrap, and
|
|
4
|
-
* exports the core types those stores build on.
|
|
5
|
-
*
|
|
6
|
-
* A subclass adds its own domain behavior — lazy-loaded relations,
|
|
7
|
-
* collaboration events, and model enrichment — by overriding the protected
|
|
8
|
-
* extension points defined here. The heavy lifting is delegated to injected
|
|
9
|
-
* collaborators: {@link SyncClient} owns pool writes and the transaction
|
|
10
|
-
* queue, {@link Database} owns local persistence, {@link InstanceCache} holds the
|
|
11
|
-
* in-memory models, and {@link ModelRegistry} holds their metadata.
|
|
12
|
-
*/
|
|
13
|
-
import type { RecoveryClass } from './transaction/errorCodes.js';
|
|
14
|
-
import { ConnectionManager } from './sync/ConnectionManager.js';
|
|
15
|
-
import { SubscriptionManager } from './sync/SubscriptionManager.js';
|
|
16
|
-
import { type ParticipantScope } from './sync/participants.js';
|
|
17
|
-
import type { SyncClient } from './SyncClient.js';
|
|
18
|
-
import type { Database, BootstrapResult } from './Database.js';
|
|
19
|
-
import type { InstanceCache } from './InstanceCache.js';
|
|
20
|
-
import { ModelRegistry } from './ModelRegistry.js';
|
|
21
|
-
import { SyncWebSocket, type SyncDelta, type SyncGroupChangePayload, type GroupAddedPayload, type GroupRemovedPayload, type BootstrapHint, type BootstrapDataEvent, type PresenceUpdate, type EventMap, type DefaultCollaborationEvents, type SyncWebSocketEventMap } from './sync/SyncWebSocket.js';
|
|
22
|
-
import { QueryProcessor } from './query/QueryProcessor.js';
|
|
23
|
-
import { Model } from './Model.js';
|
|
24
|
-
import type { RuntimeContext } from './RuntimeContext.js';
|
|
25
|
-
import type { AbloPlugin, AppliedChange } from './transaction/plugin.js';
|
|
26
|
-
import { ModelScope } from './InstanceCache.js';
|
|
27
|
-
import type { Schema } from './transaction/schema/schema.js';
|
|
28
|
-
import type { SyncStatus, LocalMutation } from './storeContract.js';
|
|
29
|
-
import type { AuthCredentialSource } from './transaction/auth/credentialSource.js';
|
|
30
|
-
import type { ModelData } from './transaction/types/modelData.js';
|
|
31
|
-
import type { EnrichmentPlanEntry, ForeignKeyIndexSpec } from './sync/syncPlan.js';
|
|
32
|
-
import { type CredentialRefresher } from './sync/credentialLifecycle.js';
|
|
33
|
-
import type { RehydrationStats } from './sync/bootstrapApply.js';
|
|
34
|
-
import type { ParticipantKind } from './transaction/types/participant.js';
|
|
35
|
-
/** Constructor type for Model subclasses (accepts abstract classes) */
|
|
36
|
-
export type ModelConstructor<T extends Model> = abstract new (...args: never[]) => T;
|
|
37
|
-
/** Concrete constructor type for instantiation */
|
|
38
|
-
export type ConcreteModelConstructor<T extends Model> = new (data?: any) => T;
|
|
39
|
-
export type { ModelData } from './transaction/types/modelData.js';
|
|
40
|
-
/** Query result interface */
|
|
41
|
-
export interface QueryResult<T extends Model> {
|
|
42
|
-
data: T[];
|
|
43
|
-
total: number;
|
|
44
|
-
hasMore: boolean;
|
|
45
|
-
fromCache?: boolean;
|
|
46
|
-
}
|
|
47
|
-
export type { ForeignKeyIndexSpec, EnrichmentPlanEntry } from './sync/syncPlan.js';
|
|
48
|
-
/** Configuration for SyncedStore behavior */
|
|
49
|
-
export interface SyncedStoreConfig {
|
|
50
|
-
enableOffline?: boolean;
|
|
51
|
-
enableCache?: boolean;
|
|
52
|
-
enableTelemetry?: boolean;
|
|
53
|
-
/**
|
|
54
|
-
* Wire message types to surface as collaboration events, e.g.
|
|
55
|
-
* `['document:selection', 'document:cursor']`.
|
|
56
|
-
*
|
|
57
|
-
* The vocabulary belongs to the application, not the SDK — these name the
|
|
58
|
-
* application's own concepts, and a schema with no documents should never see
|
|
59
|
-
* them. Defaults to none, so an application opts in by naming the events it
|
|
60
|
-
* actually broadcasts.
|
|
61
|
-
*/
|
|
62
|
-
collaborationEvents?: readonly string[];
|
|
63
|
-
/**
|
|
64
|
-
* Declarative enrichment plan consumed by `enrichRelations`. Replaces
|
|
65
|
-
* the subclass override of `enrichRelations` for per-model parent
|
|
66
|
-
* attachment. Merged with schema-derived entries (relations marked
|
|
67
|
-
* `{ enrich: true }` on `belongsTo`).
|
|
68
|
-
*/
|
|
69
|
-
enrichmentPlan?: readonly EnrichmentPlanEntry[];
|
|
70
|
-
/**
|
|
71
|
-
* Foreign-key indexes to register on the InstanceCache at construction
|
|
72
|
-
* time. Replaces the subclass override of `registerForeignKeys` for
|
|
73
|
-
* per-model FK registration. Merged with schema-derived entries
|
|
74
|
-
* (relations marked `{ index: true }` on `belongsTo`). Both sets
|
|
75
|
-
* are registered before the legacy `registerForeignKeys()` hook
|
|
76
|
-
* fires, so subclasses can still add more on top.
|
|
77
|
-
*/
|
|
78
|
-
foreignKeyIndexes?: readonly ForeignKeyIndexSpec[];
|
|
79
|
-
}
|
|
80
|
-
export type { SyncStatus } from './storeContract.js';
|
|
81
|
-
/** User context for initialization */
|
|
82
|
-
export interface UserContext {
|
|
83
|
-
userId: string;
|
|
84
|
-
organizationId: string;
|
|
85
|
-
role?: string;
|
|
86
|
-
teamIds?: string[];
|
|
87
|
-
/** Participant kind on the wire. Default 'user' for browser
|
|
88
|
-
* sessions; 'agent' for headless bots / worker processes. The
|
|
89
|
-
* store routes this to SyncWebSocket so the WS URL carries
|
|
90
|
-
* `kind=agent` and the server applies capability-token auth. */
|
|
91
|
-
kind?: ParticipantKind;
|
|
92
|
-
/** Restricted (`rk_`) API key for `kind: 'agent'` — the agent's
|
|
93
|
-
* bearer credential. Sent in the `ablo.bearer.<token>` WebSocket
|
|
94
|
-
* subprotocol, never in the URL. */
|
|
95
|
-
capabilityToken?: string;
|
|
96
|
-
/** Server-authoritative sync groups, supplied by auth/capability
|
|
97
|
-
* exchange. The SDK does not invent org/user/default groups; app
|
|
98
|
-
* structure comes from schema-declared scopes and server-issued
|
|
99
|
-
* authorization. */
|
|
100
|
-
syncGroups?: readonly string[];
|
|
101
|
-
/**
|
|
102
|
-
* How aggressively this participant should pull baseline state at
|
|
103
|
-
* startup.
|
|
104
|
-
*
|
|
105
|
-
* - `'full'` (default): pull every delta in scope before `ready()`
|
|
106
|
-
* resolves. The standard browser/user replica behavior.
|
|
107
|
-
* - `'none'`: open the WebSocket and process live deltas only.
|
|
108
|
-
* Reads go through `model.retrieve()` / filtered subscriptions
|
|
109
|
-
* backfilled by `Covering` deltas. Suitable for transactional
|
|
110
|
-
* participants — agent-worker, video-pipeline, routine runners —
|
|
111
|
-
* that don't need a local replica of the org's tenant plane.
|
|
112
|
-
*/
|
|
113
|
-
bootstrapMode?: 'full' | 'none';
|
|
114
|
-
}
|
|
115
|
-
/** Smart sync options */
|
|
116
|
-
export interface SmartSyncOptions {
|
|
117
|
-
maxDeltasBeforeBootstrap?: number;
|
|
118
|
-
maxBootstrapSize?: number;
|
|
119
|
-
batchingDelay?: number;
|
|
120
|
-
maxBatchSize?: number;
|
|
121
|
-
}
|
|
122
|
-
export type { RehydrationStats } from './sync/bootstrapApply.js';
|
|
123
|
-
/**
|
|
124
|
-
* Bootstrap retry configuration.
|
|
125
|
-
*
|
|
126
|
-
* There is deliberately no overall timeout here. How long one attempt may run
|
|
127
|
-
* is not a policy this layer gets to invent — it is a property of the fetcher's
|
|
128
|
-
* watchdogs, read from `BootstrapFetcher.budgetMs`. A second number kept here
|
|
129
|
-
* would only be able to disagree with them, which is exactly what it used to do.
|
|
130
|
-
*/
|
|
131
|
-
export declare const BOOTSTRAP_CONFIG: {
|
|
132
|
-
readonly MAX_RETRY_ATTEMPTS: 3;
|
|
133
|
-
readonly RETRY_DELAY_MS: 500;
|
|
134
|
-
};
|
|
135
|
-
export { ModelScope };
|
|
136
|
-
export type { SyncDelta, SyncGroupChangePayload, GroupAddedPayload, GroupRemovedPayload, BootstrapHint, BootstrapDataEvent, PresenceUpdate, };
|
|
137
|
-
export { deriveSyncPlanFromSchema } from './sync/syncPlan.js';
|
|
138
|
-
/**
|
|
139
|
-
* The abstract base class that application-specific sync stores extend. It
|
|
140
|
-
* carries the injected collaborators, the observable sync status, and the
|
|
141
|
-
* orchestration for initialization, delta processing, bootstrap, and the
|
|
142
|
-
* read and write API. A subclass supplies its own domain behavior by
|
|
143
|
-
* overriding the protected extension points defined here and by typing its
|
|
144
|
-
* collaboration events through the generic parameter.
|
|
145
|
-
*
|
|
146
|
-
* A subclass must call `super(dependencies, config)` and then set up its own
|
|
147
|
-
* MobX observables.
|
|
148
|
-
*
|
|
149
|
-
* Generic over `TCollaboration` — an app-defined event map for real-time
|
|
150
|
-
* collaboration events (cursors, selections, presence beyond the core set).
|
|
151
|
-
* Subclasses pass their own event map to get typed `subscribe()` calls on
|
|
152
|
-
* the underlying SyncWebSocket without casts:
|
|
153
|
-
*
|
|
154
|
-
* @example
|
|
155
|
-
* interface EditorEvents {
|
|
156
|
-
* 'document:selection': [SelectionEvent];
|
|
157
|
-
* 'document:cursor': [CursorEvent];
|
|
158
|
-
* }
|
|
159
|
-
* class EditorStore extends BaseSyncedStore<EditorEvents> {
|
|
160
|
-
* subscribeToCursor(handler: (e: CursorEvent) => void) {
|
|
161
|
-
* return this.syncWebSocket.subscribe('document:cursor', handler);
|
|
162
|
-
* }
|
|
163
|
-
* }
|
|
164
|
-
*/
|
|
165
|
-
export declare class BaseSyncedStore<TCollaboration extends EventMap<TCollaboration> = DefaultCollaborationEvents, TSchema extends Schema = Schema> {
|
|
166
|
-
syncStatus: SyncStatus;
|
|
167
|
-
/** The owning client's runtime; the module-global bridge when constructed directly. */
|
|
168
|
-
protected readonly runtime: RuntimeContext;
|
|
169
|
-
/** The installed plugins the delta pipeline dispatches stage handlers to. */
|
|
170
|
-
protected readonly stagePlugins: readonly AbloPlugin[];
|
|
171
|
-
protected readonly syncClient: SyncClient;
|
|
172
|
-
protected readonly database: Database;
|
|
173
|
-
protected readonly objectPool: InstanceCache;
|
|
174
|
-
protected readonly modelRegistry: ModelRegistry;
|
|
175
|
-
protected readonly auth?: AuthCredentialSource;
|
|
176
|
-
/**
|
|
177
|
-
* Schema the store was constructed with. Used by the schema-typed
|
|
178
|
-
* `create(key, data)` factory and model self-healing.
|
|
179
|
-
*/
|
|
180
|
-
protected readonly schema?: TSchema;
|
|
181
|
-
/**
|
|
182
|
-
* The connection, owned by whoever built this store (ADR 0016 follow-up
|
|
183
|
-
* 3b): the host constructs it and hands it in, the store seeds its late
|
|
184
|
-
* values during `initialize()` and owns the lifecycle from there. One
|
|
185
|
-
* instance for the store's whole lifetime — reconnects replace the socket
|
|
186
|
-
* inside it, never the object.
|
|
187
|
-
*/
|
|
188
|
-
protected readonly syncWebSocket: SyncWebSocket<TCollaboration>;
|
|
189
|
-
/**
|
|
190
|
-
* Dynamic read interest (area-of-interest) over the connection's sync
|
|
191
|
-
* groups. Constructed with the connection; the permanent base scopes are
|
|
192
|
-
* seeded in `setupWebSocketSync` once identity resolves.
|
|
193
|
-
*/
|
|
194
|
-
protected readonly areaOfInterest: SubscriptionManager;
|
|
195
|
-
/** Sync groups whose current state has been backfilled into the pool
|
|
196
|
-
* (hydrate-on-enter). Cleared when the pool is reset on (re)bootstrap. */
|
|
197
|
-
private readonly hydratedGroups;
|
|
198
|
-
/** In-flight scoped hydrations, keyed by group — single-flights concurrent
|
|
199
|
-
* enters of the same scope so they share one fetch. */
|
|
200
|
-
private readonly hydratingGroups;
|
|
201
|
-
private _syncServerUrl?;
|
|
202
|
-
/** Application-declared collaboration event types; empty unless configured. */
|
|
203
|
-
private _collaborationEvents;
|
|
204
|
-
/**
|
|
205
|
-
* Public accessor for the underlying SyncWebSocket. Used by the
|
|
206
|
-
* factory in `createSyncEngine` to wire the default mutation
|
|
207
|
-
* executor — the executor needs the WS handle to send commit
|
|
208
|
-
* frames, and the factory can't reach `protected` state through
|
|
209
|
-
* normal typing.
|
|
210
|
-
*/
|
|
211
|
-
getSyncWebSocket(): SyncWebSocket<TCollaboration>;
|
|
212
|
-
/**
|
|
213
|
-
* Subscribe to pushed frames — deltas, presence updates, claim grants and
|
|
214
|
-
* losses, connection changes, and this store's collaboration events.
|
|
215
|
-
* Durable by construction: the connection object exists for the store's
|
|
216
|
-
* whole lifetime (reconnects replace only the socket inside it), so a
|
|
217
|
-
* subscription made before the first connect starts delivering when the
|
|
218
|
-
* socket opens and keeps delivering across every reconnect. Returns the
|
|
219
|
-
* unsubscribe function.
|
|
220
|
-
*/
|
|
221
|
-
subscribe<K extends keyof SyncWebSocketEventMap<TCollaboration>>(event: K, handler: (...args: SyncWebSocketEventMap<TCollaboration>[K]) => void): () => void;
|
|
222
|
-
/**
|
|
223
|
-
* Send a collaboration event (an app-specific real-time message from this
|
|
224
|
-
* store's `TCollaboration` map). A no-op while the connection is down —
|
|
225
|
-
* presence-grade traffic is not queued.
|
|
226
|
-
*/
|
|
227
|
-
sendCollaborationEvent<K extends string & keyof TCollaboration>(messageType: K, payload: TCollaboration[K] extends [infer P] ? Omit<P & Record<string, unknown>, 'timestamp'> : never): void;
|
|
228
|
-
private scopeToGroups;
|
|
229
|
-
/**
|
|
230
|
-
* Bring a scope into view and subscribe to its sync groups. With
|
|
231
|
-
* `{ hydrate: true }`, also backfill the groups' current state into the pool
|
|
232
|
-
* once the subscription is active. The order matters: subscribing first
|
|
233
|
-
* guarantees no live delta is missed in the gap before the snapshot lands.
|
|
234
|
-
* Hydration is best-effort — a failed backfill never rejects `enterScope`,
|
|
235
|
-
* and the live delta stream keeps flowing regardless.
|
|
236
|
-
*/
|
|
237
|
-
enterScope(scope: ParticipantScope, opts?: {
|
|
238
|
-
hydrate?: boolean;
|
|
239
|
-
}): Promise<void>;
|
|
240
|
-
/**
|
|
241
|
-
* Backfill the current state of `syncGroups` into the pool with a side-effect-free
|
|
242
|
-
* scoped snapshot fetch followed by the version-guarded scoped apply. The call
|
|
243
|
-
* is idempotent (it skips groups already hydrated) and single-flight (concurrent
|
|
244
|
-
* enters of the same group share one fetch). On error the groups are left
|
|
245
|
-
* unmarked, so a later re-enter retries.
|
|
246
|
-
*/
|
|
247
|
-
protected hydrateGroups(syncGroups: readonly string[]): Promise<void>;
|
|
248
|
-
/** Leave a scope → its groups go warm (hysteresis), then drop on sweep. */
|
|
249
|
-
leaveScope(scope: ParticipantScope): Promise<void>;
|
|
250
|
-
/** Pin a scope (active claim / prominence) → never warms while pinned. */
|
|
251
|
-
pinScope(scope: ParticipantScope): Promise<void>;
|
|
252
|
-
/** Release a pin → the group transitions to warm rather than dropping. */
|
|
253
|
-
unpinScope(scope: ParticipantScope): Promise<void>;
|
|
254
|
-
protected readonly queryProcessor: QueryProcessor;
|
|
255
|
-
/**
|
|
256
|
-
* Runtime behavior flags only — the schema/config arrays
|
|
257
|
-
* (`enrichmentPlan`, `foreignKeyIndexes`) are consumed at construction
|
|
258
|
-
* time and stored on the instance as `enrichmentPlan` and
|
|
259
|
-
* pool-registered indexes. They don't need to persist on `this.config`.
|
|
260
|
-
*/
|
|
261
|
-
protected readonly config: Required<Pick<SyncedStoreConfig, 'enableOffline' | 'enableCache' | 'enableTelemetry'>>;
|
|
262
|
-
protected disposers: (() => void)[];
|
|
263
|
-
protected initialized: boolean;
|
|
264
|
-
protected dataReady: boolean;
|
|
265
|
-
protected userContext: UserContext | null;
|
|
266
|
-
/**
|
|
267
|
-
* Declarative enrichment plan: "for model X, when a delta arrives,
|
|
268
|
-
* read data[foreignKey] and attach the matching parent from the pool
|
|
269
|
-
* as data[relationKey]." Merged from schema-derived + config at
|
|
270
|
-
* construction time. Replaces the `enrichRelations` subclass override
|
|
271
|
-
* pattern.
|
|
272
|
-
*/
|
|
273
|
-
protected enrichmentPlan: readonly EnrichmentPlanEntry[];
|
|
274
|
-
protected smartSyncOptions: Required<SmartSyncOptions>;
|
|
275
|
-
protected pendingDeltas: SyncDelta[];
|
|
276
|
-
protected batchTimer: ReturnType<typeof setTimeout> | null;
|
|
277
|
-
protected syncPromise: Promise<void> | null;
|
|
278
|
-
/** Resume/ack cursor — delegates to the shared LogPosition (see
|
|
279
|
-
* logPosition.ts). Advances only after IDB persistence. */
|
|
280
|
-
protected get lastAckedId(): number;
|
|
281
|
-
/** Pool-applied cursor — delegates to the shared LogPosition. */
|
|
282
|
-
protected get highestProcessedSyncId(): number;
|
|
283
|
-
protected bootstrapDeltaQueue: SyncDelta[] | null;
|
|
284
|
-
protected activeBootstrapCount: number;
|
|
285
|
-
/** The live deadline for the bootstrap attempt in flight, if any. */
|
|
286
|
-
private bootstrapDeadlineTimer;
|
|
287
|
-
protected pendingDeletes: Set<string>;
|
|
288
|
-
protected modelTypesHydrated: Set<string>;
|
|
289
|
-
protected modelTypeHydrationInFlight: Map<string, Promise<void>>;
|
|
290
|
-
constructor(dependencies: {
|
|
291
|
-
syncClient: SyncClient;
|
|
292
|
-
database: Database;
|
|
293
|
-
objectPool: InstanceCache;
|
|
294
|
-
modelRegistry: ModelRegistry;
|
|
295
|
-
/**
|
|
296
|
-
* The connection, built by the host. When omitted, the store constructs
|
|
297
|
-
* its own from `url` and the collaboration-event config — the
|
|
298
|
-
* self-contained path subclasses and tests use. Either way the store
|
|
299
|
-
* owns the lifecycle from here: it seeds the late values (identity,
|
|
300
|
-
* read scope, resume cursor) during `initialize()` and releases the
|
|
301
|
-
* first connect.
|
|
302
|
-
*/
|
|
303
|
-
syncWebSocket?: SyncWebSocket<TCollaboration>;
|
|
304
|
-
/**
|
|
305
|
-
* Optional schema. When provided, {@link deriveSyncPlanFromSchema} walks
|
|
306
|
-
* the schema's models and relations to auto-populate foreign-key indexes
|
|
307
|
-
* and the enrichment plan from their declarative annotations. Subclasses
|
|
308
|
-
* that register model classes directly can instead pass explicit
|
|
309
|
-
* `config.foreignKeyIndexes` / `config.enrichmentPlan`.
|
|
310
|
-
*/
|
|
311
|
-
schema?: TSchema;
|
|
312
|
-
/** Sync server URL for WebSocket connection. Converted to wss:// automatically. */
|
|
313
|
-
url?: string;
|
|
314
|
-
/** Shared bearer credential source for every auth-aware transport. */
|
|
315
|
-
auth?: AuthCredentialSource;
|
|
316
|
-
/** The owning client's runtime. Defaults to the module-global bridge. */
|
|
317
|
-
runtime?: RuntimeContext;
|
|
318
|
-
/**
|
|
319
|
-
* The installed plugins, whose declared stage handlers the delta
|
|
320
|
-
* pipeline dispatches. Empty on direct construction — the store's own
|
|
321
|
-
* apply is then the whole pipeline.
|
|
322
|
-
*/
|
|
323
|
-
stagePlugins?: readonly AbloPlugin[];
|
|
324
|
-
}, config?: SyncedStoreConfig);
|
|
325
|
-
/**
|
|
326
|
-
* Register foreign-key indexes for constant-time lookups.
|
|
327
|
-
*
|
|
328
|
-
* This is an override hook. The preferred way to declare a foreign-key
|
|
329
|
-
* index is `config.foreignKeyIndexes` at construction time, or marking the
|
|
330
|
-
* `belongsTo` relation with `{ index: true }` in the schema. The hook fires
|
|
331
|
-
* after the schema-derived and config registrations, so a subclass can
|
|
332
|
-
* layer additional indexes on top.
|
|
333
|
-
*/
|
|
334
|
-
protected registerForeignKeys(): void;
|
|
335
|
-
/**
|
|
336
|
-
* Enrich delta data with related models from the InstanceCache.
|
|
337
|
-
*
|
|
338
|
-
* Base implementation walks `this.enrichmentPlan` — entries populated
|
|
339
|
-
* from the schema's `{ enrich: true }` relations and from
|
|
340
|
-
* `config.enrichmentPlan`. Subclasses can still override for bespoke
|
|
341
|
-
* logic, calling `super.enrichRelations(modelName, data)` first to
|
|
342
|
-
* apply the declarative plan before layering on custom work.
|
|
343
|
-
*
|
|
344
|
-
* Enrichment is best-effort: if the parent isn't yet in the pool
|
|
345
|
-
* (e.g., a child delta arrives before its parent in a bootstrap
|
|
346
|
-
* batch), the entry is silently skipped and the data passes through
|
|
347
|
-
* untouched. The next delta for the same child will re-enrich.
|
|
348
|
-
*/
|
|
349
|
-
protected enrichRelations(modelName: string, data: ModelData): ModelData;
|
|
350
|
-
/** Check if a model name represents a custom/dynamic entity type. */
|
|
351
|
-
protected isCustomEntity(modelName: string): boolean;
|
|
352
|
-
/** Create a custom entity instance from delta data. Override for domain-specific custom entities. */
|
|
353
|
-
protected createCustomEntity(_modelName: string, _modelId: string, _data: Record<string, unknown>): Model | null;
|
|
354
|
-
/** Called before save for domain-specific validation/self-healing. */
|
|
355
|
-
protected beforeSave(_model: Model): void;
|
|
356
|
-
/** Connection lifecycle event callback — set by subclass to wire connection state machine. */
|
|
357
|
-
protected onConnectionEvent?: (event: string) => void;
|
|
358
|
-
/**
|
|
359
|
-
* Internal connection FSM. Owns network probe + backoff + reconnect
|
|
360
|
-
* orchestration for the default path. Constructed lazily once we
|
|
361
|
-
* have a user context + a WebSocket (see `wireWebSocketEvents`);
|
|
362
|
-
* driven by the `onConnectionEvent` hook AND browser online/offline
|
|
363
|
-
* events it sets up itself.
|
|
364
|
-
*
|
|
365
|
-
* Every consumer gets production-grade offline-to-online recovery
|
|
366
|
-
* out of the box. Subclasses that want their own lifecycle owner
|
|
367
|
-
* can disable this by overriding `createConnectionManager()` to
|
|
368
|
-
* return null.
|
|
369
|
-
*/
|
|
370
|
-
protected connectionManager: import('./sync/ConnectionManager.js').ConnectionManager | null;
|
|
371
|
-
/**
|
|
372
|
-
* Access-credential re-mint + proactive pre-roll — extracted to
|
|
373
|
-
* sync/credentialLifecycle.ts. Owns the refresher hook, the single-flight
|
|
374
|
-
* guard, and the browser-only refresh timer / wake listener; talks back
|
|
375
|
-
* through three lazily-resolved callbacks (the ConnectionManager doesn't
|
|
376
|
-
* exist until `setupWebSocketSync`). The `setCredentialRefresher` /
|
|
377
|
-
* `performCredentialRefresh` / `startCredentialLifecycle` methods below
|
|
378
|
-
* are thin delegates so the store's public surface is unchanged.
|
|
379
|
-
*/
|
|
380
|
-
private readonly credentialLifecycle;
|
|
381
|
-
/**
|
|
382
|
-
* Listeners registered via `subscribeSessionError()`. Fired when the
|
|
383
|
-
* WebSocket closes with a session-invalid code (1008/4001/4003) or a
|
|
384
|
-
* session-error event is received. Separate from `onConnectionEvent`
|
|
385
|
-
* (which exists for the ConnectionStore FSM) so multiple consumers —
|
|
386
|
-
* typically `<AbloProvider>` and a connection-lifecycle owner — can
|
|
387
|
-
* both react without racing on the single-callback slot.
|
|
388
|
-
*/
|
|
389
|
-
protected sessionErrorListeners: Set<(error: Error) => void>;
|
|
390
|
-
/**
|
|
391
|
-
* Subscribe to session-error events. The returned function removes
|
|
392
|
-
* the listener. Safe to call multiple times from different consumers
|
|
393
|
-
* (each gets its own slot in the listener set).
|
|
394
|
-
*/
|
|
395
|
-
subscribeSessionError(listener: (error: Error) => void): () => void;
|
|
396
|
-
/**
|
|
397
|
-
* Subscribe to per-mutation failure payloads. Forwarded from the
|
|
398
|
-
* underlying `SyncClient.mutationQueue` so consumers (toast layer,
|
|
399
|
-
* route-level reverted boundaries, telemetry) can react without
|
|
400
|
-
* reaching across the store. Returns an unsubscribe function.
|
|
401
|
-
*
|
|
402
|
-
* Why this lives on the base store rather than SyncClient: the React
|
|
403
|
-
* `<AbloProvider>` binds against this surface, so adding it here
|
|
404
|
-
* keeps the engine's internal wiring private while still giving the
|
|
405
|
-
* SDK a single hook to expose. Mirrors `subscribeSessionError` —
|
|
406
|
-
* same shape, same lifecycle.
|
|
407
|
-
*/
|
|
408
|
-
subscribeMutationFailure(listener: (payload: {
|
|
409
|
-
transaction: import('./transactions/mutations/MutationQueue.js').QueuedMutation;
|
|
410
|
-
error: Error;
|
|
411
|
-
permanent?: boolean;
|
|
412
|
-
}) => void): () => void;
|
|
413
|
-
/**
|
|
414
|
-
* Subscribe to commit round-trip latency. Forwarded from the underlying
|
|
415
|
-
* `SyncClient` for the same reason as `subscribeMutationFailure` — the
|
|
416
|
-
* React provider binds against this surface, so the engine's wiring stays
|
|
417
|
-
* private while the SDK keeps one hook to expose.
|
|
418
|
-
*/
|
|
419
|
-
subscribeCommitLatency(listener: (sample: import('./transactions/mutations/commitLatency.js').CommitLatencySample) => void): () => void;
|
|
420
|
-
/**
|
|
421
|
-
* Wait for the in-flight transaction for (modelName, modelId) to be
|
|
422
|
-
* confirmed by the server. See `SyncClient.waitForConfirmation` for the
|
|
423
|
-
* lookup contract; resolves immediately if nothing is in flight.
|
|
424
|
-
*/
|
|
425
|
-
waitForConfirmation(modelName: string, modelId: string): Promise<void>;
|
|
426
|
-
/**
|
|
427
|
-
* Observe the LOCAL mutation stream for undo recording (see
|
|
428
|
-
* {@link import('./storeContract.js').LocalMutation}). Taps the
|
|
429
|
-
* MutationQueue's `transaction:created` event — fired once per local
|
|
430
|
-
* create/update/delete/archive with `previousData` already captured.
|
|
431
|
-
* Remote/collaborator deltas apply via `applyDeltaBatchToPool` and never
|
|
432
|
-
* emit here, so undo is naturally local-only (you can't undo a teammate).
|
|
433
|
-
*/
|
|
434
|
-
subscribeLocalMutations(handler: (mutation: LocalMutation) => void): () => void;
|
|
435
|
-
/**
|
|
436
|
-
* Execute a bootstrap function with timeout protection and automatic retry.
|
|
437
|
-
* Prevents the common issue where bootstrap hangs on startup.
|
|
438
|
-
*/
|
|
439
|
-
protected executeBootstrapWithTimeout<T>(bootstrapFn: () => Promise<T>, _context: UserContext, signal?: AbortSignal): Promise<T>;
|
|
440
|
-
/**
|
|
441
|
-
* The outer deadline for one bootstrap attempt.
|
|
442
|
-
*
|
|
443
|
-
* The length is DERIVED from the fetcher's own watchdog budget, not chosen. A
|
|
444
|
-
* chosen number is what broke this: the previous fixed 15s was shorter than a
|
|
445
|
-
* single model chunk's allowance — 20s waiting for response headers plus 15s
|
|
446
|
-
* of stall grace — so on any workspace with one slow model the deadline fired
|
|
447
|
-
* before the watchdogs it was meant to backstop, and every attempt timed out
|
|
448
|
-
* by construction. The watchdogs below are progress-based and already
|
|
449
|
-
* guarantee termination; this deadline exists only for a hang somewhere other
|
|
450
|
-
* than the network, so it must sit above them, and it can only do that
|
|
451
|
-
* reliably by asking them how long they take.
|
|
452
|
-
*
|
|
453
|
-
* Reaching it aborts the work in flight. `Promise.race` merely stops waiting:
|
|
454
|
-
* without the abort the losing bootstrap keeps running, keeps its sockets, and
|
|
455
|
-
* races the retry that replaced it — which is how one page load turned into
|
|
456
|
-
* dozens of overlapping requests.
|
|
457
|
-
*/
|
|
458
|
-
protected createBootstrapTimeout(attempt: number): Promise<never>;
|
|
459
|
-
/** Disarm the deadline once its attempt has settled. Load-bearing now that
|
|
460
|
-
* firing it aborts real work: a leftover timer would cancel a later,
|
|
461
|
-
* unrelated bootstrap. */
|
|
462
|
-
private clearBootstrapDeadline;
|
|
463
|
-
/** Reset bootstrap-related state for a clean retry */
|
|
464
|
-
protected resetBootstrapState(): void;
|
|
465
|
-
/** Perform reconnect: bootstrap + WS reconnect. Returns outcome for state machine. */
|
|
466
|
-
performReconnect(): Promise<'success' | 'session_error' | 'network_error'>;
|
|
467
|
-
/**
|
|
468
|
-
* Register the access-credential re-mint hook. Called by the React provider
|
|
469
|
-
* with a thunk that mints a fresh `ek_`/`rk_` (typically its `getToken`).
|
|
470
|
-
* See {@link CredentialLifecycle.setRefresher}.
|
|
471
|
-
*/
|
|
472
|
-
setCredentialRefresher(refresher: CredentialRefresher | null): void;
|
|
473
|
-
/**
|
|
474
|
-
* Re-mint the short-lived access credential and push it into the credential
|
|
475
|
-
* source, reporting a tri-state outcome the {@link ConnectionManager} maps to
|
|
476
|
-
* its FSM. Single-flight; no refresher wired ⇒ `'refreshed'` (a no-op
|
|
477
|
-
* re-probe). Full contract on {@link CredentialLifecycle.refresh}.
|
|
478
|
-
*/
|
|
479
|
-
performCredentialRefresh(): Promise<'refreshed' | 'session_error' | 'network_error'>;
|
|
480
|
-
/**
|
|
481
|
-
* The authentication-recovery path for HTTP transports, such as the lazy
|
|
482
|
-
* query lane. It runs a single-flight credential re-mint driven by the
|
|
483
|
-
* rejection's recovery class, routing outcomes through the same state
|
|
484
|
-
* machine the WebSocket probe uses. `'retry'` means a fresh credential is
|
|
485
|
-
* now in the credential source and the request should be replayed once.
|
|
486
|
-
* Full contract on {@link CredentialLifecycle.recoverFromAuthRejection}.
|
|
487
|
-
*/
|
|
488
|
-
recoverFromAuthRejection(recovery: RecoveryClass): Promise<'retry' | 'stop'>;
|
|
489
|
-
/**
|
|
490
|
-
* Nudge the connection FSM to re-probe with the current credential. Idempotent
|
|
491
|
-
* and safe in any state (ignored while `connected`). Call after pushing a
|
|
492
|
-
* freshly-minted token via `setAuthToken`, or on an OS-wake signal, so a
|
|
493
|
-
* connection parked in `offline` / `backoff` / `auth_blocked` picks the new
|
|
494
|
-
* credential up immediately instead of waiting for the 30s watchdog.
|
|
495
|
-
*/
|
|
496
|
-
nudgeReconnect(): void;
|
|
497
|
-
/**
|
|
498
|
-
* Install the client-owned access-credential lifecycle: register `getToken`
|
|
499
|
-
* as the reactive re-mint hook and arm the browser-only proactive refresh
|
|
500
|
-
* (a refresh timer plus an OS-wake re-mint). Idempotent — a second call
|
|
501
|
-
* replaces the first — and torn down on {@link disconnect}. Full rationale
|
|
502
|
-
* on {@link CredentialLifecycle.start}.
|
|
503
|
-
*/
|
|
504
|
-
startCredentialLifecycle(getToken: CredentialRefresher, opts?: {
|
|
505
|
-
proactiveInNode?: boolean;
|
|
506
|
-
}): void;
|
|
507
|
-
/** Tear down the proactive credential lifecycle (idempotent). */
|
|
508
|
-
private stopCredentialLifecycle;
|
|
509
|
-
/** Narrow context the group-change leaf talks back through. */
|
|
510
|
-
private groupChangeContext;
|
|
511
|
-
/**
|
|
512
|
-
* Handle an actionType 'G' delta — incremental `{ group, userId }` or
|
|
513
|
-
* legacy `{ addedGroups, removedGroups }` payloads. Full pathway doc on
|
|
514
|
-
* {@link groupChange.handleSyncGroupChange}.
|
|
515
|
-
*/
|
|
516
|
-
protected handleSyncGroupChange(delta: SyncDelta): Promise<void>;
|
|
517
|
-
/**
|
|
518
|
-
* Handle an incremental GroupAdded delta — metadata only, no re-bootstrap
|
|
519
|
-
* (covering deltas bring the entities). See {@link groupChange.handleGroupAdded}.
|
|
520
|
-
*/
|
|
521
|
-
protected handleGroupAdded(payload: GroupAddedPayload, syncId: number): Promise<void>;
|
|
522
|
-
/**
|
|
523
|
-
* Handle an actionType 'S' (GroupRemoved) delta: for safety, clear the
|
|
524
|
-
* revoked local state and trigger a full re-bootstrap. See
|
|
525
|
-
* {@link groupChange.handleGroupRemoved}.
|
|
526
|
-
*/
|
|
527
|
-
protected handleGroupRemoved(delta: SyncDelta): Promise<void>;
|
|
528
|
-
/** Compute new sync groups after applying additions and removals */
|
|
529
|
-
protected computeUpdatedSyncGroups(payload: SyncGroupChangePayload): string[];
|
|
530
|
-
/** Force a full re-bootstrap via connection lifecycle event (no-op for
|
|
531
|
-
* `bootstrapMode: 'none'` participants — see {@link groupChange.forceFullRebootstrap}). */
|
|
532
|
-
protected forceFullRebootstrap(): void;
|
|
533
|
-
/**
|
|
534
|
-
* Single source of truth for the sync-group list this session is
|
|
535
|
-
* subscribed to. Server-issued (`context.syncGroups`) is authoritative.
|
|
536
|
-
* When absent, the SDK subscribes to no explicit groups. Both
|
|
537
|
-
* `checkSyncGroupShrinkage` and `setupWebSocketSync` resolve through
|
|
538
|
-
* here so the WS subscription and the security-critical shrinkage
|
|
539
|
-
* check can never disagree.
|
|
540
|
-
*/
|
|
541
|
-
protected resolveSyncGroups(context: UserContext): readonly string[];
|
|
542
|
-
/** Check if sync groups shrank since last session — force full bootstrap if so */
|
|
543
|
-
protected checkSyncGroupShrinkage(): Promise<void>;
|
|
544
|
-
/** Narrow context the bootstrap-apply leaf talks back through. */
|
|
545
|
-
private poolContext;
|
|
546
|
-
/** Apply bootstrap data to the {@link InstanceCache}, removing entities that are no longer present (ghost removal). Pool writes are delegated to {@link SyncClient}. */
|
|
547
|
-
protected applyBootstrapToPool(bootstrapResult: BootstrapResult, protectedIds?: ReadonlySet<string>): RehydrationStats;
|
|
548
|
-
/**
|
|
549
|
-
* Initialize the sync engine with user context.
|
|
550
|
-
* Offline-first: hydrate from IDB → show UI → bootstrap from server in background.
|
|
551
|
-
*/
|
|
552
|
-
initialize(context: UserContext, signal?: AbortSignal): Generator<Promise<unknown>, {
|
|
553
|
-
success: boolean;
|
|
554
|
-
error?: Error;
|
|
555
|
-
}, unknown>;
|
|
556
|
-
/** Background bootstrap — non-blocking, user sees cached data while this runs */
|
|
557
|
-
protected performBackgroundBootstrap(requirements: Awaited<ReturnType<typeof this.database.requiredBootstrap>>, context: UserContext, signal?: AbortSignal): Promise<void>;
|
|
558
|
-
/** Run bootstrap with delta queuing to prevent race conditions */
|
|
559
|
-
protected withDeltaQueuing<T>(fn: () => Promise<T>): Promise<T>;
|
|
560
|
-
/** Collect IDs that must survive ghost removal (added by deltas during bootstrap) */
|
|
561
|
-
protected collectDeltaProtectedIds(preBootstrapIds: ReadonlySet<string>): Set<string>;
|
|
562
|
-
/** Replay deltas queued during bootstrap (atomically, via `applyDeltaFrame`). */
|
|
563
|
-
protected replayQueuedDeltas(): void;
|
|
564
|
-
/**
|
|
565
|
-
* Factory for the internal `ConnectionManager`. Override to return
|
|
566
|
-
* `null` in subclasses that own their own connection lifecycle
|
|
567
|
-
* (tests, headless runners, custom FSM wrappers). Default builds a
|
|
568
|
-
* manager scoped to `_syncServerUrl` with production backoff.
|
|
569
|
-
*
|
|
570
|
-
* **Agent participants get `null`.** The FSM is wired around browser
|
|
571
|
-
* events (`visibilitychange`, `online`/`offline`, watchdog) which are
|
|
572
|
-
* meaningful for human-facing tabs and meaningless for headless agent
|
|
573
|
-
* processes. On agent hosts the FSM has no event source to drive
|
|
574
|
-
* recovery — and worse, its `offline` entry action calls
|
|
575
|
-
* `syncWebSocket.disconnect()` which sets `isManualClose=true` and
|
|
576
|
-
* cancels the reconnect that `SyncWebSocket.onclose` had just
|
|
577
|
-
* scheduled. The two recovery systems fight and the browser-only one
|
|
578
|
-
* wins by destroying the Node-compatible one's work. Returning `null`
|
|
579
|
-
* for agents leaves `SyncWebSocket`'s exponential-backoff
|
|
580
|
-
* `scheduleReconnect()` as the sole recovery path — which is correct
|
|
581
|
-
* for server-side agents whether they run on Node, Bun, Deno, or
|
|
582
|
-
* inside a Docker container with no `window`.
|
|
583
|
-
*
|
|
584
|
-
* Why gate on `kind` and not `typeof window`: env detection by global
|
|
585
|
-
* existence is fragile (SSR polyfills, jsdom, sandboxed hosts). The
|
|
586
|
-
* participant kind is the actual semantic axis — "is this a human-
|
|
587
|
-
* driven session" vs "is this a server agent". The latter never has
|
|
588
|
-
* a tab to lose focus or a network adapter to wake up.
|
|
589
|
-
*/
|
|
590
|
-
protected createConnectionManager(kind?: ParticipantKind): ConnectionManager | null;
|
|
591
|
-
/**
|
|
592
|
-
* Disconnect and clean up all resources. Terminal: this means "the client
|
|
593
|
-
* is finished", not "close and reopen later" — the connection object stays
|
|
594
|
-
* assigned but closed, the event wiring is torn down, and nothing
|
|
595
|
-
* re-initializes a disconnected store. (Mid-session closes during recovery
|
|
596
|
-
* go through the connection FSM's `onDisconnectWebSocket`, which closes
|
|
597
|
-
* the transport without touching the store.)
|
|
598
|
-
*/
|
|
599
|
-
disconnect(): Promise<void>;
|
|
600
|
-
/**
|
|
601
|
-
* Destroy every IndexedDB database owned by the sync engine.
|
|
602
|
-
*
|
|
603
|
-
* First disconnects (releases WebSocket + timers + in-memory caches),
|
|
604
|
-
* then walks `indexedDB.databases()` and deletes any database whose
|
|
605
|
-
* name starts with `ablo_` or `ablo-`. This covers:
|
|
606
|
-
* - `ablo_<hash>` workspace data DBs
|
|
607
|
-
* - `ablo_databases` meta registry
|
|
608
|
-
* - `ablo-sync` offline mutation queue
|
|
609
|
-
*
|
|
610
|
-
* Use case: session expiry (previous-user data must not persist on
|
|
611
|
-
* disk before the next sign-in races into a corrupted state) or
|
|
612
|
-
* explicit user-initiated logout.
|
|
613
|
-
*
|
|
614
|
-
* Best-effort: swallows individual delete errors. Some browsers do
|
|
615
|
-
* not support `indexedDB.databases()` — the method returns without
|
|
616
|
-
* deleting in that case, same behavior as the pre-SDK app code.
|
|
617
|
-
*/
|
|
618
|
-
purge(): Promise<void>;
|
|
619
|
-
/**
|
|
620
|
-
* Create WebSocket connection and wire all event handlers.
|
|
621
|
-
* Handles: deltas, batches, presence, bootstrap_required, errors, reconnection.
|
|
622
|
-
*/
|
|
623
|
-
/**
|
|
624
|
-
* Block until the WebSocket reports a `connected` event, or until
|
|
625
|
-
* `timeoutMs` elapses (returns false on timeout, true on connect).
|
|
626
|
-
* Used by `initialize()` for `bootstrapMode: 'none'` consumers to
|
|
627
|
-
* honor `ready()`'s "WS is connected when this resolves" contract
|
|
628
|
-
* — `setupWebSocketSync` is fire-and-forget on the upgrade, and
|
|
629
|
-
* without an explicit wait the next mutation can race the open.
|
|
630
|
-
*
|
|
631
|
-
* Resolves immediately if the WS is already connected (e.g., warm
|
|
632
|
-
* reconnect after redeploy). Resolves false on timeout rather than
|
|
633
|
-
* throwing so initialize() can complete and let the caller's first
|
|
634
|
-
* mutation attempt surface a clearer error.
|
|
635
|
-
*/
|
|
636
|
-
protected waitForWebSocketConnected(timeoutMs: number): Promise<boolean>;
|
|
637
|
-
/**
|
|
638
|
-
* Seed the connection's late values and open it. The socket itself exists
|
|
639
|
-
* from construction; what identity resolution supplies — the participant
|
|
640
|
-
* kind, the credential, the read scope, and the resume cursor — is seeded
|
|
641
|
-
* here, and only then is the held first connect released. A retried
|
|
642
|
-
* `initialize()` after a failed `ready()` re-runs this against the same
|
|
643
|
-
* connection object: the reconnect counter is reset for a clean slate,
|
|
644
|
-
* while the session-error latch deliberately survives (only the
|
|
645
|
-
* credential-expiry recovery clears it).
|
|
646
|
-
*/
|
|
647
|
-
protected setupWebSocketSync(context: UserContext, lastSyncId: number): void;
|
|
648
|
-
/**
|
|
649
|
-
* Wire the store's handlers onto the connection. Runs once, at
|
|
650
|
-
* construction — the connection object is stable for the store's
|
|
651
|
-
* lifetime, so the wiring is too.
|
|
652
|
-
*/
|
|
653
|
-
protected wireSocketEvents(): void;
|
|
654
|
-
/**
|
|
655
|
-
* Build and start the connection FSM. The `onConnectionEvent` hook is the
|
|
656
|
-
* bridge — WS events fire the hook, the hook forwards into the FSM. Called
|
|
657
|
-
* from `setupWebSocketSync` because the FSM's shape depends on the resolved
|
|
658
|
-
* participant kind (agents get none — see {@link createConnectionManager}).
|
|
659
|
-
*/
|
|
660
|
-
private startConnectionManager;
|
|
661
|
-
/** Memoized pipeline context — `enqueueDelta` runs once per delta, so the
|
|
662
|
-
* accessor object is built once and reused (the get/set accessors always
|
|
663
|
-
* read the live host fields). */
|
|
664
|
-
private _deltaPipelineContext;
|
|
665
|
-
private get deltaPipelineContext();
|
|
666
|
-
/**
|
|
667
|
-
* Lands persisted changes in the in-memory pool, with this store's
|
|
668
|
-
* relation enrichment bound. The one apply path: the pipeline's bridge
|
|
669
|
-
* (no plugins installed) and the `humans()` apply handler both call it.
|
|
670
|
-
*/
|
|
671
|
-
applyChangesToPool(changes: readonly AppliedChange[]): void;
|
|
672
|
-
/** Get fields that represent meaningful state for deduplication. Override for model-specific fields. */
|
|
673
|
-
protected getStateFields(_modelName: string): string[];
|
|
674
|
-
/** Deduplicate deltas to the same entity — keep meaningful state transitions only */
|
|
675
|
-
protected deduplicateDeltas(deltas: SyncDelta[]): SyncDelta[];
|
|
676
|
-
/** Process incoming delta with smart batching */
|
|
677
|
-
protected processDeltaWithBatching(delta: SyncDelta): void;
|
|
678
|
-
/**
|
|
679
|
-
* Apply a complete, server-delivered delta frame atomically.
|
|
680
|
-
*
|
|
681
|
-
* A `delta_batch` WebSocket event (a reconnect or catch-up replay) already
|
|
682
|
-
* carries the full set of missed deltas. Routing it through the per-delta
|
|
683
|
-
* `processDeltaWithBatching` path would re-chunk it via the live-traffic
|
|
684
|
-
* debounce timer and `maxBatchSize` force-flush, so a 300-delta catch-up
|
|
685
|
-
* would fan out into several separate `flushPendingDeltas` cycles — each its
|
|
686
|
-
* own local write, pool mutation, `models:changed` emit, and re-render, so
|
|
687
|
-
* the UI visibly repaints once per chunk.
|
|
688
|
-
*
|
|
689
|
-
* Instead, this runs the per-delta bookkeeping (deduplication, ack, version
|
|
690
|
-
* vector, watermark, group-change routing, delete cascade) for every delta
|
|
691
|
-
* without scheduling a flush, then flushes once — collapsing the whole frame
|
|
692
|
-
* into a single local write, pool mutation, `models:changed` emit, and
|
|
693
|
-
* re-render. The post-bootstrap replay of deltas queued during bootstrap
|
|
694
|
-
* uses the same path.
|
|
695
|
-
*
|
|
696
|
-
* It is named `applyDeltaFrame`, not `processDeltaBatch`, to avoid confusion
|
|
697
|
-
* with {@link Database.processDeltaBatch} — the lower-level local write this
|
|
698
|
-
* eventually drives through `flushPendingDeltas`.
|
|
699
|
-
*/
|
|
700
|
-
protected applyDeltaFrame(deltas: SyncDelta[]): void;
|
|
701
|
-
/**
|
|
702
|
-
* Per-delta bookkeeping + enqueue. Returns `true` when the delta was
|
|
703
|
-
* pushed onto `pendingDeltas` (a regular batchable I/U/C/D delta that a
|
|
704
|
-
* subsequent flush must drain), `false` when it was skipped (dedup),
|
|
705
|
-
* deferred (bootstrap queue), or handled immediately out-of-band (G/S
|
|
706
|
-
* sync-group mutations). Does NOT schedule a flush — callers decide
|
|
707
|
-
* whether to debounce (live) or flush atomically (catch-up frame).
|
|
708
|
-
*/
|
|
709
|
-
protected enqueueDelta(delta: SyncDelta, options?: {
|
|
710
|
-
authoritative?: boolean;
|
|
711
|
-
}): boolean;
|
|
712
|
-
/** Debounce a flush for live single-delta traffic. */
|
|
713
|
-
protected scheduleDeltaFlush(): void;
|
|
714
|
-
/**
|
|
715
|
-
* Cancel pending transactions for child entities when a parent is deleted.
|
|
716
|
-
*
|
|
717
|
-
* Uses `pool.getByForeignKey` (O(1) via the FK index registered at
|
|
718
|
-
* schema build time) to find children. The previous implementation did
|
|
719
|
-
* `getByType(ctor).filter(e => e.toJSON()[foreignKey] === parentId)` —
|
|
720
|
-
* a full pool scan per child model + a `toJSON()` allocation per
|
|
721
|
-
* candidate. For a report delete with 10K blocks in the pool, that was
|
|
722
|
-
* 10K toJSON allocations per cascade level. The FK-indexed lookup
|
|
723
|
-
* skips both the scan AND the allocation.
|
|
724
|
-
*/
|
|
725
|
-
protected cascadeCancelTransactionsForDeletedParent(parentModelName: string, parentId: string): void;
|
|
726
|
-
/** Flush pending deltas with deduplication. Pool writes are delegated to {@link SyncClient}. */
|
|
727
|
-
protected flushPendingDeltas(): Promise<void>;
|
|
728
|
-
/** Check if a model type is local-only (no sync). Override for domain-specific models. */
|
|
729
|
-
protected isLocalOnlyModel(_modelName: string): boolean;
|
|
730
|
-
/** Validate model against schema before save */
|
|
731
|
-
protected validateModel(model: Model): void;
|
|
732
|
-
/**
|
|
733
|
-
* Save a model (create or update).
|
|
734
|
-
*
|
|
735
|
-
* Accepts any entity shape with `{ id: string }` so consumers can pass the
|
|
736
|
-
* Zod-inferred model types from `Model<Schema, K>` without knowing
|
|
737
|
-
* about the internal `Model` base class. At runtime, every entity reaching
|
|
738
|
-
* this method came through the object pool (via `store.create`, a query
|
|
739
|
-
* accessor, or an optimistic insert) and IS a `Model` instance — the one
|
|
740
|
-
* cast below preserves that invariant inside the SDK.
|
|
741
|
-
*/
|
|
742
|
-
save<T extends {
|
|
743
|
-
id: string;
|
|
744
|
-
createdAt?: Date;
|
|
745
|
-
updatedAt?: Date;
|
|
746
|
-
}>(entity: T, options?: {
|
|
747
|
-
skipValidation?: boolean;
|
|
748
|
-
}): Promise<void>;
|
|
749
|
-
/** Save with an atomic server mutation (e.g., createSectionWithBlocks) */
|
|
750
|
-
saveWithAtomicMutation(model: Model, mutation: (gql: unknown) => Promise<unknown>): Promise<void>;
|
|
751
|
-
/** Delete a model. Accepts schema-inferred entity shapes (see `save`). */
|
|
752
|
-
delete<T extends {
|
|
753
|
-
id: string;
|
|
754
|
-
}>(entity: T): Promise<void>;
|
|
755
|
-
/** Archive a model. Accepts schema-inferred entity shapes (see `save`). */
|
|
756
|
-
archive<T extends {
|
|
757
|
-
id: string;
|
|
758
|
-
archivedAt?: Date | null;
|
|
759
|
-
}>(entity: T): Promise<void>;
|
|
760
|
-
/** Unarchive a model. Accepts schema-inferred entity shapes (see `save`). */
|
|
761
|
-
unarchive<T extends {
|
|
762
|
-
id: string;
|
|
763
|
-
archivedAt?: Date | null;
|
|
764
|
-
}>(entity: T): Promise<void>;
|
|
765
|
-
/** Retrieve a single entity by id. Synchronous pool read. */
|
|
766
|
-
retrieve(_modelClass: ModelConstructor<Model>, id: string): Model | undefined;
|
|
767
|
-
/** Find any entity by ID regardless of type */
|
|
768
|
-
findAnyById(id: string): Model | undefined;
|
|
769
|
-
/**
|
|
770
|
-
* Lookup a model by ID alone. Matches the `SyncStoreRef.getById` contract
|
|
771
|
-
* that schema-defined computeds use when they need to resolve a related
|
|
772
|
-
* entity without holding onto its constructor.
|
|
773
|
-
*/
|
|
774
|
-
getById(id: string): Model | undefined;
|
|
775
|
-
/**
|
|
776
|
-
* Create a model instance locally, typed via the schema.
|
|
777
|
-
*
|
|
778
|
-
* ```ts
|
|
779
|
-
* const ledger = store.create('ledgers', { name, reportId });
|
|
780
|
-
* // ledger: Ledger | null — no cast needed
|
|
781
|
-
* ```
|
|
782
|
-
*
|
|
783
|
-
* The `typename` arg is the schema key (camelCase plural, e.g.
|
|
784
|
-
* `'ledgers'`); the returned instance has the
|
|
785
|
-
* `Model<Schema, K>` shape including computeds + relation accessors.
|
|
786
|
-
* Wraps `pool.create(...)` — the underlying runtime is unchanged, just
|
|
787
|
-
* type-narrowed.
|
|
788
|
-
*/
|
|
789
|
-
create<K extends keyof TSchema['models'] & string>(typename: K, data: Record<string, unknown>): import('./transaction/schema/schema.js').Model<TSchema, K> | null;
|
|
790
|
-
/**
|
|
791
|
-
* Query entry point for callers that hold a {@link Model} constructor and an
|
|
792
|
-
* options object. It filters, orders, and paginates the matching models from
|
|
793
|
-
* the pool. Prefer the schema-typed read surface (`ablo.<model>.list`) where
|
|
794
|
-
* you can, since it infers concrete row types without a class value or cast.
|
|
795
|
-
*/
|
|
796
|
-
queryByClass(modelClass: ModelConstructor<Model>, options?: {
|
|
797
|
-
predicate?: (model: Model) => boolean;
|
|
798
|
-
state?: ModelScope;
|
|
799
|
-
orderBy?: keyof Model;
|
|
800
|
-
order?: 'asc' | 'desc';
|
|
801
|
-
limit?: number;
|
|
802
|
-
offset?: number;
|
|
803
|
-
}): QueryResult<Model>;
|
|
804
|
-
/**
|
|
805
|
-
* Get all models of a type. Returns Model[] honestly — callers that need
|
|
806
|
-
* narrow types should use `useAblo((ablo) => ablo.<model>.list(...))`
|
|
807
|
-
* which does proper inference via `Model<S, K>`.
|
|
808
|
-
*/
|
|
809
|
-
allModelsOfType(modelClass: ModelConstructor<Model>, scope?: ModelScope): Model[];
|
|
810
|
-
/** Error handler for fire-and-forget flushPendingDeltas calls */
|
|
811
|
-
protected handleFlushError: (error: unknown) => void;
|
|
812
|
-
/** Process a single delta (used for immediate DELETE processing). Override for domain-specific handling. */
|
|
813
|
-
protected processDelta(delta: SyncDelta): Promise<void>;
|
|
814
|
-
/** Handle bootstrap_required event */
|
|
815
|
-
protected handleBootstrapRequired(_hint: BootstrapHint): void;
|
|
816
|
-
/** Handle bootstrap_data event. Override in subclass. */
|
|
817
|
-
protected handleBootstrapData(_data: BootstrapDataEvent): void;
|
|
818
|
-
/** Handle presence_update event. Override in subclass. */
|
|
819
|
-
protected handlePresenceUpdate(_data: PresenceUpdate): void;
|
|
820
|
-
protected incrementPendingChanges(): void;
|
|
821
|
-
protected decrementPendingChanges(): void;
|
|
822
|
-
protected updateSyncStatus(updates: Partial<SyncStatus>): void;
|
|
823
|
-
get pool(): InstanceCache;
|
|
824
|
-
get lastSyncId(): number;
|
|
825
|
-
get isReady(): boolean;
|
|
826
|
-
get isSyncing(): boolean;
|
|
827
|
-
get isOffline(): boolean;
|
|
828
|
-
get isReconnecting(): boolean;
|
|
829
|
-
get isError(): boolean;
|
|
830
|
-
get hasUnsyncedChanges(): boolean;
|
|
831
|
-
/** The SyncWebSocket handle — for collaboration events. */
|
|
832
|
-
get ws(): SyncWebSocket<TCollaboration> | null;
|
|
833
|
-
/** The Database instance — for demand loaders and direct IDB operations. */
|
|
834
|
-
get db(): Database;
|
|
835
|
-
/** The SyncClient instance — for assignment operations and other direct sync actions. */
|
|
836
|
-
get sc(): SyncClient;
|
|
837
|
-
/** The current organization ID — from the last initialize() call. */
|
|
838
|
-
get orgId(): string | undefined;
|
|
839
|
-
/** Count models matching a predicate. */
|
|
840
|
-
count(modelClass: ModelConstructor<Model>, predicate?: (m: Model) => boolean): number;
|
|
841
|
-
/** Get entities by foreign key (used by Model subclasses via Model.store) */
|
|
842
|
-
getByForeignKey(modelName: string, foreignKey: string, id: string): Model[];
|
|
843
|
-
}
|