@aiao/rxdb 0.0.1 → 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/RxDBError.d.ts +0 -8
- package/entity/@TreeEntity.d.ts +1 -26
- package/entity/EntityBase.d.ts +2 -0
- package/entity/TreeEntityBase.d.ts +2 -0
- package/entity/entity-metadata-options.interface.d.ts +30 -10
- package/entity/transition-metadata.d.ts +2 -2
- package/index.d.ts +7 -0
- package/index.js +354 -348
- package/package.json +2 -2
- package/repository/query.interface.d.ts +0 -5
- package/repository/relation-query.interface.d.ts +62 -0
- package/rxdb-utils.d.ts +1 -1
- package/rxdb.interface.d.ts +4 -1
- package/rxdb.private.d.ts +25 -0
package/index.js
CHANGED
|
@@ -1,96 +1,91 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { BehaviorSubject as w, filter as
|
|
4
|
-
class A
|
|
5
|
-
constructor(e, t = {}) {
|
|
6
|
-
super(oe(e, t)), this.messageTemplate = e, this.data = t;
|
|
7
|
-
}
|
|
8
|
-
toString() {
|
|
9
|
-
return JSON.stringify(this);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
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 {
|
|
13
5
|
constructor(e) {
|
|
14
6
|
this.entity = e;
|
|
15
7
|
}
|
|
16
8
|
}
|
|
17
|
-
class
|
|
9
|
+
class V extends A {
|
|
18
10
|
constructor(e, t) {
|
|
19
11
|
super(e), this.error = t;
|
|
20
12
|
}
|
|
21
13
|
}
|
|
22
|
-
const
|
|
23
|
-
class
|
|
24
|
-
type = ye;
|
|
25
|
-
}
|
|
26
|
-
const V = "ENTITY_CREATE", _e = `${V}_SUCCESS`, ge = `${V}_ERROR`;
|
|
27
|
-
class be extends T {
|
|
28
|
-
type = V;
|
|
29
|
-
}
|
|
30
|
-
class Te extends T {
|
|
14
|
+
const _e = "ENTITY_NEW";
|
|
15
|
+
class ge extends A {
|
|
31
16
|
type = _e;
|
|
32
17
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
const K = "ENTITY_UPDATE", Ae = `${K}_SUCCESS`, Oe = `${K}_ERROR`;
|
|
37
|
-
class Re extends T {
|
|
18
|
+
const K = "ENTITY_CREATE", Te = `${K}_SUCCESS`, be = `${K}_ERROR`;
|
|
19
|
+
class Ae extends A {
|
|
38
20
|
type = K;
|
|
39
21
|
}
|
|
40
|
-
class
|
|
41
|
-
type =
|
|
22
|
+
class ve extends A {
|
|
23
|
+
type = Te;
|
|
42
24
|
}
|
|
43
|
-
class
|
|
44
|
-
type =
|
|
25
|
+
class Oe extends V {
|
|
26
|
+
type = be;
|
|
45
27
|
}
|
|
46
|
-
const W = "
|
|
47
|
-
class
|
|
28
|
+
const W = "ENTITY_UPDATE", Re = `${W}_SUCCESS`, Ne = `${W}_ERROR`;
|
|
29
|
+
class we extends A {
|
|
48
30
|
type = W;
|
|
49
31
|
}
|
|
50
|
-
class
|
|
51
|
-
type =
|
|
32
|
+
class xe extends A {
|
|
33
|
+
type = Re;
|
|
52
34
|
}
|
|
53
|
-
class
|
|
35
|
+
class Se extends V {
|
|
36
|
+
type = Ne;
|
|
37
|
+
}
|
|
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 {
|
|
54
43
|
type = Me;
|
|
55
44
|
}
|
|
56
|
-
|
|
57
|
-
|
|
45
|
+
class De extends V {
|
|
46
|
+
type = Ce;
|
|
47
|
+
}
|
|
48
|
+
const $e = "ENTITY_PATCH";
|
|
49
|
+
class Pe extends A {
|
|
58
50
|
constructor(e, t, s, n, i, a) {
|
|
59
51
|
super(e), this.patch = t, this.inversePatch = s, this.recordAt = n, this.timeStamp = i, this.updatedBy = a;
|
|
60
52
|
}
|
|
61
|
-
type =
|
|
62
|
-
}
|
|
63
|
-
const F = "TRANSACTION_BEGIN", z = "TRANSACTION_COMMIT", H = "TRANSACTION_ROLLBACK";
|
|
64
|
-
class gt {
|
|
65
|
-
type = F;
|
|
53
|
+
type = $e;
|
|
66
54
|
}
|
|
55
|
+
const z = "TRANSACTION_BEGIN", H = "TRANSACTION_COMMIT", J = "TRANSACTION_ROLLBACK";
|
|
67
56
|
class bt {
|
|
68
57
|
type = z;
|
|
69
58
|
}
|
|
70
|
-
class
|
|
59
|
+
class At {
|
|
71
60
|
type = H;
|
|
72
61
|
}
|
|
73
|
-
|
|
74
|
-
|
|
62
|
+
class vt {
|
|
63
|
+
type = J;
|
|
64
|
+
}
|
|
65
|
+
const se = "DATABASE_DELETE", Ye = "DATABASE_INSERT", je = "DATABASE_UPDATE";
|
|
66
|
+
class G {
|
|
75
67
|
constructor(e, t) {
|
|
76
68
|
this.EntityType = e, this.data = t;
|
|
77
69
|
}
|
|
78
70
|
}
|
|
79
|
-
class
|
|
80
|
-
type =
|
|
81
|
-
}
|
|
82
|
-
class At extends J {
|
|
83
|
-
type = $e;
|
|
71
|
+
class Ot extends G {
|
|
72
|
+
type = se;
|
|
84
73
|
}
|
|
85
|
-
class
|
|
74
|
+
class Rt extends G {
|
|
86
75
|
type = Ye;
|
|
87
76
|
}
|
|
88
|
-
|
|
77
|
+
class Nt extends G {
|
|
78
|
+
type = je;
|
|
79
|
+
}
|
|
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) => {
|
|
89
81
|
let n = s > 1 ? void 0 : s ? Object.getOwnPropertyDescriptor(e, t) : e;
|
|
90
82
|
for (let i = r.length - 1, a; i >= 0; i--)
|
|
91
83
|
(a = r[i]) && (n = a(n) || n);
|
|
92
84
|
return n;
|
|
93
|
-
},
|
|
85
|
+
}, Ke = () => de();
|
|
86
|
+
class b extends Error {
|
|
87
|
+
}
|
|
88
|
+
const We = [
|
|
94
89
|
"id",
|
|
95
90
|
"createdAt",
|
|
96
91
|
"updatedAt",
|
|
@@ -98,12 +93,12 @@ const te = Symbol("ɵProxy"), L = Symbol("ɵMetadata"), se = Symbol("ɵStatus"),
|
|
|
98
93
|
"createdBy",
|
|
99
94
|
"updatedBy",
|
|
100
95
|
"removedBy"
|
|
101
|
-
],
|
|
96
|
+
], Fe = ["rev"], xt = (r) => !!(We.includes(r) || Fe.includes(r) || r.startsWith("_")), u = (r, e, t) => Object.defineProperty(r, e, {
|
|
102
97
|
value: t,
|
|
103
98
|
enumerable: !1,
|
|
104
99
|
configurable: !1,
|
|
105
100
|
writable: !1
|
|
106
|
-
}),
|
|
101
|
+
}), X = (r, e, t) => Object.defineProperty(r, e, {
|
|
107
102
|
value: t,
|
|
108
103
|
enumerable: !1,
|
|
109
104
|
configurable: !1,
|
|
@@ -116,35 +111,34 @@ const te = Symbol("ɵProxy"), L = Symbol("ɵMetadata"), se = Symbol("ɵStatus"),
|
|
|
116
111
|
configurable: !1
|
|
117
112
|
};
|
|
118
113
|
return Object.defineProperty(r, e, n);
|
|
119
|
-
},
|
|
114
|
+
}, ze = (r, e) => {
|
|
120
115
|
const t = {};
|
|
121
116
|
let s = !1;
|
|
122
117
|
r.defaultValueProperties.forEach((n) => {
|
|
123
|
-
e[n.name] === void 0 && (s = !0,
|
|
118
|
+
e[n.name] === void 0 && (s = !0, te(n.default) ? t[n.name] = n.default() : t[n.name] = n.default);
|
|
124
119
|
}), s && Object.assign(e, t);
|
|
125
|
-
},
|
|
120
|
+
}, He = (r, e, t) => {
|
|
126
121
|
const { propertyMap: s, foreignKeyNames: n } = O(e);
|
|
127
122
|
Object.keys(t).forEach((i) => {
|
|
128
123
|
s.has(i) ? r.propertyMap.get(i)?.readonly !== !0 && (e[i] = t[i]) : n.includes(i) && (e[i] = t[i]);
|
|
129
124
|
});
|
|
130
125
|
};
|
|
131
|
-
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 || {}),
|
|
132
|
-
const
|
|
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) => {
|
|
133
128
|
const t = [];
|
|
134
129
|
t.push(r);
|
|
135
130
|
const s = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = { ...r };
|
|
136
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) {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
a.extends =
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
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) => {
|
|
148
142
|
s.set(c.name, c);
|
|
149
143
|
}), o.relations?.forEach((c) => {
|
|
150
144
|
if (c.mappedNamespace = c.mappedNamespace || "public", c.mappedEntity === o.name && c.mappedNamespace === o.namespace) {
|
|
@@ -172,7 +166,7 @@ const He = (r, e) => {
|
|
|
172
166
|
(o) => o && o.endsWith("Id") && a.foreignKeyNames.includes(o)
|
|
173
167
|
), a;
|
|
174
168
|
}, R = (r) => (e) => {
|
|
175
|
-
const t =
|
|
169
|
+
const t = Ge(r, e);
|
|
176
170
|
if (u(e, L, t), r.abstract) return e;
|
|
177
171
|
const s = e;
|
|
178
172
|
return class extends s {
|
|
@@ -189,17 +183,72 @@ const He = (r, e) => {
|
|
|
189
183
|
*/
|
|
190
184
|
constructor(n) {
|
|
191
185
|
super(n);
|
|
192
|
-
const i = this[
|
|
193
|
-
if (!i) throw new
|
|
194
|
-
return
|
|
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);
|
|
195
189
|
}
|
|
196
190
|
};
|
|
197
|
-
}
|
|
198
|
-
var
|
|
199
|
-
for (var n = s > 1 ? void 0 : s ?
|
|
191
|
+
};
|
|
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--)
|
|
200
194
|
(a = r[i]) && (n = a(n) || n);
|
|
201
195
|
return n;
|
|
202
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
|
+
};
|
|
203
252
|
let $ = class {
|
|
204
253
|
/**
|
|
205
254
|
* 实体唯一标识符
|
|
@@ -246,100 +295,57 @@ let $ = class {
|
|
|
246
295
|
constructor(r) {
|
|
247
296
|
}
|
|
248
297
|
};
|
|
249
|
-
$ =
|
|
250
|
-
R(
|
|
251
|
-
name: "EntityBase",
|
|
252
|
-
abstract: !0,
|
|
253
|
-
// 标记为抽象类,不会直接创建此类的实例
|
|
254
|
-
properties: [
|
|
255
|
-
{
|
|
256
|
-
name: "id",
|
|
257
|
-
type: E.uuid,
|
|
258
|
-
primary: !0,
|
|
259
|
-
// 主键
|
|
260
|
-
unique: !0,
|
|
261
|
-
// 唯一索引
|
|
262
|
-
readonly: !0,
|
|
263
|
-
// 创建后不可修改
|
|
264
|
-
default: () => Ue()
|
|
265
|
-
// 默认生成UUID
|
|
266
|
-
},
|
|
267
|
-
{
|
|
268
|
-
name: "createdAt",
|
|
269
|
-
type: E.date,
|
|
270
|
-
readonly: !0,
|
|
271
|
-
default: () => /* @__PURE__ */ new Date()
|
|
272
|
-
},
|
|
273
|
-
{
|
|
274
|
-
name: "updatedAt",
|
|
275
|
-
type: E.date,
|
|
276
|
-
readonly: !0,
|
|
277
|
-
default: () => /* @__PURE__ */ new Date()
|
|
278
|
-
},
|
|
279
|
-
{
|
|
280
|
-
name: "removedAt",
|
|
281
|
-
type: E.date,
|
|
282
|
-
readonly: !0,
|
|
283
|
-
nullable: !0
|
|
284
|
-
},
|
|
285
|
-
{
|
|
286
|
-
name: "createdBy",
|
|
287
|
-
type: E.string,
|
|
288
|
-
readonly: !0,
|
|
289
|
-
nullable: !0
|
|
290
|
-
},
|
|
291
|
-
{
|
|
292
|
-
name: "updatedBy",
|
|
293
|
-
type: E.string,
|
|
294
|
-
readonly: !0,
|
|
295
|
-
nullable: !0
|
|
296
|
-
},
|
|
297
|
-
{
|
|
298
|
-
name: "removedBy",
|
|
299
|
-
type: E.string,
|
|
300
|
-
readonly: !0,
|
|
301
|
-
nullable: !0
|
|
302
|
-
}
|
|
303
|
-
]
|
|
304
|
-
})
|
|
298
|
+
$ = Qe([
|
|
299
|
+
R(k)
|
|
305
300
|
], $);
|
|
306
|
-
var
|
|
307
|
-
for (var n = s > 1 ? void 0 : s ?
|
|
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--)
|
|
308
303
|
(a = r[i]) && (n = a(n) || n);
|
|
309
304
|
return n;
|
|
310
305
|
};
|
|
311
|
-
|
|
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
|
+
]
|
|
312
332
|
};
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
{
|
|
330
|
-
name: "parent",
|
|
331
|
-
// 父节点关系名称
|
|
332
|
-
kind: p.MANY_TO_ONE,
|
|
333
|
-
// 多对一关系
|
|
334
|
-
mappedEntity: "TreeAdjacencyListEntityBase",
|
|
335
|
-
// 关联到同一实体类型
|
|
336
|
-
nullable: !0
|
|
337
|
-
// 允许根节点没有父节点
|
|
338
|
-
}
|
|
339
|
-
]
|
|
340
|
-
})
|
|
341
|
-
], X);
|
|
342
|
-
const Xe = (r) => !!r.combinator, Ze = (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) => {
|
|
343
349
|
const t = e[r.field], { operator: s, value: n } = r;
|
|
344
350
|
switch (s) {
|
|
345
351
|
case "in":
|
|
@@ -363,9 +369,9 @@ const Xe = (r) => !!r.combinator, Ze = (r, e) => {
|
|
|
363
369
|
case "notEndWith":
|
|
364
370
|
return `${t}`.endsWith(`${n}`) === !1;
|
|
365
371
|
case "=":
|
|
366
|
-
return
|
|
372
|
+
return q(n, t);
|
|
367
373
|
case "!=":
|
|
368
|
-
return
|
|
374
|
+
return q(n, t) === !1;
|
|
369
375
|
case ">":
|
|
370
376
|
return t > n;
|
|
371
377
|
case ">=":
|
|
@@ -375,16 +381,16 @@ const Xe = (r) => !!r.combinator, Ze = (r, e) => {
|
|
|
375
381
|
case "<=":
|
|
376
382
|
return t <= n;
|
|
377
383
|
default:
|
|
378
|
-
throw new
|
|
384
|
+
throw new b(`Unknown operator: ${s}`);
|
|
379
385
|
}
|
|
380
|
-
},
|
|
381
|
-
if (
|
|
386
|
+
}, U = (r, e) => {
|
|
387
|
+
if (et(r)) {
|
|
382
388
|
const { combinator: t, rules: s } = r;
|
|
383
|
-
return t === "and" ? s.every((n) =>
|
|
389
|
+
return t === "and" ? s.every((n) => U(n, e)) : s.some((n) => U(n, e));
|
|
384
390
|
} else
|
|
385
|
-
return
|
|
386
|
-
},
|
|
387
|
-
const { field: s, order: n } = t, i =
|
|
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);
|
|
388
394
|
if (n === "asc") {
|
|
389
395
|
if (r.some((c) => i < Reflect.get(c, s))) return !0;
|
|
390
396
|
if (r.every((c) => i > Reflect.get(c, s))) return !1;
|
|
@@ -392,10 +398,10 @@ const Xe = (r) => !!r.combinator, Ze = (r, e) => {
|
|
|
392
398
|
if (r.some((c) => i > Reflect.get(c, s))) return !0;
|
|
393
399
|
if (r.every((c) => i < Reflect.get(c, s))) return !1;
|
|
394
400
|
}
|
|
395
|
-
},
|
|
401
|
+
}, Ct = (r, e, t) => {
|
|
396
402
|
if (t.length === 0) return !1;
|
|
397
403
|
for (let s = 0; s < t.length; s++) {
|
|
398
|
-
const n = t[s], i =
|
|
404
|
+
const n = t[s], i = st(r, e, n);
|
|
399
405
|
if (i === void 0) {
|
|
400
406
|
if (s < t.length - 1) {
|
|
401
407
|
const { field: a } = n, o = Reflect.get(e, a);
|
|
@@ -405,8 +411,8 @@ const Xe = (r) => !!r.combinator, Ze = (r, e) => {
|
|
|
405
411
|
return i;
|
|
406
412
|
}
|
|
407
413
|
};
|
|
408
|
-
var
|
|
409
|
-
class
|
|
414
|
+
var nt = /* @__PURE__ */ ((r) => (r.Synced = "Synced", r.Syncing = "Syncing", r.Never = "Never", r))(nt || {});
|
|
415
|
+
class It {
|
|
410
416
|
constructor(e, t) {
|
|
411
417
|
this.rxdb = e, this.EntityClass = t;
|
|
412
418
|
}
|
|
@@ -435,12 +441,12 @@ class St {
|
|
|
435
441
|
* 更新实体
|
|
436
442
|
*/
|
|
437
443
|
updateEntity(e, t) {
|
|
438
|
-
e[x] =
|
|
444
|
+
e[x] = Le;
|
|
439
445
|
const s = m(e);
|
|
440
446
|
s.origin = { ...t }, Object.assign(e, t), e[x] = null;
|
|
441
447
|
}
|
|
442
448
|
}
|
|
443
|
-
class
|
|
449
|
+
class ce {
|
|
444
450
|
constructor(e, t) {
|
|
445
451
|
this.rxdb = e, this.EntityType = t;
|
|
446
452
|
const s = O(t);
|
|
@@ -453,7 +459,7 @@ class ae {
|
|
|
453
459
|
*/
|
|
454
460
|
localAdapterSub = new w("");
|
|
455
461
|
localAdapter$ = this.localAdapterSub.asObservable().pipe(
|
|
456
|
-
|
|
462
|
+
Y(Boolean),
|
|
457
463
|
I(),
|
|
458
464
|
f((e) => this.rxdb.getAdapter(e)),
|
|
459
465
|
v(1)
|
|
@@ -462,7 +468,7 @@ class ae {
|
|
|
462
468
|
* 本地仓库
|
|
463
469
|
*/
|
|
464
470
|
local$ = this.localAdapter$.pipe(
|
|
465
|
-
|
|
471
|
+
B((e) => e.getRepository(this.EntityType)),
|
|
466
472
|
v(1)
|
|
467
473
|
);
|
|
468
474
|
/**
|
|
@@ -470,7 +476,7 @@ class ae {
|
|
|
470
476
|
*/
|
|
471
477
|
remoteAdapterSub = new w("");
|
|
472
478
|
remoteAdapter$ = this.remoteAdapterSub.asObservable().pipe(
|
|
473
|
-
|
|
479
|
+
Y(Boolean),
|
|
474
480
|
I(),
|
|
475
481
|
f((e) => this.rxdb.getAdapter(e)),
|
|
476
482
|
v(1)
|
|
@@ -479,7 +485,7 @@ class ae {
|
|
|
479
485
|
* 远程仓库
|
|
480
486
|
*/
|
|
481
487
|
remote$ = this.remoteAdapter$.pipe(
|
|
482
|
-
|
|
488
|
+
B((e) => e.getRepository(this.EntityType)),
|
|
483
489
|
v(1)
|
|
484
490
|
);
|
|
485
491
|
/**
|
|
@@ -495,7 +501,7 @@ class ae {
|
|
|
495
501
|
get(e, t) {
|
|
496
502
|
return this.local$.pipe(
|
|
497
503
|
f((s) => s.get(e, t)),
|
|
498
|
-
|
|
504
|
+
T(this._setLocalEntityStatus)
|
|
499
505
|
);
|
|
500
506
|
}
|
|
501
507
|
/**
|
|
@@ -506,7 +512,7 @@ class ae {
|
|
|
506
512
|
findOne(e, t) {
|
|
507
513
|
return this.local$.pipe(
|
|
508
514
|
f((s) => s.findOne(e, t)),
|
|
509
|
-
|
|
515
|
+
T((s) => s && this._setLocalEntityStatus(s))
|
|
510
516
|
);
|
|
511
517
|
}
|
|
512
518
|
/**
|
|
@@ -517,7 +523,7 @@ class ae {
|
|
|
517
523
|
findOneOrFail(e, t) {
|
|
518
524
|
return this.local$.pipe(
|
|
519
525
|
f((s) => s.findOneOrFail(e, t)),
|
|
520
|
-
|
|
526
|
+
T(this._setLocalEntityStatus)
|
|
521
527
|
);
|
|
522
528
|
}
|
|
523
529
|
/**
|
|
@@ -528,7 +534,7 @@ class ae {
|
|
|
528
534
|
find(e, t) {
|
|
529
535
|
return this.local$.pipe(
|
|
530
536
|
f((s) => s.find(e, t)),
|
|
531
|
-
|
|
537
|
+
T(this._setLocalEntitiesStatus)
|
|
532
538
|
);
|
|
533
539
|
}
|
|
534
540
|
/**
|
|
@@ -539,7 +545,7 @@ class ae {
|
|
|
539
545
|
findAll(e, t) {
|
|
540
546
|
return this.local$.pipe(
|
|
541
547
|
f((s) => s.findAll(e, t)),
|
|
542
|
-
|
|
548
|
+
T(this._setLocalEntitiesStatus)
|
|
543
549
|
);
|
|
544
550
|
}
|
|
545
551
|
/**
|
|
@@ -550,7 +556,7 @@ class ae {
|
|
|
550
556
|
findByCursor(e, t) {
|
|
551
557
|
return this.local$.pipe(
|
|
552
558
|
f((s) => s.findByCursor(e, t)),
|
|
553
|
-
|
|
559
|
+
T(this._setLocalEntitiesStatus)
|
|
554
560
|
);
|
|
555
561
|
}
|
|
556
562
|
/**
|
|
@@ -566,7 +572,7 @@ class ae {
|
|
|
566
572
|
* @param entities 需要保存的实体
|
|
567
573
|
*/
|
|
568
574
|
async transactionSave(e) {
|
|
569
|
-
return e = Array.from(new Set(e)), (await
|
|
575
|
+
return e = Array.from(new Set(e)), (await M(this.localAdapter$)).transaction(async () => {
|
|
570
576
|
let s;
|
|
571
577
|
for (let n = 0; n < e.length; n++) {
|
|
572
578
|
const i = e[n], a = m(i);
|
|
@@ -582,9 +588,9 @@ class ae {
|
|
|
582
588
|
create(e) {
|
|
583
589
|
const t = this.local$.pipe(
|
|
584
590
|
f((s) => s.create(e)),
|
|
585
|
-
|
|
591
|
+
T(this._setLocalEntityStatus)
|
|
586
592
|
);
|
|
587
|
-
return
|
|
593
|
+
return M(t);
|
|
588
594
|
}
|
|
589
595
|
/**
|
|
590
596
|
* 更新实体
|
|
@@ -594,9 +600,9 @@ class ae {
|
|
|
594
600
|
update(e, t) {
|
|
595
601
|
const s = this.local$.pipe(
|
|
596
602
|
f((n) => n.update(e, t)),
|
|
597
|
-
|
|
603
|
+
T(this._setLocalEntityStatus)
|
|
598
604
|
);
|
|
599
|
-
return
|
|
605
|
+
return M(s);
|
|
600
606
|
}
|
|
601
607
|
/**
|
|
602
608
|
* 删除实体
|
|
@@ -604,7 +610,7 @@ class ae {
|
|
|
604
610
|
*/
|
|
605
611
|
remove(e) {
|
|
606
612
|
const t = this.local$.pipe(f((s) => s.remove(e)));
|
|
607
|
-
return
|
|
613
|
+
return M(t);
|
|
608
614
|
}
|
|
609
615
|
/**
|
|
610
616
|
* 设置状态 local
|
|
@@ -612,14 +618,14 @@ class ae {
|
|
|
612
618
|
_setLocalEntityStatus = (e) => m(e).local = !0;
|
|
613
619
|
_setLocalEntitiesStatus = (e) => e.forEach(this._setLocalEntityStatus);
|
|
614
620
|
}
|
|
615
|
-
class
|
|
621
|
+
class rt extends ce {
|
|
616
622
|
/**
|
|
617
623
|
* 查询子孙
|
|
618
624
|
*/
|
|
619
625
|
findDescendants(e, t, s) {
|
|
620
626
|
return this.local$.pipe(
|
|
621
627
|
f((n) => n.findDescendants(e, t, s)),
|
|
622
|
-
|
|
628
|
+
T(this._setLocalEntitiesStatus)
|
|
623
629
|
);
|
|
624
630
|
}
|
|
625
631
|
/**
|
|
@@ -634,7 +640,7 @@ class st extends ae {
|
|
|
634
640
|
findAncestors(e, t, s) {
|
|
635
641
|
return this.local$.pipe(
|
|
636
642
|
f((n) => n.findAncestors(e, t, s)),
|
|
637
|
-
|
|
643
|
+
T(this._setLocalEntitiesStatus)
|
|
638
644
|
);
|
|
639
645
|
}
|
|
640
646
|
/**
|
|
@@ -644,7 +650,7 @@ class st extends ae {
|
|
|
644
650
|
return this.local$.pipe(f((n) => n.countAncestors(e, t, s)));
|
|
645
651
|
}
|
|
646
652
|
}
|
|
647
|
-
const
|
|
653
|
+
const at = (r) => {
|
|
648
654
|
const e = m(r), t = r;
|
|
649
655
|
let s = [];
|
|
650
656
|
const n = () => {
|
|
@@ -654,7 +660,7 @@ const nt = (r) => {
|
|
|
654
660
|
};
|
|
655
661
|
s.forEach(({ prop: h, value: y, oldValue: _, updatedBy: g }) => {
|
|
656
662
|
o[h] = o[h] ?? _, c[h] = y, l === null ? l = g : l !== g && d();
|
|
657
|
-
}), d(), e[
|
|
663
|
+
}), d(), e[D] = !1, s = [], t[x] = null;
|
|
658
664
|
};
|
|
659
665
|
let i;
|
|
660
666
|
const a = {
|
|
@@ -668,17 +674,17 @@ const nt = (r) => {
|
|
|
668
674
|
*/
|
|
669
675
|
set: (o, c, l, d) => {
|
|
670
676
|
if (o[c] === l) return !0;
|
|
671
|
-
if (
|
|
672
|
-
const h = o[x] ||
|
|
673
|
-
s.push({ updatedBy: h, prop: c, value: l, oldValue: o[c] }), e[
|
|
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);
|
|
674
680
|
}
|
|
675
681
|
return Reflect.set(o, c, l, d);
|
|
676
682
|
}
|
|
677
683
|
};
|
|
678
684
|
return new Proxy(r, a);
|
|
679
|
-
},
|
|
685
|
+
}, it = (r, e, t) => {
|
|
680
686
|
const s = t.rxdb.schema.getEntityType(r.mappedEntity, r.mappedNamespace);
|
|
681
|
-
if (!s) throw new
|
|
687
|
+
if (!s) throw new b(`mapped entity not found: ${r.mappedEntity}`);
|
|
682
688
|
const n = r.name + "Id", i = r.name + "$";
|
|
683
689
|
let a;
|
|
684
690
|
switch (r.kind) {
|
|
@@ -747,7 +753,7 @@ const nt = (r) => {
|
|
|
747
753
|
case p.MANY_TO_MANY:
|
|
748
754
|
a = function() {
|
|
749
755
|
const o = this, c = m(o), l = r.name + "Id";
|
|
750
|
-
if (!r.junctionEntityType) throw new
|
|
756
|
+
if (!r.junctionEntityType) throw new b("junction entity not found");
|
|
751
757
|
const d = t.getRepository(r.junctionEntityType).findAll({
|
|
752
758
|
combinator: "and",
|
|
753
759
|
rules: [
|
|
@@ -796,13 +802,8 @@ const nt = (r) => {
|
|
|
796
802
|
enumerable: !1,
|
|
797
803
|
configurable: !1
|
|
798
804
|
});
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
[p.MANY_TO_ONE]: 1,
|
|
802
|
-
[p.ONE_TO_ONE]: -1,
|
|
803
|
-
[p.MANY_TO_MANY]: 1
|
|
804
|
-
});
|
|
805
|
-
class it {
|
|
805
|
+
};
|
|
806
|
+
class ot {
|
|
806
807
|
/**
|
|
807
808
|
* 创建实体状态实例
|
|
808
809
|
*
|
|
@@ -822,7 +823,7 @@ class it {
|
|
|
822
823
|
"_snapshots",
|
|
823
824
|
"patches$",
|
|
824
825
|
"rxdb",
|
|
825
|
-
|
|
826
|
+
D
|
|
826
827
|
].forEach(
|
|
827
828
|
(s) => Object.defineProperty(this, s, {
|
|
828
829
|
enumerable: !1,
|
|
@@ -887,7 +888,7 @@ class it {
|
|
|
887
888
|
* 状态检查标记
|
|
888
889
|
* 用于内部状态验证
|
|
889
890
|
*/
|
|
890
|
-
[
|
|
891
|
+
[D] = !1;
|
|
891
892
|
/**
|
|
892
893
|
* 实体原始数据
|
|
893
894
|
* 用于比较变更和恢复
|
|
@@ -974,7 +975,7 @@ class it {
|
|
|
974
975
|
}
|
|
975
976
|
return d;
|
|
976
977
|
}), this._patches.push(a), this.#t.next(this._patches);
|
|
977
|
-
const o = new
|
|
978
|
+
const o = new Pe(this.proxyTarget, e, t, n, i, s);
|
|
978
979
|
this.rxdb.dispatchEvent(o);
|
|
979
980
|
}
|
|
980
981
|
/**
|
|
@@ -984,15 +985,12 @@ class it {
|
|
|
984
985
|
* @returns 需要保存的实体数组
|
|
985
986
|
*/
|
|
986
987
|
getNeedSaveRelationEntities() {
|
|
987
|
-
const e = /* @__PURE__ */ new
|
|
988
|
+
const e = /* @__PURE__ */ new Set([this.proxyTarget]);
|
|
988
989
|
return this.#e.forEach(
|
|
989
|
-
(
|
|
990
|
-
m(
|
|
990
|
+
(t) => t.forEach((s) => {
|
|
991
|
+
m(s).modified === !0 && e.add(s);
|
|
991
992
|
})
|
|
992
|
-
), Array.from(
|
|
993
|
-
const i = e.get(s) || 0, a = e.get(n) || 0;
|
|
994
|
-
return i - a;
|
|
995
|
-
});
|
|
993
|
+
), Array.from(e);
|
|
996
994
|
}
|
|
997
995
|
/**
|
|
998
996
|
* 添加关系实体
|
|
@@ -1050,7 +1048,7 @@ class it {
|
|
|
1050
1048
|
return t ? this.#e.get(e) : (t = /* @__PURE__ */ new Set(), this.#e.set(e, t), t);
|
|
1051
1049
|
}
|
|
1052
1050
|
}
|
|
1053
|
-
class
|
|
1051
|
+
class ct {
|
|
1054
1052
|
/**
|
|
1055
1053
|
* 创建实体管理器实例
|
|
1056
1054
|
*
|
|
@@ -1064,7 +1062,7 @@ class ot {
|
|
|
1064
1062
|
constructor(e) {
|
|
1065
1063
|
this.rxdb = e, this.rxdb.options.entities.forEach((t) => {
|
|
1066
1064
|
const s = O(t);
|
|
1067
|
-
u(t.prototype,
|
|
1065
|
+
u(t.prototype, ae, this), ["get", "findOneOrFail", "find", "findOne", "findAll", "findByCursor", "count"].forEach((n) => {
|
|
1068
1066
|
u(t, n, (i, a) => this.#n(t)[n](i, a));
|
|
1069
1067
|
}), s.repository === "TreeRepository" && ["findDescendants", "countDescendants", "findAncestors", "countAncestors"].forEach((n) => {
|
|
1070
1068
|
u(
|
|
@@ -1072,15 +1070,15 @@ class ot {
|
|
|
1072
1070
|
n,
|
|
1073
1071
|
(i, a, o) => this.#n(t)[n](i, a, o)
|
|
1074
1072
|
);
|
|
1075
|
-
}), Object.keys(
|
|
1076
|
-
(n) => u(t.prototype, n,
|
|
1077
|
-
), s.relationMap.forEach((n) =>
|
|
1078
|
-
}), u(this,
|
|
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) => {
|
|
1079
1077
|
const s = this.#i(t, { local: !1, remote: !1, modified: !0 });
|
|
1080
1078
|
this.addEntityCache(s);
|
|
1081
|
-
const n = new
|
|
1079
|
+
const n = new ge(s);
|
|
1082
1080
|
return this.rxdb.dispatchEvent(n), s;
|
|
1083
|
-
}), u(this,
|
|
1081
|
+
}), u(this, ie, (t) => {
|
|
1084
1082
|
const { EntityType: s, data: n } = t;
|
|
1085
1083
|
if (n.rowId) {
|
|
1086
1084
|
const a = this.#a(s).get(n.rowId), o = a && this.#r(s).get(a);
|
|
@@ -1208,12 +1206,12 @@ class ot {
|
|
|
1208
1206
|
*/
|
|
1209
1207
|
async remove(e) {
|
|
1210
1208
|
const t = e.constructor;
|
|
1211
|
-
this.rxdb.dispatchEvent(new
|
|
1209
|
+
this.rxdb.dispatchEvent(new Ie(e));
|
|
1212
1210
|
try {
|
|
1213
1211
|
const s = await this.#n(t).remove(e);
|
|
1214
|
-
return this.rxdb.dispatchEvent(new
|
|
1212
|
+
return this.rxdb.dispatchEvent(new Be(s)), s;
|
|
1215
1213
|
} catch (s) {
|
|
1216
|
-
throw this.rxdb.dispatchEvent(new
|
|
1214
|
+
throw this.rxdb.dispatchEvent(new De(e, s)), s;
|
|
1217
1215
|
}
|
|
1218
1216
|
}
|
|
1219
1217
|
/**
|
|
@@ -1227,12 +1225,12 @@ class ot {
|
|
|
1227
1225
|
*/
|
|
1228
1226
|
async create(e) {
|
|
1229
1227
|
const t = e.constructor;
|
|
1230
|
-
this.rxdb.dispatchEvent(new
|
|
1228
|
+
this.rxdb.dispatchEvent(new Ae(e));
|
|
1231
1229
|
try {
|
|
1232
1230
|
const s = await this.#n(t).create(e);
|
|
1233
|
-
return this.rxdb.dispatchEvent(new
|
|
1231
|
+
return this.rxdb.dispatchEvent(new ve(s)), s;
|
|
1234
1232
|
} catch (s) {
|
|
1235
|
-
throw this.rxdb.dispatchEvent(new
|
|
1233
|
+
throw this.rxdb.dispatchEvent(new Oe(e, s)), s;
|
|
1236
1234
|
}
|
|
1237
1235
|
}
|
|
1238
1236
|
/**
|
|
@@ -1247,13 +1245,13 @@ class ot {
|
|
|
1247
1245
|
async update(e) {
|
|
1248
1246
|
const t = e.constructor, s = m(e);
|
|
1249
1247
|
if (s.modified) {
|
|
1250
|
-
const n =
|
|
1251
|
-
this.rxdb.dispatchEvent(new
|
|
1248
|
+
const n = Ee(s.target, (i, a) => i === s.origin[a]);
|
|
1249
|
+
this.rxdb.dispatchEvent(new we(e));
|
|
1252
1250
|
try {
|
|
1253
1251
|
const i = await this.#n(t).update(e, n);
|
|
1254
|
-
return this.rxdb.dispatchEvent(new
|
|
1252
|
+
return this.rxdb.dispatchEvent(new xe(i)), i;
|
|
1255
1253
|
} catch (i) {
|
|
1256
|
-
throw this.rxdb.dispatchEvent(new
|
|
1254
|
+
throw this.rxdb.dispatchEvent(new Se(e, i)), i;
|
|
1257
1255
|
}
|
|
1258
1256
|
}
|
|
1259
1257
|
return e;
|
|
@@ -1285,13 +1283,13 @@ class ot {
|
|
|
1285
1283
|
let s;
|
|
1286
1284
|
switch (t.repository) {
|
|
1287
1285
|
case "Repository":
|
|
1288
|
-
s = new
|
|
1286
|
+
s = new ce(this.rxdb, e);
|
|
1289
1287
|
break;
|
|
1290
1288
|
case "TreeRepository":
|
|
1291
|
-
s = new
|
|
1289
|
+
s = new rt(this.rxdb, e);
|
|
1292
1290
|
break;
|
|
1293
1291
|
default:
|
|
1294
|
-
throw new
|
|
1292
|
+
throw new b("repository must be 'Repository' or 'TreeRepository'");
|
|
1295
1293
|
}
|
|
1296
1294
|
return this.#e.set(e, s), s;
|
|
1297
1295
|
}
|
|
@@ -1329,21 +1327,21 @@ class ot {
|
|
|
1329
1327
|
* @returns 初始化后的代理实体实例
|
|
1330
1328
|
*/
|
|
1331
1329
|
#i(e, t) {
|
|
1332
|
-
|
|
1333
|
-
const s = new
|
|
1334
|
-
|
|
1335
|
-
const n =
|
|
1330
|
+
X(e, x, "");
|
|
1331
|
+
const s = new ot(this.rxdb, { target: e, ...t });
|
|
1332
|
+
X(e, re, s);
|
|
1333
|
+
const n = at(e);
|
|
1336
1334
|
return u(s, "proxyTarget", n), n;
|
|
1337
1335
|
}
|
|
1338
1336
|
}
|
|
1339
|
-
const
|
|
1337
|
+
const ee = {
|
|
1340
1338
|
save: (r) => function() {
|
|
1341
1339
|
return r.save(this);
|
|
1342
1340
|
},
|
|
1343
1341
|
remove: (r) => function() {
|
|
1344
1342
|
return r.remove(this);
|
|
1345
1343
|
}
|
|
1346
|
-
},
|
|
1344
|
+
}, lt = (r) => {
|
|
1347
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;
|
|
1348
1346
|
return {
|
|
1349
1347
|
name: Array.from(/* @__PURE__ */ new Set([e.name, s.name])).sort().join("_"),
|
|
@@ -1364,12 +1362,12 @@ const Z = {
|
|
|
1364
1362
|
]
|
|
1365
1363
|
};
|
|
1366
1364
|
};
|
|
1367
|
-
var
|
|
1368
|
-
for (var n = s > 1 ? void 0 : s ?
|
|
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--)
|
|
1369
1367
|
(a = r[i]) && (n = a(n) || n);
|
|
1370
1368
|
return n;
|
|
1371
1369
|
};
|
|
1372
|
-
let
|
|
1370
|
+
let P = class {
|
|
1373
1371
|
id;
|
|
1374
1372
|
namespace;
|
|
1375
1373
|
entity;
|
|
@@ -1379,7 +1377,7 @@ let Y = class {
|
|
|
1379
1377
|
patch;
|
|
1380
1378
|
changedAt;
|
|
1381
1379
|
};
|
|
1382
|
-
|
|
1380
|
+
P = ht([
|
|
1383
1381
|
R({
|
|
1384
1382
|
name: "RxDBChange",
|
|
1385
1383
|
log: !1,
|
|
@@ -1431,18 +1429,18 @@ Y = dt([
|
|
|
1431
1429
|
}
|
|
1432
1430
|
]
|
|
1433
1431
|
})
|
|
1434
|
-
],
|
|
1435
|
-
var
|
|
1436
|
-
for (var n = s > 1 ? void 0 : s ?
|
|
1432
|
+
], P);
|
|
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--)
|
|
1437
1435
|
(a = r[i]) && (n = a(n) || n);
|
|
1438
1436
|
return n;
|
|
1439
1437
|
};
|
|
1440
|
-
let
|
|
1438
|
+
let S = class {
|
|
1441
1439
|
id;
|
|
1442
1440
|
name;
|
|
1443
1441
|
executedAt;
|
|
1444
1442
|
};
|
|
1445
|
-
|
|
1443
|
+
S = ut([
|
|
1446
1444
|
R({
|
|
1447
1445
|
name: "RxDBMigration",
|
|
1448
1446
|
log: !1,
|
|
@@ -1465,18 +1463,18 @@ M = pt([
|
|
|
1465
1463
|
}
|
|
1466
1464
|
]
|
|
1467
1465
|
})
|
|
1468
|
-
],
|
|
1469
|
-
var
|
|
1470
|
-
for (var n = s > 1 ? void 0 : s ?
|
|
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--)
|
|
1471
1469
|
(a = r[i]) && (n = a(n) || n);
|
|
1472
1470
|
return n;
|
|
1473
1471
|
};
|
|
1474
1472
|
const C = (r, e) => e + ":" + r;
|
|
1475
|
-
class
|
|
1473
|
+
class yt {
|
|
1476
1474
|
constructor(e) {
|
|
1477
1475
|
this.rxdb = e;
|
|
1478
1476
|
const { entities: t } = this.rxdb.options;
|
|
1479
|
-
[
|
|
1477
|
+
[P, S, ...t].forEach((s) => {
|
|
1480
1478
|
const n = O(s), { name: i, namespace: a } = n, o = C(i, a);
|
|
1481
1479
|
this.#e.set(o, n), this.#t.set(o, s);
|
|
1482
1480
|
}), this.#e.forEach((s) => {
|
|
@@ -1484,12 +1482,12 @@ class Et {
|
|
|
1484
1482
|
n.forEach((i) => {
|
|
1485
1483
|
if (i.kind === p.MANY_TO_MANY) {
|
|
1486
1484
|
const a = this.findMappedRelation(s, i);
|
|
1487
|
-
if (!a) throw new
|
|
1488
|
-
const o =
|
|
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);
|
|
1489
1487
|
if (this.#e.has(c) === !1) {
|
|
1490
1488
|
let l = class extends $ {
|
|
1491
1489
|
};
|
|
1492
|
-
l =
|
|
1490
|
+
l = Et([
|
|
1493
1491
|
R(o)
|
|
1494
1492
|
], l);
|
|
1495
1493
|
const d = O(l);
|
|
@@ -1541,15 +1539,15 @@ class Et {
|
|
|
1541
1539
|
* @param field 查询条件的字段
|
|
1542
1540
|
*/
|
|
1543
1541
|
getFieldRelations(e, t) {
|
|
1544
|
-
if (t.includes(".") === !1) throw new
|
|
1542
|
+
if (t.includes(".") === !1) throw new b(`field '${t}' 必须是关属性查询`);
|
|
1545
1543
|
const s = [], n = t.split("."), i = n.length - 1;
|
|
1546
1544
|
let a = e, o, c = !1, l = "";
|
|
1547
1545
|
return n.length === 2 && n[1] == "id" && (c = a.foreignKeyRelationMap.has(n[0]), l = n[0] + "Id"), n.forEach((d, h) => {
|
|
1548
1546
|
if (h === i) {
|
|
1549
|
-
if (a.propertyMap.has(d) === !1) throw new
|
|
1547
|
+
if (a.propertyMap.has(d) === !1) throw new b(`property '${d}' not found`);
|
|
1550
1548
|
o = a.propertyMap.get(d);
|
|
1551
1549
|
} else {
|
|
1552
|
-
if (a.relationMap.has(d) === !1) throw new
|
|
1550
|
+
if (a.relationMap.has(d) === !1) throw new b(`relation '${d}' not found`);
|
|
1553
1551
|
const y = a.relationMap.get(d);
|
|
1554
1552
|
s.push({ relation: y, metadata: a }), a = this.getEntityMetadata(y.mappedEntity, y.mappedNamespace);
|
|
1555
1553
|
}
|
|
@@ -1575,7 +1573,7 @@ class Et {
|
|
|
1575
1573
|
return this.#t.get(s);
|
|
1576
1574
|
}
|
|
1577
1575
|
}
|
|
1578
|
-
class
|
|
1576
|
+
class Bt {
|
|
1579
1577
|
// 插件
|
|
1580
1578
|
#e = /* @__PURE__ */ new WeakSet();
|
|
1581
1579
|
// events
|
|
@@ -1615,15 +1613,15 @@ class Ct {
|
|
|
1615
1613
|
},
|
|
1616
1614
|
e
|
|
1617
1615
|
)
|
|
1618
|
-
), this.schema = new
|
|
1616
|
+
), this.schema = new yt(this), this.em = new ct(this), this.context = { ...this.options.context }, this.addEventListener(z, () => {
|
|
1619
1617
|
this.#n = !0;
|
|
1620
|
-
}), this.addEventListener(z, () => {
|
|
1621
|
-
this.#n = !1, this.#s.forEach((s) => this.dispatchEvent(s)), this.#s = [];
|
|
1622
1618
|
}), this.addEventListener(H, () => {
|
|
1619
|
+
this.#n = !1, this.#s.forEach((s) => this.dispatchEvent(s)), this.#s = [];
|
|
1620
|
+
}), this.addEventListener(J, () => {
|
|
1623
1621
|
this.#n = !1, this.#s = [];
|
|
1624
1622
|
});
|
|
1625
1623
|
const t = this.em;
|
|
1626
|
-
this.addEventListener(
|
|
1624
|
+
this.addEventListener(se, (s) => t[ie](s)), ye(this.options);
|
|
1627
1625
|
}
|
|
1628
1626
|
/**
|
|
1629
1627
|
* 注册适配器
|
|
@@ -1636,13 +1634,13 @@ class Ct {
|
|
|
1636
1634
|
*/
|
|
1637
1635
|
getAdapter(e) {
|
|
1638
1636
|
return this.#a.has(e) ? this.#a.get(e) : this.#l.pipe(
|
|
1639
|
-
|
|
1640
|
-
|
|
1637
|
+
B(() => this.#r.get(e)),
|
|
1638
|
+
Y(Boolean),
|
|
1641
1639
|
I(),
|
|
1642
1640
|
f((t) => {
|
|
1643
1641
|
if (!this.#a.has(e)) {
|
|
1644
1642
|
const s = t(this);
|
|
1645
|
-
|
|
1643
|
+
me(s) ? this.#a.set(e, Q(() => s).pipe(v(1))) : this.#a.set(e, j(s).pipe(v(1)));
|
|
1646
1644
|
}
|
|
1647
1645
|
return this.#a.get(e);
|
|
1648
1646
|
})
|
|
@@ -1667,9 +1665,9 @@ class Ct {
|
|
|
1667
1665
|
connect(e) {
|
|
1668
1666
|
return this.getAdapter(e).pipe(
|
|
1669
1667
|
f((t) => t.connect()),
|
|
1670
|
-
f((t) =>
|
|
1671
|
-
if (!await t.isTableExisted(
|
|
1672
|
-
await t.createTable(
|
|
1668
|
+
f((t) => Ue(e, this.options) ? Q(async () => {
|
|
1669
|
+
if (!await t.isTableExisted(S)) {
|
|
1670
|
+
await t.createTable(S), await t.createTable(P);
|
|
1673
1671
|
for (let n = 0; n < this.options.entities.length; n++) {
|
|
1674
1672
|
const i = this.options.entities[n];
|
|
1675
1673
|
try {
|
|
@@ -1679,7 +1677,7 @@ class Ct {
|
|
|
1679
1677
|
}
|
|
1680
1678
|
}
|
|
1681
1679
|
}
|
|
1682
|
-
}).pipe(
|
|
1680
|
+
}).pipe(B(() => t)) : j(t))
|
|
1683
1681
|
);
|
|
1684
1682
|
}
|
|
1685
1683
|
addEventListener(e, t) {
|
|
@@ -1689,7 +1687,7 @@ class Ct {
|
|
|
1689
1687
|
this.#o(e).delete(t);
|
|
1690
1688
|
}
|
|
1691
1689
|
dispatchEvent(e) {
|
|
1692
|
-
this.#n &&
|
|
1690
|
+
this.#n && Ve(e) === !1 ? this.#s.push(e) : this.#o(e.type).forEach((t) => t.call(this, e));
|
|
1693
1691
|
}
|
|
1694
1692
|
#o(e) {
|
|
1695
1693
|
if (this.#t.has(e))
|
|
@@ -1700,84 +1698,92 @@ class Ct {
|
|
|
1700
1698
|
}
|
|
1701
1699
|
}
|
|
1702
1700
|
}
|
|
1703
|
-
class
|
|
1701
|
+
class le {
|
|
1704
1702
|
constructor(e) {
|
|
1705
1703
|
this.rxdb = e;
|
|
1706
1704
|
}
|
|
1707
1705
|
}
|
|
1708
|
-
class
|
|
1706
|
+
class Dt extends le {
|
|
1709
1707
|
}
|
|
1710
|
-
class
|
|
1708
|
+
class $t extends le {
|
|
1711
1709
|
}
|
|
1712
|
-
class
|
|
1710
|
+
class Pt {
|
|
1713
1711
|
constructor(e) {
|
|
1714
1712
|
this.rxdb = e;
|
|
1715
1713
|
}
|
|
1716
1714
|
}
|
|
1715
|
+
const mt = {
|
|
1716
|
+
EntityBase: [k],
|
|
1717
|
+
TreeAdjacencyListEntityBase: [oe, k]
|
|
1718
|
+
}, Yt = (r) => mt[r];
|
|
1717
1719
|
export {
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
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,
|
|
1732
1736
|
R as Entity,
|
|
1733
1737
|
$ as EntityBase,
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
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,
|
|
1745
1749
|
E as PropertyType,
|
|
1746
1750
|
p as RelationKind,
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
bt as
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
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,
|
|
1759
|
+
P as RxDBChange,
|
|
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,
|
|
1772
1777
|
O as getEntityMetadata,
|
|
1778
|
+
Yt as getEntityMetadataOptions,
|
|
1773
1779
|
m as getEntityStatus,
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1780
|
+
Ct as isEntityEffectOrderBy,
|
|
1781
|
+
xt as isEntityInternalName,
|
|
1782
|
+
Mt as isEntityMatchRuleGroup,
|
|
1783
|
+
et as isRuleGroup,
|
|
1778
1784
|
u as setSafeObjectKey,
|
|
1779
1785
|
N as setSafeObjectKeyLazyInitOnce,
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1786
|
+
X as setSafeObjectWritableKey,
|
|
1787
|
+
Ge as transitionMetadata,
|
|
1788
|
+
Ke as uuid
|
|
1783
1789
|
};
|