@anfenn/dync 1.0.25 → 1.0.26

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/index.d.cts CHANGED
@@ -1,8 +1,92 @@
1
- export { A as AfterRemoteAddCallback, a as ApiFunctions, d as BatchFirstLoadResult, b as BatchPushPayload, c as BatchPushResult, B as BatchSync, C as ConflictResolutionStrategy, D as Dync, F as FirstLoadProgress, e as FirstLoadProgressCallback, f as MissingRemoteRecordDuringUpdateCallback, M as MissingRemoteRecordStrategy, g as MutationEvent, S as SyncAction, h as SyncOptions, i as SyncState, j as SyncedRecord, T as TableMap } from './index.shared-DHuT0l_t.cjs';
2
- export { M as MemoryAdapter, a as MemoryQueryContext, S as SQLiteAdapter, b as SqliteQueryContext, c as StorageAdapter } from './dexie-BqktVP7s.cjs';
1
+ import { A as ApiFunctions, S as SyncOptions, B as BatchSync, a as SyncStatus, b as SyncApi, T as TableMap } from './types-BgGGLrE9.cjs';
2
+ export { d as AfterRemoteAddCallback, g as BatchFirstLoadResult, e as BatchPushPayload, f as BatchPushResult, C as ConflictResolutionStrategy, F as FirstLoadProgress, h as FirstLoadProgressCallback, i as MissingRemoteRecordDuringUpdateCallback, M as MissingRemoteRecordStrategy, j as MutationEvent, c as SyncAction, k as SyncState, l as SyncedRecord } from './types-BgGGLrE9.cjs';
3
+ import { S as StorageAdapter, T as TableSchemaDefinition, D as DexieQueryContext, a as SqliteQueryContext, M as MemoryQueryContext, b as StorageTable } from './dexie-DtgGGM68.cjs';
4
+ export { c as MemoryAdapter, d as SQLiteAdapter } from './dexie-DtgGGM68.cjs';
5
+ import { c as SQLiteVersionConfigurator } from './types-CSbIAfu2.cjs';
3
6
  export { S as SQLiteDatabaseDriver, b as SQLiteQueryResult, a as SQLiteRunResult } from './types-CSbIAfu2.cjs';
4
7
  import 'dexie';
5
8
 
9
+ declare class DyncBase<_TStoreMap = Record<string, any>> {
10
+ private readonly adapter;
11
+ private readonly tableCache;
12
+ private readonly mutationWrappedTables;
13
+ private readonly syncEnhancedTables;
14
+ private readonly mutationListeners;
15
+ private visibilitySubscription?;
16
+ private openPromise?;
17
+ private disableSyncPromise?;
18
+ private disableSyncPromiseResolver?;
19
+ private sleepAbortController?;
20
+ private closing;
21
+ private syncApis;
22
+ private batchSync?;
23
+ private syncedTables;
24
+ private syncOptions;
25
+ private logger;
26
+ private syncTimerStarted;
27
+ private mutationsDuringSync;
28
+ private state;
29
+ readonly name: string;
30
+ /**
31
+ * Create a new Dync instance.
32
+ *
33
+ * Mode 1 - Per-table endpoints:
34
+ * @param databaseName - Name of the database
35
+ * @param syncApis - Map of table names to API functions
36
+ * @param storageAdapter - Storage adapter implementation (required)
37
+ * @param options - Sync options
38
+ *
39
+ * Mode 2 - Batch endpoints:
40
+ * @param databaseName - Name of the database
41
+ * @param batchSync - Batch sync config (syncTables, push, pull, firstLoad)
42
+ * @param storageAdapter - Storage adapter implementation (required)
43
+ * @param options - Sync options
44
+ */
45
+ constructor(databaseName: string, syncApis: Record<string, ApiFunctions>, storageAdapter: StorageAdapter, options?: SyncOptions);
46
+ constructor(databaseName: string, batchSync: BatchSync, storageAdapter: StorageAdapter, options?: SyncOptions);
47
+ version(versionNumber: number): {
48
+ stores(schema: Record<string, TableSchemaDefinition>): /*elided*/ any;
49
+ sqlite(configure: (builder: SQLiteVersionConfigurator) => void): /*elided*/ any;
50
+ };
51
+ open(): Promise<void>;
52
+ close(): Promise<void>;
53
+ delete(): Promise<void>;
54
+ query<R>(callback: (ctx: DexieQueryContext | SqliteQueryContext | MemoryQueryContext) => Promise<R>): Promise<R>;
55
+ table<K extends keyof _TStoreMap>(name: K): StorageTable<_TStoreMap[K]>;
56
+ table<T = any>(name: string): StorageTable<T>;
57
+ private withTransaction;
58
+ private setupEnhancedTables;
59
+ private injectSyncColumns;
60
+ private enhanceSyncTable;
61
+ private syncOnce;
62
+ private pullAll;
63
+ private pushAll;
64
+ private startSyncTimer;
65
+ private tryStart;
66
+ private setupVisibilityListener;
67
+ private handleVisibilityChange;
68
+ private startFirstLoad;
69
+ private getSyncState;
70
+ private resolveConflict;
71
+ private enableSync;
72
+ get syncStatus(): SyncStatus;
73
+ set syncStatus(status: SyncStatus);
74
+ private onSyncStateChange;
75
+ private onMutation;
76
+ private emitMutation;
77
+ sync: SyncApi;
78
+ }
79
+ type DyncInstance<TStoreMap extends Record<string, unknown> = Record<string, unknown>> = DyncBase<TStoreMap> & TableMap<TStoreMap> & {
80
+ table<K extends keyof TStoreMap & string>(name: K): StorageTable<TStoreMap[K]>;
81
+ table(name: string): StorageTable<any>;
82
+ };
83
+ declare const Dync: {
84
+ new <TStoreMap extends Record<string, unknown> = Record<string, unknown>>(databaseName: string, syncApis: Record<string, ApiFunctions>, storageAdapter: StorageAdapter, options?: SyncOptions): DyncInstance<TStoreMap>;
85
+ new <TStoreMap extends Record<string, unknown> = Record<string, unknown>>(databaseName: string, batchSync: BatchSync, storageAdapter: StorageAdapter, options?: SyncOptions): DyncInstance<TStoreMap>;
86
+ prototype: DyncInstance<Record<string, unknown>>;
87
+ } & typeof DyncBase;
88
+ type Dync<TStoreMap extends Record<string, unknown> = Record<string, unknown>> = DyncInstance<TStoreMap>;
89
+
6
90
  declare function createLocalId(): string;
