@vue-skuilder/db 0.1.36 → 0.1.38

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/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.1.36",
7
+ "version": "0.1.38",
8
8
  "description": "Database layer for vue-skuilder",
9
9
  "main": "dist/index.js",
10
10
  "module": "dist/index.mjs",
@@ -48,7 +48,7 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "@nilock2/pouchdb-authentication": "^1.0.2",
51
- "@vue-skuilder/common": "0.1.36",
51
+ "@vue-skuilder/common": "0.1.38",
52
52
  "cross-fetch": "^4.1.0",
53
53
  "moment": "^2.29.4",
54
54
  "pouchdb": "^9.0.0",
@@ -62,5 +62,5 @@
62
62
  "vite": "^8.0.0",
63
63
  "vitest": "^4.1.0"
64
64
  },
65
- "stableVersion": "0.1.36"
65
+ "stableVersion": "0.1.38"
66
66
  }
@@ -686,7 +686,12 @@ Currently logged-in as ${this._username}.`
686
686
  _rev: existingDoc._rev,
687
687
  });
688
688
  } catch (e: unknown) {
689
- if (e instanceof Error && e.name === 'not_found') {
689
+ // NB: PouchDB errors are plain objects ({error, reason, status, name,
690
+ // message, ...}), not Error instances — `e instanceof Error` is false
691
+ // for them. Check `.name` directly. The outer catch at line ~697
692
+ // already does this correctly; mirror that style here so the
693
+ // not_found → "create new doc" path actually fires for fresh user DBs.
694
+ if ((e as { name?: string })?.name === 'not_found') {
690
695
  // Create new doc
691
696
  await this.remoteDB.put(doc);
692
697
  } else {
@@ -716,7 +721,10 @@ Currently logged-in as ${this._username}.`
716
721
  _rev: existingDoc._rev,
717
722
  });
718
723
  } catch (e: unknown) {
719
- if (e instanceof Error && e.name === 'conflict' && retries > 0) {
724
+ // NB: PouchDB errors are plain objects, not Error instances see
725
+ // applyDesignDocs() above. Check `.name` directly so the conflict-retry
726
+ // path actually fires.
727
+ if ((e as { name?: string })?.name === 'conflict' && retries > 0) {
720
728
  await new Promise((resolve) => setTimeout(resolve, 1000));
721
729
  return this.applyDesignDoc(doc, retries - 1);
722
730
  }