@slimr/dbsync 0.0.3

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.
Files changed (122) hide show
  1. package/README.md +183 -0
  2. package/cjs/DbRepository.d.ts +59 -0
  3. package/cjs/DbRepository.js +78 -0
  4. package/cjs/DbRepository.js.map +1 -0
  5. package/cjs/DbSync.d.ts +51 -0
  6. package/cjs/DbSync.js +123 -0
  7. package/cjs/DbSync.js.map +1 -0
  8. package/cjs/DbTransaction.d.ts +60 -0
  9. package/cjs/DbTransaction.js +82 -0
  10. package/cjs/DbTransaction.js.map +1 -0
  11. package/cjs/DbTxRepository.d.ts +41 -0
  12. package/cjs/DbTxRepository.js +56 -0
  13. package/cjs/DbTxRepository.js.map +1 -0
  14. package/cjs/MigrationManager.d.ts +60 -0
  15. package/cjs/MigrationManager.js +69 -0
  16. package/cjs/MigrationManager.js.map +1 -0
  17. package/cjs/Repository.d.ts +59 -0
  18. package/cjs/Repository.js +78 -0
  19. package/cjs/Repository.js.map +1 -0
  20. package/cjs/adapters/RestAdapter.d.ts +13 -0
  21. package/cjs/adapters/RestAdapter.js +47 -0
  22. package/cjs/adapters/RestAdapter.js.map +1 -0
  23. package/cjs/adapters/index.d.ts +2 -0
  24. package/cjs/adapters/index.js +19 -0
  25. package/cjs/adapters/index.js.map +1 -0
  26. package/cjs/adapters/types.d.ts +11 -0
  27. package/cjs/adapters/types.js +3 -0
  28. package/cjs/adapters/types.js.map +1 -0
  29. package/cjs/index.d.ts +3 -0
  30. package/cjs/index.js +20 -0
  31. package/cjs/index.js.map +1 -0
  32. package/cjs/internal/AuthManager.d.ts +13 -0
  33. package/cjs/internal/AuthManager.js +34 -0
  34. package/cjs/internal/AuthManager.js.map +1 -0
  35. package/cjs/internal/DbTransaction.d.ts +60 -0
  36. package/cjs/internal/DbTransaction.js +82 -0
  37. package/cjs/internal/DbTransaction.js.map +1 -0
  38. package/cjs/internal/EventBus.d.ts +16 -0
  39. package/cjs/internal/EventBus.js +41 -0
  40. package/cjs/internal/EventBus.js.map +1 -0
  41. package/cjs/internal/MigrationManager.d.ts +60 -0
  42. package/cjs/internal/MigrationManager.js +69 -0
  43. package/cjs/internal/MigrationManager.js.map +1 -0
  44. package/cjs/internal/StorageManager.d.ts +20 -0
  45. package/cjs/internal/StorageManager.js +148 -0
  46. package/cjs/internal/StorageManager.js.map +1 -0
  47. package/cjs/internal/SyncEngine.d.ts +27 -0
  48. package/cjs/internal/SyncEngine.js +191 -0
  49. package/cjs/internal/SyncEngine.js.map +1 -0
  50. package/cjs/internal/utils.d.ts +1 -0
  51. package/cjs/internal/utils.js +7 -0
  52. package/cjs/internal/utils.js.map +1 -0
  53. package/cjs/react.d.ts +1 -0
  54. package/cjs/react.js +18 -0
  55. package/cjs/react.js.map +1 -0
  56. package/cjs/useDbQuery.d.ts +13 -0
  57. package/cjs/useDbQuery.js +59 -0
  58. package/cjs/useDbQuery.js.map +1 -0
  59. package/cjs/util/promiseWithResolvers.d.ts +11 -0
  60. package/cjs/util/promiseWithResolvers.js +19 -0
  61. package/cjs/util/promiseWithResolvers.js.map +1 -0
  62. package/esm/DbRepository.d.ts +59 -0
  63. package/esm/DbRepository.js +74 -0
  64. package/esm/DbRepository.js.map +1 -0
  65. package/esm/DbSync.d.ts +51 -0
  66. package/esm/DbSync.js +119 -0
  67. package/esm/DbSync.js.map +1 -0
  68. package/esm/DbTransaction.d.ts +60 -0
  69. package/esm/DbTransaction.js +78 -0
  70. package/esm/DbTransaction.js.map +1 -0
  71. package/esm/DbTxRepository.d.ts +41 -0
  72. package/esm/DbTxRepository.js +52 -0
  73. package/esm/DbTxRepository.js.map +1 -0
  74. package/esm/MigrationManager.d.ts +60 -0
  75. package/esm/MigrationManager.js +65 -0
  76. package/esm/MigrationManager.js.map +1 -0
  77. package/esm/Repository.d.ts +59 -0
  78. package/esm/Repository.js +74 -0
  79. package/esm/Repository.js.map +1 -0
  80. package/esm/adapters/RestAdapter.d.ts +13 -0
  81. package/esm/adapters/RestAdapter.js +43 -0
  82. package/esm/adapters/RestAdapter.js.map +1 -0
  83. package/esm/adapters/index.d.ts +2 -0
  84. package/esm/adapters/index.js +3 -0
  85. package/esm/adapters/index.js.map +1 -0
  86. package/esm/adapters/types.d.ts +11 -0
  87. package/esm/adapters/types.js +2 -0
  88. package/esm/adapters/types.js.map +1 -0
  89. package/esm/index.d.ts +3 -0
  90. package/esm/index.js +4 -0
  91. package/esm/index.js.map +1 -0
  92. package/esm/internal/AuthManager.d.ts +13 -0
  93. package/esm/internal/AuthManager.js +30 -0
  94. package/esm/internal/AuthManager.js.map +1 -0
  95. package/esm/internal/DbTransaction.d.ts +60 -0
  96. package/esm/internal/DbTransaction.js +78 -0
  97. package/esm/internal/DbTransaction.js.map +1 -0
  98. package/esm/internal/EventBus.d.ts +16 -0
  99. package/esm/internal/EventBus.js +37 -0
  100. package/esm/internal/EventBus.js.map +1 -0
  101. package/esm/internal/MigrationManager.d.ts +60 -0
  102. package/esm/internal/MigrationManager.js +65 -0
  103. package/esm/internal/MigrationManager.js.map +1 -0
  104. package/esm/internal/StorageManager.d.ts +20 -0
  105. package/esm/internal/StorageManager.js +144 -0
  106. package/esm/internal/StorageManager.js.map +1 -0
  107. package/esm/internal/SyncEngine.d.ts +27 -0
  108. package/esm/internal/SyncEngine.js +187 -0
  109. package/esm/internal/SyncEngine.js.map +1 -0
  110. package/esm/internal/utils.d.ts +1 -0
  111. package/esm/internal/utils.js +4 -0
  112. package/esm/internal/utils.js.map +1 -0
  113. package/esm/react.d.ts +1 -0
  114. package/esm/react.js +2 -0
  115. package/esm/react.js.map +1 -0
  116. package/esm/useDbQuery.d.ts +13 -0
  117. package/esm/useDbQuery.js +56 -0
  118. package/esm/useDbQuery.js.map +1 -0
  119. package/esm/util/promiseWithResolvers.d.ts +11 -0
  120. package/esm/util/promiseWithResolvers.js +16 -0
  121. package/esm/util/promiseWithResolvers.js.map +1 -0
  122. package/package.json +44 -0
