@keepkit/core 0.28.12 → 0.28.14
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 +5 -1
- package/dist/{chunk-CSBPFROD.js → chunk-36NNVLEU.js} +2 -2
- package/dist/{chunk-SS22UTBH.js → chunk-WKXLHEAK.js} +181 -31
- package/dist/chunk-WKXLHEAK.js.map +1 -0
- package/dist/core.d.ts +7 -6
- package/dist/core.js +167 -13
- package/dist/core.js.map +1 -1
- package/dist/react.d.ts +4 -4
- package/dist/react.js +2 -2
- package/dist/schema.d.ts +1 -1
- package/dist/storage.d.ts +15 -2
- package/dist/storage.js +1 -1
- package/dist/{store-C8cxvXRV.d.ts → store-D-ZFtgDn.d.ts} +1 -1
- package/dist/{types-DjXvE9Zb.d.ts → types-KNIY89_m.d.ts} +24 -1
- package/package.json +1 -1
- package/dist/chunk-SS22UTBH.js.map +0 -1
- /package/dist/{chunk-CSBPFROD.js.map → chunk-36NNVLEU.js.map} +0 -0
package/dist/storage.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as StorageAdapter, R as RemoteSyncDriver,
|
|
2
|
-
export {
|
|
1
|
+
import { S as StorageAdapter, R as RemoteSyncDriver, af as SyncQueueAdapter, M as KeepConflictResolver, k as SyncScope, a7 as KeepSyncQueueOperation, l as SyncCapableStorageAdapter, a3 as KeepStorageRecovery, o as KeepCollectionDefinition, d as KeepCollectionMembership, aa as KeepSyncState, K as KeepItem, a9 as KeepSyncResolution, e as KeepScope, F as FallbackRecoveryJournal } from './types-KNIY89_m.js';
|
|
2
|
+
export { q as FallbackRecoveryJournalState, r as FallbackRecoveryJournalV2, s as FallbackRecoveryOperation, t as FallbackRecoverySnapshot, U as KeepRecoveryInspection, V as KeepRecoveryResult, W as KeepRecoveryRow, X as KeepRecoveryState, ac as LocalStorageRecoveryJournal, ad as ScopedStorageAdapter, ae as ScopedSyncQueueAdapter, ag as createScopedStorageAdapter } from './types-KNIY89_m.js';
|
|
3
3
|
|
|
4
4
|
type LocalStorageSyncQueueOptions = {
|
|
5
5
|
key?: string;
|
|
@@ -31,6 +31,13 @@ type SyncStorageAdapterOptions<TMeta = Record<string, unknown>> = {
|
|
|
31
31
|
retryDelayMs?: number;
|
|
32
32
|
retryBackoff?: number;
|
|
33
33
|
scope?: SyncScope;
|
|
34
|
+
/**
|
|
35
|
+
* How `remote.pull()` results are applied. `"merge"` (default) treats them as a partial list and never deletes
|
|
36
|
+
* local items. `"snapshot"` treats them as the complete item list for the active scope and removes local items
|
|
37
|
+
* that the server has acknowledged before (they carry a `revision`) but no longer returns. Items with pending
|
|
38
|
+
* local operations are kept, so an offline edit of a remotely deleted item is pushed again.
|
|
39
|
+
*/
|
|
40
|
+
itemPullMode?: "merge" | "snapshot";
|
|
34
41
|
};
|
|
35
42
|
declare const DEFAULT_SYNC_QUEUE_KEY = "keepkit:sync-queue";
|
|
36
43
|
declare const DEFAULT_SYNC_QUEUE_DATABASE = "keepkit-sync";
|
|
@@ -43,6 +50,8 @@ declare class LocalStorageSyncQueueAdapter<TMeta = Record<string, unknown>> impl
|
|
|
43
50
|
setMany(operations: KeepSyncQueueOperation<TMeta>[]): Promise<void>;
|
|
44
51
|
remove(operationIds: string[]): Promise<void>;
|
|
45
52
|
clear(): Promise<void>;
|
|
53
|
+
private readAll;
|
|
54
|
+
private writeAll;
|
|
46
55
|
}
|
|
47
56
|
declare class IndexedDBSyncQueueAdapter<TMeta = Record<string, unknown>> implements SyncQueueAdapter<TMeta> {
|
|
48
57
|
private readonly databaseName;
|
|
@@ -91,6 +100,7 @@ declare class SyncStorageAdapter<TMeta = Record<string, unknown>> implements Syn
|
|
|
91
100
|
private readonly maxRetries;
|
|
92
101
|
private readonly retryDelayMs;
|
|
93
102
|
private readonly retryBackoff;
|
|
103
|
+
private readonly itemPullMode;
|
|
94
104
|
private readonly listeners;
|
|
95
105
|
private readonly dataListeners;
|
|
96
106
|
private queueItems;
|
|
@@ -99,6 +109,7 @@ declare class SyncStorageAdapter<TMeta = Record<string, unknown>> implements Syn
|
|
|
99
109
|
private flushPromise;
|
|
100
110
|
private state;
|
|
101
111
|
private readonly conflicts;
|
|
112
|
+
private readonly rejectedOperations;
|
|
102
113
|
private onlineHandler?;
|
|
103
114
|
private disposed;
|
|
104
115
|
constructor(options: SyncStorageAdapterOptions<TMeta>);
|
|
@@ -115,6 +126,7 @@ declare class SyncStorageAdapter<TMeta = Record<string, unknown>> implements Syn
|
|
|
115
126
|
flushSync(): Promise<void>;
|
|
116
127
|
retrySync(): Promise<void>;
|
|
117
128
|
resolveSyncConflict(id: string, resolution: KeepSyncResolution, item?: KeepItem<TMeta>): Promise<void>;
|
|
129
|
+
resolveRejectedSyncOperation(operationId: string, resolution: "retry" | "discard"): Promise<void>;
|
|
118
130
|
resolveCollectionSyncConflict(id: string, resolution: "local" | "remote", collection?: KeepCollectionDefinition): Promise<void>;
|
|
119
131
|
dispose(): void;
|
|
120
132
|
private runFlush;
|
|
@@ -122,6 +134,7 @@ declare class SyncStorageAdapter<TMeta = Record<string, unknown>> implements Syn
|
|
|
122
134
|
private createCollectionOperation;
|
|
123
135
|
private createMembershipOperation;
|
|
124
136
|
private applyScope;
|
|
137
|
+
private removeLocalItems;
|
|
125
138
|
private pushWithRetry;
|
|
126
139
|
private pushCollectionWithRetry;
|
|
127
140
|
private applyCollectionPushResult;
|
package/dist/storage.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { K as KeepItem, a as KeepItemStatus, S as StorageAdapter, b as KeepChangeContext, c as KeepUndoState } from './types-
|
|
1
|
+
import { K as KeepItem, a as KeepItemStatus, S as StorageAdapter, b as KeepChangeContext, c as KeepUndoState } from './types-KNIY89_m.js';
|
|
2
2
|
|
|
3
3
|
type KeepNavigationState<TMeta = Record<string, unknown>> = {
|
|
4
4
|
items: KeepItem<TMeta>[];
|
|
@@ -17,6 +17,16 @@ type KeepBackupV2<TMeta = Record<string, unknown>> = {
|
|
|
17
17
|
scopes?: SyncScope[];
|
|
18
18
|
};
|
|
19
19
|
type KeepBackup<TMeta = Record<string, unknown>> = KeepBackupV1<TMeta> | KeepBackupV2<TMeta>;
|
|
20
|
+
type KeepBackupSummary = {
|
|
21
|
+
version: 1 | typeof KEEP_BACKUP_VERSION;
|
|
22
|
+
exportedAt: number;
|
|
23
|
+
itemCount: number;
|
|
24
|
+
collectionCount: number;
|
|
25
|
+
membershipCount: number;
|
|
26
|
+
scopes: SyncScope[];
|
|
27
|
+
};
|
|
28
|
+
/** Validate a serialized backup and return its record counts without modifying storage. */
|
|
29
|
+
declare function inspectKeepBackup<TMeta = Record<string, unknown>>(data: string | KeepBackup<TMeta>): KeepBackupSummary;
|
|
20
30
|
type ImportItemsOptions<TMeta = unknown> = {
|
|
21
31
|
mode?: "replace" | "merge";
|
|
22
32
|
schema?: KeepSchema<TMeta>;
|
|
@@ -66,6 +76,10 @@ declare class KeepBackupImportError extends Error {
|
|
|
66
76
|
}
|
|
67
77
|
/** Serialize all adapter data into a versioned JSON backup. */
|
|
68
78
|
declare function exportItems<TMeta>(adapter: StorageAdapter<TMeta>): Promise<string>;
|
|
79
|
+
/** Format saved items as a portable Markdown list for notes, docs, or sharing. */
|
|
80
|
+
declare function formatItemsAsMarkdown<TMeta = Record<string, unknown>>(items: readonly KeepItem<TMeta>[], options?: {
|
|
81
|
+
collectionLabels?: Record<string, string>;
|
|
82
|
+
}): string;
|
|
69
83
|
/** Validate and restore a backup, either replacing or merging existing data. */
|
|
70
84
|
declare function importItems<TMeta>(adapter: StorageAdapter<TMeta>, data: string | KeepBackup<TMeta>, options?: ImportItemsOptions<TMeta>): Promise<ImportItemsResult<TMeta>>;
|
|
71
85
|
|
|
@@ -368,6 +382,10 @@ type KeepSyncConflict<TMeta = Record<string, unknown>> = {
|
|
|
368
382
|
remote: KeepItem<TMeta>;
|
|
369
383
|
revision?: string;
|
|
370
384
|
};
|
|
385
|
+
type KeepSyncRejectedOperation<TMeta = Record<string, unknown>> = {
|
|
386
|
+
operation: KeepSyncQueueOperation<TMeta>;
|
|
387
|
+
error: unknown;
|
|
388
|
+
};
|
|
371
389
|
type KeepSyncState<TMeta = Record<string, unknown>> = {
|
|
372
390
|
status: KeepSyncStatus;
|
|
373
391
|
pendingCount: number;
|
|
@@ -375,6 +393,8 @@ type KeepSyncState<TMeta = Record<string, unknown>> = {
|
|
|
375
393
|
/** Detailed conflict records when the adapter supports interactive resolution. */
|
|
376
394
|
conflicts?: KeepSyncConflict<TMeta>[];
|
|
377
395
|
collectionConflicts?: KeepCollectionSyncConflict[];
|
|
396
|
+
/** Permanently rejected operations stay queued until the host retries or discards them. */
|
|
397
|
+
rejectedOperations?: KeepSyncRejectedOperation<TMeta>[];
|
|
378
398
|
lastSyncedAt?: number;
|
|
379
399
|
error?: unknown;
|
|
380
400
|
};
|
|
@@ -468,6 +488,7 @@ type KeepConflictContext<TMeta = Record<string, unknown>> = {
|
|
|
468
488
|
type KeepConflictResolver<TMeta = Record<string, unknown>> = (local: KeepItem<TMeta> | undefined, remote: KeepItem<TMeta>, context: KeepConflictContext<TMeta>) => KeepItem<TMeta> | undefined | Promise<KeepItem<TMeta> | undefined>;
|
|
469
489
|
interface RemoteSyncDriver<TMeta = Record<string, unknown>> {
|
|
470
490
|
push(operation: SyncOperation<TMeta>): Promise<RemoteSyncResult<TMeta>>;
|
|
491
|
+
/** Return remote items for the active scope; with `itemPullMode: "snapshot"` this must be the complete list. */
|
|
471
492
|
pull?: () => Promise<KeepItem<TMeta>[]>;
|
|
472
493
|
/** Push collection operations through the same scoped, durable queue as item operations. */
|
|
473
494
|
pushCollection?(operation: KeepCollectionSyncOperation): Promise<void | KeepCollectionSyncResult>;
|
|
@@ -480,6 +501,7 @@ interface RemoteSyncDriver<TMeta = Record<string, unknown>> {
|
|
|
480
501
|
}
|
|
481
502
|
interface SyncQueueAdapter<TMeta = Record<string, unknown>> {
|
|
482
503
|
getAll(): Promise<KeepSyncQueueOperation<TMeta>[]>;
|
|
504
|
+
/** Upsert each operation by operation ID without replacing unrelated queued work. */
|
|
483
505
|
setMany(operations: KeepSyncQueueOperation<TMeta>[]): Promise<void>;
|
|
484
506
|
remove(operationIds: string[]): Promise<void>;
|
|
485
507
|
clear(): Promise<void>;
|
|
@@ -491,6 +513,7 @@ interface SyncCapableStorageAdapter<TMeta = Record<string, unknown>> extends Sto
|
|
|
491
513
|
flushSync(): Promise<void>;
|
|
492
514
|
retrySync?(): Promise<void>;
|
|
493
515
|
resolveSyncConflict?(id: string, resolution: KeepSyncResolution, item?: KeepItem<TMeta>): Promise<void>;
|
|
516
|
+
resolveRejectedSyncOperation?(operationId: string, resolution: "retry" | "discard"): Promise<void>;
|
|
494
517
|
resolveCollectionSyncConflict?(id: string, resolution: "local" | "remote", collection?: KeepCollectionDefinition): Promise<void>;
|
|
495
518
|
dispose?(): void;
|
|
496
519
|
}
|
|
@@ -557,4 +580,4 @@ type KeepUndoState = {
|
|
|
557
580
|
};
|
|
558
581
|
declare function normalizeKeepTags(tags?: string[]): string[] | undefined;
|
|
559
582
|
|
|
560
|
-
export {
|
|
583
|
+
export { KeepStorageError as $, type KeepBackupDataType as A, KeepBackupImportError as B, KeepBackupParseError as C, type KeepBackupSummary as D, type KeepBackupV1 as E, type FallbackRecoveryJournal as F, type KeepBackupV2 as G, type KeepChangePhase as H, type ImportItemsOptions as I, type KeepCollectionSyncConflict as J, type KeepItem as K, type KeepConflictContext as L, type KeepConflictResolver as M, type KeepErrorContext as N, type KeepErrorHandler as O, type KeepEventHandlers as P, type KeepInvalidItemPolicy as Q, type RemoteSyncDriver as R, type StorageAdapter as S, type KeepItemInput as T, type KeepRecoveryInspection as U, type KeepRecoveryResult as V, type KeepRecoveryRow as W, type KeepRecoveryState as X, type KeepSchema as Y, type KeepSchemaParseResult as Z, KeepStorageAccessError as _, type KeepItemStatus as a, type KeepStorageOperation as a0, KeepStorageParseError as a1, KeepStorageQuotaError as a2, type KeepStorageRecovery as a3, KeepStorageSerializationError as a4, type KeepSyncAuthStatus as a5, type KeepSyncConflict as a6, type KeepSyncQueueOperation as a7, type KeepSyncRejectedOperation as a8, type KeepSyncResolution as a9, type KeepSyncState as aa, type KeepSyncStatus as ab, LocalStorageRecoveryJournal as ac, ScopedStorageAdapter as ad, ScopedSyncQueueAdapter as ae, type SyncQueueAdapter as af, createScopedStorageAdapter as ag, exportItems as ah, formatItemsAsMarkdown as ai, getKeepScopeKey as aj, importItems as ak, inspectKeepBackup as al, isKeepSyncAuthError as am, isSameKeepScope as an, normalizeKeepTags as ao, type KeepChangeContext as b, type KeepUndoState as c, type KeepCollectionMembership as d, type KeepScope as e, type KeepPluginContext as f, type KeepPlugin as g, type SyncOperation as h, type KeepCollectionSyncOperation as i, type KeepMembershipSyncOperation as j, type SyncScope as k, type SyncCapableStorageAdapter as l, type RemoteSyncResult as m, type KeepCollectionSyncResult as n, type KeepCollectionDefinition as o, KeepSyncAuthError as p, type FallbackRecoveryJournalState as q, type FallbackRecoveryJournalV2 as r, type FallbackRecoveryOperation as s, type FallbackRecoverySnapshot as t, type ImportItemsResult as u, KEEP_BACKUP_FORMAT as v, KEEP_BACKUP_VERSION as w, type KeepAction as x, type KeepBackup as y, type KeepBackupAppliedCounts as z };
|