@affectively/aeon 1.3.1 → 5.0.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/LICENSE +15 -21
- package/README.md +422 -342
- package/dist/compression/index.cjs +20 -3
- package/dist/compression/index.cjs.map +1 -1
- package/dist/compression/index.js +20 -3
- package/dist/compression/index.js.map +1 -1
- package/dist/crypto/index.cjs +30 -0
- package/dist/crypto/index.cjs.map +1 -1
- package/dist/crypto/index.js +29 -1
- package/dist/crypto/index.js.map +1 -1
- package/dist/distributed/index.cjs +15 -8
- package/dist/distributed/index.cjs.map +1 -1
- package/dist/distributed/index.js +15 -8
- package/dist/distributed/index.js.map +1 -1
- package/dist/index.cjs +6686 -3118
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6642 -3117
- package/dist/index.js.map +1 -1
- package/dist/offline/index.cjs.map +1 -1
- package/dist/offline/index.js.map +1 -1
- package/dist/optimization/index.cjs +6 -3
- package/dist/optimization/index.cjs.map +1 -1
- package/dist/optimization/index.js +6 -3
- package/dist/optimization/index.js.map +1 -1
- package/dist/persistence/index.cjs +91 -29
- package/dist/persistence/index.cjs.map +1 -1
- package/dist/persistence/index.js +91 -29
- package/dist/persistence/index.js.map +1 -1
- package/dist/presence/index.cjs.map +1 -1
- package/dist/presence/index.js.map +1 -1
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/versioning/index.cjs +4 -3
- package/dist/versioning/index.cjs.map +1 -1
- package/dist/versioning/index.js +4 -3
- package/dist/versioning/index.js.map +1 -1
- package/package.json +195 -196
- package/dist/compression/index.d.cts +0 -189
- package/dist/compression/index.d.ts +0 -189
- package/dist/core/index.d.cts +0 -216
- package/dist/core/index.d.ts +0 -216
- package/dist/crypto/index.d.cts +0 -446
- package/dist/crypto/index.d.ts +0 -446
- package/dist/distributed/index.d.cts +0 -1016
- package/dist/distributed/index.d.ts +0 -1016
- package/dist/index.d.cts +0 -57
- package/dist/index.d.ts +0 -57
- package/dist/offline/index.d.cts +0 -154
- package/dist/offline/index.d.ts +0 -154
- package/dist/optimization/index.d.cts +0 -347
- package/dist/optimization/index.d.ts +0 -347
- package/dist/persistence/index.d.cts +0 -63
- package/dist/persistence/index.d.ts +0 -63
- package/dist/presence/index.d.cts +0 -283
- package/dist/presence/index.d.ts +0 -283
- package/dist/types-B7CxsoLh.d.cts +0 -33
- package/dist/types-B7CxsoLh.d.ts +0 -33
- package/dist/utils/index.d.cts +0 -38
- package/dist/utils/index.d.ts +0 -38
- package/dist/versioning/index.d.cts +0 -537
- package/dist/versioning/index.d.ts +0 -537
package/dist/index.d.cts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
export { BandwidthProfile, CRDTOperation, ConflictDetectionResult, EventCallback, EventUnsubscribe, IEventEmitter, NetworkState, Operation, OperationPriority, OperationStatus, OperationType, PresenceEmotion, PresenceInfo, PresenceInputState, PresenceScroll, PresenceSelection, PresenceTyping, PresenceViewport, ResolutionStrategy, SyncBatch, SyncCoordinatorConfig, SyncResult, VectorClock } from './core/index.cjs';
|
|
2
|
-
export { Logger, createNamespacedLogger, disableLogging, getLogger, logger, resetLogger, setLogger } from './utils/index.cjs';
|
|
3
|
-
export { DashStorageAdapter, DashStorageAdapterOptions, DashStorageBackend, DashStorageChange, DashSyncClient, InMemoryStorageAdapter } from './persistence/index.cjs';
|
|
4
|
-
export { P as PersistedEnvelope, a as PersistenceDeserializer, b as PersistenceSerializer, S as StorageAdapter } from './types-B7CxsoLh.cjs';
|
|
5
|
-
export { CompatibilityRule, DataTransformer, FieldTransformer, Migration, MigrationEngine, MigrationIntegrityEntry, MigrationRecord, MigrationResult, MigrationState, MigrationTracker, MigrationTrackerOptions, MigrationTrackerPersistenceConfig, MigrationTrackerPersistenceData, RollbackPath, SchemaVersion, TransformationResult, TransformationRule, VersionMetadata } from './versioning/index.cjs';
|
|
6
|
-
export { Handshake, MergeStrategy, ProtocolError, ReconciliationResult, Replica, ReplicationEvent, ReplicationManager, ReplicationManagerOptions, ReplicationPersistenceConfig, ReplicationPersistenceData, ReplicationPolicy, StateDiff, StateReconciler, StateVersion, SyncEvent, SyncMessage, SyncNode, SyncProtocol, SyncProtocolOptions, SyncProtocolPersistenceConfig, SyncProtocolPersistenceData, SyncRequest, SyncResponse, SyncSession } from './distributed/index.cjs';
|
|
7
|
-
export { OfflineOperation, OfflineOperationQueue, OfflineOperationQueueOptions, OfflineQueueEvents, OfflineQueuePersistenceConfig, OfflineQueueStats, getOfflineOperationQueue, resetOfflineOperationQueue } from './offline/index.cjs';
|
|
8
|
-
export { CompressedBatch, CompressedChunk, CompressionEngine, CompressionStats, DeltaBatch, DeltaOperation, DeltaStats, DeltaSyncOptimizer, getCompressionEngine, getDeltaSyncOptimizer, resetCompressionEngine, resetDeltaSyncOptimizer } from './compression/index.cjs';
|
|
9
|
-
export { ActivityPattern, AdaptiveCompressionOptimizer, AdaptiveStats, BatchTimingOptimizer, BatchTimingStats, CompressionRecommendation, DeviceProfile, NetworkProfile, NetworkWindow, OperationPattern, OperationPrediction, PrefetchedBatch, PrefetchingEngine, PrefetchingStats, SchedulingDecision, getBatchTimingOptimizer, getPrefetchingEngine, resetAdaptiveCompressionOptimizer, resetBatchTimingOptimizer, resetPrefetchingEngine } from './optimization/index.cjs';
|
|
10
|
-
export { AgentEmotionState, AgentInputState, AgentPresence, AgentPresenceManager, AgentScrollState, AgentSelectionRange, AgentTypingState, AgentViewportState, PresenceEvents, PresenceUpdate, clearAgentPresenceManager } from './presence/index.cjs';
|
|
11
|
-
export { AEON_CAPABILITIES, AeonCapability, AeonCapabilityResult, AeonCryptoConfig, AeonEncryptionMode, AuthenticatedMessageFields, Capability, DEFAULT_CRYPTO_CONFIG, DID, DecryptionResult, DomainCategory, ECKeyPair, EncryptedPayload, EncryptionAlgorithm, ICryptoProvider, Identity, KeyPair, NullCryptoProvider, SecureNodeInfo, SecureSyncSession, SignedSyncData, SigningAlgorithm, UCANPayload, UCANToken, VerificationResult } from './crypto/index.cjs';
|
|
12
|
-
import 'eventemitter3';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Aeon - Distributed Synchronization & Versioning Library
|
|
16
|
-
*
|
|
17
|
-
* A comprehensive library for building distributed, collaborative applications
|
|
18
|
-
* with real-time synchronization, schema versioning, and conflict resolution.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```typescript
|
|
22
|
-
* import { SyncCoordinator, SchemaVersionManager } from '@affectively/aeon';
|
|
23
|
-
*
|
|
24
|
-
* // Create a sync coordinator
|
|
25
|
-
* const coordinator = new SyncCoordinator();
|
|
26
|
-
*
|
|
27
|
-
* // Register a node
|
|
28
|
-
* coordinator.registerNode({
|
|
29
|
-
* id: 'node-1',
|
|
30
|
-
* address: 'localhost',
|
|
31
|
-
* port: 3000,
|
|
32
|
-
* status: 'online',
|
|
33
|
-
* lastHeartbeat: new Date().toISOString(),
|
|
34
|
-
* version: '1.0.0',
|
|
35
|
-
* capabilities: ['sync', 'replicate'],
|
|
36
|
-
* });
|
|
37
|
-
*
|
|
38
|
-
* // Create a sync session
|
|
39
|
-
* const session = coordinator.createSyncSession('node-1', ['node-2', 'node-3']);
|
|
40
|
-
* ```
|
|
41
|
-
*
|
|
42
|
-
* @packageDocumentation
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* STUBS for React components and hooks
|
|
47
|
-
* These are normally provided by @affectively/aeon-flux-react but are
|
|
48
|
-
* imported from @affectively/aeon in many legacy parts of edge-web-app.
|
|
49
|
-
*/
|
|
50
|
-
declare const Link: any;
|
|
51
|
-
declare const useAeonPage: any;
|
|
52
|
-
declare const getAdaptiveCompressionOptimizer: any;
|
|
53
|
-
declare const SchemaVersionManager: any;
|
|
54
|
-
declare const getAgentPresenceManager: any;
|
|
55
|
-
declare const SyncCoordinator: any;
|
|
56
|
-
|
|
57
|
-
export { Link, SchemaVersionManager, SyncCoordinator, getAdaptiveCompressionOptimizer, getAgentPresenceManager, useAeonPage };
|
package/dist/index.d.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
export { BandwidthProfile, CRDTOperation, ConflictDetectionResult, EventCallback, EventUnsubscribe, IEventEmitter, NetworkState, Operation, OperationPriority, OperationStatus, OperationType, PresenceEmotion, PresenceInfo, PresenceInputState, PresenceScroll, PresenceSelection, PresenceTyping, PresenceViewport, ResolutionStrategy, SyncBatch, SyncCoordinatorConfig, SyncResult, VectorClock } from './core/index.js';
|
|
2
|
-
export { Logger, createNamespacedLogger, disableLogging, getLogger, logger, resetLogger, setLogger } from './utils/index.js';
|
|
3
|
-
export { DashStorageAdapter, DashStorageAdapterOptions, DashStorageBackend, DashStorageChange, DashSyncClient, InMemoryStorageAdapter } from './persistence/index.js';
|
|
4
|
-
export { P as PersistedEnvelope, a as PersistenceDeserializer, b as PersistenceSerializer, S as StorageAdapter } from './types-B7CxsoLh.js';
|
|
5
|
-
export { CompatibilityRule, DataTransformer, FieldTransformer, Migration, MigrationEngine, MigrationIntegrityEntry, MigrationRecord, MigrationResult, MigrationState, MigrationTracker, MigrationTrackerOptions, MigrationTrackerPersistenceConfig, MigrationTrackerPersistenceData, RollbackPath, SchemaVersion, TransformationResult, TransformationRule, VersionMetadata } from './versioning/index.js';
|
|
6
|
-
export { Handshake, MergeStrategy, ProtocolError, ReconciliationResult, Replica, ReplicationEvent, ReplicationManager, ReplicationManagerOptions, ReplicationPersistenceConfig, ReplicationPersistenceData, ReplicationPolicy, StateDiff, StateReconciler, StateVersion, SyncEvent, SyncMessage, SyncNode, SyncProtocol, SyncProtocolOptions, SyncProtocolPersistenceConfig, SyncProtocolPersistenceData, SyncRequest, SyncResponse, SyncSession } from './distributed/index.js';
|
|
7
|
-
export { OfflineOperation, OfflineOperationQueue, OfflineOperationQueueOptions, OfflineQueueEvents, OfflineQueuePersistenceConfig, OfflineQueueStats, getOfflineOperationQueue, resetOfflineOperationQueue } from './offline/index.js';
|
|
8
|
-
export { CompressedBatch, CompressedChunk, CompressionEngine, CompressionStats, DeltaBatch, DeltaOperation, DeltaStats, DeltaSyncOptimizer, getCompressionEngine, getDeltaSyncOptimizer, resetCompressionEngine, resetDeltaSyncOptimizer } from './compression/index.js';
|
|
9
|
-
export { ActivityPattern, AdaptiveCompressionOptimizer, AdaptiveStats, BatchTimingOptimizer, BatchTimingStats, CompressionRecommendation, DeviceProfile, NetworkProfile, NetworkWindow, OperationPattern, OperationPrediction, PrefetchedBatch, PrefetchingEngine, PrefetchingStats, SchedulingDecision, getBatchTimingOptimizer, getPrefetchingEngine, resetAdaptiveCompressionOptimizer, resetBatchTimingOptimizer, resetPrefetchingEngine } from './optimization/index.js';
|
|
10
|
-
export { AgentEmotionState, AgentInputState, AgentPresence, AgentPresenceManager, AgentScrollState, AgentSelectionRange, AgentTypingState, AgentViewportState, PresenceEvents, PresenceUpdate, clearAgentPresenceManager } from './presence/index.js';
|
|
11
|
-
export { AEON_CAPABILITIES, AeonCapability, AeonCapabilityResult, AeonCryptoConfig, AeonEncryptionMode, AuthenticatedMessageFields, Capability, DEFAULT_CRYPTO_CONFIG, DID, DecryptionResult, DomainCategory, ECKeyPair, EncryptedPayload, EncryptionAlgorithm, ICryptoProvider, Identity, KeyPair, NullCryptoProvider, SecureNodeInfo, SecureSyncSession, SignedSyncData, SigningAlgorithm, UCANPayload, UCANToken, VerificationResult } from './crypto/index.js';
|
|
12
|
-
import 'eventemitter3';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Aeon - Distributed Synchronization & Versioning Library
|
|
16
|
-
*
|
|
17
|
-
* A comprehensive library for building distributed, collaborative applications
|
|
18
|
-
* with real-time synchronization, schema versioning, and conflict resolution.
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```typescript
|
|
22
|
-
* import { SyncCoordinator, SchemaVersionManager } from '@affectively/aeon';
|
|
23
|
-
*
|
|
24
|
-
* // Create a sync coordinator
|
|
25
|
-
* const coordinator = new SyncCoordinator();
|
|
26
|
-
*
|
|
27
|
-
* // Register a node
|
|
28
|
-
* coordinator.registerNode({
|
|
29
|
-
* id: 'node-1',
|
|
30
|
-
* address: 'localhost',
|
|
31
|
-
* port: 3000,
|
|
32
|
-
* status: 'online',
|
|
33
|
-
* lastHeartbeat: new Date().toISOString(),
|
|
34
|
-
* version: '1.0.0',
|
|
35
|
-
* capabilities: ['sync', 'replicate'],
|
|
36
|
-
* });
|
|
37
|
-
*
|
|
38
|
-
* // Create a sync session
|
|
39
|
-
* const session = coordinator.createSyncSession('node-1', ['node-2', 'node-3']);
|
|
40
|
-
* ```
|
|
41
|
-
*
|
|
42
|
-
* @packageDocumentation
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* STUBS for React components and hooks
|
|
47
|
-
* These are normally provided by @affectively/aeon-flux-react but are
|
|
48
|
-
* imported from @affectively/aeon in many legacy parts of edge-web-app.
|
|
49
|
-
*/
|
|
50
|
-
declare const Link: any;
|
|
51
|
-
declare const useAeonPage: any;
|
|
52
|
-
declare const getAdaptiveCompressionOptimizer: any;
|
|
53
|
-
declare const SchemaVersionManager: any;
|
|
54
|
-
declare const getAgentPresenceManager: any;
|
|
55
|
-
declare const SyncCoordinator: any;
|
|
56
|
-
|
|
57
|
-
export { Link, SchemaVersionManager, SyncCoordinator, getAdaptiveCompressionOptimizer, getAgentPresenceManager, useAeonPage };
|
package/dist/offline/index.d.cts
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from 'eventemitter3';
|
|
2
|
-
import { Operation, OperationPriority } from '../core/index.cjs';
|
|
3
|
-
import { S as StorageAdapter, b as PersistenceSerializer, a as PersistenceDeserializer } from '../types-B7CxsoLh.cjs';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Offline Operation Queue (Phase 11)
|
|
7
|
-
*
|
|
8
|
-
* Manages pending operations for offline-first clients.
|
|
9
|
-
* Provides priority-based queuing, persistence, and retry logic.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
interface OfflineOperation {
|
|
13
|
-
id: string;
|
|
14
|
-
type: Operation['type'];
|
|
15
|
-
data: Record<string, unknown>;
|
|
16
|
-
sessionId: string;
|
|
17
|
-
priority: OperationPriority;
|
|
18
|
-
createdAt: number;
|
|
19
|
-
retryCount: number;
|
|
20
|
-
maxRetries: number;
|
|
21
|
-
lastError?: string;
|
|
22
|
-
status: 'pending' | 'syncing' | 'failed' | 'synced';
|
|
23
|
-
}
|
|
24
|
-
interface OfflineQueueStats {
|
|
25
|
-
pending: number;
|
|
26
|
-
syncing: number;
|
|
27
|
-
failed: number;
|
|
28
|
-
synced: number;
|
|
29
|
-
totalOperations: number;
|
|
30
|
-
oldestPendingMs: number;
|
|
31
|
-
averageRetries: number;
|
|
32
|
-
}
|
|
33
|
-
interface OfflineQueueEvents {
|
|
34
|
-
'operation-added': (operation: OfflineOperation) => void;
|
|
35
|
-
'operation-synced': (operation: OfflineOperation) => void;
|
|
36
|
-
'operation-failed': (operation: OfflineOperation, error: Error) => void;
|
|
37
|
-
'queue-empty': () => void;
|
|
38
|
-
'sync-started': () => void;
|
|
39
|
-
'sync-completed': (stats: { synced: number; failed: number }) => void;
|
|
40
|
-
}
|
|
41
|
-
interface OfflineQueuePersistenceConfig {
|
|
42
|
-
adapter: StorageAdapter;
|
|
43
|
-
key?: string;
|
|
44
|
-
autoPersist?: boolean;
|
|
45
|
-
autoLoad?: boolean;
|
|
46
|
-
persistDebounceMs?: number;
|
|
47
|
-
serializer?: PersistenceSerializer<OfflineOperation[]>;
|
|
48
|
-
deserializer?: PersistenceDeserializer<OfflineOperation[]>;
|
|
49
|
-
}
|
|
50
|
-
interface OfflineOperationQueueOptions {
|
|
51
|
-
maxQueueSize?: number;
|
|
52
|
-
defaultMaxRetries?: number;
|
|
53
|
-
persistence?: OfflineQueuePersistenceConfig;
|
|
54
|
-
}
|
|
55
|
-
declare class OfflineOperationQueue extends EventEmitter<OfflineQueueEvents> {
|
|
56
|
-
private static readonly DEFAULT_PERSIST_KEY;
|
|
57
|
-
private queue;
|
|
58
|
-
private syncingIds;
|
|
59
|
-
private maxQueueSize;
|
|
60
|
-
private defaultMaxRetries;
|
|
61
|
-
private persistence;
|
|
62
|
-
private persistTimer;
|
|
63
|
-
private persistInFlight;
|
|
64
|
-
private persistPending;
|
|
65
|
-
constructor(
|
|
66
|
-
maxQueueSizeOrOptions?: number | OfflineOperationQueueOptions,
|
|
67
|
-
defaultMaxRetries?: number
|
|
68
|
-
);
|
|
69
|
-
/**
|
|
70
|
-
* Add operation to the queue
|
|
71
|
-
*/
|
|
72
|
-
enqueue(
|
|
73
|
-
type: Operation['type'],
|
|
74
|
-
data: Record<string, unknown>,
|
|
75
|
-
sessionId: string,
|
|
76
|
-
priority?: OperationPriority,
|
|
77
|
-
maxRetries?: number
|
|
78
|
-
): OfflineOperation;
|
|
79
|
-
/**
|
|
80
|
-
* Get next operations to sync (by priority)
|
|
81
|
-
*/
|
|
82
|
-
getNextBatch(batchSize?: number): OfflineOperation[];
|
|
83
|
-
/**
|
|
84
|
-
* Mark operations as syncing
|
|
85
|
-
*/
|
|
86
|
-
markSyncing(operationIds: string[]): void;
|
|
87
|
-
/**
|
|
88
|
-
* Mark operation as synced
|
|
89
|
-
*/
|
|
90
|
-
markSynced(operationId: string): void;
|
|
91
|
-
/**
|
|
92
|
-
* Mark operation as failed
|
|
93
|
-
*/
|
|
94
|
-
markFailed(operationId: string, error: Error): void;
|
|
95
|
-
/**
|
|
96
|
-
* Get operation by ID
|
|
97
|
-
*/
|
|
98
|
-
getOperation(operationId: string): OfflineOperation | undefined;
|
|
99
|
-
/**
|
|
100
|
-
* Get all pending operations
|
|
101
|
-
*/
|
|
102
|
-
getPendingOperations(): OfflineOperation[];
|
|
103
|
-
/**
|
|
104
|
-
* Get pending count
|
|
105
|
-
*/
|
|
106
|
-
getPendingCount(): number;
|
|
107
|
-
/**
|
|
108
|
-
* Get queue statistics
|
|
109
|
-
*/
|
|
110
|
-
getStats(): OfflineQueueStats;
|
|
111
|
-
/**
|
|
112
|
-
* Clear all operations
|
|
113
|
-
*/
|
|
114
|
-
clear(): void;
|
|
115
|
-
/**
|
|
116
|
-
* Clear failed operations
|
|
117
|
-
*/
|
|
118
|
-
clearFailed(): void;
|
|
119
|
-
/**
|
|
120
|
-
* Retry failed operations
|
|
121
|
-
*/
|
|
122
|
-
retryFailed(): void;
|
|
123
|
-
/**
|
|
124
|
-
* Find oldest low-priority operation
|
|
125
|
-
*/
|
|
126
|
-
private findOldestLowPriority;
|
|
127
|
-
/**
|
|
128
|
-
* Export queue for persistence
|
|
129
|
-
*/
|
|
130
|
-
export(): OfflineOperation[];
|
|
131
|
-
/**
|
|
132
|
-
* Import queue from persistence
|
|
133
|
-
*/
|
|
134
|
-
import(operations: OfflineOperation[]): void;
|
|
135
|
-
/**
|
|
136
|
-
* Persist current queue snapshot.
|
|
137
|
-
*/
|
|
138
|
-
saveToPersistence(): Promise<void>;
|
|
139
|
-
/**
|
|
140
|
-
* Load queue snapshot from persistence.
|
|
141
|
-
*/
|
|
142
|
-
loadFromPersistence(): Promise<number>;
|
|
143
|
-
/**
|
|
144
|
-
* Remove persisted queue snapshot.
|
|
145
|
-
*/
|
|
146
|
-
clearPersistence(): Promise<void>;
|
|
147
|
-
private schedulePersist;
|
|
148
|
-
private persistSafely;
|
|
149
|
-
private isValidOfflineOperation;
|
|
150
|
-
}
|
|
151
|
-
declare function getOfflineOperationQueue(): OfflineOperationQueue;
|
|
152
|
-
declare function resetOfflineOperationQueue(): void;
|
|
153
|
-
|
|
154
|
-
export { type OfflineOperation, OfflineOperationQueue, type OfflineOperationQueueOptions, type OfflineQueueEvents, type OfflineQueuePersistenceConfig, type OfflineQueueStats, OperationPriority, getOfflineOperationQueue, resetOfflineOperationQueue };
|
package/dist/offline/index.d.ts
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from 'eventemitter3';
|
|
2
|
-
import { Operation, OperationPriority } from '../core/index.js';
|
|
3
|
-
import { S as StorageAdapter, b as PersistenceSerializer, a as PersistenceDeserializer } from '../types-B7CxsoLh.js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Offline Operation Queue (Phase 11)
|
|
7
|
-
*
|
|
8
|
-
* Manages pending operations for offline-first clients.
|
|
9
|
-
* Provides priority-based queuing, persistence, and retry logic.
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
interface OfflineOperation {
|
|
13
|
-
id: string;
|
|
14
|
-
type: Operation['type'];
|
|
15
|
-
data: Record<string, unknown>;
|
|
16
|
-
sessionId: string;
|
|
17
|
-
priority: OperationPriority;
|
|
18
|
-
createdAt: number;
|
|
19
|
-
retryCount: number;
|
|
20
|
-
maxRetries: number;
|
|
21
|
-
lastError?: string;
|
|
22
|
-
status: 'pending' | 'syncing' | 'failed' | 'synced';
|
|
23
|
-
}
|
|
24
|
-
interface OfflineQueueStats {
|
|
25
|
-
pending: number;
|
|
26
|
-
syncing: number;
|
|
27
|
-
failed: number;
|
|
28
|
-
synced: number;
|
|
29
|
-
totalOperations: number;
|
|
30
|
-
oldestPendingMs: number;
|
|
31
|
-
averageRetries: number;
|
|
32
|
-
}
|
|
33
|
-
interface OfflineQueueEvents {
|
|
34
|
-
'operation-added': (operation: OfflineOperation) => void;
|
|
35
|
-
'operation-synced': (operation: OfflineOperation) => void;
|
|
36
|
-
'operation-failed': (operation: OfflineOperation, error: Error) => void;
|
|
37
|
-
'queue-empty': () => void;
|
|
38
|
-
'sync-started': () => void;
|
|
39
|
-
'sync-completed': (stats: { synced: number; failed: number }) => void;
|
|
40
|
-
}
|
|
41
|
-
interface OfflineQueuePersistenceConfig {
|
|
42
|
-
adapter: StorageAdapter;
|
|
43
|
-
key?: string;
|
|
44
|
-
autoPersist?: boolean;
|
|
45
|
-
autoLoad?: boolean;
|
|
46
|
-
persistDebounceMs?: number;
|
|
47
|
-
serializer?: PersistenceSerializer<OfflineOperation[]>;
|
|
48
|
-
deserializer?: PersistenceDeserializer<OfflineOperation[]>;
|
|
49
|
-
}
|
|
50
|
-
interface OfflineOperationQueueOptions {
|
|
51
|
-
maxQueueSize?: number;
|
|
52
|
-
defaultMaxRetries?: number;
|
|
53
|
-
persistence?: OfflineQueuePersistenceConfig;
|
|
54
|
-
}
|
|
55
|
-
declare class OfflineOperationQueue extends EventEmitter<OfflineQueueEvents> {
|
|
56
|
-
private static readonly DEFAULT_PERSIST_KEY;
|
|
57
|
-
private queue;
|
|
58
|
-
private syncingIds;
|
|
59
|
-
private maxQueueSize;
|
|
60
|
-
private defaultMaxRetries;
|
|
61
|
-
private persistence;
|
|
62
|
-
private persistTimer;
|
|
63
|
-
private persistInFlight;
|
|
64
|
-
private persistPending;
|
|
65
|
-
constructor(
|
|
66
|
-
maxQueueSizeOrOptions?: number | OfflineOperationQueueOptions,
|
|
67
|
-
defaultMaxRetries?: number
|
|
68
|
-
);
|
|
69
|
-
/**
|
|
70
|
-
* Add operation to the queue
|
|
71
|
-
*/
|
|
72
|
-
enqueue(
|
|
73
|
-
type: Operation['type'],
|
|
74
|
-
data: Record<string, unknown>,
|
|
75
|
-
sessionId: string,
|
|
76
|
-
priority?: OperationPriority,
|
|
77
|
-
maxRetries?: number
|
|
78
|
-
): OfflineOperation;
|
|
79
|
-
/**
|
|
80
|
-
* Get next operations to sync (by priority)
|
|
81
|
-
*/
|
|
82
|
-
getNextBatch(batchSize?: number): OfflineOperation[];
|
|
83
|
-
/**
|
|
84
|
-
* Mark operations as syncing
|
|
85
|
-
*/
|
|
86
|
-
markSyncing(operationIds: string[]): void;
|
|
87
|
-
/**
|
|
88
|
-
* Mark operation as synced
|
|
89
|
-
*/
|
|
90
|
-
markSynced(operationId: string): void;
|
|
91
|
-
/**
|
|
92
|
-
* Mark operation as failed
|
|
93
|
-
*/
|
|
94
|
-
markFailed(operationId: string, error: Error): void;
|
|
95
|
-
/**
|
|
96
|
-
* Get operation by ID
|
|
97
|
-
*/
|
|
98
|
-
getOperation(operationId: string): OfflineOperation | undefined;
|
|
99
|
-
/**
|
|
100
|
-
* Get all pending operations
|
|
101
|
-
*/
|
|
102
|
-
getPendingOperations(): OfflineOperation[];
|
|
103
|
-
/**
|
|
104
|
-
* Get pending count
|
|
105
|
-
*/
|
|
106
|
-
getPendingCount(): number;
|
|
107
|
-
/**
|
|
108
|
-
* Get queue statistics
|
|
109
|
-
*/
|
|
110
|
-
getStats(): OfflineQueueStats;
|
|
111
|
-
/**
|
|
112
|
-
* Clear all operations
|
|
113
|
-
*/
|
|
114
|
-
clear(): void;
|
|
115
|
-
/**
|
|
116
|
-
* Clear failed operations
|
|
117
|
-
*/
|
|
118
|
-
clearFailed(): void;
|
|
119
|
-
/**
|
|
120
|
-
* Retry failed operations
|
|
121
|
-
*/
|
|
122
|
-
retryFailed(): void;
|
|
123
|
-
/**
|
|
124
|
-
* Find oldest low-priority operation
|
|
125
|
-
*/
|
|
126
|
-
private findOldestLowPriority;
|
|
127
|
-
/**
|
|
128
|
-
* Export queue for persistence
|
|
129
|
-
*/
|
|
130
|
-
export(): OfflineOperation[];
|
|
131
|
-
/**
|
|
132
|
-
* Import queue from persistence
|
|
133
|
-
*/
|
|
134
|
-
import(operations: OfflineOperation[]): void;
|
|
135
|
-
/**
|
|
136
|
-
* Persist current queue snapshot.
|
|
137
|
-
*/
|
|
138
|
-
saveToPersistence(): Promise<void>;
|
|
139
|
-
/**
|
|
140
|
-
* Load queue snapshot from persistence.
|
|
141
|
-
*/
|
|
142
|
-
loadFromPersistence(): Promise<number>;
|
|
143
|
-
/**
|
|
144
|
-
* Remove persisted queue snapshot.
|
|
145
|
-
*/
|
|
146
|
-
clearPersistence(): Promise<void>;
|
|
147
|
-
private schedulePersist;
|
|
148
|
-
private persistSafely;
|
|
149
|
-
private isValidOfflineOperation;
|
|
150
|
-
}
|
|
151
|
-
declare function getOfflineOperationQueue(): OfflineOperationQueue;
|
|
152
|
-
declare function resetOfflineOperationQueue(): void;
|
|
153
|
-
|
|
154
|
-
export { type OfflineOperation, OfflineOperationQueue, type OfflineOperationQueueOptions, type OfflineQueueEvents, type OfflineQueuePersistenceConfig, type OfflineQueueStats, OperationPriority, getOfflineOperationQueue, resetOfflineOperationQueue };
|