cry-synced-db-client 0.1.123 → 0.1.124

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 CHANGED
@@ -1,5 +1,9 @@
1
1
  # Versions
2
2
 
3
+ ## 0.1.124 (2026-04-08)
4
+
5
+ - Fix `ensureId` not generating `_id` when key is absent (caused `"undefined"` string ids)
6
+
3
7
  ## 0.1.123 (2026-04-08)
4
8
 
5
9
  - Falsy `_id` guard on all public DB operations with detailed `console.error` messages
package/dist/index.js CHANGED
@@ -4683,21 +4683,19 @@ var SyncedDb = class _SyncedDb {
4683
4683
  }
4684
4684
  }
4685
4685
  /**
4686
- * Ensure `_id` on a data object is never falsy.
4687
- * Replaces undefined / null / 0 / "" with a new ObjectId hex string.
4688
- * @mutates modifies the object in-place and returns it.
4689
- */
4690
- /**
4691
- * Ensure `_id` on a data object is never falsy.
4692
- * Replaces undefined / null / 0 / "" with a new ObjectId hex string.
4686
+ * Ensure `_id` on a data object is never falsy or absent.
4687
+ * Replaces undefined / null / 0 / "" / missing with a new ObjectId hex string.
4688
+ * Logs console.error only when `_id` key is present but falsy (caller bug).
4693
4689
  * @mutates — modifies the object in-place and returns it.
4694
4690
  */
4695
4691
  ensureId(data, method, collection) {
4696
- if ("_id" in data && !data._id) {
4692
+ if (!data._id) {
4697
4693
  const newId = new ObjectId2().toHexString();
4698
- console.error(
4699
- `SyncedDb.${method}("${collection}"): _id is present but falsy (${JSON.stringify(data._id)}). Replaced with "${newId}". This is a bug \u2014 the caller should provide a valid _id. Data keys: [${Object.keys(data).join(", ")}]`
4700
- );
4694
+ if ("_id" in data) {
4695
+ console.error(
4696
+ `SyncedDb.${method}("${collection}"): _id is present but falsy (${JSON.stringify(data._id)}). Replaced with "${newId}". This is a bug \u2014 the caller should provide a valid _id. Data keys: [${Object.keys(data).join(", ")}]`
4697
+ );
4698
+ }
4701
4699
  data._id = newId;
4702
4700
  }
4703
4701
  return data;
@@ -216,13 +216,9 @@ export declare class SyncedDb implements I_SyncedDb {
216
216
  */
217
217
  private warnFalsyQueryId;
218
218
  /**
219
- * Ensure `_id` on a data object is never falsy.
220
- * Replaces undefined / null / 0 / "" with a new ObjectId hex string.
221
- * @mutates modifies the object in-place and returns it.
222
- */
223
- /**
224
- * Ensure `_id` on a data object is never falsy.
225
- * Replaces undefined / null / 0 / "" with a new ObjectId hex string.
219
+ * Ensure `_id` on a data object is never falsy or absent.
220
+ * Replaces undefined / null / 0 / "" / missing with a new ObjectId hex string.
221
+ * Logs console.error only when `_id` key is present but falsy (caller bug).
226
222
  * @mutates — modifies the object in-place and returns it.
227
223
  */
228
224
  private ensureId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cry-synced-db-client",
3
- "version": "0.1.123",
3
+ "version": "0.1.124",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",