@yuneta/gobj-js 7.26.9 → 7.26.10
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/dist/gobj-js.cjs.js +21 -12
- package/dist/gobj-js.cjs.js.map +1 -1
- package/dist/gobj-js.cjs.min.js +6 -9
- package/dist/gobj-js.cjs.min.js.map +1 -1
- package/dist/gobj-js.es.js +21 -12
- package/dist/gobj-js.es.js.map +1 -1
- package/dist/gobj-js.es.min.js +6 -9
- package/dist/gobj-js.es.min.js.map +1 -1
- package/dist/gobj-js.iife.js +21 -12
- package/dist/gobj-js.iife.js.map +1 -1
- package/dist/gobj-js.iife.min.js +6 -9
- package/dist/gobj-js.iife.min.js.map +1 -1
- package/dist/gobj-js.umd.js +21 -12
- package/dist/gobj-js.umd.js.map +1 -1
- package/dist/gobj-js.umd.min.js +148 -151
- package/dist/gobj-js.umd.min.js.map +1 -1
- package/package.json +1 -1
package/dist/gobj-js.umd.js
CHANGED
|
@@ -4442,6 +4442,10 @@
|
|
|
4442
4442
|
log_error(`${gobj ? gobj_short_name(gobj) + ": " : ""}kw_set_dict_value(): path must be a string: ${String(path)}`);
|
|
4443
4443
|
return -1;
|
|
4444
4444
|
}
|
|
4445
|
+
if (path === "") {
|
|
4446
|
+
log_error(`${gobj ? gobj_short_name(gobj) + ": " : ""}kw_set_dict_value(): path empty`);
|
|
4447
|
+
return -1;
|
|
4448
|
+
}
|
|
4445
4449
|
let ss = path.split("`");
|
|
4446
4450
|
let len = ss.length;
|
|
4447
4451
|
for (let i = 0; i < len; i++) {
|
|
@@ -5231,7 +5235,7 @@
|
|
|
5231
5235
|
let schema = kw_get_dict_value(null, jdb, "schema", {}, kw_flag_t.KW_CREATE);
|
|
5232
5236
|
let topics = kw_get_dict_value(null, jdb, "topics", {}, kw_flag_t.KW_CREATE);
|
|
5233
5237
|
let walk = function(obj, key, value, full_path) {
|
|
5234
|
-
if (key.substring(0, 2) !== "__") kw_get_dict_value(null, topics, full_path, json_deep_copy(type), kw_flag_t.KW_CREATE);
|
|
5238
|
+
if (key.substring(0, 2) !== "__" && !is_object(value)) kw_get_dict_value(null, topics, full_path, json_deep_copy(type), kw_flag_t.KW_CREATE);
|
|
5235
5239
|
};
|
|
5236
5240
|
_traverse_dict(schema, walk, prefix);
|
|
5237
5241
|
return jdb;
|
|
@@ -5262,6 +5266,10 @@
|
|
|
5262
5266
|
if (is_object(v)) v = kw_get_dict_value(null, v, jdb.hook, [], kw_flag_t.KW_CREATE);
|
|
5263
5267
|
v = _jdb_get(v, null, id, false);
|
|
5264
5268
|
}
|
|
5269
|
+
if (!v || ids.length !== 0) {
|
|
5270
|
+
log_error(`jdb_update: path not found in topic '${topic_name}': '${path}'`);
|
|
5271
|
+
return null;
|
|
5272
|
+
}
|
|
5265
5273
|
if (ids.length === 0 && v) {
|
|
5266
5274
|
if (is_array(v)) v.push(kw);
|
|
5267
5275
|
else if (v["id"] === kw["id"]) json_object_update(v, kw);
|
|
@@ -5300,29 +5308,30 @@
|
|
|
5300
5308
|
if (is_object(v)) v = kw_get_dict_value(null, v, jdb.hook, null, 0);
|
|
5301
5309
|
v = _jdb_get(v, null, id, false);
|
|
5302
5310
|
}
|
|
5303
|
-
if (ids.length
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
|
|
5307
|
-
|
|
5308
|
-
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5311
|
+
if (!v || ids.length !== 0) {
|
|
5312
|
+
log_error(`jdb_delete: path not found in topic '${topic_name}': '${path}'`);
|
|
5313
|
+
return null;
|
|
5314
|
+
}
|
|
5315
|
+
let list = is_array(v) ? v : kw_get_dict_value(null, v, jdb.hook, null, 0);
|
|
5316
|
+
let idx = id_index_in_obj_list(list, kw["id"]);
|
|
5317
|
+
if (idx < 0) {
|
|
5318
|
+
log_error(`jdb_delete: record not found in topic '${topic_name}': '${path}' '${kw["id"]}'`);
|
|
5319
|
+
return null;
|
|
5312
5320
|
}
|
|
5321
|
+
list.splice(idx, 1);
|
|
5313
5322
|
return topic;
|
|
5314
5323
|
}
|
|
5315
5324
|
/********************************************
|
|
5316
5325
|
*
|
|
5317
5326
|
********************************************/
|
|
5318
5327
|
function jdb_get_topic(jdb, topic_name) {
|
|
5319
|
-
let topics = kw_get_dict_value(null, jdb, "topics", null, 0
|
|
5328
|
+
let topics = kw_get_dict_value(null, jdb, "topics", null, 0);
|
|
5320
5329
|
if (!topics) {
|
|
5321
5330
|
log_error("jdb topics section not found");
|
|
5322
5331
|
trace_msg(jdb);
|
|
5323
5332
|
return null;
|
|
5324
5333
|
}
|
|
5325
|
-
let topic = kw_get_dict_value(null, topics, topic_name, null, 0
|
|
5334
|
+
let topic = kw_get_dict_value(null, topics, topic_name, null, 0);
|
|
5326
5335
|
if (!topic) {
|
|
5327
5336
|
log_error("jdb topic not found: " + topic_name);
|
|
5328
5337
|
trace_msg(topics);
|