@keepkit/core 0.28.13 → 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/dist/storage.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { S as StorageAdapter, R as RemoteSyncDriver, ad as SyncQueueAdapter, L as KeepConflictResolver, k as SyncScope, a6 as KeepSyncQueueOperation, l as SyncCapableStorageAdapter, a2 as KeepStorageRecovery, n as KeepCollectionDefinition, d as KeepCollectionMembership, a8 as KeepSyncState, K as KeepItem, a7 as KeepSyncResolution, e as KeepScope, F as FallbackRecoveryJournal } from './types-DjXvE9Zb.js';
2
- export { p as FallbackRecoveryJournalState, q as FallbackRecoveryJournalV2, r as FallbackRecoveryOperation, s as FallbackRecoverySnapshot, T as KeepRecoveryInspection, U as KeepRecoveryResult, V as KeepRecoveryRow, W as KeepRecoveryState, aa as LocalStorageRecoveryJournal, ab as ScopedStorageAdapter, ac as ScopedSyncQueueAdapter, ae as createScopedStorageAdapter } from './types-DjXvE9Zb.js';
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
@@ -18,7 +18,7 @@ import {
18
18
  createBrowserStorageAdapter,
19
19
  createScopedStorageAdapter,
20
20
  createStorageAdapter
21
- } from "./chunk-SS22UTBH.js";
21
+ } from "./chunk-WKXLHEAK.js";
22
22
  import "./chunk-5W4QSJHV.js";
23
23
  export {
24
24
  DEFAULT_INDEXEDDB_DATABASE,
@@ -1,4 +1,4 @@
1
- import { K as KeepItem, a as KeepItemStatus, S as StorageAdapter, b as KeepChangeContext, c as KeepUndoState } from './types-DjXvE9Zb.js';
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 { type KeepStorageOperation as $, KeepBackupImportError as A, KeepBackupParseError as B, type KeepBackupV1 as C, type KeepBackupV2 as D, type KeepChangePhase as E, type FallbackRecoveryJournal as F, type KeepCollectionSyncConflict as G, type KeepCollectionSyncResult as H, type ImportItemsOptions as I, type KeepConflictContext as J, type KeepItem as K, type KeepConflictResolver as L, type KeepErrorContext as M, type KeepErrorHandler as N, type KeepEventHandlers as O, type KeepInvalidItemPolicy as P, type KeepItemInput as Q, type RemoteSyncDriver as R, type StorageAdapter as S, type KeepRecoveryInspection as T, type KeepRecoveryResult as U, type KeepRecoveryRow as V, type KeepRecoveryState as W, type KeepSchema as X, type KeepSchemaParseResult as Y, KeepStorageAccessError as Z, KeepStorageError as _, type KeepItemStatus as a, KeepStorageParseError as a0, KeepStorageQuotaError as a1, type KeepStorageRecovery as a2, KeepStorageSerializationError as a3, type KeepSyncAuthStatus as a4, type KeepSyncConflict as a5, type KeepSyncQueueOperation as a6, type KeepSyncResolution as a7, type KeepSyncState as a8, type KeepSyncStatus as a9, LocalStorageRecoveryJournal as aa, ScopedStorageAdapter as ab, ScopedSyncQueueAdapter as ac, type SyncQueueAdapter as ad, createScopedStorageAdapter as ae, exportItems as af, getKeepScopeKey as ag, importItems as ah, isKeepSyncAuthError as ai, isSameKeepScope as aj, normalizeKeepTags as ak, 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 KeepCollectionDefinition as n, KeepSyncAuthError as o, type FallbackRecoveryJournalState as p, type FallbackRecoveryJournalV2 as q, type FallbackRecoveryOperation as r, type FallbackRecoverySnapshot as s, type ImportItemsResult as t, KEEP_BACKUP_FORMAT as u, KEEP_BACKUP_VERSION as v, type KeepAction as w, type KeepBackup as x, type KeepBackupAppliedCounts as y, type KeepBackupDataType as z };
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 };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keepkit/core",
3
- "version": "0.28.13",
3
+ "version": "0.28.14",
4
4
  "description": "A flexible save-and-collect toolkit for React apps.",
5
5
  "type": "module",
6
6
  "license": "MIT",