7
91
 
8
- export { createLocalId };
92
+ export { ApiFunctions, BatchSync, Dync, MemoryQueryContext, SqliteQueryContext, StorageAdapter, SyncOptions, TableMap, createLocalId };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,92 @@
1
- export { A as AfterRemoteAddCallback, a as ApiFunctions, d as BatchFirstLoadResult, b as BatchPushPayload, c as BatchPushResult, B as BatchSync, C as ConflictResolutionStrategy, D as Dync, F as FirstLoadProgress, e as FirstLoadProgressCallback, f as MissingRemoteRecordDuringUpdateCallback, M as MissingRemoteRecordStrategy, g as MutationEvent, S as SyncAction, h as SyncOptions, i as SyncState, j as SyncedRecord, T as TableMap } from './index.shared-D-fB8Odd.js';
2
- export { M as MemoryAdapter, a as MemoryQueryContext, S as SQLiteAdapter, b as SqliteQueryContext, c as StorageAdapter } from './dexie-DRLMKLl5.js';
1
+ import { A as ApiFunctions, S as SyncOptions, B as BatchSync, a as SyncStatus, b as SyncApi, T as TableMap } from './types-B1Vn8_DF.js';
2
+ export { d as AfterRemoteAddCallback, g as BatchFirstLoadResult, e as BatchPushPayload, f as BatchPushResult, C as ConflictResolutionStrategy, F as FirstLoadProgress, h as FirstLoadProgressCallback, i as MissingRemoteRecordDuringUpdateCallback, M as MissingRemoteRecordStrategy, j as MutationEvent, c as SyncAction, k as SyncState, l as SyncedRecord } from './types-B1Vn8_DF.js';
3
+ import { S as StorageAdapter, T as TableSchemaDefinition, D as DexieQueryContext, a as SqliteQueryContext, M as MemoryQueryContext, b as StorageTable } from './dexie-B1FuZqDB.js';
4
+ export { c as MemoryAdapter, d as SQLiteAdapter } from './dexie-B1FuZqDB.js';
5
+ import { c as SQLiteVersionConfigurator } from './types-CSbIAfu2.js';
3
6
  export { S as SQLiteDatabaseDriver, b as SQLiteQueryResult, a as SQLiteRunResult } from './types-CSbIAfu2.js';
4
7
  import 'dexie';
5
8
 