@@ -0,0 +1 @@
1
+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,UAAU,CAAC,WAAW,EAAE,CAAA;IACrC,CAAC;IACM,KAAK,CAAC,WAAW;QACvB,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,EAAE,CAAA;IACrC,CAAC;IAED,iBAAiB;IACV,iBAAiB;QACvB,IAAI,CAAC,MAAM,EAAE,CAAA;IACd,CAAC;IACM,gBAAgB;QACtB,IAAI,CAAC,OAAO,EAAE,CAAA;IACf,CAAC;IAES,sBAAsB;QAC/B,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAA;QACtB,IAAI,CAAC,OAAO,EAAE,CAAA;QACd,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;YACnC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAA;QACzB,CAAC;IACF,CAAC;IAEM,OAAO;QACb,IAAI,CAAC,OAAO,EAAE,CAAA;QACd,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAA;QACrB,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAA;IACvB,CAAC;CACD"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Represents an atomic sequence of write operations.
3
+ * Operations are queued in memory and only executed against the target
4
+ * database when `commit()` is called.
5
+ */
6
+ export declare class DbTransaction {
7
+ private executor;
8
+ /**
9
+ * Stores the pending CRUD operations.
10
+ * @internal Evaluated and executed by the executor function upon `commit()`.
11
+ */
12
+ private operations;
13
+ /**
14
+ * Initializes the transaction with an execution engine.
15
+ * Should be instantiated via `DbSync.getTransaction()` rather than directly.
16
+ *
17
+ * @internal
18
+ * @param executor Provides the context needed to process the queued operations.
19
+ */
20
+ constructor(executor: (ops: any[]) => Promise<void>);
21
+ /**
22
+ * Queues an insertion operation.
23
+ *
24
+ * @param storeName The name of the target object store.
25
+ * @param value The object payload to insert.
26
+ * @param key An optional explicit primary key.
27
+ */
28
+ add(storeName: string, value: any, key?: string | number): void;
29
+ /**
30
+ * Queues an upsert (insert or update) operation.
31
+ *
32
+ * @param storeName The name of the target object store.
33
+ * @param value The object payload to write.
34
+ * @param key An optional explicit primary key.
35
+ */
36
+ put(storeName: string, value: any, key?: string | number): void;
37
+ /**
38
+ * Queues a deletion operation.
39
+ *
40
+ * @param storeName The name of the target object store.
41
+ * @param key The primary key of the record to remove.
42
+ */
43
+ delete(storeName: string, key: string | number): void;
44
+ /**
45
+ * Queues an operation to remove all records from an object store.
46
+ *
47
+ * @param storeName The name of the object store to clear.
48
+ */
49
+ clear(storeName: string): void;
50
+ /**
51
+ * Executes all queued operations atomically within a single database transaction.
52
+ *
53
+ * @returns A promise that resolves when the transaction successfully completes.
54
+ */
55
+ commit(): Promise<void>;
56
+ /**
57
+ * Discards all pending operations without modifying the database.
58
+ */
59
+ cancel(): void;
60
+ }
@@ -0,0 +1,78 @@
1
+ // DbTransaction does not depend on DbSync now
2
+ /**
3
+ * Represents an atomic sequence of write operations.
4
+ * Operations are queued in memory and only executed against the target
5
+ * database when `commit()` is called.
6
+ */
7
+ export class DbTransaction {
8
+ executor;
9
+ /**
10
+ * Stores the pending CRUD operations.
11
+ * @internal Evaluated and executed by the executor function upon `commit()`.
12
+ */
13
+ operations = [];
14
+ /**
15
+ * Initializes the transaction with an execution engine.
16
+ * Should be instantiated via `DbSync.getTransaction()` rather than directly.
17
+ *
18
+ * @internal
19
+ * @param executor Provides the context needed to process the queued operations.
20
+ */
21
+ constructor(executor) {
22
+ this.executor = executor;
23
+ }
24
+ /**
25
+ * Queues an insertion operation.
26
+ *
27
+ * @param storeName The name of the target object store.
28
+ * @param value The object payload to insert.
29
+ * @param key An optional explicit primary key.
30
+ */
31
+ add(storeName, value, key) {
32
+ this.operations.push({ type: "add", storeName, value, key });
33
+ }
34
+ /**
35
+ * Queues an upsert (insert or update) operation.
36
+ *
37
+ * @param storeName The name of the target object store.
38
+ * @param value The object payload to write.
39
+ * @param key An optional explicit primary key.
40
+ */
41
+ put(storeName, value, key) {
42
+ this.operations.push({ type: "put", storeName, value, key });
43
+ }
44
+ /**
45
+ * Queues a deletion operation.
46
+ *
47
+ * @param storeName The name of the target object store.
48
+ * @param key The primary key of the record to remove.
49
+ */
50
+ delete(storeName, key) {
51
+ this.operations.push({ type: "delete", storeName, key });
52
+ }
53
+ /**
54
+ * Queues an operation to remove all records from an object store.
55
+ *
56
+ * @param storeName The name of the object store to clear.
57
+ */
58
+ clear(storeName) {
59
+ this.operations.push({ type: "clear", storeName });
60
+ }
61
+ /**
62
+ * Executes all queued operations atomically within a single database transaction.
63
+ *
64
+ * @returns A promise that resolves when the transaction successfully completes.
65
+ */
66
+ async commit() {
67
+ if (this.operations.length === 0)
68
+ return;
69
+ return this.executor(this.operations);
70
+ }
71
+ /**
72
+ * Discards all pending operations without modifying the database.
73
+ */
74
+ cancel() {
75
+ this.operations = [];
76
+ }
77
+ }
78
+ //# sourceMappingURL=DbTransaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DbTransaction.js","sourceRoot":"","sources":["../src/DbTransaction.ts"],"names":[],"mappings":"AAAA,8CAA8C;AAE9C;;;;GAIG;AACH,MAAM,OAAO,aAAa;IAmBL;IAlBpB;;;OAGG;IACK,UAAU,GAKZ,EAAE,CAAA;IAER;;;;;;OAMG;IACH,YAAoB,QAAuC;QAAvC,aAAQ,GAAR,QAAQ,CAA+B;IAAG,CAAC;IAE/D;;;;;;OAMG;IACH,GAAG,CAAC,SAAiB,EAAE,KAAU,EAAE,GAAqB;QACvD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;IAC7D,CAAC;IAED;;;;;;OAMG;IACH,GAAG,CAAC,SAAiB,EAAE,KAAU,EAAE,GAAqB;QACvD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;IAC7D,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,SAAiB,EAAE,GAAoB;QAC7C,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,CAAA;IACzD,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,SAAiB;QACtB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAA;IACnD,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM;QACX,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC;YAAE,OAAM;QACxC,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IACtC,CAAC;IAED;;OAEG;IACH,MAAM;QACL,IAAI,CAAC,UAAU,GAAG,EAAE,CAAA;IACrB,CAAC;CACD"}
@@ -0,0 +1,41 @@
1
+ import type { DbTransaction } from "./internal/DbTransaction.js";
2
+ /**
3
+ * A typed repository wrapper for a single `DbTransaction` object store target.
4
+ * Provides a localized interface to queue write operations with strict typings
5
+ * to minimize boilerplate and enforce consistent data types for a specific table.
6
+ */
7
+ export declare class DbTxRepository<T> {
8
+ protected tx: DbTransaction;
9
+ readonly storeName: string;
10
+ /**
11
+ * Initializes a new transaction repository tied to a specific object store.
12
+ *
13
+ * @param tx The active `DbTransaction` instance.
14
+ * @param storeName The name of the object store to queue writes for.
15
+ */
16
+ constructor(tx: DbTransaction, storeName: string);
17
+ /**
18
+ * Queues an insertion operation.
19
+ *
20
+ * @param value The object payload to insert.
21
+ * @param key An optional explicit primary key.
22
+ */
23
+ add(value: Partial<T>, key?: string | number): void;
24
+ /**
25
+ * Queues an upsert (insert or update) operation.
26
+ *
27
+ * @param value The complete object to upsert.
28
+ * @param key An optional explicit primary key.
29
+ */
30
+ put(value: T, key?: string | number): void;
31
+ /**
32
+ * Queues a deletion operation.
33
+ *
34
+ * @param key The primary key of the record to delete.
35
+ */
36
+ delete(key: string | number): void;
37
+ /**
38
+ * Queues an operation to remove all records from the object store.
39
+ */
40
+ clear(): void;
41
+ }
@@ -0,0 +1,52 @@
1
+ /**
2
+ * A typed repository wrapper for a single `DbTransaction` object store target.
3
+ * Provides a localized interface to queue write operations with strict typings
4
+ * to minimize boilerplate and enforce consistent data types for a specific table.
5
+ */
6
+ export class DbTxRepository {
7
+ tx;
8
+ storeName;
9
+ /**
10
+ * Initializes a new transaction repository tied to a specific object store.
11
+ *
12
+ * @param tx The active `DbTransaction` instance.
13
+ * @param storeName The name of the object store to queue writes for.
14
+ */
15
+ constructor(tx, storeName) {
16
+ this.tx = tx;
17
+ this.storeName = storeName;
18
+ }
19
+ /**
20
+ * Queues an insertion operation.
21
+ *
22
+ * @param value The object payload to insert.
23
+ * @param key An optional explicit primary key.
24
+ */
25
+ add(value, key) {
26
+ this.tx.add(this.storeName, value, key);
27
+ }
28
+ /**
29
+ * Queues an upsert (insert or update) operation.
30
+ *
31
+ * @param value The complete object to upsert.
32
+ * @param key An optional explicit primary key.
33
+ */
34
+ put(value, key) {
35
+ this.tx.put(this.storeName, value, key);
36
+ }
37
+ /**
38
+ * Queues a deletion operation.
39
+ *
40
+ * @param key The primary key of the record to delete.
41
+ */
42
+ delete(key) {
43
+ this.tx.delete(this.storeName, key);
44
+ }
45
+ /**
46
+ * Queues an operation to remove all records from the object store.
47
+ */
48
+ clear() {
49
+ this.tx.clear(this.storeName);
50
+ }
51
+ }
52
+ //# sourceMappingURL=DbTxRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DbTxRepository.js","sourceRoot":"","sources":["../src/DbTxRepository.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,OAAO,cAAc;IAQf;IACM;IARjB;;;;;OAKG;IACH,YACW,EAAiB,EACX,SAAiB;QADvB,OAAE,GAAF,EAAE,CAAe;QACX,cAAS,GAAT,SAAS,CAAQ;IAC/B,CAAC;IAEJ;;;;;OAKG;IACH,GAAG,CAAC,KAAiB,EAAE,GAAqB;QAC3C,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,GAAG,CAAC,CAAA;IACxC,CAAC;IAED;;;;;OAKG;IACH,GAAG,CAAC,KAAQ,EAAE,GAAqB;QAClC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,GAAG,CAAC,CAAA;IACxC,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,GAAoB;QAC1B,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,CAAC,CAAA;IACpC,CAAC;IAED;;OAEG;IACH,KAAK;QACJ,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IAC9B,CAAC;CACD"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Defines a single, sequential schema evolution step for a document structure.
3
+ * Migrations allow existing offline data to be selectively upgraded rather than wiped
4
+ * when backend domain modeling changes.
5
+ */
6
+ export interface IMigration<T = any> {
7
+ /**
8
+ * An ascending integer determining execution order. A record currently at `storeVersion: 1`
9
+ * will only trigger migrations where `version >= 2`.
10
+ */
11
+ version: number;
12
+ /**
13
+ * A human-readable note summarizing the structural change.
14
+ */
15
+ note: string;
16
+ /**
17
+ * Mutates the provided record in-place to comply with the new schema structure.
18
+ *
19
+ * @param record The raw record needing an upgrade.
20
+ * @returns A promise that resolves when the record has been fully transformed.
21
+ */
22
+ upgrade(record: T): Promise<void>;
23
+ }
24
+ /**
25
+ * An engine for applying a suite of `IMigration` objects to all records
26
+ * across targeted `DbSync` object stores.
27
+ */
28
+ export declare class MigrationManager {
29
+ private db;
30
+ /**
31
+ * Initializes the MigrationManager for a specific database instance.
32
+ *
33
+ * @internal
34
+ * @param db The `DbSync` instance used to traverse object stores and apply rewrites.
35
+ */
36
+ constructor(db: any);
37
+ /**
38
+ * Iterates through a map of object stores and systematically applies their respective migrations.
39
+ *
40
+ * @param schemaMigrations A dictionary mapping store names to arrays of `IMigration` steps.
41
+ */
42
+ runAll(schemaMigrations: Record<string, IMigration[]>): Promise<void>;
43
+ /**
44
+ * Sorts and attempts to apply a sequence of migrations to a single record in memory.
45
+ * Evaluates `storeVersion` to ensure migrations are only executed sequentially and exactly once.
46
+ *
47
+ * @param record The plain object to be upgraded.
48
+ * @param migrations The full list of potential migrations for the record's domain type.
49
+ * @returns The functionally upgraded record with an updated `storeVersion`.
50
+ */
51
+ static upgradeRecord<T>(record: any, migrations: IMigration<T>[]): Promise<any>;
52
+ /**
53
+ * Reads all records from a specific store, upgrades out-of-date entries,
54
+ * and atomically flushes the changed entries back within a single database transaction.
55
+ *
56
+ * @param storeName The name of the target object store.
57
+ * @param migrations The ordered array of migrations applicable to the store.
58
+ */
59
+ private upgradeStore;
60
+ }
@@ -0,0 +1,65 @@
1
+ /**
2
+ * An engine for applying a suite of `IMigration` objects to all records
3
+ * across targeted `DbSync` object stores.
4
+ */
5
+ export class MigrationManager {
6
+ db;
7
+ /**
8
+ * Initializes the MigrationManager for a specific database instance.
9
+ *
10
+ * @internal
11
+ * @param db The `DbSync` instance used to traverse object stores and apply rewrites.
12
+ */
13
+ constructor(db) {
14
+ this.db = db;
15
+ } // db is DbSync instance
16
+ /**
17
+ * Iterates through a map of object stores and systematically applies their respective migrations.
18
+ *
19
+ * @param schemaMigrations A dictionary mapping store names to arrays of `IMigration` steps.
20
+ */
21
+ async runAll(schemaMigrations) {
22
+ for (const [storeName, migrations] of Object.entries(schemaMigrations)) {
23
+ await this.upgradeStore(storeName, migrations);
24
+ }
25
+ }
26
+ /**
27
+ * Sorts and attempts to apply a sequence of migrations to a single record in memory.
28
+ * Evaluates `storeVersion` to ensure migrations are only executed sequentially and exactly once.
29
+ *
30
+ * @param record The plain object to be upgraded.
31
+ * @param migrations The full list of potential migrations for the record's domain type.
32
+ * @returns The functionally upgraded record with an updated `storeVersion`.
33
+ */
34
+ static async upgradeRecord(record, migrations) {
35
+ const sortedMigrations = [...migrations].sort((a, b) => a.version - b.version);
36
+ for (const migration of sortedMigrations) {
37
+ const currentVersion = record.storeVersion || 0;
38
+ if (currentVersion < migration.version) {
39
+ await migration.upgrade(record);
40
+ record.storeVersion = migration.version;
41
+ }
42
+ }
43
+ return record;
44
+ }
45
+ /**
46
+ * Reads all records from a specific store, upgrades out-of-date entries,
47
+ * and atomically flushes the changed entries back within a single database transaction.
48
+ *
49
+ * @param storeName The name of the target object store.
50
+ * @param migrations The ordered array of migrations applicable to the store.
51
+ */
52
+ async upgradeStore(storeName, migrations) {
53
+ const allRecords = await this.db.findAll(storeName);
54
+ const tx = this.db.getTransaction();
55
+ for (const recordCurrent of allRecords) {
56
+ const recordNext = { ...recordCurrent };
57
+ await MigrationManager.upgradeRecord(recordNext, migrations);
58
+ if (recordNext.storeVersion !== recordCurrent.storeVersion) {
59
+ tx.put(storeName, recordNext);
60
+ }
61
+ }
62
+ await tx.commit();
63
+ }
64
+ }
65
+ //# sourceMappingURL=MigrationManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MigrationManager.js","sourceRoot":"","sources":["../src/MigrationManager.ts"],"names":[],"mappings":"AA0BA;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IAOR;IANpB;;;;;OAKG;IACH,YAAoB,EAAO;QAAP,OAAE,GAAF,EAAE,CAAK;IAAG,CAAC,CAAC,wBAAwB;IAExD;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,gBAA8C;QAC1D,KAAK,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,CAAC;YACxE,MAAM,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA;QAC/C,CAAC;IACF,CAAC;IAED;;;;;;;OAOG;IACI,MAAM,CAAC,KAAK,CAAC,aAAa,CAAI,MAAW,EAAE,UAA2B;QAC5E,MAAM,gBAAgB,GAAG,CAAC,GAAG,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC,CAAA;QAC9E,KAAK,MAAM,SAAS,IAAI,gBAAgB,EAAE,CAAC;YAC1C,MAAM,cAAc,GAAG,MAAM,CAAC,YAAY,IAAI,CAAC,CAAA;YAC/C,IAAI,cAAc,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC;gBACxC,MAAM,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;gBAC/B,MAAM,CAAC,YAAY,GAAG,SAAS,CAAC,OAAO,CAAA;YACxC,CAAC;QACF,CAAC;QACD,OAAO,MAAM,CAAA;IACd,CAAC;IAED;;;;;;OAMG;IACK,KAAK,CAAC,YAAY,CAAC,SAAiB,EAAE,UAAwB;QACrE,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;QACnD,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,cAAc,EAAE,CAAA;QAEnC,KAAK,MAAM,aAAa,IAAI,UAAU,EAAE,CAAC;YACxC,MAAM,UAAU,GAAG,EAAE,GAAG,aAAa,EAAE,CAAA;YACvC,MAAM,gBAAgB,CAAC,aAAa,CAAC,UAAU,EAAE,UAAU,CAAC,CAAA;YAE5D,IAAI,UAAU,CAAC,YAAY,KAAK,aAAa,CAAC,YAAY,EAAE,CAAC;gBAC5D,EAAE,CAAC,GAAG,CAAC,SAAS,EAAE,UAAU,CAAC,CAAA;YAC9B,CAAC;QACF,CAAC;QAED,MAAM,EAAE,CAAC,MAAM,EAAE,CAAA;IAClB,CAAC;CACD"}
@@ -0,0 +1,59 @@
1
+ import type { DbSync } from "./DbSync.js";
2
+ /**
3
+ * A typed repository wrapper for a single `DbSync` object store.
4
+ * Provides a localized CRUD interface to minimize boilerplate and
5
+ * enforce consistent data types for a specific table.
6
+ */
7
+ export declare class Repository<T> {
8
+ protected db: DbSync;
9
+ readonly storeName: string;
10
+ /**
11
+ * Initializes a new repository tied to a specific object store.
12
+ *
13
+ * @param db The centralized `DbSync` instance.
14
+ * @param storeName The name of the object store this repository will manage.
15
+ */
16
+ constructor(db: DbSync, storeName: string);
17
+ /**
18
+ * Retrieves a single record by its primary key.
19
+ *
20
+ * @param id The primary key of the record to retrieve.
21
+ * @returns A promise resolving to the typed record, or `undefined` if not found.
22
+ */
23
+ findById(id: string | number): Promise<T | undefined>;
24
+ /**
25
+ * Retrieves all records currently held in the object store.
26
+ *
27
+ * @returns A promise resolving to an array of all typed records.
28
+ */
29
+ findAll(): Promise<T[]>;
30
+ /**
31
+ * Inserts a new record into the object store.
32
+ *
33
+ * @param value The object payload to insert.
34
+ * @param key An optional explicit primary key.
35
+ * @returns A promise resolving to the newly inserted record.
36
+ */
37
+ add(value: Partial<T>, key?: string | number): Promise<T>;
38
+ /**
39
+ * Inserts or updates an existing record in the object store.
40
+ *
41
+ * @param value The complete object to upsert.
42
+ * @param key An optional explicit primary key.
43
+ * @returns A promise resolving to the upserted record.
44
+ */
45
+ put(value: T, key?: string | number): Promise<T>;
46
+ /**
47
+ * Removes a record from the object store by its primary key.
48
+ *
49
+ * @param key The primary key of the record to delete.
50
+ * @returns A promise resolving when the deletion is complete.
51
+ */
52
+ delete(key: string | number): Promise<void>;
53
+ /**
54
+ * Discards all records present in the object store.
55
+ *
56
+ * @returns A promise resolving when the store has been completely cleared.
57
+ */
58
+ clear(): Promise<void>;
59
+ }
@@ -0,0 +1,74 @@
1
+ /**
2
+ * A typed repository wrapper for a single `DbSync` object store.
3
+ * Provides a localized CRUD interface to minimize boilerplate and
4
+ * enforce consistent data types for a specific table.
5
+ */
6
+ export class Repository {
7
+ db;
8
+ storeName;
9
+ /**
10
+ * Initializes a new repository tied to a specific object store.
11
+ *
12
+ * @param db The centralized `DbSync` instance.
13
+ * @param storeName The name of the object store this repository will manage.
14
+ */
15
+ constructor(db, storeName) {
16
+ this.db = db;
17
+ this.storeName = storeName;
18
+ }
19
+ /**
20
+ * Retrieves a single record by its primary key.
21
+ *
22
+ * @param id The primary key of the record to retrieve.
23
+ * @returns A promise resolving to the typed record, or `undefined` if not found.
24
+ */
25
+ async findById(id) {
26
+ return this.db.get(this.storeName, id);
27
+ }
28
+ /**
29
+ * Retrieves all records currently held in the object store.
30
+ *
31
+ * @returns A promise resolving to an array of all typed records.
32
+ */
33
+ async findAll() {
34
+ return this.db.findAll(this.storeName);
35
+ }
36
+ /**
37
+ * Inserts a new record into the object store.
38
+ *
39
+ * @param value The object payload to insert.
40
+ * @param key An optional explicit primary key.
41
+ * @returns A promise resolving to the newly inserted record.
42
+ */
43
+ async add(value, key) {
44
+ return this.db.add(this.storeName, value, key);
45
+ }
46
+ /**
47
+ * Inserts or updates an existing record in the object store.
48
+ *
49
+ * @param value The complete object to upsert.
50
+ * @param key An optional explicit primary key.
51
+ * @returns A promise resolving to the upserted record.
52
+ */
53
+ async put(value, key) {
54
+ return this.db.put(this.storeName, value, key);
55
+ }
56
+ /**
57
+ * Removes a record from the object store by its primary key.
58
+ *
59
+ * @param key The primary key of the record to delete.
60
+ * @returns A promise resolving when the deletion is complete.
61
+ */
62
+ async delete(key) {
63
+ return this.db.delete(this.storeName, key);
64
+ }
65
+ /**
66
+ * Discards all records present in the object store.
67
+ *
68
+ * @returns A promise resolving when the store has been completely cleared.
69
+ */
70
+ async clear() {
71
+ return this.db.clear(this.storeName);
72
+ }
73
+ }
74
+ //# sourceMappingURL=Repository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Repository.js","sourceRoot":"","sources":["../src/Repository.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,OAAO,UAAU;IAQX;IACM;IARjB;;;;;OAKG;IACH,YACW,EAAU,EACJ,SAAiB;QADvB,OAAE,GAAF,EAAE,CAAQ;QACJ,cAAS,GAAT,SAAS,CAAQ;IAC/B,CAAC;IAEJ;;;;;OAKG;IACH,KAAK,CAAC,QAAQ,CAAC,EAAmB;QACjC,OAAO,IAAI,CAAC,EAAE,CAAC,GAAG,CAAI,IAAI,CAAC,SAAS,EAAE,EAAE,CAAC,CAAA;IAC1C,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,OAAO;QACZ,OAAO,IAAI,CAAC,EAAE,CAAC,OAAO,CAAI,IAAI,CAAC,SAAS,CAAC,CAAA;IAC1C,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,GAAG,CAAC,KAAiB,EAAE,GAAqB;QACjD,OAAO,IAAI,CAAC,EAAE,CAAC,GAAG,CAAI,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,GAAG,CAAC,CAAA;IAClD,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,GAAG,CAAC,KAAQ,EAAE,GAAqB;QACxC,OAAO,IAAI,CAAC,EAAE,CAAC,GAAG,CAAI,IAAI,CAAC,SAAS,EAAE,KAAK,EAAE,GAAG,CAAC,CAAA;IAClD,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,MAAM,CAAC,GAAoB;QAChC,OAAO,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,CAAC,CAAA;IAC3C,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,KAAK;QACV,OAAO,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IACrC,CAAC;CACD"}
@@ -0,0 +1,13 @@
1
+ import type { BackendAdapter, SyncPullResult } from "./types.js";
2
+ export interface RestAdapterConfig {
3
+ url: string;
4
+ }
5
+ export declare class RestAdapter implements BackendAdapter {
6
+ private config;
7
+ constructor(config: RestAdapterConfig);
8
+ checkAuth(): Promise<boolean>;
9
+ login(email: string, code: string): Promise<boolean>;
10
+ logout(): Promise<void>;
11
+ pull(cursor: string): Promise<SyncPullResult>;
12
+ push(payload: any[]): Promise<void>;
13
+ }
@@ -0,0 +1,43 @@
1
+ export class RestAdapter {
2
+ config;
3
+ constructor(config) {
4
+ this.config = config;
5
+ }
6
+ async checkAuth() {
7
+ const res = await fetch(`${this.config.url}/api/session`, { credentials: "include" });
8
+ return res.ok;
9
+ }
10
+ async login(email, code) {
11
+ const res = await fetch(`${this.config.url}/api/session/login`, {
12
+ method: "POST",
13
+ headers: { "Content-Type": "application/json" },
14
+ credentials: "include",
15
+ body: JSON.stringify({ email, code }),
16
+ });
17
+ if (!res.ok)
18
+ throw new Error("Login failed");
19
+ return true;
20
+ }
21
+ async logout() {
22
+ await fetch(`${this.config.url}/api/session/logout`, { method: "POST", credentials: "include" });
23
+ }
24
+ async pull(cursor) {
25
+ const res = await fetch(`${this.config.url}/api/posts?after=${cursor}&limit=40`, {
26
+ credentials: "include",
27
+ });
28
+ if (!res.ok)
29
+ throw { status: res.status };
30
+ return await res.json();
31
+ }
32
+ async push(payload) {
33
+ const res = await fetch(`${this.config.url}/api/posts/upsert-many`, {
34
+ method: "POST",
35
+ headers: { "Content-Type": "application/json" },
36
+ credentials: "include",
37
+ body: JSON.stringify(payload),
38
+ });
39
+ if (!res.ok)
40
+ throw { status: res.status };
41
+ }
42
+ }
43
+ //# sourceMappingURL=RestAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RestAdapter.js","sourceRoot":"","sources":["../../src/adapters/RestAdapter.ts"],"names":[],"mappings":"AAMA,MAAM,OAAO,WAAW;IACH;IAApB,YAAoB,MAAyB;QAAzB,WAAM,GAAN,MAAM,CAAmB;IAAG,CAAC;IAE1C,KAAK,CAAC,SAAS;QACrB,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,cAAc,EAAE,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC,CAAA;QACrF,OAAO,GAAG,CAAC,EAAE,CAAA;IACd,CAAC;IAEM,KAAK,CAAC,KAAK,CAAC,KAAa,EAAE,IAAY;QAC7C,MAAM,GAAG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,CAAC,EAAE;YAAE,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAA;IAC1C,CAAC;CACD"}
@@ -0,0 +1,2 @@
1
+ export * from "./RestAdapter.js";
2
+ export * from "./types.js";
@@ -0,0 +1,3 @@
1
+ export * from "./RestAdapter.js";
2
+ export * from "./types.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA"}
@@ -0,0 +1,11 @@
1
+ export interface SyncPullResult {
2
+ items: any[];
3
+ hasMore: boolean;
4
+ }
5
+ export interface BackendAdapter {
6
+ checkAuth(): Promise<boolean>;
7
+ login(email: string, code: string): Promise<boolean>;
8
+ logout(): Promise<void>;
9
+ pull(cursor: string): Promise<SyncPullResult>;
10
+ push(payload: any[]): Promise<void>;
11
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/adapters/types.ts"],"names":[],"mappings":""}
package/esm/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from "./DbRepository.js";
2
+ export * from "./DbSync.js";
3
+ export * from "./DbTxRepository.js";
package/esm/index.js ADDED
@@ -0,0 +1,4 @@
1
+ export * from "./DbRepository.js";
2
+ export * from "./DbSync.js";
3
+ export * from "./DbTxRepository.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA;AAC3B,cAAc,qBAAqB,CAAA"}
@@ -0,0 +1,13 @@
1
+ import type { BackendAdapter } from "../adapters/types.js";
2
+ import type { StorageManager } from "./StorageManager.js";
3
+ export declare class AuthManager {
4
+ private adapter;
5
+ private storage;
6
+ private disableSync;
7
+ isAuth: boolean;
8
+ constructor(adapter: BackendAdapter, storage: StorageManager, disableSync: () => void);
9
+ checkAuth(): Promise<boolean>;
10
+ login(email: string, code: string): Promise<void>;
11
+ logout(): Promise<void>;
12
+ reset(): Promise<void>;
13
+ }