@yuneta/gobj-js 7.26.9 → 7.26.11

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.
@@ -2135,6 +2135,7 @@ function Sl(e, t, n, r, l) {
2135
2135
  function Nl(e, t, n, r) {
2136
2136
  if (e && !el(e) && ir("GObj bad instanceof"), !Yr(t)) return ir("kw is not an object"), -1;
2137
2137
  if (!Jr(n)) return ir(`${e ? $t(e) + ": " : ""}kw_set_dict_value(): path must be a string: ${String(n)}`), -1;
2138
+ if ("" === n) return ir((e ? $t(e) + ": " : "") + "kw_set_dict_value(): path empty"), -1;
2138
2139
  let l = n.split("`"), o = l.length;
2139
2140
  for (let i = 0; i < o; i++) {
2140
2141
  let s = l[i];
@@ -2508,7 +2509,7 @@ function ro(e, t, n) {
2508
2509
  yl(null, e, "hook", "data", Vn.KW_CREATE);
2509
2510
  let l = Ol(null, e, "schema", {}, Vn.KW_CREATE), o = Ol(null, e, "topics", {}, Vn.KW_CREATE);
2510
2511
  return no(l, function(e, t, n, l) {
2511
- "__" !== t.substring(0, 2) && Ol(null, o, l, jr(r), Vn.KW_CREATE);
2512
+ "__" === t.substring(0, 2) || Yr(n) || Ol(null, o, l, jr(r), Vn.KW_CREATE);
2512
2513
  }, t), e;
2513
2514
  }
2514
2515
  function lo(e, t, n, r) {
@@ -2516,15 +2517,17 @@ function lo(e, t, n, r) {
2516
2517
  if (!l) return ir("jdb_update: topic not found: " + t), null;
2517
2518
  if (tl(r.id)) return ir("jdb_update: record without id: " + r), _r(r), null;
2518
2519
  if (!Jr(n)) return ir(`jdb_update: path must be a string: ${String(n)}`), null;
2519
- let o, i = n.split("`"), s = l;
2520
- for (; (o = i.shift()) && !tl(o) && s;) Yr(s) && (s = Ol(null, s, e.hook, [], Vn.KW_CREATE)), s = uo(s, null, o, !1);
2521
- if (0 === i.length && s) if (Br(s)) s.push(r);
2522
- else if (s.id === r.id) Dr(s, r);
2520
+ let o, i, s = n.split("`"), a = l;
2521
+ for (; (o = s.shift()) && !tl(o) && a;) Yr(a) && (a = Ol(null, a, e.hook, null, 0)), a = uo(a, null, o, !1);
2522
+ if (!a || 0 !== s.length) return ir(`jdb_update: path not found in topic '${t}': '${n}'`), null;
2523
+ if (Br(a)) i = a;
2523
2524
  else {
2524
- let t = Ol(null, s, e.hook, [], Vn.KW_CREATE), n = uo(t, e.hook, r.id, !1);
2525
- n ? Dr(n, r) : t.push(r);
2525
+ if (a.id === r.id) return Dr(a, r), l;
2526
+ if (i = Ol(null, a, e.hook, null, 0), null == i) i = [], Lr(a, e.hook, i);
2527
+ else if (!Br(i)) return ir(`jdb_update: the hook '${e.hook}' of '${n}' is not a list in topic '${t}'`), null;
2526
2528
  }
2527
- return l;
2529
+ let u = uo(i, e.hook, r.id, !1);
2530
+ return u ? Dr(u, r) : i.push(r), l;
2528
2531
  }
2529
2532
  function oo(e, t, n, r) {
2530
2533
  let l = Ol(null, Ol(null, e, "topics", null, 0), t, null, 0);
@@ -2533,14 +2536,9 @@ function oo(e, t, n, r) {
2533
2536
  if (!Jr(n)) return ir(`jdb_delete: path must be a string: ${String(n)}`), null;
2534
2537
  let o, i = n.split("`"), s = l;
2535
2538
  for (; (o = i.shift()) && !tl(o) && s;) Yr(s) && (s = Ol(null, s, e.hook, null, 0)), s = uo(s, null, o, !1);
2536
- if (0 === i.length && s) if (Br(s)) {
2537
- let e = Kl(s, r.id);
2538
- e >= 0 && s.splice(e, 1);
2539
- } else {
2540
- let t = Ol(null, s, e.hook, null, 0), n = Kl(t, r.id);
2541
- n >= 0 && t.splice(n, 1);
2542
- }
2543
- return l;
2539
+ if (!s || 0 !== i.length) return ir(`jdb_delete: path not found in topic '${t}': '${n}'`), null;
2540
+ let a = Br(s) ? s : Ol(null, s, e.hook, null, 0), u = Kl(a, r.id);
2541
+ return u < 0 ? (ir(`jdb_delete: record not found in topic '${t}': '${n}' '${r.id}'`), null) : (a.splice(u, 1), l);
2544
2542
  }
2545
2543
  function io(e, t) {
2546
2544
  let n = Ol(null, e, "topics", null, 0);