9
+ declare class DyncBase<_TStoreMap = Record<string, any>> {
10
+ private readonly adapter;
11
+ private readonly tableCache;
12
+ private readonly mutationWrappedTables;
13
+ private readonly syncEnhancedTables;
14
+ private readonly mutationListeners;
15
+ private visibilitySubscription?;
16
+ private openPromise?;
17
+ private disableSyncPromise?;
18
+ private disableSyncPromiseResolver?;
19
+ private sleepAbortController?;
20
+ private closing;
21
+ private syncApis;
22
+ private batchSync?;
23
+ private syncedTables;
24
+ private syncOptions;
25
+ private logger;
26
+ private syncTimerStarted;
27
+ private mutationsDuringSync;
28
+ private state;
29
+ readonly name: string;
30
+ /**
31
+ * Create a new Dync instance.
32
+ *
33
+ * Mode 1 - Per-table endpoints:
34
+ * @param databaseName - Name of the database
35
+ * @param syncApis - Map of table names to API functions
36
+ * @param storageAdapter - Storage adapter implementation (required)
37
+ * @param options - Sync options
38
+ *
39
+ * Mode 2 - Batch endpoints:
40
+ * @param databaseName - Name of the database
41
+ * @param batchSync - Batch sync config (syncTables, push, pull, firstLoad)
42
+ * @param storageAdapter - Storage adapter implementation (required)
43
+ * @param options - Sync options
44
+ */
45
+ constructor(databaseName: string, syncApis: Record<string, ApiFunctions>, storageAdapter: StorageAdapter, options?: SyncOptions);
46
+ constructor(databaseName: string, batchSync: BatchSync, storageAdapter: StorageAdapter, options?: SyncOptions);
47
+ version(versionNumber: number): {
48
+ stores(schema: Record<string, TableSchemaDefinition>): /*elided*/ any;
49
+ sqlite(configure: (builder: SQLiteVersionConfigurator) => void): /*elided*/ any;
50
+ };
51
+ open(): Promise<void>;
52
+ close(): Promise<void>;
53
+ delete(): Promise<void>;
54
+ query<R>(callback: (ctx: DexieQueryContext | SqliteQueryContext | MemoryQueryContext) => Promise<R>): Promise<R>;
55
+ table<K extends keyof _TStoreMap>(name: K): StorageTable<_TStoreMap[K]>;
56
+ table<T = any>(name: string): StorageTable<T>;
57
+ private withTransaction;
58
+ private setupEnhancedTables;
59
+ private injectSyncColumns;
60
+ private enhanceSyncTable;
61
+ private syncOnce;
62
+ private pullAll;
63
+ private pushAll;
64
+ private startSyncTimer;
65
+ private tryStart;
66
+ private setupVisibilityListener;
67
+ private handleVisibilityChange;
68
+ private startFirstLoad;
69
+ private getSyncState;
70
+ private resolveConflict;
71
+ private enableSync;
72
+ get syncStatus(): SyncStatus;
73
+ set syncStatus(status: SyncStatus);
74
+ private onSyncStateChange;
75
+ private onMutation;
76
+ private emitMutation;
77
+ sync: SyncApi;
78
+ }
79
+ type DyncInstance<TStoreMap extends Record<string, unknown> = Record<string, unknown>> = DyncBase<TStoreMap> & TableMap<TStoreMap> & {
80
+ table<K extends keyof TStoreMap & string>(name: K): StorageTable<TStoreMap[K]>;
81
+ table(name: string): StorageTable<any>;
82
+ };
83
+ declare const Dync: {
84
+ new <TStoreMap extends Record<string, unknown> = Record<string, unknown>>(databaseName: string, syncApis: Record<string, ApiFunctions>, storageAdapter: StorageAdapter, options?: SyncOptions): DyncInstance<TStoreMap>;
85
+ new <TStoreMap extends Record<string, unknown> = Record<string, unknown>>(databaseName: string, batchSync: BatchSync, storageAdapter: StorageAdapter, options?: SyncOptions): DyncInstance<TStoreMap>;
86
+ prototype: DyncInstance<Record<string, unknown>>;
87
+ } & typeof DyncBase;
88
+ type Dync<TStoreMap extends Record<string, unknown> = Record<string, unknown>> = DyncInstance<TStoreMap>;
89
+
6
90
  declare function createLocalId(): string;
7
91
 
8
- export { createLocalId };
92
+ export { ApiFunctions, BatchSync, Dync, MemoryQueryContext, SqliteQueryContext, StorageAdapter, SyncOptions, TableMap, createLocalId };