@abloatai/humans 0.37.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/README.md +52 -0
- package/dist/Ablo.d.ts +208 -0
- package/dist/Ablo.js +120 -0
- package/dist/client.d.ts +317 -0
- package/dist/client.js +13 -0
- package/dist/core.d.ts +35 -0
- package/dist/core.js +48 -0
- package/dist/humans.d.ts +28 -0
- package/dist/humans.js +34 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +6 -0
- package/dist/local/BaseSyncedStore.d.ts +807 -0
- package/dist/local/BaseSyncedStore.js +1516 -0
- package/dist/local/Database.d.ts +322 -0
- package/dist/local/Database.js +1589 -0
- package/dist/local/InstanceCache.d.ts +255 -0
- package/dist/local/InstanceCache.js +1263 -0
- package/dist/local/LazyReferenceCollection.d.ts +177 -0
- package/dist/local/LazyReferenceCollection.js +461 -0
- package/dist/local/Model.d.ts +475 -0
- package/dist/local/Model.js +950 -0
- package/dist/local/ModelRegistry.d.ts +225 -0
- package/dist/local/ModelRegistry.js +539 -0
- package/dist/local/NetworkMonitor.d.ts +28 -0
- package/dist/local/NetworkMonitor.js +79 -0
- package/dist/local/RuntimeContext.d.ts +52 -0
- package/dist/local/RuntimeContext.js +80 -0
- package/dist/local/SyncClient.d.ts +516 -0
- package/dist/local/SyncClient.js +1754 -0
- package/dist/local/adapters/alwaysOnline.d.ts +14 -0
- package/dist/local/adapters/alwaysOnline.js +17 -0
- package/dist/local/adapters/inMemoryStorage.d.ts +37 -0
- package/dist/local/adapters/inMemoryStorage.js +122 -0
- package/dist/local/client/clientPrelude.d.ts +52 -0
- package/dist/local/client/clientPrelude.js +60 -0
- package/dist/local/client/consoleLogger.d.ts +35 -0
- package/dist/local/client/consoleLogger.js +44 -0
- package/dist/local/client/createInternalComponents.d.ts +50 -0
- package/dist/local/client/createInternalComponents.js +98 -0
- package/dist/local/client/createModelProxy.d.ts +248 -0
- package/dist/local/client/createModelProxy.js +880 -0
- package/dist/local/client/modelRegistration.d.ts +10 -0
- package/dist/local/client/modelRegistration.js +316 -0
- package/dist/local/client/options.d.ts +440 -0
- package/dist/local/client/options.js +7 -0
- package/dist/local/client/reactiveEngine.d.ts +53 -0
- package/dist/local/client/reactiveEngine.js +705 -0
- package/dist/local/client/resourceTypes.d.ts +12 -0
- package/dist/local/client/resourceTypes.js +10 -0
- package/dist/local/client/schemaConfig.d.ts +44 -0
- package/dist/local/client/schemaConfig.js +185 -0
- package/dist/local/client/storeCluster.d.ts +46 -0
- package/dist/local/client/storeCluster.js +133 -0
- package/dist/local/client/storeLifecycle.d.ts +61 -0
- package/dist/local/client/storeLifecycle.js +236 -0
- package/dist/local/client/validateAbloOptions.d.ts +42 -0
- package/dist/local/client/validateAbloOptions.js +43 -0
- package/dist/local/client/wsMutationExecutor.d.ts +27 -0
- package/dist/local/client/wsMutationExecutor.js +72 -0
- package/dist/local/context.d.ts +42 -0
- package/dist/local/context.js +81 -0
- package/dist/local/coordination/ClaimLog.d.ts +26 -0
- package/dist/local/coordination/ClaimLog.js +32 -0
- package/dist/local/interfaces/index.d.ts +311 -0
- package/dist/local/interfaces/index.js +9 -0
- package/dist/local/localModelContract.d.ts +14 -0
- package/dist/local/localModelContract.js +1 -0
- package/dist/local/logPosition.d.ts +31 -0
- package/dist/local/logPosition.js +53 -0
- package/dist/local/mutationPersistence.d.ts +6 -0
- package/dist/local/mutationPersistence.js +1 -0
- package/dist/local/mutators/RecordingMutation.d.ts +36 -0
- package/dist/local/mutators/RecordingMutation.js +182 -0
- package/dist/local/mutators/Transaction.d.ts +40 -0
- package/dist/local/mutators/Transaction.js +58 -0
- package/dist/local/mutators/UndoManager.d.ts +258 -0
- package/dist/local/mutators/UndoManager.js +665 -0
- package/dist/local/mutators/defineMutators.d.ts +60 -0
- package/dist/local/mutators/defineMutators.js +18 -0
- package/dist/local/mutators/inverseOp.d.ts +126 -0
- package/dist/local/mutators/inverseOp.js +71 -0
- package/dist/local/mutators/mutateActions.d.ts +45 -0
- package/dist/local/mutators/mutateActions.js +105 -0
- package/dist/local/mutators/readerActions.d.ts +33 -0
- package/dist/local/mutators/readerActions.js +57 -0
- package/dist/local/mutators/undoApply.d.ts +51 -0
- package/dist/local/mutators/undoApply.js +117 -0
- package/dist/local/persistence.d.ts +7 -0
- package/dist/local/persistence.js +9 -0
- package/dist/local/query/QueryProcessor.d.ts +75 -0
- package/dist/local/query/QueryProcessor.js +255 -0
- package/dist/local/query/client.d.ts +64 -0
- package/dist/local/query/client.js +138 -0
- package/dist/local/query/types.d.ts +85 -0
- package/dist/local/query/types.js +16 -0
- package/dist/local/schema/serialize.d.ts +1 -0
- package/dist/local/schema/serialize.js +1 -0
- package/dist/local/store/queryApi.d.ts +13 -0
- package/dist/local/store/queryApi.js +35 -0
- package/dist/local/storeContract.d.ts +145 -0
- package/dist/local/storeContract.js +12 -0
- package/dist/local/stores/DatabaseManager.d.ts +112 -0
- package/dist/local/stores/DatabaseManager.js +400 -0
- package/dist/local/stores/ObjectStore.d.ts +115 -0
- package/dist/local/stores/ObjectStore.js +393 -0
- package/dist/local/stores/ObjectStoreContract.d.ts +38 -0
- package/dist/local/stores/ObjectStoreContract.js +1 -0
- package/dist/local/stores/StoreManager.d.ts +114 -0
- package/dist/local/stores/StoreManager.js +304 -0
- package/dist/local/stores/SyncActionStore.d.ts +99 -0
- package/dist/local/stores/SyncActionStore.js +506 -0
- package/dist/local/stores/openIDBWithTimeout.d.ts +65 -0
- package/dist/local/stores/openIDBWithTimeout.js +153 -0
- package/dist/local/stores/persistenceCleanup.d.ts +7 -0
- package/dist/local/stores/persistenceCleanup.js +26 -0
- package/dist/local/stores/persistenceIdentity.d.ts +27 -0
- package/dist/local/stores/persistenceIdentity.js +38 -0
- package/dist/local/stores/syncAction.d.ts +26 -0
- package/dist/local/stores/syncAction.js +16 -0
- package/dist/local/stores/v1PersistenceDeletion.d.ts +8 -0
- package/dist/local/stores/v1PersistenceDeletion.js +16 -0
- package/dist/local/sync/BootstrapFetcher.d.ts +284 -0
- package/dist/local/sync/BootstrapFetcher.js +964 -0
- package/dist/local/sync/ConnectionManager.d.ts +8 -0
- package/dist/local/sync/ConnectionManager.js +8 -0
- package/dist/local/sync/OnDemandLoader.d.ts +231 -0
- package/dist/local/sync/OnDemandLoader.js +743 -0
- package/dist/local/sync/SubscriptionManager.d.ts +159 -0
- package/dist/local/sync/SubscriptionManager.js +243 -0
- package/dist/local/sync/SyncWebSocket.d.ts +173 -0
- package/dist/local/sync/SyncWebSocket.js +438 -0
- package/dist/local/sync/bootstrapApply.d.ts +73 -0
- package/dist/local/sync/bootstrapApply.js +73 -0
- package/dist/local/sync/commitFrames.d.ts +8 -0
- package/dist/local/sync/commitFrames.js +8 -0
- package/dist/local/sync/connectionManagerLifecycle.d.ts +23 -0
- package/dist/local/sync/connectionManagerLifecycle.js +126 -0
- package/dist/local/sync/contextPorts.d.ts +18 -0
- package/dist/local/sync/contextPorts.js +31 -0
- package/dist/local/sync/createClaimStream.d.ts +64 -0
- package/dist/local/sync/createClaimStream.js +475 -0
- package/dist/local/sync/createSnapshot.d.ts +29 -0
- package/dist/local/sync/createSnapshot.js +116 -0
- package/dist/local/sync/credentialLifecycle.d.ts +7 -0
- package/dist/local/sync/credentialLifecycle.js +7 -0
- package/dist/local/sync/deltaPipeline.d.ts +116 -0
- package/dist/local/sync/deltaPipeline.js +357 -0
- package/dist/local/sync/groupChange.d.ts +116 -0
- package/dist/local/sync/groupChange.js +244 -0
- package/dist/local/sync/initialize.d.ts +27 -0
- package/dist/local/sync/initialize.js +137 -0
- package/dist/local/sync/participants.d.ts +132 -0
- package/dist/local/sync/participants.js +342 -0
- package/dist/local/sync/persistedPrefix.d.ts +12 -0
- package/dist/local/sync/persistedPrefix.js +22 -0
- package/dist/local/sync/reconnect.d.ts +23 -0
- package/dist/local/sync/reconnect.js +55 -0
- package/dist/local/sync/schemaDrift.d.ts +55 -0
- package/dist/local/sync/schemaDrift.js +53 -0
- package/dist/local/sync/schemas.d.ts +71 -0
- package/dist/local/sync/schemas.js +94 -0
- package/dist/local/sync/socketEventWiring.d.ts +31 -0
- package/dist/local/sync/socketEventWiring.js +130 -0
- package/dist/local/sync/syncCursor.d.ts +40 -0
- package/dist/local/sync/syncCursor.js +55 -0
- package/dist/local/sync/syncPlan.d.ts +54 -0
- package/dist/local/sync/syncPlan.js +50 -0
- package/dist/local/sync/terminalSessionLifecycle.d.ts +20 -0
- package/dist/local/sync/terminalSessionLifecycle.js +50 -0
- package/dist/local/sync/wsFrameHandlers.d.ts +8 -0
- package/dist/local/sync/wsFrameHandlers.js +8 -0
- package/dist/local/transactions/databaseCommitOutbox.d.ts +15 -0
- package/dist/local/transactions/databaseCommitOutbox.js +16 -0
- package/dist/local/transactions/localMutation.d.ts +10 -0
- package/dist/local/transactions/localMutation.js +37 -0
- package/dist/local/transactions/mutations/MutationQueue.d.ts +511 -0
- package/dist/local/transactions/mutations/MutationQueue.js +1498 -0
- package/dist/local/transactions/mutations/MutationStore.d.ts +20 -0
- package/dist/local/transactions/mutations/MutationStore.js +53 -0
- package/dist/local/transactions/mutations/UnconfirmedWrites.d.ts +82 -0
- package/dist/local/transactions/mutations/UnconfirmedWrites.js +104 -0
- package/dist/local/transactions/mutations/batchProcessing.d.ts +64 -0
- package/dist/local/transactions/mutations/batchProcessing.js +349 -0
- package/dist/local/transactions/mutations/coalesceRules.d.ts +58 -0
- package/dist/local/transactions/mutations/coalesceRules.js +140 -0
- package/dist/local/transactions/mutations/commitApi.d.ts +19 -0
- package/dist/local/transactions/mutations/commitApi.js +74 -0
- package/dist/local/transactions/mutations/commitLane.d.ts +70 -0
- package/dist/local/transactions/mutations/commitLane.js +140 -0
- package/dist/local/transactions/mutations/commitLatency.d.ts +52 -0
- package/dist/local/transactions/mutations/commitLatency.js +130 -0
- package/dist/local/transactions/mutations/commitPayload.d.ts +165 -0
- package/dist/local/transactions/mutations/commitPayload.js +152 -0
- package/dist/local/transactions/mutations/commitTransport.d.ts +36 -0
- package/dist/local/transactions/mutations/commitTransport.js +104 -0
- package/dist/local/transactions/mutations/deltaConfirmation.d.ts +63 -0
- package/dist/local/transactions/mutations/deltaConfirmation.js +235 -0
- package/dist/local/transactions/mutations/durableCommitRestore.d.ts +17 -0
- package/dist/local/transactions/mutations/durableCommitRestore.js +95 -0
- package/dist/local/transactions/mutations/durableWriteStore.d.ts +14 -0
- package/dist/local/transactions/mutations/durableWriteStore.js +12 -0
- package/dist/local/transactions/mutations/executionSelection.d.ts +6 -0
- package/dist/local/transactions/mutations/executionSelection.js +42 -0
- package/dist/local/transactions/mutations/failureHandling.d.ts +16 -0
- package/dist/local/transactions/mutations/failureHandling.js +130 -0
- package/dist/local/transactions/mutations/failurePolicy.d.ts +13 -0
- package/dist/local/transactions/mutations/failurePolicy.js +48 -0
- package/dist/local/transactions/mutations/localMutation.d.ts +58 -0
- package/dist/local/transactions/mutations/localMutation.js +75 -0
- package/dist/local/transactions/mutations/modelOperations.d.ts +44 -0
- package/dist/local/transactions/mutations/modelOperations.js +144 -0
- package/dist/local/transactions/mutations/mutationPersistence.d.ts +25 -0
- package/dist/local/transactions/mutations/mutationPersistence.js +188 -0
- package/dist/local/transactions/mutations/pendingDrain.d.ts +33 -0
- package/dist/local/transactions/mutations/pendingDrain.js +112 -0
- package/dist/local/transactions/mutations/processingScheduler.d.ts +14 -0
- package/dist/local/transactions/mutations/processingScheduler.js +24 -0
- package/dist/local/transactions/mutations/queueCoalescing.d.ts +13 -0
- package/dist/local/transactions/mutations/queueCoalescing.js +35 -0
- package/dist/local/transactions/mutations/replayValidation.d.ts +187 -0
- package/dist/local/transactions/mutations/replayValidation.js +164 -0
- package/dist/local/transactions/reconnectDrain.d.ts +11 -0
- package/dist/local/transactions/reconnectDrain.js +13 -0
- package/dist/local/utils/mobxSetup.d.ts +53 -0
- package/dist/local/utils/mobxSetup.js +330 -0
- package/dist/local/views/QueryView.d.ts +79 -0
- package/dist/local/views/QueryView.js +218 -0
- package/dist/local/views/ViewRegistry.d.ts +20 -0
- package/dist/local/views/ViewRegistry.js +57 -0
- package/dist/local/views/incrementalView.d.ts +45 -0
- package/dist/local/views/incrementalView.js +69 -0
- package/dist/plugin.d.ts +285 -0
- package/dist/plugin.js +106 -0
- package/dist/presenceStream.d.ts +69 -0
- package/dist/presenceStream.js +200 -0
- package/dist/react/AbloProvider.d.ts +242 -0
- package/dist/react/AbloProvider.js +456 -0
- package/dist/react/ClientSideSuspense.d.ts +36 -0
- package/dist/react/ClientSideSuspense.js +17 -0
- package/dist/react/DefaultFallback.d.ts +24 -0
- package/dist/react/DefaultFallback.js +43 -0
- package/dist/react/context.d.ts +55 -0
- package/dist/react/context.js +29 -0
- package/dist/react/createAbloReact.d.ts +50 -0
- package/dist/react/createAbloReact.js +48 -0
- package/dist/react/internalContext.d.ts +33 -0
- package/dist/react/internalContext.js +3 -0
- package/dist/react/useAblo.d.ts +96 -0
- package/dist/react/useAblo.js +120 -0
- package/dist/react/useCurrentUserId.d.ts +2 -0
- package/dist/react/useCurrentUserId.js +12 -0
- package/dist/react/useErrorListener.d.ts +2 -0
- package/dist/react/useErrorListener.js +14 -0
- package/dist/react/useMutationFailureListener.d.ts +8 -0
- package/dist/react/useMutationFailureListener.js +19 -0
- package/dist/react/useMutators.d.ts +56 -0
- package/dist/react/useMutators.js +84 -0
- package/dist/react/useSyncStatus.d.ts +19 -0
- package/dist/react/useSyncStatus.js +37 -0
- package/dist/react/useUndoScope.d.ts +34 -0
- package/dist/react/useUndoScope.js +73 -0
- package/dist/react.d.ts +18 -0
- package/dist/react.js +14 -0
- package/dist/reactRuntime.d.ts +4 -0
- package/dist/reactRuntime.js +2 -0
- package/dist/surface.d.ts +36 -0
- package/dist/surface.js +77 -0
- package/dist/useReactive.d.ts +6 -0
- package/dist/useReactive.js +43 -0
- package/package.json +119 -0
- package/src/Ablo.ts +456 -0
- package/src/client.ts +374 -0
- package/src/core.ts +104 -0
- package/src/humans.ts +61 -0
- package/src/index.ts +40 -0
- package/src/local/BaseSyncedStore.ts +1991 -0
- package/src/local/Database.ts +2052 -0
- package/src/local/InstanceCache.ts +1503 -0
- package/src/local/LazyReferenceCollection.ts +563 -0
- package/src/local/Model.ts +1124 -0
- package/src/local/ModelRegistry.ts +762 -0
- package/src/local/NetworkMonitor.ts +88 -0
- package/src/local/RuntimeContext.ts +141 -0
- package/src/local/SyncClient.ts +2131 -0
- package/src/local/adapters/alwaysOnline.ts +20 -0
- package/src/local/adapters/inMemoryStorage.ts +141 -0
- package/src/local/client/clientPrelude.ts +112 -0
- package/src/local/client/consoleLogger.ts +60 -0
- package/src/local/client/createInternalComponents.ts +163 -0
- package/src/local/client/createModelProxy.ts +1390 -0
- package/src/local/client/modelRegistration.ts +350 -0
- package/src/local/client/options.ts +526 -0
- package/src/local/client/reactiveEngine.ts +935 -0
- package/src/local/client/resourceTypes.ts +37 -0
- package/src/local/client/schemaConfig.ts +194 -0
- package/src/local/client/storeCluster.ts +172 -0
- package/src/local/client/storeLifecycle.ts +343 -0
- package/src/local/client/validateAbloOptions.ts +95 -0
- package/src/local/client/wsMutationExecutor.ts +110 -0
- package/src/local/context.ts +96 -0
- package/src/local/coordination/ClaimLog.ts +39 -0
- package/src/local/interfaces/index.ts +468 -0
- package/src/local/localModelContract.ts +15 -0
- package/src/local/logPosition.ts +84 -0
- package/src/local/mutationPersistence.ts +7 -0
- package/src/local/mutators/RecordingMutation.ts +222 -0
- package/src/local/mutators/Transaction.ts +97 -0
- package/src/local/mutators/UndoManager.ts +741 -0
- package/src/local/mutators/defineMutators.ts +76 -0
- package/src/local/mutators/inverseOp.ts +83 -0
- package/src/local/mutators/mutateActions.ts +167 -0
- package/src/local/mutators/readerActions.ts +99 -0
- package/src/local/mutators/undoApply.ts +141 -0
- package/src/local/persistence.ts +16 -0
- package/src/local/query/QueryProcessor.ts +347 -0
- package/src/local/query/client.ts +197 -0
- package/src/local/query/types.ts +102 -0
- package/src/local/schema/serialize.ts +1 -0
- package/src/local/store/queryApi.ts +56 -0
- package/src/local/storeContract.ts +146 -0
- package/src/local/stores/DatabaseManager.ts +507 -0
- package/src/local/stores/ObjectStore.ts +449 -0
- package/src/local/stores/ObjectStoreContract.ts +48 -0
- package/src/local/stores/StoreManager.ts +388 -0
- package/src/local/stores/SyncActionStore.ts +579 -0
- package/src/local/stores/openIDBWithTimeout.ts +195 -0
- package/src/local/stores/persistenceCleanup.ts +43 -0
- package/src/local/stores/persistenceIdentity.ts +83 -0
- package/src/local/stores/syncAction.ts +21 -0
- package/src/local/stores/v1PersistenceDeletion.ts +21 -0
- package/src/local/sync/BootstrapFetcher.ts +1224 -0
- package/src/local/sync/ConnectionManager.ts +15 -0
- package/src/local/sync/OnDemandLoader.ts +927 -0
- package/src/local/sync/SubscriptionManager.ts +300 -0
- package/src/local/sync/SyncWebSocket.ts +584 -0
- package/src/local/sync/bootstrapApply.ts +130 -0
- package/src/local/sync/commitFrames.ts +16 -0
- package/src/local/sync/connectionManagerLifecycle.ts +158 -0
- package/src/local/sync/contextPorts.ts +37 -0
- package/src/local/sync/createClaimStream.ts +668 -0
- package/src/local/sync/createSnapshot.ts +160 -0
- package/src/local/sync/credentialLifecycle.ts +18 -0
- package/src/local/sync/deltaPipeline.ts +473 -0
- package/src/local/sync/groupChange.ts +343 -0
- package/src/local/sync/initialize.ts +205 -0
- package/src/local/sync/participants.ts +564 -0
- package/src/local/sync/persistedPrefix.ts +27 -0
- package/src/local/sync/reconnect.ts +88 -0
- package/src/local/sync/schemaDrift.ts +86 -0
- package/src/local/sync/schemas.ts +118 -0
- package/src/local/sync/socketEventWiring.ts +196 -0
- package/src/local/sync/syncCursor.ts +62 -0
- package/src/local/sync/syncPlan.ts +89 -0
- package/src/local/sync/terminalSessionLifecycle.ts +66 -0
- package/src/local/sync/wsFrameHandlers.ts +20 -0
- package/src/local/transactions/databaseCommitOutbox.ts +33 -0
- package/src/local/transactions/localMutation.ts +58 -0
- package/src/local/transactions/mutations/MutationQueue.ts +1998 -0
- package/src/local/transactions/mutations/MutationStore.ts +65 -0
- package/src/local/transactions/mutations/UnconfirmedWrites.ts +133 -0
- package/src/local/transactions/mutations/batchProcessing.ts +469 -0
- package/src/local/transactions/mutations/coalesceRules.ts +192 -0
- package/src/local/transactions/mutations/commitApi.ts +97 -0
- package/src/local/transactions/mutations/commitLane.ts +191 -0
- package/src/local/transactions/mutations/commitLatency.ts +164 -0
- package/src/local/transactions/mutations/commitPayload.ts +281 -0
- package/src/local/transactions/mutations/commitTransport.ts +174 -0
- package/src/local/transactions/mutations/deltaConfirmation.ts +298 -0
- package/src/local/transactions/mutations/durableCommitRestore.ts +128 -0
- package/src/local/transactions/mutations/durableWriteStore.ts +21 -0
- package/src/local/transactions/mutations/executionSelection.ts +42 -0
- package/src/local/transactions/mutations/failureHandling.ts +154 -0
- package/src/local/transactions/mutations/failurePolicy.ts +61 -0
- package/src/local/transactions/mutations/localMutation.ts +135 -0
- package/src/local/transactions/mutations/modelOperations.ts +210 -0
- package/src/local/transactions/mutations/mutationPersistence.ts +231 -0
- package/src/local/transactions/mutations/pendingDrain.ts +160 -0
- package/src/local/transactions/mutations/processingScheduler.ts +35 -0
- package/src/local/transactions/mutations/queueCoalescing.ts +45 -0
- package/src/local/transactions/mutations/replayValidation.ts +192 -0
- package/src/local/transactions/reconnectDrain.ts +24 -0
- package/src/local/utils/mobxSetup.ts +388 -0
- package/src/local/views/QueryView.ts +311 -0
- package/src/local/views/ViewRegistry.ts +61 -0
- package/src/local/views/incrementalView.ts +92 -0
- package/src/plugin.ts +396 -0
- package/src/presenceStream.ts +279 -0
- package/src/react/AbloProvider.tsx +744 -0
- package/src/react/ClientSideSuspense.tsx +57 -0
- package/src/react/DefaultFallback.tsx +60 -0
- package/src/react/context.ts +89 -0
- package/src/react/createAbloReact.ts +116 -0
- package/src/react/internalContext.ts +38 -0
- package/src/react/useAblo.ts +280 -0
- package/src/react/useCurrentUserId.ts +17 -0
- package/src/react/useErrorListener.ts +22 -0
- package/src/react/useMutationFailureListener.ts +34 -0
- package/src/react/useMutators.ts +184 -0
- package/src/react/useSyncStatus.ts +42 -0
- package/src/react/useUndoScope.ts +143 -0
- package/src/react.ts +69 -0
- package/src/reactRuntime.ts +10 -0
- package/src/surface.ts +106 -0
- package/src/useReactive.ts +51 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An in-memory index of transactions by id, with a secondary index by status.
|
|
3
|
+
* The status index keeps the queue's hot paths — such as `getByStatus('pending')`
|
|
4
|
+
* on every batch and coalesce decision — proportional to the number of
|
|
5
|
+
* transactions in that status rather than the total across all statuses.
|
|
6
|
+
* {@link MutationQueue} owns an instance and routes every status change
|
|
7
|
+
* through {@link updateStatus}, which keeps the two indexes consistent.
|
|
8
|
+
*/
|
|
9
|
+
import type { QueuedMutation } from './commitPayload.js';
|
|
10
|
+
export declare class MutationStore {
|
|
11
|
+
private transactions;
|
|
12
|
+
private byStatus;
|
|
13
|
+
add(transaction: QueuedMutation): void;
|
|
14
|
+
get(id: string): QueuedMutation | undefined;
|
|
15
|
+
updateStatus(id: string, newStatus: QueuedMutation['status']): void;
|
|
16
|
+
getByStatus(status: QueuedMutation['status']): QueuedMutation[];
|
|
17
|
+
remove(id: string): void;
|
|
18
|
+
clear(): void;
|
|
19
|
+
getAll(): QueuedMutation[];
|
|
20
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An in-memory index of transactions by id, with a secondary index by status.
|
|
3
|
+
* The status index keeps the queue's hot paths — such as `getByStatus('pending')`
|
|
4
|
+
* on every batch and coalesce decision — proportional to the number of
|
|
5
|
+
* transactions in that status rather than the total across all statuses.
|
|
6
|
+
* {@link MutationQueue} owns an instance and routes every status change
|
|
7
|
+
* through {@link updateStatus}, which keeps the two indexes consistent.
|
|
8
|
+
*/
|
|
9
|
+
export class MutationStore {
|
|
10
|
+
transactions = new Map();
|
|
11
|
+
byStatus = new Map();
|
|
12
|
+
add(transaction) {
|
|
13
|
+
this.transactions.set(transaction.id, transaction);
|
|
14
|
+
if (!this.byStatus.has(transaction.status)) {
|
|
15
|
+
this.byStatus.set(transaction.status, new Set());
|
|
16
|
+
}
|
|
17
|
+
this.byStatus.get(transaction.status).add(transaction.id);
|
|
18
|
+
}
|
|
19
|
+
get(id) {
|
|
20
|
+
return this.transactions.get(id);
|
|
21
|
+
}
|
|
22
|
+
updateStatus(id, newStatus) {
|
|
23
|
+
const tx = this.transactions.get(id);
|
|
24
|
+
if (!tx)
|
|
25
|
+
return;
|
|
26
|
+
this.byStatus.get(tx.status)?.delete(id);
|
|
27
|
+
tx.status = newStatus;
|
|
28
|
+
if (!this.byStatus.has(newStatus)) {
|
|
29
|
+
this.byStatus.set(newStatus, new Set());
|
|
30
|
+
}
|
|
31
|
+
this.byStatus.get(newStatus).add(id);
|
|
32
|
+
}
|
|
33
|
+
getByStatus(status) {
|
|
34
|
+
const ids = this.byStatus.get(status) || new Set();
|
|
35
|
+
return Array.from(ids)
|
|
36
|
+
.map((id) => this.transactions.get(id))
|
|
37
|
+
.filter(Boolean);
|
|
38
|
+
}
|
|
39
|
+
remove(id) {
|
|
40
|
+
const tx = this.transactions.get(id);
|
|
41
|
+
if (!tx)
|
|
42
|
+
return;
|
|
43
|
+
this.transactions.delete(id);
|
|
44
|
+
this.byStatus.get(tx.status)?.delete(id);
|
|
45
|
+
}
|
|
46
|
+
clear() {
|
|
47
|
+
this.transactions.clear();
|
|
48
|
+
this.byStatus.clear();
|
|
49
|
+
}
|
|
50
|
+
getAll() {
|
|
51
|
+
return Array.from(this.transactions.values());
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tracks the transactions this client has applied locally but the server has
|
|
3
|
+
* not yet confirmed, so their echoes can be recognized when they return over
|
|
4
|
+
* the sync stream. When a change is made optimistically, the client updates
|
|
5
|
+
* its own state at once; the server later broadcasts the same change as a sync
|
|
6
|
+
* delta stamped with the originating `transactionId`. This tracker lets the
|
|
7
|
+
* receive path recognize that delta as its own echo and skip re-applying it,
|
|
8
|
+
* since the optimistic write already reflects it. Without this discriminator
|
|
9
|
+
* the apply path would re-apply the confirmation on top of state that may have
|
|
10
|
+
* changed since, producing a visible flicker.
|
|
11
|
+
*
|
|
12
|
+
* An entry is added with {@link markPending} and drained either by
|
|
13
|
+
* {@link consumeEcho} when the matching delta arrives, or by
|
|
14
|
+
* {@link drainOnRollback} when the originating transaction is cancelled.
|
|
15
|
+
*
|
|
16
|
+
* The set is bounded by `maxSize` to guard against unbounded growth if
|
|
17
|
+
* transactions are somehow never confirmed and never rolled back. When the
|
|
18
|
+
* bound is reached the oldest id is evicted first, since the backing Map
|
|
19
|
+
* iterates in insertion order. Eviction carries no correctness risk for the
|
|
20
|
+
* client that made the write, whose local state already reflects the change;
|
|
21
|
+
* the only cost is that a later echo of the evicted transaction is applied as
|
|
22
|
+
* if it were a foreign change, at worst a single redundant re-set.
|
|
23
|
+
*/
|
|
24
|
+
export interface UnconfirmedWritesOptions {
|
|
25
|
+
/**
|
|
26
|
+
* The maximum number of unconfirmed transaction ids to track. Once this many
|
|
27
|
+
* are held, adding another evicts the oldest. Defaults to 10,000, which
|
|
28
|
+
* leaves ample headroom even for a client with many tabs open during a large
|
|
29
|
+
* bulk edit.
|
|
30
|
+
*/
|
|
31
|
+
maxSize?: number;
|
|
32
|
+
}
|
|
33
|
+
export interface UnconfirmedWritesMetrics {
|
|
34
|
+
/** Total ids currently tracked. */
|
|
35
|
+
size: number;
|
|
36
|
+
/** Cumulative ids ever added since construction. */
|
|
37
|
+
totalAdded: number;
|
|
38
|
+
/** Cumulative successful echo matches (delta arrived → drained). */
|
|
39
|
+
hits: number;
|
|
40
|
+
/** Cumulative explicit rollback drains (transaction never made it). */
|
|
41
|
+
rollbacks: number;
|
|
42
|
+
/** Cumulative ids evicted due to maxSize pressure. */
|
|
43
|
+
evictions: number;
|
|
44
|
+
}
|
|
45
|
+
export declare class UnconfirmedWrites {
|
|
46
|
+
private readonly ids;
|
|
47
|
+
private readonly maxSize;
|
|
48
|
+
private _totalAdded;
|
|
49
|
+
private _hits;
|
|
50
|
+
private _rollbacks;
|
|
51
|
+
private _evictions;
|
|
52
|
+
constructor(options?: UnconfirmedWritesOptions);
|
|
53
|
+
/**
|
|
54
|
+
* Mark a transaction as locally-applied. The next sync delta with a
|
|
55
|
+
* matching `transactionId` will be recognized as the server's
|
|
56
|
+
* confirmation of this same write. Idempotent — repeated calls with
|
|
57
|
+
* the same id are no-ops.
|
|
58
|
+
*/
|
|
59
|
+
markPending(transactionId: string): void;
|
|
60
|
+
/**
|
|
61
|
+
* Reports whether an incoming delta is this client's own echo, draining the
|
|
62
|
+
* entry if so. Returns true when the id was being tracked, signalling the
|
|
63
|
+
* caller to skip re-applying the change because the optimistic write already
|
|
64
|
+
* reflects it; returns false for a change that originated elsewhere, which
|
|
65
|
+
* should be applied normally.
|
|
66
|
+
*
|
|
67
|
+
* The check and drain are combined into one call so the receive path cannot
|
|
68
|
+
* accidentally treat two deltas carrying the same id, arriving in one batch,
|
|
69
|
+
* as separate echoes.
|
|
70
|
+
*/
|
|
71
|
+
consumeEcho(transactionId: string | null | undefined): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Drains the entry for a transaction that was rolled back before the server
|
|
74
|
+
* confirmed it. No echo will ever arrive for a cancelled transaction, so
|
|
75
|
+
* without this the pending entry would leak. Rollbacks are counted separately
|
|
76
|
+
* from confirmed echoes, so a rise in rollbacks relative to hits can flag
|
|
77
|
+
* network or server trouble.
|
|
78
|
+
*/
|
|
79
|
+
drainOnRollback(transactionId: string): void;
|
|
80
|
+
getMetrics(): Readonly<UnconfirmedWritesMetrics>;
|
|
81
|
+
clear(): void;
|
|
82
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tracks the transactions this client has applied locally but the server has
|
|
3
|
+
* not yet confirmed, so their echoes can be recognized when they return over
|
|
4
|
+
* the sync stream. When a change is made optimistically, the client updates
|
|
5
|
+
* its own state at once; the server later broadcasts the same change as a sync
|
|
6
|
+
* delta stamped with the originating `transactionId`. This tracker lets the
|
|
7
|
+
* receive path recognize that delta as its own echo and skip re-applying it,
|
|
8
|
+
* since the optimistic write already reflects it. Without this discriminator
|
|
9
|
+
* the apply path would re-apply the confirmation on top of state that may have
|
|
10
|
+
* changed since, producing a visible flicker.
|
|
11
|
+
*
|
|
12
|
+
* An entry is added with {@link markPending} and drained either by
|
|
13
|
+
* {@link consumeEcho} when the matching delta arrives, or by
|
|
14
|
+
* {@link drainOnRollback} when the originating transaction is cancelled.
|
|
15
|
+
*
|
|
16
|
+
* The set is bounded by `maxSize` to guard against unbounded growth if
|
|
17
|
+
* transactions are somehow never confirmed and never rolled back. When the
|
|
18
|
+
* bound is reached the oldest id is evicted first, since the backing Map
|
|
19
|
+
* iterates in insertion order. Eviction carries no correctness risk for the
|
|
20
|
+
* client that made the write, whose local state already reflects the change;
|
|
21
|
+
* the only cost is that a later echo of the evicted transaction is applied as
|
|
22
|
+
* if it were a foreign change, at worst a single redundant re-set.
|
|
23
|
+
*/
|
|
24
|
+
const DEFAULT_MAX_SIZE = 10_000;
|
|
25
|
+
export class UnconfirmedWrites {
|
|
26
|
+
// Map (not Set) for O(1) FIFO eviction via insertion order.
|
|
27
|
+
// Value is unused; Map.keys() iterates in insertion order so
|
|
28
|
+
// `keys().next()` yields the oldest id.
|
|
29
|
+
ids = new Map();
|
|
30
|
+
maxSize;
|
|
31
|
+
// Metrics — internal counters; exposed via `getMetrics()`. Kept
|
|
32
|
+
// numeric (not BigInt) since cumulative-since-page-load fits well
|
|
33
|
+
// under Number.MAX_SAFE_INTEGER for any realistic session.
|
|
34
|
+
_totalAdded = 0;
|
|
35
|
+
_hits = 0;
|
|
36
|
+
_rollbacks = 0;
|
|
37
|
+
_evictions = 0;
|
|
38
|
+
constructor(options = {}) {
|
|
39
|
+
this.maxSize = options.maxSize ?? DEFAULT_MAX_SIZE;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Mark a transaction as locally-applied. The next sync delta with a
|
|
43
|
+
* matching `transactionId` will be recognized as the server's
|
|
44
|
+
* confirmation of this same write. Idempotent — repeated calls with
|
|
45
|
+
* the same id are no-ops.
|
|
46
|
+
*/
|
|
47
|
+
markPending(transactionId) {
|
|
48
|
+
if (this.ids.has(transactionId))
|
|
49
|
+
return;
|
|
50
|
+
if (this.ids.size >= this.maxSize) {
|
|
51
|
+
const oldest = this.ids.keys().next().value;
|
|
52
|
+
if (oldest !== undefined) {
|
|
53
|
+
this.ids.delete(oldest);
|
|
54
|
+
this._evictions += 1;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
this.ids.set(transactionId, true);
|
|
58
|
+
this._totalAdded += 1;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Reports whether an incoming delta is this client's own echo, draining the
|
|
62
|
+
* entry if so. Returns true when the id was being tracked, signalling the
|
|
63
|
+
* caller to skip re-applying the change because the optimistic write already
|
|
64
|
+
* reflects it; returns false for a change that originated elsewhere, which
|
|
65
|
+
* should be applied normally.
|
|
66
|
+
*
|
|
67
|
+
* The check and drain are combined into one call so the receive path cannot
|
|
68
|
+
* accidentally treat two deltas carrying the same id, arriving in one batch,
|
|
69
|
+
* as separate echoes.
|
|
70
|
+
*/
|
|
71
|
+
consumeEcho(transactionId) {
|
|
72
|
+
if (!transactionId)
|
|
73
|
+
return false;
|
|
74
|
+
if (!this.ids.has(transactionId))
|
|
75
|
+
return false;
|
|
76
|
+
this.ids.delete(transactionId);
|
|
77
|
+
this._hits += 1;
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Drains the entry for a transaction that was rolled back before the server
|
|
82
|
+
* confirmed it. No echo will ever arrive for a cancelled transaction, so
|
|
83
|
+
* without this the pending entry would leak. Rollbacks are counted separately
|
|
84
|
+
* from confirmed echoes, so a rise in rollbacks relative to hits can flag
|
|
85
|
+
* network or server trouble.
|
|
86
|
+
*/
|
|
87
|
+
drainOnRollback(transactionId) {
|
|
88
|
+
if (this.ids.delete(transactionId)) {
|
|
89
|
+
this._rollbacks += 1;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
getMetrics() {
|
|
93
|
+
return {
|
|
94
|
+
size: this.ids.size,
|
|
95
|
+
totalAdded: this._totalAdded,
|
|
96
|
+
hits: this._hits,
|
|
97
|
+
rollbacks: this._rollbacks,
|
|
98
|
+
evictions: this._evictions,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
clear() {
|
|
102
|
+
this.ids.clear();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { RuntimeContext } from '../../RuntimeContext.js';
|
|
2
|
+
import type { MutationQueueConfig } from './MutationQueue.js';
|
|
3
|
+
import type { MutationInput, QueuedMutation } from './commitPayload.js';
|
|
4
|
+
import type { MutationStore } from './MutationStore.js';
|
|
5
|
+
import type { OptimisticUpdateEntry } from './localMutation.js';
|
|
6
|
+
import type { StaleNotification } from '@abloatai/transaction/coordination/schema';
|
|
7
|
+
import type { MutationCommitResult } from '@abloatai/transaction/wire/commit';
|
|
8
|
+
import type { DurableCommitEnvelope } from '@abloatai/transaction/transactions/settlement/commitEnvelope';
|
|
9
|
+
export interface BatchProcessingContext {
|
|
10
|
+
readonly runtime: RuntimeContext;
|
|
11
|
+
readonly config: MutationQueueConfig;
|
|
12
|
+
readonly durableReplayBlock: object | null;
|
|
13
|
+
readonly executionQueue: QueuedMutation[];
|
|
14
|
+
readonly isProcessing: boolean;
|
|
15
|
+
readonly setIsProcessing: (value: boolean) => void;
|
|
16
|
+
readonly takeNextExecutionBatch: () => QueuedMutation[];
|
|
17
|
+
readonly ensureDerivedFields: (transaction: QueuedMutation) => void;
|
|
18
|
+
readonly ensureCommitEnvelope: (batch: QueuedMutation[]) => string;
|
|
19
|
+
readonly executingCount: number;
|
|
20
|
+
readonly setExecutingCount: (value: number) => void;
|
|
21
|
+
readonly inFlightByModel: Set<string>;
|
|
22
|
+
readonly pendingMergeByModel: Map<string, {
|
|
23
|
+
data: MutationInput;
|
|
24
|
+
sourceMutationIds: string[];
|
|
25
|
+
}>;
|
|
26
|
+
readonly generateId: () => string;
|
|
27
|
+
readonly computePriorityScore: (type: QueuedMutation['type'], modelName: string) => number;
|
|
28
|
+
readonly store: MutationStore;
|
|
29
|
+
readonly enqueue: (transaction: QueuedMutation) => void;
|
|
30
|
+
readonly optimisticUpdates: Map<string, OptimisticUpdateEntry>;
|
|
31
|
+
readonly commitNotifications: Map<string, StaleNotification[]>;
|
|
32
|
+
readonly commitMissingIds: Map<string, string[]>;
|
|
33
|
+
readonly sourceMutationIdsFor: (batch: readonly QueuedMutation[]) => string[];
|
|
34
|
+
readonly dispatchCommitBounded: (...args: Parameters<import('../../interfaces/index.js').MutationExecutor['commit']>) => ReturnType<import('../../interfaces/index.js').MutationExecutor['commit']>;
|
|
35
|
+
readonly parseMutationCommitResult: (value: Awaited<ReturnType<import('../../interfaces/index.js').MutationExecutor['commit']>>) => MutationCommitResult;
|
|
36
|
+
readonly persistDurableCommitAcceptance: (envelope: DurableCommitEnvelope, result: MutationCommitResult) => Promise<DurableCommitEnvelope>;
|
|
37
|
+
readonly removeDurableCommit: (idempotencyKey: string) => Promise<void>;
|
|
38
|
+
readonly assertEnvelopeInsideReplayWindow: (envelope: DurableCommitEnvelope) => void;
|
|
39
|
+
readonly sealDurableCommit: (input: Parameters<typeof import('./commitTransport.js').sealDurableCommit>[1]) => Promise<DurableCommitEnvelope>;
|
|
40
|
+
readonly noteAck: (syncId: number | undefined) => void;
|
|
41
|
+
readonly classifyReceiptNotifications: (operations: readonly {
|
|
42
|
+
model: string;
|
|
43
|
+
id: string;
|
|
44
|
+
}[], notifications: readonly StaleNotification[]) => {
|
|
45
|
+
holdsEntireBatch: boolean;
|
|
46
|
+
heldTargets: Set<string>;
|
|
47
|
+
notificationsByTarget: Map<string, StaleNotification[]>;
|
|
48
|
+
};
|
|
49
|
+
readonly receiptTargetKey: (modelName: string, modelId: string) => string;
|
|
50
|
+
readonly scheduleReplicationLagTimeout: (transactionId: string, clientTxId?: string, correlationId?: string) => void;
|
|
51
|
+
readonly scheduleDeltaConfirmationTimeout: (transaction: QueuedMutation, timeoutMs: number) => void;
|
|
52
|
+
readonly clearReplicationLagState: (transactionId: string) => void;
|
|
53
|
+
readonly completeQueuedCommit: (transaction: import('./commitLane.js').CommitTransaction, syncId: number) => void;
|
|
54
|
+
readonly queuedCommitMatchesCorrelation: (transaction: import('./commitLane.js').CommitTransaction, correlationId: string) => boolean;
|
|
55
|
+
readonly recentDeltaCorrelations: Map<string, number>;
|
|
56
|
+
readonly lastSeenSyncId: number;
|
|
57
|
+
readonly scheduleProcessing: (immediate?: boolean) => void;
|
|
58
|
+
readonly handleFailure: (transaction: QueuedMutation, error: Error) => Promise<void>;
|
|
59
|
+
readonly isDefinitiveRejection: (error: Error) => boolean;
|
|
60
|
+
readonly emitCommitLifecycle: (event: string, payload: object) => void;
|
|
61
|
+
readonly emit: (event: string, payload: object) => boolean;
|
|
62
|
+
readonly rollbackOptimistic: (transaction: QueuedMutation, reason: string, error?: Error) => Promise<void>;
|
|
63
|
+
}
|
|
64
|
+
export declare function processBatch(ctx: BatchProcessingContext): Promise<void>;
|