@aiao/rxdb 0.0.12 → 0.0.14
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/entity/EntityStatus.d.ts +7 -2
- package/dist/entity/EntityStatus.d.ts.map +1 -1
- package/dist/entity/metadata-options.interface.d.ts +52 -10
- package/dist/entity/metadata-options.interface.d.ts.map +1 -1
- package/dist/entity/proxy.d.ts.map +1 -1
- package/dist/index.js +462 -436
- package/dist/query/entity_type_dependencies.d.ts.map +1 -1
- package/dist/query/merge-update.utils.d.ts +1 -1
- package/dist/query/merge-update.utils.d.ts.map +1 -1
- package/dist/repository/query.interface.d.ts +6 -0
- package/dist/repository/query.interface.d.ts.map +1 -1
- package/dist/schema/SchemaManager.d.ts.map +1 -1
- package/dist/version/get-repository-sync-status.d.ts +1 -1
- package/dist/version/get-repository-sync-status.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/__tests__/fixtures/index.d.ts +0 -10
- package/dist/__tests__/fixtures/index.d.ts.map +0 -1
- package/dist/__tests__/fixtures/mock-remote-server.d.ts +0 -146
- package/dist/__tests__/fixtures/mock-remote-server.d.ts.map +0 -1
- package/dist/__tests__/fixtures/test-db-setup.d.ts +0 -52
- package/dist/__tests__/fixtures/test-db-setup.d.ts.map +0 -1
- package/dist/__tests__/fixtures/test-entities.d.ts +0 -41
- package/dist/__tests__/fixtures/test-entities.d.ts.map +0 -1
- package/dist/__tests__/fixtures/test-fixtures.d.ts +0 -129
- package/dist/__tests__/fixtures/test-fixtures.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { isFunction as Bt, isArray as Rn, orderBy as Cn, get as In, isEqual as Dt, once as S, performChunk as Tn,
|
|
2
|
-
import { v7 as
|
|
1
|
+
import { isFunction as Bt, isArray as Rn, orderBy as Cn, get as In, isEqual as Dt, once as S, performChunk as Tn, pick as An, isSymbol as Sn, nextMicroTask as Mn, createBroadcastTopic as On, LeaderElection as xn, needArray as Nn, isNil as mt, deepFreeze as Pn, isPromise as $n } from "@aiao/utils";
|
|
2
|
+
import { v7 as Bn } from "uuid";
|
|
3
3
|
import Lt from "object-hash";
|
|
4
|
-
import { finalize as Ft, forkJoin as
|
|
4
|
+
import { finalize as Ft, forkJoin as Dn, concat as Ln, of as Q, EMPTY as Fn, BehaviorSubject as J, ReplaySubject as Un, takeUntil as jn, distinctUntilChanged as Fe, tap as k, switchMap as x, Observable as Ut, map as $, shareReplay as P, firstValueFrom as L, Subject as Yn, defer as ae, combineLatest as Ne, filter as Ce } from "rxjs";
|
|
5
5
|
class R extends Error {
|
|
6
6
|
constructor(e) {
|
|
7
7
|
super(e), this.name = "RxDBError", Object.setPrototypeOf(this, R.prototype);
|
|
@@ -13,56 +13,56 @@ class et extends R {
|
|
|
13
13
|
super(`NetworkOfflineError: ${e.message}`), this.name = "NetworkOfflineError", this.originalError = e, Object.setPrototypeOf(this, et.prototype);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
const
|
|
17
|
-
class
|
|
16
|
+
const zn = "ENTITY_LOCAL_NEW", ne = "ENTITY_LOCAL_CREATE", oe = "ENTITY_LOCAL_UPDATE", ce = "ENTITY_LOCAL_REMOVE", Ue = "ENTITY_REMOTE_CREATE", je = "ENTITY_REMOTE_UPDATE", Ye = "ENTITY_REMOTE_REMOVE", tt = "TRANSACTION_BEGIN", nt = "TRANSACTION_COMMIT", rt = "TRANSACTION_ROLLBACK", kn = "SWITCH_BRANCH_BEGIN", Wn = "SWITCH_BRANCH_COMMIT", Kn = "SWITCH_BRANCH_ROLLBACK", Hn = "SYNC_BEGIN", qn = "SYNC_COMPLETE", Vn = "SYNC_ERROR", Vi = "REMOTE_CHANGES_PENDING", Gn = "CONFLICT_DETECTED", Qn = "CONFLICT_PENDING", Jn = "REPOSITORY_SYNC_BEGIN", jt = "REPOSITORY_SYNC_COMPLETE", Xn = "REPOSITORY_SYNC_ERROR";
|
|
17
|
+
class Zn {
|
|
18
18
|
constructor(e) {
|
|
19
19
|
this.entities = e;
|
|
20
20
|
}
|
|
21
|
-
type =
|
|
21
|
+
type = zn;
|
|
22
22
|
}
|
|
23
|
-
class
|
|
23
|
+
class Gi {
|
|
24
24
|
constructor(e) {
|
|
25
25
|
this.entities = e;
|
|
26
26
|
}
|
|
27
27
|
type = ne;
|
|
28
28
|
}
|
|
29
|
-
class
|
|
29
|
+
class Qi {
|
|
30
30
|
constructor(e) {
|
|
31
31
|
this.entities = e;
|
|
32
32
|
}
|
|
33
33
|
type = oe;
|
|
34
34
|
}
|
|
35
|
-
class
|
|
35
|
+
class Ji {
|
|
36
36
|
constructor(e) {
|
|
37
37
|
this.entities = e;
|
|
38
38
|
}
|
|
39
39
|
type = ce;
|
|
40
40
|
}
|
|
41
|
-
class
|
|
41
|
+
class Xi {
|
|
42
42
|
constructor(e) {
|
|
43
43
|
this.entities = e;
|
|
44
44
|
}
|
|
45
45
|
type = Ue;
|
|
46
46
|
}
|
|
47
|
-
class
|
|
47
|
+
class Zi {
|
|
48
48
|
constructor(e) {
|
|
49
49
|
this.entities = e;
|
|
50
50
|
}
|
|
51
51
|
type = je;
|
|
52
52
|
}
|
|
53
|
-
class
|
|
53
|
+
class ea {
|
|
54
54
|
constructor(e) {
|
|
55
55
|
this.entities = e;
|
|
56
56
|
}
|
|
57
57
|
type = Ye;
|
|
58
58
|
}
|
|
59
|
-
class
|
|
59
|
+
class ta {
|
|
60
60
|
type = tt;
|
|
61
61
|
}
|
|
62
|
-
class
|
|
62
|
+
class na {
|
|
63
63
|
type = nt;
|
|
64
64
|
}
|
|
65
|
-
class
|
|
65
|
+
class ra {
|
|
66
66
|
type = rt;
|
|
67
67
|
}
|
|
68
68
|
class st {
|
|
@@ -70,50 +70,50 @@ class st {
|
|
|
70
70
|
this.branchName = e;
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
class
|
|
73
|
+
class er extends st {
|
|
74
74
|
type = kn;
|
|
75
75
|
}
|
|
76
|
+
class tr extends st {
|
|
77
|
+
type = Wn;
|
|
78
|
+
}
|
|
76
79
|
class nr extends st {
|
|
77
80
|
type = Kn;
|
|
78
81
|
}
|
|
79
|
-
class rr extends st {
|
|
80
|
-
type = Hn;
|
|
81
|
-
}
|
|
82
82
|
class Yt {
|
|
83
83
|
constructor(e) {
|
|
84
84
|
this.direction = e;
|
|
85
85
|
}
|
|
86
|
-
type =
|
|
86
|
+
type = Hn;
|
|
87
87
|
}
|
|
88
88
|
class zt {
|
|
89
89
|
constructor(e, t) {
|
|
90
90
|
this.direction = e, this.result = t;
|
|
91
91
|
}
|
|
92
|
-
type =
|
|
92
|
+
type = qn;
|
|
93
93
|
}
|
|
94
|
-
class
|
|
94
|
+
class kt {
|
|
95
95
|
constructor(e, t) {
|
|
96
96
|
this.direction = e, this.error = t;
|
|
97
97
|
}
|
|
98
|
-
type =
|
|
98
|
+
type = Vn;
|
|
99
99
|
}
|
|
100
|
-
class
|
|
100
|
+
class sa {
|
|
101
101
|
constructor(e, t, n) {
|
|
102
102
|
this.conflicts = e, this.resolved = t, this.deferred = n;
|
|
103
103
|
}
|
|
104
|
-
type =
|
|
104
|
+
type = Gn;
|
|
105
105
|
}
|
|
106
|
-
class
|
|
106
|
+
class ia {
|
|
107
107
|
constructor(e) {
|
|
108
108
|
this.conflicts = e;
|
|
109
109
|
}
|
|
110
|
-
type =
|
|
110
|
+
type = Qn;
|
|
111
111
|
}
|
|
112
112
|
class it {
|
|
113
113
|
constructor(e, t, n, s) {
|
|
114
114
|
this.direction = e, this.namespace = t, this.entity = n, this.includeRelated = s;
|
|
115
115
|
}
|
|
116
|
-
type =
|
|
116
|
+
type = Jn;
|
|
117
117
|
}
|
|
118
118
|
class at {
|
|
119
119
|
constructor(e, t, n, s) {
|
|
@@ -125,19 +125,19 @@ class ot {
|
|
|
125
125
|
constructor(e, t, n, s) {
|
|
126
126
|
this.direction = e, this.namespace = t, this.entity = n, this.error = s;
|
|
127
127
|
}
|
|
128
|
-
type =
|
|
128
|
+
type = Xn;
|
|
129
129
|
}
|
|
130
|
-
const
|
|
130
|
+
const Wt = /* @__PURE__ */ Symbol("ɵProxy"), ze = /* @__PURE__ */ Symbol("ɵMetadata"), Kt = /* @__PURE__ */ Symbol("ɵStatus"), ke = /* @__PURE__ */ Symbol("ɵEntityManager"), We = /* @__PURE__ */ Symbol("ɵEntityType"), rr = (r, e) => e.sync.local?.adapter === r, sr = (r) => [tt, nt, rt].includes(r.type), I = (r) => r[ze] || r.constructor[ze], aa = (r) => r[We] || r.constructor[We], O = (r) => r && r[Kt], oa = (r) => r && !!O(r), ca = (r, e, t, n) => {
|
|
131
131
|
let s = n > 1 ? void 0 : n ? Object.getOwnPropertyDescriptor(e, t) : e;
|
|
132
132
|
for (let i = r.length - 1, a; i >= 0; i--)
|
|
133
133
|
(a = r[i]) && (s = a(s) || s);
|
|
134
134
|
return s;
|
|
135
|
-
}, Ht = () =>
|
|
135
|
+
}, Ht = () => Bn(), ir = ["id", "createdAt", "updatedAt", "createdBy", "updatedBy"], ar = ["rev"], la = (r) => !!(ir.includes(r) || ar.includes(r) || r.startsWith("_")), M = (r, e, t) => Object.defineProperty(r, e, {
|
|
136
136
|
value: t,
|
|
137
137
|
enumerable: !1,
|
|
138
138
|
configurable: !1,
|
|
139
139
|
writable: !1
|
|
140
|
-
}),
|
|
140
|
+
}), or = (r, e, t) => Object.defineProperty(r, e, {
|
|
141
141
|
value: t,
|
|
142
142
|
enumerable: !1,
|
|
143
143
|
configurable: !1,
|
|
@@ -150,13 +150,13 @@ const kt = /* @__PURE__ */ Symbol("ɵProxy"), ze = /* @__PURE__ */ Symbol("ɵMet
|
|
|
150
150
|
configurable: !1
|
|
151
151
|
};
|
|
152
152
|
return Object.defineProperty(r, e, s);
|
|
153
|
-
},
|
|
153
|
+
}, cr = (r, e) => {
|
|
154
154
|
const t = {};
|
|
155
155
|
let n = !1;
|
|
156
156
|
r.defaultValueProperties.forEach((s) => {
|
|
157
157
|
e[s.name] === void 0 && (n = !0, Bt(s.default) ? t[s.name] = s.default() : t[s.name] = s.default);
|
|
158
158
|
}), n && Object.assign(e, t);
|
|
159
|
-
},
|
|
159
|
+
}, lr = (r, e, t) => {
|
|
160
160
|
const { propertyMap: n, foreignKeyNames: s } = I(e);
|
|
161
161
|
Object.keys(t).forEach((i) => {
|
|
162
162
|
n.has(i) ? r.propertyMap.get(i)?.readonly !== !0 && (e[i] = t[i]) : s.includes(i) && (e[i] = t[i]);
|
|
@@ -169,7 +169,7 @@ const kt = /* @__PURE__ */ Symbol("ɵProxy"), ze = /* @__PURE__ */ Symbol("ɵMet
|
|
|
169
169
|
e.add(i), t(i);
|
|
170
170
|
});
|
|
171
171
|
return n(r), Array.from(e).filter((s) => O(s).modified);
|
|
172
|
-
},
|
|
172
|
+
}, ur = (r) => {
|
|
173
173
|
const e = /* @__PURE__ */ new Set(), t = (n) => {
|
|
174
174
|
O(n).getNeedRemoveEntities().forEach((a) => {
|
|
175
175
|
e.has(a) || (e.add(a), t(a));
|
|
@@ -193,46 +193,46 @@ const kt = /* @__PURE__ */ Symbol("ɵProxy"), ze = /* @__PURE__ */ Symbol("ɵMet
|
|
|
193
193
|
update: s
|
|
194
194
|
};
|
|
195
195
|
};
|
|
196
|
-
var C = /* @__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))(C || {}), T = /* @__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))(T || {}),
|
|
197
|
-
const
|
|
198
|
-
const n =
|
|
196
|
+
var C = /* @__PURE__ */ ((r) => (r.uuid = "uuid", r.string = "string", r.enum = "enum", 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))(C || {}), T = /* @__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))(T || {}), W = /* @__PURE__ */ ((r) => (r.NO_ACTION = "NO ACTION", r.RESTRICT = "RESTRICT", r.CASCADE = "CASCADE", r.SET_NULL = "SET NULL", r.SET_DEFAULT = "SET DEFAULT", r))(W || {}), qt = /* @__PURE__ */ ((r) => (r.NO_ACTION = "NO ACTION", r.RESTRICT = "RESTRICT", r.CASCADE = "CASCADE", r.SET_NULL = "SET NULL", r.SET_DEFAULT = "SET DEFAULT", r))(qt || {}), fe = /* @__PURE__ */ ((r) => (r.Full = "full", r.Filter = "filter", r.QueryCache = "QueryCache", r.None = "none", r))(fe || {});
|
|
197
|
+
const dr = (r, e, t = !1) => {
|
|
198
|
+
const n = hr(e, t);
|
|
199
199
|
return {
|
|
200
200
|
onDelete: r.onDelete ?? n.onDelete,
|
|
201
201
|
onUpdate: r.onUpdate ?? n.onUpdate
|
|
202
202
|
};
|
|
203
|
-
},
|
|
203
|
+
}, hr = (r, e = !1) => {
|
|
204
204
|
const t = qt.RESTRICT;
|
|
205
205
|
switch (r) {
|
|
206
206
|
case T.ONE_TO_ONE:
|
|
207
207
|
return {
|
|
208
|
-
onDelete:
|
|
208
|
+
onDelete: W.CASCADE,
|
|
209
209
|
onUpdate: t
|
|
210
210
|
};
|
|
211
211
|
case T.ONE_TO_MANY:
|
|
212
212
|
return {
|
|
213
|
-
onDelete:
|
|
213
|
+
onDelete: W.CASCADE,
|
|
214
214
|
onUpdate: t
|
|
215
215
|
};
|
|
216
216
|
case T.MANY_TO_ONE:
|
|
217
217
|
return e ? {
|
|
218
|
-
onDelete:
|
|
218
|
+
onDelete: W.SET_NULL,
|
|
219
219
|
onUpdate: t
|
|
220
220
|
} : {
|
|
221
|
-
onDelete:
|
|
221
|
+
onDelete: W.RESTRICT,
|
|
222
222
|
onUpdate: t
|
|
223
223
|
};
|
|
224
224
|
case T.MANY_TO_MANY:
|
|
225
225
|
return {
|
|
226
|
-
onDelete:
|
|
226
|
+
onDelete: W.RESTRICT,
|
|
227
227
|
onUpdate: t
|
|
228
228
|
};
|
|
229
229
|
default:
|
|
230
230
|
return {
|
|
231
|
-
onDelete:
|
|
231
|
+
onDelete: W.RESTRICT,
|
|
232
232
|
onUpdate: t
|
|
233
233
|
};
|
|
234
234
|
}
|
|
235
|
-
},
|
|
235
|
+
}, pr = (r) => r.kind !== T.ONE_TO_MANY, fr = (r, e) => {
|
|
236
236
|
const t = [];
|
|
237
237
|
t.push(r);
|
|
238
238
|
const n = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), o = { ...r };
|
|
@@ -252,7 +252,7 @@ const hr = (r, e, t = !1) => {
|
|
|
252
252
|
u.columnName || (u.columnName = u.name), s.set(u.name, u);
|
|
253
253
|
}), c.relations?.forEach((u) => {
|
|
254
254
|
u.mappedNamespace = u.mappedNamespace || "public";
|
|
255
|
-
const d = "nullable" in u ? u.nullable ?? !1 : !1, h =
|
|
255
|
+
const d = "nullable" in u ? u.nullable ?? !1 : !1, h = dr(
|
|
256
256
|
{
|
|
257
257
|
onDelete: u.onDelete,
|
|
258
258
|
onUpdate: u.onUpdate
|
|
@@ -260,7 +260,7 @@ const hr = (r, e, t = !1) => {
|
|
|
260
260
|
u.kind,
|
|
261
261
|
d
|
|
262
262
|
);
|
|
263
|
-
if (u.onDelete = h.onDelete, u.onUpdate = h.onUpdate,
|
|
263
|
+
if (u.onDelete = h.onDelete, u.onUpdate = h.onUpdate, pr(u) && !u.columnName && (u.columnName = u.name + "Id"), u.mappedEntity === c.name && u.mappedNamespace === c.namespace) {
|
|
264
264
|
const p = { ...u };
|
|
265
265
|
p.mappedEntity = o.name, p.mappedNamespace = o.namespace, i.set(u.name, p);
|
|
266
266
|
} else
|
|
@@ -293,7 +293,7 @@ const hr = (r, e, t = !1) => {
|
|
|
293
293
|
(c) => c && c.endsWith("Id") && o.foreignKeyNames.includes(c)
|
|
294
294
|
), o;
|
|
295
295
|
}, ie = (r) => (e) => {
|
|
296
|
-
const t =
|
|
296
|
+
const t = fr(r, e);
|
|
297
297
|
if (M(e, ze, t), r.abstract) return e;
|
|
298
298
|
const n = e;
|
|
299
299
|
return class extends n {
|
|
@@ -310,12 +310,12 @@ const hr = (r, e, t = !1) => {
|
|
|
310
310
|
*/
|
|
311
311
|
constructor(s) {
|
|
312
312
|
super(s);
|
|
313
|
-
const i = this[
|
|
313
|
+
const i = this[ke];
|
|
314
314
|
if (!i) throw new R("need init rxdb");
|
|
315
|
-
return
|
|
315
|
+
return cr(t, this), s && lr(t, this, s), i[Wt](this);
|
|
316
316
|
}
|
|
317
317
|
};
|
|
318
|
-
},
|
|
318
|
+
}, yr = (r) => {
|
|
319
319
|
const e = r.features?.tree ?? {};
|
|
320
320
|
return ie({
|
|
321
321
|
...r,
|
|
@@ -330,12 +330,12 @@ const hr = (r, e, t = !1) => {
|
|
|
330
330
|
repository: r.repository ?? "TreeRepository"
|
|
331
331
|
});
|
|
332
332
|
}, ct = /* @__PURE__ */ Symbol("ɵEntityStaticTypes");
|
|
333
|
-
var
|
|
334
|
-
for (var s = n > 1 ? void 0 : n ?
|
|
333
|
+
var mr = Object.getOwnPropertyDescriptor, gr = (r, e, t, n) => {
|
|
334
|
+
for (var s = n > 1 ? void 0 : n ? mr(e, t) : e, i = r.length - 1, a; i >= 0; i--)
|
|
335
335
|
(a = r[i]) && (s = a(s) || s);
|
|
336
336
|
return s;
|
|
337
337
|
};
|
|
338
|
-
const
|
|
338
|
+
const _r = {
|
|
339
339
|
name: "EntityBase",
|
|
340
340
|
abstract: !0,
|
|
341
341
|
// 标记为抽象类,不会直接创建此类的实例
|
|
@@ -419,15 +419,15 @@ let Ie = class {
|
|
|
419
419
|
constructor(r) {
|
|
420
420
|
}
|
|
421
421
|
};
|
|
422
|
-
Ie =
|
|
423
|
-
ie(
|
|
422
|
+
Ie = gr([
|
|
423
|
+
ie(_r)
|
|
424
424
|
], Ie);
|
|
425
|
-
var
|
|
426
|
-
for (var s = n > 1 ? void 0 : n ?
|
|
425
|
+
var br = Object.getOwnPropertyDescriptor, wr = (r, e, t, n) => {
|
|
426
|
+
for (var s = n > 1 ? void 0 : n ? br(e, t) : e, i = r.length - 1, a; i >= 0; i--)
|
|
427
427
|
(a = r[i]) && (s = a(s) || s);
|
|
428
428
|
return s;
|
|
429
429
|
};
|
|
430
|
-
const
|
|
430
|
+
const vr = {
|
|
431
431
|
name: "TreeAdjacencyListEntityBase",
|
|
432
432
|
abstract: !0,
|
|
433
433
|
// 标记为抽象类,不会直接创建此类的实例
|
|
@@ -468,7 +468,7 @@ const Er = {
|
|
|
468
468
|
// 映射到父实体的 children 属性
|
|
469
469
|
nullable: !0,
|
|
470
470
|
// 允许根节点没有父节点
|
|
471
|
-
onDelete:
|
|
471
|
+
onDelete: W.CASCADE
|
|
472
472
|
// 删除父节点时级联删除子节点
|
|
473
473
|
}
|
|
474
474
|
],
|
|
@@ -487,10 +487,10 @@ let _t = class extends Ie {
|
|
|
487
487
|
*/
|
|
488
488
|
parentId;
|
|
489
489
|
};
|
|
490
|
-
_t =
|
|
491
|
-
ie(
|
|
490
|
+
_t = wr([
|
|
491
|
+
ie(vr)
|
|
492
492
|
], _t);
|
|
493
|
-
const Vt = (r) => !!(r && r.combinator),
|
|
493
|
+
const Vt = (r) => !!(r && r.combinator), Er = (r) => !!(r && r.field), Rr = (r) => r.operator === "exists" || r.operator === "notExists", Cr = (r, e) => {
|
|
494
494
|
const t = Reflect.get(e, r.field), { operator: n } = r;
|
|
495
495
|
switch (n) {
|
|
496
496
|
case "in":
|
|
@@ -543,7 +543,7 @@ const Vt = (r) => !!(r && r.combinator), Rr = (r) => !!(r && r.field), Cr = (r)
|
|
|
543
543
|
}
|
|
544
544
|
case "exists":
|
|
545
545
|
case "notExists": {
|
|
546
|
-
const s =
|
|
546
|
+
const s = Rr(r) ? r.where : void 0;
|
|
547
547
|
if (Array.isArray(t)) {
|
|
548
548
|
let i = t;
|
|
549
549
|
s && (i = t.filter((o) => Y(o, s)));
|
|
@@ -566,8 +566,8 @@ const Vt = (r) => !!(r && r.combinator), Rr = (r) => !!(r && r.field), Cr = (r)
|
|
|
566
566
|
const { combinator: t, rules: n } = r;
|
|
567
567
|
return t === "and" ? n.every((s) => Ke(s, e)) : n.some((s) => Ke(s, e));
|
|
568
568
|
} else
|
|
569
|
-
return
|
|
570
|
-
}, Y = (r, e) => r == null ? !1 : Ke(e, r),
|
|
569
|
+
return Cr(r, e);
|
|
570
|
+
}, Y = (r, e) => r == null ? !1 : Ke(e, r), Ir = (r, e, t) => {
|
|
571
571
|
const { field: n, sort: s } = t, i = In(r, n);
|
|
572
572
|
if (s === "asc") {
|
|
573
573
|
if (e.some((l) => i < Reflect.get(l, n))) return !0;
|
|
@@ -576,10 +576,10 @@ const Vt = (r) => !!(r && r.combinator), Rr = (r) => !!(r && r.field), Cr = (r)
|
|
|
576
576
|
if (e.some((l) => i > Reflect.get(l, n))) return !0;
|
|
577
577
|
if (e.every((l) => i < Reflect.get(l, n))) return !1;
|
|
578
578
|
}
|
|
579
|
-
},
|
|
579
|
+
}, Tr = (r, e, t) => {
|
|
580
580
|
if (!t || t.length === 0 || e.length === 0 || !r) return !0;
|
|
581
581
|
for (let n = 0; n < t.length; n++) {
|
|
582
|
-
const s = t[n], i =
|
|
582
|
+
const s = t[n], i = Ir(r, e, s);
|
|
583
583
|
if (i === void 0) {
|
|
584
584
|
const { field: a } = s, o = Reflect.get(r, a);
|
|
585
585
|
e = e.filter((l) => Reflect.get(l, a) === o);
|
|
@@ -597,7 +597,7 @@ const Vt = (r) => !!(r && r.combinator), Rr = (r) => !!(r && r.field), Cr = (r)
|
|
|
597
597
|
refresh: n === !1 && bt(r, e),
|
|
598
598
|
recalculate: n
|
|
599
599
|
};
|
|
600
|
-
}, bt = (r, e) => e.some((t) => t.every((n) => r[n]())),
|
|
600
|
+
}, bt = (r, e) => e.some((t) => t.every((n) => r[n]())), Ar = (r, e, t, n, s) => {
|
|
601
601
|
const i = t.slice(0, n);
|
|
602
602
|
let a = e;
|
|
603
603
|
for (const o of i) {
|
|
@@ -611,7 +611,7 @@ const Vt = (r) => !!(r && r.combinator), Rr = (r) => !!(r && r.field), Cr = (r)
|
|
|
611
611
|
a = r.schemaManager.getEntityMetadata(l.mappedEntity, l.mappedNamespace);
|
|
612
612
|
}
|
|
613
613
|
return a !== void 0;
|
|
614
|
-
},
|
|
614
|
+
}, Sr = (r, e, t, n) => {
|
|
615
615
|
const s = t.split(".");
|
|
616
616
|
try {
|
|
617
617
|
const i = r.schemaManager.getFieldRelations(e, t);
|
|
@@ -625,7 +625,8 @@ const Vt = (r) => !!(r && r.combinator), Rr = (r) => !!(r && r.field), Cr = (r)
|
|
|
625
625
|
}
|
|
626
626
|
});
|
|
627
627
|
return;
|
|
628
|
-
} catch {
|
|
628
|
+
} catch (i) {
|
|
629
|
+
i instanceof R || console.warn("[entity_type_dependencies] Failed to resolve field relations:", t, i);
|
|
629
630
|
}
|
|
630
631
|
if (s.length > 1) {
|
|
631
632
|
const [i, ...a] = s, o = e.propertyMap.get(i);
|
|
@@ -635,7 +636,7 @@ const Vt = (r) => !!(r && r.combinator), Rr = (r) => !!(r && r.field), Cr = (r)
|
|
|
635
636
|
for (let i = s.length - 1; i > 0; i--) {
|
|
636
637
|
const a = s.slice(i);
|
|
637
638
|
if (a.length === 0) continue;
|
|
638
|
-
if (
|
|
639
|
+
if (Ar(r, e, s, i, n)) {
|
|
639
640
|
const l = s.slice(0, i);
|
|
640
641
|
let c = e;
|
|
641
642
|
for (const u of l) {
|
|
@@ -682,14 +683,15 @@ const Vt = (r) => !!(r && r.combinator), Rr = (r) => !!(r && r.field), Cr = (r)
|
|
|
682
683
|
}
|
|
683
684
|
if (c && c.includes("."))
|
|
684
685
|
try {
|
|
685
|
-
|
|
686
|
-
} catch {
|
|
686
|
+
Sr(r, s, c, n);
|
|
687
|
+
} catch (d) {
|
|
688
|
+
d instanceof R || console.warn("[entity_type_dependencies] Failed to resolve dotted field:", c, d);
|
|
687
689
|
}
|
|
688
690
|
}
|
|
689
691
|
};
|
|
690
692
|
i(e);
|
|
691
693
|
};
|
|
692
|
-
function
|
|
694
|
+
function Mr(r, e) {
|
|
693
695
|
const { rxdb: t, entityType: n } = r, s = I(n);
|
|
694
696
|
if (!s) return !1;
|
|
695
697
|
const i = t.schemaManager.getEntityMetadata(e.entity, e.namespace);
|
|
@@ -717,11 +719,11 @@ function Gt(r, e) {
|
|
|
717
719
|
};
|
|
718
720
|
const n = [], s = [];
|
|
719
721
|
return e.forEach((i) => {
|
|
720
|
-
const a = i.entity === t.name && i.namespace === t.namespace, o =
|
|
722
|
+
const a = i.entity === t.name && i.namespace === t.namespace, o = Mr(r, i);
|
|
721
723
|
a ? (n.push(i), o && r.type !== "findByCursor" && s.push(i)) : o && s.push(i);
|
|
722
724
|
}), { current_entities: n, relation_entities: s };
|
|
723
725
|
}
|
|
724
|
-
function
|
|
726
|
+
function Or(r, e) {
|
|
725
727
|
const t = new Set(
|
|
726
728
|
e.relations ? e.relations.map((s) => s.name) : Array.from(e.relationMap?.keys() ?? [])
|
|
727
729
|
), n = (s) => {
|
|
@@ -729,7 +731,7 @@ function xr(r, e) {
|
|
|
729
731
|
for (const i of s.rules)
|
|
730
732
|
if (Vt(i)) {
|
|
731
733
|
if (n(i)) return !0;
|
|
732
|
-
} else if (
|
|
734
|
+
} else if (Er(i)) {
|
|
733
735
|
const a = i.field;
|
|
734
736
|
if (a.includes(".")) return !0;
|
|
735
737
|
const o = a.split(":")[0];
|
|
@@ -836,11 +838,11 @@ class ut {
|
|
|
836
838
|
buildOrderByRule() {
|
|
837
839
|
const e = "orderBy" in this.task.options ? this.task.options.orderBy : void 0;
|
|
838
840
|
return e ? S(
|
|
839
|
-
() => this.current_entities.some((t) =>
|
|
841
|
+
() => this.current_entities.some((t) => Tr(t.patch, Array.from(this.task.resultEntitySet), e))
|
|
840
842
|
) : ee;
|
|
841
843
|
}
|
|
842
844
|
}
|
|
843
|
-
const $e = S(() => !0),
|
|
845
|
+
const $e = S(() => !0), xr = (r, e, t, n) => {
|
|
844
846
|
if (!I(r.entityType)) {
|
|
845
847
|
const c = S(() => e.map((_) => _.id)), u = $e, d = $e, h = $e, p = S(() => !1), m = S(() => !0), f = S(() => c().some((_) => r.resultEntitySet?.has(_))), y = S(() => f() === !1);
|
|
846
848
|
return {
|
|
@@ -863,10 +865,10 @@ const $e = S(() => !0), Nr = (r, e, t, n) => {
|
|
|
863
865
|
current_entities: i,
|
|
864
866
|
relation_entities: a
|
|
865
867
|
};
|
|
866
|
-
},
|
|
868
|
+
}, Nr = (r, e, t, n) => {
|
|
867
869
|
const i = new ut(r, e, !1).buildRemoveRules();
|
|
868
870
|
return me(i, t, n);
|
|
869
|
-
}, wt = S(() => !0),
|
|
871
|
+
}, wt = S(() => !0), Pr = (r, e, t, n) => {
|
|
870
872
|
const s = I(r.entityType);
|
|
871
873
|
if (!s) {
|
|
872
874
|
const { options: d, resultEntityIds: h } = r, p = S(() => e.map((E) => E.id)), m = "where" in d ? d.where : void 0, f = m ? S(() => e.some((E) => Y(E.patch, m))) : wt, y = S(() => f() === !1), g = m ? S(() => e.some((E) => Y(E.inversePatch, m))) : wt, _ = S(() => g() === !1), v = S(() => p().some((E) => h.has(E))), b = S(() => v() === !1), w = {
|
|
@@ -883,7 +885,7 @@ const $e = S(() => !0), Nr = (r, e, t, n) => {
|
|
|
883
885
|
}
|
|
884
886
|
const { current_entities: i, relation_entities: a } = Gt(r, e), o = "where" in r.options ? r.options.where : void 0;
|
|
885
887
|
let l = !1;
|
|
886
|
-
o && (l =
|
|
888
|
+
o && (l = Or(o, s));
|
|
887
889
|
const u = new ut(r, i, a.length > 0, l).buildUpdateRules();
|
|
888
890
|
return {
|
|
889
891
|
...me(u, t, n),
|
|
@@ -891,7 +893,7 @@ const $e = S(() => !0), Nr = (r, e, t, n) => {
|
|
|
891
893
|
relation_entities: a
|
|
892
894
|
};
|
|
893
895
|
};
|
|
894
|
-
function
|
|
896
|
+
function $r(r, e) {
|
|
895
897
|
const t = [], n = [], s = [], i = /* @__PURE__ */ new Set();
|
|
896
898
|
for (const o of r) {
|
|
897
899
|
const l = e.get(o.id);
|
|
@@ -905,12 +907,12 @@ function Br(r, e) {
|
|
|
905
907
|
function F(r) {
|
|
906
908
|
return typeof r == "function";
|
|
907
909
|
}
|
|
908
|
-
function
|
|
910
|
+
function Br(r) {
|
|
909
911
|
return F(r?.lift);
|
|
910
912
|
}
|
|
911
913
|
function we(r) {
|
|
912
914
|
return function(e) {
|
|
913
|
-
if (
|
|
915
|
+
if (Br(e))
|
|
914
916
|
return e.lift(function(t) {
|
|
915
917
|
try {
|
|
916
918
|
return r(t, this);
|
|
@@ -937,7 +939,7 @@ function de(r, e) {
|
|
|
937
939
|
}
|
|
938
940
|
r.prototype = e === null ? Object.create(e) : (t.prototype = e.prototype, new t());
|
|
939
941
|
}
|
|
940
|
-
function
|
|
942
|
+
function Dr(r, e, t, n) {
|
|
941
943
|
function s(i) {
|
|
942
944
|
return i instanceof t ? i : new t(function(a) {
|
|
943
945
|
a(i);
|
|
@@ -1059,7 +1061,7 @@ function Ae(r, e, t) {
|
|
|
1059
1061
|
function le(r) {
|
|
1060
1062
|
return this instanceof le ? (this.v = r, this) : new le(r);
|
|
1061
1063
|
}
|
|
1062
|
-
function
|
|
1064
|
+
function Lr(r, e, t) {
|
|
1063
1065
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
1064
1066
|
var n = t.apply(r, e || []), s, i = [];
|
|
1065
1067
|
return s = Object.create((typeof AsyncIterator == "function" ? AsyncIterator : Object).prototype), o("next"), o("throw"), o("return", a), s[Symbol.asyncIterator] = function() {
|
|
@@ -1097,7 +1099,7 @@ function Fr(r, e, t) {
|
|
|
1097
1099
|
p(m), i.shift(), i.length && l(i[0][0], i[0][1]);
|
|
1098
1100
|
}
|
|
1099
1101
|
}
|
|
1100
|
-
function
|
|
1102
|
+
function Fr(r) {
|
|
1101
1103
|
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
1102
1104
|
var e = r[Symbol.asyncIterator], t;
|
|
1103
1105
|
return e ? e.call(r) : (r = typeof ue == "function" ? ue(r) : r[Symbol.iterator](), t = {}, n("next"), n("throw"), n("return"), t[Symbol.asyncIterator] = function() {
|
|
@@ -1116,10 +1118,10 @@ function Ur(r) {
|
|
|
1116
1118
|
}, a);
|
|
1117
1119
|
}
|
|
1118
1120
|
}
|
|
1119
|
-
var
|
|
1121
|
+
var Ur = (function(r) {
|
|
1120
1122
|
return r && typeof r.length == "number" && typeof r != "function";
|
|
1121
1123
|
});
|
|
1122
|
-
function
|
|
1124
|
+
function jr(r) {
|
|
1123
1125
|
return F(r?.then);
|
|
1124
1126
|
}
|
|
1125
1127
|
function Jt(r) {
|
|
@@ -1238,9 +1240,9 @@ function Zt(r) {
|
|
|
1238
1240
|
function vt(r) {
|
|
1239
1241
|
F(r) ? r() : r.unsubscribe();
|
|
1240
1242
|
}
|
|
1241
|
-
var
|
|
1243
|
+
var Yr = {
|
|
1242
1244
|
Promise: void 0
|
|
1243
|
-
},
|
|
1245
|
+
}, zr = {
|
|
1244
1246
|
setTimeout: function(r, e) {
|
|
1245
1247
|
for (var t = [], n = 2; n < arguments.length; n++)
|
|
1246
1248
|
t[n - 2] = arguments[n];
|
|
@@ -1252,7 +1254,7 @@ var zr = {
|
|
|
1252
1254
|
delegate: void 0
|
|
1253
1255
|
};
|
|
1254
1256
|
function en(r) {
|
|
1255
|
-
|
|
1257
|
+
zr.setTimeout(function() {
|
|
1256
1258
|
throw r;
|
|
1257
1259
|
});
|
|
1258
1260
|
}
|
|
@@ -1265,7 +1267,7 @@ var dt = (function(r) {
|
|
|
1265
1267
|
de(e, r);
|
|
1266
1268
|
function e(t) {
|
|
1267
1269
|
var n = r.call(this) || this;
|
|
1268
|
-
return n.isStopped = !1, t ? (n.destination = t, Zt(t) && t.add(n)) : n.destination =
|
|
1270
|
+
return n.isStopped = !1, t ? (n.destination = t, Zt(t) && t.add(n)) : n.destination = Kr, n;
|
|
1269
1271
|
}
|
|
1270
1272
|
return e.create = function(t, n, s) {
|
|
1271
1273
|
return new ge(t, n, s);
|
|
@@ -1338,22 +1340,22 @@ var dt = (function(r) {
|
|
|
1338
1340
|
function ve(r) {
|
|
1339
1341
|
en(r);
|
|
1340
1342
|
}
|
|
1341
|
-
function
|
|
1343
|
+
function Wr(r) {
|
|
1342
1344
|
throw r;
|
|
1343
1345
|
}
|
|
1344
|
-
var
|
|
1346
|
+
var Kr = {
|
|
1345
1347
|
closed: !0,
|
|
1346
1348
|
next: Et,
|
|
1347
|
-
error:
|
|
1349
|
+
error: Wr,
|
|
1348
1350
|
complete: Et
|
|
1349
1351
|
}, ht = (function() {
|
|
1350
1352
|
return typeof Symbol == "function" && Symbol.observable || "@@observable";
|
|
1351
1353
|
})();
|
|
1352
|
-
function
|
|
1354
|
+
function Hr(r) {
|
|
1353
1355
|
return r;
|
|
1354
1356
|
}
|
|
1355
|
-
function
|
|
1356
|
-
return r.length === 0 ?
|
|
1357
|
+
function qr(r) {
|
|
1358
|
+
return r.length === 0 ? Hr : r.length === 1 ? r[0] : function(t) {
|
|
1357
1359
|
return r.reduce(function(n, s) {
|
|
1358
1360
|
return s(n);
|
|
1359
1361
|
}, t);
|
|
@@ -1367,7 +1369,7 @@ var re = (function() {
|
|
|
1367
1369
|
var t = new r();
|
|
1368
1370
|
return t.source = this, t.operator = e, t;
|
|
1369
1371
|
}, r.prototype.subscribe = function(e, t, n) {
|
|
1370
|
-
var s = this, i =
|
|
1372
|
+
var s = this, i = Gr(e) ? e : new ge(e, t, n);
|
|
1371
1373
|
return Ee(function() {
|
|
1372
1374
|
var a = s, o = a.operator, l = a.source;
|
|
1373
1375
|
i.add(o ? o.call(i, l) : l ? s._subscribe(i) : s._trySubscribe(i));
|
|
@@ -1402,7 +1404,7 @@ var re = (function() {
|
|
|
1402
1404
|
}, r.prototype.pipe = function() {
|
|
1403
1405
|
for (var e = [], t = 0; t < arguments.length; t++)
|
|
1404
1406
|
e[t] = arguments[t];
|
|
1405
|
-
return
|
|
1407
|
+
return qr(e)(this);
|
|
1406
1408
|
}, r.prototype.toPromise = function(e) {
|
|
1407
1409
|
var t = this;
|
|
1408
1410
|
return e = Rt(e), new e(function(n, s) {
|
|
@@ -1421,32 +1423,32 @@ var re = (function() {
|
|
|
1421
1423
|
})();
|
|
1422
1424
|
function Rt(r) {
|
|
1423
1425
|
var e;
|
|
1424
|
-
return (e = r ??
|
|
1426
|
+
return (e = r ?? Yr.Promise) !== null && e !== void 0 ? e : Promise;
|
|
1425
1427
|
}
|
|
1426
|
-
function
|
|
1428
|
+
function Vr(r) {
|
|
1427
1429
|
return r && F(r.next) && F(r.error) && F(r.complete);
|
|
1428
1430
|
}
|
|
1429
|
-
function
|
|
1430
|
-
return r && r instanceof dt ||
|
|
1431
|
+
function Gr(r) {
|
|
1432
|
+
return r && r instanceof dt || Vr(r) && Zt(r);
|
|
1431
1433
|
}
|
|
1432
|
-
function
|
|
1434
|
+
function Qr(r) {
|
|
1433
1435
|
return F(r[ht]);
|
|
1434
1436
|
}
|
|
1435
|
-
function
|
|
1437
|
+
function Jr(r) {
|
|
1436
1438
|
return Symbol.asyncIterator && F(r?.[Symbol.asyncIterator]);
|
|
1437
1439
|
}
|
|
1438
|
-
function
|
|
1440
|
+
function Xr(r) {
|
|
1439
1441
|
return new TypeError("You provided " + (r !== null && typeof r == "object" ? "an invalid object" : "'" + r + "'") + " where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.");
|
|
1440
1442
|
}
|
|
1441
|
-
function
|
|
1443
|
+
function Zr() {
|
|
1442
1444
|
return typeof Symbol != "function" || !Symbol.iterator ? "@@iterator" : Symbol.iterator;
|
|
1443
1445
|
}
|
|
1444
|
-
var
|
|
1445
|
-
function
|
|
1446
|
-
return F(r?.[
|
|
1446
|
+
var es = Zr();
|
|
1447
|
+
function ts(r) {
|
|
1448
|
+
return F(r?.[es]);
|
|
1447
1449
|
}
|
|
1448
|
-
function
|
|
1449
|
-
return
|
|
1450
|
+
function ns(r) {
|
|
1451
|
+
return Lr(this, arguments, function() {
|
|
1450
1452
|
var t, n, s, i;
|
|
1451
1453
|
return Qt(this, function(a) {
|
|
1452
1454
|
switch (a.label) {
|
|
@@ -1476,29 +1478,29 @@ function rs(r) {
|
|
|
1476
1478
|
});
|
|
1477
1479
|
});
|
|
1478
1480
|
}
|
|
1479
|
-
function
|
|
1481
|
+
function rs(r) {
|
|
1480
1482
|
return F(r?.getReader);
|
|
1481
1483
|
}
|
|
1482
1484
|
function Me(r) {
|
|
1483
1485
|
if (r instanceof re)
|
|
1484
1486
|
return r;
|
|
1485
1487
|
if (r != null) {
|
|
1486
|
-
if (
|
|
1488
|
+
if (Qr(r))
|
|
1489
|
+
return ss(r);
|
|
1490
|
+
if (Ur(r))
|
|
1487
1491
|
return is(r);
|
|
1488
1492
|
if (jr(r))
|
|
1489
1493
|
return as(r);
|
|
1490
|
-
if (
|
|
1491
|
-
return os(r);
|
|
1492
|
-
if (Xr(r))
|
|
1494
|
+
if (Jr(r))
|
|
1493
1495
|
return tn(r);
|
|
1494
|
-
if (
|
|
1496
|
+
if (ts(r))
|
|
1497
|
+
return os(r);
|
|
1498
|
+
if (rs(r))
|
|
1495
1499
|
return cs(r);
|
|
1496
|
-
if (ss(r))
|
|
1497
|
-
return ls(r);
|
|
1498
1500
|
}
|
|
1499
|
-
throw
|
|
1501
|
+
throw Xr(r);
|
|
1500
1502
|
}
|
|
1501
|
-
function
|
|
1503
|
+
function ss(r) {
|
|
1502
1504
|
return new re(function(e) {
|
|
1503
1505
|
var t = r[ht]();
|
|
1504
1506
|
if (F(t.subscribe))
|
|
@@ -1506,14 +1508,14 @@ function is(r) {
|
|
|
1506
1508
|
throw new TypeError("Provided object does not correctly implement Symbol.observable");
|
|
1507
1509
|
});
|
|
1508
1510
|
}
|
|
1509
|
-
function
|
|
1511
|
+
function is(r) {
|
|
1510
1512
|
return new re(function(e) {
|
|
1511
1513
|
for (var t = 0; t < r.length && !e.closed; t++)
|
|
1512
1514
|
e.next(r[t]);
|
|
1513
1515
|
e.complete();
|
|
1514
1516
|
});
|
|
1515
1517
|
}
|
|
1516
|
-
function
|
|
1518
|
+
function as(r) {
|
|
1517
1519
|
return new re(function(e) {
|
|
1518
1520
|
r.then(function(t) {
|
|
1519
1521
|
e.closed || (e.next(t), e.complete());
|
|
@@ -1522,7 +1524,7 @@ function os(r) {
|
|
|
1522
1524
|
}).then(null, en);
|
|
1523
1525
|
});
|
|
1524
1526
|
}
|
|
1525
|
-
function
|
|
1527
|
+
function os(r) {
|
|
1526
1528
|
return new re(function(e) {
|
|
1527
1529
|
var t, n;
|
|
1528
1530
|
try {
|
|
@@ -1545,22 +1547,22 @@ function cs(r) {
|
|
|
1545
1547
|
}
|
|
1546
1548
|
function tn(r) {
|
|
1547
1549
|
return new re(function(e) {
|
|
1548
|
-
|
|
1550
|
+
ls(r, e).catch(function(t) {
|
|
1549
1551
|
return e.error(t);
|
|
1550
1552
|
});
|
|
1551
1553
|
});
|
|
1552
1554
|
}
|
|
1553
|
-
function
|
|
1554
|
-
return tn(
|
|
1555
|
+
function cs(r) {
|
|
1556
|
+
return tn(ns(r));
|
|
1555
1557
|
}
|
|
1556
|
-
function
|
|
1558
|
+
function ls(r, e) {
|
|
1557
1559
|
var t, n, s, i;
|
|
1558
|
-
return
|
|
1560
|
+
return Dr(this, void 0, void 0, function() {
|
|
1559
1561
|
var a, o;
|
|
1560
1562
|
return Qt(this, function(l) {
|
|
1561
1563
|
switch (l.label) {
|
|
1562
1564
|
case 0:
|
|
1563
|
-
l.trys.push([0, 5, 6, 11]), t =
|
|
1565
|
+
l.trys.push([0, 5, 6, 11]), t = Fr(r), l.label = 1;
|
|
1564
1566
|
case 1:
|
|
1565
1567
|
return [4, t.next()];
|
|
1566
1568
|
case 2:
|
|
@@ -1592,9 +1594,9 @@ function us(r, e) {
|
|
|
1592
1594
|
});
|
|
1593
1595
|
}
|
|
1594
1596
|
function _e(r, e, t, n, s) {
|
|
1595
|
-
return new
|
|
1597
|
+
return new us(r, e, t, n, s);
|
|
1596
1598
|
}
|
|
1597
|
-
var
|
|
1599
|
+
var us = (function(r) {
|
|
1598
1600
|
de(e, r);
|
|
1599
1601
|
function e(t, n, s, i, a, o) {
|
|
1600
1602
|
var l = r.call(this, t) || this;
|
|
@@ -1651,7 +1653,7 @@ function te(r, e) {
|
|
|
1651
1653
|
}));
|
|
1652
1654
|
});
|
|
1653
1655
|
}
|
|
1654
|
-
var
|
|
1656
|
+
var ds = Jt(function(r) {
|
|
1655
1657
|
return function() {
|
|
1656
1658
|
r(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
|
|
1657
1659
|
};
|
|
@@ -1666,7 +1668,7 @@ var hs = Jt(function(r) {
|
|
|
1666
1668
|
return n.operator = t, n;
|
|
1667
1669
|
}, e.prototype._throwIfClosed = function() {
|
|
1668
1670
|
if (this.closed)
|
|
1669
|
-
throw new
|
|
1671
|
+
throw new ds();
|
|
1670
1672
|
}, e.prototype.next = function(t) {
|
|
1671
1673
|
var n = this;
|
|
1672
1674
|
Ee(function() {
|
|
@@ -1762,7 +1764,7 @@ function It(r, e) {
|
|
|
1762
1764
|
}));
|
|
1763
1765
|
});
|
|
1764
1766
|
}
|
|
1765
|
-
var
|
|
1767
|
+
var hs = (function(r) {
|
|
1766
1768
|
de(e, r);
|
|
1767
1769
|
function e(t, n, s) {
|
|
1768
1770
|
t === void 0 && (t = 1 / 0), n === void 0 && (n = 1 / 0), s === void 0 && (s = nn);
|
|
@@ -1786,7 +1788,7 @@ var ps = (function(r) {
|
|
|
1786
1788
|
}
|
|
1787
1789
|
}, e;
|
|
1788
1790
|
})(pt);
|
|
1789
|
-
function
|
|
1791
|
+
function ps(r) {
|
|
1790
1792
|
r === void 0 && (r = {});
|
|
1791
1793
|
var e = r.connector, t = e === void 0 ? function() {
|
|
1792
1794
|
return new pt();
|
|
@@ -1835,11 +1837,11 @@ function De(r, e) {
|
|
|
1835
1837
|
return Me(e.apply(void 0, Ae([], Te(t)))).subscribe(s);
|
|
1836
1838
|
}
|
|
1837
1839
|
}
|
|
1838
|
-
function
|
|
1840
|
+
function fs(r, e, t) {
|
|
1839
1841
|
var n, s = !1;
|
|
1840
|
-
return n = r,
|
|
1842
|
+
return n = r, ps({
|
|
1841
1843
|
connector: function() {
|
|
1842
|
-
return new
|
|
1844
|
+
return new hs(n, e, t);
|
|
1843
1845
|
},
|
|
1844
1846
|
resetOnError: !0,
|
|
1845
1847
|
resetOnComplete: !1,
|
|
@@ -1864,7 +1866,7 @@ function V(r, e) {
|
|
|
1864
1866
|
}));
|
|
1865
1867
|
});
|
|
1866
1868
|
}
|
|
1867
|
-
class
|
|
1869
|
+
class ua {
|
|
1868
1870
|
constructor(e, t, n) {
|
|
1869
1871
|
this.remoteAdapter = t, this.localAdapter = n, this.entityName = e;
|
|
1870
1872
|
}
|
|
@@ -1909,9 +1911,9 @@ class da {
|
|
|
1909
1911
|
if (n)
|
|
1910
1912
|
return n;
|
|
1911
1913
|
let s;
|
|
1912
|
-
e.localCacheFirst ? s = this.#n(e) : s = this.#
|
|
1914
|
+
e.localCacheFirst ? s = this.#n(e) : s = this.#s(e), e.offlineFallback && (s = this.#i(s));
|
|
1913
1915
|
const i = s.pipe(
|
|
1914
|
-
|
|
1916
|
+
fs(1),
|
|
1915
1917
|
Ft(() => {
|
|
1916
1918
|
this.#e.delete(t);
|
|
1917
1919
|
})
|
|
@@ -1935,7 +1937,7 @@ class da {
|
|
|
1935
1937
|
combinator: "and",
|
|
1936
1938
|
rules: [{ field: "id", operator: "=", value: e }]
|
|
1937
1939
|
};
|
|
1938
|
-
return
|
|
1940
|
+
return Dn({
|
|
1939
1941
|
remoteMetadata: this.remoteAdapter.fetchMetadata(this.entityName, t),
|
|
1940
1942
|
localMetadata: this.localAdapter.getMetadataByIds(this.entityName, [e])
|
|
1941
1943
|
}).pipe(
|
|
@@ -2043,12 +2045,12 @@ class da {
|
|
|
2043
2045
|
#n(e) {
|
|
2044
2046
|
const t = this.#t().pipe(Re(() => Q([])));
|
|
2045
2047
|
let n = !1, s = "";
|
|
2046
|
-
const i = this.#
|
|
2048
|
+
const i = this.#s(e).pipe(
|
|
2047
2049
|
It((a) => n ? this.#r(a) !== s : !0),
|
|
2048
|
-
Re(() =>
|
|
2050
|
+
Re(() => Fn)
|
|
2049
2051
|
// 远程失败时静默处理,保留缓存数据
|
|
2050
2052
|
);
|
|
2051
|
-
return
|
|
2053
|
+
return Ln(
|
|
2052
2054
|
t.pipe(
|
|
2053
2055
|
It((a) => a.length > 0),
|
|
2054
2056
|
// 只有有缓存时才发射
|
|
@@ -2080,7 +2082,7 @@ class da {
|
|
|
2080
2082
|
* - 如果有本地缓存,返回缓存数据
|
|
2081
2083
|
* - 如果没有本地缓存,抛出 NetworkOfflineError
|
|
2082
2084
|
*/
|
|
2083
|
-
#
|
|
2085
|
+
#i(e) {
|
|
2084
2086
|
return e.pipe(
|
|
2085
2087
|
Re((t) => this.#t().pipe(
|
|
2086
2088
|
V((n) => {
|
|
@@ -2094,7 +2096,7 @@ class da {
|
|
|
2094
2096
|
/**
|
|
2095
2097
|
* 执行实际的查询逻辑
|
|
2096
2098
|
*/
|
|
2097
|
-
#
|
|
2099
|
+
#s(e) {
|
|
2098
2100
|
const t = e.where, n = Date.now();
|
|
2099
2101
|
return this.remoteAdapter.fetchMetadata(this.entityName, t).pipe(
|
|
2100
2102
|
V((s) => {
|
|
@@ -2111,7 +2113,7 @@ class da {
|
|
|
2111
2113
|
const i = s.map((a) => a.id);
|
|
2112
2114
|
return this.localAdapter.getMetadataByIds(this.entityName, i).pipe(
|
|
2113
2115
|
V((a) => {
|
|
2114
|
-
const o =
|
|
2116
|
+
const o = $r(s, a), l = [...o.missingIds, ...o.staleIds];
|
|
2115
2117
|
return l.length === 0 ? this.#a(o.freshIds).pipe(
|
|
2116
2118
|
te((c) => (this.#o(e.onSyncStats, {
|
|
2117
2119
|
remoteCount: s.length,
|
|
@@ -2182,7 +2184,7 @@ class da {
|
|
|
2182
2184
|
return Lt(e);
|
|
2183
2185
|
}
|
|
2184
2186
|
}
|
|
2185
|
-
class
|
|
2187
|
+
class ys {
|
|
2186
2188
|
/**
|
|
2187
2189
|
* 刷新
|
|
2188
2190
|
* 重新执行 SQL 查询
|
|
@@ -2191,7 +2193,7 @@ class ms {
|
|
|
2191
2193
|
/**
|
|
2192
2194
|
* 销毁
|
|
2193
2195
|
*/
|
|
2194
|
-
#n = new
|
|
2196
|
+
#n = new Un(1);
|
|
2195
2197
|
/**
|
|
2196
2198
|
* 是否首次运行
|
|
2197
2199
|
* 标识查询是否为第一次执行
|
|
@@ -2297,9 +2299,9 @@ class ms {
|
|
|
2297
2299
|
const n = this.depEntityTypeMap.get(t) || 0;
|
|
2298
2300
|
this.depEntityTypeMap.set(t, n + 1);
|
|
2299
2301
|
})), this.refresh$.pipe(
|
|
2300
|
-
|
|
2302
|
+
jn(this.destroy$),
|
|
2301
2303
|
Fe(),
|
|
2302
|
-
|
|
2304
|
+
k(() => this.refreshCount++),
|
|
2303
2305
|
x(() => this.runner())
|
|
2304
2306
|
).subscribe({
|
|
2305
2307
|
next: (t) => {
|
|
@@ -2345,7 +2347,7 @@ class ms {
|
|
|
2345
2347
|
this.#e.next(this.refreshCount + 1);
|
|
2346
2348
|
};
|
|
2347
2349
|
}
|
|
2348
|
-
var
|
|
2350
|
+
var ms = /* @__PURE__ */ ((r) => (r.Synced = "Synced", r.Syncing = "Syncing", r.Never = "Never", r))(ms || {});
|
|
2349
2351
|
const Ve = (r) => Array.isArray(r) ? r : [r], Le = (r) => r ? [O(r).fingerprint] : [r], ye = (r) => r.map((e) => O(e).fingerprint), D = (r) => r?.parentId || null;
|
|
2350
2352
|
function* rn(r, e, t = {}) {
|
|
2351
2353
|
const { maxLevel: n, maxDepth: s = 1e3 } = t, i = /* @__PURE__ */ new Set();
|
|
@@ -2357,7 +2359,7 @@ function* rn(r, e, t = {}) {
|
|
|
2357
2359
|
yield { entity: l, level: o }, a = D(l), o++;
|
|
2358
2360
|
}
|
|
2359
2361
|
}
|
|
2360
|
-
function
|
|
2362
|
+
function gs(r, e, t, n) {
|
|
2361
2363
|
if (e == null)
|
|
2362
2364
|
return r.parentId === null;
|
|
2363
2365
|
const s = /* @__PURE__ */ new Set();
|
|
@@ -2374,7 +2376,7 @@ function _s(r, e, t, n) {
|
|
|
2374
2376
|
}
|
|
2375
2377
|
return !1;
|
|
2376
2378
|
}
|
|
2377
|
-
function
|
|
2379
|
+
function _s(r, e, t) {
|
|
2378
2380
|
const n = t.get(e);
|
|
2379
2381
|
if (!n) return !1;
|
|
2380
2382
|
for (const { entity: s } of rn(n, t))
|
|
@@ -2392,7 +2394,7 @@ function Ge(r, e) {
|
|
|
2392
2394
|
function Tt(r, e) {
|
|
2393
2395
|
return r.length !== e.length ? !0 : r.some((t, n) => t !== e[n]);
|
|
2394
2396
|
}
|
|
2395
|
-
const
|
|
2397
|
+
const bs = (r, e) => {
|
|
2396
2398
|
const t = r.options.where, n = e.filter((i) => !t || Y(i.patch, t));
|
|
2397
2399
|
if (n.length === 0) return;
|
|
2398
2400
|
const s = n.map((i) => r.serialize(i));
|
|
@@ -2458,14 +2460,14 @@ const ws = (r, e) => {
|
|
|
2458
2460
|
}
|
|
2459
2461
|
case "findDescendants": {
|
|
2460
2462
|
const i = r.options, a = Array.from(r.resultEntitySet.values()), o = Ge(a, (c) => c.id), l = s.filter(
|
|
2461
|
-
(c) =>
|
|
2463
|
+
(c) => gs(c, i.entityId, o, i.level)
|
|
2462
2464
|
);
|
|
2463
2465
|
if (l.length === 0) return;
|
|
2464
2466
|
l.forEach((c) => r.resultEntitySet.add(c)), r.next(Array.from(r.resultEntitySet.values()), !0);
|
|
2465
2467
|
break;
|
|
2466
2468
|
}
|
|
2467
2469
|
case "findAncestors": {
|
|
2468
|
-
const i = r.options, o = [...Array.from(r.resultEntitySet.values()), ...s], l = Ge(o, (u) => u.id), c = s.filter((u) => u.id === i.entityId ? !0 : i.entityId ?
|
|
2470
|
+
const i = r.options, o = [...Array.from(r.resultEntitySet.values()), ...s], l = Ge(o, (u) => u.id), c = s.filter((u) => u.id === i.entityId ? !0 : i.entityId ? _s(u, i.entityId, l) : !1);
|
|
2469
2471
|
if (c.length === 0) return;
|
|
2470
2472
|
c.forEach((u) => r.resultEntitySet.add(u)), r.next(Array.from(r.resultEntitySet.values()), !0);
|
|
2471
2473
|
break;
|
|
@@ -2493,9 +2495,9 @@ const ws = (r, e) => {
|
|
|
2493
2495
|
t.push(["match_where"], ["match_relation_where"]);
|
|
2494
2496
|
break;
|
|
2495
2497
|
}
|
|
2496
|
-
const i =
|
|
2497
|
-
i.refresh ? r.refresh() : i.recalculate &&
|
|
2498
|
-
},
|
|
2498
|
+
const i = xr(r, e, t, n);
|
|
2499
|
+
i.refresh ? r.refresh() : i.recalculate && bs(r, i.current_entities);
|
|
2500
|
+
}, ws = (r, e) => {
|
|
2499
2501
|
const t = new Set(e.map((n) => n.id));
|
|
2500
2502
|
switch (r.type) {
|
|
2501
2503
|
case "findAll": {
|
|
@@ -2574,13 +2576,13 @@ const ws = (r, e) => {
|
|
|
2574
2576
|
t.push(["match_where"]);
|
|
2575
2577
|
break;
|
|
2576
2578
|
}
|
|
2577
|
-
const s =
|
|
2578
|
-
s.refresh ? r.refresh() : s.recalculate &&
|
|
2579
|
+
const s = Nr(r, e, t, n);
|
|
2580
|
+
s.refresh ? r.refresh() : s.recalculate && ws(r, e);
|
|
2579
2581
|
}, N = (r) => {
|
|
2580
2582
|
if (r)
|
|
2581
2583
|
return r.id;
|
|
2582
2584
|
};
|
|
2583
|
-
class
|
|
2585
|
+
class vs {
|
|
2584
2586
|
constructor(e, t) {
|
|
2585
2587
|
this.serialize = t, e.forEach((n) => this.dataById.set(n.id, n));
|
|
2586
2588
|
}
|
|
@@ -2615,7 +2617,7 @@ class Es {
|
|
|
2615
2617
|
return this.dataById.get(e);
|
|
2616
2618
|
}
|
|
2617
2619
|
}
|
|
2618
|
-
const
|
|
2620
|
+
const Es = (r, e, t) => {
|
|
2619
2621
|
const n = new Set(r.map((d) => d.id)), s = r.filter((d) => !e || t(d.patch, e)), i = r.filter((d) => !e || t(d.inversePatch, e)), a = new Set(s.map((d) => d.id)), o = new Set(i.map((d) => d.id)), l = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set();
|
|
2620
2622
|
return s.forEach((d) => {
|
|
2621
2623
|
o.has(d.id) ? u.add(d.id) : l.add(d.id);
|
|
@@ -2629,7 +2631,7 @@ const Rs = (r, e, t) => {
|
|
|
2629
2631
|
newlyUnmatchedIds: c,
|
|
2630
2632
|
stillMatchedIds: u
|
|
2631
2633
|
};
|
|
2632
|
-
},
|
|
2634
|
+
}, Rs = (r, e, t) => {
|
|
2633
2635
|
const n = r.options, s = n.where, i = Array.from(r.resultEntitySet.values()), a = [];
|
|
2634
2636
|
for (const u of i) {
|
|
2635
2637
|
const d = N(u);
|
|
@@ -2643,19 +2645,19 @@ const Rs = (r, e, t) => {
|
|
|
2643
2645
|
const o = new Set(a.map((u) => N(u)).filter(Boolean)), l = Array.from(e.newlyMatchedIds).filter((u) => !o.has(u)).map((u) => t.getSerializedUpdate(u)).filter((u) => !!u);
|
|
2644
2646
|
let c = [...a, ...l];
|
|
2645
2647
|
n.orderBy?.length && (c = X(c, n.orderBy)), r.next(c, !0);
|
|
2646
|
-
},
|
|
2648
|
+
}, Cs = (r, e) => {
|
|
2647
2649
|
const n = Array.from(r.resultEntitySet.values()).some((i) => {
|
|
2648
2650
|
const a = N(i);
|
|
2649
2651
|
return !!a && e.updatedIds.has(a);
|
|
2650
2652
|
}), s = e.newlyMatchedIds.size > 0;
|
|
2651
2653
|
(n || s) && r.refresh();
|
|
2652
|
-
},
|
|
2654
|
+
}, Is = (r, e) => {
|
|
2653
2655
|
const n = Array.from(r.resultEntitySet.values()).some((i) => {
|
|
2654
2656
|
const a = N(i);
|
|
2655
2657
|
return !!a && e.updatedIds.has(a);
|
|
2656
2658
|
}), s = e.newlyMatchedIds.size > 0;
|
|
2657
2659
|
(n || s) && r.refresh();
|
|
2658
|
-
},
|
|
2660
|
+
}, Ts = (r, e, t) => {
|
|
2659
2661
|
const n = r.options, s = n.where;
|
|
2660
2662
|
if (r.result === null || r.result === void 0) {
|
|
2661
2663
|
e.newlyMatchedIds.size > 0 && r.refresh();
|
|
@@ -2678,7 +2680,7 @@ const Rs = (r, e, t) => {
|
|
|
2678
2680
|
return;
|
|
2679
2681
|
}
|
|
2680
2682
|
e.newlyMatchedIds.size > 0 && r.refresh();
|
|
2681
|
-
},
|
|
2683
|
+
}, As = (r, e) => {
|
|
2682
2684
|
const t = r.result || 0, n = e.newlyMatchedIds.size, s = e.newlyUnmatchedIds.size;
|
|
2683
2685
|
if (n > 0 || s > 0) {
|
|
2684
2686
|
const i = Math.max(0, t + n - s);
|
|
@@ -2838,7 +2840,7 @@ class Oe {
|
|
|
2838
2840
|
return !1;
|
|
2839
2841
|
}
|
|
2840
2842
|
}
|
|
2841
|
-
const
|
|
2843
|
+
const Ss = (r, e, t, n) => {
|
|
2842
2844
|
const s = r.options, i = s.entityId, a = s.level, o = Array.from(r.resultEntitySet.values()), l = /* @__PURE__ */ new Map();
|
|
2843
2845
|
o.forEach((y) => {
|
|
2844
2846
|
const g = N(y);
|
|
@@ -2898,7 +2900,7 @@ const Ms = (r, e, t, n) => {
|
|
|
2898
2900
|
return;
|
|
2899
2901
|
const f = [...h, ...p];
|
|
2900
2902
|
r.next(f, !0);
|
|
2901
|
-
},
|
|
2903
|
+
}, Ms = (r, e, t, n) => {
|
|
2902
2904
|
const i = r.options.entityId, a = Array.from(r.resultEntitySet.values()), o = /* @__PURE__ */ new Map();
|
|
2903
2905
|
a.forEach((b) => {
|
|
2904
2906
|
const w = N(b);
|
|
@@ -2953,7 +2955,7 @@ const Ms = (r, e, t, n) => {
|
|
|
2953
2955
|
return;
|
|
2954
2956
|
const v = [...y, ...g];
|
|
2955
2957
|
r.next(v, !0);
|
|
2956
|
-
},
|
|
2958
|
+
}, Os = (r, e, t, n, s, i) => {
|
|
2957
2959
|
const o = r.options.entityId, l = r.result || 0, c = /* @__PURE__ */ new Map(), u = new Oe(n, c);
|
|
2958
2960
|
let d = !1, h = 0;
|
|
2959
2961
|
for (const p of e) {
|
|
@@ -2979,7 +2981,7 @@ const Ms = (r, e, t, n) => {
|
|
|
2979
2981
|
const p = Math.max(0, l + h);
|
|
2980
2982
|
r.next(p);
|
|
2981
2983
|
}
|
|
2982
|
-
},
|
|
2984
|
+
}, xs = (r, e, t, n, s, i) => {
|
|
2983
2985
|
const o = r.options.entityId, l = r.result || 0;
|
|
2984
2986
|
if (!o) {
|
|
2985
2987
|
r.refresh();
|
|
@@ -3037,36 +3039,36 @@ const Ms = (r, e, t, n) => {
|
|
|
3037
3039
|
const v = Math.max(0, l + y);
|
|
3038
3040
|
r.next(v);
|
|
3039
3041
|
}
|
|
3040
|
-
},
|
|
3041
|
-
const t = r.options.where, n = new
|
|
3042
|
+
}, Ns = (r, e) => {
|
|
3043
|
+
const t = r.options.where, n = new vs(e, (i) => r.serialize(i)), s = Es(e, t, Y);
|
|
3042
3044
|
switch (r.type) {
|
|
3043
3045
|
case "findAll":
|
|
3044
|
-
|
|
3046
|
+
Rs(r, s, n);
|
|
3045
3047
|
break;
|
|
3046
3048
|
case "find":
|
|
3047
|
-
|
|
3049
|
+
Cs(r, s);
|
|
3048
3050
|
break;
|
|
3049
3051
|
case "findOne":
|
|
3050
3052
|
case "findOneOrFail":
|
|
3051
|
-
|
|
3053
|
+
Ts(r, s, n);
|
|
3052
3054
|
break;
|
|
3053
3055
|
case "findByCursor":
|
|
3054
|
-
|
|
3056
|
+
Is(r, s);
|
|
3055
3057
|
break;
|
|
3056
3058
|
case "count":
|
|
3057
|
-
|
|
3059
|
+
As(r, s);
|
|
3058
3060
|
break;
|
|
3059
3061
|
case "findDescendants":
|
|
3060
|
-
|
|
3062
|
+
Ss(r, e, s, n);
|
|
3061
3063
|
break;
|
|
3062
3064
|
case "findAncestors":
|
|
3063
|
-
|
|
3065
|
+
Ms(r, e, s, n);
|
|
3064
3066
|
break;
|
|
3065
3067
|
case "countDescendants":
|
|
3066
|
-
|
|
3068
|
+
Os(r, e, s, n, t, Y);
|
|
3067
3069
|
break;
|
|
3068
3070
|
case "countAncestors":
|
|
3069
|
-
|
|
3071
|
+
xs(r, e, s, n, t, Y);
|
|
3070
3072
|
break;
|
|
3071
3073
|
}
|
|
3072
3074
|
}, Xe = (r, e) => {
|
|
@@ -3133,10 +3135,10 @@ const Ms = (r, e, t, n) => {
|
|
|
3133
3135
|
t.push(["match_where"]), t.push(["match_where_before"]), t.push(["match_relation_where"]);
|
|
3134
3136
|
break;
|
|
3135
3137
|
}
|
|
3136
|
-
const s =
|
|
3137
|
-
s.refresh ? r.refresh() : s.recalculate &&
|
|
3138
|
+
const s = Pr(r, e, t, n);
|
|
3139
|
+
s.refresh ? r.refresh() : s.recalculate && Ns(r, e);
|
|
3138
3140
|
};
|
|
3139
|
-
class
|
|
3141
|
+
class Ps {
|
|
3140
3142
|
/**
|
|
3141
3143
|
* 构造函数
|
|
3142
3144
|
*
|
|
@@ -3153,10 +3155,10 @@ class $s {
|
|
|
3153
3155
|
#n = /* @__PURE__ */ new Map();
|
|
3154
3156
|
#t = /* @__PURE__ */ new Map();
|
|
3155
3157
|
#r = /* @__PURE__ */ new Map();
|
|
3156
|
-
#
|
|
3157
|
-
#
|
|
3158
|
+
#i = /* @__PURE__ */ new Map();
|
|
3159
|
+
#s;
|
|
3158
3160
|
destroy() {
|
|
3159
|
-
this.rxdb.removeEventListener(ne, this.#
|
|
3161
|
+
this.rxdb.removeEventListener(ne, this.#s), this.rxdb.removeEventListener(oe, this.#s), this.rxdb.removeEventListener(ce, this.#s), this.#e.clear();
|
|
3160
3162
|
}
|
|
3161
3163
|
// ==================== 通用仓库查询方法重载 ====================
|
|
3162
3164
|
/**
|
|
@@ -3182,7 +3184,7 @@ class $s {
|
|
|
3182
3184
|
this.#r.set(e, t);
|
|
3183
3185
|
}
|
|
3184
3186
|
registerMergeRemoveFn(e, t) {
|
|
3185
|
-
this.#
|
|
3187
|
+
this.#i.set(e, t);
|
|
3186
3188
|
}
|
|
3187
3189
|
/**
|
|
3188
3190
|
* 创建新的查询任务
|
|
@@ -3192,7 +3194,7 @@ class $s {
|
|
|
3192
3194
|
* @returns 新创建的查询任务
|
|
3193
3195
|
*/
|
|
3194
3196
|
#o(e, t) {
|
|
3195
|
-
return new
|
|
3197
|
+
return new ys({
|
|
3196
3198
|
cacheKey: e,
|
|
3197
3199
|
...t,
|
|
3198
3200
|
entityType: this.EntityType,
|
|
@@ -3278,16 +3280,16 @@ class $s {
|
|
|
3278
3280
|
(this.#r.get(i.type) || Xe)(i, s);
|
|
3279
3281
|
break;
|
|
3280
3282
|
case ce:
|
|
3281
|
-
(this.#
|
|
3283
|
+
(this.#i.get(i.type) || Je)(i, s);
|
|
3282
3284
|
break;
|
|
3283
3285
|
}
|
|
3284
3286
|
});
|
|
3285
3287
|
}
|
|
3286
3288
|
};
|
|
3287
|
-
this.#
|
|
3289
|
+
this.#s = e, this.rxdb.addEventListener(ne, e), this.rxdb.addEventListener(oe, e), this.rxdb.addEventListener(ce, e);
|
|
3288
3290
|
}
|
|
3289
3291
|
}
|
|
3290
|
-
class
|
|
3292
|
+
class $s {
|
|
3291
3293
|
constructor(e, t) {
|
|
3292
3294
|
this.rxdb = e, this.EntityType = t;
|
|
3293
3295
|
}
|
|
@@ -3324,7 +3326,7 @@ class Bs {
|
|
|
3324
3326
|
n.origin = { ...t }, Object.assign(e, t);
|
|
3325
3327
|
}
|
|
3326
3328
|
}
|
|
3327
|
-
class sn extends
|
|
3329
|
+
class sn extends $s {
|
|
3328
3330
|
static _STATIC_METHODS = [
|
|
3329
3331
|
...super._STATIC_METHODS,
|
|
3330
3332
|
"get",
|
|
@@ -3368,7 +3370,7 @@ class sn extends Bs {
|
|
|
3368
3370
|
const n = I(t);
|
|
3369
3371
|
this.sync = n.sync || e.config.sync;
|
|
3370
3372
|
const { local: s, remote: i } = this.sync, a = !s && !!i;
|
|
3371
|
-
this.primary$ = a ? this.remote$ : this.local$, this.queryManager = new
|
|
3373
|
+
this.primary$ = a ? this.remote$ : this.local$, this.queryManager = new Ps(e, t, this);
|
|
3372
3374
|
}
|
|
3373
3375
|
/**
|
|
3374
3376
|
* 根据 id 获取实体
|
|
@@ -3393,7 +3395,7 @@ class sn extends Bs {
|
|
|
3393
3395
|
if (s.length === 0) throw new R(`Entity with id ${e} not found`);
|
|
3394
3396
|
return s[0];
|
|
3395
3397
|
}),
|
|
3396
|
-
|
|
3398
|
+
k((s) => this._setLocal(s))
|
|
3397
3399
|
);
|
|
3398
3400
|
return this.queryManager.createTask({
|
|
3399
3401
|
options: { type: "get", options: e },
|
|
@@ -3409,7 +3411,7 @@ class sn extends Bs {
|
|
|
3409
3411
|
const t = () => this.primary$.pipe(
|
|
3410
3412
|
x((n) => n.find({ ...e, limit: 1 })),
|
|
3411
3413
|
$((n) => n[0] || null),
|
|
3412
|
-
|
|
3414
|
+
k((n) => n && this._setLocal(n))
|
|
3413
3415
|
);
|
|
3414
3416
|
return this.queryManager.createTask({
|
|
3415
3417
|
options: { type: "findOne", options: e },
|
|
@@ -3428,7 +3430,7 @@ class sn extends Bs {
|
|
|
3428
3430
|
if (n.length === 0) throw new R(`Entity not found for query: ${JSON.stringify(e.where)}`);
|
|
3429
3431
|
return n[0];
|
|
3430
3432
|
}),
|
|
3431
|
-
|
|
3433
|
+
k((n) => this._setLocal(n))
|
|
3432
3434
|
);
|
|
3433
3435
|
return this.queryManager.createTask({
|
|
3434
3436
|
options: { type: "findOneOrFail", options: e },
|
|
@@ -3443,7 +3445,7 @@ class sn extends Bs {
|
|
|
3443
3445
|
find(e) {
|
|
3444
3446
|
const t = () => this.primary$.pipe(
|
|
3445
3447
|
x((n) => n.find({ ...e, limit: e.limit || 100, offset: e.offset || 0 })),
|
|
3446
|
-
|
|
3448
|
+
k(this._setLocals)
|
|
3447
3449
|
);
|
|
3448
3450
|
return this.queryManager.createTask({
|
|
3449
3451
|
options: { type: "find", options: e },
|
|
@@ -3459,7 +3461,7 @@ class sn extends Bs {
|
|
|
3459
3461
|
findAll(e) {
|
|
3460
3462
|
const t = () => this.primary$.pipe(
|
|
3461
3463
|
x((n) => n.find(e)),
|
|
3462
|
-
|
|
3464
|
+
k(this._setLocals)
|
|
3463
3465
|
);
|
|
3464
3466
|
return this.queryManager.createTask({
|
|
3465
3467
|
options: { type: "findAll", options: e },
|
|
@@ -3479,11 +3481,11 @@ class sn extends Bs {
|
|
|
3479
3481
|
if (e.before && e.after)
|
|
3480
3482
|
throw new R("before and after cannot be used together in cursor-based pagination");
|
|
3481
3483
|
let n = structuredClone(e.where);
|
|
3482
|
-
const s =
|
|
3483
|
-
s && (n =
|
|
3484
|
+
const s = Bs(e);
|
|
3485
|
+
s && (n = Ds(n, s));
|
|
3484
3486
|
const i = () => this.primary$.pipe(
|
|
3485
3487
|
x((a) => a.find({ ...e, where: n })),
|
|
3486
|
-
|
|
3488
|
+
k(this._setLocals)
|
|
3487
3489
|
);
|
|
3488
3490
|
return this.queryManager.createTask({
|
|
3489
3491
|
options: { type: "findByCursor", options: e },
|
|
@@ -3510,7 +3512,7 @@ class sn extends Bs {
|
|
|
3510
3512
|
create(e) {
|
|
3511
3513
|
const t = this.primary$.pipe(
|
|
3512
3514
|
x((n) => n.create(e)),
|
|
3513
|
-
|
|
3515
|
+
k(this._setLocal)
|
|
3514
3516
|
);
|
|
3515
3517
|
return L(t);
|
|
3516
3518
|
}
|
|
@@ -3522,7 +3524,7 @@ class sn extends Bs {
|
|
|
3522
3524
|
update(e, t) {
|
|
3523
3525
|
const n = this.primary$.pipe(
|
|
3524
3526
|
x((s) => s.update(e, t)),
|
|
3525
|
-
|
|
3527
|
+
k(this._setLocal)
|
|
3526
3528
|
);
|
|
3527
3529
|
return L(n);
|
|
3528
3530
|
}
|
|
@@ -3543,7 +3545,7 @@ class sn extends Bs {
|
|
|
3543
3545
|
};
|
|
3544
3546
|
_setLocals = (e) => e.forEach(this._setLocal);
|
|
3545
3547
|
}
|
|
3546
|
-
const
|
|
3548
|
+
const Bs = (r) => {
|
|
3547
3549
|
const e = r.after || r.before;
|
|
3548
3550
|
if (!e) return null;
|
|
3549
3551
|
const t = !!r.after;
|
|
@@ -3565,7 +3567,7 @@ const Ds = (r) => {
|
|
|
3565
3567
|
c.push({ field: i, operator: u, value: e[i] }), n.push({ combinator: "and", rules: c });
|
|
3566
3568
|
}
|
|
3567
3569
|
return { combinator: "or", rules: n };
|
|
3568
|
-
},
|
|
3570
|
+
}, Ds = (r, e) => r.combinator === "and" ? { ...r, rules: [...r.rules, e] } : { combinator: "and", rules: [r, e] };
|
|
3569
3571
|
class an {
|
|
3570
3572
|
constructor(e) {
|
|
3571
3573
|
this.rxdb = e;
|
|
@@ -3581,17 +3583,17 @@ class an {
|
|
|
3581
3583
|
this.repository_map.set(e, t);
|
|
3582
3584
|
}
|
|
3583
3585
|
}
|
|
3584
|
-
class
|
|
3586
|
+
class da extends an {
|
|
3585
3587
|
}
|
|
3586
|
-
class
|
|
3588
|
+
class ha extends an {
|
|
3587
3589
|
}
|
|
3588
|
-
class
|
|
3590
|
+
class pa {
|
|
3589
3591
|
constructor(e) {
|
|
3590
3592
|
this.rxdb = e;
|
|
3591
3593
|
}
|
|
3592
3594
|
}
|
|
3593
3595
|
const At = 100;
|
|
3594
|
-
class
|
|
3596
|
+
class Ls extends sn {
|
|
3595
3597
|
static _STATIC_METHODS = [
|
|
3596
3598
|
...super._STATIC_METHODS,
|
|
3597
3599
|
"findDescendants",
|
|
@@ -3606,7 +3608,7 @@ class Fs extends sn {
|
|
|
3606
3608
|
e = this.#e(e);
|
|
3607
3609
|
const t = () => this.primary$.pipe(
|
|
3608
3610
|
x((n) => n.findDescendants(e)),
|
|
3609
|
-
|
|
3611
|
+
k(this._setLocals)
|
|
3610
3612
|
);
|
|
3611
3613
|
return this.queryManager.createTask({
|
|
3612
3614
|
options: { type: "findDescendants", options: e },
|
|
@@ -3633,7 +3635,7 @@ class Fs extends sn {
|
|
|
3633
3635
|
e = this.#e(e);
|
|
3634
3636
|
const t = () => this.primary$.pipe(
|
|
3635
3637
|
x((n) => n.findAncestors(e)),
|
|
3636
|
-
|
|
3638
|
+
k(this._setLocals)
|
|
3637
3639
|
);
|
|
3638
3640
|
return this.queryManager.createTask({
|
|
3639
3641
|
options: { type: "findAncestors", options: e },
|
|
@@ -3658,7 +3660,7 @@ class Fs extends sn {
|
|
|
3658
3660
|
return n < 0 ? t.level = 0 : n > At ? t.level = At : t.level = n, t.entityId = t.entityId ?? null, t;
|
|
3659
3661
|
}
|
|
3660
3662
|
}
|
|
3661
|
-
class
|
|
3663
|
+
class Fs {
|
|
3662
3664
|
/**
|
|
3663
3665
|
* 创建实体状态实例
|
|
3664
3666
|
*
|
|
@@ -3709,13 +3711,19 @@ class Us {
|
|
|
3709
3711
|
* 每次调用 checkChange 时发布最新的 patches 数组
|
|
3710
3712
|
* 使用 shareReplay(1) 确保新订阅者能立即收到最近的变更记录
|
|
3711
3713
|
*/
|
|
3712
|
-
#t = new
|
|
3714
|
+
#t = new Yn();
|
|
3713
3715
|
/**
|
|
3714
3716
|
* 状态快照数组
|
|
3715
3717
|
* 存储实体在不同时间点的完整状态,用于支持撤销/重做功能
|
|
3716
3718
|
* 第一个元素是初始状态(首次调用 checkChange 时记录)
|
|
3717
3719
|
*/
|
|
3718
3720
|
#r = [];
|
|
3721
|
+
/**
|
|
3722
|
+
* 增量变更记录
|
|
3723
|
+
* 只记录被修改的属性键,用于优化 patch 计算
|
|
3724
|
+
* @private
|
|
3725
|
+
*/
|
|
3726
|
+
#i = /* @__PURE__ */ new Set();
|
|
3719
3727
|
/**
|
|
3720
3728
|
* 标识实体是否存在于远程数据库
|
|
3721
3729
|
*/
|
|
@@ -3809,11 +3817,16 @@ class Us {
|
|
|
3809
3817
|
* 当前变更内容(相对于 origin)
|
|
3810
3818
|
* 返回与 origin 不同的属性集合,用于生成数据库更新语句
|
|
3811
3819
|
*
|
|
3812
|
-
*
|
|
3813
|
-
* 缓存失效:修改 modified 属性时清空缓存
|
|
3820
|
+
* 优化:只比较被修改过的属性键,避免全量遍历
|
|
3814
3821
|
*/
|
|
3815
3822
|
get patch() {
|
|
3816
|
-
|
|
3823
|
+
if (!this._patch_cache) {
|
|
3824
|
+
const e = Array.from(this.#i);
|
|
3825
|
+
this._patch_cache = {};
|
|
3826
|
+
for (const t of e)
|
|
3827
|
+
this.proxyTarget[t] !== this.origin[t] && (this._patch_cache[t] = this.proxyTarget[t]);
|
|
3828
|
+
}
|
|
3829
|
+
return this._patch_cache || null;
|
|
3817
3830
|
}
|
|
3818
3831
|
/**
|
|
3819
3832
|
* 逆向变更内容(用于撤销操作)
|
|
@@ -3822,7 +3835,7 @@ class Us {
|
|
|
3822
3835
|
* 例如:patch = { name: 'new' } → inversePatch = { name: 'old' }
|
|
3823
3836
|
*/
|
|
3824
3837
|
get inversePatch() {
|
|
3825
|
-
return this.patch &&
|
|
3838
|
+
return this.patch && An(this.origin, Object.keys(this.patch)) || null;
|
|
3826
3839
|
}
|
|
3827
3840
|
/**
|
|
3828
3841
|
* 获取变化
|
|
@@ -3853,6 +3866,14 @@ class Us {
|
|
|
3853
3866
|
get fingerprint() {
|
|
3854
3867
|
return this._fingerprint || (this._fingerprint = `${this.target.id}@${this.target.updatedAt && this.target.updatedAt.getTime()}`), this._fingerprint;
|
|
3855
3868
|
}
|
|
3869
|
+
/**
|
|
3870
|
+
* 记录属性变更
|
|
3871
|
+
* 在 Proxy set 拦截时调用,同步记录哪些属性被修改
|
|
3872
|
+
* @param key - 被修改的属性键
|
|
3873
|
+
*/
|
|
3874
|
+
markChanged(e) {
|
|
3875
|
+
this.#i.add(e);
|
|
3876
|
+
}
|
|
3856
3877
|
/**
|
|
3857
3878
|
* 重置实体状态到初始状态(origin)
|
|
3858
3879
|
*
|
|
@@ -3865,7 +3886,7 @@ class Us {
|
|
|
3865
3886
|
* 使用场景:撤销所有未保存的修改
|
|
3866
3887
|
*/
|
|
3867
3888
|
reset() {
|
|
3868
|
-
Object.assign(this.proxyTarget, this.origin), this._modified = !1, this.#s(), this._patches = [], this.#t.next(this._patches);
|
|
3889
|
+
Object.assign(this.proxyTarget, this.origin), this._modified = !1, this.#s(), this.#i.clear(), this._patches = [], this.#t.next(this._patches);
|
|
3869
3890
|
}
|
|
3870
3891
|
/**
|
|
3871
3892
|
* 记录实体变更
|
|
@@ -4027,26 +4048,27 @@ class Us {
|
|
|
4027
4048
|
return t || (t = /* @__PURE__ */ new Set(), this.#e.set(e, t)), t;
|
|
4028
4049
|
}
|
|
4029
4050
|
/**
|
|
4030
|
-
*
|
|
4051
|
+
* 清理计算缓存
|
|
4031
4052
|
* 在 modified 或其他需要重新计算的场景调用
|
|
4053
|
+
* 注意:不清理 #changed_keys,它是累积的源数据,仅在 reset() 时清除
|
|
4032
4054
|
* @private
|
|
4033
4055
|
*/
|
|
4034
4056
|
#s() {
|
|
4035
4057
|
this._patch_cache = void 0, this._fingerprint = void 0;
|
|
4036
4058
|
}
|
|
4037
4059
|
}
|
|
4038
|
-
const
|
|
4060
|
+
const Us = (r) => {
|
|
4039
4061
|
const e = O(r), t = I(r.constructor), n = () => e.checkChange();
|
|
4040
4062
|
let s;
|
|
4041
4063
|
const i = {
|
|
4042
4064
|
/**
|
|
4043
4065
|
* 拦截属性设置操作
|
|
4044
|
-
*
|
|
4066
|
+
* 当属性值发生变化时,同步记录变更属性键,并安排异步检查
|
|
4045
4067
|
* 同时根据 metadata 配置进行类型转换
|
|
4046
4068
|
*/
|
|
4047
4069
|
set: (a, o, l, c) => {
|
|
4048
4070
|
if (Dt(a[o], l)) return !0;
|
|
4049
|
-
if (
|
|
4071
|
+
if (Sn(o) === !1 && (e.markChanged(o), e.modified = !0, clearTimeout(s), s = setTimeout(() => n(), 0), l === null && t.isForeignKey(o))) {
|
|
4050
4072
|
const u = t.foreignKeyRelationMap.get(o);
|
|
4051
4073
|
u && (u.kind === T.MANY_TO_ONE || u.kind === T.ONE_TO_ONE) && e.cleanRelationEntity(u);
|
|
4052
4074
|
}
|
|
@@ -4054,7 +4076,7 @@ const js = (r) => {
|
|
|
4054
4076
|
}
|
|
4055
4077
|
};
|
|
4056
4078
|
return new Proxy(r, i);
|
|
4057
|
-
},
|
|
4079
|
+
}, js = (r, e, t) => {
|
|
4058
4080
|
const n = t.rxdb.schemaManager.getEntityType(r.mappedEntity, r.mappedNamespace);
|
|
4059
4081
|
if (!n) throw new R(`mapped entity not found: ${r.mappedEntity}`);
|
|
4060
4082
|
const s = r.name + "Id", i = r.name + "$";
|
|
@@ -4203,7 +4225,7 @@ const js = (r) => {
|
|
|
4203
4225
|
configurable: !1
|
|
4204
4226
|
});
|
|
4205
4227
|
};
|
|
4206
|
-
class
|
|
4228
|
+
class Ys {
|
|
4207
4229
|
/**
|
|
4208
4230
|
* 创建实体管理器实例
|
|
4209
4231
|
*
|
|
@@ -4223,7 +4245,7 @@ class zs {
|
|
|
4223
4245
|
remove: Je
|
|
4224
4246
|
}
|
|
4225
4247
|
}).repository("TreeRepository", {
|
|
4226
|
-
class:
|
|
4248
|
+
class: Ls,
|
|
4227
4249
|
mergeOperations: {
|
|
4228
4250
|
create: Qe,
|
|
4229
4251
|
update: Xe,
|
|
@@ -4245,7 +4267,7 @@ class zs {
|
|
|
4245
4267
|
init() {
|
|
4246
4268
|
this.rxdb.config.entities.forEach((e) => {
|
|
4247
4269
|
const t = I(e);
|
|
4248
|
-
M(e.prototype,
|
|
4270
|
+
M(e.prototype, ke, this), M(t, ke, this), M(t, We, e);
|
|
4249
4271
|
const n = this.rxdb.getRepositoryConfig(t.repository);
|
|
4250
4272
|
n && n.class.staticMethods.forEach(
|
|
4251
4273
|
(i) => M(
|
|
@@ -4255,12 +4277,12 @@ class zs {
|
|
|
4255
4277
|
)
|
|
4256
4278
|
), Object.keys(St).forEach(
|
|
4257
4279
|
(s) => M(e.prototype, s, St[s](this, e))
|
|
4258
|
-
), t.relationMap.forEach((s) =>
|
|
4259
|
-
}), M(this,
|
|
4260
|
-
const t = this.#
|
|
4261
|
-
return
|
|
4280
|
+
), t.relationMap.forEach((s) => js(s, e, this));
|
|
4281
|
+
}), M(this, Wt, (e) => {
|
|
4282
|
+
const t = this.#i(e, { local: !1, remote: !1, modified: !0 });
|
|
4283
|
+
return Mn(() => {
|
|
4262
4284
|
this.addEntityCache(t);
|
|
4263
|
-
const n = I(e), s = new
|
|
4285
|
+
const n = I(e), s = new Zn([
|
|
4264
4286
|
{
|
|
4265
4287
|
type: "NEW",
|
|
4266
4288
|
namespace: n.namespace,
|
|
@@ -4299,7 +4321,7 @@ class zs {
|
|
|
4299
4321
|
return Object.assign(i, t);
|
|
4300
4322
|
{
|
|
4301
4323
|
i = Object.create(e.prototype), Object.assign(i, t);
|
|
4302
|
-
const a = this.#
|
|
4324
|
+
const a = this.#i(i, n);
|
|
4303
4325
|
return s.set(i.id, a), a;
|
|
4304
4326
|
}
|
|
4305
4327
|
}
|
|
@@ -4357,7 +4379,7 @@ class zs {
|
|
|
4357
4379
|
* @returns 保存后的实体实例
|
|
4358
4380
|
*/
|
|
4359
4381
|
async save(e) {
|
|
4360
|
-
const t = gt([e]), n =
|
|
4382
|
+
const t = gt([e]), n = ur([e]);
|
|
4361
4383
|
if (t.length === 1 && n.length === 0) {
|
|
4362
4384
|
const s = t[0];
|
|
4363
4385
|
O(s).local ? await this.update(s) : await this.create(s);
|
|
@@ -4502,10 +4524,10 @@ class zs {
|
|
|
4502
4524
|
* @param [status] - 可选的实体状态配置
|
|
4503
4525
|
* @returns 初始化后的代理实体实例
|
|
4504
4526
|
*/
|
|
4505
|
-
#
|
|
4506
|
-
const n = new
|
|
4507
|
-
|
|
4508
|
-
const s =
|
|
4527
|
+
#i(e, t) {
|
|
4528
|
+
const n = new Fs(this.rxdb, { target: e, ...t });
|
|
4529
|
+
or(e, Kt, n);
|
|
4530
|
+
const s = Us(e);
|
|
4509
4531
|
return M(n, "proxyTarget", s), s;
|
|
4510
4532
|
}
|
|
4511
4533
|
}
|
|
@@ -4520,13 +4542,13 @@ const St = {
|
|
|
4520
4542
|
return r.reset(this);
|
|
4521
4543
|
}
|
|
4522
4544
|
}, Mt = "entity_event", Ot = "hello", xt = "first_connected_at";
|
|
4523
|
-
class
|
|
4545
|
+
class zs {
|
|
4524
4546
|
#e;
|
|
4525
4547
|
#n;
|
|
4526
4548
|
#t;
|
|
4527
4549
|
#r = [];
|
|
4528
|
-
#s;
|
|
4529
4550
|
#i;
|
|
4551
|
+
#s;
|
|
4530
4552
|
#o = !1;
|
|
4531
4553
|
#a;
|
|
4532
4554
|
#c = 0;
|
|
@@ -4548,7 +4570,7 @@ class Ws {
|
|
|
4548
4570
|
return this.#o;
|
|
4549
4571
|
}
|
|
4550
4572
|
constructor(e) {
|
|
4551
|
-
this.#t = e.clientId, this.#e =
|
|
4573
|
+
this.#t = e.clientId, this.#e = On(`${e.dbName}_gateway`), this.#n = new xn(`${e.dbName}_leader`);
|
|
4552
4574
|
}
|
|
4553
4575
|
/**
|
|
4554
4576
|
* 初始化网关
|
|
@@ -4557,13 +4579,13 @@ class Ws {
|
|
|
4557
4579
|
* @param addEventListener - 事件监听器注册函数(用于监听本地事件并广播)
|
|
4558
4580
|
*/
|
|
4559
4581
|
init(e, t, n) {
|
|
4560
|
-
this.#
|
|
4582
|
+
this.#i = n, this.#d(e), this.#y(t), this.#m(), this.#h();
|
|
4561
4583
|
}
|
|
4562
4584
|
/**
|
|
4563
4585
|
* 销毁网关,释放资源
|
|
4564
4586
|
*/
|
|
4565
4587
|
destroy() {
|
|
4566
|
-
this.#r.forEach((e) => e.unsubscribe()), this.#r.length = 0, this.#n.dispose(), this.#
|
|
4588
|
+
this.#r.forEach((e) => e.unsubscribe()), this.#r.length = 0, this.#n.dispose(), this.#i && this.#s && (this.#i(ne, this.#s), this.#i(oe, this.#s), this.#i(ce, this.#s));
|
|
4567
4589
|
}
|
|
4568
4590
|
/**
|
|
4569
4591
|
* 生成唯一消息 ID
|
|
@@ -4634,7 +4656,7 @@ class Ws {
|
|
|
4634
4656
|
*/
|
|
4635
4657
|
#y(e) {
|
|
4636
4658
|
const t = (n) => this.#f(n);
|
|
4637
|
-
this.#
|
|
4659
|
+
this.#s = t, e(ne, t), e(oe, t), e(ce, t);
|
|
4638
4660
|
}
|
|
4639
4661
|
/**
|
|
4640
4662
|
* 设置 Leader 选举
|
|
@@ -4666,7 +4688,7 @@ const ks = (r) => {
|
|
|
4666
4688
|
mappedNamespace: n.namespace,
|
|
4667
4689
|
mappedEntity: n.name,
|
|
4668
4690
|
mappedProperty: s.name,
|
|
4669
|
-
onDelete:
|
|
4691
|
+
onDelete: W.CASCADE
|
|
4670
4692
|
},
|
|
4671
4693
|
{
|
|
4672
4694
|
/**
|
|
@@ -4678,16 +4700,16 @@ const ks = (r) => {
|
|
|
4678
4700
|
mappedNamespace: e.namespace,
|
|
4679
4701
|
mappedEntity: e.name,
|
|
4680
4702
|
mappedProperty: t.name,
|
|
4681
|
-
onDelete:
|
|
4703
|
+
onDelete: W.CASCADE
|
|
4682
4704
|
}
|
|
4683
4705
|
]
|
|
4684
4706
|
};
|
|
4685
4707
|
};
|
|
4686
|
-
var
|
|
4687
|
-
for (var s = n > 1 ? void 0 : n ?
|
|
4708
|
+
var Ws = Object.defineProperty, Ks = Object.getOwnPropertyDescriptor, Hs = (r, e, t) => e in r ? Ws(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, qs = (r, e, t, n) => {
|
|
4709
|
+
for (var s = n > 1 ? void 0 : n ? Ks(e, t) : e, i = r.length - 1, a; i >= 0; i--)
|
|
4688
4710
|
(a = r[i]) && (s = a(s) || s);
|
|
4689
4711
|
return s;
|
|
4690
|
-
},
|
|
4712
|
+
}, Vs = (r, e, t) => Hs(r, typeof e != "symbol" ? e + "" : e, t), on;
|
|
4691
4713
|
on = ct;
|
|
4692
4714
|
let K = class {
|
|
4693
4715
|
/**
|
|
@@ -4741,9 +4763,9 @@ let K = class {
|
|
|
4741
4763
|
*/
|
|
4742
4764
|
children$;
|
|
4743
4765
|
};
|
|
4744
|
-
|
|
4745
|
-
K =
|
|
4746
|
-
|
|
4766
|
+
Vs(K, on);
|
|
4767
|
+
K = qs([
|
|
4768
|
+
yr({
|
|
4747
4769
|
name: "RxDBBranch",
|
|
4748
4770
|
tableName: "rxdb_branch",
|
|
4749
4771
|
log: !1,
|
|
@@ -4818,11 +4840,11 @@ K = Vs([
|
|
|
4818
4840
|
]
|
|
4819
4841
|
})
|
|
4820
4842
|
], K);
|
|
4821
|
-
var
|
|
4822
|
-
for (var s = n > 1 ? void 0 : n ?
|
|
4843
|
+
var Gs = Object.defineProperty, Qs = Object.getOwnPropertyDescriptor, Js = (r, e, t) => e in r ? Gs(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, Xs = (r, e, t, n) => {
|
|
4844
|
+
for (var s = n > 1 ? void 0 : n ? Qs(e, t) : e, i = r.length - 1, a; i >= 0; i--)
|
|
4823
4845
|
(a = r[i]) && (s = a(s) || s);
|
|
4824
4846
|
return s;
|
|
4825
|
-
},
|
|
4847
|
+
}, Zs = (r, e, t) => Js(r, typeof e != "symbol" ? e + "" : e, t), cn;
|
|
4826
4848
|
cn = ct;
|
|
4827
4849
|
let H = class {
|
|
4828
4850
|
/**
|
|
@@ -5359,8 +5381,8 @@ let H = class {
|
|
|
5359
5381
|
*/
|
|
5360
5382
|
branch$;
|
|
5361
5383
|
};
|
|
5362
|
-
|
|
5363
|
-
H =
|
|
5384
|
+
Zs(H, cn);
|
|
5385
|
+
H = Xs([
|
|
5364
5386
|
ie({
|
|
5365
5387
|
name: "RxDBChange",
|
|
5366
5388
|
tableName: "rxdb_change",
|
|
@@ -5454,11 +5476,11 @@ H = Zs([
|
|
|
5454
5476
|
]
|
|
5455
5477
|
})
|
|
5456
5478
|
], H);
|
|
5457
|
-
var
|
|
5458
|
-
for (var s = n > 1 ? void 0 : n ?
|
|
5479
|
+
var ei = Object.defineProperty, ti = Object.getOwnPropertyDescriptor, ni = (r, e, t) => e in r ? ei(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, ri = (r, e, t, n) => {
|
|
5480
|
+
for (var s = n > 1 ? void 0 : n ? ti(e, t) : e, i = r.length - 1, a; i >= 0; i--)
|
|
5459
5481
|
(a = r[i]) && (s = a(s) || s);
|
|
5460
5482
|
return s;
|
|
5461
|
-
},
|
|
5483
|
+
}, si = (r, e, t) => ni(r, typeof e != "symbol" ? e + "" : e, t), ln;
|
|
5462
5484
|
ln = ct;
|
|
5463
5485
|
let se = class {
|
|
5464
5486
|
/**
|
|
@@ -5475,8 +5497,8 @@ let se = class {
|
|
|
5475
5497
|
*/
|
|
5476
5498
|
name;
|
|
5477
5499
|
};
|
|
5478
|
-
|
|
5479
|
-
se =
|
|
5500
|
+
si(se, ln);
|
|
5501
|
+
se = ri([
|
|
5480
5502
|
ie({
|
|
5481
5503
|
name: "RxDBMigration",
|
|
5482
5504
|
tableName: "rxdb_migration",
|
|
@@ -5501,8 +5523,8 @@ se = si([
|
|
|
5501
5523
|
]
|
|
5502
5524
|
})
|
|
5503
5525
|
], se);
|
|
5504
|
-
var
|
|
5505
|
-
for (var s = n > 1 ? void 0 : n ?
|
|
5526
|
+
var ii = Object.getOwnPropertyDescriptor, ai = (r, e, t, n) => {
|
|
5527
|
+
for (var s = n > 1 ? void 0 : n ? ii(e, t) : e, i = r.length - 1, a; i >= 0; i--)
|
|
5506
5528
|
(a = r[i]) && (s = a(s) || s);
|
|
5507
5529
|
return s;
|
|
5508
5530
|
};
|
|
@@ -5570,7 +5592,7 @@ let z = class {
|
|
|
5570
5592
|
*/
|
|
5571
5593
|
branch;
|
|
5572
5594
|
};
|
|
5573
|
-
z =
|
|
5595
|
+
z = ai([
|
|
5574
5596
|
ie({
|
|
5575
5597
|
name: "RxDBSync",
|
|
5576
5598
|
tableName: "rxdb_sync",
|
|
@@ -5655,18 +5677,18 @@ z = oi([
|
|
|
5655
5677
|
kind: T.MANY_TO_ONE,
|
|
5656
5678
|
mappedEntity: "RxDBBranch",
|
|
5657
5679
|
mappedProperty: "syncs",
|
|
5658
|
-
onDelete:
|
|
5680
|
+
onDelete: W.CASCADE
|
|
5659
5681
|
}
|
|
5660
5682
|
]
|
|
5661
5683
|
})
|
|
5662
5684
|
], z);
|
|
5663
|
-
var
|
|
5664
|
-
for (var s = n > 1 ? void 0 : n ?
|
|
5685
|
+
var oi = Object.getOwnPropertyDescriptor, ci = (r, e, t, n) => {
|
|
5686
|
+
for (var s = n > 1 ? void 0 : n ? oi(e, t) : e, i = r.length - 1, a; i >= 0; i--)
|
|
5665
5687
|
(a = r[i]) && (s = a(s) || s);
|
|
5666
5688
|
return s;
|
|
5667
5689
|
};
|
|
5668
5690
|
const G = (r, e) => e + ":" + r;
|
|
5669
|
-
class
|
|
5691
|
+
class li {
|
|
5670
5692
|
constructor(e) {
|
|
5671
5693
|
this.rxdb = e;
|
|
5672
5694
|
}
|
|
@@ -5682,7 +5704,7 @@ class ui {
|
|
|
5682
5704
|
const o = this.rxdb.getRepositoryConfig(n.repository);
|
|
5683
5705
|
if (o?.entityGenerator) {
|
|
5684
5706
|
const l = o.entityGenerator(n);
|
|
5685
|
-
|
|
5707
|
+
Nn(l).forEach((u) => {
|
|
5686
5708
|
const d = I(u), h = G(d.name, d.namespace);
|
|
5687
5709
|
this.#e.has(h) || (this.#e.set(h, d), this.#n.set(h, u), e.push(u));
|
|
5688
5710
|
});
|
|
@@ -5700,7 +5722,7 @@ class ui {
|
|
|
5700
5722
|
if (this.#e.has(o) === !1) {
|
|
5701
5723
|
let l = class extends Ie {
|
|
5702
5724
|
};
|
|
5703
|
-
l =
|
|
5725
|
+
l = ci([
|
|
5704
5726
|
ie(a)
|
|
5705
5727
|
], l);
|
|
5706
5728
|
const c = I(l);
|
|
@@ -5714,7 +5736,7 @@ class ui {
|
|
|
5714
5736
|
this.#t.set(o, this.#n.get(n)), this.#r.set(o, t);
|
|
5715
5737
|
let l = this.rxdb;
|
|
5716
5738
|
i !== "public" && (M(l, i, {}), l = l[i]), M(l, s, this.#n.get(n));
|
|
5717
|
-
})
|
|
5739
|
+
});
|
|
5718
5740
|
}
|
|
5719
5741
|
/**
|
|
5720
5742
|
* 查找当前关系属性的映射关系
|
|
@@ -5801,7 +5823,7 @@ class ui {
|
|
|
5801
5823
|
return this.#r.get(G(e, t)) ?? this.#e.get(G(e, t));
|
|
5802
5824
|
}
|
|
5803
5825
|
}
|
|
5804
|
-
const
|
|
5826
|
+
const ui = "0.0.10", Ze = (r) => `${r.namespace}:${r.entity}:${r.entityId}`, fa = (r) => r.split(":");
|
|
5805
5827
|
function un(r, e = {
|
|
5806
5828
|
deletes: /* @__PURE__ */ new Map(),
|
|
5807
5829
|
updates: /* @__PURE__ */ new Map(),
|
|
@@ -5864,9 +5886,9 @@ function ft(r) {
|
|
|
5864
5886
|
const s = `${n.namespace}:${n.entity}`, i = e.get(s);
|
|
5865
5887
|
i && i.requiredBy.push(t.repository);
|
|
5866
5888
|
}
|
|
5867
|
-
return
|
|
5889
|
+
return di(e), e;
|
|
5868
5890
|
}
|
|
5869
|
-
function
|
|
5891
|
+
function di(r) {
|
|
5870
5892
|
const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Set(), n = [];
|
|
5871
5893
|
function s(i) {
|
|
5872
5894
|
e.add(i), t.add(i), n.push(i);
|
|
@@ -5888,11 +5910,11 @@ function hi(r) {
|
|
|
5888
5910
|
for (const i of r.keys())
|
|
5889
5911
|
e.has(i) || s(i);
|
|
5890
5912
|
}
|
|
5891
|
-
function
|
|
5913
|
+
function hi(r, e) {
|
|
5892
5914
|
return r.sync || e;
|
|
5893
5915
|
}
|
|
5894
5916
|
function j(r, e) {
|
|
5895
|
-
const t =
|
|
5917
|
+
const t = hi(r, e);
|
|
5896
5918
|
if (!t)
|
|
5897
5919
|
return "none";
|
|
5898
5920
|
if (t.type === fe.Filter)
|
|
@@ -5911,17 +5933,17 @@ function dn(r, e) {
|
|
|
5911
5933
|
const t = j(r, e);
|
|
5912
5934
|
return t === "full" || t === "filter" || t === "remote";
|
|
5913
5935
|
}
|
|
5914
|
-
function
|
|
5936
|
+
function pi(r, e) {
|
|
5915
5937
|
const t = j(r, e);
|
|
5916
5938
|
return t === "full" || t === "filter" || t === "local";
|
|
5917
5939
|
}
|
|
5918
|
-
function
|
|
5940
|
+
function fi(r, e) {
|
|
5919
5941
|
return j(r, e) === "none";
|
|
5920
5942
|
}
|
|
5921
|
-
function
|
|
5922
|
-
return r.filter((t) => !
|
|
5943
|
+
function ya(r, e) {
|
|
5944
|
+
return r.filter((t) => !fi(t, e));
|
|
5923
5945
|
}
|
|
5924
|
-
function
|
|
5946
|
+
function ma(r, e) {
|
|
5925
5947
|
const t = {
|
|
5926
5948
|
full: [],
|
|
5927
5949
|
filter: [],
|
|
@@ -5957,10 +5979,10 @@ function yt(r, e) {
|
|
|
5957
5979
|
i(a);
|
|
5958
5980
|
return t;
|
|
5959
5981
|
}
|
|
5960
|
-
function
|
|
5982
|
+
function yi(r) {
|
|
5961
5983
|
return yt(r, "pull");
|
|
5962
5984
|
}
|
|
5963
|
-
function
|
|
5985
|
+
function mi(r) {
|
|
5964
5986
|
return yt(r, "push");
|
|
5965
5987
|
}
|
|
5966
5988
|
function hn(r) {
|
|
@@ -5968,17 +5990,17 @@ function hn(r) {
|
|
|
5968
5990
|
const e = r;
|
|
5969
5991
|
return (e.combinator === "and" || e.combinator === "or") && Array.isArray(e.rules);
|
|
5970
5992
|
}
|
|
5971
|
-
const
|
|
5993
|
+
const gi = {
|
|
5972
5994
|
limit: 1e3,
|
|
5973
5995
|
fetchAll: !1,
|
|
5974
5996
|
includeRelated: !0,
|
|
5975
5997
|
filter: void 0
|
|
5976
5998
|
};
|
|
5977
5999
|
async function pn(r, e, t, n) {
|
|
5978
|
-
const s = { ...
|
|
6000
|
+
const s = { ...gi, ...n }, i = r.rxdb;
|
|
5979
6001
|
i.dispatchEvent(new it("pull", e, t, s.includeRelated));
|
|
5980
6002
|
try {
|
|
5981
|
-
const a = await
|
|
6003
|
+
const a = await _i(r, e, t, s);
|
|
5982
6004
|
return i.dispatchEvent(
|
|
5983
6005
|
new at("pull", e, t, {
|
|
5984
6006
|
pulled: a.pulled,
|
|
@@ -5989,7 +6011,7 @@ async function pn(r, e, t, n) {
|
|
|
5989
6011
|
throw i.dispatchEvent(new ot("pull", e, t, a)), a;
|
|
5990
6012
|
}
|
|
5991
6013
|
}
|
|
5992
|
-
async function
|
|
6014
|
+
async function _i(r, e, t, n) {
|
|
5993
6015
|
const s = r.rxdb.config.entities.find((c) => {
|
|
5994
6016
|
const u = I(c);
|
|
5995
6017
|
return u.namespace === e && u.name === t;
|
|
@@ -6019,15 +6041,15 @@ async function bi(r, e, t, n) {
|
|
|
6019
6041
|
}
|
|
6020
6042
|
}
|
|
6021
6043
|
const l = { ...n, filter: o };
|
|
6022
|
-
return n.includeRelated ? await
|
|
6044
|
+
return n.includeRelated ? await bi(r, e, t, l) : await fn(r, e, t, l);
|
|
6023
6045
|
}
|
|
6024
|
-
async function
|
|
6046
|
+
async function bi(r, e, t, n) {
|
|
6025
6047
|
const s = r.rxdb.config.entities.map((y) => I(y)), i = ft(s), a = new Map(
|
|
6026
6048
|
r.rxdb.config.entities.map((y) => {
|
|
6027
6049
|
const g = I(y);
|
|
6028
6050
|
return [`${g.namespace}:${g.name}`, y];
|
|
6029
6051
|
})
|
|
6030
|
-
), o =
|
|
6052
|
+
), o = yi(i), l = `${e}:${t}`;
|
|
6031
6053
|
if (!i.get(l))
|
|
6032
6054
|
throw new R(`Repository ${e}:${t} not found in dependency graph`);
|
|
6033
6055
|
const u = /* @__PURE__ */ new Set([l]), d = (y) => {
|
|
@@ -6161,15 +6183,15 @@ async function fn(r, e, t, n) {
|
|
|
6161
6183
|
hasMore: _
|
|
6162
6184
|
};
|
|
6163
6185
|
}
|
|
6164
|
-
const
|
|
6186
|
+
const wi = {
|
|
6165
6187
|
batchSize: 1e3,
|
|
6166
6188
|
includeRelated: !0
|
|
6167
6189
|
};
|
|
6168
6190
|
async function yn(r, e, t, n) {
|
|
6169
|
-
const s = { ...
|
|
6191
|
+
const s = { ...wi, ...n }, i = r.rxdb;
|
|
6170
6192
|
i.dispatchEvent(new it("push", e, t, s.includeRelated));
|
|
6171
6193
|
try {
|
|
6172
|
-
const a = await
|
|
6194
|
+
const a = await vi(r, e, t, s);
|
|
6173
6195
|
return i.dispatchEvent(
|
|
6174
6196
|
new at("push", e, t, {
|
|
6175
6197
|
pushed: a.pushed,
|
|
@@ -6181,7 +6203,7 @@ async function yn(r, e, t, n) {
|
|
|
6181
6203
|
throw i.dispatchEvent(new ot("push", e, t, a)), a;
|
|
6182
6204
|
}
|
|
6183
6205
|
}
|
|
6184
|
-
async function
|
|
6206
|
+
async function vi(r, e, t, n) {
|
|
6185
6207
|
const s = r.rxdb.config.entities.find((o) => {
|
|
6186
6208
|
const l = I(o);
|
|
6187
6209
|
return l.namespace === e && l.name === t;
|
|
@@ -6193,10 +6215,10 @@ async function Ei(r, e, t, n) {
|
|
|
6193
6215
|
throw new R(`Cannot push repository ${e}:${t}: syncType is 'none'.`);
|
|
6194
6216
|
if (a === "remote")
|
|
6195
6217
|
throw new R(`Cannot push repository ${e}:${t}: syncType is 'remote' (read-only).`);
|
|
6196
|
-
return n.includeRelated ? await
|
|
6218
|
+
return n.includeRelated ? await Ei(r, e, t, n) : await mn(r, e, t);
|
|
6197
6219
|
}
|
|
6198
|
-
async function
|
|
6199
|
-
const s = r.rxdb.config.entities.map((f) => I(f)), i = ft(s), a =
|
|
6220
|
+
async function Ei(r, e, t, n) {
|
|
6221
|
+
const s = r.rxdb.config.entities.map((f) => I(f)), i = ft(s), a = mi(i), o = `${e}:${t}`;
|
|
6200
6222
|
if (!i.get(o))
|
|
6201
6223
|
throw new R(`Repository ${e}:${t} not found in dependency graph`);
|
|
6202
6224
|
const c = /* @__PURE__ */ new Set([o]), u = (f) => {
|
|
@@ -6214,7 +6236,7 @@ async function Ri(r, e, t, n) {
|
|
|
6214
6236
|
}), h = [], p = /* @__PURE__ */ new Set();
|
|
6215
6237
|
for (const f of d) {
|
|
6216
6238
|
const y = `${f.namespace}:${f.entity}`;
|
|
6217
|
-
if (i.get(y)?.
|
|
6239
|
+
if (i.get(y)?.dependsOn.some((v) => {
|
|
6218
6240
|
const b = `${v.namespace}:${v.entity}`;
|
|
6219
6241
|
return p.has(b);
|
|
6220
6242
|
})) {
|
|
@@ -6274,7 +6296,7 @@ async function mn(r, e, t, n) {
|
|
|
6274
6296
|
}), B = I(E), U = j(B, r.rxdb.config.sync), A = new z();
|
|
6275
6297
|
A.id = l, A.namespace = e, A.entity = t, A.branchId = o.id, A.syncType = U, A.lastPushedChangeId = null, A.lastPushedAt = null, A.lastPulledAt = null, A.lastPullRemoteChangeId = null, A.enabled = !0, A.createdAt = /* @__PURE__ */ new Date(), A.updatedAt = /* @__PURE__ */ new Date(), d = await c.create(A);
|
|
6276
6298
|
}
|
|
6277
|
-
const h = d.lastPushedChangeId, p = a.getRepository(H), m = await
|
|
6299
|
+
const h = d.lastPushedChangeId, p = a.getRepository(H), m = await Ri(p, o.id, h, [t]), f = m.length;
|
|
6278
6300
|
if (f === 0)
|
|
6279
6301
|
return {
|
|
6280
6302
|
repository: { namespace: e, entity: t },
|
|
@@ -6335,7 +6357,7 @@ async function mn(r, e, t, n) {
|
|
|
6335
6357
|
originalCount: f
|
|
6336
6358
|
};
|
|
6337
6359
|
}
|
|
6338
|
-
async function
|
|
6360
|
+
async function Ri(r, e, t, n) {
|
|
6339
6361
|
const s = [
|
|
6340
6362
|
{ field: "branchId", operator: "=", value: e },
|
|
6341
6363
|
{ field: "revertChangeId", operator: "=", value: null },
|
|
@@ -6353,7 +6375,7 @@ async function gn(r, e, t, n) {
|
|
|
6353
6375
|
const s = r.rxdb, i = n?.pull?.includeRelated ?? n?.push?.includeRelated ?? !0;
|
|
6354
6376
|
s.dispatchEvent(new it("sync", e, t, i));
|
|
6355
6377
|
try {
|
|
6356
|
-
const a = await
|
|
6378
|
+
const a = await Ci(r, e, t, n), o = {
|
|
6357
6379
|
pulled: a.pullResult?.pulled ?? 0,
|
|
6358
6380
|
pushed: a.pushResult?.pushed ?? 0,
|
|
6359
6381
|
compacted: (a.pullResult?.compacted ?? 0) + (a.pushResult?.compacted ?? 0),
|
|
@@ -6364,7 +6386,7 @@ async function gn(r, e, t, n) {
|
|
|
6364
6386
|
throw s.dispatchEvent(new ot("sync", e, t, a)), a;
|
|
6365
6387
|
}
|
|
6366
6388
|
}
|
|
6367
|
-
async function
|
|
6389
|
+
async function Ci(r, e, t, n) {
|
|
6368
6390
|
const s = r.rxdb.config.entities.find((d) => {
|
|
6369
6391
|
const h = I(d);
|
|
6370
6392
|
return h.namespace === e && h.name === t;
|
|
@@ -6396,7 +6418,7 @@ async function Ii(r, e, t, n) {
|
|
|
6396
6418
|
pushResult: c
|
|
6397
6419
|
};
|
|
6398
6420
|
}
|
|
6399
|
-
function
|
|
6421
|
+
function Ii(r, e) {
|
|
6400
6422
|
if (e.repositories && e.repositories.length > 0)
|
|
6401
6423
|
return e.repositories;
|
|
6402
6424
|
const t = [];
|
|
@@ -6425,7 +6447,7 @@ async function _n(r, e, t) {
|
|
|
6425
6447
|
};
|
|
6426
6448
|
}
|
|
6427
6449
|
}
|
|
6428
|
-
async function
|
|
6450
|
+
async function Ti(r, e, t) {
|
|
6429
6451
|
const n = [];
|
|
6430
6452
|
for (const s of e) {
|
|
6431
6453
|
const i = await _n(r, s, t);
|
|
@@ -6433,7 +6455,7 @@ async function Ai(r, e, t) {
|
|
|
6433
6455
|
}
|
|
6434
6456
|
return n;
|
|
6435
6457
|
}
|
|
6436
|
-
async function
|
|
6458
|
+
async function Ai(r, e, t, n) {
|
|
6437
6459
|
const s = [];
|
|
6438
6460
|
for (let i = 0; i < e.length; i += n) {
|
|
6439
6461
|
const o = e.slice(i, i + n).map((c) => _n(r, c, t)), l = await Promise.all(o);
|
|
@@ -6441,14 +6463,14 @@ async function Si(r, e, t, n) {
|
|
|
6441
6463
|
}
|
|
6442
6464
|
return s;
|
|
6443
6465
|
}
|
|
6444
|
-
async function
|
|
6445
|
-
const t = Date.now(), n =
|
|
6466
|
+
async function Si(r, e = {}) {
|
|
6467
|
+
const t = Date.now(), n = Ii(r, e), s = {
|
|
6446
6468
|
direction: e.operation,
|
|
6447
6469
|
pull: e.pull,
|
|
6448
6470
|
push: e.push
|
|
6449
6471
|
}, i = e.concurrent ?? !1, a = e.concurrency ?? 3;
|
|
6450
6472
|
let o;
|
|
6451
|
-
i ? o = await
|
|
6473
|
+
i ? o = await Ai(r, n, s, a) : o = await Ti(r, n, s);
|
|
6452
6474
|
const l = o.filter((d) => d.success).length, c = o.filter((d) => !d.success).length, u = Date.now() - t;
|
|
6453
6475
|
return {
|
|
6454
6476
|
succeeded: l,
|
|
@@ -6491,7 +6513,7 @@ async function bn(r, e, t) {
|
|
|
6491
6513
|
hasUpdates: g > 0
|
|
6492
6514
|
};
|
|
6493
6515
|
}
|
|
6494
|
-
async function
|
|
6516
|
+
async function Mi(r, e, t, n) {
|
|
6495
6517
|
const s = r.rxdb, { adapter: i } = await r.getLocalRepositories(), a = s.config.entities.find((f) => {
|
|
6496
6518
|
const y = I(f);
|
|
6497
6519
|
return y.namespace === e && y.name === t;
|
|
@@ -6538,10 +6560,10 @@ async function Oi(r, e, t, n) {
|
|
|
6538
6560
|
function wn(r) {
|
|
6539
6561
|
return {
|
|
6540
6562
|
combinator: r.combinator === "and" ? "or" : "and",
|
|
6541
|
-
rules: r.rules.map((e) => "combinator" in e ? wn(e) :
|
|
6563
|
+
rules: r.rules.map((e) => "combinator" in e ? wn(e) : Oi(e))
|
|
6542
6564
|
};
|
|
6543
6565
|
}
|
|
6544
|
-
function
|
|
6566
|
+
function Oi(r) {
|
|
6545
6567
|
const t = {
|
|
6546
6568
|
"=": "!=",
|
|
6547
6569
|
"!=": "=",
|
|
@@ -6569,7 +6591,7 @@ function xi(r) {
|
|
|
6569
6591
|
operator: t
|
|
6570
6592
|
};
|
|
6571
6593
|
}
|
|
6572
|
-
const
|
|
6594
|
+
const xi = async (r, e, t) => {
|
|
6573
6595
|
const { branchRepository: n, changeRepository: s } = await r.getLocalRepositories();
|
|
6574
6596
|
if ((await n.find({
|
|
6575
6597
|
where: {
|
|
@@ -6596,11 +6618,11 @@ const Ni = async (r, e, t) => {
|
|
|
6596
6618
|
limit: 1
|
|
6597
6619
|
}))[0];
|
|
6598
6620
|
} else
|
|
6599
|
-
a = await r.getCurrentBranch(), a && (o = await
|
|
6621
|
+
a = await r.getCurrentBranch(), a && (o = await Ni(r, a.id));
|
|
6600
6622
|
if (!a) throw new R("Source branch not found");
|
|
6601
6623
|
const l = new K();
|
|
6602
6624
|
return l.id = e, l.activated = !1, l.local = !0, l.remote = !1, l.fromChangeId = o?.id ?? null, l.parentId = a.id, await l.save(), l;
|
|
6603
|
-
},
|
|
6625
|
+
}, Ni = async (r, e) => {
|
|
6604
6626
|
const { changeRepository: t } = await r.getLocalRepositories();
|
|
6605
6627
|
return (await t.find({
|
|
6606
6628
|
where: {
|
|
@@ -6618,7 +6640,7 @@ const Ni = async (r, e, t) => {
|
|
|
6618
6640
|
limit: 1
|
|
6619
6641
|
}))[0];
|
|
6620
6642
|
};
|
|
6621
|
-
async function
|
|
6643
|
+
async function Pi(r, e, t, n, s) {
|
|
6622
6644
|
const { adapter: i } = await r.versionManager.getLocalRepositories(), a = i.getRepository(H), o = [
|
|
6623
6645
|
{ field: "namespace", operator: "=", value: e },
|
|
6624
6646
|
{ field: "entity", operator: "=", value: t },
|
|
@@ -6633,8 +6655,12 @@ async function $i(r, e, t, n, s) {
|
|
|
6633
6655
|
}
|
|
6634
6656
|
})).length;
|
|
6635
6657
|
}
|
|
6636
|
-
async function
|
|
6637
|
-
|
|
6658
|
+
async function $i(r, e, t) {
|
|
6659
|
+
try {
|
|
6660
|
+
return (await bn(r, e, t)).pendingCount;
|
|
6661
|
+
} catch (n) {
|
|
6662
|
+
return console.error("Failed to check repository updates:", n), 0;
|
|
6663
|
+
}
|
|
6638
6664
|
}
|
|
6639
6665
|
async function vn(r, e, t) {
|
|
6640
6666
|
const n = r.config.entities.find((y) => {
|
|
@@ -6648,13 +6674,13 @@ async function vn(r, e, t) {
|
|
|
6648
6674
|
rules: [{ field: "id", operator: "=", value: `${e}:${t}:${o}` }]
|
|
6649
6675
|
}, h = await c.find({ where: d, limit: 1 }), p = h.length > 0 ? h[0] : null;
|
|
6650
6676
|
let m = 0, f = 0;
|
|
6651
|
-
return
|
|
6677
|
+
return pi(s) && (m = await Pi(
|
|
6652
6678
|
r,
|
|
6653
6679
|
e,
|
|
6654
6680
|
t,
|
|
6655
6681
|
o,
|
|
6656
6682
|
p?.lastPushedChangeId ?? null
|
|
6657
|
-
)), dn(s) && (f = await
|
|
6683
|
+
)), dn(s) && (f = await $i(r, e, t)), {
|
|
6658
6684
|
repository: { namespace: e, entity: t },
|
|
6659
6685
|
branchId: o,
|
|
6660
6686
|
syncType: i,
|
|
@@ -6667,7 +6693,7 @@ async function vn(r, e, t) {
|
|
|
6667
6693
|
pullableCount: f
|
|
6668
6694
|
};
|
|
6669
6695
|
}
|
|
6670
|
-
async function
|
|
6696
|
+
async function Bi(r, e) {
|
|
6671
6697
|
const t = r.config.entities, n = [];
|
|
6672
6698
|
for (const i of t) {
|
|
6673
6699
|
const a = I(i), o = a.namespace, l = a.name, c = await vn(r, o, l);
|
|
@@ -6676,7 +6702,7 @@ async function Di(r, e) {
|
|
|
6676
6702
|
let s = n;
|
|
6677
6703
|
return e?.syncType && e.syncType.length > 0 && (s = s.filter((i) => e.syncType.includes(i.syncType))), e?.enabled !== void 0 && (s = s.filter((i) => i.enabled === e.enabled)), e?.hasPendingChanges !== void 0 && (e.hasPendingChanges ? s = s.filter((i) => i.pushableCount > 0 || i.pullableCount > 0) : s = s.filter((i) => i.pushableCount === 0 && i.pullableCount === 0)), s;
|
|
6678
6704
|
}
|
|
6679
|
-
const
|
|
6705
|
+
const Di = (r) => {
|
|
6680
6706
|
const { branches: e, currentBranch: t, nextBranch: n } = r, s = r.currentChangeId ?? t.fromChangeId ?? 0, i = r.nextChangeId ?? n.fromChangeId ?? 0;
|
|
6681
6707
|
if (s === i)
|
|
6682
6708
|
return [];
|
|
@@ -6774,7 +6800,7 @@ const Li = (r) => {
|
|
|
6774
6800
|
}
|
|
6775
6801
|
}
|
|
6776
6802
|
return h;
|
|
6777
|
-
},
|
|
6803
|
+
}, Li = async (r, e) => {
|
|
6778
6804
|
const { branchRepository: t, changeRepository: n } = await r.getLocalRepositories(), s = await t.find({
|
|
6779
6805
|
where: {
|
|
6780
6806
|
combinator: "and",
|
|
@@ -6787,7 +6813,7 @@ const Li = (r) => {
|
|
|
6787
6813
|
if (!a) throw new R(`Branch (${e}) not found`);
|
|
6788
6814
|
if (i.id === a.id)
|
|
6789
6815
|
throw new R("Cannot switch to the same branch");
|
|
6790
|
-
const o = await Nt(n, i.id), l = await Nt(n, a.id), c =
|
|
6816
|
+
const o = await Nt(n, i.id), l = await Nt(n, a.id), c = Di({
|
|
6791
6817
|
branches: s,
|
|
6792
6818
|
currentBranch: i,
|
|
6793
6819
|
currentChangeId: o ? o.id : null,
|
|
@@ -6812,10 +6838,10 @@ const Li = (r) => {
|
|
|
6812
6838
|
};
|
|
6813
6839
|
h.fromChangeId && g < h.fromChangeId && v.where.rules.push({ field: "id", operator: ">", value: h.fromChangeId });
|
|
6814
6840
|
const b = await n.find(v);
|
|
6815
|
-
y ?
|
|
6841
|
+
y ? Ui(b, u) : f && Fi(b, u);
|
|
6816
6842
|
}
|
|
6817
6843
|
return u;
|
|
6818
|
-
},
|
|
6844
|
+
}, Fi = (r, e) => be(r, !0, e), Ui = (r, e) => be(r, !1, e), be = (r, e, t = {
|
|
6819
6845
|
deletes: /* @__PURE__ */ new Map(),
|
|
6820
6846
|
updates: /* @__PURE__ */ new Map(),
|
|
6821
6847
|
inserts: /* @__PURE__ */ new Map()
|
|
@@ -6923,10 +6949,10 @@ function En(r) {
|
|
|
6923
6949
|
), t = [];
|
|
6924
6950
|
return e.insert && t.push(`创建${e.insert}条`), e.update && t.push(`更新${e.update}条`), e.delete && t.push(`删除${e.delete}条`), `事务: ${t.join(", ")}`;
|
|
6925
6951
|
}
|
|
6926
|
-
function
|
|
6952
|
+
function ji(r) {
|
|
6927
6953
|
return r.type === "database" ? "database" : r.type === "repository" ? `${r.namespace}:${r.entity}` : `${r.namespace}:${r.entity}:${r.entityId}`;
|
|
6928
6954
|
}
|
|
6929
|
-
class
|
|
6955
|
+
class Yi {
|
|
6930
6956
|
constructor(e) {
|
|
6931
6957
|
this.rxdb = e;
|
|
6932
6958
|
const t = e.entityManager.getRepository(K).findOne({
|
|
@@ -6940,7 +6966,7 @@ class zi {
|
|
|
6940
6966
|
branch: t
|
|
6941
6967
|
}).pipe(
|
|
6942
6968
|
Ce(({ connected: n, branch: s }) => n && !!s),
|
|
6943
|
-
x(({ branch: n }) => (this.#
|
|
6969
|
+
x(({ branch: n }) => (this.#i || (this.#i = /* @__PURE__ */ new Date()), H.findAll({
|
|
6944
6970
|
where: {
|
|
6945
6971
|
combinator: "and",
|
|
6946
6972
|
rules: [
|
|
@@ -6952,7 +6978,7 @@ class zi {
|
|
|
6952
6978
|
{
|
|
6953
6979
|
field: "createdAt",
|
|
6954
6980
|
operator: ">=",
|
|
6955
|
-
value: this.#
|
|
6981
|
+
value: this.#i
|
|
6956
6982
|
}
|
|
6957
6983
|
]
|
|
6958
6984
|
},
|
|
@@ -6966,7 +6992,7 @@ class zi {
|
|
|
6966
6992
|
P(1)
|
|
6967
6993
|
), this.undoHistories$ = Ne({
|
|
6968
6994
|
histories: this.histories$,
|
|
6969
|
-
syncCleared: this.#
|
|
6995
|
+
syncCleared: this.#s,
|
|
6970
6996
|
trigger: this.#t
|
|
6971
6997
|
// 监听 push/pull 完成事件
|
|
6972
6998
|
}).pipe(
|
|
@@ -7065,14 +7091,14 @@ class zi {
|
|
|
7065
7091
|
* 用于过滤 session 内的变更:只有 createdAt >= firstConnectedAt 的变更才能被 undo
|
|
7066
7092
|
* 这是初始过滤条件,pull/push 后会通过 syncCleared 来清空 undo 历史
|
|
7067
7093
|
*/
|
|
7068
|
-
#
|
|
7094
|
+
#i = null;
|
|
7069
7095
|
/**
|
|
7070
7096
|
* 同步后清空标记
|
|
7071
7097
|
*
|
|
7072
7098
|
* 当 pull/push 有数据变更时设为 true,此时 undoHistories$ 返回空数组
|
|
7073
7099
|
* 当用户执行新操作时自动重置为 false
|
|
7074
7100
|
*/
|
|
7075
|
-
#
|
|
7101
|
+
#s = new J(!1);
|
|
7076
7102
|
/**
|
|
7077
7103
|
* 标记是否正在执行 undo/redo 操作
|
|
7078
7104
|
*/
|
|
@@ -7173,14 +7199,14 @@ class zi {
|
|
|
7173
7199
|
* 当用户执行新操作时,会自动重置 syncCleared 为 false
|
|
7174
7200
|
*/
|
|
7175
7201
|
clearUndoHistory() {
|
|
7176
|
-
this.#
|
|
7202
|
+
this.#s.next(!0), this.clearRedoStack();
|
|
7177
7203
|
}
|
|
7178
7204
|
/**
|
|
7179
7205
|
* 重置 syncCleared 标记(当用户执行新操作时调用)
|
|
7180
7206
|
* @internal
|
|
7181
7207
|
*/
|
|
7182
7208
|
resetSyncCleared() {
|
|
7183
|
-
this.#
|
|
7209
|
+
this.#s.value && this.#s.next(!1);
|
|
7184
7210
|
}
|
|
7185
7211
|
/**
|
|
7186
7212
|
* 检查是否正在执行 undo/redo 或同步操作
|
|
@@ -7322,7 +7348,7 @@ class zi {
|
|
|
7322
7348
|
entity: m.name
|
|
7323
7349
|
};
|
|
7324
7350
|
}
|
|
7325
|
-
const n =
|
|
7351
|
+
const n = ji(t);
|
|
7326
7352
|
if (this.history_cache) {
|
|
7327
7353
|
const m = this.history_cache.get(n);
|
|
7328
7354
|
if (m)
|
|
@@ -7621,7 +7647,7 @@ async function Pt(r, e) {
|
|
|
7621
7647
|
};
|
|
7622
7648
|
return t.dispatchEvent(new zt("pull", u)), u;
|
|
7623
7649
|
} catch (s) {
|
|
7624
|
-
throw t.dispatchEvent(new
|
|
7650
|
+
throw t.dispatchEvent(new kt("pull", s)), s;
|
|
7625
7651
|
}
|
|
7626
7652
|
}
|
|
7627
7653
|
async function $t(r, e) {
|
|
@@ -7649,10 +7675,10 @@ async function $t(r, e) {
|
|
|
7649
7675
|
};
|
|
7650
7676
|
return t.dispatchEvent(new zt("push", u)), u;
|
|
7651
7677
|
} catch (s) {
|
|
7652
|
-
throw t.dispatchEvent(new
|
|
7678
|
+
throw t.dispatchEvent(new kt("push", s)), s;
|
|
7653
7679
|
}
|
|
7654
7680
|
}
|
|
7655
|
-
const
|
|
7681
|
+
const zi = async (r, e) => {
|
|
7656
7682
|
const { branchRepository: t, changeRepository: n, adapter: s } = await r.getLocalRepositories();
|
|
7657
7683
|
if (e === "main")
|
|
7658
7684
|
throw new R("Cannot remove main branch");
|
|
@@ -7691,7 +7717,7 @@ const Wi = async (r, e) => {
|
|
|
7691
7717
|
};
|
|
7692
7718
|
class ki {
|
|
7693
7719
|
constructor(e) {
|
|
7694
|
-
this.rxdb = e, this.historyManager = new
|
|
7720
|
+
this.rxdb = e, this.historyManager = new Yi(this.rxdb);
|
|
7695
7721
|
}
|
|
7696
7722
|
#e = [];
|
|
7697
7723
|
/**
|
|
@@ -7738,14 +7764,14 @@ class ki {
|
|
|
7738
7764
|
* @param fromChangeId 从哪个 changeId 创建新分支
|
|
7739
7765
|
*/
|
|
7740
7766
|
async createBranch(e, t) {
|
|
7741
|
-
return
|
|
7767
|
+
return xi(this, e, t);
|
|
7742
7768
|
}
|
|
7743
7769
|
/**
|
|
7744
7770
|
* 删除分支
|
|
7745
7771
|
* @param branchId 分支 id
|
|
7746
7772
|
*/
|
|
7747
7773
|
async removeBranch(e) {
|
|
7748
|
-
return
|
|
7774
|
+
return zi(this, e);
|
|
7749
7775
|
}
|
|
7750
7776
|
// ============================================
|
|
7751
7777
|
// Pull/Push 同步方法
|
|
@@ -7934,7 +7960,7 @@ class ki {
|
|
|
7934
7960
|
* ```
|
|
7935
7961
|
*/
|
|
7936
7962
|
async cleanupExpired(e, t, n) {
|
|
7937
|
-
return
|
|
7963
|
+
return Mi(this, e, t, n);
|
|
7938
7964
|
}
|
|
7939
7965
|
/**
|
|
7940
7966
|
* Check for remote updates without downloading data (T040, US2)
|
|
@@ -8009,7 +8035,7 @@ class ki {
|
|
|
8009
8035
|
* ```
|
|
8010
8036
|
*/
|
|
8011
8037
|
async getAllRepositorySyncStatus(e) {
|
|
8012
|
-
return
|
|
8038
|
+
return Bi(this.rxdb, e);
|
|
8013
8039
|
}
|
|
8014
8040
|
/**
|
|
8015
8041
|
* Bulk sync multiple repositories
|
|
@@ -8052,7 +8078,7 @@ class ki {
|
|
|
8052
8078
|
* ```
|
|
8053
8079
|
*/
|
|
8054
8080
|
async bulkSync(e) {
|
|
8055
|
-
return
|
|
8081
|
+
return Si(this.rxdb, e);
|
|
8056
8082
|
}
|
|
8057
8083
|
/**
|
|
8058
8084
|
* Get dependency graph for all repositories
|
|
@@ -8116,14 +8142,14 @@ class ki {
|
|
|
8116
8142
|
async switchBranch(e) {
|
|
8117
8143
|
if ((await this.getCurrentBranch())?.id !== e)
|
|
8118
8144
|
try {
|
|
8119
|
-
this.rxdb.dispatchEvent(new
|
|
8120
|
-
const { adapter: n } = await this.getLocalRepositories(), s = await
|
|
8145
|
+
this.rxdb.dispatchEvent(new er(e));
|
|
8146
|
+
const { adapter: n } = await this.getLocalRepositories(), s = await Li(this, e), i = await n.switchBranch({
|
|
8121
8147
|
branchId: e,
|
|
8122
8148
|
actions: s
|
|
8123
8149
|
});
|
|
8124
|
-
return this.historyManager.clearRedoStack(), this.rxdb.dispatchEvent(new
|
|
8150
|
+
return this.historyManager.clearRedoStack(), this.rxdb.dispatchEvent(new tr(e)), i;
|
|
8125
8151
|
} catch (n) {
|
|
8126
|
-
throw this.rxdb.dispatchEvent(new
|
|
8152
|
+
throw this.rxdb.dispatchEvent(new nr(e)), n;
|
|
8127
8153
|
}
|
|
8128
8154
|
}
|
|
8129
8155
|
/**
|
|
@@ -8219,7 +8245,7 @@ class ki {
|
|
|
8219
8245
|
);
|
|
8220
8246
|
}
|
|
8221
8247
|
}
|
|
8222
|
-
class
|
|
8248
|
+
class ga {
|
|
8223
8249
|
#e = new J("");
|
|
8224
8250
|
#n = new J("");
|
|
8225
8251
|
/**
|
|
@@ -8233,11 +8259,11 @@ class _a {
|
|
|
8233
8259
|
/**
|
|
8234
8260
|
* Repository 配置映射表
|
|
8235
8261
|
*/
|
|
8236
|
-
#
|
|
8262
|
+
#i = /* @__PURE__ */ new Map();
|
|
8237
8263
|
/**
|
|
8238
8264
|
* 插件映射表
|
|
8239
8265
|
*/
|
|
8240
|
-
#
|
|
8266
|
+
#s = /* @__PURE__ */ new Map();
|
|
8241
8267
|
/**
|
|
8242
8268
|
* 连接状态 BehaviorSubject
|
|
8243
8269
|
*/
|
|
@@ -8331,7 +8357,7 @@ class _a {
|
|
|
8331
8357
|
* 获取 RxDB 版本号
|
|
8332
8358
|
*/
|
|
8333
8359
|
get version() {
|
|
8334
|
-
return
|
|
8360
|
+
return ui;
|
|
8335
8361
|
}
|
|
8336
8362
|
get config() {
|
|
8337
8363
|
return this.#t;
|
|
@@ -8341,7 +8367,7 @@ class _a {
|
|
|
8341
8367
|
* @param options - RxDB 配置选项
|
|
8342
8368
|
*/
|
|
8343
8369
|
constructor(e) {
|
|
8344
|
-
this.#t = e, this.schemaManager = new
|
|
8370
|
+
this.#t = e, this.schemaManager = new li(this), this.entityManager = new Ys(this), this.versionManager = new ki(this), this.context = { ...this.#t.context }, this.#t.dbName = this.#t.dbName + "@" + this.version.replace(/\./g, "_"), Pn(this.#t), globalThis.rxdb = this;
|
|
8345
8371
|
}
|
|
8346
8372
|
/**
|
|
8347
8373
|
* 初始化 RxDB
|
|
@@ -8360,7 +8386,7 @@ class _a {
|
|
|
8360
8386
|
* @param config - Repository 配置对象
|
|
8361
8387
|
*/
|
|
8362
8388
|
repository(e, t) {
|
|
8363
|
-
return this.#
|
|
8389
|
+
return this.#i.set(e, t), this;
|
|
8364
8390
|
}
|
|
8365
8391
|
/**
|
|
8366
8392
|
* 注册 adapter
|
|
@@ -8378,11 +8404,11 @@ class _a {
|
|
|
8378
8404
|
* @returns 返回 RxDB 实例,支持链式调用
|
|
8379
8405
|
*/
|
|
8380
8406
|
use(e, t) {
|
|
8381
|
-
if (this.#
|
|
8407
|
+
if (this.#s.has(e))
|
|
8382
8408
|
console.warn("plugin already installed");
|
|
8383
8409
|
else {
|
|
8384
8410
|
const n = e(this, t);
|
|
8385
|
-
this.#
|
|
8411
|
+
this.#s.set(e, n);
|
|
8386
8412
|
}
|
|
8387
8413
|
return this;
|
|
8388
8414
|
}
|
|
@@ -8398,7 +8424,7 @@ class _a {
|
|
|
8398
8424
|
const t = this.#f.get(e);
|
|
8399
8425
|
if (!t)
|
|
8400
8426
|
throw new Error(`Adapter "${String(e)}" not found. Please register it first using rxdb.adapter()`);
|
|
8401
|
-
const n = t(this), s =
|
|
8427
|
+
const n = t(this), s = $n(n) ? n : Promise.resolve(n);
|
|
8402
8428
|
return this.#h.set(e, s), s;
|
|
8403
8429
|
}
|
|
8404
8430
|
/**
|
|
@@ -8408,7 +8434,7 @@ class _a {
|
|
|
8408
8434
|
* @returns Repository 配置对象,如果不存在返回 undefined
|
|
8409
8435
|
*/
|
|
8410
8436
|
getRepositoryConfig(e) {
|
|
8411
|
-
return this.#
|
|
8437
|
+
return this.#i.get(e);
|
|
8412
8438
|
}
|
|
8413
8439
|
/**
|
|
8414
8440
|
* 连接适配器
|
|
@@ -8421,7 +8447,7 @@ class _a {
|
|
|
8421
8447
|
const t = (async () => {
|
|
8422
8448
|
this.init();
|
|
8423
8449
|
const n = await this.getAdapter(e);
|
|
8424
|
-
if (await n.connect(),
|
|
8450
|
+
if (await n.connect(), rr(e, this.#t))
|
|
8425
8451
|
if (await n.isTableExisted(se))
|
|
8426
8452
|
await this.#w(n);
|
|
8427
8453
|
else {
|
|
@@ -8467,14 +8493,14 @@ class _a {
|
|
|
8467
8493
|
* @param event - 要派发的事件对象
|
|
8468
8494
|
*/
|
|
8469
8495
|
dispatchEvent(e) {
|
|
8470
|
-
this.#l &&
|
|
8496
|
+
this.#l && sr(e) === !1 ? this.#u.push(e) : this.#g(e.type).forEach((t) => t.call(this, e));
|
|
8471
8497
|
}
|
|
8472
8498
|
/**
|
|
8473
8499
|
* 初始化网关
|
|
8474
8500
|
* 设置统一的多 Tab 通信网关
|
|
8475
8501
|
*/
|
|
8476
8502
|
#y() {
|
|
8477
|
-
this.#c = new
|
|
8503
|
+
this.#c = new zs({
|
|
8478
8504
|
dbName: this.#t.dbName,
|
|
8479
8505
|
clientId: this.#d.clientId
|
|
8480
8506
|
}), this.#c.init(
|
|
@@ -8505,13 +8531,13 @@ class _a {
|
|
|
8505
8531
|
* 安装所有插件
|
|
8506
8532
|
*/
|
|
8507
8533
|
#_() {
|
|
8508
|
-
Array.from(this.#
|
|
8534
|
+
Array.from(this.#s.values()).forEach((e) => e.install());
|
|
8509
8535
|
}
|
|
8510
8536
|
/**
|
|
8511
8537
|
* 销毁所有插件
|
|
8512
8538
|
*/
|
|
8513
8539
|
#b() {
|
|
8514
|
-
Array.from(this.#
|
|
8540
|
+
Array.from(this.#s.values()).forEach((e) => e.destroy());
|
|
8515
8541
|
}
|
|
8516
8542
|
/**
|
|
8517
8543
|
* 获取或创建事件监听器集合
|
|
@@ -8550,7 +8576,7 @@ class _a {
|
|
|
8550
8576
|
});
|
|
8551
8577
|
}
|
|
8552
8578
|
}
|
|
8553
|
-
class
|
|
8579
|
+
class _a {
|
|
8554
8580
|
/**
|
|
8555
8581
|
* 解决单个冲突
|
|
8556
8582
|
*
|
|
@@ -8577,13 +8603,13 @@ class ba {
|
|
|
8577
8603
|
}
|
|
8578
8604
|
}
|
|
8579
8605
|
export {
|
|
8580
|
-
|
|
8581
|
-
|
|
8582
|
-
|
|
8583
|
-
|
|
8584
|
-
|
|
8606
|
+
Gn as CONFLICT_DETECTED_EVENT,
|
|
8607
|
+
Qn as CONFLICT_PENDING_EVENT,
|
|
8608
|
+
sa as ConflictDetectedEvent,
|
|
8609
|
+
ia as ConflictPendingEvent,
|
|
8610
|
+
_r as ENTITY_BASE_METADATA_OPTIONS,
|
|
8585
8611
|
ne as ENTITY_LOCAL_CREATE_EVENT,
|
|
8586
|
-
|
|
8612
|
+
zn as ENTITY_LOCAL_NEW_EVENT,
|
|
8587
8613
|
ce as ENTITY_LOCAL_REMOVE_EVENT,
|
|
8588
8614
|
oe as ENTITY_LOCAL_UPDATE_EVENT,
|
|
8589
8615
|
Ue as ENTITY_REMOTE_CREATE_EVENT,
|
|
@@ -8592,94 +8618,94 @@ export {
|
|
|
8592
8618
|
ct as ENTITY_STATIC_TYPES,
|
|
8593
8619
|
ie as Entity,
|
|
8594
8620
|
Ie as EntityBase,
|
|
8595
|
-
|
|
8596
|
-
|
|
8597
|
-
|
|
8598
|
-
|
|
8599
|
-
|
|
8600
|
-
|
|
8601
|
-
|
|
8602
|
-
|
|
8621
|
+
Gi as EntityLocalCreatedEvent,
|
|
8622
|
+
Zn as EntityLocalNewEvent,
|
|
8623
|
+
Ji as EntityLocalRemovedEvent,
|
|
8624
|
+
Qi as EntityLocalUpdatedEvent,
|
|
8625
|
+
Xi as EntityRemoteCreatedEvent,
|
|
8626
|
+
ea as EntityRemoteRemovedEvent,
|
|
8627
|
+
Zi as EntityRemoteUpdatedEvent,
|
|
8628
|
+
_a as LWWConflictResolver,
|
|
8603
8629
|
et as NetworkOfflineError,
|
|
8604
|
-
|
|
8630
|
+
W as OnDeleteAction,
|
|
8605
8631
|
qt as OnUpdateAction,
|
|
8606
8632
|
C as PropertyType,
|
|
8607
|
-
|
|
8608
|
-
|
|
8609
|
-
|
|
8610
|
-
|
|
8633
|
+
ua as QueryCacheRepository,
|
|
8634
|
+
ys as QueryTask,
|
|
8635
|
+
Vi as REMOTE_CHANGES_PENDING_EVENT,
|
|
8636
|
+
Jn as REPOSITORY_SYNC_BEGIN_EVENT,
|
|
8611
8637
|
jt as REPOSITORY_SYNC_COMPLETE_EVENT,
|
|
8612
|
-
|
|
8638
|
+
Xn as REPOSITORY_SYNC_ERROR_EVENT,
|
|
8613
8639
|
T as RelationKind,
|
|
8614
8640
|
sn as Repository,
|
|
8615
|
-
|
|
8641
|
+
$s as RepositoryBase,
|
|
8616
8642
|
it as RepositorySyncBeginEvent,
|
|
8617
8643
|
at as RepositorySyncCompleteEvent,
|
|
8618
8644
|
ot as RepositorySyncErrorEvent,
|
|
8619
|
-
|
|
8645
|
+
ga as RxDB,
|
|
8620
8646
|
an as RxDBAdapterBase,
|
|
8621
|
-
|
|
8622
|
-
|
|
8647
|
+
da as RxDBAdapterLocalBase,
|
|
8648
|
+
ha as RxDBAdapterRemoteBase,
|
|
8623
8649
|
K as RxDBBranch,
|
|
8624
8650
|
H as RxDBChange,
|
|
8625
8651
|
R as RxDBError,
|
|
8626
8652
|
se as RxDBMigration,
|
|
8627
|
-
|
|
8653
|
+
pa as RxDBPluginBase,
|
|
8628
8654
|
z as RxDBSync,
|
|
8629
8655
|
kn as SWITCH_BRANCH_BEGIN,
|
|
8630
|
-
|
|
8631
|
-
|
|
8632
|
-
|
|
8633
|
-
|
|
8634
|
-
|
|
8635
|
-
|
|
8636
|
-
|
|
8656
|
+
Wn as SWITCH_BRANCH_COMMIT,
|
|
8657
|
+
Kn as SWITCH_BRANCH_ROLLBACK,
|
|
8658
|
+
Hn as SYNC_BEGIN_EVENT,
|
|
8659
|
+
qn as SYNC_COMPLETE_EVENT,
|
|
8660
|
+
Vn as SYNC_ERROR_EVENT,
|
|
8661
|
+
er as SwitchBranchBeginEvent,
|
|
8662
|
+
tr as SwitchBranchCommitEvent,
|
|
8637
8663
|
st as SwitchBranchEventBase,
|
|
8638
|
-
|
|
8664
|
+
nr as SwitchBranchRollbackEvent,
|
|
8639
8665
|
Yt as SyncBeginEvent,
|
|
8640
8666
|
zt as SyncCompleteEvent,
|
|
8641
|
-
|
|
8642
|
-
|
|
8667
|
+
kt as SyncErrorEvent,
|
|
8668
|
+
ms as SyncStatus,
|
|
8643
8669
|
fe as SyncType,
|
|
8644
8670
|
tt as TRANSACTION_BEGIN,
|
|
8645
8671
|
nt as TRANSACTION_COMMIT,
|
|
8646
8672
|
rt as TRANSACTION_ROLLBACK,
|
|
8647
|
-
|
|
8648
|
-
|
|
8649
|
-
|
|
8650
|
-
|
|
8673
|
+
vr as TREE_ADJACENCY_LIST_ENTITY_BASE_OPTIONS,
|
|
8674
|
+
ta as TransactionBeginEvent,
|
|
8675
|
+
na as TransactionCommitEvent,
|
|
8676
|
+
ra as TransactionRollbackEvent,
|
|
8651
8677
|
_t as TreeAdjacencyListEntityBase,
|
|
8652
|
-
|
|
8653
|
-
|
|
8654
|
-
|
|
8678
|
+
yr as TreeEntity,
|
|
8679
|
+
ca as __decorateClass,
|
|
8680
|
+
Mi as cleanupExpired,
|
|
8655
8681
|
un as compactChanges,
|
|
8656
|
-
|
|
8657
|
-
|
|
8658
|
-
|
|
8682
|
+
$r as diffMetadata,
|
|
8683
|
+
cr as fillDefaultValue,
|
|
8684
|
+
lr as fillInitValue,
|
|
8659
8685
|
I as getEntityMetadata,
|
|
8660
8686
|
Pe as getEntityMutations,
|
|
8661
8687
|
O as getEntityStatus,
|
|
8662
|
-
|
|
8663
|
-
|
|
8688
|
+
aa as getEntityType,
|
|
8689
|
+
ur as getNeedRemoveEntities,
|
|
8664
8690
|
gt as getNeedSaveEntities,
|
|
8665
8691
|
Ze as getRxDBChangeKey,
|
|
8666
|
-
|
|
8692
|
+
hi as getSyncConfig,
|
|
8667
8693
|
j as getSyncType,
|
|
8668
|
-
|
|
8669
|
-
|
|
8670
|
-
|
|
8671
|
-
|
|
8694
|
+
ya as getSyncableRepositories,
|
|
8695
|
+
ma as groupBySyncType,
|
|
8696
|
+
la as isEntityInternalName,
|
|
8697
|
+
fi as isNoSync,
|
|
8672
8698
|
Vt as isRuleGroup,
|
|
8673
|
-
|
|
8699
|
+
oa as isRxDBEntity,
|
|
8674
8700
|
dn as needsPull,
|
|
8675
|
-
|
|
8676
|
-
|
|
8677
|
-
|
|
8678
|
-
|
|
8679
|
-
|
|
8701
|
+
pi as needsPush,
|
|
8702
|
+
fa as parseRxDBChangeKey,
|
|
8703
|
+
xr as queryNeedRefreshCreate,
|
|
8704
|
+
Nr as queryNeedRefreshRemove,
|
|
8705
|
+
Pr as queryNeedRefreshUpdate,
|
|
8680
8706
|
M as setSafeObjectKey,
|
|
8681
8707
|
he as setSafeObjectKeyLazyInitOnce,
|
|
8682
|
-
|
|
8683
|
-
|
|
8708
|
+
or as setSafeObjectWritableKey,
|
|
8709
|
+
fr as transitionMetadata,
|
|
8684
8710
|
Ht as uuid
|
|
8685
8711
|
};
|