@slimr/dbsync 0.0.3 → 0.0.5

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 CHANGED
@@ -27,9 +27,9 @@ You instantiate `dbsync` by supplying your backend [adapter](./src/adapters/Adap
27
27
 
28
28
  ```typescript
29
29
  import { DbSync } from '@slimr/dbsync';
30
- import { RestAdapter } from '@slimr/dbsync/adapters';
30
+ import { LocalAdapter, RestAdapter } from '@slimr/dbsync/adapters';
31
31
 
32
- const dbAdapter = new RestAdapter({ url: 'https://api.myapp.com' });
32
+ const dbAdapter = process.env.TEST ? new LocalAdapter() : new RestAdapter({ url: 'https://api.myapp.com' });
33
33
 
34
34
  const db = new DbSync({
35
35
  adapter: dbAdapter,
@@ -43,6 +43,8 @@ const db = new DbSync({
43
43
  await db.init();
44
44
  ```
45
45
 
46
+ > **Local-Only No-Sync Database:** If you want all the IndexedDB ORM and reactive features, but completely lack a remote database to sync to, simply import `LocalAdapter` from `@slimr/dbsync/adapters` and pass that into the constructor instead. It acts as an empty black box so your operations succeed cleanly entirely on the client.
47
+
46
48
  ## Schema Versioning
47
49
 
48
50
  `@slimr/dbsync` automatically manages your IndexedDB database versioning to prevent schema mismatches and corruption across tabs and devices.
@@ -0,0 +1,18 @@
1
+ import type { BackendAdapter, SyncPullResult } from "./types.js";
2
+ /**
3
+ * A no-op network adapter for pure local-only usage.
4
+ * Satisfies the DbSync adapter requirement and silently discards sync operations
5
+ * so your local `dirtyQueue` doesn't grow infinitely if synchronization is enabled.
6
+ */
7
+ export declare class LocalAdapter implements BackendAdapter {
8
+ /** Always returns true so session checks pass locally. */
9
+ checkAuth(): Promise<boolean>;
10
+ /** Always resolves true to mimic successful mock logins. */
11
+ login(): Promise<boolean>;
12
+ /** Does nothing natively. */
13
+ logout(): Promise<void>;
14
+ /** Returns an empty payload because there is no remote source of truth. */
15
+ pull(): Promise<SyncPullResult>;
16
+ /** Silently drops write payloads into the void. */
17
+ push(): Promise<void>;
18
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LocalAdapter = void 0;
4
+ /**
5
+ * A no-op network adapter for pure local-only usage.
6
+ * Satisfies the DbSync adapter requirement and silently discards sync operations
7
+ * so your local `dirtyQueue` doesn't grow infinitely if synchronization is enabled.
8
+ */
9
+ class LocalAdapter {
10
+ /** Always returns true so session checks pass locally. */
11
+ async checkAuth() {
12
+ return true;
13
+ }
14
+ /** Always resolves true to mimic successful mock logins. */
15
+ async login() {
16
+ return true;
17
+ }
18
+ /** Does nothing natively. */
19
+ async logout() { }
20
+ /** Returns an empty payload because there is no remote source of truth. */
21
+ async pull() {
22
+ return { items: [], hasMore: false };
23
+ }
24
+ /** Silently drops write payloads into the void. */
25
+ async push() { }
26
+ }
27
+ exports.LocalAdapter = LocalAdapter;
28
+ //# sourceMappingURL=LocalAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocalAdapter.js","sourceRoot":"","sources":["../../src/adapters/LocalAdapter.ts"],"names":[],"mappings":";;;AAEA;;;;GAIG;AACH,MAAa,YAAY;IACxB,0DAA0D;IAC1D,KAAK,CAAC,SAAS;QACd,OAAO,IAAI,CAAA;IACZ,CAAC;IAED,4DAA4D;IAC5D,KAAK,CAAC,KAAK;QACV,OAAO,IAAI,CAAA;IACZ,CAAC;IAED,6BAA6B;IAC7B,KAAK,CAAC,MAAM,KAAmB,CAAC;IAEhC,2EAA2E;IAC3E,KAAK,CAAC,IAAI;QACT,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAA;IACrC,CAAC;IAED,mDAAmD;IACnD,KAAK,CAAC,IAAI,KAAmB,CAAC;CAC9B;AArBD,oCAqBC"}
@@ -1,2 +1,3 @@
1
+ export * from "./LocalAdapter.js";
1
2
  export * from "./RestAdapter.js";
2
3
  export * from "./types.js";
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./LocalAdapter.js"), exports);
17
18
  __exportStar(require("./RestAdapter.js"), exports);
18
19
  __exportStar(require("./types.js"), exports);
19
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAgC;AAChC,6CAA0B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAiC;AACjC,mDAAgC;AAChC,6CAA0B"}
@@ -0,0 +1,18 @@
1
+ import type { BackendAdapter, SyncPullResult } from "./types.js";
2
+ /**
3
+ * A no-op network adapter for pure local-only usage.
4
+ * Satisfies the DbSync adapter requirement and silently discards sync operations
5
+ * so your local `dirtyQueue` doesn't grow infinitely if synchronization is enabled.
6
+ */
7
+ export declare class LocalAdapter implements BackendAdapter {
8
+ /** Always returns true so session checks pass locally. */
9
+ checkAuth(): Promise<boolean>;
10
+ /** Always resolves true to mimic successful mock logins. */
11
+ login(): Promise<boolean>;
12
+ /** Does nothing natively. */
13
+ logout(): Promise<void>;
14
+ /** Returns an empty payload because there is no remote source of truth. */
15
+ pull(): Promise<SyncPullResult>;
16
+ /** Silently drops write payloads into the void. */
17
+ push(): Promise<void>;
18
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * A no-op network adapter for pure local-only usage.
3
+ * Satisfies the DbSync adapter requirement and silently discards sync operations
4
+ * so your local `dirtyQueue` doesn't grow infinitely if synchronization is enabled.
5
+ */
6
+ export class LocalAdapter {
7
+ /** Always returns true so session checks pass locally. */
8
+ async checkAuth() {
9
+ return true;
10
+ }
11
+ /** Always resolves true to mimic successful mock logins. */
12
+ async login() {
13
+ return true;
14
+ }
15
+ /** Does nothing natively. */
16
+ async logout() { }
17
+ /** Returns an empty payload because there is no remote source of truth. */
18
+ async pull() {
19
+ return { items: [], hasMore: false };
20
+ }
21
+ /** Silently drops write payloads into the void. */
22
+ async push() { }
23
+ }
24
+ //# sourceMappingURL=LocalAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocalAdapter.js","sourceRoot":"","sources":["../../src/adapters/LocalAdapter.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,OAAO,YAAY;IACxB,0DAA0D;IAC1D,KAAK,CAAC,SAAS;QACd,OAAO,IAAI,CAAA;IACZ,CAAC;IAED,4DAA4D;IAC5D,KAAK,CAAC,KAAK;QACV,OAAO,IAAI,CAAA;IACZ,CAAC;IAED,6BAA6B;IAC7B,KAAK,CAAC,MAAM,KAAmB,CAAC;IAEhC,2EAA2E;IAC3E,KAAK,CAAC,IAAI;QACT,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAA;IACrC,CAAC;IAED,mDAAmD;IACnD,KAAK,CAAC,IAAI,KAAmB,CAAC;CAC9B"}
@@ -1,2 +1,3 @@
1
+ export * from "./LocalAdapter.js";
1
2
  export * from "./RestAdapter.js";
2
3
  export * from "./types.js";
@@ -1,3 +1,4 @@
1
+ export * from "./LocalAdapter.js";
1
2
  export * from "./RestAdapter.js";
2
3
  export * from "./types.js";
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slimr/dbsync",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "author": "Brian Dombrowski",
5
5
  "license": "ISC",
6
6
  "private": false,