json-object-editor 0.10.507 → 0.10.508

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,3 +1,7 @@
1
+ ## 0.10.508
2
+
3
+ - Saves: `saveObject` assigns an `_id` if missing (prefers `cuid()`, fallback `$c.guid()`), ensuring history consistency
4
+
1
5
  ## CHANGELOG
2
6
 
3
7
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "json-object-editor",
3
- "version": "0.10.507",
3
+ "version": "0.10.508",
4
4
  "description": "JOE the Json Object Editor | Platform Edition",
5
5
  "main": "app.js",
6
6
  "scripts": {
@@ -168,9 +168,11 @@ MCP.tools = {
168
168
  if (!object || !object.itemtype) throw new Error("'object' with 'itemtype' is required");
169
169
  const user = (ctx.req && ctx.req.User) ? ctx.req.User : { name: 'anonymous' };
170
170
  // Ensure server-side update timestamp parity with /API/save
171
- if (!object.joeUpdated) {
172
- object.joeUpdated = new Date();
173
- }
171
+ if (!object.joeUpdated) { object.joeUpdated = new Date(); }
172
+ // Ensure a stable _id for new objects so history and events work consistently
173
+ try {
174
+ if (!object._id) { object._id = (typeof cuid === 'function') ? cuid() : ($c && $c.guid ? $c.guid() : undefined); }
175
+ } catch(_e) { /* ignore id generation errors; Mongo will assign one */ }
174
176
  const saved = await new Promise((resolve, reject) => {
175
177
  try {
176
178
  Storage.save(object, object.itemtype, function(err, data){