@aiao/rxdb 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/RxDB.d.ts +3 -0
- package/dist/RxDB.d.ts.map +1 -1
- package/dist/index.js +448 -442
- package/dist/rxdb-events.d.ts +10 -3
- package/dist/rxdb-events.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,42 +1,36 @@
|
|
|
1
|
-
import { isFunction as
|
|
2
|
-
import { v7 as
|
|
3
|
-
import { BehaviorSubject as k, ReplaySubject as
|
|
4
|
-
import
|
|
1
|
+
import { isFunction as st, isArray as Ut, orderBy as Ft, get as Yt, isEqual as at, once as T, performChunk as jt, omitBy as zt, pick as Wt, isSymbol as Ht, nextMicroTask as Kt, createBroadcastTopic as kt, LeaderElection as qt, needArray as Vt, isNil as We, deepFreeze as Gt, isPromise as Jt } from "@aiao/utils";
|
|
2
|
+
import { v7 as Qt } from "uuid";
|
|
3
|
+
import { BehaviorSubject as k, ReplaySubject as Xt, takeUntil as Zt, distinctUntilChanged as we, tap as j, switchMap as N, Observable as it, map as L, shareReplay as B, firstValueFrom as F, Subject as en, defer as X, of as tn, combineLatest as ye, filter as de, finalize as nn } from "rxjs";
|
|
4
|
+
import rn from "object-hash";
|
|
5
5
|
class v extends Error {
|
|
6
6
|
constructor(e) {
|
|
7
7
|
super(e), this.name = "RxDBError", Object.setPrototypeOf(this, v.prototype);
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
-
const
|
|
11
|
-
class
|
|
12
|
-
constructor(e) {
|
|
13
|
-
this.entities = e;
|
|
14
|
-
}
|
|
15
|
-
type = rn;
|
|
16
|
-
}
|
|
17
|
-
class Ts {
|
|
10
|
+
const sn = "ENTITY_LOCAL_NEW", se = "ENTITY_LOCAL_CREATE", he = "ENTITY_LOCAL_UPDATE", ue = "ENTITY_LOCAL_REMOVE", ot = "ENTITY_REMOTE_CREATE", ct = "ENTITY_REMOTE_UPDATE", lt = "ENTITY_REMOTE_REMOVE", Oe = "TRANSACTION_BEGIN", Ne = "TRANSACTION_COMMIT", Pe = "TRANSACTION_ROLLBACK", an = "SWITCH_BRANCH_BEGIN", on = "SWITCH_BRANCH_COMMIT", cn = "SWITCH_BRANCH_ROLLBACK", ln = "SYNC_BEGIN", dn = "SYNC_COMPLETE", hn = "SYNC_ERROR", Ts = "REMOTE_CHANGES_PENDING", un = "CONFLICT_DETECTED", pn = "CONFLICT_PENDING", fn = "REPOSITORY_SYNC_BEGIN", dt = "REPOSITORY_SYNC_COMPLETE", yn = "REPOSITORY_SYNC_ERROR";
|
|
11
|
+
class mn {
|
|
18
12
|
constructor(e) {
|
|
19
13
|
this.entities = e;
|
|
20
14
|
}
|
|
21
|
-
type =
|
|
15
|
+
type = sn;
|
|
22
16
|
}
|
|
23
17
|
class As {
|
|
24
18
|
constructor(e) {
|
|
25
19
|
this.entities = e;
|
|
26
20
|
}
|
|
27
|
-
type =
|
|
21
|
+
type = se;
|
|
28
22
|
}
|
|
29
23
|
class Ms {
|
|
30
24
|
constructor(e) {
|
|
31
25
|
this.entities = e;
|
|
32
26
|
}
|
|
33
|
-
type =
|
|
27
|
+
type = he;
|
|
34
28
|
}
|
|
35
29
|
class Ss {
|
|
36
30
|
constructor(e) {
|
|
37
31
|
this.entities = e;
|
|
38
32
|
}
|
|
39
|
-
type =
|
|
33
|
+
type = ue;
|
|
40
34
|
}
|
|
41
35
|
class Os {
|
|
42
36
|
constructor(e) {
|
|
@@ -51,82 +45,93 @@ class Ns {
|
|
|
51
45
|
type = ct;
|
|
52
46
|
}
|
|
53
47
|
class Ps {
|
|
54
|
-
|
|
48
|
+
constructor(e) {
|
|
49
|
+
this.entities = e;
|
|
50
|
+
}
|
|
51
|
+
type = lt;
|
|
55
52
|
}
|
|
56
53
|
class xs {
|
|
57
|
-
type =
|
|
54
|
+
type = Oe;
|
|
58
55
|
}
|
|
59
56
|
class $s {
|
|
57
|
+
type = Ne;
|
|
58
|
+
}
|
|
59
|
+
class Ds {
|
|
60
60
|
type = Pe;
|
|
61
61
|
}
|
|
62
|
-
class
|
|
63
|
-
|
|
62
|
+
class xe {
|
|
63
|
+
constructor(e) {
|
|
64
|
+
this.branchName = e;
|
|
65
|
+
}
|
|
64
66
|
}
|
|
65
|
-
class gn {
|
|
67
|
+
class gn extends xe {
|
|
66
68
|
type = an;
|
|
67
69
|
}
|
|
68
|
-
class _n {
|
|
70
|
+
class _n extends xe {
|
|
69
71
|
type = on;
|
|
70
72
|
}
|
|
71
|
-
class
|
|
73
|
+
class wn extends xe {
|
|
74
|
+
type = cn;
|
|
75
|
+
}
|
|
76
|
+
class ht {
|
|
72
77
|
constructor(e) {
|
|
73
78
|
this.direction = e;
|
|
74
79
|
}
|
|
75
|
-
type =
|
|
80
|
+
type = ln;
|
|
76
81
|
}
|
|
77
|
-
class
|
|
82
|
+
class ut {
|
|
78
83
|
constructor(e, t) {
|
|
79
84
|
this.direction = e, this.result = t;
|
|
80
85
|
}
|
|
81
|
-
type =
|
|
86
|
+
type = dn;
|
|
82
87
|
}
|
|
83
|
-
class
|
|
88
|
+
class pt {
|
|
84
89
|
constructor(e, t) {
|
|
85
90
|
this.direction = e, this.error = t;
|
|
86
91
|
}
|
|
87
|
-
type =
|
|
92
|
+
type = hn;
|
|
88
93
|
}
|
|
89
|
-
class
|
|
94
|
+
class Bs {
|
|
90
95
|
constructor(e, t, n) {
|
|
91
96
|
this.conflicts = e, this.resolved = t, this.deferred = n;
|
|
92
97
|
}
|
|
93
|
-
type =
|
|
98
|
+
type = un;
|
|
94
99
|
}
|
|
95
|
-
class
|
|
100
|
+
class Ls {
|
|
96
101
|
constructor(e) {
|
|
97
102
|
this.conflicts = e;
|
|
98
103
|
}
|
|
99
|
-
type =
|
|
104
|
+
type = pn;
|
|
100
105
|
}
|
|
101
|
-
class
|
|
106
|
+
class $e {
|
|
102
107
|
constructor(e, t, n, s) {
|
|
103
108
|
this.direction = e, this.namespace = t, this.entity = n, this.includeRelated = s;
|
|
104
109
|
}
|
|
105
|
-
type =
|
|
110
|
+
type = fn;
|
|
106
111
|
}
|
|
107
|
-
class
|
|
112
|
+
class De {
|
|
108
113
|
constructor(e, t, n, s) {
|
|
109
114
|
this.direction = e, this.namespace = t, this.entity = n, this.result = s;
|
|
110
115
|
}
|
|
111
|
-
type =
|
|
116
|
+
type = dt;
|
|
112
117
|
}
|
|
113
|
-
class
|
|
118
|
+
class Be {
|
|
114
119
|
constructor(e, t, n, s) {
|
|
115
120
|
this.direction = e, this.namespace = t, this.entity = n, this.error = s;
|
|
116
121
|
}
|
|
117
|
-
type =
|
|
122
|
+
type = yn;
|
|
118
123
|
}
|
|
119
|
-
const
|
|
124
|
+
const ft = /* @__PURE__ */ Symbol("ɵProxy"), Ee = /* @__PURE__ */ Symbol("ɵMetadata"), yt = /* @__PURE__ */ Symbol("ɵStatus"), be = /* @__PURE__ */ Symbol("ɵEntityManager"), ve = /* @__PURE__ */ Symbol("ɵEntityType"), En = (r, e) => e.sync.local?.adapter === r, bn = (r) => [Oe, Ne, Pe].includes(r.type), A = (r) => r[Ee] || r.constructor[Ee], Us = (r) => r[ve] || r.constructor[ve], O = (r) => r && r[yt], Fs = (r) => r && !!O(r), Ys = (r, e, t, n) => {
|
|
120
125
|
let s = n > 1 ? void 0 : n ? Object.getOwnPropertyDescriptor(e, t) : e;
|
|
121
126
|
for (let a = r.length - 1, i; a >= 0; a--)
|
|
122
127
|
(i = r[a]) && (s = i(s) || s);
|
|
123
128
|
return s;
|
|
124
|
-
},
|
|
129
|
+
}, mt = () => Qt(), vn = ["id", "createdAt", "updatedAt", "createdBy", "updatedBy"], Rn = ["rev"], js = (r) => !!(vn.includes(r) || Rn.includes(r) || r.startsWith("_")), S = (r, e, t) => Object.defineProperty(r, e, {
|
|
125
130
|
value: t,
|
|
126
131
|
enumerable: !1,
|
|
127
132
|
configurable: !1,
|
|
128
133
|
writable: !1
|
|
129
|
-
}),
|
|
134
|
+
}), Cn = (r, e, t) => Object.defineProperty(r, e, {
|
|
130
135
|
value: t,
|
|
131
136
|
enumerable: !1,
|
|
132
137
|
configurable: !1,
|
|
@@ -139,18 +144,18 @@ const pt = /* @__PURE__ */ Symbol("ɵProxy"), Ee = /* @__PURE__ */ Symbol("ɵMet
|
|
|
139
144
|
configurable: !1
|
|
140
145
|
};
|
|
141
146
|
return Object.defineProperty(r, e, s);
|
|
142
|
-
},
|
|
147
|
+
}, In = (r, e) => {
|
|
143
148
|
const t = {};
|
|
144
149
|
let n = !1;
|
|
145
150
|
r.defaultValueProperties.forEach((s) => {
|
|
146
|
-
e[s.name] === void 0 && (n = !0,
|
|
151
|
+
e[s.name] === void 0 && (n = !0, st(s.default) ? t[s.name] = s.default() : t[s.name] = s.default);
|
|
147
152
|
}), n && Object.assign(e, t);
|
|
148
|
-
},
|
|
153
|
+
}, Tn = (r, e, t) => {
|
|
149
154
|
const { propertyMap: n, foreignKeyNames: s } = A(e);
|
|
150
155
|
Object.keys(t).forEach((a) => {
|
|
151
156
|
n.has(a) ? r.propertyMap.get(a)?.readonly !== !0 && (e[a] = t[a]) : s.includes(a) && (e[a] = t[a]);
|
|
152
157
|
});
|
|
153
|
-
},
|
|
158
|
+
}, He = (r) => {
|
|
154
159
|
const e = /* @__PURE__ */ new Set(), t = (s) => {
|
|
155
160
|
const i = O(s).getNeedSaveEntities();
|
|
156
161
|
i.length && n(i);
|
|
@@ -158,7 +163,7 @@ const pt = /* @__PURE__ */ Symbol("ɵProxy"), Ee = /* @__PURE__ */ Symbol("ɵMet
|
|
|
158
163
|
e.add(a), t(a);
|
|
159
164
|
});
|
|
160
165
|
return n(r), Array.from(e).filter((s) => O(s).modified);
|
|
161
|
-
},
|
|
166
|
+
}, An = (r) => {
|
|
162
167
|
const e = /* @__PURE__ */ new Set(), t = (n) => {
|
|
163
168
|
O(n).getNeedRemoveEntities().forEach((i) => {
|
|
164
169
|
e.has(i) || (e.add(i), t(i));
|
|
@@ -182,15 +187,15 @@ const pt = /* @__PURE__ */ Symbol("ɵProxy"), Ee = /* @__PURE__ */ Symbol("ɵMet
|
|
|
182
187
|
update: s
|
|
183
188
|
};
|
|
184
189
|
};
|
|
185
|
-
var R = /* @__PURE__ */ ((r) => (r.uuid = "uuid", r.string = "string", r.number = "number", r.integer = "integer", r.boolean = "boolean", r.date = "date", r.stringArray = "stringArray", r.numberArray = "numberArray", r.keyValue = "keyValue", r.json = "json", r))(R || {}), I = /* @__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))(I || {}), z = /* @__PURE__ */ ((r) => (r.NO_ACTION = "NO ACTION", r.RESTRICT = "RESTRICT", r.CASCADE = "CASCADE", r.SET_NULL = "SET NULL", r.SET_DEFAULT = "SET DEFAULT", r))(z || {}),
|
|
186
|
-
const
|
|
187
|
-
const n =
|
|
190
|
+
var R = /* @__PURE__ */ ((r) => (r.uuid = "uuid", r.string = "string", r.number = "number", r.integer = "integer", r.boolean = "boolean", r.date = "date", r.stringArray = "stringArray", r.numberArray = "numberArray", r.keyValue = "keyValue", r.json = "json", r))(R || {}), I = /* @__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))(I || {}), z = /* @__PURE__ */ ((r) => (r.NO_ACTION = "NO ACTION", r.RESTRICT = "RESTRICT", r.CASCADE = "CASCADE", r.SET_NULL = "SET NULL", r.SET_DEFAULT = "SET DEFAULT", r))(z || {}), gt = /* @__PURE__ */ ((r) => (r.NO_ACTION = "NO ACTION", r.RESTRICT = "RESTRICT", r.CASCADE = "CASCADE", r.SET_NULL = "SET NULL", r.SET_DEFAULT = "SET DEFAULT", r))(gt || {}), le = /* @__PURE__ */ ((r) => (r.Full = "full", r.Filter = "filter", r.None = "none", r))(le || {});
|
|
191
|
+
const Mn = (r, e, t = !1) => {
|
|
192
|
+
const n = Sn(e, t);
|
|
188
193
|
return {
|
|
189
194
|
onDelete: r.onDelete ?? n.onDelete,
|
|
190
195
|
onUpdate: r.onUpdate ?? n.onUpdate
|
|
191
196
|
};
|
|
192
|
-
},
|
|
193
|
-
const t =
|
|
197
|
+
}, Sn = (r, e = !1) => {
|
|
198
|
+
const t = gt.RESTRICT;
|
|
194
199
|
switch (r) {
|
|
195
200
|
case I.ONE_TO_ONE:
|
|
196
201
|
return {
|
|
@@ -221,16 +226,16 @@ const An = (r, e, t = !1) => {
|
|
|
221
226
|
onUpdate: t
|
|
222
227
|
};
|
|
223
228
|
}
|
|
224
|
-
},
|
|
229
|
+
}, On = (r, e) => {
|
|
225
230
|
const t = [];
|
|
226
231
|
t.push(r);
|
|
227
232
|
const n = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), o = { ...r };
|
|
228
233
|
if (o.repository = o.repository || "Repository", o.namespace = o.namespace || "public", o.properties = o.properties || [], o.relations = o.relations || [], o.indexes = o.indexes || [], o.computedProperties = o.computedProperties || [], e) {
|
|
229
|
-
if (
|
|
234
|
+
if (st(e)) {
|
|
230
235
|
let l = e, d = r;
|
|
231
236
|
for (; l !== Object.prototype && d; )
|
|
232
237
|
l = Object.getPrototypeOf(l), d = A(l), d && t.push(d);
|
|
233
|
-
} else
|
|
238
|
+
} else Ut(e) ? t.push(...e) : t.push(e);
|
|
234
239
|
const c = t.map((l) => l.name);
|
|
235
240
|
c.shift(), o.extends = c;
|
|
236
241
|
}
|
|
@@ -241,7 +246,7 @@ const An = (r, e, t = !1) => {
|
|
|
241
246
|
s.set(l.name, l);
|
|
242
247
|
}), c.relations?.forEach((l) => {
|
|
243
248
|
l.mappedNamespace = l.mappedNamespace || "public";
|
|
244
|
-
const d = "nullable" in l ? l.nullable ?? !1 : !1, h =
|
|
249
|
+
const d = "nullable" in l ? l.nullable ?? !1 : !1, h = Mn(
|
|
245
250
|
{
|
|
246
251
|
onDelete: l.onDelete,
|
|
247
252
|
onUpdate: l.onUpdate
|
|
@@ -274,7 +279,7 @@ const An = (r, e, t = !1) => {
|
|
|
274
279
|
(c) => c && c.endsWith("Id") && o.foreignKeyNames.includes(c)
|
|
275
280
|
), o;
|
|
276
281
|
}, J = (r) => (e) => {
|
|
277
|
-
const t =
|
|
282
|
+
const t = On(r, e);
|
|
278
283
|
if (S(e, Ee, t), r.abstract) return e;
|
|
279
284
|
const n = e;
|
|
280
285
|
return class extends n {
|
|
@@ -293,10 +298,10 @@ const An = (r, e, t = !1) => {
|
|
|
293
298
|
super(s);
|
|
294
299
|
const a = this[be];
|
|
295
300
|
if (!a) throw new v("need init rxdb");
|
|
296
|
-
return
|
|
301
|
+
return In(t, this), s && Tn(t, this, s), a[ft](this);
|
|
297
302
|
}
|
|
298
303
|
};
|
|
299
|
-
},
|
|
304
|
+
}, Nn = (r) => {
|
|
300
305
|
const e = r.features?.tree ?? {};
|
|
301
306
|
return J({
|
|
302
307
|
...r,
|
|
@@ -310,13 +315,13 @@ const An = (r, e, t = !1) => {
|
|
|
310
315
|
},
|
|
311
316
|
repository: r.repository ?? "TreeRepository"
|
|
312
317
|
});
|
|
313
|
-
},
|
|
314
|
-
var
|
|
315
|
-
for (var s = n > 1 ? void 0 : n ?
|
|
318
|
+
}, Le = /* @__PURE__ */ Symbol("ɵEntityStaticTypes");
|
|
319
|
+
var Pn = Object.getOwnPropertyDescriptor, _t = (r, e, t, n) => {
|
|
320
|
+
for (var s = n > 1 ? void 0 : n ? Pn(e, t) : e, a = r.length - 1, i; a >= 0; a--)
|
|
316
321
|
(i = r[a]) && (s = i(s) || s);
|
|
317
322
|
return s;
|
|
318
323
|
};
|
|
319
|
-
const
|
|
324
|
+
const xn = {
|
|
320
325
|
name: "EntityBase",
|
|
321
326
|
abstract: !0,
|
|
322
327
|
// 标记为抽象类,不会直接创建此类的实例
|
|
@@ -330,7 +335,7 @@ const Pn = {
|
|
|
330
335
|
// 唯一索引
|
|
331
336
|
readonly: !0,
|
|
332
337
|
// 创建后不可修改
|
|
333
|
-
default: () =>
|
|
338
|
+
default: () => mt()
|
|
334
339
|
// 默认生成 UUID
|
|
335
340
|
},
|
|
336
341
|
{
|
|
@@ -395,12 +400,12 @@ let ae = class {
|
|
|
395
400
|
constructor(r) {
|
|
396
401
|
}
|
|
397
402
|
};
|
|
398
|
-
ae =
|
|
399
|
-
J(
|
|
403
|
+
ae = _t([
|
|
404
|
+
J(xn)
|
|
400
405
|
], ae);
|
|
401
|
-
let
|
|
406
|
+
let Ke = class extends ae {
|
|
402
407
|
};
|
|
403
|
-
|
|
408
|
+
Ke = _t([
|
|
404
409
|
J({
|
|
405
410
|
name: "Todo",
|
|
406
411
|
properties: [
|
|
@@ -408,13 +413,13 @@ He = gt([
|
|
|
408
413
|
{ name: "completed", type: R.boolean, default: !1 }
|
|
409
414
|
]
|
|
410
415
|
})
|
|
411
|
-
],
|
|
412
|
-
var
|
|
413
|
-
for (var s = n > 1 ? void 0 : n ?
|
|
416
|
+
], Ke);
|
|
417
|
+
var $n = Object.getOwnPropertyDescriptor, Dn = (r, e, t, n) => {
|
|
418
|
+
for (var s = n > 1 ? void 0 : n ? $n(e, t) : e, a = r.length - 1, i; a >= 0; a--)
|
|
414
419
|
(i = r[a]) && (s = i(s) || s);
|
|
415
420
|
return s;
|
|
416
421
|
};
|
|
417
|
-
const
|
|
422
|
+
const Bn = {
|
|
418
423
|
name: "TreeAdjacencyListEntityBase",
|
|
419
424
|
abstract: !0,
|
|
420
425
|
// 标记为抽象类,不会直接创建此类的实例
|
|
@@ -461,16 +466,16 @@ const Dn = {
|
|
|
461
466
|
}
|
|
462
467
|
}
|
|
463
468
|
};
|
|
464
|
-
let
|
|
469
|
+
let ke = class extends ae {
|
|
465
470
|
/**
|
|
466
471
|
* 父节点ID
|
|
467
472
|
*/
|
|
468
473
|
parentId;
|
|
469
474
|
};
|
|
470
|
-
|
|
471
|
-
J(
|
|
472
|
-
],
|
|
473
|
-
const
|
|
475
|
+
ke = Dn([
|
|
476
|
+
J(Bn)
|
|
477
|
+
], ke);
|
|
478
|
+
const wt = (r) => !!(r && r.combinator), Ln = (r) => !!(r && r.field), Un = (r) => r.operator === "exists" || r.operator === "notExists", Fn = (r, e) => {
|
|
474
479
|
const t = Reflect.get(e, r.field), { operator: n } = r;
|
|
475
480
|
switch (n) {
|
|
476
481
|
case "in":
|
|
@@ -500,7 +505,7 @@ const _t = (r) => !!(r && r.combinator), Bn = (r) => !!(r && r.field), Ln = (r)
|
|
|
500
505
|
}
|
|
501
506
|
case "=":
|
|
502
507
|
case "!=": {
|
|
503
|
-
const { value: s } = r, a =
|
|
508
|
+
const { value: s } = r, a = at(s, t);
|
|
504
509
|
return n === "=" ? a : !a;
|
|
505
510
|
}
|
|
506
511
|
case ">":
|
|
@@ -523,7 +528,7 @@ const _t = (r) => !!(r && r.combinator), Bn = (r) => !!(r && r.field), Ln = (r)
|
|
|
523
528
|
}
|
|
524
529
|
case "exists":
|
|
525
530
|
case "notExists": {
|
|
526
|
-
const s =
|
|
531
|
+
const s = Un(r) ? r.where : void 0;
|
|
527
532
|
if (Array.isArray(t)) {
|
|
528
533
|
let a = t;
|
|
529
534
|
s && (a = t.filter((o) => W(o, s)));
|
|
@@ -542,13 +547,13 @@ const _t = (r) => !!(r && r.combinator), Bn = (r) => !!(r && r.field), Ln = (r)
|
|
|
542
547
|
throw new v(`Unknown operator: ${n}`);
|
|
543
548
|
}
|
|
544
549
|
}, Re = (r, e) => {
|
|
545
|
-
if (
|
|
550
|
+
if (wt(r)) {
|
|
546
551
|
const { combinator: t, rules: n } = r;
|
|
547
552
|
return t === "and" ? n.every((s) => Re(s, e)) : n.some((s) => Re(s, e));
|
|
548
553
|
} else
|
|
549
|
-
return
|
|
550
|
-
}, W = (r, e) => r == null ? !1 : Re(e, r),
|
|
551
|
-
const { field: n, sort: s } = t, a =
|
|
554
|
+
return Fn(r, e);
|
|
555
|
+
}, W = (r, e) => r == null ? !1 : Re(e, r), Yn = (r, e, t) => {
|
|
556
|
+
const { field: n, sort: s } = t, a = Yt(r, n);
|
|
552
557
|
if (s === "asc") {
|
|
553
558
|
if (e.some((c) => a < Reflect.get(c, n))) return !0;
|
|
554
559
|
if (e.every((c) => a > Reflect.get(c, n))) return !1;
|
|
@@ -556,10 +561,10 @@ const _t = (r) => !!(r && r.combinator), Bn = (r) => !!(r && r.field), Ln = (r)
|
|
|
556
561
|
if (e.some((c) => a > Reflect.get(c, n))) return !0;
|
|
557
562
|
if (e.every((c) => a < Reflect.get(c, n))) return !1;
|
|
558
563
|
}
|
|
559
|
-
},
|
|
564
|
+
}, jn = (r, e, t) => {
|
|
560
565
|
if (!t || !t || t.length === 0 || e.length === 0 || !r) return !0;
|
|
561
566
|
for (let n = 0; n < t.length; n++) {
|
|
562
|
-
const s = t[n], a =
|
|
567
|
+
const s = t[n], a = Yn(r, e, s);
|
|
563
568
|
if (a === void 0) {
|
|
564
569
|
const { field: i } = s, o = Reflect.get(r, i);
|
|
565
570
|
e = e.filter((c) => Reflect.get(c, i) === o);
|
|
@@ -570,14 +575,14 @@ const _t = (r) => !!(r && r.combinator), Bn = (r) => !!(r && r.field), Ln = (r)
|
|
|
570
575
|
const t = [], n = [];
|
|
571
576
|
return e.forEach((s) => {
|
|
572
577
|
t.push(s.field), n.push(s.sort);
|
|
573
|
-
}),
|
|
578
|
+
}), Ft(r, t, n);
|
|
574
579
|
}, ie = (r, e, t) => {
|
|
575
|
-
const n =
|
|
580
|
+
const n = qe(r, t);
|
|
576
581
|
return {
|
|
577
|
-
refresh: n === !1 &&
|
|
582
|
+
refresh: n === !1 && qe(r, e),
|
|
578
583
|
recalculate: n
|
|
579
584
|
};
|
|
580
|
-
},
|
|
585
|
+
}, qe = (r, e) => e.some((t) => t.every((n) => r[n]())), zn = (r, e, t, n, s) => {
|
|
581
586
|
const a = t.slice(0, n);
|
|
582
587
|
let i = e;
|
|
583
588
|
for (const o of a) {
|
|
@@ -591,7 +596,7 @@ const _t = (r) => !!(r && r.combinator), Bn = (r) => !!(r && r.field), Ln = (r)
|
|
|
591
596
|
i = r.schemaManager.getEntityMetadata(c.mappedEntity, c.mappedNamespace);
|
|
592
597
|
}
|
|
593
598
|
return i !== void 0;
|
|
594
|
-
},
|
|
599
|
+
}, Wn = (r, e, t, n) => {
|
|
595
600
|
const s = t.split(".");
|
|
596
601
|
try {
|
|
597
602
|
const a = r.schemaManager.getFieldRelations(e, t);
|
|
@@ -615,7 +620,7 @@ const _t = (r) => !!(r && r.combinator), Bn = (r) => !!(r && r.field), Ln = (r)
|
|
|
615
620
|
for (let a = s.length - 1; a > 0; a--) {
|
|
616
621
|
const i = s.slice(a);
|
|
617
622
|
if (i.length === 0) continue;
|
|
618
|
-
if (
|
|
623
|
+
if (zn(r, e, s, a, n)) {
|
|
619
624
|
const c = s.slice(0, a);
|
|
620
625
|
let l = e;
|
|
621
626
|
for (const d of c) {
|
|
@@ -629,7 +634,7 @@ const _t = (r) => !!(r && r.combinator), Bn = (r) => !!(r && r.field), Ln = (r)
|
|
|
629
634
|
}
|
|
630
635
|
}
|
|
631
636
|
}
|
|
632
|
-
},
|
|
637
|
+
}, Ue = (r, e, t, n) => {
|
|
633
638
|
n.add(t);
|
|
634
639
|
const s = A(t), a = (i) => {
|
|
635
640
|
if (i.rules)
|
|
@@ -655,21 +660,21 @@ const _t = (r) => !!(r && r.combinator), Bn = (r) => !!(r && r.field), Ln = (r)
|
|
|
655
660
|
h.mappedEntity,
|
|
656
661
|
h.mappedNamespace
|
|
657
662
|
);
|
|
658
|
-
p && (
|
|
663
|
+
p && (Ue(r, c.where, p, f), f.forEach((y) => n.add(y)));
|
|
659
664
|
}
|
|
660
665
|
}
|
|
661
666
|
continue;
|
|
662
667
|
}
|
|
663
668
|
if (l && l.includes("."))
|
|
664
669
|
try {
|
|
665
|
-
|
|
670
|
+
Wn(r, s, l, n);
|
|
666
671
|
} catch {
|
|
667
672
|
}
|
|
668
673
|
}
|
|
669
674
|
};
|
|
670
675
|
a(e);
|
|
671
676
|
};
|
|
672
|
-
function
|
|
677
|
+
function Hn(r, e) {
|
|
673
678
|
const { rxdb: t, entityType: n } = r, s = A(n);
|
|
674
679
|
if (!s) return !1;
|
|
675
680
|
const a = t.schemaManager.getEntityMetadata(e.entity, e.namespace);
|
|
@@ -677,7 +682,7 @@ function Wn(r, e) {
|
|
|
677
682
|
const i = r.options?.where;
|
|
678
683
|
if (i) {
|
|
679
684
|
const o = /* @__PURE__ */ new Set();
|
|
680
|
-
|
|
685
|
+
Ue(t, i, n, o);
|
|
681
686
|
for (const c of o) {
|
|
682
687
|
const l = A(c);
|
|
683
688
|
if (l && l.name === e.entity && l.namespace === e.namespace)
|
|
@@ -688,7 +693,7 @@ function Wn(r, e) {
|
|
|
688
693
|
(o) => o.mappedEntity === s.name && o.mappedNamespace === s.namespace
|
|
689
694
|
);
|
|
690
695
|
}
|
|
691
|
-
function
|
|
696
|
+
function Et(r, e) {
|
|
692
697
|
const t = A(r.entityType);
|
|
693
698
|
if (!t)
|
|
694
699
|
return {
|
|
@@ -697,19 +702,19 @@ function wt(r, e) {
|
|
|
697
702
|
};
|
|
698
703
|
const n = [], s = [];
|
|
699
704
|
return e.forEach((a) => {
|
|
700
|
-
const i = a.entity === t.name && a.namespace === t.namespace, o =
|
|
705
|
+
const i = a.entity === t.name && a.namespace === t.namespace, o = Hn(r, a);
|
|
701
706
|
i ? (n.push(a), o && r.type !== "findByCursor" && s.push(a)) : o && s.push(a);
|
|
702
707
|
}), { current_entities: n, relation_entities: s };
|
|
703
708
|
}
|
|
704
|
-
function
|
|
709
|
+
function Kn(r, e) {
|
|
705
710
|
const t = new Set(
|
|
706
711
|
e.relations ? e.relations.map((s) => s.name) : Array.from(e.relationMap?.keys() ?? [])
|
|
707
712
|
), n = (s) => {
|
|
708
713
|
if (!s) return !1;
|
|
709
714
|
for (const a of s.rules)
|
|
710
|
-
if (
|
|
715
|
+
if (wt(a)) {
|
|
711
716
|
if (n(a)) return !0;
|
|
712
|
-
} else if (
|
|
717
|
+
} else if (Ln(a)) {
|
|
713
718
|
const i = a.field;
|
|
714
719
|
if (i.includes(".")) return !0;
|
|
715
720
|
const o = i.split(":")[0];
|
|
@@ -720,7 +725,7 @@ function Hn(r, e) {
|
|
|
720
725
|
return n(r);
|
|
721
726
|
}
|
|
722
727
|
const G = T(() => !0);
|
|
723
|
-
class
|
|
728
|
+
class Fe {
|
|
724
729
|
constructor(e, t, n, s = !1) {
|
|
725
730
|
this.task = e, this.current_entities = t, this.hasRelationChanges = n, this.whereUsesRelations = s, this.entityIds = T(() => t.map((a) => a.id));
|
|
726
731
|
}
|
|
@@ -816,11 +821,11 @@ class Ue {
|
|
|
816
821
|
buildOrderByRule() {
|
|
817
822
|
const e = "orderBy" in this.task.options ? this.task.options.orderBy : void 0;
|
|
818
823
|
return e ? T(
|
|
819
|
-
() => this.current_entities.some((t) =>
|
|
824
|
+
() => this.current_entities.some((t) => jn(t.patch, Array.from(this.task.resultEntitySet), e))
|
|
820
825
|
) : G;
|
|
821
826
|
}
|
|
822
827
|
}
|
|
823
|
-
const ge = T(() => !0),
|
|
828
|
+
const ge = T(() => !0), kn = (r, e, t, n) => {
|
|
824
829
|
if (!A(r.entityType)) {
|
|
825
830
|
const l = T(() => e.map((_) => _.id)), d = ge, h = ge, u = ge, m = T(() => !1), f = T(() => !0), p = T(() => l().some((_) => r.resultEntitySet?.has(_))), y = T(() => p() === !1);
|
|
826
831
|
return {
|
|
@@ -837,19 +842,19 @@ const ge = T(() => !0), Kn = (r, e, t, n) => {
|
|
|
837
842
|
relation_entities: []
|
|
838
843
|
};
|
|
839
844
|
}
|
|
840
|
-
const { current_entities: a, relation_entities: i } =
|
|
845
|
+
const { current_entities: a, relation_entities: i } = Et(r, e), c = new Fe(r, a, i.length > 0).buildCreateRules();
|
|
841
846
|
return {
|
|
842
847
|
...ie(c, t, n),
|
|
843
848
|
current_entities: a,
|
|
844
849
|
relation_entities: i
|
|
845
850
|
};
|
|
846
|
-
},
|
|
847
|
-
const a = new
|
|
851
|
+
}, qn = (r, e, t, n) => {
|
|
852
|
+
const a = new Fe(r, e, !1).buildRemoveRules();
|
|
848
853
|
return ie(a, t, n);
|
|
849
|
-
},
|
|
854
|
+
}, Ve = T(() => !0), Vn = (r, e, t, n) => {
|
|
850
855
|
const s = A(r.entityType);
|
|
851
856
|
if (!s) {
|
|
852
|
-
const { options: h, resultEntityIds: u } = r, m = T(() => e.map((C) => C.id)), f = "where" in h ? h.where : void 0, p = f ? T(() => e.some((C) => W(C.patch, f))) :
|
|
857
|
+
const { options: h, resultEntityIds: u } = r, m = T(() => e.map((C) => C.id)), f = "where" in h ? h.where : void 0, p = f ? T(() => e.some((C) => W(C.patch, f))) : Ve, y = T(() => p() === !1), g = f ? T(() => e.some((C) => W(C.inversePatch, f))) : Ve, _ = T(() => g() === !1), w = T(() => m().some((C) => u.has(C))), E = T(() => w() === !1), b = {
|
|
853
858
|
match_where: p,
|
|
854
859
|
not_match_where: y,
|
|
855
860
|
match_where_before: g,
|
|
@@ -861,17 +866,17 @@ const ge = T(() => !0), Kn = (r, e, t, n) => {
|
|
|
861
866
|
};
|
|
862
867
|
return ie(b, t, n);
|
|
863
868
|
}
|
|
864
|
-
const { current_entities: a, relation_entities: i } =
|
|
869
|
+
const { current_entities: a, relation_entities: i } = Et(r, e), o = "where" in r.options ? r.options.where : void 0;
|
|
865
870
|
let c = !1;
|
|
866
|
-
o && (c =
|
|
867
|
-
const d = new
|
|
871
|
+
o && (c = Kn(o, s));
|
|
872
|
+
const d = new Fe(r, a, i.length > 0, c).buildUpdateRules();
|
|
868
873
|
return {
|
|
869
874
|
...ie(d, t, n),
|
|
870
875
|
current_entities: a,
|
|
871
876
|
relation_entities: i
|
|
872
877
|
};
|
|
873
878
|
};
|
|
874
|
-
class
|
|
879
|
+
class Gn {
|
|
875
880
|
/**
|
|
876
881
|
* 刷新
|
|
877
882
|
* 重新执行 SQL 查询
|
|
@@ -880,7 +885,7 @@ class Vn {
|
|
|
880
885
|
/**
|
|
881
886
|
* 销毁
|
|
882
887
|
*/
|
|
883
|
-
#t = new
|
|
888
|
+
#t = new Xt(1);
|
|
884
889
|
/**
|
|
885
890
|
* 是否首次运行
|
|
886
891
|
* 标识查询是否为第一次执行
|
|
@@ -982,11 +987,11 @@ class Vn {
|
|
|
982
987
|
if (this.#n === !0) return;
|
|
983
988
|
this.#n = !0;
|
|
984
989
|
const e = this.options?.where;
|
|
985
|
-
e && (
|
|
990
|
+
e && (Ue(this.rxdb, e, this.entityType, this.relationEntityTypes), this.relationEntityTypes.forEach((t) => {
|
|
986
991
|
const n = this.depEntityTypeMap.get(t) || 0;
|
|
987
992
|
this.depEntityTypeMap.set(t, n + 1);
|
|
988
993
|
})), this.refresh$.pipe(
|
|
989
|
-
|
|
994
|
+
Zt(this.destroy$),
|
|
990
995
|
we(),
|
|
991
996
|
j(() => this.refreshCount++),
|
|
992
997
|
N(() => this.runner())
|
|
@@ -1023,9 +1028,9 @@ class Vn {
|
|
|
1023
1028
|
this.#e.next(this.refreshCount + 1);
|
|
1024
1029
|
};
|
|
1025
1030
|
}
|
|
1026
|
-
var
|
|
1031
|
+
var Jn = /* @__PURE__ */ ((r) => (r.Synced = "Synced", r.Syncing = "Syncing", r.Never = "Never", r))(Jn || {});
|
|
1027
1032
|
const Ce = (r) => Array.isArray(r) ? r : [r], _e = (r) => r ? [O(r).fingerprint] : [r], re = (r) => r.map((e) => O(e).fingerprint), U = (r) => r?.parentId || null;
|
|
1028
|
-
function*
|
|
1033
|
+
function* bt(r, e, t = {}) {
|
|
1029
1034
|
const { maxLevel: n, maxDepth: s = 1e3 } = t, a = /* @__PURE__ */ new Set();
|
|
1030
1035
|
let i = U(r), o = 1;
|
|
1031
1036
|
for (; i && !a.has(i) && a.size < s; ) {
|
|
@@ -1035,7 +1040,7 @@ function* Et(r, e, t = {}) {
|
|
|
1035
1040
|
yield { entity: c, level: o }, i = U(c), o++;
|
|
1036
1041
|
}
|
|
1037
1042
|
}
|
|
1038
|
-
function
|
|
1043
|
+
function Qn(r, e, t, n) {
|
|
1039
1044
|
if (e == null)
|
|
1040
1045
|
return r.parentId === null;
|
|
1041
1046
|
const s = /* @__PURE__ */ new Set();
|
|
@@ -1052,10 +1057,10 @@ function Jn(r, e, t, n) {
|
|
|
1052
1057
|
}
|
|
1053
1058
|
return !1;
|
|
1054
1059
|
}
|
|
1055
|
-
function
|
|
1060
|
+
function Xn(r, e, t) {
|
|
1056
1061
|
const n = t.get(e);
|
|
1057
1062
|
if (!n) return !1;
|
|
1058
|
-
for (const { entity: s } of
|
|
1063
|
+
for (const { entity: s } of bt(n, t))
|
|
1059
1064
|
if (s?.id === r.id)
|
|
1060
1065
|
return !0;
|
|
1061
1066
|
return !1;
|
|
@@ -1067,10 +1072,10 @@ function Ie(r, e) {
|
|
|
1067
1072
|
s && t.set(s, n);
|
|
1068
1073
|
}), t;
|
|
1069
1074
|
}
|
|
1070
|
-
function
|
|
1075
|
+
function Ge(r, e) {
|
|
1071
1076
|
return r.length !== e.length ? !0 : r.some((t, n) => t !== e[n]);
|
|
1072
1077
|
}
|
|
1073
|
-
const
|
|
1078
|
+
const Zn = (r, e) => {
|
|
1074
1079
|
const t = r.options.where, n = e.filter((a) => !t || W(a.patch, t));
|
|
1075
1080
|
if (n.length === 0) return;
|
|
1076
1081
|
const s = n.map((a) => r.serialize(a));
|
|
@@ -1087,7 +1092,7 @@ const Xn = (r, e) => {
|
|
|
1087
1092
|
let c = [...o, ...s];
|
|
1088
1093
|
a.orderBy?.length && (c = q(c, a.orderBy));
|
|
1089
1094
|
const l = c.slice(0, i);
|
|
1090
|
-
if (!
|
|
1095
|
+
if (!Ge(o, l)) return;
|
|
1091
1096
|
r.next(l, !0);
|
|
1092
1097
|
break;
|
|
1093
1098
|
}
|
|
@@ -1125,7 +1130,7 @@ const Xn = (r, e) => {
|
|
|
1125
1130
|
}
|
|
1126
1131
|
} else
|
|
1127
1132
|
u = h;
|
|
1128
|
-
if (!
|
|
1133
|
+
if (!Ge(l, u)) return;
|
|
1129
1134
|
r.next(u, !0);
|
|
1130
1135
|
break;
|
|
1131
1136
|
}
|
|
@@ -1136,14 +1141,14 @@ const Xn = (r, e) => {
|
|
|
1136
1141
|
}
|
|
1137
1142
|
case "findDescendants": {
|
|
1138
1143
|
const a = r.options, i = Array.from(r.resultEntitySet.values()), o = Ie(i, (l) => l.id), c = s.filter(
|
|
1139
|
-
(l) =>
|
|
1144
|
+
(l) => Qn(l, a.entityId, o, a.level)
|
|
1140
1145
|
);
|
|
1141
1146
|
if (c.length === 0) return;
|
|
1142
1147
|
c.forEach((l) => r.resultEntitySet.add(l)), r.next(Array.from(r.resultEntitySet.values()), !0);
|
|
1143
1148
|
break;
|
|
1144
1149
|
}
|
|
1145
1150
|
case "findAncestors": {
|
|
1146
|
-
const a = r.options, o = [...Array.from(r.resultEntitySet.values()), ...s], c = Ie(o, (d) => d.id), l = s.filter((d) => d.id === a.entityId ? !0 : a.entityId ?
|
|
1151
|
+
const a = r.options, o = [...Array.from(r.resultEntitySet.values()), ...s], c = Ie(o, (d) => d.id), l = s.filter((d) => d.id === a.entityId ? !0 : a.entityId ? Xn(d, a.entityId, c) : !1);
|
|
1147
1152
|
if (l.length === 0) return;
|
|
1148
1153
|
l.forEach((d) => r.resultEntitySet.add(d)), r.next(Array.from(r.resultEntitySet.values()), !0);
|
|
1149
1154
|
break;
|
|
@@ -1171,9 +1176,9 @@ const Xn = (r, e) => {
|
|
|
1171
1176
|
t.push(["match_where"], ["match_relation_where"]);
|
|
1172
1177
|
break;
|
|
1173
1178
|
}
|
|
1174
|
-
const a =
|
|
1175
|
-
a.refresh ? r.refresh() : a.recalculate &&
|
|
1176
|
-
},
|
|
1179
|
+
const a = kn(r, e, t, n);
|
|
1180
|
+
a.refresh ? r.refresh() : a.recalculate && Zn(r, a.current_entities);
|
|
1181
|
+
}, er = (r, e) => {
|
|
1177
1182
|
const t = new Set(e.map((n) => n.id));
|
|
1178
1183
|
switch (r.type) {
|
|
1179
1184
|
case "findAll": {
|
|
@@ -1211,7 +1216,7 @@ const Xn = (r, e) => {
|
|
|
1211
1216
|
const o = s.filter((l) => {
|
|
1212
1217
|
if (t.has(l.id))
|
|
1213
1218
|
return i = !0, !1;
|
|
1214
|
-
for (const { entity: d } of
|
|
1219
|
+
for (const { entity: d } of bt(l, a))
|
|
1215
1220
|
if (d?.id && t.has(d.id))
|
|
1216
1221
|
return i = !0, !1;
|
|
1217
1222
|
return !0;
|
|
@@ -1252,13 +1257,13 @@ const Xn = (r, e) => {
|
|
|
1252
1257
|
t.push(["match_where"]);
|
|
1253
1258
|
break;
|
|
1254
1259
|
}
|
|
1255
|
-
const s =
|
|
1256
|
-
s.refresh ? r.refresh() : s.recalculate &&
|
|
1260
|
+
const s = qn(r, e, t, n);
|
|
1261
|
+
s.refresh ? r.refresh() : s.recalculate && er(r, e);
|
|
1257
1262
|
}, x = (r) => {
|
|
1258
1263
|
if (r)
|
|
1259
1264
|
return r.id;
|
|
1260
1265
|
};
|
|
1261
|
-
class
|
|
1266
|
+
class tr {
|
|
1262
1267
|
constructor(e, t) {
|
|
1263
1268
|
this.serialize = t, e.forEach((n) => this.dataById.set(n.id, n));
|
|
1264
1269
|
}
|
|
@@ -1293,7 +1298,7 @@ class er {
|
|
|
1293
1298
|
return this.dataById.get(e);
|
|
1294
1299
|
}
|
|
1295
1300
|
}
|
|
1296
|
-
const
|
|
1301
|
+
const nr = (r, e, t) => {
|
|
1297
1302
|
const n = new Set(r.map((h) => h.id)), s = r.filter((h) => !e || t(h.patch, e)), a = r.filter((h) => !e || t(h.inversePatch, e)), i = new Set(s.map((h) => h.id)), o = new Set(a.map((h) => h.id)), c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set();
|
|
1298
1303
|
return s.forEach((h) => {
|
|
1299
1304
|
o.has(h.id) ? d.add(h.id) : c.add(h.id);
|
|
@@ -1307,7 +1312,7 @@ const tr = (r, e, t) => {
|
|
|
1307
1312
|
newlyUnmatchedIds: l,
|
|
1308
1313
|
stillMatchedIds: d
|
|
1309
1314
|
};
|
|
1310
|
-
},
|
|
1315
|
+
}, rr = (r, e, t) => {
|
|
1311
1316
|
const n = r.options, s = n.where, a = Array.from(r.resultEntitySet.values()), i = [];
|
|
1312
1317
|
for (const d of a) {
|
|
1313
1318
|
const h = x(d);
|
|
@@ -1321,19 +1326,19 @@ const tr = (r, e, t) => {
|
|
|
1321
1326
|
const o = new Set(i.map((d) => x(d)).filter(Boolean)), c = Array.from(e.newlyMatchedIds).filter((d) => !o.has(d)).map((d) => t.getSerializedUpdate(d)).filter((d) => !!d);
|
|
1322
1327
|
let l = [...i, ...c];
|
|
1323
1328
|
n.orderBy?.length && (l = q(l, n.orderBy)), r.next(l, !0);
|
|
1324
|
-
},
|
|
1329
|
+
}, sr = (r, e) => {
|
|
1325
1330
|
const n = Array.from(r.resultEntitySet.values()).some((a) => {
|
|
1326
1331
|
const i = x(a);
|
|
1327
1332
|
return !!i && e.updatedIds.has(i);
|
|
1328
1333
|
}), s = e.newlyMatchedIds.size > 0;
|
|
1329
1334
|
(n || s) && r.refresh();
|
|
1330
|
-
},
|
|
1335
|
+
}, ar = (r, e) => {
|
|
1331
1336
|
const n = Array.from(r.resultEntitySet.values()).some((a) => {
|
|
1332
1337
|
const i = x(a);
|
|
1333
1338
|
return !!i && e.updatedIds.has(i);
|
|
1334
1339
|
}), s = e.newlyMatchedIds.size > 0;
|
|
1335
1340
|
(n || s) && r.refresh();
|
|
1336
|
-
},
|
|
1341
|
+
}, ir = (r, e, t) => {
|
|
1337
1342
|
const n = r.options, s = n.where;
|
|
1338
1343
|
if (r.result === null || r.result === void 0) {
|
|
1339
1344
|
e.newlyMatchedIds.size > 0 && r.refresh();
|
|
@@ -1356,7 +1361,7 @@ const tr = (r, e, t) => {
|
|
|
1356
1361
|
return;
|
|
1357
1362
|
}
|
|
1358
1363
|
e.newlyMatchedIds.size > 0 && r.refresh();
|
|
1359
|
-
},
|
|
1364
|
+
}, or = (r, e) => {
|
|
1360
1365
|
const t = r.result || 0, n = e.newlyMatchedIds.size, s = e.newlyUnmatchedIds.size;
|
|
1361
1366
|
if (n > 0 || s > 0) {
|
|
1362
1367
|
const a = Math.max(0, t + n - s);
|
|
@@ -1516,7 +1521,7 @@ class fe {
|
|
|
1516
1521
|
return !1;
|
|
1517
1522
|
}
|
|
1518
1523
|
}
|
|
1519
|
-
const
|
|
1524
|
+
const cr = (r, e, t, n) => {
|
|
1520
1525
|
const s = r.options, a = s.entityId, i = s.level, o = Array.from(r.resultEntitySet.values()), c = /* @__PURE__ */ new Map();
|
|
1521
1526
|
o.forEach((y) => {
|
|
1522
1527
|
const g = x(y);
|
|
@@ -1576,7 +1581,7 @@ const or = (r, e, t, n) => {
|
|
|
1576
1581
|
return;
|
|
1577
1582
|
const p = [...u, ...m];
|
|
1578
1583
|
r.next(p, !0);
|
|
1579
|
-
},
|
|
1584
|
+
}, lr = (r, e, t, n) => {
|
|
1580
1585
|
const a = r.options.entityId, i = Array.from(r.resultEntitySet.values()), o = /* @__PURE__ */ new Map();
|
|
1581
1586
|
i.forEach((E) => {
|
|
1582
1587
|
const b = x(E);
|
|
@@ -1631,7 +1636,7 @@ const or = (r, e, t, n) => {
|
|
|
1631
1636
|
return;
|
|
1632
1637
|
const w = [...y, ...g];
|
|
1633
1638
|
r.next(w, !0);
|
|
1634
|
-
},
|
|
1639
|
+
}, dr = (r, e, t, n, s, a) => {
|
|
1635
1640
|
const o = r.options.entityId, c = r.result || 0, l = /* @__PURE__ */ new Map(), d = new fe(n, l);
|
|
1636
1641
|
let h = !1, u = 0;
|
|
1637
1642
|
for (const m of e) {
|
|
@@ -1657,7 +1662,7 @@ const or = (r, e, t, n) => {
|
|
|
1657
1662
|
const m = Math.max(0, c + u);
|
|
1658
1663
|
r.next(m);
|
|
1659
1664
|
}
|
|
1660
|
-
},
|
|
1665
|
+
}, hr = (r, e, t, n, s, a) => {
|
|
1661
1666
|
const o = r.options.entityId, c = r.result || 0;
|
|
1662
1667
|
if (!o) {
|
|
1663
1668
|
r.refresh();
|
|
@@ -1715,36 +1720,36 @@ const or = (r, e, t, n) => {
|
|
|
1715
1720
|
const w = Math.max(0, c + y);
|
|
1716
1721
|
r.next(w);
|
|
1717
1722
|
}
|
|
1718
|
-
},
|
|
1719
|
-
const t = r.options.where, n = new
|
|
1723
|
+
}, ur = (r, e) => {
|
|
1724
|
+
const t = r.options.where, n = new tr(e, (a) => r.serialize(a)), s = nr(e, t, W);
|
|
1720
1725
|
switch (r.type) {
|
|
1721
1726
|
case "findAll":
|
|
1722
|
-
|
|
1727
|
+
rr(r, s, n);
|
|
1723
1728
|
break;
|
|
1724
1729
|
case "find":
|
|
1725
|
-
|
|
1730
|
+
sr(r, s);
|
|
1726
1731
|
break;
|
|
1727
1732
|
case "findOne":
|
|
1728
1733
|
case "findOneOrFail":
|
|
1729
|
-
|
|
1734
|
+
ir(r, s, n);
|
|
1730
1735
|
break;
|
|
1731
1736
|
case "findByCursor":
|
|
1732
|
-
|
|
1737
|
+
ar(r, s);
|
|
1733
1738
|
break;
|
|
1734
1739
|
case "count":
|
|
1735
|
-
|
|
1740
|
+
or(r, s);
|
|
1736
1741
|
break;
|
|
1737
1742
|
case "findDescendants":
|
|
1738
|
-
|
|
1743
|
+
cr(r, e, s, n);
|
|
1739
1744
|
break;
|
|
1740
1745
|
case "findAncestors":
|
|
1741
|
-
|
|
1746
|
+
lr(r, e, s, n);
|
|
1742
1747
|
break;
|
|
1743
1748
|
case "countDescendants":
|
|
1744
|
-
|
|
1749
|
+
dr(r, e, s, n, t, W);
|
|
1745
1750
|
break;
|
|
1746
1751
|
case "countAncestors":
|
|
1747
|
-
|
|
1752
|
+
hr(r, e, s, n, t, W);
|
|
1748
1753
|
break;
|
|
1749
1754
|
}
|
|
1750
1755
|
}, Me = (r, e) => {
|
|
@@ -1811,10 +1816,10 @@ const or = (r, e, t, n) => {
|
|
|
1811
1816
|
t.push(["match_where"]), t.push(["match_where_before"]), t.push(["match_relation_where"]);
|
|
1812
1817
|
break;
|
|
1813
1818
|
}
|
|
1814
|
-
const s =
|
|
1815
|
-
s.refresh ? r.refresh() : s.recalculate &&
|
|
1819
|
+
const s = Vn(r, e, t, n);
|
|
1820
|
+
s.refresh ? r.refresh() : s.recalculate && ur(r, e);
|
|
1816
1821
|
};
|
|
1817
|
-
class
|
|
1822
|
+
class pr {
|
|
1818
1823
|
/**
|
|
1819
1824
|
* 构造函数
|
|
1820
1825
|
*
|
|
@@ -1845,7 +1850,7 @@ class ur {
|
|
|
1845
1850
|
* @returns 查询任务对象,包含 result$ 用于订阅查询结果
|
|
1846
1851
|
*/
|
|
1847
1852
|
createTask(e) {
|
|
1848
|
-
const t =
|
|
1853
|
+
const t = rn(e.options);
|
|
1849
1854
|
let n = this.#e.get(t);
|
|
1850
1855
|
return n || (n = this.#a(t, e), this.#e.set(t, n)), n.result$ = this.#i(n), n;
|
|
1851
1856
|
}
|
|
@@ -1866,7 +1871,7 @@ class ur {
|
|
|
1866
1871
|
* @returns 新创建的查询任务
|
|
1867
1872
|
*/
|
|
1868
1873
|
#a(e, t) {
|
|
1869
|
-
return new
|
|
1874
|
+
return new Gn({
|
|
1870
1875
|
cacheKey: e,
|
|
1871
1876
|
...t,
|
|
1872
1877
|
entityType: this.EntityType,
|
|
@@ -1913,7 +1918,7 @@ class ur {
|
|
|
1913
1918
|
* @returns Observable 结果流
|
|
1914
1919
|
*/
|
|
1915
1920
|
#i(e) {
|
|
1916
|
-
return new
|
|
1921
|
+
return new it((t) => (e.observerCount++, e.result !== void 0 && t.next(e.result), e.observers.add(t), e.run(), () => {
|
|
1917
1922
|
e.observerCount--, e.observers.delete(t), e.observerCount <= 0 && e.clean();
|
|
1918
1923
|
}));
|
|
1919
1924
|
}
|
|
@@ -1942,7 +1947,7 @@ class ur {
|
|
|
1942
1947
|
return !0;
|
|
1943
1948
|
});
|
|
1944
1949
|
if (s.length === 0) return;
|
|
1945
|
-
|
|
1950
|
+
jt(Array.from(this.#e.values()), (a) => {
|
|
1946
1951
|
switch (t.type) {
|
|
1947
1952
|
case se:
|
|
1948
1953
|
(this.#n.get(a.type) || Te)(a, s);
|
|
@@ -1960,7 +1965,7 @@ class ur {
|
|
|
1960
1965
|
this.rxdb.addEventListener(se, e), this.rxdb.addEventListener(he, e), this.rxdb.addEventListener(ue, e);
|
|
1961
1966
|
}
|
|
1962
1967
|
}
|
|
1963
|
-
class
|
|
1968
|
+
class fr {
|
|
1964
1969
|
constructor(e, t) {
|
|
1965
1970
|
this.rxdb = e, this.EntityType = t;
|
|
1966
1971
|
}
|
|
@@ -1997,7 +2002,7 @@ class pr {
|
|
|
1997
2002
|
n.origin = { ...t }, Object.assign(e, t);
|
|
1998
2003
|
}
|
|
1999
2004
|
}
|
|
2000
|
-
class
|
|
2005
|
+
class vt extends fr {
|
|
2001
2006
|
static _STATIC_METHODS = [
|
|
2002
2007
|
...super._STATIC_METHODS,
|
|
2003
2008
|
"get",
|
|
@@ -2041,7 +2046,7 @@ class bt extends pr {
|
|
|
2041
2046
|
const n = A(t);
|
|
2042
2047
|
this.sync = n.sync || e.config.sync;
|
|
2043
2048
|
const { local: s, remote: a } = this.sync, i = !s && !!a;
|
|
2044
|
-
this.primary$ = i ? this.remote$ : this.local$, this.queryManager = new
|
|
2049
|
+
this.primary$ = i ? this.remote$ : this.local$, this.queryManager = new pr(e, t, this);
|
|
2045
2050
|
}
|
|
2046
2051
|
/**
|
|
2047
2052
|
* 根据 id 获取实体
|
|
@@ -2152,8 +2157,8 @@ class bt extends pr {
|
|
|
2152
2157
|
if (e.before && e.after)
|
|
2153
2158
|
throw new v("before and after cannot be used together in cursor-based pagination");
|
|
2154
2159
|
let n = structuredClone(e.where);
|
|
2155
|
-
const s =
|
|
2156
|
-
s && (n =
|
|
2160
|
+
const s = yr(e);
|
|
2161
|
+
s && (n = mr(n, s));
|
|
2157
2162
|
const a = () => this.primary$.pipe(
|
|
2158
2163
|
N((i) => i.find({ ...e, where: n })),
|
|
2159
2164
|
j(this._setLocals)
|
|
@@ -2216,7 +2221,7 @@ class bt extends pr {
|
|
|
2216
2221
|
};
|
|
2217
2222
|
_setLocals = (e) => e.forEach(this._setLocal);
|
|
2218
2223
|
}
|
|
2219
|
-
const
|
|
2224
|
+
const yr = (r) => {
|
|
2220
2225
|
const e = r.after || r.before;
|
|
2221
2226
|
if (!e) return null;
|
|
2222
2227
|
const t = !!r.after;
|
|
@@ -2238,8 +2243,8 @@ const fr = (r) => {
|
|
|
2238
2243
|
l.push({ field: a, operator: d, value: e[a] }), n.push({ combinator: "and", rules: l });
|
|
2239
2244
|
}
|
|
2240
2245
|
return { combinator: "or", rules: n };
|
|
2241
|
-
},
|
|
2242
|
-
class
|
|
2246
|
+
}, mr = (r, e) => r.combinator === "and" ? { ...r, rules: [...r.rules, e] } : { combinator: "and", rules: [r, e] };
|
|
2247
|
+
class Rt {
|
|
2243
2248
|
constructor(e) {
|
|
2244
2249
|
this.rxdb = e;
|
|
2245
2250
|
}
|
|
@@ -2254,17 +2259,17 @@ class vt {
|
|
|
2254
2259
|
this.repository_map.set(e, t);
|
|
2255
2260
|
}
|
|
2256
2261
|
}
|
|
2257
|
-
class
|
|
2262
|
+
class zs extends Rt {
|
|
2258
2263
|
}
|
|
2259
|
-
class
|
|
2264
|
+
class Ws extends Rt {
|
|
2260
2265
|
}
|
|
2261
|
-
class
|
|
2266
|
+
class Hs {
|
|
2262
2267
|
constructor(e) {
|
|
2263
2268
|
this.rxdb = e;
|
|
2264
2269
|
}
|
|
2265
2270
|
}
|
|
2266
|
-
const
|
|
2267
|
-
class
|
|
2271
|
+
const Je = 100;
|
|
2272
|
+
class gr extends vt {
|
|
2268
2273
|
static _STATIC_METHODS = [
|
|
2269
2274
|
...super._STATIC_METHODS,
|
|
2270
2275
|
"findDescendants",
|
|
@@ -2328,10 +2333,10 @@ class mr extends bt {
|
|
|
2328
2333
|
}
|
|
2329
2334
|
#e(e) {
|
|
2330
2335
|
const t = { ...e }, n = t.level ?? 0;
|
|
2331
|
-
return n < 0 ? t.level = 0 : n >
|
|
2336
|
+
return n < 0 ? t.level = 0 : n > Je ? t.level = Je : t.level = n, t.entityId = t.entityId ?? null, t;
|
|
2332
2337
|
}
|
|
2333
2338
|
}
|
|
2334
|
-
class
|
|
2339
|
+
class _r {
|
|
2335
2340
|
/**
|
|
2336
2341
|
* 创建实体状态实例
|
|
2337
2342
|
*
|
|
@@ -2382,7 +2387,7 @@ class gr {
|
|
|
2382
2387
|
* 每次调用 checkChange 时发布最新的 patches 数组
|
|
2383
2388
|
* 使用 shareReplay(1) 确保新订阅者能立即收到最近的变更记录
|
|
2384
2389
|
*/
|
|
2385
|
-
#n = new
|
|
2390
|
+
#n = new en();
|
|
2386
2391
|
/**
|
|
2387
2392
|
* 状态快照数组
|
|
2388
2393
|
* 存储实体在不同时间点的完整状态,用于支持撤销/重做功能
|
|
@@ -2486,7 +2491,7 @@ class gr {
|
|
|
2486
2491
|
* 缓存失效:修改 modified 属性时清空缓存
|
|
2487
2492
|
*/
|
|
2488
2493
|
get patch() {
|
|
2489
|
-
return this._patch_cache || (this._patch_cache =
|
|
2494
|
+
return this._patch_cache || (this._patch_cache = zt(this.proxyTarget, (e, t) => e === this.origin[t])), this._patch_cache || null;
|
|
2490
2495
|
}
|
|
2491
2496
|
/**
|
|
2492
2497
|
* 逆向变更内容(用于撤销操作)
|
|
@@ -2495,7 +2500,7 @@ class gr {
|
|
|
2495
2500
|
* 例如:patch = { name: 'new' } → inversePatch = { name: 'old' }
|
|
2496
2501
|
*/
|
|
2497
2502
|
get inversePatch() {
|
|
2498
|
-
return this.patch &&
|
|
2503
|
+
return this.patch && Wt(this.origin, Object.keys(this.patch)) || null;
|
|
2499
2504
|
}
|
|
2500
2505
|
/**
|
|
2501
2506
|
* 获取变化
|
|
@@ -2708,7 +2713,7 @@ class gr {
|
|
|
2708
2713
|
this._patch_cache = void 0, this._fingerprint = void 0;
|
|
2709
2714
|
}
|
|
2710
2715
|
}
|
|
2711
|
-
const
|
|
2716
|
+
const wr = (r) => {
|
|
2712
2717
|
const e = O(r), t = A(r.constructor), n = () => e.checkChange();
|
|
2713
2718
|
let s;
|
|
2714
2719
|
const a = {
|
|
@@ -2718,8 +2723,8 @@ const _r = (r) => {
|
|
|
2718
2723
|
* 同时根据 metadata 配置进行类型转换
|
|
2719
2724
|
*/
|
|
2720
2725
|
set: (i, o, c, l) => {
|
|
2721
|
-
if (
|
|
2722
|
-
if (
|
|
2726
|
+
if (at(i[o], c)) return !0;
|
|
2727
|
+
if (Ht(o) === !1 && (e.modified = !0, clearTimeout(s), s = setTimeout(() => n(), 0), c === null && t.isForeignKey(o))) {
|
|
2723
2728
|
const d = t.foreignKeyRelationMap.get(o);
|
|
2724
2729
|
d && (d.kind === I.MANY_TO_ONE || d.kind === I.ONE_TO_ONE) && e.cleanRelationEntity(d);
|
|
2725
2730
|
}
|
|
@@ -2727,7 +2732,7 @@ const _r = (r) => {
|
|
|
2727
2732
|
}
|
|
2728
2733
|
};
|
|
2729
2734
|
return new Proxy(r, a);
|
|
2730
|
-
},
|
|
2735
|
+
}, Er = (r, e, t) => {
|
|
2731
2736
|
const n = t.rxdb.schemaManager.getEntityType(r.mappedEntity, r.mappedNamespace);
|
|
2732
2737
|
if (!n) throw new v(`mapped entity not found: ${r.mappedEntity}`);
|
|
2733
2738
|
const s = r.name + "Id", a = r.name + "$";
|
|
@@ -2742,7 +2747,7 @@ const _r = (r) => {
|
|
|
2742
2747
|
case I.ONE_TO_ONE:
|
|
2743
2748
|
i = function() {
|
|
2744
2749
|
const o = this, c = O(o), l = new k(o[s]), d = l.asObservable().pipe(
|
|
2745
|
-
N((h) => h ? t.getRepository(n).get(h) :
|
|
2750
|
+
N((h) => h ? t.getRepository(n).get(h) : tn(null)),
|
|
2746
2751
|
B(1)
|
|
2747
2752
|
);
|
|
2748
2753
|
return S(d, "set", (h) => {
|
|
@@ -2876,7 +2881,7 @@ const _r = (r) => {
|
|
|
2876
2881
|
configurable: !1
|
|
2877
2882
|
});
|
|
2878
2883
|
};
|
|
2879
|
-
class
|
|
2884
|
+
class br {
|
|
2880
2885
|
/**
|
|
2881
2886
|
* 创建实体管理器实例
|
|
2882
2887
|
*
|
|
@@ -2889,14 +2894,14 @@ class Er {
|
|
|
2889
2894
|
*/
|
|
2890
2895
|
constructor(e) {
|
|
2891
2896
|
this.rxdb = e, e.repository("Repository", {
|
|
2892
|
-
class:
|
|
2897
|
+
class: vt,
|
|
2893
2898
|
mergeOperations: {
|
|
2894
2899
|
create: Te,
|
|
2895
2900
|
update: Me,
|
|
2896
2901
|
remove: Ae
|
|
2897
2902
|
}
|
|
2898
2903
|
}).repository("TreeRepository", {
|
|
2899
|
-
class:
|
|
2904
|
+
class: gr,
|
|
2900
2905
|
mergeOperations: {
|
|
2901
2906
|
create: Te,
|
|
2902
2907
|
update: Me,
|
|
@@ -2926,14 +2931,14 @@ class Er {
|
|
|
2926
2931
|
a,
|
|
2927
2932
|
(i) => this.#n(e)[a](i)
|
|
2928
2933
|
)
|
|
2929
|
-
), Object.keys(
|
|
2930
|
-
(s) => S(e.prototype, s,
|
|
2931
|
-
), t.relationMap.forEach((s) =>
|
|
2932
|
-
}), S(this,
|
|
2934
|
+
), Object.keys(Qe).forEach(
|
|
2935
|
+
(s) => S(e.prototype, s, Qe[s](this, e))
|
|
2936
|
+
), t.relationMap.forEach((s) => Er(s, e, this));
|
|
2937
|
+
}), S(this, ft, (e) => {
|
|
2933
2938
|
const t = this.#s(e, { local: !1, remote: !1, modified: !0 });
|
|
2934
|
-
return
|
|
2939
|
+
return Kt(() => {
|
|
2935
2940
|
this.addEntityCache(t);
|
|
2936
|
-
const n = A(e), s = new
|
|
2941
|
+
const n = A(e), s = new mn([
|
|
2937
2942
|
{
|
|
2938
2943
|
type: "NEW",
|
|
2939
2944
|
namespace: n.namespace,
|
|
@@ -3030,7 +3035,7 @@ class Er {
|
|
|
3030
3035
|
* @returns 保存后的实体实例
|
|
3031
3036
|
*/
|
|
3032
3037
|
async save(e) {
|
|
3033
|
-
const t =
|
|
3038
|
+
const t = He([e]), n = An([e]);
|
|
3034
3039
|
if (t.length === 1 && n.length === 0) {
|
|
3035
3040
|
const s = t[0];
|
|
3036
3041
|
O(s).local ? await this.update(s) : await this.create(s);
|
|
@@ -3051,7 +3056,7 @@ class Er {
|
|
|
3051
3056
|
* @returns
|
|
3052
3057
|
*/
|
|
3053
3058
|
async saveMany(e) {
|
|
3054
|
-
const t =
|
|
3059
|
+
const t = He(e), n = me({
|
|
3055
3060
|
need_save_entities: t,
|
|
3056
3061
|
need_remove_entities: []
|
|
3057
3062
|
});
|
|
@@ -3176,13 +3181,13 @@ class Er {
|
|
|
3176
3181
|
* @returns 初始化后的代理实体实例
|
|
3177
3182
|
*/
|
|
3178
3183
|
#s(e, t) {
|
|
3179
|
-
const n = new
|
|
3180
|
-
|
|
3181
|
-
const s =
|
|
3184
|
+
const n = new _r(this.rxdb, { target: e, ...t });
|
|
3185
|
+
Cn(e, yt, n);
|
|
3186
|
+
const s = wr(e);
|
|
3182
3187
|
return S(n, "proxyTarget", s), s;
|
|
3183
3188
|
}
|
|
3184
3189
|
}
|
|
3185
|
-
const
|
|
3190
|
+
const Qe = {
|
|
3186
3191
|
save: (r) => function() {
|
|
3187
3192
|
return r.save(this);
|
|
3188
3193
|
},
|
|
@@ -3192,8 +3197,8 @@ const Je = {
|
|
|
3192
3197
|
reset: (r) => function() {
|
|
3193
3198
|
return r.reset(this);
|
|
3194
3199
|
}
|
|
3195
|
-
},
|
|
3196
|
-
class
|
|
3200
|
+
}, Xe = "entity_event", Ze = "hello", et = "first_connected_at";
|
|
3201
|
+
class vr {
|
|
3197
3202
|
#e;
|
|
3198
3203
|
#t;
|
|
3199
3204
|
#n;
|
|
@@ -3219,7 +3224,7 @@ class br {
|
|
|
3219
3224
|
return this.#s;
|
|
3220
3225
|
}
|
|
3221
3226
|
constructor(e) {
|
|
3222
|
-
this.#n = e.clientId, this.#e =
|
|
3227
|
+
this.#n = e.clientId, this.#e = kt(`${e.dbName}_gateway`), this.#t = new qt(`${e.dbName}_leader`);
|
|
3223
3228
|
}
|
|
3224
3229
|
/**
|
|
3225
3230
|
* 初始化网关
|
|
@@ -3248,7 +3253,7 @@ class br {
|
|
|
3248
3253
|
*/
|
|
3249
3254
|
#c(e) {
|
|
3250
3255
|
this.#o || this.#e.emit({
|
|
3251
|
-
type:
|
|
3256
|
+
type: Xe,
|
|
3252
3257
|
messageId: this.#i(),
|
|
3253
3258
|
clientId: this.#n,
|
|
3254
3259
|
event: e
|
|
@@ -3259,7 +3264,7 @@ class br {
|
|
|
3259
3264
|
*/
|
|
3260
3265
|
#l() {
|
|
3261
3266
|
this.#e.emit({
|
|
3262
|
-
type:
|
|
3267
|
+
type: Ze,
|
|
3263
3268
|
messageId: this.#i(),
|
|
3264
3269
|
clientId: this.#n
|
|
3265
3270
|
});
|
|
@@ -3269,7 +3274,7 @@ class br {
|
|
|
3269
3274
|
*/
|
|
3270
3275
|
#p() {
|
|
3271
3276
|
this.#a && this.#e.emit({
|
|
3272
|
-
type:
|
|
3277
|
+
type: et,
|
|
3273
3278
|
messageId: this.#i(),
|
|
3274
3279
|
clientId: this.#n,
|
|
3275
3280
|
firstConnectedAt: this.#a.toISOString()
|
|
@@ -3282,7 +3287,7 @@ class br {
|
|
|
3282
3287
|
const t = this.#e.message$.subscribe((n) => {
|
|
3283
3288
|
if (n.clientId !== this.#n)
|
|
3284
3289
|
switch (n.type) {
|
|
3285
|
-
case
|
|
3290
|
+
case Xe:
|
|
3286
3291
|
this.#o = !0;
|
|
3287
3292
|
try {
|
|
3288
3293
|
e(n.event);
|
|
@@ -3290,10 +3295,10 @@ class br {
|
|
|
3290
3295
|
this.#o = !1;
|
|
3291
3296
|
}
|
|
3292
3297
|
break;
|
|
3293
|
-
case
|
|
3298
|
+
case Ze:
|
|
3294
3299
|
this.#s && this.#p();
|
|
3295
3300
|
break;
|
|
3296
|
-
case
|
|
3301
|
+
case et:
|
|
3297
3302
|
this.#a || (this.#a = new Date(n.firstConnectedAt));
|
|
3298
3303
|
break;
|
|
3299
3304
|
}
|
|
@@ -3316,7 +3321,7 @@ class br {
|
|
|
3316
3321
|
});
|
|
3317
3322
|
}
|
|
3318
3323
|
}
|
|
3319
|
-
const
|
|
3324
|
+
const Rr = (r) => {
|
|
3320
3325
|
const [{ metadata: e, relation: t }, { metadata: n, relation: s }] = r, a = Array.from(/* @__PURE__ */ new Set([e.namespace, n.namespace])).sort().join("_") || void 0;
|
|
3321
3326
|
return {
|
|
3322
3327
|
name: Array.from(/* @__PURE__ */ new Set([e.name, n.name])).sort().join("_"),
|
|
@@ -3352,12 +3357,12 @@ const vr = (r) => {
|
|
|
3352
3357
|
]
|
|
3353
3358
|
};
|
|
3354
3359
|
};
|
|
3355
|
-
var
|
|
3356
|
-
for (var s = n > 1 ? void 0 : n ?
|
|
3360
|
+
var Cr = Object.defineProperty, Ir = Object.getOwnPropertyDescriptor, Tr = (r, e, t) => e in r ? Cr(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, Ar = (r, e, t, n) => {
|
|
3361
|
+
for (var s = n > 1 ? void 0 : n ? Ir(e, t) : e, a = r.length - 1, i; a >= 0; a--)
|
|
3357
3362
|
(i = r[a]) && (s = i(s) || s);
|
|
3358
3363
|
return s;
|
|
3359
|
-
},
|
|
3360
|
-
|
|
3364
|
+
}, Mr = (r, e, t) => Tr(r, typeof e != "symbol" ? e + "" : e, t), Ct;
|
|
3365
|
+
Ct = Le;
|
|
3361
3366
|
let H = class {
|
|
3362
3367
|
/**
|
|
3363
3368
|
* id
|
|
@@ -3410,9 +3415,9 @@ let H = class {
|
|
|
3410
3415
|
*/
|
|
3411
3416
|
children$;
|
|
3412
3417
|
};
|
|
3413
|
-
|
|
3414
|
-
H =
|
|
3415
|
-
|
|
3418
|
+
Mr(H, Ct);
|
|
3419
|
+
H = Ar([
|
|
3420
|
+
Nn({
|
|
3416
3421
|
name: "RxDBBranch",
|
|
3417
3422
|
log: !1,
|
|
3418
3423
|
properties: [
|
|
@@ -3485,12 +3490,12 @@ H = Tr([
|
|
|
3485
3490
|
]
|
|
3486
3491
|
})
|
|
3487
3492
|
], H);
|
|
3488
|
-
var
|
|
3489
|
-
for (var s = n > 1 ? void 0 : n ?
|
|
3493
|
+
var Sr = Object.defineProperty, Or = Object.getOwnPropertyDescriptor, Nr = (r, e, t) => e in r ? Sr(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, Pr = (r, e, t, n) => {
|
|
3494
|
+
for (var s = n > 1 ? void 0 : n ? Or(e, t) : e, a = r.length - 1, i; a >= 0; a--)
|
|
3490
3495
|
(i = r[a]) && (s = i(s) || s);
|
|
3491
3496
|
return s;
|
|
3492
|
-
},
|
|
3493
|
-
|
|
3497
|
+
}, xr = (r, e, t) => Nr(r, typeof e != "symbol" ? e + "" : e, t), It;
|
|
3498
|
+
It = Le;
|
|
3494
3499
|
let K = class {
|
|
3495
3500
|
/**
|
|
3496
3501
|
* id
|
|
@@ -4026,8 +4031,8 @@ let K = class {
|
|
|
4026
4031
|
*/
|
|
4027
4032
|
branch$;
|
|
4028
4033
|
};
|
|
4029
|
-
|
|
4030
|
-
K =
|
|
4034
|
+
xr(K, It);
|
|
4035
|
+
K = Pr([
|
|
4031
4036
|
J({
|
|
4032
4037
|
name: "RxDBChange",
|
|
4033
4038
|
log: !1,
|
|
@@ -4119,12 +4124,12 @@ K = Nr([
|
|
|
4119
4124
|
]
|
|
4120
4125
|
})
|
|
4121
4126
|
], K);
|
|
4122
|
-
var
|
|
4123
|
-
for (var s = n > 1 ? void 0 : n ?
|
|
4127
|
+
var $r = Object.defineProperty, Dr = Object.getOwnPropertyDescriptor, Br = (r, e, t) => e in r ? $r(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, Lr = (r, e, t, n) => {
|
|
4128
|
+
for (var s = n > 1 ? void 0 : n ? Dr(e, t) : e, a = r.length - 1, i; a >= 0; a--)
|
|
4124
4129
|
(i = r[a]) && (s = i(s) || s);
|
|
4125
4130
|
return s;
|
|
4126
|
-
},
|
|
4127
|
-
|
|
4131
|
+
}, Ur = (r, e, t) => Br(r, typeof e != "symbol" ? e + "" : e, t), Tt;
|
|
4132
|
+
Tt = Le;
|
|
4128
4133
|
let oe = class {
|
|
4129
4134
|
/**
|
|
4130
4135
|
* id
|
|
@@ -4140,8 +4145,8 @@ let oe = class {
|
|
|
4140
4145
|
*/
|
|
4141
4146
|
name;
|
|
4142
4147
|
};
|
|
4143
|
-
|
|
4144
|
-
oe =
|
|
4148
|
+
Ur(oe, Tt);
|
|
4149
|
+
oe = Lr([
|
|
4145
4150
|
J({
|
|
4146
4151
|
name: "RxDBMigration",
|
|
4147
4152
|
log: !1,
|
|
@@ -4165,11 +4170,11 @@ oe = Br([
|
|
|
4165
4170
|
]
|
|
4166
4171
|
})
|
|
4167
4172
|
], oe);
|
|
4168
|
-
var
|
|
4169
|
-
for (var s = n > 1 ? void 0 : n ?
|
|
4173
|
+
var Fr = Object.defineProperty, Yr = Object.getOwnPropertyDescriptor, jr = (r, e, t) => e in r ? Fr(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, zr = (r, e, t, n) => {
|
|
4174
|
+
for (var s = n > 1 ? void 0 : n ? Yr(e, t) : e, a = r.length - 1, i; a >= 0; a--)
|
|
4170
4175
|
(i = r[a]) && (s = i(s) || s);
|
|
4171
4176
|
return s;
|
|
4172
|
-
}, Z = (r, e, t) =>
|
|
4177
|
+
}, Z = (r, e, t) => jr(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4173
4178
|
let D = class {
|
|
4174
4179
|
/**
|
|
4175
4180
|
* 主键ID
|
|
@@ -4238,7 +4243,7 @@ Z(D, "findOne");
|
|
|
4238
4243
|
Z(D, "findOneOrFail");
|
|
4239
4244
|
Z(D, "findByCursor");
|
|
4240
4245
|
Z(D, "count");
|
|
4241
|
-
D =
|
|
4246
|
+
D = zr([
|
|
4242
4247
|
J({
|
|
4243
4248
|
name: "RxDBRepositorySync",
|
|
4244
4249
|
log: !1,
|
|
@@ -4326,13 +4331,13 @@ D = jr([
|
|
|
4326
4331
|
]
|
|
4327
4332
|
})
|
|
4328
4333
|
], D);
|
|
4329
|
-
var
|
|
4330
|
-
for (var s = n > 1 ? void 0 : n ?
|
|
4334
|
+
var Wr = Object.getOwnPropertyDescriptor, Hr = (r, e, t, n) => {
|
|
4335
|
+
for (var s = n > 1 ? void 0 : n ? Wr(e, t) : e, a = r.length - 1, i; a >= 0; a--)
|
|
4331
4336
|
(i = r[a]) && (s = i(s) || s);
|
|
4332
4337
|
return s;
|
|
4333
4338
|
};
|
|
4334
4339
|
const te = (r, e) => e + ":" + r;
|
|
4335
|
-
class
|
|
4340
|
+
class Kr {
|
|
4336
4341
|
constructor(e) {
|
|
4337
4342
|
this.rxdb = e;
|
|
4338
4343
|
}
|
|
@@ -4346,7 +4351,7 @@ class Hr {
|
|
|
4346
4351
|
const o = this.rxdb.getRepositoryConfig(n.repository);
|
|
4347
4352
|
if (o?.entityGenerator) {
|
|
4348
4353
|
const c = o.entityGenerator(n);
|
|
4349
|
-
|
|
4354
|
+
Vt(c).forEach((d) => {
|
|
4350
4355
|
const h = A(d), u = te(h.name, h.namespace);
|
|
4351
4356
|
this.#e.has(u) || (this.#e.set(u, h), this.#t.set(u, d), e.push(d));
|
|
4352
4357
|
});
|
|
@@ -4357,14 +4362,14 @@ class Hr {
|
|
|
4357
4362
|
const s = n, a = this.findMappedRelation(t, s);
|
|
4358
4363
|
if (!a)
|
|
4359
4364
|
throw new v("mapped relation not found");
|
|
4360
|
-
const i =
|
|
4365
|
+
const i = Rr([
|
|
4361
4366
|
{ metadata: t, relation: s },
|
|
4362
4367
|
a
|
|
4363
4368
|
]), o = te(i.name, i.namespace);
|
|
4364
4369
|
if (this.#e.has(o) === !1) {
|
|
4365
4370
|
let c = class extends ae {
|
|
4366
4371
|
};
|
|
4367
|
-
c =
|
|
4372
|
+
c = Hr([
|
|
4368
4373
|
J(i)
|
|
4369
4374
|
], c);
|
|
4370
4375
|
const l = A(c);
|
|
@@ -4448,8 +4453,8 @@ class Hr {
|
|
|
4448
4453
|
return this.#t.get(n);
|
|
4449
4454
|
}
|
|
4450
4455
|
}
|
|
4451
|
-
const Se = (r) => `${r.namespace}:${r.entity}:${r.entityId}`,
|
|
4452
|
-
function
|
|
4456
|
+
const Se = (r) => `${r.namespace}:${r.entity}:${r.entityId}`, Ks = (r) => r.split(":");
|
|
4457
|
+
function At(r, e = {
|
|
4453
4458
|
deletes: /* @__PURE__ */ new Map(),
|
|
4454
4459
|
updates: /* @__PURE__ */ new Map(),
|
|
4455
4460
|
inserts: /* @__PURE__ */ new Map()
|
|
@@ -4486,7 +4491,7 @@ function Tt(r, e = {
|
|
|
4486
4491
|
}
|
|
4487
4492
|
return e;
|
|
4488
4493
|
}
|
|
4489
|
-
function
|
|
4494
|
+
function Ye(r) {
|
|
4490
4495
|
const e = /* @__PURE__ */ new Map();
|
|
4491
4496
|
for (const t of r) {
|
|
4492
4497
|
const n = `${t.namespace}:${t.name}`, s = {
|
|
@@ -4511,9 +4516,9 @@ function Fe(r) {
|
|
|
4511
4516
|
const s = `${n.namespace}:${n.entity}`, a = e.get(s);
|
|
4512
4517
|
a && a.requiredBy.push(t.repository);
|
|
4513
4518
|
}
|
|
4514
|
-
return
|
|
4519
|
+
return kr(e), e;
|
|
4515
4520
|
}
|
|
4516
|
-
function
|
|
4521
|
+
function kr(r) {
|
|
4517
4522
|
const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Set(), n = [];
|
|
4518
4523
|
function s(a) {
|
|
4519
4524
|
e.add(a), t.add(a), n.push(a);
|
|
@@ -4535,11 +4540,11 @@ function Kr(r) {
|
|
|
4535
4540
|
for (const a of r.keys())
|
|
4536
4541
|
e.has(a) || s(a);
|
|
4537
4542
|
}
|
|
4538
|
-
function
|
|
4543
|
+
function qr(r, e) {
|
|
4539
4544
|
return r.sync || e;
|
|
4540
4545
|
}
|
|
4541
4546
|
function V(r, e) {
|
|
4542
|
-
const t =
|
|
4547
|
+
const t = qr(r, e);
|
|
4543
4548
|
if (!t)
|
|
4544
4549
|
return "none";
|
|
4545
4550
|
if (t.type === le.Filter)
|
|
@@ -4554,15 +4559,15 @@ function V(r, e) {
|
|
|
4554
4559
|
}
|
|
4555
4560
|
return "none";
|
|
4556
4561
|
}
|
|
4557
|
-
function
|
|
4562
|
+
function Mt(r, e) {
|
|
4558
4563
|
const t = V(r, e);
|
|
4559
4564
|
return t === "full" || t === "remote";
|
|
4560
4565
|
}
|
|
4561
|
-
function
|
|
4566
|
+
function Vr(r, e) {
|
|
4562
4567
|
const t = V(r, e);
|
|
4563
4568
|
return t === "full" || t === "local";
|
|
4564
4569
|
}
|
|
4565
|
-
function
|
|
4570
|
+
function je(r, e) {
|
|
4566
4571
|
const t = [], n = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set();
|
|
4567
4572
|
function a(i) {
|
|
4568
4573
|
if (n.has(i)) return;
|
|
@@ -4583,33 +4588,33 @@ function Ye(r, e) {
|
|
|
4583
4588
|
a(i);
|
|
4584
4589
|
return t;
|
|
4585
4590
|
}
|
|
4586
|
-
function Vr(r) {
|
|
4587
|
-
return Ye(r, "pull");
|
|
4588
|
-
}
|
|
4589
4591
|
function Gr(r) {
|
|
4590
|
-
return
|
|
4592
|
+
return je(r, "pull");
|
|
4593
|
+
}
|
|
4594
|
+
function Jr(r) {
|
|
4595
|
+
return je(r, "push");
|
|
4591
4596
|
}
|
|
4592
|
-
const
|
|
4597
|
+
const Qr = {
|
|
4593
4598
|
limit: 1e3,
|
|
4594
4599
|
fetchAll: !1,
|
|
4595
4600
|
includeRelated: !0
|
|
4596
4601
|
};
|
|
4597
|
-
async function
|
|
4598
|
-
const s = { ...
|
|
4599
|
-
a.dispatchEvent(new
|
|
4602
|
+
async function St(r, e, t, n) {
|
|
4603
|
+
const s = { ...Qr, ...n }, a = r.rxdb;
|
|
4604
|
+
a.dispatchEvent(new $e("pull", e, t, s.includeRelated));
|
|
4600
4605
|
try {
|
|
4601
|
-
const i = await
|
|
4606
|
+
const i = await Xr(r, e, t, s);
|
|
4602
4607
|
return a.dispatchEvent(
|
|
4603
|
-
new
|
|
4608
|
+
new De("pull", e, t, {
|
|
4604
4609
|
pulled: i.pulled,
|
|
4605
4610
|
compacted: i.compacted
|
|
4606
4611
|
})
|
|
4607
4612
|
), i;
|
|
4608
4613
|
} catch (i) {
|
|
4609
|
-
throw a.dispatchEvent(new
|
|
4614
|
+
throw a.dispatchEvent(new Be("pull", e, t, i)), i;
|
|
4610
4615
|
}
|
|
4611
4616
|
}
|
|
4612
|
-
async function
|
|
4617
|
+
async function Xr(r, e, t, n) {
|
|
4613
4618
|
const s = r.rxdb.config.entities.find((o) => {
|
|
4614
4619
|
const c = A(o);
|
|
4615
4620
|
return c.namespace === e && c.name === t;
|
|
@@ -4621,10 +4626,10 @@ async function Qr(r, e, t, n) {
|
|
|
4621
4626
|
throw new v(`Cannot pull repository ${e}:${t}: syncType is 'none'.`);
|
|
4622
4627
|
if (i === "local")
|
|
4623
4628
|
throw new v(`Cannot pull repository ${e}:${t}: syncType is 'local' (no remote).`);
|
|
4624
|
-
return n.includeRelated ? await
|
|
4629
|
+
return n.includeRelated ? await Zr(r, e, t, n) : await Ot(r, e, t, n);
|
|
4625
4630
|
}
|
|
4626
|
-
async function
|
|
4627
|
-
const s = r.rxdb.config.entities.map((p) => A(p)), a =
|
|
4631
|
+
async function Zr(r, e, t, n) {
|
|
4632
|
+
const s = r.rxdb.config.entities.map((p) => A(p)), a = Ye(s), i = Gr(a), o = `${e}:${t}`;
|
|
4628
4633
|
if (!a.get(o))
|
|
4629
4634
|
throw new v(`Repository ${e}:${t} not found in dependency graph`);
|
|
4630
4635
|
const l = /* @__PURE__ */ new Set([o]), d = (p) => {
|
|
@@ -4658,7 +4663,7 @@ async function Xr(r, e, t, n) {
|
|
|
4658
4663
|
continue;
|
|
4659
4664
|
}
|
|
4660
4665
|
try {
|
|
4661
|
-
const w = await
|
|
4666
|
+
const w = await Ot(r, p.namespace, p.entity, {
|
|
4662
4667
|
...n,
|
|
4663
4668
|
includeRelated: !1
|
|
4664
4669
|
// 防止递归级联
|
|
@@ -4683,7 +4688,7 @@ async function Xr(r, e, t, n) {
|
|
|
4683
4688
|
throw f.error;
|
|
4684
4689
|
return f;
|
|
4685
4690
|
}
|
|
4686
|
-
async function
|
|
4691
|
+
async function Ot(r, e, t, n) {
|
|
4687
4692
|
if (!r.rxdb.config.sync?.remote?.adapter)
|
|
4688
4693
|
throw new v("Remote adapter not configured.");
|
|
4689
4694
|
const { adapter: i } = await r.getRemoteRepositories(), { adapter: o } = await r.getLocalRepositories(), c = await r.getCurrentBranch(), l = `${e}:${t}:${c.id}`, d = o.getRepository(D);
|
|
@@ -4722,7 +4727,7 @@ async function St(r, e, t, n) {
|
|
|
4722
4727
|
_ = !1;
|
|
4723
4728
|
break;
|
|
4724
4729
|
}
|
|
4725
|
-
w = C[C.length - 1], E = w.id,
|
|
4730
|
+
w = C[C.length - 1], E = w.id, At(C, b);
|
|
4726
4731
|
const Y = b.inserts.size + b.updates.size + b.deletes.size;
|
|
4727
4732
|
if (y += C.length - Y, _ = C.length >= n.limit, await o.mergeChanges(b, void 0, !0), Y > 0) {
|
|
4728
4733
|
const M = w.id;
|
|
@@ -4742,27 +4747,27 @@ async function St(r, e, t, n) {
|
|
|
4742
4747
|
hasMore: _
|
|
4743
4748
|
};
|
|
4744
4749
|
}
|
|
4745
|
-
const
|
|
4750
|
+
const es = {
|
|
4746
4751
|
batchSize: 1e3,
|
|
4747
4752
|
includeRelated: !0
|
|
4748
4753
|
};
|
|
4749
|
-
async function
|
|
4750
|
-
const s = { ...
|
|
4751
|
-
a.dispatchEvent(new
|
|
4754
|
+
async function Nt(r, e, t, n) {
|
|
4755
|
+
const s = { ...es, ...n }, a = r.rxdb;
|
|
4756
|
+
a.dispatchEvent(new $e("push", e, t, s.includeRelated));
|
|
4752
4757
|
try {
|
|
4753
|
-
const i = await
|
|
4758
|
+
const i = await ts(r, e, t, s);
|
|
4754
4759
|
return a.dispatchEvent(
|
|
4755
|
-
new
|
|
4760
|
+
new De("push", e, t, {
|
|
4756
4761
|
pushed: i.pushed,
|
|
4757
4762
|
compacted: i.compacted,
|
|
4758
4763
|
failed: i.failed
|
|
4759
4764
|
})
|
|
4760
4765
|
), i;
|
|
4761
4766
|
} catch (i) {
|
|
4762
|
-
throw a.dispatchEvent(new
|
|
4767
|
+
throw a.dispatchEvent(new Be("push", e, t, i)), i;
|
|
4763
4768
|
}
|
|
4764
4769
|
}
|
|
4765
|
-
async function
|
|
4770
|
+
async function ts(r, e, t, n) {
|
|
4766
4771
|
const s = r.rxdb.config.entities.find((o) => {
|
|
4767
4772
|
const c = A(o);
|
|
4768
4773
|
return c.namespace === e && c.name === t;
|
|
@@ -4774,10 +4779,10 @@ async function es(r, e, t, n) {
|
|
|
4774
4779
|
throw new v(`Cannot push repository ${e}:${t}: syncType is 'none'.`);
|
|
4775
4780
|
if (i === "remote")
|
|
4776
4781
|
throw new v(`Cannot push repository ${e}:${t}: syncType is 'remote' (read-only).`);
|
|
4777
|
-
return n.includeRelated ? await
|
|
4782
|
+
return n.includeRelated ? await ns(r, e, t, n) : await Pt(r, e, t);
|
|
4778
4783
|
}
|
|
4779
|
-
async function
|
|
4780
|
-
const s = r.rxdb.config.entities.map((p) => A(p)), a =
|
|
4784
|
+
async function ns(r, e, t, n) {
|
|
4785
|
+
const s = r.rxdb.config.entities.map((p) => A(p)), a = Ye(s), i = Jr(a), o = `${e}:${t}`;
|
|
4781
4786
|
if (!a.get(o))
|
|
4782
4787
|
throw new v(`Repository ${e}:${t} not found in dependency graph`);
|
|
4783
4788
|
const l = /* @__PURE__ */ new Set([o]), d = (p) => {
|
|
@@ -4811,7 +4816,7 @@ async function ts(r, e, t, n) {
|
|
|
4811
4816
|
continue;
|
|
4812
4817
|
}
|
|
4813
4818
|
try {
|
|
4814
|
-
const w = await
|
|
4819
|
+
const w = await Pt(r, p.namespace, p.entity, {
|
|
4815
4820
|
...n,
|
|
4816
4821
|
includeRelated: !1
|
|
4817
4822
|
// 防止递归级联
|
|
@@ -4836,7 +4841,7 @@ async function ts(r, e, t, n) {
|
|
|
4836
4841
|
throw f.error;
|
|
4837
4842
|
return f;
|
|
4838
4843
|
}
|
|
4839
|
-
async function
|
|
4844
|
+
async function Pt(r, e, t, n) {
|
|
4840
4845
|
if (!r.rxdb.config.sync?.remote?.adapter)
|
|
4841
4846
|
throw new v("Remote adapter not configured.");
|
|
4842
4847
|
await r.getRemoteRepositories();
|
|
@@ -4850,8 +4855,8 @@ async function Nt(r, e, t, n) {
|
|
|
4850
4855
|
}))[0];
|
|
4851
4856
|
if (!h) {
|
|
4852
4857
|
const M = r.rxdb.config.entities.find((ee) => {
|
|
4853
|
-
const
|
|
4854
|
-
return
|
|
4858
|
+
const ze = A(ee);
|
|
4859
|
+
return ze.namespace === e && ze.name === t;
|
|
4855
4860
|
}), P = A(M), Q = V(P, r.rxdb.config.sync), $ = new D();
|
|
4856
4861
|
$.id = c, $.namespace = e, $.entity = t, $.branchId = o.id, $.syncType = Q, $.lastPushedChangeId = null, $.lastPushedAt = null, $.lastPulledAt = null, $.lastPullRemoteChangeId = null, $.enabled = !0, $.createdAt = /* @__PURE__ */ new Date(), $.updatedAt = /* @__PURE__ */ new Date(), h = await l.create($);
|
|
4857
4862
|
}
|
|
@@ -4863,7 +4868,7 @@ async function Nt(r, e, t, n) {
|
|
|
4863
4868
|
limit: 1
|
|
4864
4869
|
});
|
|
4865
4870
|
u.length > 0 && (h = u[0]);
|
|
4866
|
-
const m = h.lastPushedChangeId, f = i.getRepository(K), p = await
|
|
4871
|
+
const m = h.lastPushedChangeId, f = i.getRepository(K), p = await rs(f, o.id, m, [t]), y = p.length;
|
|
4867
4872
|
if (y === 0)
|
|
4868
4873
|
return {
|
|
4869
4874
|
repository: { namespace: e, entity: t },
|
|
@@ -4877,7 +4882,7 @@ async function Nt(r, e, t, n) {
|
|
|
4877
4882
|
updates: /* @__PURE__ */ new Map(),
|
|
4878
4883
|
inserts: /* @__PURE__ */ new Map()
|
|
4879
4884
|
};
|
|
4880
|
-
|
|
4885
|
+
At(
|
|
4881
4886
|
p.map((M) => ({
|
|
4882
4887
|
id: M.id,
|
|
4883
4888
|
namespace: M.namespace,
|
|
@@ -4921,7 +4926,7 @@ async function Nt(r, e, t, n) {
|
|
|
4921
4926
|
originalCount: y
|
|
4922
4927
|
};
|
|
4923
4928
|
}
|
|
4924
|
-
async function
|
|
4929
|
+
async function rs(r, e, t, n) {
|
|
4925
4930
|
const s = [
|
|
4926
4931
|
{ field: "branchId", operator: "=", value: e },
|
|
4927
4932
|
{ field: "revertChangeId", operator: "=", value: null },
|
|
@@ -4935,22 +4940,22 @@ async function ns(r, e, t, n) {
|
|
|
4935
4940
|
orderBy: [{ field: "id", sort: "asc" }]
|
|
4936
4941
|
});
|
|
4937
4942
|
}
|
|
4938
|
-
async function
|
|
4943
|
+
async function xt(r, e, t, n) {
|
|
4939
4944
|
const s = r.rxdb, a = n?.pull?.includeRelated ?? n?.push?.includeRelated ?? !0;
|
|
4940
|
-
s.dispatchEvent(new
|
|
4945
|
+
s.dispatchEvent(new $e("sync", e, t, a));
|
|
4941
4946
|
try {
|
|
4942
|
-
const i = await
|
|
4947
|
+
const i = await ss(r, e, t, n), o = {
|
|
4943
4948
|
pulled: i.pullResult?.pulled ?? 0,
|
|
4944
4949
|
pushed: i.pushResult?.pushed ?? 0,
|
|
4945
4950
|
compacted: (i.pullResult?.compacted ?? 0) + (i.pushResult?.compacted ?? 0),
|
|
4946
4951
|
failed: i.pushResult?.failed ?? 0
|
|
4947
4952
|
};
|
|
4948
|
-
return s.dispatchEvent(new
|
|
4953
|
+
return s.dispatchEvent(new De("sync", e, t, o)), i;
|
|
4949
4954
|
} catch (i) {
|
|
4950
|
-
throw s.dispatchEvent(new
|
|
4955
|
+
throw s.dispatchEvent(new Be("sync", e, t, i)), i;
|
|
4951
4956
|
}
|
|
4952
4957
|
}
|
|
4953
|
-
async function
|
|
4958
|
+
async function ss(r, e, t, n) {
|
|
4954
4959
|
const s = r.rxdb.config.entities.find((h) => {
|
|
4955
4960
|
const u = A(h);
|
|
4956
4961
|
return u.namespace === e && u.name === t;
|
|
@@ -4963,7 +4968,7 @@ async function rs(r, e, t, n) {
|
|
|
4963
4968
|
`Cannot sync repository ${e}:${t}: syncType is 'none'. This entity is not configured for remote synchronization.`
|
|
4964
4969
|
);
|
|
4965
4970
|
let o;
|
|
4966
|
-
(n?.direction === "pull" || n?.direction === "sync" || !n?.direction) && (i === "remote" || i === "full") ? o = await
|
|
4971
|
+
(n?.direction === "pull" || n?.direction === "sync" || !n?.direction) && (i === "remote" || i === "full") ? o = await St(r, e, t, n?.pull) : o = {
|
|
4967
4972
|
repository: { namespace: e, entity: t },
|
|
4968
4973
|
pulled: 0,
|
|
4969
4974
|
compacted: 0,
|
|
@@ -4971,7 +4976,7 @@ async function rs(r, e, t, n) {
|
|
|
4971
4976
|
hasMore: !1
|
|
4972
4977
|
};
|
|
4973
4978
|
let l;
|
|
4974
|
-
return (n?.direction === "push" || n?.direction === "sync" || !n?.direction) && (i === "local" || i === "full") ? l = await
|
|
4979
|
+
return (n?.direction === "push" || n?.direction === "sync" || !n?.direction) && (i === "local" || i === "full") ? l = await Nt(r, e, t, n?.push) : l = {
|
|
4975
4980
|
repository: { namespace: e, entity: t },
|
|
4976
4981
|
pushed: 0,
|
|
4977
4982
|
failed: 0,
|
|
@@ -4982,7 +4987,7 @@ async function rs(r, e, t, n) {
|
|
|
4982
4987
|
pushResult: l
|
|
4983
4988
|
};
|
|
4984
4989
|
}
|
|
4985
|
-
function
|
|
4990
|
+
function as(r, e) {
|
|
4986
4991
|
if (e.repositories && e.repositories.length > 0)
|
|
4987
4992
|
return e.repositories;
|
|
4988
4993
|
const t = [];
|
|
@@ -4995,9 +5000,9 @@ function ss(r, e) {
|
|
|
4995
5000
|
}
|
|
4996
5001
|
return t;
|
|
4997
5002
|
}
|
|
4998
|
-
async function
|
|
5003
|
+
async function $t(r, e, t) {
|
|
4999
5004
|
try {
|
|
5000
|
-
const n = await
|
|
5005
|
+
const n = await xt(r.versionManager, e.namespace, e.entity, t);
|
|
5001
5006
|
return {
|
|
5002
5007
|
repository: e,
|
|
5003
5008
|
success: !0,
|
|
@@ -5011,30 +5016,30 @@ async function xt(r, e, t) {
|
|
|
5011
5016
|
};
|
|
5012
5017
|
}
|
|
5013
5018
|
}
|
|
5014
|
-
async function
|
|
5019
|
+
async function is(r, e, t) {
|
|
5015
5020
|
const n = [];
|
|
5016
5021
|
for (const s of e) {
|
|
5017
|
-
const a = await
|
|
5022
|
+
const a = await $t(r, s, t);
|
|
5018
5023
|
n.push(a);
|
|
5019
5024
|
}
|
|
5020
5025
|
return n;
|
|
5021
5026
|
}
|
|
5022
|
-
async function
|
|
5027
|
+
async function os(r, e, t, n) {
|
|
5023
5028
|
const s = [];
|
|
5024
5029
|
for (let a = 0; a < e.length; a += n) {
|
|
5025
|
-
const o = e.slice(a, a + n).map((l) =>
|
|
5030
|
+
const o = e.slice(a, a + n).map((l) => $t(r, l, t)), c = await Promise.all(o);
|
|
5026
5031
|
s.push(...c);
|
|
5027
5032
|
}
|
|
5028
5033
|
return s;
|
|
5029
5034
|
}
|
|
5030
|
-
async function
|
|
5031
|
-
const t = Date.now(), n =
|
|
5035
|
+
async function cs(r, e = {}) {
|
|
5036
|
+
const t = Date.now(), n = as(r, e), s = {
|
|
5032
5037
|
direction: e.operation,
|
|
5033
5038
|
pull: e.pull,
|
|
5034
5039
|
push: e.push
|
|
5035
5040
|
}, a = e.concurrent ?? !1, i = e.concurrency ?? 3;
|
|
5036
5041
|
let o;
|
|
5037
|
-
a ? o = await
|
|
5042
|
+
a ? o = await os(r, n, s, i) : o = await is(r, n, s);
|
|
5038
5043
|
const c = o.filter((h) => h.success).length, l = o.filter((h) => !h.success).length, d = Date.now() - t;
|
|
5039
5044
|
return {
|
|
5040
5045
|
succeeded: c,
|
|
@@ -5043,7 +5048,7 @@ async function os(r, e = {}) {
|
|
|
5043
5048
|
durationMs: d
|
|
5044
5049
|
};
|
|
5045
5050
|
}
|
|
5046
|
-
async function
|
|
5051
|
+
async function Dt(r, e, t) {
|
|
5047
5052
|
const n = { namespace: e, entity: t }, s = r.config.entities.find((w) => {
|
|
5048
5053
|
const E = A(w);
|
|
5049
5054
|
return E.namespace === e && E.name === t;
|
|
@@ -5051,7 +5056,7 @@ async function $t(r, e, t) {
|
|
|
5051
5056
|
if (!s)
|
|
5052
5057
|
throw new Error(`Entity not found: ${e}.${t}`);
|
|
5053
5058
|
const a = A(s);
|
|
5054
|
-
if (!
|
|
5059
|
+
if (!Mt(a))
|
|
5055
5060
|
return {
|
|
5056
5061
|
repository: n,
|
|
5057
5062
|
remoteLatestChangeId: 0,
|
|
@@ -5079,7 +5084,7 @@ async function $t(r, e, t) {
|
|
|
5079
5084
|
hasUpdates: g > 0
|
|
5080
5085
|
};
|
|
5081
5086
|
}
|
|
5082
|
-
const
|
|
5087
|
+
const ls = async (r, e, t) => {
|
|
5083
5088
|
const { branchRepository: n, changeRepository: s } = await r.getLocalRepositories();
|
|
5084
5089
|
if ((await n.find({
|
|
5085
5090
|
where: {
|
|
@@ -5106,11 +5111,11 @@ const cs = async (r, e, t) => {
|
|
|
5106
5111
|
limit: 1
|
|
5107
5112
|
}))[0];
|
|
5108
5113
|
} else
|
|
5109
|
-
i = await r.getCurrentBranch(), i && (o = await
|
|
5114
|
+
i = await r.getCurrentBranch(), i && (o = await ds(r, i.id));
|
|
5110
5115
|
if (!i) throw new v("Source branch not found");
|
|
5111
5116
|
const c = new H();
|
|
5112
5117
|
return c.id = e, c.activated = !1, c.local = !0, c.remote = !1, c.fromChangeId = o?.id ?? null, c.parentId = i.id, await c.save(), c;
|
|
5113
|
-
},
|
|
5118
|
+
}, ds = async (r, e) => {
|
|
5114
5119
|
const { changeRepository: t } = await r.getLocalRepositories();
|
|
5115
5120
|
return (await t.find({
|
|
5116
5121
|
where: {
|
|
@@ -5128,7 +5133,7 @@ const cs = async (r, e, t) => {
|
|
|
5128
5133
|
limit: 1
|
|
5129
5134
|
}))[0];
|
|
5130
5135
|
};
|
|
5131
|
-
async function
|
|
5136
|
+
async function hs(r, e, t, n, s) {
|
|
5132
5137
|
const { adapter: a } = await r.versionManager.getLocalRepositories(), i = a.getRepository(K), o = [
|
|
5133
5138
|
{ field: "namespace", operator: "=", value: e },
|
|
5134
5139
|
{ field: "entity", operator: "=", value: t },
|
|
@@ -5143,10 +5148,10 @@ async function ds(r, e, t, n, s) {
|
|
|
5143
5148
|
}
|
|
5144
5149
|
})).length;
|
|
5145
5150
|
}
|
|
5146
|
-
async function
|
|
5147
|
-
return (await
|
|
5151
|
+
async function us(r, e, t) {
|
|
5152
|
+
return (await Dt(r, e, t)).pendingCount;
|
|
5148
5153
|
}
|
|
5149
|
-
async function
|
|
5154
|
+
async function Bt(r, e, t) {
|
|
5150
5155
|
const n = r.config.entities.find((y) => {
|
|
5151
5156
|
const g = A(y);
|
|
5152
5157
|
return g.namespace === e && g.name === t;
|
|
@@ -5158,13 +5163,13 @@ async function Dt(r, e, t) {
|
|
|
5158
5163
|
rules: [{ field: "id", operator: "=", value: `${e}:${t}:${o}` }]
|
|
5159
5164
|
}, u = await l.find({ where: h, limit: 1 }), m = u.length > 0 ? u[0] : null;
|
|
5160
5165
|
let f = 0, p = 0;
|
|
5161
|
-
return
|
|
5166
|
+
return Vr(s) && (f = await hs(
|
|
5162
5167
|
r,
|
|
5163
5168
|
e,
|
|
5164
5169
|
t,
|
|
5165
5170
|
o,
|
|
5166
5171
|
m?.lastPushedChangeId ?? null
|
|
5167
|
-
)),
|
|
5172
|
+
)), Mt(s) && (p = await us(r, e, t)), {
|
|
5168
5173
|
repository: { namespace: e, entity: t },
|
|
5169
5174
|
branchId: o,
|
|
5170
5175
|
syncType: a,
|
|
@@ -5177,16 +5182,16 @@ async function Dt(r, e, t) {
|
|
|
5177
5182
|
pullableCount: p
|
|
5178
5183
|
};
|
|
5179
5184
|
}
|
|
5180
|
-
async function
|
|
5185
|
+
async function ps(r, e) {
|
|
5181
5186
|
const t = r.config.entities, n = [];
|
|
5182
5187
|
for (const a of t) {
|
|
5183
|
-
const i = A(a), o = i.namespace, c = i.name, l = await
|
|
5188
|
+
const i = A(a), o = i.namespace, c = i.name, l = await Bt(r, o, c);
|
|
5184
5189
|
n.push(l);
|
|
5185
5190
|
}
|
|
5186
5191
|
let s = n;
|
|
5187
5192
|
return e?.syncType && e.syncType.length > 0 && (s = s.filter((a) => e.syncType.includes(a.syncType))), e?.enabled !== void 0 && (s = s.filter((a) => a.enabled === e.enabled)), e?.hasPendingChanges !== void 0 && (e.hasPendingChanges ? s = s.filter((a) => a.pushableCount > 0 || a.pullableCount > 0) : s = s.filter((a) => a.pushableCount === 0 && a.pullableCount === 0)), s;
|
|
5188
5193
|
}
|
|
5189
|
-
const
|
|
5194
|
+
const fs = (r) => {
|
|
5190
5195
|
const { branches: e, currentBranch: t, nextBranch: n } = r, s = r.currentChangeId ?? t.fromChangeId ?? 0, a = r.nextChangeId ?? n.fromChangeId ?? 0;
|
|
5191
5196
|
if (s === a)
|
|
5192
5197
|
return [];
|
|
@@ -5284,7 +5289,7 @@ const ps = (r) => {
|
|
|
5284
5289
|
}
|
|
5285
5290
|
}
|
|
5286
5291
|
return u;
|
|
5287
|
-
},
|
|
5292
|
+
}, ys = async (r, e) => {
|
|
5288
5293
|
const { branchRepository: t, changeRepository: n } = await r.getLocalRepositories(), s = await t.find({
|
|
5289
5294
|
where: {
|
|
5290
5295
|
combinator: "and",
|
|
@@ -5297,7 +5302,7 @@ const ps = (r) => {
|
|
|
5297
5302
|
if (!i) throw new v(`Branch (${e}) not found`);
|
|
5298
5303
|
if (a.id === i.id)
|
|
5299
5304
|
throw new v("Cannot switch to the same branch");
|
|
5300
|
-
const o = await
|
|
5305
|
+
const o = await tt(n, a.id), c = await tt(n, i.id), l = fs({
|
|
5301
5306
|
branches: s,
|
|
5302
5307
|
currentBranch: a,
|
|
5303
5308
|
currentChangeId: o ? o.id : null,
|
|
@@ -5322,10 +5327,10 @@ const ps = (r) => {
|
|
|
5322
5327
|
};
|
|
5323
5328
|
u.fromChangeId && g < u.fromChangeId && w.where.rules.push({ field: "id", operator: ">", value: u.fromChangeId });
|
|
5324
5329
|
const E = await n.find(w);
|
|
5325
|
-
y ?
|
|
5330
|
+
y ? gs(E, d) : p && ms(E, d);
|
|
5326
5331
|
}
|
|
5327
5332
|
return d;
|
|
5328
|
-
},
|
|
5333
|
+
}, ms = (r, e) => pe(r, !0, e), gs = (r, e) => pe(r, !1, e), pe = (r, e, t = {
|
|
5329
5334
|
deletes: /* @__PURE__ */ new Map(),
|
|
5330
5335
|
updates: /* @__PURE__ */ new Map(),
|
|
5331
5336
|
inserts: /* @__PURE__ */ new Map()
|
|
@@ -5388,7 +5393,7 @@ const ps = (r) => {
|
|
|
5388
5393
|
}
|
|
5389
5394
|
}
|
|
5390
5395
|
return t;
|
|
5391
|
-
},
|
|
5396
|
+
}, tt = async (r, e) => (await r.find({
|
|
5392
5397
|
where: {
|
|
5393
5398
|
combinator: "and",
|
|
5394
5399
|
rules: [
|
|
@@ -5406,11 +5411,11 @@ function ne(r, e) {
|
|
|
5406
5411
|
...t,
|
|
5407
5412
|
changes: n,
|
|
5408
5413
|
count: n.length,
|
|
5409
|
-
description:
|
|
5414
|
+
description: Lt(n)
|
|
5410
5415
|
};
|
|
5411
5416
|
}).filter((t) => t !== null);
|
|
5412
5417
|
}
|
|
5413
|
-
function
|
|
5418
|
+
function Lt(r) {
|
|
5414
5419
|
if (r.length === 1) {
|
|
5415
5420
|
const n = r[0];
|
|
5416
5421
|
return `${n.type === "INSERT" ? "创建" : n.type === "UPDATE" ? "更新" : "删除"} ${n.entity}`;
|
|
@@ -5421,10 +5426,10 @@ function Bt(r) {
|
|
|
5421
5426
|
), t = [];
|
|
5422
5427
|
return e.insert && t.push(`创建${e.insert}条`), e.update && t.push(`更新${e.update}条`), e.delete && t.push(`删除${e.delete}条`), `事务: ${t.join(", ")}`;
|
|
5423
5428
|
}
|
|
5424
|
-
function
|
|
5429
|
+
function _s(r) {
|
|
5425
5430
|
return r.type === "database" ? "database" : r.type === "repository" ? `${r.namespace}:${r.entity}` : `${r.namespace}:${r.entity}:${r.entityId}`;
|
|
5426
5431
|
}
|
|
5427
|
-
class
|
|
5432
|
+
class ws {
|
|
5428
5433
|
constructor(e) {
|
|
5429
5434
|
this.rxdb = e;
|
|
5430
5435
|
const t = e.entityManager.getRepository(H).findOne({
|
|
@@ -5535,7 +5540,7 @@ class _s {
|
|
|
5535
5540
|
})
|
|
5536
5541
|
).subscribe(() => {
|
|
5537
5542
|
this.#l();
|
|
5538
|
-
}), this.rxdb.addEventListener(
|
|
5543
|
+
}), this.rxdb.addEventListener(dt, () => {
|
|
5539
5544
|
this.#l(), this.#n.next(Date.now());
|
|
5540
5545
|
}), this.#l();
|
|
5541
5546
|
}
|
|
@@ -5820,7 +5825,7 @@ class _s {
|
|
|
5820
5825
|
entity: f.name
|
|
5821
5826
|
};
|
|
5822
5827
|
}
|
|
5823
|
-
const n =
|
|
5828
|
+
const n = _s(t);
|
|
5824
5829
|
if (this.history_cache) {
|
|
5825
5830
|
const f = this.history_cache.get(n);
|
|
5826
5831
|
if (f)
|
|
@@ -5836,9 +5841,9 @@ class _s {
|
|
|
5836
5841
|
this.history_ref_counts.set(n, f);
|
|
5837
5842
|
}, i = this.histories$.pipe(
|
|
5838
5843
|
L((f) => ne(f, t)),
|
|
5839
|
-
|
|
5844
|
+
nn(s),
|
|
5840
5845
|
B({ bufferSize: 1, refCount: !0 })
|
|
5841
|
-
), o = (f) => new
|
|
5846
|
+
), o = (f) => new it((p) => {
|
|
5842
5847
|
a();
|
|
5843
5848
|
const y = f.subscribe(p);
|
|
5844
5849
|
return () => {
|
|
@@ -5963,7 +5968,7 @@ class _s {
|
|
|
5963
5968
|
* @returns 结构化的历史项,包含描述、类型、状态等信息
|
|
5964
5969
|
*/
|
|
5965
5970
|
#i(e) {
|
|
5966
|
-
const t = e[0], n = e.length, s = t.transactionId ?? null, a = t.createdAt, i = t.namespace, o = t.entity, c = s ? "TRANSACTION" : t.type, l = [c, t.entityId, a.getTime()].join(":"), d = e.some((u) =>
|
|
5971
|
+
const t = e[0], n = e.length, s = t.transactionId ?? null, a = t.createdAt, i = t.namespace, o = t.entity, c = s ? "TRANSACTION" : t.type, l = [c, t.entityId, a.getTime()].join(":"), d = e.some((u) => We(u.revertChangeId) === !1), h = e.some((u) => We(u.redoInvalidatedAt) === !1);
|
|
5967
5972
|
return {
|
|
5968
5973
|
transactionId: s,
|
|
5969
5974
|
changeId: Math.max(...e.map((u) => u.id)),
|
|
@@ -5972,7 +5977,7 @@ class _s {
|
|
|
5972
5977
|
type: c,
|
|
5973
5978
|
count: n,
|
|
5974
5979
|
createdAt: a,
|
|
5975
|
-
description:
|
|
5980
|
+
description: Lt(e),
|
|
5976
5981
|
namespace: i,
|
|
5977
5982
|
entity: o,
|
|
5978
5983
|
reverted: d,
|
|
@@ -6095,11 +6100,11 @@ class _s {
|
|
|
6095
6100
|
}
|
|
6096
6101
|
}
|
|
6097
6102
|
}
|
|
6098
|
-
async function
|
|
6103
|
+
async function nt(r, e) {
|
|
6099
6104
|
const t = r.rxdb;
|
|
6100
6105
|
if (!t.config.sync?.remote?.adapter)
|
|
6101
6106
|
throw new v("Remote adapter not configured.");
|
|
6102
|
-
t.dispatchEvent(new
|
|
6107
|
+
t.dispatchEvent(new ht("pull"));
|
|
6103
6108
|
try {
|
|
6104
6109
|
const s = {
|
|
6105
6110
|
operation: "pull",
|
|
@@ -6117,16 +6122,16 @@ async function tt(r, e) {
|
|
|
6117
6122
|
applied: c,
|
|
6118
6123
|
hasMore: l
|
|
6119
6124
|
};
|
|
6120
|
-
return t.dispatchEvent(new
|
|
6125
|
+
return t.dispatchEvent(new ut("pull", d)), d;
|
|
6121
6126
|
} catch (s) {
|
|
6122
|
-
throw t.dispatchEvent(new
|
|
6127
|
+
throw t.dispatchEvent(new pt("pull", s)), s;
|
|
6123
6128
|
}
|
|
6124
6129
|
}
|
|
6125
|
-
async function
|
|
6130
|
+
async function rt(r, e) {
|
|
6126
6131
|
const t = r.rxdb;
|
|
6127
6132
|
if (!t.config.sync?.remote?.adapter)
|
|
6128
6133
|
throw new v("Remote adapter not configured.");
|
|
6129
|
-
t.dispatchEvent(new
|
|
6134
|
+
t.dispatchEvent(new ht("push"));
|
|
6130
6135
|
try {
|
|
6131
6136
|
const s = {
|
|
6132
6137
|
operation: "push",
|
|
@@ -6145,12 +6150,12 @@ async function nt(r, e) {
|
|
|
6145
6150
|
compacted: c,
|
|
6146
6151
|
originalCount: l
|
|
6147
6152
|
};
|
|
6148
|
-
return t.dispatchEvent(new
|
|
6153
|
+
return t.dispatchEvent(new ut("push", d)), d;
|
|
6149
6154
|
} catch (s) {
|
|
6150
|
-
throw t.dispatchEvent(new
|
|
6155
|
+
throw t.dispatchEvent(new pt("push", s)), s;
|
|
6151
6156
|
}
|
|
6152
6157
|
}
|
|
6153
|
-
const
|
|
6158
|
+
const Es = async (r, e) => {
|
|
6154
6159
|
const { branchRepository: t, changeRepository: n, adapter: s } = await r.getLocalRepositories();
|
|
6155
6160
|
if (e === "main")
|
|
6156
6161
|
throw new v("Cannot remove main branch");
|
|
@@ -6187,9 +6192,9 @@ const ws = async (r, e) => {
|
|
|
6187
6192
|
}
|
|
6188
6193
|
await s.removeMany([...i, a]);
|
|
6189
6194
|
};
|
|
6190
|
-
class
|
|
6195
|
+
class bs {
|
|
6191
6196
|
constructor(e) {
|
|
6192
|
-
this.rxdb = e, this.historyManager = new
|
|
6197
|
+
this.rxdb = e, this.historyManager = new ws(this.rxdb);
|
|
6193
6198
|
}
|
|
6194
6199
|
/**
|
|
6195
6200
|
* 撤销/重做辅助类
|
|
@@ -6229,14 +6234,14 @@ class Es {
|
|
|
6229
6234
|
* @param fromChangeId 从哪个 changeId 创建新分支
|
|
6230
6235
|
*/
|
|
6231
6236
|
async createBranch(e, t) {
|
|
6232
|
-
return
|
|
6237
|
+
return ls(this, e, t);
|
|
6233
6238
|
}
|
|
6234
6239
|
/**
|
|
6235
6240
|
* 删除分支
|
|
6236
6241
|
* @param branchId 分支 id
|
|
6237
6242
|
*/
|
|
6238
6243
|
async removeBranch(e) {
|
|
6239
|
-
return
|
|
6244
|
+
return Es(this, e);
|
|
6240
6245
|
}
|
|
6241
6246
|
// ============================================
|
|
6242
6247
|
// Pull/Push 同步方法
|
|
@@ -6260,7 +6265,7 @@ class Es {
|
|
|
6260
6265
|
* ```
|
|
6261
6266
|
*/
|
|
6262
6267
|
async pull(e) {
|
|
6263
|
-
const t = await this.historyManager.syncing(() =>
|
|
6268
|
+
const t = await this.historyManager.syncing(() => nt(this, e));
|
|
6264
6269
|
return this.historyManager.resetPullableCount(), t.pulled > 0 && this.historyManager.clearUndoHistory(), t;
|
|
6265
6270
|
}
|
|
6266
6271
|
/**
|
|
@@ -6287,7 +6292,7 @@ class Es {
|
|
|
6287
6292
|
* ```
|
|
6288
6293
|
*/
|
|
6289
6294
|
async push(e) {
|
|
6290
|
-
const t = await this.historyManager.syncing(() =>
|
|
6295
|
+
const t = await this.historyManager.syncing(() => rt(this, e));
|
|
6291
6296
|
return t.pushed > 0 && this.historyManager.clearUndoHistory(), t;
|
|
6292
6297
|
}
|
|
6293
6298
|
/**
|
|
@@ -6309,7 +6314,7 @@ class Es {
|
|
|
6309
6314
|
*/
|
|
6310
6315
|
async sync(e) {
|
|
6311
6316
|
const t = await this.historyManager.syncing(async () => {
|
|
6312
|
-
const n = await
|
|
6317
|
+
const n = await nt(this, e?.pull), s = await rt(this, e?.push);
|
|
6313
6318
|
return { pullResult: n, pushResult: s };
|
|
6314
6319
|
});
|
|
6315
6320
|
return (t.pullResult.pulled > 0 || t.pushResult.pushed > 0) && this.historyManager.clearUndoHistory(), t;
|
|
@@ -6342,7 +6347,7 @@ class Es {
|
|
|
6342
6347
|
* ```
|
|
6343
6348
|
*/
|
|
6344
6349
|
async pullRepository(e, t, n) {
|
|
6345
|
-
const s = await this.historyManager.syncing(() =>
|
|
6350
|
+
const s = await this.historyManager.syncing(() => St(this, e, t, n));
|
|
6346
6351
|
return s.pulled > 0 && this.historyManager.clearUndoHistory(), s;
|
|
6347
6352
|
}
|
|
6348
6353
|
/**
|
|
@@ -6370,7 +6375,7 @@ class Es {
|
|
|
6370
6375
|
* ```
|
|
6371
6376
|
*/
|
|
6372
6377
|
async pushRepository(e, t, n) {
|
|
6373
|
-
const s = await this.historyManager.syncing(() =>
|
|
6378
|
+
const s = await this.historyManager.syncing(() => Nt(this, e, t, n));
|
|
6374
6379
|
return s.pushed > 0 && this.historyManager.clearUndoHistory(), s;
|
|
6375
6380
|
}
|
|
6376
6381
|
/**
|
|
@@ -6398,7 +6403,7 @@ class Es {
|
|
|
6398
6403
|
* ```
|
|
6399
6404
|
*/
|
|
6400
6405
|
async syncRepository(e, t, n) {
|
|
6401
|
-
const s = await this.historyManager.syncing(() =>
|
|
6406
|
+
const s = await this.historyManager.syncing(() => xt(this, e, t, n));
|
|
6402
6407
|
return (s.pullResult.pulled > 0 || s.pushResult.pushed > 0) && this.historyManager.clearUndoHistory(), s;
|
|
6403
6408
|
}
|
|
6404
6409
|
/**
|
|
@@ -6423,7 +6428,7 @@ class Es {
|
|
|
6423
6428
|
* ```
|
|
6424
6429
|
*/
|
|
6425
6430
|
async checkRepositoryUpdates(e, t) {
|
|
6426
|
-
return
|
|
6431
|
+
return Dt(this.rxdb, e, t);
|
|
6427
6432
|
}
|
|
6428
6433
|
/**
|
|
6429
6434
|
* Get sync status for a single repository (T052, US3)
|
|
@@ -6446,7 +6451,7 @@ class Es {
|
|
|
6446
6451
|
* ```
|
|
6447
6452
|
*/
|
|
6448
6453
|
async getRepositorySyncStatus(e, t) {
|
|
6449
|
-
return
|
|
6454
|
+
return Bt(this.rxdb, e, t);
|
|
6450
6455
|
}
|
|
6451
6456
|
/**
|
|
6452
6457
|
* Get sync status for all repositories (T053, US3)
|
|
@@ -6474,7 +6479,7 @@ class Es {
|
|
|
6474
6479
|
* ```
|
|
6475
6480
|
*/
|
|
6476
6481
|
async getAllRepositorySyncStatus(e) {
|
|
6477
|
-
return
|
|
6482
|
+
return ps(this.rxdb, e);
|
|
6478
6483
|
}
|
|
6479
6484
|
/**
|
|
6480
6485
|
* Bulk sync multiple repositories
|
|
@@ -6517,7 +6522,7 @@ class Es {
|
|
|
6517
6522
|
* ```
|
|
6518
6523
|
*/
|
|
6519
6524
|
async bulkSync(e) {
|
|
6520
|
-
return
|
|
6525
|
+
return cs(this.rxdb, e);
|
|
6521
6526
|
}
|
|
6522
6527
|
/**
|
|
6523
6528
|
* Get dependency graph for all repositories
|
|
@@ -6540,7 +6545,7 @@ class Es {
|
|
|
6540
6545
|
*/
|
|
6541
6546
|
getRepositoryDependencyGraph() {
|
|
6542
6547
|
const e = this.rxdb.config.entities.map((t) => A(t));
|
|
6543
|
-
return
|
|
6548
|
+
return Ye(e);
|
|
6544
6549
|
}
|
|
6545
6550
|
/**
|
|
6546
6551
|
* Get sync order for repositories based on dependencies
|
|
@@ -6564,7 +6569,7 @@ class Es {
|
|
|
6564
6569
|
*/
|
|
6565
6570
|
getRepositorySyncOrder(e) {
|
|
6566
6571
|
const t = this.getRepositoryDependencyGraph();
|
|
6567
|
-
return
|
|
6572
|
+
return je(t, e);
|
|
6568
6573
|
}
|
|
6569
6574
|
// ============================================
|
|
6570
6575
|
// Branch management
|
|
@@ -6581,14 +6586,14 @@ class Es {
|
|
|
6581
6586
|
async switchBranch(e) {
|
|
6582
6587
|
if ((await this.getCurrentBranch())?.id !== e)
|
|
6583
6588
|
try {
|
|
6584
|
-
this.rxdb.dispatchEvent(new
|
|
6585
|
-
const { adapter: n } = await this.getLocalRepositories(), s = await
|
|
6589
|
+
this.rxdb.dispatchEvent(new gn(e));
|
|
6590
|
+
const { adapter: n } = await this.getLocalRepositories(), s = await ys(this, e), a = await n.switchBranch({
|
|
6586
6591
|
branchId: e,
|
|
6587
6592
|
actions: s
|
|
6588
6593
|
});
|
|
6589
|
-
return this.historyManager.clearRedoStack(), this.rxdb.dispatchEvent(new
|
|
6594
|
+
return this.historyManager.clearRedoStack(), this.rxdb.dispatchEvent(new _n(e)), a;
|
|
6590
6595
|
} catch (n) {
|
|
6591
|
-
throw this.rxdb.dispatchEvent(new
|
|
6596
|
+
throw this.rxdb.dispatchEvent(new wn(e)), n;
|
|
6592
6597
|
}
|
|
6593
6598
|
}
|
|
6594
6599
|
/**
|
|
@@ -6644,16 +6649,16 @@ class Es {
|
|
|
6644
6649
|
}))[0];
|
|
6645
6650
|
}
|
|
6646
6651
|
#e() {
|
|
6647
|
-
this.rxdb.addEventListener(
|
|
6648
|
-
this.historyManager.incrementPullableCount(e.entities.length);
|
|
6649
|
-
}), this.rxdb.addEventListener(ot, (e) => {
|
|
6652
|
+
this.rxdb.addEventListener(ot, (e) => {
|
|
6650
6653
|
this.historyManager.incrementPullableCount(e.entities.length);
|
|
6651
6654
|
}), this.rxdb.addEventListener(ct, (e) => {
|
|
6652
6655
|
this.historyManager.incrementPullableCount(e.entities.length);
|
|
6656
|
+
}), this.rxdb.addEventListener(lt, (e) => {
|
|
6657
|
+
this.historyManager.incrementPullableCount(e.entities.length);
|
|
6653
6658
|
});
|
|
6654
6659
|
}
|
|
6655
6660
|
}
|
|
6656
|
-
class
|
|
6661
|
+
class ks {
|
|
6657
6662
|
#e = new k("");
|
|
6658
6663
|
#t = new k("");
|
|
6659
6664
|
/**
|
|
@@ -6775,14 +6780,14 @@ class Ks {
|
|
|
6775
6780
|
* @param options - RxDB 配置选项
|
|
6776
6781
|
*/
|
|
6777
6782
|
constructor(e) {
|
|
6778
|
-
this.#n = e, this.schemaManager = new
|
|
6783
|
+
this.#n = e, this.schemaManager = new Kr(this), this.entityManager = new br(this), this.versionManager = new bs(this), this.context = { ...this.#n.context }, this.#n.dbName = this.#n.dbName + "@" + this.version.replace(/\./g, "_"), Gt(this.#n), globalThis.rxdb = this;
|
|
6779
6784
|
}
|
|
6780
6785
|
/**
|
|
6781
6786
|
* 初始化 RxDB
|
|
6782
6787
|
*/
|
|
6783
6788
|
init() {
|
|
6784
6789
|
if (this.#r) return;
|
|
6785
|
-
this.#r = !0, this.#h.clientId || (this.#h.clientId =
|
|
6790
|
+
this.#r = !0, this.#h.clientId || (this.#h.clientId = mt());
|
|
6786
6791
|
const { local: e, remote: t } = this.#n.sync || {};
|
|
6787
6792
|
e && this.#e.next(e.adapter), t && this.#t.next(t.adapter), this.#_(), this.schemaManager.init(), this.entityManager.init(), this.versionManager.init(), this.#m(), this.#g();
|
|
6788
6793
|
}
|
|
@@ -6832,7 +6837,7 @@ class Ks {
|
|
|
6832
6837
|
const t = this.#p.get(e);
|
|
6833
6838
|
if (!t)
|
|
6834
6839
|
throw new Error(`Adapter "${String(e)}" not found. Please register it first using rxdb.adapter()`);
|
|
6835
|
-
const n = t(this), s =
|
|
6840
|
+
const n = t(this), s = Jt(n) ? n : Promise.resolve(n);
|
|
6836
6841
|
return this.#u.set(e, s), s;
|
|
6837
6842
|
}
|
|
6838
6843
|
/**
|
|
@@ -6855,7 +6860,7 @@ class Ks {
|
|
|
6855
6860
|
const t = (async () => {
|
|
6856
6861
|
this.init();
|
|
6857
6862
|
const n = await this.getAdapter(e);
|
|
6858
|
-
if (await n.connect(),
|
|
6863
|
+
if (await n.connect(), En(e, this.#n) && !await n.isTableExisted(oe)) {
|
|
6859
6864
|
const a = new H();
|
|
6860
6865
|
a.id = "main", a.activated = !0, await n.createTables(this.#n.entities, [a]);
|
|
6861
6866
|
}
|
|
@@ -6898,14 +6903,14 @@ class Ks {
|
|
|
6898
6903
|
* @param event - 要派发的事件对象
|
|
6899
6904
|
*/
|
|
6900
6905
|
dispatchEvent(e) {
|
|
6901
|
-
this.#l &&
|
|
6906
|
+
this.#l && bn(e) === !1 ? this.#c.push(e) : this.#y(e.type).forEach((t) => t.call(this, e));
|
|
6902
6907
|
}
|
|
6903
6908
|
/**
|
|
6904
6909
|
* 初始化网关
|
|
6905
6910
|
* 设置统一的多 Tab 通信网关
|
|
6906
6911
|
*/
|
|
6907
6912
|
#m() {
|
|
6908
|
-
this.#i = new
|
|
6913
|
+
this.#i = new vr({
|
|
6909
6914
|
dbName: this.#n.dbName,
|
|
6910
6915
|
clientId: this.#h.clientId
|
|
6911
6916
|
}), this.#i.init(
|
|
@@ -6957,7 +6962,7 @@ class Ks {
|
|
|
6957
6962
|
}
|
|
6958
6963
|
}
|
|
6959
6964
|
}
|
|
6960
|
-
class
|
|
6965
|
+
class qs {
|
|
6961
6966
|
/**
|
|
6962
6967
|
* 解决单个冲突
|
|
6963
6968
|
*
|
|
@@ -6984,98 +6989,99 @@ class ks {
|
|
|
6984
6989
|
}
|
|
6985
6990
|
}
|
|
6986
6991
|
export {
|
|
6987
|
-
|
|
6988
|
-
|
|
6989
|
-
|
|
6990
|
-
|
|
6991
|
-
|
|
6992
|
+
un as CONFLICT_DETECTED_EVENT,
|
|
6993
|
+
pn as CONFLICT_PENDING_EVENT,
|
|
6994
|
+
Bs as ConflictDetectedEvent,
|
|
6995
|
+
Ls as ConflictPendingEvent,
|
|
6996
|
+
xn as ENTITY_BASE_METADATA_OPTIONS,
|
|
6992
6997
|
se as ENTITY_LOCAL_CREATE_EVENT,
|
|
6993
|
-
|
|
6998
|
+
sn as ENTITY_LOCAL_NEW_EVENT,
|
|
6994
6999
|
ue as ENTITY_LOCAL_REMOVE_EVENT,
|
|
6995
7000
|
he as ENTITY_LOCAL_UPDATE_EVENT,
|
|
6996
|
-
|
|
6997
|
-
|
|
6998
|
-
|
|
6999
|
-
|
|
7001
|
+
ot as ENTITY_REMOTE_CREATE_EVENT,
|
|
7002
|
+
lt as ENTITY_REMOTE_REMOVE_EVENT,
|
|
7003
|
+
ct as ENTITY_REMOTE_UPDATE_EVENT,
|
|
7004
|
+
Le as ENTITY_STATIC_TYPES,
|
|
7000
7005
|
J as Entity,
|
|
7001
7006
|
ae as EntityBase,
|
|
7002
|
-
|
|
7003
|
-
|
|
7004
|
-
|
|
7005
|
-
|
|
7006
|
-
|
|
7007
|
-
|
|
7008
|
-
|
|
7009
|
-
|
|
7007
|
+
As as EntityLocalCreatedEvent,
|
|
7008
|
+
mn as EntityLocalNewEvent,
|
|
7009
|
+
Ss as EntityLocalRemovedEvent,
|
|
7010
|
+
Ms as EntityLocalUpdatedEvent,
|
|
7011
|
+
Os as EntityRemoteCreatedEvent,
|
|
7012
|
+
Ps as EntityRemoteRemovedEvent,
|
|
7013
|
+
Ns as EntityRemoteUpdatedEvent,
|
|
7014
|
+
qs as LWWConflictResolver,
|
|
7010
7015
|
z as OnDeleteAction,
|
|
7011
|
-
|
|
7016
|
+
gt as OnUpdateAction,
|
|
7012
7017
|
R as PropertyType,
|
|
7013
|
-
|
|
7014
|
-
|
|
7015
|
-
|
|
7016
|
-
|
|
7017
|
-
|
|
7018
|
+
Gn as QueryTask,
|
|
7019
|
+
Ts as REMOTE_CHANGES_PENDING_EVENT,
|
|
7020
|
+
fn as REPOSITORY_SYNC_BEGIN_EVENT,
|
|
7021
|
+
dt as REPOSITORY_SYNC_COMPLETE_EVENT,
|
|
7022
|
+
yn as REPOSITORY_SYNC_ERROR_EVENT,
|
|
7018
7023
|
I as RelationKind,
|
|
7019
|
-
|
|
7020
|
-
|
|
7021
|
-
|
|
7022
|
-
|
|
7023
|
-
|
|
7024
|
-
|
|
7025
|
-
|
|
7026
|
-
|
|
7027
|
-
|
|
7024
|
+
vt as Repository,
|
|
7025
|
+
fr as RepositoryBase,
|
|
7026
|
+
$e as RepositorySyncBeginEvent,
|
|
7027
|
+
De as RepositorySyncCompleteEvent,
|
|
7028
|
+
Be as RepositorySyncErrorEvent,
|
|
7029
|
+
ks as RxDB,
|
|
7030
|
+
Rt as RxDBAdapterBase,
|
|
7031
|
+
zs as RxDBAdapterLocalBase,
|
|
7032
|
+
Ws as RxDBAdapterRemoteBase,
|
|
7028
7033
|
H as RxDBBranch,
|
|
7029
7034
|
K as RxDBChange,
|
|
7030
7035
|
v as RxDBError,
|
|
7031
7036
|
oe as RxDBMigration,
|
|
7032
|
-
|
|
7037
|
+
Hs as RxDBPluginBase,
|
|
7033
7038
|
D as RxDBRepositorySync,
|
|
7034
|
-
|
|
7035
|
-
|
|
7036
|
-
|
|
7037
|
-
|
|
7038
|
-
|
|
7039
|
-
|
|
7040
|
-
|
|
7041
|
-
|
|
7042
|
-
|
|
7043
|
-
|
|
7044
|
-
ht as
|
|
7045
|
-
ut as
|
|
7046
|
-
|
|
7039
|
+
an as SWITCH_BRANCH_BEGIN,
|
|
7040
|
+
on as SWITCH_BRANCH_COMMIT,
|
|
7041
|
+
cn as SWITCH_BRANCH_ROLLBACK,
|
|
7042
|
+
ln as SYNC_BEGIN_EVENT,
|
|
7043
|
+
dn as SYNC_COMPLETE_EVENT,
|
|
7044
|
+
hn as SYNC_ERROR_EVENT,
|
|
7045
|
+
gn as SwitchBranchBeginEvent,
|
|
7046
|
+
_n as SwitchBranchCommitEvent,
|
|
7047
|
+
xe as SwitchBranchEventBase,
|
|
7048
|
+
wn as SwitchBranchRollbackEvent,
|
|
7049
|
+
ht as SyncBeginEvent,
|
|
7050
|
+
ut as SyncCompleteEvent,
|
|
7051
|
+
pt as SyncErrorEvent,
|
|
7052
|
+
Jn as SyncStatus,
|
|
7047
7053
|
le as SyncType,
|
|
7048
7054
|
Oe as TRANSACTION_BEGIN,
|
|
7049
7055
|
Ne as TRANSACTION_COMMIT,
|
|
7050
7056
|
Pe as TRANSACTION_ROLLBACK,
|
|
7051
|
-
|
|
7052
|
-
|
|
7053
|
-
|
|
7054
|
-
|
|
7055
|
-
|
|
7056
|
-
|
|
7057
|
-
|
|
7058
|
-
|
|
7059
|
-
|
|
7060
|
-
|
|
7061
|
-
|
|
7057
|
+
Bn as TREE_ADJACENCY_LIST_ENTITY_BASE_OPTIONS,
|
|
7058
|
+
Ke as Todo,
|
|
7059
|
+
xs as TransactionBeginEvent,
|
|
7060
|
+
$s as TransactionCommitEvent,
|
|
7061
|
+
Ds as TransactionRollbackEvent,
|
|
7062
|
+
ke as TreeAdjacencyListEntityBase,
|
|
7063
|
+
Nn as TreeEntity,
|
|
7064
|
+
Ys as __decorateClass,
|
|
7065
|
+
At as compactChanges,
|
|
7066
|
+
In as fillDefaultValue,
|
|
7067
|
+
Tn as fillInitValue,
|
|
7062
7068
|
A as getEntityMetadata,
|
|
7063
7069
|
me as getEntityMutations,
|
|
7064
7070
|
O as getEntityStatus,
|
|
7065
|
-
|
|
7066
|
-
|
|
7067
|
-
|
|
7071
|
+
Us as getEntityType,
|
|
7072
|
+
An as getNeedRemoveEntities,
|
|
7073
|
+
He as getNeedSaveEntities,
|
|
7068
7074
|
Se as getRxDBChangeKey,
|
|
7069
|
-
|
|
7070
|
-
|
|
7071
|
-
|
|
7072
|
-
|
|
7073
|
-
|
|
7074
|
-
|
|
7075
|
-
|
|
7075
|
+
js as isEntityInternalName,
|
|
7076
|
+
wt as isRuleGroup,
|
|
7077
|
+
Fs as isRxDBEntity,
|
|
7078
|
+
Ks as parseRxDBChangeKey,
|
|
7079
|
+
kn as queryNeedRefreshCreate,
|
|
7080
|
+
qn as queryNeedRefreshRemove,
|
|
7081
|
+
Vn as queryNeedRefreshUpdate,
|
|
7076
7082
|
S as setSafeObjectKey,
|
|
7077
7083
|
ce as setSafeObjectKeyLazyInitOnce,
|
|
7078
|
-
|
|
7079
|
-
|
|
7080
|
-
|
|
7084
|
+
Cn as setSafeObjectWritableKey,
|
|
7085
|
+
On as transitionMetadata,
|
|
7086
|
+
mt as uuid
|
|
7081
7087
|
};
|