@abloatai/humans 0.56.0 → 0.58.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/dist/Ablo.d.ts +8 -18
- package/dist/client.d.ts +6 -19
- package/dist/core.d.ts +1 -1
- package/dist/core.js +1 -1
- package/dist/local/Database.d.ts +1 -1
- package/dist/local/Model.js +1 -1
- package/dist/local/SyncClient.d.ts +3 -34
- package/dist/local/SyncClient.js +6 -16
- package/dist/local/client/createInternalComponents.d.ts +1 -1
- package/dist/local/client/createInternalComponents.js +1 -1
- package/dist/local/client/{createModelProxy.d.ts → createModelOperations.d.ts} +22 -9
- package/dist/local/client/{createModelProxy.js → createModelOperations.js} +341 -335
- package/dist/local/client/options.d.ts +2 -2
- package/dist/local/client/reactiveEngine.js +38 -45
- package/dist/local/client/resourceTypes.d.ts +3 -3
- package/dist/local/client/resourceTypes.js +1 -1
- package/dist/local/client/wsMutationExecutor.d.ts +4 -4
- package/dist/local/client/wsMutationExecutor.js +4 -5
- package/dist/local/coordination/ClaimLog.d.ts +3 -3
- package/dist/local/coordination/ClaimLog.js +2 -2
- package/dist/local/interfaces/index.d.ts +5 -7
- package/dist/local/mutators/mutateActions.d.ts +3 -2
- package/dist/local/query/types.d.ts +2 -2
- package/dist/local/stores/syncAction.d.ts +1 -1
- package/dist/local/stores/syncAction.js +1 -1
- package/dist/local/sync/ConnectionManager.d.ts +1 -1
- package/dist/local/sync/ConnectionManager.js +1 -1
- package/dist/local/sync/OnDemandLoader.d.ts +1 -1
- package/dist/local/sync/OnDemandLoader.js +1 -1
- package/dist/local/sync/SyncWebSocket.d.ts +3 -3
- package/dist/local/sync/SyncWebSocket.js +2 -2
- package/dist/local/sync/commitFrames.d.ts +1 -1
- package/dist/local/sync/commitFrames.js +1 -1
- package/dist/local/sync/contextOnChange.d.ts +8 -0
- package/dist/local/sync/contextOnChange.js +65 -0
- package/dist/local/sync/createClaimStream.d.ts +1 -1
- package/dist/local/sync/createClaimStream.js +47 -28
- package/dist/local/sync/credentialLifecycle.d.ts +1 -1
- package/dist/local/sync/credentialLifecycle.js +1 -1
- package/dist/local/sync/participants.d.ts +1 -1
- package/dist/local/sync/schemas.d.ts +2 -2
- package/dist/local/sync/schemas.js +1 -1
- package/dist/local/sync/wsFrameHandlers.d.ts +1 -1
- package/dist/local/sync/wsFrameHandlers.js +1 -1
- package/dist/local/syncClientTypes.d.ts +41 -0
- package/dist/local/syncClientTypes.js +11 -0
- package/dist/local/transactions/databaseCommitOutbox.d.ts +2 -2
- package/dist/local/transactions/mutations/MutationQueue.d.ts +5 -18
- package/dist/local/transactions/mutations/MutationQueue.js +57 -137
- package/dist/local/transactions/mutations/batchProcessing.d.ts +2 -13
- package/dist/local/transactions/mutations/batchProcessing.js +0 -20
- package/dist/local/transactions/mutations/commitApi.d.ts +2 -3
- package/dist/local/transactions/mutations/commitApi.js +0 -4
- package/dist/local/transactions/mutations/commitLane.d.ts +6 -8
- package/dist/local/transactions/mutations/commitLane.js +12 -14
- package/dist/local/transactions/mutations/commitPayload.d.ts +2 -4
- package/dist/local/transactions/mutations/commitPayload.js +2 -6
- package/dist/local/transactions/mutations/commitTransport.d.ts +3 -4
- package/dist/local/transactions/mutations/commitTransport.js +2 -5
- package/dist/local/transactions/mutations/durableCommitRestore.d.ts +1 -1
- package/dist/local/transactions/mutations/durableCommitRestore.js +1 -4
- package/dist/local/transactions/mutations/durableWriteStore.d.ts +5 -5
- package/dist/local/transactions/mutations/durableWriteStore.js +3 -3
- package/dist/local/transactions/mutations/failurePolicy.d.ts +2 -2
- package/dist/local/transactions/mutations/mutationInput.d.ts +40 -0
- package/dist/local/transactions/mutations/mutationInput.js +53 -0
- package/dist/local/transactions/mutations/mutationPersistence.d.ts +1 -1
- package/dist/local/transactions/mutations/pendingDrain.d.ts +2 -2
- package/dist/local/transactions/mutations/replayValidation.d.ts +0 -20
- package/dist/local/transactions/mutations/replayValidation.js +1 -3
- package/dist/local/transactions/persistedTransaction.d.ts +0 -2
- package/dist/plugin.d.ts +2 -2
- package/dist/presenceStream.d.ts +1 -1
- package/dist/react/createAbloReact.d.ts +1 -1
- package/dist/react/useAblo.d.ts +2 -2
- package/dist/react/useAblo.js +1 -1
- package/dist/surface.d.ts +1 -1
- package/dist/surface.js +2 -2
- package/package.json +2 -2
- package/src/Ablo.ts +9 -27
- package/src/client.ts +6 -22
- package/src/core.ts +1 -1
- package/src/local/Database.ts +1 -2
- package/src/local/Model.ts +1 -1
- package/src/local/SyncClient.ts +17 -72
- package/src/local/client/createInternalComponents.ts +2 -2
- package/src/local/client/{createModelProxy.ts → createModelOperations.ts} +396 -320
- package/src/local/client/options.ts +2 -2
- package/src/local/client/reactiveEngine.ts +67 -55
- package/src/local/client/resourceTypes.ts +4 -4
- package/src/local/client/wsMutationExecutor.ts +4 -9
- package/src/local/coordination/ClaimLog.ts +3 -3
- package/src/local/interfaces/index.ts +5 -7
- package/src/local/mutators/mutateActions.ts +3 -2
- package/src/local/query/types.ts +2 -2
- package/src/local/stores/syncAction.ts +1 -1
- package/src/local/sync/ConnectionManager.ts +1 -1
- package/src/local/sync/OnDemandLoader.ts +1 -1
- package/src/local/sync/SyncWebSocket.ts +3 -3
- package/src/local/sync/commitFrames.ts +1 -2
- package/src/local/sync/contextOnChange.ts +92 -0
- package/src/local/sync/createClaimStream.ts +77 -39
- package/src/local/sync/credentialLifecycle.ts +1 -1
- package/src/local/sync/participants.ts +1 -1
- package/src/local/sync/schemas.ts +1 -1
- package/src/local/sync/wsFrameHandlers.ts +1 -1
- package/src/local/syncClientTypes.ts +59 -0
- package/src/local/transactions/databaseCommitOutbox.ts +2 -2
- package/src/local/transactions/mutations/MutationQueue.ts +69 -183
- package/src/local/transactions/mutations/batchProcessing.ts +2 -38
- package/src/local/transactions/mutations/commitApi.ts +3 -7
- package/src/local/transactions/mutations/commitLane.ts +24 -20
- package/src/local/transactions/mutations/commitPayload.ts +3 -11
- package/src/local/transactions/mutations/commitTransport.ts +3 -7
- package/src/local/transactions/mutations/durableCommitRestore.ts +2 -5
- package/src/local/transactions/mutations/durableWriteStore.ts +5 -5
- package/src/local/transactions/mutations/failurePolicy.ts +2 -2
- package/src/local/transactions/mutations/mutationInput.ts +69 -0
- package/src/local/transactions/mutations/mutationPersistence.ts +1 -1
- package/src/local/transactions/mutations/pendingDrain.ts +2 -2
- package/src/local/transactions/mutations/replayValidation.ts +1 -3
- package/src/local/transactions/persistedTransaction.ts +0 -3
- package/src/plugin.ts +2 -2
- package/src/presenceStream.ts +2 -2
- package/src/react/createAbloReact.ts +1 -1
- package/src/react/useAblo.ts +2 -2
- package/src/surface.ts +3 -3
- package/dist/local/sync/createSnapshot.d.ts +0 -29
- package/dist/local/sync/createSnapshot.js +0 -116
- package/src/local/sync/createSnapshot.ts +0 -160
package/src/local/Database.ts
CHANGED
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
* server. {@link BaseSyncedStore} drives it, and {@link InstanceCache} holds the
|
|
6
6
|
* in-memory mirror of what this class persists.
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
8
|
import { DatabaseManager, type DatabaseInfo, type WorkspaceMetadata } from './stores/DatabaseManager.js';
|
|
10
9
|
import type { PersistenceIdentity } from './stores/persistenceIdentity.js';
|
|
11
10
|
import { StoreManager } from './stores/StoreManager.js';
|
|
@@ -22,7 +21,7 @@ import {
|
|
|
22
21
|
import type { BootstrapFetcher, BootstrapData } from './sync/BootstrapFetcher.js';
|
|
23
22
|
import { InMemoryObjectStore } from './adapters/inMemoryStorage.js';
|
|
24
23
|
import { logPositionSnapshotSchema } from './logPosition.js';
|
|
25
|
-
import type { SyncDeltaAction } from '@abloatai/transaction/
|
|
24
|
+
import type { SyncDeltaAction } from '@abloatai/transaction/observation';
|
|
26
25
|
import type { BootstrapType } from '@abloatai/transaction/types';
|
|
27
26
|
import { highestPersistedPrefixSyncId } from './sync/persistedPrefix.js';
|
|
28
27
|
import {
|
package/src/local/Model.ts
CHANGED
|
@@ -1106,7 +1106,7 @@ export abstract class Model {
|
|
|
1106
1106
|
}
|
|
1107
1107
|
|
|
1108
1108
|
// Try to get model class by identifier
|
|
1109
|
-
|
|
1109
|
+
const ModelClass = getActiveRegistry().getModelByName(modelIdentifier);
|
|
1110
1110
|
|
|
1111
1111
|
if (!ModelClass) {
|
|
1112
1112
|
throw new AbloValidationError(
|
package/src/local/SyncClient.ts
CHANGED
|
@@ -34,85 +34,25 @@ import {
|
|
|
34
34
|
type UnconfirmedWritesMetrics,
|
|
35
35
|
} from './transactions/mutations/UnconfirmedWrites.js';
|
|
36
36
|
import type { DurableWriteStore } from './transactions/mutations/durableWriteStore.js';
|
|
37
|
-
import type { CommitTransaction } from './transactions/mutations/commitLane.js';
|
|
38
37
|
import type { Database } from './Database.js';
|
|
39
|
-
import type { BootstrapData } from './sync/BootstrapFetcher.js';
|
|
40
38
|
import type { MutationPersistencePort } from './mutationPersistence.js';
|
|
41
39
|
import type { WriteOptions } from './interfaces/index.js';
|
|
42
40
|
import { LogPosition } from './logPosition.js';
|
|
43
41
|
import { createLocalMutationPort } from './transactions/localMutation.js';
|
|
44
42
|
import { createReconnectDrain } from './transactions/reconnectDrain.js';
|
|
45
43
|
import { DatabaseCommitOutboxStore } from './transactions/databaseCommitOutbox.js';
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
type
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
interface SyncState {
|
|
60
|
-
connectionState: 'connected' | 'disconnected' | 'connecting';
|
|
61
|
-
pendingMutations: number;
|
|
62
|
-
lastSyncAt?: Date;
|
|
63
|
-
error?: Error;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export interface RehydrationStats {
|
|
67
|
-
added: number;
|
|
68
|
-
updated: number;
|
|
69
|
-
removed: number;
|
|
70
|
-
skipped: number;
|
|
71
|
-
healed: number;
|
|
72
|
-
elapsedMs: number;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
type EventHandler = () => void;
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* The slice of a bootstrap answer the pool applies: its rows, the models whose
|
|
79
|
-
* server query failed, and the log position the snapshot was taken at — the
|
|
80
|
-
* position every row in it reflects. `lastSyncId` is optional only for callers
|
|
81
|
-
* applying rows with no snapshot position to speak of; the fetcher always
|
|
82
|
-
* names one.
|
|
83
|
-
*/
|
|
84
|
-
export type BootstrapSnapshot = Pick<BootstrapData, 'models' | 'failedModels'> &
|
|
85
|
-
Partial<Pick<BootstrapData, 'lastSyncId'>>;
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* What `transaction:completed` carries: a model mutation (one row, confirmed
|
|
89
|
-
* at `syncIdNeededForCompletion`) or an explicit commit (one row per operation,
|
|
90
|
-
* confirmed at `lastSyncId`). Each arm projects its own queue record.
|
|
91
|
-
*/
|
|
92
|
-
type CompletedTransaction =
|
|
93
|
-
| (Pick<QueuedMutation, 'id' | 'modelId' | 'syncIdNeededForCompletion'> & {
|
|
94
|
-
lastSyncId?: undefined;
|
|
95
|
-
operations?: undefined;
|
|
96
|
-
})
|
|
97
|
-
| (Pick<CommitTransaction, 'id' | 'lastSyncId' | 'operations'> & {
|
|
98
|
-
modelId?: undefined;
|
|
99
|
-
syncIdNeededForCompletion?: undefined;
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Converts an untyped server `updatedAt` value — an ISO string, epoch number,
|
|
104
|
-
* or Date read off an untyped row — into epoch milliseconds for
|
|
105
|
-
* last-write-wins comparison. Falsy or non-date values become 0, matching the
|
|
106
|
-
* conflict resolver's rule that a missing timestamp sorts as the epoch.
|
|
107
|
-
*/
|
|
108
|
-
function toEpochMs(value: unknown): number {
|
|
109
|
-
if (!value) return 0;
|
|
110
|
-
if (value instanceof Date) return value.getTime();
|
|
111
|
-
if (typeof value === 'string' || typeof value === 'number') {
|
|
112
|
-
return new Date(value).getTime();
|
|
113
|
-
}
|
|
114
|
-
return 0;
|
|
115
|
-
}
|
|
44
|
+
import {
|
|
45
|
+
toEpochMs,
|
|
46
|
+
type CompletedTransaction,
|
|
47
|
+
type EventHandler,
|
|
48
|
+
type RehydrationStats,
|
|
49
|
+
type SyncEvent,
|
|
50
|
+
type SyncObserver,
|
|
51
|
+
type SyncState,
|
|
52
|
+
} from './syncClientTypes.js';
|
|
53
|
+
import type { BootstrapSnapshot } from './syncClientTypes.js';
|
|
54
|
+
|
|
55
|
+
export type { BootstrapSnapshot, RehydrationStats } from './syncClientTypes.js';
|
|
116
56
|
|
|
117
57
|
export class SyncClient extends EventEmitter {
|
|
118
58
|
private objectPool: InstanceCache;
|
|
@@ -1549,6 +1489,11 @@ export class SyncClient extends EventEmitter {
|
|
|
1549
1489
|
dispose(): void {
|
|
1550
1490
|
this.isDisposed = true;
|
|
1551
1491
|
this.disconnect();
|
|
1492
|
+
// The queue owns commit retry, replication-lag, offline-grace, and
|
|
1493
|
+
// per-mutation timers. A disposed client must release those resources too;
|
|
1494
|
+
// otherwise an atomic commit can keep a worker process alive after the
|
|
1495
|
+
// public client has been disposed.
|
|
1496
|
+
this.mutationQueue.dispose();
|
|
1552
1497
|
this.networkMonitor.dispose();
|
|
1553
1498
|
this.observers.clear();
|
|
1554
1499
|
this.pendingStages.clear();
|
|
@@ -25,10 +25,10 @@ import {
|
|
|
25
25
|
import type {
|
|
26
26
|
DurableWriteStore,
|
|
27
27
|
DurableWritesConfig,
|
|
28
|
-
} from '@abloatai/transaction/
|
|
28
|
+
} from '@abloatai/transaction/commit';
|
|
29
29
|
import type { RuntimeContext } from '../RuntimeContext.js';
|
|
30
30
|
import { globalRuntime } from '../context.js';
|
|
31
|
-
import { resolveDurableWrites } from '@abloatai/transaction/
|
|
31
|
+
import { resolveDurableWrites } from '@abloatai/transaction/commit';
|
|
32
32
|
|
|
33
33
|
export interface InternalComponentsInput<S extends SchemaRecord> {
|
|
34
34
|
readonly schema: Schema<S>;
|