@aiao/rxdb-query-builder 0.0.11 → 0.0.13

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.
Files changed (2) hide show
  1. package/dist/index.js +145 -145
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import { v4 as U } from "uuid";
2
2
  import { BehaviorSubject as W, map as k, distinctUntilChanged as $ } from "rxjs";
3
3
  import { RelationKind as B, PropertyType as g } from "@aiao/rxdb";
4
- function v(s) {
5
- return "combinator" in s && "rules" in s;
4
+ function v(n) {
5
+ return "combinator" in n && "rules" in n;
6
6
  }
7
- function M(s) {
8
- return "field" in s && "operator" in s;
7
+ function M(n) {
8
+ return "field" in n && "operator" in n;
9
9
  }
10
10
  const O = [
11
11
  // 相等操作符
@@ -136,41 +136,41 @@ const O = [
136
136
  applicableTypes: ["relation"]
137
137
  }
138
138
  ];
139
- function ye(s, e = O) {
140
- return e.filter((t) => t.applicableTypes.includes(s));
139
+ function ye(n, e = O) {
140
+ return e.filter((t) => t.applicableTypes.includes(n));
141
141
  }
142
- function D(s) {
143
- return s == null || Array.isArray(s);
142
+ function D(n) {
143
+ return n == null || Array.isArray(n);
144
144
  }
145
145
  const Y = [
146
146
  {
147
147
  name: "stringType",
148
148
  appliesTo: ["string"],
149
149
  message: "值必须是字符串类型",
150
- validate: (s) => D(s.value) ? !0 : typeof s.value == "string"
150
+ validate: (n) => D(n.value) ? !0 : typeof n.value == "string"
151
151
  },
152
152
  {
153
153
  name: "numberType",
154
154
  appliesTo: ["number"],
155
155
  message: "值必须是数字类型",
156
- validate: (s) => D(s.value) ? !0 : typeof s.value == "number" && !isNaN(s.value)
156
+ validate: (n) => D(n.value) ? !0 : typeof n.value == "number" && !isNaN(n.value)
157
157
  },
158
158
  {
159
159
  name: "booleanType",
160
160
  appliesTo: ["boolean"],
161
161
  message: "值必须是布尔类型",
162
- validate: (s) => D(s.value) ? !0 : typeof s.value == "boolean"
162
+ validate: (n) => D(n.value) ? !0 : typeof n.value == "boolean"
163
163
  },
164
164
  {
165
165
  name: "dateType",
166
166
  appliesTo: ["date"],
167
167
  message: "值必须是有效日期",
168
- validate: (s) => {
169
- if (D(s.value)) return !0;
170
- if (s.value instanceof Date)
171
- return !isNaN(s.value.getTime());
172
- if (typeof s.value == "string") {
173
- const e = new Date(s.value);
168
+ validate: (n) => {
169
+ if (D(n.value)) return !0;
170
+ if (n.value instanceof Date)
171
+ return !isNaN(n.value.getTime());
172
+ if (typeof n.value == "string") {
173
+ const e = new Date(n.value);
174
174
  return !isNaN(e.getTime());
175
175
  }
176
176
  return !1;
@@ -188,8 +188,8 @@ const Y = [
188
188
  keyValue: "object",
189
189
  json: "object"
190
190
  };
191
- function z(s, e) {
192
- return e?.displayName ? e.displayName : s.replace(/([A-Z])/g, " $1").replace(/^./, (t) => t.toUpperCase()).trim();
191
+ function z(n, e) {
192
+ return e?.displayName ? e.displayName : n.replace(/([A-Z])/g, " $1").replace(/^./, (t) => t.toUpperCase()).trim();
193
193
  }
194
194
  class x {
195
195
  options;
@@ -221,18 +221,18 @@ class x {
221
221
  for (const r of e.properties) {
222
222
  if (!this.options.includeForeignKeys && e.isForeignKey(r.name))
223
223
  continue;
224
- const n = this.parseProperty(r);
225
- n && this.options.fieldFilter(n) && t.push(n);
224
+ const s = this.parseProperty(r);
225
+ s && this.options.fieldFilter(s) && t.push(s);
226
226
  }
227
227
  if (this.options.includeComputedProperties)
228
228
  for (const r of e.computedProperties) {
229
- const n = this.parseProperty(r);
230
- n && this.options.fieldFilter(n) && t.push(n);
229
+ const s = this.parseProperty(r);
230
+ s && this.options.fieldFilter(s) && t.push(s);
231
231
  }
232
232
  if (this.options.includeRelations && e.relations)
233
233
  for (const r of e.relations) {
234
- const n = this.parseRelation(r);
235
- n && this.options.fieldFilter(n) && t.push(n);
234
+ const s = this.parseRelation(r);
235
+ s && this.options.fieldFilter(s) && t.push(s);
236
236
  }
237
237
  return t;
238
238
  }
@@ -244,8 +244,8 @@ class x {
244
244
  */
245
245
  parseMany(e) {
246
246
  const t = /* @__PURE__ */ new Map();
247
- for (const [r, n] of e)
248
- t.set(r, this.parse(n));
247
+ for (const [r, s] of e)
248
+ t.set(r, this.parse(s));
249
249
  return t;
250
250
  }
251
251
  /**
@@ -282,21 +282,21 @@ class x {
282
282
  relationKind: e.kind
283
283
  };
284
284
  if (this.options.entityMetadataMap) {
285
- const r = e.mappedEntity, n = this.options.entityMetadataMap.get(r);
286
- if (n) {
285
+ const r = e.mappedEntity, s = this.options.entityMetadataMap.get(r);
286
+ if (s) {
287
287
  const a = new x({
288
288
  ...this.options,
289
289
  includeRelations: !1
290
290
  // 防止无限递归
291
291
  });
292
- t.relationFields = a.parse(n);
292
+ t.relationFields = a.parse(s);
293
293
  }
294
294
  }
295
295
  return t;
296
296
  }
297
297
  }
298
- function _(s) {
299
- return new x(s);
298
+ function _(n) {
299
+ return new x(n);
300
300
  }
301
301
  function E() {
302
302
  return U();
@@ -383,8 +383,8 @@ class Z {
383
383
  };
384
384
  }
385
385
  }
386
- function H(s) {
387
- return new Z(s);
386
+ function H(n) {
387
+ return new Z(n);
388
388
  }
389
389
  class C {
390
390
  operators;
@@ -479,8 +479,8 @@ class C {
479
479
  getForField(e) {
480
480
  const t = this.getForType(e.type);
481
481
  if (e.nullable) {
482
- const r = t.some((o) => o.key === "null"), n = t.some((o) => o.key === "notNull"), a = this.operators.get("null"), l = this.operators.get("notNull"), i = [...t];
483
- return !r && a && i.push(a), !n && l && i.push(l), i;
482
+ const r = t.some((o) => o.key === "null"), s = t.some((o) => o.key === "notNull"), a = this.operators.get("null"), l = this.operators.get("notNull"), i = [...t];
483
+ return !r && a && i.push(a), !s && l && i.push(l), i;
484
484
  }
485
485
  return t;
486
486
  }
@@ -530,19 +530,19 @@ class C {
530
530
  this.operators.set(e.key, e);
531
531
  }
532
532
  }
533
- function J(s) {
534
- return new C(s);
533
+ function J(n) {
534
+ return new C(n);
535
535
  }
536
536
  let P = null;
537
537
  function ee() {
538
538
  return P || (P = new C()), P;
539
539
  }
540
- function te(s) {
541
- return typeof s == "object" && s !== null && "where" in s;
540
+ function te(n) {
541
+ return typeof n == "object" && n !== null && "where" in n;
542
542
  }
543
- function j(s) {
544
- if ("value" in s)
545
- return s.value;
543
+ function j(n) {
544
+ if ("value" in n)
545
+ return n.value;
546
546
  }
547
547
  class re {
548
548
  rules;
@@ -559,10 +559,10 @@ class re {
559
559
  * 校验单条规则
560
560
  */
561
561
  validateRule(e, t) {
562
- const r = [], n = j(e), a = {
562
+ const r = [], s = j(e), a = {
563
563
  fieldType: t.type,
564
564
  operator: e.operator,
565
- value: n
565
+ value: s
566
566
  };
567
567
  this.operatorRegistry.isOperatorSupportedForField(e.operator, t) || r.push({
568
568
  field: e.field,
@@ -598,7 +598,7 @@ class re {
598
598
  });
599
599
  }
600
600
  } else {
601
- const i = this.validateValueType(n, l, e.field, t.displayName);
601
+ const i = this.validateValueType(s, l, e.field, t.displayName);
602
602
  i && r.push(i);
603
603
  }
604
604
  for (const i of this.rules.values()) {
@@ -620,21 +620,21 @@ class re {
620
620
  */
621
621
  validateGroup(e, t) {
622
622
  const r = [];
623
- for (const n of e.rules)
624
- if (v(n)) {
625
- const a = this.validateGroup(n, t);
623
+ for (const s of e.rules)
624
+ if (v(s)) {
625
+ const a = this.validateGroup(s, t);
626
626
  !a.valid && a.errors && r.push(...a.errors);
627
- } else if (M(n)) {
628
- const a = t.get(n.field);
627
+ } else if (M(s)) {
628
+ const a = t.get(s.field);
629
629
  if (!a) {
630
630
  r.push({
631
- field: n.field,
631
+ field: s.field,
632
632
  rule: "fieldExists",
633
- message: `字段 "${n.field}" 不存在`
633
+ message: `字段 "${s.field}" 不存在`
634
634
  });
635
635
  continue;
636
636
  }
637
- const l = this.validateRule(n, a);
637
+ const l = this.validateRule(s, a);
638
638
  !l.valid && l.errors && r.push(...l.errors);
639
639
  }
640
640
  return {
@@ -663,19 +663,19 @@ class re {
663
663
  /**
664
664
  * 校验值类型
665
665
  */
666
- validateValueType(e, t, r, n) {
666
+ validateValueType(e, t, r, s) {
667
667
  return t === "none" || t === "subquery" ? null : t === "array" ? !Array.isArray(e) || e.length === 0 ? {
668
668
  field: r,
669
669
  rule: "valueType",
670
- message: `${n || r}需要提供一个或多个值`
670
+ message: `${s || r}需要提供一个或多个值`
671
671
  } : null : t === "range" ? !Array.isArray(e) || e.length !== 2 ? {
672
672
  field: r,
673
673
  rule: "valueType",
674
- message: `${n || r}需要提供两个值(范围)`
674
+ message: `${s || r}需要提供两个值(范围)`
675
675
  } : null : e == null || e === "" ? {
676
676
  field: r,
677
677
  rule: "valueType",
678
- message: `${n || r}需要提供一个值`
678
+ message: `${s || r}需要提供一个值`
679
679
  } : null;
680
680
  }
681
681
  /**
@@ -689,10 +689,10 @@ class re {
689
689
  const t = [];
690
690
  for (const r of e.rules)
691
691
  if (v(r)) {
692
- const n = this.validateSubqueryRules(r);
693
- t.push(...n);
692
+ const s = this.validateSubqueryRules(r);
693
+ t.push(...s);
694
694
  } else if (M(r)) {
695
- const n = j(r), a = this.operatorRegistry.getValueType(r.operator), l = this.validateValueType(n, a, r.field);
695
+ const s = j(r), a = this.operatorRegistry.getValueType(r.operator), l = this.validateValueType(s, a, r.field);
696
696
  if (l && t.push(l), a === "subquery") {
697
697
  const i = r;
698
698
  if ("where" in i && i.where) {
@@ -720,22 +720,22 @@ class re {
720
720
  return t;
721
721
  }
722
722
  }
723
- function se(s) {
724
- return new re(s);
723
+ function se(n) {
724
+ return new re(n);
725
725
  }
726
- function w(s, e) {
727
- if (s === e) return !0;
728
- if (s === null || e === null || typeof s != typeof e) return !1;
729
- if (Array.isArray(s)) {
730
- if (!Array.isArray(e) || s.length !== e.length) return !1;
731
- for (let t = 0; t < s.length; t++)
732
- if (!w(s[t], e[t])) return !1;
726
+ function w(n, e) {
727
+ if (n === e) return !0;
728
+ if (n === null || e === null || typeof n != typeof e) return !1;
729
+ if (Array.isArray(n)) {
730
+ if (!Array.isArray(e) || n.length !== e.length) return !1;
731
+ for (let t = 0; t < n.length; t++)
732
+ if (!w(n[t], e[t])) return !1;
733
733
  return !0;
734
734
  }
735
- if (typeof s == "object") {
736
- const t = s, r = e, n = Object.keys(t), a = Object.keys(r);
737
- if (n.length !== a.length) return !1;
738
- for (const l of n)
735
+ if (typeof n == "object") {
736
+ const t = n, r = e, s = Object.keys(t), a = Object.keys(r);
737
+ if (s.length !== a.length) return !1;
738
+ for (const l of s)
739
739
  if (!Object.prototype.hasOwnProperty.call(r, l) || !w(t[l], r[l])) return !1;
740
740
  return !0;
741
741
  }
@@ -785,10 +785,10 @@ class ie {
785
785
  $()
786
786
  ), this.validation$ = this.state$.pipe(
787
787
  k((r) => this.validationService.validateGroup(r.rootGroup, this.fieldsMap)),
788
- $((r, n) => r.valid === n.valid && w(r.errors, n.errors))
788
+ $((r, s) => r.valid === s.valid && w(r.errors, s.errors))
789
789
  ), this.query$ = this.state$.pipe(
790
790
  k((r) => this.queryConverter.toRxDBQuery(r)),
791
- $((r, n) => w(r, n))
791
+ $((r, s) => w(r, s))
792
792
  );
793
793
  }
794
794
  /**
@@ -839,36 +839,36 @@ class ie {
839
839
  field: t?.field ?? "",
840
840
  operator: t?.operator ?? "=",
841
841
  ...t && "value" in t ? { value: t.value } : { value: "" }
842
- }, n = this.getState(), a = this.addItemToGroup(n.rootGroup, e ?? n.rootGroup.id, r);
842
+ }, s = this.getState(), a = this.addItemToGroup(s.rootGroup, e ?? s.rootGroup.id, r);
843
843
  return this.stateSubject.next({ rootGroup: a }), r.id;
844
844
  }
845
845
  /**
846
846
  * 添加规则组
847
847
  */
848
848
  addGroup(e = null, t = V) {
849
- const r = this.getState(), n = e ?? r.rootGroup.id, a = this.getGroupDepth(r.rootGroup, n), l = this.getMaxNestingLevel();
849
+ const r = this.getState(), s = e ?? r.rootGroup.id, a = this.getGroupDepth(r.rootGroup, s), l = this.getMaxNestingLevel();
850
850
  if (a >= l)
851
851
  throw new Error(`已达到最大嵌套深度 ${l}`);
852
852
  const i = {
853
853
  id: E(),
854
854
  combinator: t,
855
855
  rules: []
856
- }, o = this.addItemToGroup(r.rootGroup, n, i);
856
+ }, o = this.addItemToGroup(r.rootGroup, s, i);
857
857
  return this.stateSubject.next({ rootGroup: o }), i.id;
858
858
  }
859
859
  /**
860
860
  * 更新规则
861
861
  */
862
862
  updateRule(e, t) {
863
- const r = this.getState(), n = this.updateItemInGroup(r.rootGroup, e, t);
864
- this.stateSubject.next({ rootGroup: n });
863
+ const r = this.getState(), s = this.updateItemInGroup(r.rootGroup, e, t);
864
+ this.stateSubject.next({ rootGroup: s });
865
865
  }
866
866
  /**
867
867
  * 更新组的组合器
868
868
  */
869
869
  updateGroupCombinator(e, t) {
870
- const r = this.getState(), n = this.updateItemInGroup(r.rootGroup, e, { combinator: t });
871
- this.stateSubject.next({ rootGroup: n });
870
+ const r = this.getState(), s = this.updateItemInGroup(r.rootGroup, e, { combinator: t });
871
+ this.stateSubject.next({ rootGroup: s });
872
872
  }
873
873
  /**
874
874
  * 删除规则或组
@@ -926,13 +926,13 @@ class ie {
926
926
  rules: [...e.rules, r]
927
927
  } : {
928
928
  ...e,
929
- rules: e.rules.map((n) => v(n) ? this.addItemToGroup(n, t, r) : n)
929
+ rules: e.rules.map((s) => v(s) ? this.addItemToGroup(s, t, r) : s)
930
930
  };
931
931
  }
932
932
  updateItemInGroup(e, t, r) {
933
933
  return e.id === t ? { ...e, ...r } : {
934
934
  ...e,
935
- rules: e.rules.map((n) => v(n) ? n.id === t ? { ...n, ...r } : this.updateItemInGroup(n, t, r) : M(n) && n.id === t ? { ...n, ...r } : n)
935
+ rules: e.rules.map((s) => v(s) ? s.id === t ? { ...s, ...r } : this.updateItemInGroup(s, t, r) : M(s) && s.id === t ? { ...s, ...r } : s)
936
936
  };
937
937
  }
938
938
  removeItemFromGroup(e, t) {
@@ -944,21 +944,21 @@ class ie {
944
944
  getGroupDepth(e, t, r = 1) {
945
945
  if (e.id === t)
946
946
  return r;
947
- for (const n of e.rules)
948
- if (v(n)) {
949
- const a = this.getGroupDepth(n, t, r + 1);
947
+ for (const s of e.rules)
948
+ if (v(s)) {
949
+ const a = this.getGroupDepth(s, t, r + 1);
950
950
  if (a > 0)
951
951
  return a;
952
952
  }
953
953
  return 0;
954
954
  }
955
955
  }
956
- function de(s) {
957
- return new ie(s);
956
+ function de(n) {
957
+ return new ie(n);
958
958
  }
959
959
  const q = "__exists__";
960
- function he(s) {
961
- const e = /* @__PURE__ */ new Set(), t = s.filter((i) => e.has(i.name) ? !1 : (e.add(i.name), !0)), r = [], n = /* @__PURE__ */ new Map(), a = [...t].sort((i, o) => {
960
+ function he(n) {
961
+ const e = /* @__PURE__ */ new Set(), t = n.filter((i) => e.has(i.name) ? !1 : (e.add(i.name), !0)), r = [], s = /* @__PURE__ */ new Map(), a = [...t].sort((i, o) => {
962
962
  const f = (i.name.match(/\./g) || []).length, y = (o.name.match(/\./g) || []).length;
963
963
  return f - y;
964
964
  }), l = /* @__PURE__ */ new Map();
@@ -982,10 +982,10 @@ function he(s) {
982
982
  // 关系字段复制 relationFields 用于子查询
983
983
  ...i.relationFields && { relationFields: i.relationFields }
984
984
  };
985
- if (n.set(i.name, p), o.length === 1)
985
+ if (s.set(i.name, p), o.length === 1)
986
986
  r.push(p);
987
987
  else {
988
- const m = o.slice(0, -1).join("."), b = n.get(m);
988
+ const m = o.slice(0, -1).join("."), b = s.get(m);
989
989
  if (b)
990
990
  b.children = b.children ?? [], b.children.push(p);
991
991
  else {
@@ -993,7 +993,7 @@ function he(s) {
993
993
  for (let T = 0; T < o.length - 1; T++) {
994
994
  const R = o[T];
995
995
  d = d ? `${d}.${R}` : R;
996
- let h = n.get(d);
996
+ let h = s.get(d);
997
997
  if (!h) {
998
998
  const S = l.get(d) ?? R;
999
999
  h = {
@@ -1003,7 +1003,7 @@ function he(s) {
1003
1003
  type: "relation",
1004
1004
  isRelation: !0,
1005
1005
  children: []
1006
- }, n.set(d, h), N.push(h);
1006
+ }, s.set(d, h), N.push(h);
1007
1007
  }
1008
1008
  h.children = h.children ?? [], N = h.children;
1009
1009
  }
@@ -1013,9 +1013,9 @@ function he(s) {
1013
1013
  }
1014
1014
  return Q(r, t), r;
1015
1015
  }
1016
- function Q(s, e) {
1016
+ function Q(n, e) {
1017
1017
  const t = new Map(e.map((r) => [r.name, r]));
1018
- for (const r of s) {
1018
+ for (const r of n) {
1019
1019
  if (r.isRelation && r.children && r.children.length > 0 && !r.children.some((a) => a.label === q)) {
1020
1020
  const l = t.get(r.value)?.relationFields;
1021
1021
  r.children.unshift({
@@ -1033,8 +1033,8 @@ function Q(s, e) {
1033
1033
  r.children && Q(r.children, e);
1034
1034
  }
1035
1035
  }
1036
- function ae(s, e) {
1037
- for (const t of s) {
1036
+ function ae(n, e) {
1037
+ for (const t of n) {
1038
1038
  if (t.value === e)
1039
1039
  return t;
1040
1040
  if (t.children) {
@@ -1043,28 +1043,28 @@ function ae(s, e) {
1043
1043
  }
1044
1044
  }
1045
1045
  }
1046
- function me(s) {
1046
+ function me(n) {
1047
1047
  const e = /* @__PURE__ */ new Map(), t = (r) => {
1048
- for (const n of r)
1049
- e.set(n.value, n), n.children && t(n.children);
1048
+ for (const s of r)
1049
+ e.set(s.value, s), s.children && t(s.children);
1050
1050
  };
1051
- return t(s), e;
1051
+ return t(n), e;
1052
1052
  }
1053
- function ge(s = 10) {
1054
- return Array(s).fill("children");
1053
+ function ge(n = 10) {
1054
+ return Array(n).fill("children");
1055
1055
  }
1056
- function be(s, e) {
1056
+ function be(n, e) {
1057
1057
  const t = e.split("."), r = [];
1058
- let n = s;
1058
+ let s = n;
1059
1059
  for (let a = 0; a < t.length; a++) {
1060
- const l = t.slice(0, a + 1).join("."), i = n.find((o) => o.value === l);
1061
- i ? (r.push(i.displayName || i.label), n = i.children ?? []) : r.push(t[a]);
1060
+ const l = t.slice(0, a + 1).join("."), i = s.find((o) => o.value === l);
1061
+ i ? (r.push(i.displayName || i.label), s = i.children ?? []) : r.push(t[a]);
1062
1062
  }
1063
1063
  return r.join(".");
1064
1064
  }
1065
1065
  const oe = 4, L = ["id", "createdAt", "updatedAt", "createdBy", "updatedBy"];
1066
- function G(s) {
1067
- switch (s) {
1066
+ function G(n) {
1067
+ switch (n) {
1068
1068
  case g.uuid:
1069
1069
  return "string";
1070
1070
  case g.string:
@@ -1086,19 +1086,19 @@ function G(s) {
1086
1086
  return "string";
1087
1087
  }
1088
1088
  }
1089
- function le(s) {
1090
- return s.kind === B.ONE_TO_MANY || s.kind === B.MANY_TO_MANY ? "mappedProperty" in s && s.mappedProperty ? [s.mappedProperty] : [] : [];
1089
+ function le(n) {
1090
+ return n.kind === B.ONE_TO_MANY || n.kind === B.MANY_TO_MANY ? [n.mappedProperty] : [];
1091
1091
  }
1092
- function ve(s, e, t = {}) {
1093
- return K(s, e, t, s, [], "", /* @__PURE__ */ new Set(), 0);
1092
+ function ve(n, e, t = {}) {
1093
+ return K(n, e, t, n, [], "", /* @__PURE__ */ new Set(), 0);
1094
1094
  }
1095
- function K(s, e, t, r, n, a, l, i) {
1095
+ function K(n, e, t, r, s, a, l, i) {
1096
1096
  const o = [], f = t.relationQueryDeep ?? oe, y = t.systemFields ?? L;
1097
- if (l.has(s.name))
1097
+ if (l.has(n.name))
1098
1098
  return o;
1099
1099
  if (!a)
1100
1100
  for (const u of y) {
1101
- const c = s.properties.find((p) => p.name === u);
1101
+ const c = n.properties.find((p) => p.name === u);
1102
1102
  c && o.push({
1103
1103
  name: u,
1104
1104
  displayName: c.displayName ?? u,
@@ -1106,7 +1106,7 @@ function K(s, e, t, r, n, a, l, i) {
1106
1106
  nullable: c.nullable ?? !1
1107
1107
  });
1108
1108
  }
1109
- for (const [u, c] of s.propertyMap) {
1109
+ for (const [u, c] of n.propertyMap) {
1110
1110
  const p = a ? `${a}.${u}` : u;
1111
1111
  o.push({
1112
1112
  name: p,
@@ -1115,10 +1115,10 @@ function K(s, e, t, r, n, a, l, i) {
1115
1115
  nullable: c.nullable ?? !1
1116
1116
  });
1117
1117
  }
1118
- for (const u of s.foreignKeyNames) {
1118
+ for (const u of n.foreignKeyNames) {
1119
1119
  const c = a ? `${a}.${u}` : u;
1120
1120
  if (!o.some((p) => p.name === c)) {
1121
- const p = u.slice(0, -2), m = s.foreignKeyRelationMap.get(p), b = m?.displayName ?? p, d = m && "nullable" in m ? m.nullable ?? !1 : !1;
1121
+ const p = u.slice(0, -2), m = n.foreignKeyRelationMap.get(p), b = m?.displayName ?? p, d = m && "nullable" in m ? m.nullable ?? !1 : !1;
1122
1122
  o.push({
1123
1123
  name: c,
1124
1124
  displayName: `${b}ID`,
@@ -1128,8 +1128,8 @@ function K(s, e, t, r, n, a, l, i) {
1128
1128
  }
1129
1129
  }
1130
1130
  if (i < f)
1131
- for (const [u, c] of s.relationMap) {
1132
- if (n.includes(u)) continue;
1131
+ for (const [u, c] of n.relationMap) {
1132
+ if (s.includes(u)) continue;
1133
1133
  const p = e.get(c.mappedEntity);
1134
1134
  if (!p || i > 0 && p.metadata === r || l.has(p.metadata.name)) continue;
1135
1135
  const m = a ? `${a}.${u}` : u, b = c.displayName || u, d = ue(p.metadata, t);
@@ -1142,7 +1142,7 @@ function K(s, e, t, r, n, a, l, i) {
1142
1142
  relationFields: d
1143
1143
  });
1144
1144
  const N = le(c), T = new Set(l);
1145
- T.add(s.name);
1145
+ T.add(n.name);
1146
1146
  const R = K(
1147
1147
  p.metadata,
1148
1148
  e,
@@ -1166,29 +1166,29 @@ function K(s, e, t, r, n, a, l, i) {
1166
1166
  }
1167
1167
  return o;
1168
1168
  }
1169
- function ue(s, e = {}) {
1169
+ function ue(n, e = {}) {
1170
1170
  const t = [], r = e.systemFields ?? L;
1171
- for (const n of r) {
1172
- const a = s.properties.find((l) => l.name === n);
1171
+ for (const s of r) {
1172
+ const a = n.properties.find((l) => l.name === s);
1173
1173
  a && t.push({
1174
- name: n,
1175
- displayName: a.displayName ?? n,
1174
+ name: s,
1175
+ displayName: a.displayName ?? s,
1176
1176
  type: G(a.type),
1177
1177
  nullable: a.nullable ?? !1
1178
1178
  });
1179
1179
  }
1180
- for (const [n, a] of s.propertyMap)
1180
+ for (const [s, a] of n.propertyMap)
1181
1181
  t.push({
1182
- name: n,
1183
- displayName: a.displayName ?? n,
1182
+ name: s,
1183
+ displayName: a.displayName ?? s,
1184
1184
  type: G(a.type),
1185
1185
  nullable: a.nullable ?? !1
1186
1186
  });
1187
- for (const n of s.foreignKeyNames)
1188
- if (!t.some((a) => a.name === n)) {
1189
- const a = n.slice(0, -2), l = s.foreignKeyRelationMap.get(a), i = l?.displayName ?? a, o = l && "nullable" in l ? l.nullable ?? !1 : !1;
1187
+ for (const s of n.foreignKeyNames)
1188
+ if (!t.some((a) => a.name === s)) {
1189
+ const a = s.slice(0, -2), l = n.foreignKeyRelationMap.get(a), i = l?.displayName ?? a, o = l && "nullable" in l ? l.nullable ?? !1 : !1;
1190
1190
  t.push({
1191
- name: n,
1191
+ name: s,
1192
1192
  displayName: `${i}ID`,
1193
1193
  type: "string",
1194
1194
  nullable: o
@@ -1196,17 +1196,17 @@ function ue(s, e = {}) {
1196
1196
  }
1197
1197
  return t;
1198
1198
  }
1199
- function Te(s) {
1200
- return [...s].sort((e, t) => {
1201
- const r = (e.name.match(/\./g) || []).length, n = (t.name.match(/\./g) || []).length;
1202
- return r !== n ? r - n : e.name.localeCompare(t.name);
1199
+ function Te(n) {
1200
+ return [...n].sort((e, t) => {
1201
+ const r = (e.name.match(/\./g) || []).length, s = (t.name.match(/\./g) || []).length;
1202
+ return r !== s ? r - s : e.name.localeCompare(t.name);
1203
1203
  });
1204
1204
  }
1205
- function Re(s, e) {
1206
- return _(e).parse(s);
1205
+ function Re(n, e) {
1206
+ return _(e).parse(n);
1207
1207
  }
1208
- function Ne(s, e) {
1209
- return _(e).parseMany(s);
1208
+ function Ne(n, e) {
1209
+ return _(e).parseMany(n);
1210
1210
  }
1211
1211
  export {
1212
1212
  Y as BUILTIN_VALIDATION_RULES,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiao/rxdb-query-builder",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -30,6 +30,6 @@
30
30
  "dependencies": {
31
31
  "rxjs": "^7.8.2",
32
32
  "uuid": "^13.0.0",
33
- "@aiao/rxdb": "0.0.11"
33
+ "@aiao/rxdb": "0.0.13"
34
34
  }
35
35
  }