cry-synced-db-client 0.1.124 → 0.1.125
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/CHANGELOG.md +4 -0
- package/dist/index.js +25 -1
- package/dist/src/db/SyncedDb.d.ts +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Versions
|
|
2
2
|
|
|
3
|
+
## 0.1.125 (2026-04-08)
|
|
4
|
+
|
|
5
|
+
- Detect stringified falsy `_id` values (`"undefined"`, `"null"`, `"0"`, `"false"`, `""`) across all DB operations
|
|
6
|
+
|
|
3
7
|
## 0.1.124 (2026-04-08)
|
|
4
8
|
|
|
5
9
|
- Fix `ensureId` not generating `_id` when key is absent (caused `"undefined"` string ids)
|
package/dist/index.js
CHANGED
|
@@ -3416,7 +3416,7 @@ var NetworkStatusManager = class {
|
|
|
3416
3416
|
};
|
|
3417
3417
|
|
|
3418
3418
|
// src/db/SyncedDb.ts
|
|
3419
|
-
var
|
|
3419
|
+
var _SyncedDb = class _SyncedDb {
|
|
3420
3420
|
constructor(config) {
|
|
3421
3421
|
this.collections = /* @__PURE__ */ new Map();
|
|
3422
3422
|
// State
|
|
@@ -4669,6 +4669,11 @@ var SyncedDb = class _SyncedDb {
|
|
|
4669
4669
|
`SyncedDb.${method != null ? method : "?"}("${collection != null ? collection : "?"}"): id parameter is falsy (${JSON.stringify(id)}). This is a bug \u2014 the caller must provide a valid _id.`
|
|
4670
4670
|
);
|
|
4671
4671
|
}
|
|
4672
|
+
if (typeof id === "string" && _SyncedDb.STRINGIFIED_FALSY.has(id)) {
|
|
4673
|
+
console.error(
|
|
4674
|
+
`SyncedDb.${method != null ? method : "?"}("${collection != null ? collection : "?"}"): id is a stringified falsy value ("${id}"). This is a bug \u2014 a falsy value was coerced to string before being passed as _id.`
|
|
4675
|
+
);
|
|
4676
|
+
}
|
|
4672
4677
|
return typeof id === "object" && id !== null ? String(id) : id;
|
|
4673
4678
|
}
|
|
4674
4679
|
/**
|
|
@@ -4681,6 +4686,11 @@ var SyncedDb = class _SyncedDb {
|
|
|
4681
4686
|
`SyncedDb.${method}("${collection}"): _id is present in query/data but falsy (${JSON.stringify(data._id)}). This is a bug \u2014 _id must be valid when specified. Data keys: [${Object.keys(data).join(", ")}]`
|
|
4682
4687
|
);
|
|
4683
4688
|
}
|
|
4689
|
+
if ("_id" in data && typeof data._id === "string" && _SyncedDb.STRINGIFIED_FALSY.has(data._id)) {
|
|
4690
|
+
console.error(
|
|
4691
|
+
`SyncedDb.${method}("${collection}"): _id is a stringified falsy value ("${data._id}"). This is a bug \u2014 a falsy value was coerced to string before being passed as _id. Data keys: [${Object.keys(data).join(", ")}]`
|
|
4692
|
+
);
|
|
4693
|
+
}
|
|
4684
4694
|
}
|
|
4685
4695
|
/**
|
|
4686
4696
|
* Ensure `_id` on a data object is never falsy or absent.
|
|
@@ -4689,6 +4699,12 @@ var SyncedDb = class _SyncedDb {
|
|
|
4689
4699
|
* @mutates — modifies the object in-place and returns it.
|
|
4690
4700
|
*/
|
|
4691
4701
|
ensureId(data, method, collection) {
|
|
4702
|
+
if (typeof data._id === "string" && _SyncedDb.STRINGIFIED_FALSY.has(data._id)) {
|
|
4703
|
+
console.error(
|
|
4704
|
+
`SyncedDb.${method}("${collection}"): _id is a stringified falsy value ("${data._id}"). This is a bug \u2014 a falsy value was coerced to string before being passed as _id. Data keys: [${Object.keys(data).join(", ")}]`
|
|
4705
|
+
);
|
|
4706
|
+
data._id = null;
|
|
4707
|
+
}
|
|
4692
4708
|
if (!data._id) {
|
|
4693
4709
|
const newId = new ObjectId2().toHexString();
|
|
4694
4710
|
if ("_id" in data) {
|
|
@@ -4765,6 +4781,14 @@ var SyncedDb = class _SyncedDb {
|
|
|
4765
4781
|
);
|
|
4766
4782
|
}
|
|
4767
4783
|
};
|
|
4784
|
+
_SyncedDb.STRINGIFIED_FALSY = /* @__PURE__ */ new Set([
|
|
4785
|
+
"undefined",
|
|
4786
|
+
"null",
|
|
4787
|
+
"0",
|
|
4788
|
+
"false",
|
|
4789
|
+
""
|
|
4790
|
+
]);
|
|
4791
|
+
var SyncedDb = _SyncedDb;
|
|
4768
4792
|
|
|
4769
4793
|
// src/db/DexieDb.ts
|
|
4770
4794
|
import Dexie from "dexie";
|
|
@@ -208,6 +208,7 @@ export declare class SyncedDb implements I_SyncedDb {
|
|
|
208
208
|
private loadCollectionsToInMem;
|
|
209
209
|
private loadCollectionToInMem;
|
|
210
210
|
private assertCollection;
|
|
211
|
+
private static readonly STRINGIFIED_FALSY;
|
|
211
212
|
/** Stringify an Id parameter (ObjectId → hex string). */
|
|
212
213
|
private normalizeId;
|
|
213
214
|
/**
|