@aiao/rxdb 0.0.2 → 0.0.3

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/index.js CHANGED
@@ -1,90 +1,91 @@
1
- import { isFunction as oe, startCase as ce, get as le, isEqual as J, isSymbol as de, omitBy as he, deepFreeze as pe, isPromise as ue } from "@aiao/utils";
2
- import { v7 as fe } from "uuid";
3
- import { BehaviorSubject as N, filter as Y, distinctUntilChanged as I, switchMap as f, shareReplay as A, map as D, tap as b, firstValueFrom as S, of as j, defer as q } from "rxjs";
4
- class v extends Error {
5
- }
6
- class T {
1
+ import { v7 as de } from "uuid";
2
+ import { isFunction as te, isArray as he, startCase as pe, get as ue, isEqual as q, isSymbol as fe, omitBy as Ee, deepFreeze as ye, isPromise as me } from "@aiao/utils";
3
+ import { BehaviorSubject as w, filter as Y, distinctUntilChanged as I, switchMap as f, shareReplay as v, map as B, tap as T, firstValueFrom as M, of as j, defer as Q } from "rxjs";
4
+ class A {
7
5
  constructor(e) {
8
6
  this.entity = e;
9
7
  }
10
8
  }
11
- class U extends T {
9
+ class V extends A {
12
10
  constructor(e, t) {
13
11
  super(e), this.error = t;
14
12
  }
15
13
  }
16
- const Ee = "ENTITY_NEW";
17
- class ye extends T {
18
- type = Ee;
19
- }
20
- const V = "ENTITY_CREATE", me = `${V}_SUCCESS`, _e = `${V}_ERROR`;
21
- class ge extends T {
22
- type = V;
23
- }
24
- class be extends T {
25
- type = me;
26
- }
27
- class ve extends U {
14
+ const _e = "ENTITY_NEW";
15
+ class ge extends A {
28
16
  type = _e;
29
17
  }
30
- const K = "ENTITY_UPDATE", Te = `${K}_SUCCESS`, Ae = `${K}_ERROR`;
31
- class Oe extends T {
18
+ const K = "ENTITY_CREATE", Te = `${K}_SUCCESS`, be = `${K}_ERROR`;
19
+ class Ae extends A {
32
20
  type = K;
33
21
  }
34
- class Re extends T {
22
+ class ve extends A {
35
23
  type = Te;
36
24
  }
37
- class we extends U {
38
- type = Ae;
25
+ class Oe extends V {
26
+ type = be;
39
27
  }
40
- const W = "ENTITY_REMOVE", Ne = `${W}_SUCCESS`, xe = `${W}_ERROR`;
41
- class Me extends T {
28
+ const W = "ENTITY_UPDATE", Re = `${W}_SUCCESS`, Ne = `${W}_ERROR`;
29
+ class we extends A {
42
30
  type = W;
43
31
  }
44
- class Se extends T {
32
+ class xe extends A {
33
+ type = Re;
34
+ }
35
+ class Se extends V {
45
36
  type = Ne;
46
37
  }
47
- class Ce extends U {
48
- type = xe;
38
+ const F = "ENTITY_REMOVE", Me = `${F}_SUCCESS`, Ce = `${F}_ERROR`;
39
+ class Ie extends A {
40
+ type = F;
41
+ }
42
+ class Be extends A {
43
+ type = Me;
49
44
  }
50
- const Ie = "ENTITY_PATCH";
51
- class De extends T {
45
+ class De extends V {
46
+ type = Ce;
47
+ }
48
+ const $e = "ENTITY_PATCH";
49
+ class Pe extends A {
52
50
  constructor(e, t, s, n, i, a) {
53
51
  super(e), this.patch = t, this.inversePatch = s, this.recordAt = n, this.timeStamp = i, this.updatedBy = a;
54
52
  }
55
- type = Ie;
56
- }
57
- const F = "TRANSACTION_BEGIN", z = "TRANSACTION_COMMIT", H = "TRANSACTION_ROLLBACK";
58
- class mt {
59
- type = F;
53
+ type = $e;
60
54
  }
61
- class _t {
55
+ const z = "TRANSACTION_BEGIN", H = "TRANSACTION_COMMIT", J = "TRANSACTION_ROLLBACK";
56
+ class bt {
62
57
  type = z;
63
58
  }
64
- class gt {
59
+ class At {
65
60
  type = H;
66
61
  }
67
- const ee = "DATABASE_DELETE", Be = "DATABASE_INSERT", $e = "DATABASE_UPDATE";
62
+ class vt {
63
+ type = J;
64
+ }
65
+ const se = "DATABASE_DELETE", Ye = "DATABASE_INSERT", je = "DATABASE_UPDATE";
68
66
  class G {
69
67
  constructor(e, t) {
70
68
  this.EntityType = e, this.data = t;
71
69
  }
72
70
  }
73
- class bt extends G {
74
- type = ee;
71
+ class Ot extends G {
72
+ type = se;
75
73
  }
76
- class vt extends G {
77
- type = Be;
74
+ class Rt extends G {
75
+ type = Ye;
78
76
  }
79
- class Tt extends G {
80
- type = $e;
77
+ class Nt extends G {
78
+ type = je;
81
79
  }
82
- const te = Symbol("ɵProxy"), L = Symbol("ɵMetadata"), se = Symbol("ɵStatus"), B = Symbol("ɵStatusCheck"), ne = Symbol("ɵEntityManager"), re = Symbol("ɵEntityDeleteCheck"), x = Symbol("ɵUpdateBy"), Pe = "SYSTEM", Ye = "USER", je = (r, e) => e.sync.local?.adapter === r, Le = (r) => [F, z, H].includes(r.type), O = (r) => r[L] || r.constructor[L], m = (r) => r[se], At = (r, e, t, s) => {
80
+ const ne = Symbol("ɵProxy"), L = Symbol("ɵMetadata"), re = Symbol("ɵStatus"), D = Symbol("ɵStatusCheck"), ae = Symbol("ɵEntityManager"), ie = Symbol("ɵEntityDeleteCheck"), x = Symbol("ɵUpdateBy"), Le = "SYSTEM", ke = "USER", Ue = (r, e) => e.sync.local?.adapter === r, Ve = (r) => [z, H, J].includes(r.type), O = (r) => r[L] || r.constructor[L], m = (r) => r[re], wt = (r, e, t, s) => {
83
81
  let n = s > 1 ? void 0 : s ? Object.getOwnPropertyDescriptor(e, t) : e;
84
82
  for (let i = r.length - 1, a; i >= 0; i--)
85
83
  (a = r[i]) && (n = a(n) || n);
86
84
  return n;
87
- }, ke = () => fe(), Ue = [
85
+ }, Ke = () => de();
86
+ class b extends Error {
87
+ }
88
+ const We = [
88
89
  "id",
89
90
  "createdAt",
90
91
  "updatedAt",
@@ -92,17 +93,17 @@ const te = Symbol("ɵProxy"), L = Symbol("ɵMetadata"), se = Symbol("ɵStatus"),
92
93
  "createdBy",
93
94
  "updatedBy",
94
95
  "removedBy"
95
- ], Ve = ["rev"], Ot = (r) => !!(Ue.includes(r) || Ve.includes(r) || r.startsWith("_")), u = (r, e, t) => Object.defineProperty(r, e, {
96
+ ], Fe = ["rev"], xt = (r) => !!(We.includes(r) || Fe.includes(r) || r.startsWith("_")), u = (r, e, t) => Object.defineProperty(r, e, {
96
97
  value: t,
97
98
  enumerable: !1,
98
99
  configurable: !1,
99
100
  writable: !1
100
- }), Q = (r, e, t) => Object.defineProperty(r, e, {
101
+ }), X = (r, e, t) => Object.defineProperty(r, e, {
101
102
  value: t,
102
103
  enumerable: !1,
103
104
  configurable: !1,
104
105
  writable: !0
105
- }), w = (r, e, t) => {
106
+ }), N = (r, e, t) => {
106
107
  let s;
107
108
  const n = {
108
109
  get: () => (s = t(), n.get = () => s, s),
@@ -110,35 +111,34 @@ const te = Symbol("ɵProxy"), L = Symbol("ɵMetadata"), se = Symbol("ɵStatus"),
110
111
  configurable: !1
111
112
  };
112
113
  return Object.defineProperty(r, e, n);
113
- }, Ke = (r, e) => {
114
+ }, ze = (r, e) => {
114
115
  const t = {};
115
116
  let s = !1;
116
117
  r.defaultValueProperties.forEach((n) => {
117
- e[n.name] === void 0 && (s = !0, oe(n.default) ? t[n.name] = n.default() : t[n.name] = n.default);
118
+ e[n.name] === void 0 && (s = !0, te(n.default) ? t[n.name] = n.default() : t[n.name] = n.default);
118
119
  }), s && Object.assign(e, t);
119
- }, We = (r, e, t) => {
120
+ }, He = (r, e, t) => {
120
121
  const { propertyMap: s, foreignKeyNames: n } = O(e);
121
122
  Object.keys(t).forEach((i) => {
122
123
  s.has(i) ? r.propertyMap.get(i)?.readonly !== !0 && (e[i] = t[i]) : n.includes(i) && (e[i] = t[i]);
123
124
  });
124
125
  };
125
- var E = /* @__PURE__ */ ((r) => (r.uuid = "uuid", r.string = "string", r.number = "number", r.integer = "integer", r.boolean = "boolean", r.date = "date", r.json = "json", r))(E || {}), p = /* @__PURE__ */ ((r) => (r.ONE_TO_ONE = "1:1", r.ONE_TO_MANY = "1:m", r.MANY_TO_ONE = "m:1", r.MANY_TO_MANY = "m:n", r))(p || {}), Fe = /* @__PURE__ */ ((r) => (r.Full = "full", r.Filter = "filter", r.None = "None", r))(Fe || {});
126
- const ze = (r, e) => {
126
+ var E = /* @__PURE__ */ ((r) => (r.uuid = "uuid", r.string = "string", r.number = "number", r.integer = "integer", r.boolean = "boolean", r.date = "date", r.json = "json", r))(E || {}), p = /* @__PURE__ */ ((r) => (r.ONE_TO_ONE = "1:1", r.ONE_TO_MANY = "1:m", r.MANY_TO_ONE = "m:1", r.MANY_TO_MANY = "m:n", r))(p || {}), Je = /* @__PURE__ */ ((r) => (r.Full = "full", r.Filter = "filter", r.None = "None", r))(Je || {});
127
+ const Ge = (r, e) => {
127
128
  const t = [];
128
129
  t.push(r);
129
130
  const s = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = { ...r };
130
131
  if (a.repository = a.repository || "Repository", a.namespace = a.namespace || "public", a.properties = a.properties || [], a.relations = a.relations || [], a.indexes = a.indexes || [], e) {
131
- let o = e, c = r;
132
- for (; o !== Object.prototype && c; )
133
- o = Object.getPrototypeOf(o), c = O(o), c && t.push(c);
134
- const l = t.map((d) => d.name);
135
- l.shift(), a.extends = l;
136
- } else
137
- a.extends = r.extends || [];
138
- return a.displayName || (a.displayName = ce(a.name).replace(" ", "")), a.relations.forEach((o) => {
139
- o.mappedNamespace = o.mappedNamespace || "public";
140
- }), t.reverse().forEach((o) => {
141
- o.properties?.forEach((c) => {
132
+ if (te(e)) {
133
+ let c = e, l = r;
134
+ for (; c !== Object.prototype && l; )
135
+ c = Object.getPrototypeOf(c), l = O(c), l && t.push(l);
136
+ } else he(e) ? t.push(...e) : t.push(e);
137
+ const o = t.map((c) => c.name);
138
+ o.shift(), a.extends = o;
139
+ }
140
+ return a.extends = a.extends || [], a.displayName || (a.displayName = pe(a.name).replace(" ", "")), t.reverse().forEach((o) => {
141
+ o.namespace = o.namespace || "public", o.properties?.forEach((c) => {
142
142
  s.set(c.name, c);
143
143
  }), o.relations?.forEach((c) => {
144
144
  if (c.mappedNamespace = c.mappedNamespace || "public", c.mappedEntity === o.name && c.mappedNamespace === o.namespace) {
@@ -147,26 +147,26 @@ const ze = (r, e) => {
147
147
  } else
148
148
  n.set(c.name, c);
149
149
  }), o.indexes?.forEach((c) => i.set(c.name, c));
150
- }), u(a, "propertyMap", s), u(a, "relationMap", n), u(a, "indexMap", i), w(
150
+ }), u(a, "propertyMap", s), u(a, "relationMap", n), u(a, "indexMap", i), N(
151
151
  a,
152
152
  "defaultValueProperties",
153
153
  () => Array.from(s.values()).filter((o) => o.default !== void 0)
154
- ), w(
154
+ ), N(
155
155
  a,
156
156
  "foreignKeyRelations",
157
157
  () => Array.from(a.relationMap.values()).filter(
158
158
  (o) => o.kind === p.MANY_TO_ONE || o.kind === p.ONE_TO_ONE
159
159
  )
160
- ), w(a, "foreignKeyRelationMap", () => {
160
+ ), N(a, "foreignKeyRelationMap", () => {
161
161
  const o = /* @__PURE__ */ new Map();
162
162
  return a.foreignKeyRelations.forEach((c) => o.set(c.name, c)), o;
163
- }), w(a, "foreignKeyNames", () => a.foreignKeyRelations.map((o) => `${o.name}Id`)), u(
163
+ }), N(a, "foreignKeyNames", () => a.foreignKeyRelations.map((o) => `${o.name}Id`)), u(
164
164
  a,
165
165
  "isForeignKey",
166
166
  (o) => o && o.endsWith("Id") && a.foreignKeyNames.includes(o)
167
167
  ), a;
168
168
  }, R = (r) => (e) => {
169
- const t = ze(r, e);
169
+ const t = Ge(r, e);
170
170
  if (u(e, L, t), r.abstract) return e;
171
171
  const s = e;
172
172
  return class extends s {
@@ -183,27 +183,72 @@ const ze = (r, e) => {
183
183
  */
184
184
  constructor(n) {
185
185
  super(n);
186
- const i = this[ne];
187
- if (!i) throw new v("need init rxdb");
188
- return Ke(t, this), n && We(t, this, n), i[te](this);
186
+ const i = this[ae];
187
+ if (!i) throw new b("need init rxdb");
188
+ return ze(t, this), n && He(t, this, n), i[ne](this);
189
189
  }
190
190
  };
191
- }, Rt = (r) => {
192
- const e = r.features || {};
193
- return R({
194
- ...r,
195
- features: {
196
- ...e,
197
- treeType: e.treeType || "adjacency-list"
198
- },
199
- repository: r.repository || "TreeRepository"
200
- });
201
191
  };
202
- var He = Object.getOwnPropertyDescriptor, Ge = (r, e, t, s) => {
203
- for (var n = s > 1 ? void 0 : s ? He(e, t) : e, i = r.length - 1, a; i >= 0; i--)
192
+ var qe = Object.getOwnPropertyDescriptor, Qe = (r, e, t, s) => {
193
+ for (var n = s > 1 ? void 0 : s ? qe(e, t) : e, i = r.length - 1, a; i >= 0; i--)
204
194
  (a = r[i]) && (n = a(n) || n);
205
195
  return n;
206
196
  };
197
+ const k = {
198
+ name: "EntityBase",
199
+ abstract: !0,
200
+ // 标记为抽象类,不会直接创建此类的实例
201
+ properties: [
202
+ {
203
+ name: "id",
204
+ type: E.uuid,
205
+ primary: !0,
206
+ // 主键
207
+ unique: !0,
208
+ // 唯一索引
209
+ readonly: !0,
210
+ // 创建后不可修改
211
+ default: () => Ke()
212
+ // 默认生成UUID
213
+ },
214
+ {
215
+ name: "createdAt",
216
+ type: E.date,
217
+ readonly: !0,
218
+ default: () => /* @__PURE__ */ new Date()
219
+ },
220
+ {
221
+ name: "updatedAt",
222
+ type: E.date,
223
+ readonly: !0,
224
+ default: () => /* @__PURE__ */ new Date()
225
+ },
226
+ {
227
+ name: "removedAt",
228
+ type: E.date,
229
+ readonly: !0,
230
+ nullable: !0
231
+ },
232
+ {
233
+ name: "createdBy",
234
+ type: E.string,
235
+ readonly: !0,
236
+ nullable: !0
237
+ },
238
+ {
239
+ name: "updatedBy",
240
+ type: E.string,
241
+ readonly: !0,
242
+ nullable: !0
243
+ },
244
+ {
245
+ name: "removedBy",
246
+ type: E.string,
247
+ readonly: !0,
248
+ nullable: !0
249
+ }
250
+ ]
251
+ };
207
252
  let $ = class {
208
253
  /**
209
254
  * 实体唯一标识符
@@ -250,100 +295,57 @@ let $ = class {
250
295
  constructor(r) {
251
296
  }
252
297
  };
253
- $ = Ge([
254
- R({
255
- name: "EntityBase",
256
- abstract: !0,
257
- // 标记为抽象类,不会直接创建此类的实例
258
- properties: [
259
- {
260
- name: "id",
261
- type: E.uuid,
262
- primary: !0,
263
- // 主键
264
- unique: !0,
265
- // 唯一索引
266
- readonly: !0,
267
- // 创建后不可修改
268
- default: () => ke()
269
- // 默认生成UUID
270
- },
271
- {
272
- name: "createdAt",
273
- type: E.date,
274
- readonly: !0,
275
- default: () => /* @__PURE__ */ new Date()
276
- },
277
- {
278
- name: "updatedAt",
279
- type: E.date,
280
- readonly: !0,
281
- default: () => /* @__PURE__ */ new Date()
282
- },
283
- {
284
- name: "removedAt",
285
- type: E.date,
286
- readonly: !0,
287
- nullable: !0
288
- },
289
- {
290
- name: "createdBy",
291
- type: E.string,
292
- readonly: !0,
293
- nullable: !0
294
- },
295
- {
296
- name: "updatedBy",
297
- type: E.string,
298
- readonly: !0,
299
- nullable: !0
300
- },
301
- {
302
- name: "removedBy",
303
- type: E.string,
304
- readonly: !0,
305
- nullable: !0
306
- }
307
- ]
308
- })
298
+ $ = Qe([
299
+ R(k)
309
300
  ], $);
310
- var Je = Object.getOwnPropertyDescriptor, qe = (r, e, t, s) => {
311
- for (var n = s > 1 ? void 0 : s ? Je(e, t) : e, i = r.length - 1, a; i >= 0; i--)
301
+ var Xe = Object.getOwnPropertyDescriptor, Ze = (r, e, t, s) => {
302
+ for (var n = s > 1 ? void 0 : s ? Xe(e, t) : e, i = r.length - 1, a; i >= 0; i--)
312
303
  (a = r[i]) && (n = a(n) || n);
313
304
  return n;
314
305
  };
315
- let X = class extends $ {
306
+ const oe = {
307
+ name: "TreeAdjacencyListEntityBase",
308
+ abstract: !0,
309
+ // 标记为抽象类,不会直接创建此类的实例
310
+ relations: [
311
+ {
312
+ name: "children",
313
+ // 子节点关系名称
314
+ kind: p.ONE_TO_MANY,
315
+ // 一对多关系
316
+ mappedEntity: "TreeAdjacencyListEntityBase",
317
+ // 关联到同一实体类型
318
+ mappedProperty: "parent"
319
+ // 映射到子实体的 parent 属性
320
+ },
321
+ {
322
+ name: "parent",
323
+ // 父节点关系名称
324
+ kind: p.MANY_TO_ONE,
325
+ // 多对一关系
326
+ mappedEntity: "TreeAdjacencyListEntityBase",
327
+ // 关联到同一实体类型
328
+ nullable: !0
329
+ // 允许根节点没有父节点
330
+ }
331
+ ]
316
332
  };
317
- X = qe([
318
- R({
319
- name: "TreeAdjacencyListEntityBase",
320
- abstract: !0,
321
- // 标记为抽象类,不会直接创建此类的实例
322
- relations: [
323
- {
324
- name: "children",
325
- // 子节点关系名称
326
- kind: p.ONE_TO_MANY,
327
- // 一对多关系
328
- mappedEntity: "TreeAdjacencyListEntityBase",
329
- // 关联到同一实体类型
330
- mappedProperty: "parent"
331
- // 映射到子实体的 parent 属性
332
- },
333
- {
334
- name: "parent",
335
- // 父节点关系名称
336
- kind: p.MANY_TO_ONE,
337
- // 多对一关系
338
- mappedEntity: "TreeAdjacencyListEntityBase",
339
- // 关联到同一实体类型
340
- nullable: !0
341
- // 允许根节点没有父节点
342
- }
343
- ]
344
- })
345
- ], X);
346
- const Qe = (r) => !!r.combinator, Xe = (r, e) => {
333
+ let Z = class extends $ {
334
+ };
335
+ Z = Ze([
336
+ R(oe)
337
+ ], Z);
338
+ const St = (r) => {
339
+ const e = r.features || {};
340
+ return R({
341
+ ...r,
342
+ features: {
343
+ ...e,
344
+ treeType: e.treeType || "adjacency-list"
345
+ },
346
+ repository: r.repository || "TreeRepository"
347
+ });
348
+ }, et = (r) => !!r.combinator, tt = (r, e) => {
347
349
  const t = e[r.field], { operator: s, value: n } = r;
348
350
  switch (s) {
349
351
  case "in":
@@ -367,9 +369,9 @@ const Qe = (r) => !!r.combinator, Xe = (r, e) => {
367
369
  case "notEndWith":
368
370
  return `${t}`.endsWith(`${n}`) === !1;
369
371
  case "=":
370
- return J(n, t);
372
+ return q(n, t);
371
373
  case "!=":
372
- return J(n, t) === !1;
374
+ return q(n, t) === !1;
373
375
  case ">":
374
376
  return t > n;
375
377
  case ">=":
@@ -379,16 +381,16 @@ const Qe = (r) => !!r.combinator, Xe = (r, e) => {
379
381
  case "<=":
380
382
  return t <= n;
381
383
  default:
382
- throw new v(`Unknown operator: ${s}`);
384
+ throw new b(`Unknown operator: ${s}`);
383
385
  }
384
- }, k = (r, e) => {
385
- if (Qe(r)) {
386
+ }, U = (r, e) => {
387
+ if (et(r)) {
386
388
  const { combinator: t, rules: s } = r;
387
- return t === "and" ? s.every((n) => k(n, e)) : s.some((n) => k(n, e));
389
+ return t === "and" ? s.every((n) => U(n, e)) : s.some((n) => U(n, e));
388
390
  } else
389
- return Xe(r, e);
390
- }, wt = (r, e) => k(e, r), Ze = (r, e, t) => {
391
- const { field: s, order: n } = t, i = le(e, s);
391
+ return tt(r, e);
392
+ }, Mt = (r, e) => U(e, r), st = (r, e, t) => {
393
+ const { field: s, order: n } = t, i = ue(e, s);
392
394
  if (n === "asc") {
393
395
  if (r.some((c) => i < Reflect.get(c, s))) return !0;
394
396
  if (r.every((c) => i > Reflect.get(c, s))) return !1;
@@ -396,10 +398,10 @@ const Qe = (r) => !!r.combinator, Xe = (r, e) => {
396
398
  if (r.some((c) => i > Reflect.get(c, s))) return !0;
397
399
  if (r.every((c) => i < Reflect.get(c, s))) return !1;
398
400
  }
399
- }, Nt = (r, e, t) => {
401
+ }, Ct = (r, e, t) => {
400
402
  if (t.length === 0) return !1;
401
403
  for (let s = 0; s < t.length; s++) {
402
- const n = t[s], i = Ze(r, e, n);
404
+ const n = t[s], i = st(r, e, n);
403
405
  if (i === void 0) {
404
406
  if (s < t.length - 1) {
405
407
  const { field: a } = n, o = Reflect.get(e, a);
@@ -409,8 +411,8 @@ const Qe = (r) => !!r.combinator, Xe = (r, e) => {
409
411
  return i;
410
412
  }
411
413
  };
412
- var et = /* @__PURE__ */ ((r) => (r.Synced = "Synced", r.Syncing = "Syncing", r.Never = "Never", r))(et || {});
413
- class xt {
414
+ var nt = /* @__PURE__ */ ((r) => (r.Synced = "Synced", r.Syncing = "Syncing", r.Never = "Never", r))(nt || {});
415
+ class It {
414
416
  constructor(e, t) {
415
417
  this.rxdb = e, this.EntityClass = t;
416
418
  }
@@ -439,12 +441,12 @@ class xt {
439
441
  * 更新实体
440
442
  */
441
443
  updateEntity(e, t) {
442
- e[x] = Pe;
444
+ e[x] = Le;
443
445
  const s = m(e);
444
446
  s.origin = { ...t }, Object.assign(e, t), e[x] = null;
445
447
  }
446
448
  }
447
- class ae {
449
+ class ce {
448
450
  constructor(e, t) {
449
451
  this.rxdb = e, this.EntityType = t;
450
452
  const s = O(t);
@@ -455,36 +457,36 @@ class ae {
455
457
  /**
456
458
  * 本地适配器
457
459
  */
458
- localAdapterSub = new N("");
460
+ localAdapterSub = new w("");
459
461
  localAdapter$ = this.localAdapterSub.asObservable().pipe(
460
462
  Y(Boolean),
461
463
  I(),
462
464
  f((e) => this.rxdb.getAdapter(e)),
463
- A(1)
465
+ v(1)
464
466
  );
465
467
  /**
466
468
  * 本地仓库
467
469
  */
468
470
  local$ = this.localAdapter$.pipe(
469
- D((e) => e.getRepository(this.EntityType)),
470
- A(1)
471
+ B((e) => e.getRepository(this.EntityType)),
472
+ v(1)
471
473
  );
472
474
  /**
473
475
  * 远程适配器
474
476
  */
475
- remoteAdapterSub = new N("");
477
+ remoteAdapterSub = new w("");
476
478
  remoteAdapter$ = this.remoteAdapterSub.asObservable().pipe(
477
479
  Y(Boolean),
478
480
  I(),
479
481
  f((e) => this.rxdb.getAdapter(e)),
480
- A(1)
482
+ v(1)
481
483
  );
482
484
  /**
483
485
  * 远程仓库
484
486
  */
485
487
  remote$ = this.remoteAdapter$.pipe(
486
- D((e) => e.getRepository(this.EntityType)),
487
- A(1)
488
+ B((e) => e.getRepository(this.EntityType)),
489
+ v(1)
488
490
  );
489
491
  /**
490
492
  * 同步配置
@@ -499,7 +501,7 @@ class ae {
499
501
  get(e, t) {
500
502
  return this.local$.pipe(
501
503
  f((s) => s.get(e, t)),
502
- b(this._setLocalEntityStatus)
504
+ T(this._setLocalEntityStatus)
503
505
  );
504
506
  }
505
507
  /**
@@ -510,7 +512,7 @@ class ae {
510
512
  findOne(e, t) {
511
513
  return this.local$.pipe(
512
514
  f((s) => s.findOne(e, t)),
513
- b((s) => s && this._setLocalEntityStatus(s))
515
+ T((s) => s && this._setLocalEntityStatus(s))
514
516
  );
515
517
  }
516
518
  /**
@@ -521,7 +523,7 @@ class ae {
521
523
  findOneOrFail(e, t) {
522
524
  return this.local$.pipe(
523
525
  f((s) => s.findOneOrFail(e, t)),
524
- b(this._setLocalEntityStatus)
526
+ T(this._setLocalEntityStatus)
525
527
  );
526
528
  }
527
529
  /**
@@ -532,7 +534,7 @@ class ae {
532
534
  find(e, t) {
533
535
  return this.local$.pipe(
534
536
  f((s) => s.find(e, t)),
535
- b(this._setLocalEntitiesStatus)
537
+ T(this._setLocalEntitiesStatus)
536
538
  );
537
539
  }
538
540
  /**
@@ -543,7 +545,7 @@ class ae {
543
545
  findAll(e, t) {
544
546
  return this.local$.pipe(
545
547
  f((s) => s.findAll(e, t)),
546
- b(this._setLocalEntitiesStatus)
548
+ T(this._setLocalEntitiesStatus)
547
549
  );
548
550
  }
549
551
  /**
@@ -554,7 +556,7 @@ class ae {
554
556
  findByCursor(e, t) {
555
557
  return this.local$.pipe(
556
558
  f((s) => s.findByCursor(e, t)),
557
- b(this._setLocalEntitiesStatus)
559
+ T(this._setLocalEntitiesStatus)
558
560
  );
559
561
  }
560
562
  /**
@@ -570,7 +572,7 @@ class ae {
570
572
  * @param entities 需要保存的实体
571
573
  */
572
574
  async transactionSave(e) {
573
- return e = Array.from(new Set(e)), (await S(this.localAdapter$)).transaction(async () => {
575
+ return e = Array.from(new Set(e)), (await M(this.localAdapter$)).transaction(async () => {
574
576
  let s;
575
577
  for (let n = 0; n < e.length; n++) {
576
578
  const i = e[n], a = m(i);
@@ -586,9 +588,9 @@ class ae {
586
588
  create(e) {
587
589
  const t = this.local$.pipe(
588
590
  f((s) => s.create(e)),
589
- b(this._setLocalEntityStatus)
591
+ T(this._setLocalEntityStatus)
590
592
  );
591
- return S(t);
593
+ return M(t);
592
594
  }
593
595
  /**
594
596
  * 更新实体
@@ -598,9 +600,9 @@ class ae {
598
600
  update(e, t) {
599
601
  const s = this.local$.pipe(
600
602
  f((n) => n.update(e, t)),
601
- b(this._setLocalEntityStatus)
603
+ T(this._setLocalEntityStatus)
602
604
  );
603
- return S(s);
605
+ return M(s);
604
606
  }
605
607
  /**
606
608
  * 删除实体
@@ -608,7 +610,7 @@ class ae {
608
610
  */
609
611
  remove(e) {
610
612
  const t = this.local$.pipe(f((s) => s.remove(e)));
611
- return S(t);
613
+ return M(t);
612
614
  }
613
615
  /**
614
616
  * 设置状态 local
@@ -616,14 +618,14 @@ class ae {
616
618
  _setLocalEntityStatus = (e) => m(e).local = !0;
617
619
  _setLocalEntitiesStatus = (e) => e.forEach(this._setLocalEntityStatus);
618
620
  }
619
- class tt extends ae {
621
+ class rt extends ce {
620
622
  /**
621
623
  * 查询子孙
622
624
  */
623
625
  findDescendants(e, t, s) {
624
626
  return this.local$.pipe(
625
627
  f((n) => n.findDescendants(e, t, s)),
626
- b(this._setLocalEntitiesStatus)
628
+ T(this._setLocalEntitiesStatus)
627
629
  );
628
630
  }
629
631
  /**
@@ -638,7 +640,7 @@ class tt extends ae {
638
640
  findAncestors(e, t, s) {
639
641
  return this.local$.pipe(
640
642
  f((n) => n.findAncestors(e, t, s)),
641
- b(this._setLocalEntitiesStatus)
643
+ T(this._setLocalEntitiesStatus)
642
644
  );
643
645
  }
644
646
  /**
@@ -648,7 +650,7 @@ class tt extends ae {
648
650
  return this.local$.pipe(f((n) => n.countAncestors(e, t, s)));
649
651
  }
650
652
  }
651
- const st = (r) => {
653
+ const at = (r) => {
652
654
  const e = m(r), t = r;
653
655
  let s = [];
654
656
  const n = () => {
@@ -658,7 +660,7 @@ const st = (r) => {
658
660
  };
659
661
  s.forEach(({ prop: h, value: y, oldValue: _, updatedBy: g }) => {
660
662
  o[h] = o[h] ?? _, c[h] = y, l === null ? l = g : l !== g && d();
661
- }), d(), e[B] = !1, s = [], t[x] = null;
663
+ }), d(), e[D] = !1, s = [], t[x] = null;
662
664
  };
663
665
  let i;
664
666
  const a = {
@@ -672,17 +674,17 @@ const st = (r) => {
672
674
  */
673
675
  set: (o, c, l, d) => {
674
676
  if (o[c] === l) return !0;
675
- if (de(c) === !1) {
676
- const h = o[x] || Ye;
677
- s.push({ updatedBy: h, prop: c, value: l, oldValue: o[c] }), e[B] = !0, e.modified = !0, clearTimeout(i), i = setTimeout(() => n(), 0);
677
+ if (fe(c) === !1) {
678
+ const h = o[x] || ke;
679
+ s.push({ updatedBy: h, prop: c, value: l, oldValue: o[c] }), e[D] = !0, e.modified = !0, clearTimeout(i), i = setTimeout(() => n(), 0);
678
680
  }
679
681
  return Reflect.set(o, c, l, d);
680
682
  }
681
683
  };
682
684
  return new Proxy(r, a);
683
- }, nt = (r, e, t) => {
685
+ }, it = (r, e, t) => {
684
686
  const s = t.rxdb.schema.getEntityType(r.mappedEntity, r.mappedNamespace);
685
- if (!s) throw new v(`mapped entity not found: ${r.mappedEntity}`);
687
+ if (!s) throw new b(`mapped entity not found: ${r.mappedEntity}`);
686
688
  const n = r.name + "Id", i = r.name + "$";
687
689
  let a;
688
690
  switch (r.kind) {
@@ -694,9 +696,9 @@ const st = (r) => {
694
696
  case p.MANY_TO_ONE:
695
697
  case p.ONE_TO_ONE:
696
698
  a = function() {
697
- const o = this, c = m(o), l = new N(o[n]), d = l.asObservable().pipe(
699
+ const o = this, c = m(o), l = new w(o[n]), d = l.asObservable().pipe(
698
700
  f((h) => h ? t.getRepository(s).get(h) : j(null)),
699
- A(1)
701
+ v(1)
700
702
  );
701
703
  return u(d, "set", (h) => {
702
704
  h || d.remove(), Reflect.get(o, n) != h.id && (c.addRelationEntity(r, h), l.next(h.id), Reflect.set(o, n, h.id));
@@ -751,7 +753,7 @@ const st = (r) => {
751
753
  case p.MANY_TO_MANY:
752
754
  a = function() {
753
755
  const o = this, c = m(o), l = r.name + "Id";
754
- if (!r.junctionEntityType) throw new v("junction entity not found");
756
+ if (!r.junctionEntityType) throw new b("junction entity not found");
755
757
  const d = t.getRepository(r.junctionEntityType).findAll({
756
758
  combinator: "and",
757
759
  rules: [
@@ -801,7 +803,7 @@ const st = (r) => {
801
803
  configurable: !1
802
804
  });
803
805
  };
804
- class rt {
806
+ class ot {
805
807
  /**
806
808
  * 创建实体状态实例
807
809
  *
@@ -821,7 +823,7 @@ class rt {
821
823
  "_snapshots",
822
824
  "patches$",
823
825
  "rxdb",
824
- B
826
+ D
825
827
  ].forEach(
826
828
  (s) => Object.defineProperty(this, s, {
827
829
  enumerable: !1,
@@ -838,7 +840,7 @@ class rt {
838
840
  * 实体变更记录的可观察对象
839
841
  * 用于发布实体变更通知
840
842
  */
841
- #t = new N([]);
843
+ #t = new w([]);
842
844
  /**
843
845
  * 实体状态快照数组
844
846
  * 用于存储实体在不同时间点的完整状态
@@ -886,7 +888,7 @@ class rt {
886
888
  * 状态检查标记
887
889
  * 用于内部状态验证
888
890
  */
889
- [B] = !1;
891
+ [D] = !1;
890
892
  /**
891
893
  * 实体原始数据
892
894
  * 用于比较变更和恢复
@@ -963,7 +965,7 @@ class rt {
963
965
  */
964
966
  addEntityPatch(e, t, s, n = Date.now()) {
965
967
  const i = performance.now(), a = { patch: e, inversePatch: t, recordAt: n, timeStamp: i, updatedBy: s };
966
- this._patches.length === 0 && this.#s.push(Object.freeze(structuredClone(this.origin))), w(a, "snapshot", () => {
968
+ this._patches.length === 0 && this.#s.push(Object.freeze(structuredClone(this.origin))), N(a, "snapshot", () => {
967
969
  const c = this._patches.findIndex((h) => h === a), l = this.#s[c];
968
970
  if (l) return l;
969
971
  let d;
@@ -973,7 +975,7 @@ class rt {
973
975
  }
974
976
  return d;
975
977
  }), this._patches.push(a), this.#t.next(this._patches);
976
- const o = new De(this.proxyTarget, e, t, n, i, s);
978
+ const o = new Pe(this.proxyTarget, e, t, n, i, s);
977
979
  this.rxdb.dispatchEvent(o);
978
980
  }
979
981
  /**
@@ -1046,7 +1048,7 @@ class rt {
1046
1048
  return t ? this.#e.get(e) : (t = /* @__PURE__ */ new Set(), this.#e.set(e, t), t);
1047
1049
  }
1048
1050
  }
1049
- class at {
1051
+ class ct {
1050
1052
  /**
1051
1053
  * 创建实体管理器实例
1052
1054
  *
@@ -1060,7 +1062,7 @@ class at {
1060
1062
  constructor(e) {
1061
1063
  this.rxdb = e, this.rxdb.options.entities.forEach((t) => {
1062
1064
  const s = O(t);
1063
- u(t.prototype, ne, this), ["get", "findOneOrFail", "find", "findOne", "findAll", "findByCursor", "count"].forEach((n) => {
1065
+ u(t.prototype, ae, this), ["get", "findOneOrFail", "find", "findOne", "findAll", "findByCursor", "count"].forEach((n) => {
1064
1066
  u(t, n, (i, a) => this.#n(t)[n](i, a));
1065
1067
  }), s.repository === "TreeRepository" && ["findDescendants", "countDescendants", "findAncestors", "countAncestors"].forEach((n) => {
1066
1068
  u(
@@ -1068,15 +1070,15 @@ class at {
1068
1070
  n,
1069
1071
  (i, a, o) => this.#n(t)[n](i, a, o)
1070
1072
  );
1071
- }), Object.keys(Z).forEach(
1072
- (n) => u(t.prototype, n, Z[n](this, t))
1073
- ), s.relationMap.forEach((n) => nt(n, t, this));
1074
- }), u(this, te, (t) => {
1073
+ }), Object.keys(ee).forEach(
1074
+ (n) => u(t.prototype, n, ee[n](this, t))
1075
+ ), s.relationMap.forEach((n) => it(n, t, this));
1076
+ }), u(this, ne, (t) => {
1075
1077
  const s = this.#i(t, { local: !1, remote: !1, modified: !0 });
1076
1078
  this.addEntityCache(s);
1077
- const n = new ye(s);
1079
+ const n = new ge(s);
1078
1080
  return this.rxdb.dispatchEvent(n), s;
1079
- }), u(this, re, (t) => {
1081
+ }), u(this, ie, (t) => {
1080
1082
  const { EntityType: s, data: n } = t;
1081
1083
  if (n.rowId) {
1082
1084
  const a = this.#a(s).get(n.rowId), o = a && this.#r(s).get(a);
@@ -1204,12 +1206,12 @@ class at {
1204
1206
  */
1205
1207
  async remove(e) {
1206
1208
  const t = e.constructor;
1207
- this.rxdb.dispatchEvent(new Me(e));
1209
+ this.rxdb.dispatchEvent(new Ie(e));
1208
1210
  try {
1209
1211
  const s = await this.#n(t).remove(e);
1210
- return this.rxdb.dispatchEvent(new Se(s)), s;
1212
+ return this.rxdb.dispatchEvent(new Be(s)), s;
1211
1213
  } catch (s) {
1212
- throw this.rxdb.dispatchEvent(new Ce(e, s)), s;
1214
+ throw this.rxdb.dispatchEvent(new De(e, s)), s;
1213
1215
  }
1214
1216
  }
1215
1217
  /**
@@ -1223,12 +1225,12 @@ class at {
1223
1225
  */
1224
1226
  async create(e) {
1225
1227
  const t = e.constructor;
1226
- this.rxdb.dispatchEvent(new ge(e));
1228
+ this.rxdb.dispatchEvent(new Ae(e));
1227
1229
  try {
1228
1230
  const s = await this.#n(t).create(e);
1229
- return this.rxdb.dispatchEvent(new be(s)), s;
1231
+ return this.rxdb.dispatchEvent(new ve(s)), s;
1230
1232
  } catch (s) {
1231
- throw this.rxdb.dispatchEvent(new ve(e, s)), s;
1233
+ throw this.rxdb.dispatchEvent(new Oe(e, s)), s;
1232
1234
  }
1233
1235
  }
1234
1236
  /**
@@ -1243,13 +1245,13 @@ class at {
1243
1245
  async update(e) {
1244
1246
  const t = e.constructor, s = m(e);
1245
1247
  if (s.modified) {
1246
- const n = he(s.target, (i, a) => i === s.origin[a]);
1247
- this.rxdb.dispatchEvent(new Oe(e));
1248
+ const n = Ee(s.target, (i, a) => i === s.origin[a]);
1249
+ this.rxdb.dispatchEvent(new we(e));
1248
1250
  try {
1249
1251
  const i = await this.#n(t).update(e, n);
1250
- return this.rxdb.dispatchEvent(new Re(i)), i;
1252
+ return this.rxdb.dispatchEvent(new xe(i)), i;
1251
1253
  } catch (i) {
1252
- throw this.rxdb.dispatchEvent(new we(e, i)), i;
1254
+ throw this.rxdb.dispatchEvent(new Se(e, i)), i;
1253
1255
  }
1254
1256
  }
1255
1257
  return e;
@@ -1281,13 +1283,13 @@ class at {
1281
1283
  let s;
1282
1284
  switch (t.repository) {
1283
1285
  case "Repository":
1284
- s = new ae(this.rxdb, e);
1286
+ s = new ce(this.rxdb, e);
1285
1287
  break;
1286
1288
  case "TreeRepository":
1287
- s = new tt(this.rxdb, e);
1289
+ s = new rt(this.rxdb, e);
1288
1290
  break;
1289
1291
  default:
1290
- throw new v("repository must be 'Repository' or 'TreeRepository'");
1292
+ throw new b("repository must be 'Repository' or 'TreeRepository'");
1291
1293
  }
1292
1294
  return this.#e.set(e, s), s;
1293
1295
  }
@@ -1325,21 +1327,21 @@ class at {
1325
1327
  * @returns 初始化后的代理实体实例
1326
1328
  */
1327
1329
  #i(e, t) {
1328
- Q(e, x, "");
1329
- const s = new rt(this.rxdb, { target: e, ...t });
1330
- Q(e, se, s);
1331
- const n = st(e);
1330
+ X(e, x, "");
1331
+ const s = new ot(this.rxdb, { target: e, ...t });
1332
+ X(e, re, s);
1333
+ const n = at(e);
1332
1334
  return u(s, "proxyTarget", n), n;
1333
1335
  }
1334
1336
  }
1335
- const Z = {
1337
+ const ee = {
1336
1338
  save: (r) => function() {
1337
1339
  return r.save(this);
1338
1340
  },
1339
1341
  remove: (r) => function() {
1340
1342
  return r.remove(this);
1341
1343
  }
1342
- }, it = (r) => {
1344
+ }, lt = (r) => {
1343
1345
  const [{ metadata: e, relation: t }, { metadata: s, relation: n }] = r, i = Array.from(/* @__PURE__ */ new Set([e.namespace, s.namespace])).sort().join("_") || void 0;
1344
1346
  return {
1345
1347
  name: Array.from(/* @__PURE__ */ new Set([e.name, s.name])).sort().join("_"),
@@ -1360,8 +1362,8 @@ const Z = {
1360
1362
  ]
1361
1363
  };
1362
1364
  };
1363
- var ot = Object.getOwnPropertyDescriptor, ct = (r, e, t, s) => {
1364
- for (var n = s > 1 ? void 0 : s ? ot(e, t) : e, i = r.length - 1, a; i >= 0; i--)
1365
+ var dt = Object.getOwnPropertyDescriptor, ht = (r, e, t, s) => {
1366
+ for (var n = s > 1 ? void 0 : s ? dt(e, t) : e, i = r.length - 1, a; i >= 0; i--)
1365
1367
  (a = r[i]) && (n = a(n) || n);
1366
1368
  return n;
1367
1369
  };
@@ -1375,7 +1377,7 @@ let P = class {
1375
1377
  patch;
1376
1378
  changedAt;
1377
1379
  };
1378
- P = ct([
1380
+ P = ht([
1379
1381
  R({
1380
1382
  name: "RxDBChange",
1381
1383
  log: !1,
@@ -1428,17 +1430,17 @@ P = ct([
1428
1430
  ]
1429
1431
  })
1430
1432
  ], P);
1431
- var lt = Object.getOwnPropertyDescriptor, dt = (r, e, t, s) => {
1432
- for (var n = s > 1 ? void 0 : s ? lt(e, t) : e, i = r.length - 1, a; i >= 0; i--)
1433
+ var pt = Object.getOwnPropertyDescriptor, ut = (r, e, t, s) => {
1434
+ for (var n = s > 1 ? void 0 : s ? pt(e, t) : e, i = r.length - 1, a; i >= 0; i--)
1433
1435
  (a = r[i]) && (n = a(n) || n);
1434
1436
  return n;
1435
1437
  };
1436
- let M = class {
1438
+ let S = class {
1437
1439
  id;
1438
1440
  name;
1439
1441
  executedAt;
1440
1442
  };
1441
- M = dt([
1443
+ S = ut([
1442
1444
  R({
1443
1445
  name: "RxDBMigration",
1444
1446
  log: !1,
@@ -1461,18 +1463,18 @@ M = dt([
1461
1463
  }
1462
1464
  ]
1463
1465
  })
1464
- ], M);
1465
- var ht = Object.getOwnPropertyDescriptor, pt = (r, e, t, s) => {
1466
- for (var n = s > 1 ? void 0 : s ? ht(e, t) : e, i = r.length - 1, a; i >= 0; i--)
1466
+ ], S);
1467
+ var ft = Object.getOwnPropertyDescriptor, Et = (r, e, t, s) => {
1468
+ for (var n = s > 1 ? void 0 : s ? ft(e, t) : e, i = r.length - 1, a; i >= 0; i--)
1467
1469
  (a = r[i]) && (n = a(n) || n);
1468
1470
  return n;
1469
1471
  };
1470
1472
  const C = (r, e) => e + ":" + r;
1471
- class ut {
1473
+ class yt {
1472
1474
  constructor(e) {
1473
1475
  this.rxdb = e;
1474
1476
  const { entities: t } = this.rxdb.options;
1475
- [P, M, ...t].forEach((s) => {
1477
+ [P, S, ...t].forEach((s) => {
1476
1478
  const n = O(s), { name: i, namespace: a } = n, o = C(i, a);
1477
1479
  this.#e.set(o, n), this.#t.set(o, s);
1478
1480
  }), this.#e.forEach((s) => {
@@ -1480,12 +1482,12 @@ class ut {
1480
1482
  n.forEach((i) => {
1481
1483
  if (i.kind === p.MANY_TO_MANY) {
1482
1484
  const a = this.findMappedRelation(s, i);
1483
- if (!a) throw new v("mapped relation not found");
1484
- const o = it([{ metadata: s, relation: i }, a]), c = C(o.name, o.namespace);
1485
+ if (!a) throw new b("mapped relation not found");
1486
+ const o = lt([{ metadata: s, relation: i }, a]), c = C(o.name, o.namespace);
1485
1487
  if (this.#e.has(c) === !1) {
1486
1488
  let l = class extends $ {
1487
1489
  };
1488
- l = pt([
1490
+ l = Et([
1489
1491
  R(o)
1490
1492
  ], l);
1491
1493
  const d = O(l);
@@ -1537,15 +1539,15 @@ class ut {
1537
1539
  * @param field 查询条件的字段
1538
1540
  */
1539
1541
  getFieldRelations(e, t) {
1540
- if (t.includes(".") === !1) throw new v(`field '${t}' 必须是关属性查询`);
1542
+ if (t.includes(".") === !1) throw new b(`field '${t}' 必须是关属性查询`);
1541
1543
  const s = [], n = t.split("."), i = n.length - 1;
1542
1544
  let a = e, o, c = !1, l = "";
1543
1545
  return n.length === 2 && n[1] == "id" && (c = a.foreignKeyRelationMap.has(n[0]), l = n[0] + "Id"), n.forEach((d, h) => {
1544
1546
  if (h === i) {
1545
- if (a.propertyMap.has(d) === !1) throw new v(`property '${d}' not found`);
1547
+ if (a.propertyMap.has(d) === !1) throw new b(`property '${d}' not found`);
1546
1548
  o = a.propertyMap.get(d);
1547
1549
  } else {
1548
- if (a.relationMap.has(d) === !1) throw new v(`relation '${d}' not found`);
1550
+ if (a.relationMap.has(d) === !1) throw new b(`relation '${d}' not found`);
1549
1551
  const y = a.relationMap.get(d);
1550
1552
  s.push({ relation: y, metadata: a }), a = this.getEntityMetadata(y.mappedEntity, y.mappedNamespace);
1551
1553
  }
@@ -1571,7 +1573,7 @@ class ut {
1571
1573
  return this.#t.get(s);
1572
1574
  }
1573
1575
  }
1574
- class Mt {
1576
+ class Bt {
1575
1577
  // 插件
1576
1578
  #e = /* @__PURE__ */ new WeakSet();
1577
1579
  // events
@@ -1581,8 +1583,8 @@ class Mt {
1581
1583
  // 适配器
1582
1584
  #r = /* @__PURE__ */ new Map();
1583
1585
  #a = /* @__PURE__ */ new Map();
1584
- #i = new N(0);
1585
- #l = this.#i.asObservable().pipe(I(), A(1));
1586
+ #i = new w(0);
1587
+ #l = this.#i.asObservable().pipe(I(), v(1));
1586
1588
  // 上下文
1587
1589
  #c = {};
1588
1590
  /**
@@ -1611,15 +1613,15 @@ class Mt {
1611
1613
  },
1612
1614
  e
1613
1615
  )
1614
- ), this.schema = new ut(this), this.em = new at(this), this.context = { ...this.options.context }, this.addEventListener(F, () => {
1616
+ ), this.schema = new yt(this), this.em = new ct(this), this.context = { ...this.options.context }, this.addEventListener(z, () => {
1615
1617
  this.#n = !0;
1616
- }), this.addEventListener(z, () => {
1617
- this.#n = !1, this.#s.forEach((s) => this.dispatchEvent(s)), this.#s = [];
1618
1618
  }), this.addEventListener(H, () => {
1619
+ this.#n = !1, this.#s.forEach((s) => this.dispatchEvent(s)), this.#s = [];
1620
+ }), this.addEventListener(J, () => {
1619
1621
  this.#n = !1, this.#s = [];
1620
1622
  });
1621
1623
  const t = this.em;
1622
- this.addEventListener(ee, (s) => t[re](s)), pe(this.options);
1624
+ this.addEventListener(se, (s) => t[ie](s)), ye(this.options);
1623
1625
  }
1624
1626
  /**
1625
1627
  * 注册适配器
@@ -1632,13 +1634,13 @@ class Mt {
1632
1634
  */
1633
1635
  getAdapter(e) {
1634
1636
  return this.#a.has(e) ? this.#a.get(e) : this.#l.pipe(
1635
- D(() => this.#r.get(e)),
1637
+ B(() => this.#r.get(e)),
1636
1638
  Y(Boolean),
1637
1639
  I(),
1638
1640
  f((t) => {
1639
1641
  if (!this.#a.has(e)) {
1640
1642
  const s = t(this);
1641
- ue(s) ? this.#a.set(e, q(() => s).pipe(A(1))) : this.#a.set(e, j(s).pipe(A(1)));
1643
+ me(s) ? this.#a.set(e, Q(() => s).pipe(v(1))) : this.#a.set(e, j(s).pipe(v(1)));
1642
1644
  }
1643
1645
  return this.#a.get(e);
1644
1646
  })
@@ -1663,9 +1665,9 @@ class Mt {
1663
1665
  connect(e) {
1664
1666
  return this.getAdapter(e).pipe(
1665
1667
  f((t) => t.connect()),
1666
- f((t) => je(e, this.options) ? q(async () => {
1667
- if (!await t.isTableExisted(M)) {
1668
- await t.createTable(M), await t.createTable(P);
1668
+ f((t) => Ue(e, this.options) ? Q(async () => {
1669
+ if (!await t.isTableExisted(S)) {
1670
+ await t.createTable(S), await t.createTable(P);
1669
1671
  for (let n = 0; n < this.options.entities.length; n++) {
1670
1672
  const i = this.options.entities[n];
1671
1673
  try {
@@ -1675,7 +1677,7 @@ class Mt {
1675
1677
  }
1676
1678
  }
1677
1679
  }
1678
- }).pipe(D(() => t)) : j(t))
1680
+ }).pipe(B(() => t)) : j(t))
1679
1681
  );
1680
1682
  }
1681
1683
  addEventListener(e, t) {
@@ -1685,7 +1687,7 @@ class Mt {
1685
1687
  this.#o(e).delete(t);
1686
1688
  }
1687
1689
  dispatchEvent(e) {
1688
- this.#n && Le(e) === !1 ? this.#s.push(e) : this.#o(e.type).forEach((t) => t.call(this, e));
1690
+ this.#n && Ve(e) === !1 ? this.#s.push(e) : this.#o(e.type).forEach((t) => t.call(this, e));
1689
1691
  }
1690
1692
  #o(e) {
1691
1693
  if (this.#t.has(e))
@@ -1696,84 +1698,92 @@ class Mt {
1696
1698
  }
1697
1699
  }
1698
1700
  }
1699
- class ie {
1701
+ class le {
1700
1702
  constructor(e) {
1701
1703
  this.rxdb = e;
1702
1704
  }
1703
1705
  }
1704
- class St extends ie {
1706
+ class Dt extends le {
1705
1707
  }
1706
- class Ct extends ie {
1708
+ class $t extends le {
1707
1709
  }
1708
- class It {
1710
+ class Pt {
1709
1711
  constructor(e) {
1710
1712
  this.rxdb = e;
1711
1713
  }
1712
1714
  }
1715
+ const mt = {
1716
+ EntityBase: [k],
1717
+ TreeAdjacencyListEntityBase: [oe, k]
1718
+ }, Yt = (r) => mt[r];
1713
1719
  export {
1714
- ee as DATABASE_DELETE,
1715
- Be as DATABASE_INSERT,
1716
- $e as DATABASE_UPDATE,
1717
- _e as ENTITY_CREATE_ERROR_EVENT,
1718
- V as ENTITY_CREATE_EVENT,
1719
- me as ENTITY_CREATE_SUCCESS_EVENT,
1720
- Ee as ENTITY_NEW_EVENT,
1721
- Ie as ENTITY_PATCH_EVENT,
1722
- xe as ENTITY_REMOVE_ERROR_EVENT,
1723
- W as ENTITY_REMOVE_EVENT,
1724
- Ne as ENTITY_REMOVE_SUCCESS_EVENT,
1725
- Ae as ENTITY_UPDATE_ERROR_EVENT,
1726
- K as ENTITY_UPDATE_EVENT,
1727
- Te as ENTITY_UPDATE_SUCCESS_EVENT,
1720
+ se as DATABASE_DELETE,
1721
+ Ye as DATABASE_INSERT,
1722
+ je as DATABASE_UPDATE,
1723
+ k as ENTITY_BASE_METADATA_OPTIONS,
1724
+ be as ENTITY_CREATE_ERROR_EVENT,
1725
+ K as ENTITY_CREATE_EVENT,
1726
+ Te as ENTITY_CREATE_SUCCESS_EVENT,
1727
+ mt as ENTITY_METADATA_MAP,
1728
+ _e as ENTITY_NEW_EVENT,
1729
+ $e as ENTITY_PATCH_EVENT,
1730
+ Ce as ENTITY_REMOVE_ERROR_EVENT,
1731
+ F as ENTITY_REMOVE_EVENT,
1732
+ Me as ENTITY_REMOVE_SUCCESS_EVENT,
1733
+ Ne as ENTITY_UPDATE_ERROR_EVENT,
1734
+ W as ENTITY_UPDATE_EVENT,
1735
+ Re as ENTITY_UPDATE_SUCCESS_EVENT,
1728
1736
  R as Entity,
1729
1737
  $ as EntityBase,
1730
- ve as EntityCreateErrorEvent,
1731
- ge as EntityCreateEvent,
1732
- be as EntityCreateSuccessEvent,
1733
- ye as EntityNewEvent,
1734
- De as EntityPatchEvent,
1735
- Ce as EntityRemoveErrorEvent,
1736
- Me as EntityRemoveEvent,
1737
- Se as EntityRemoveSuccessEvent,
1738
- we as EntityUpdateErrorEvent,
1739
- Oe as EntityUpdateEvent,
1740
- Re as EntityUpdateSuccessEvent,
1738
+ Oe as EntityCreateErrorEvent,
1739
+ Ae as EntityCreateEvent,
1740
+ ve as EntityCreateSuccessEvent,
1741
+ ge as EntityNewEvent,
1742
+ Pe as EntityPatchEvent,
1743
+ De as EntityRemoveErrorEvent,
1744
+ Ie as EntityRemoveEvent,
1745
+ Be as EntityRemoveSuccessEvent,
1746
+ Se as EntityUpdateErrorEvent,
1747
+ we as EntityUpdateEvent,
1748
+ xe as EntityUpdateSuccessEvent,
1741
1749
  E as PropertyType,
1742
1750
  p as RelationKind,
1743
- xt as RepositoryBase,
1744
- Mt as RxDB,
1745
- ie as RxDBAdapterBase,
1746
- bt as RxDBAdapterDeleteChangeEvent,
1747
- vt as RxDBAdapterInsertChangeEvent,
1748
- St as RxDBAdapterLocalBase,
1749
- Ct as RxDBAdapterRemoteBase,
1750
- Tt as RxDBAdapterUpdateChangeEvent,
1751
+ It as RepositoryBase,
1752
+ Bt as RxDB,
1753
+ le as RxDBAdapterBase,
1754
+ Ot as RxDBAdapterDeleteChangeEvent,
1755
+ Rt as RxDBAdapterInsertChangeEvent,
1756
+ Dt as RxDBAdapterLocalBase,
1757
+ $t as RxDBAdapterRemoteBase,
1758
+ Nt as RxDBAdapterUpdateChangeEvent,
1751
1759
  P as RxDBChange,
1752
- v as RxDBError,
1753
- M as RxDBMigration,
1754
- It as RxDBPluginBase,
1755
- et as SyncStatus,
1756
- Fe as SyncType,
1757
- F as TRANSACTION_BEGIN,
1758
- z as TRANSACTION_COMMIT,
1759
- H as TRANSACTION_ROLLBACK,
1760
- mt as TransactionBeginEvent,
1761
- _t as TransactionCommitEvent,
1762
- gt as TransactionRollbackEvent,
1763
- X as TreeAdjacencyListEntityBase,
1764
- Rt as TreeEntity,
1765
- At as __decorateClass,
1766
- Ke as fillDefaultValue,
1767
- We as fillInitValue,
1760
+ b as RxDBError,
1761
+ S as RxDBMigration,
1762
+ Pt as RxDBPluginBase,
1763
+ nt as SyncStatus,
1764
+ Je as SyncType,
1765
+ z as TRANSACTION_BEGIN,
1766
+ H as TRANSACTION_COMMIT,
1767
+ J as TRANSACTION_ROLLBACK,
1768
+ oe as TREE_ADJACENCY_LIST_ENTITY_BASE_OPTIONS,
1769
+ bt as TransactionBeginEvent,
1770
+ At as TransactionCommitEvent,
1771
+ vt as TransactionRollbackEvent,
1772
+ Z as TreeAdjacencyListEntityBase,
1773
+ St as TreeEntity,
1774
+ wt as __decorateClass,
1775
+ ze as fillDefaultValue,
1776
+ He as fillInitValue,
1768
1777
  O as getEntityMetadata,
1778
+ Yt as getEntityMetadataOptions,
1769
1779
  m as getEntityStatus,
1770
- Nt as isEntityEffectOrderBy,
1771
- Ot as isEntityInternalName,
1772
- wt as isEntityMatchRuleGroup,
1773
- Qe as isRuleGroup,
1780
+ Ct as isEntityEffectOrderBy,
1781
+ xt as isEntityInternalName,
1782
+ Mt as isEntityMatchRuleGroup,
1783
+ et as isRuleGroup,
1774
1784
  u as setSafeObjectKey,
1775
- w as setSafeObjectKeyLazyInitOnce,
1776
- Q as setSafeObjectWritableKey,
1777
- ze as transitionMetadata,
1778
- ke as uuid
1785
+ N as setSafeObjectKeyLazyInitOnce,
1786
+ X as setSafeObjectWritableKey,
1787
+ Ge as transitionMetadata,
1788
+ Ke as uuid
1779
1789
  };