@aiao/rxdb-adapter-sqlite 0.0.12 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +470 -464
- package/dist/sqlite.utils.d.ts.map +1 -1
- package/dist/table/trigger_sql.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,83 +1,84 @@
|
|
|
1
|
-
import { getEntityMetadata as w, PropertyType as
|
|
2
|
-
import { isString as
|
|
3
|
-
import { wrap as
|
|
4
|
-
import
|
|
5
|
-
import { defer as
|
|
6
|
-
import { Factory as
|
|
7
|
-
const
|
|
1
|
+
import { getEntityMetadata as w, PropertyType as E, RelationKind as A, isRuleGroup as fe, getEntityStatus as q, RepositoryBase as Fe, RxDBChange as F, EntityLocalCreatedEvent as W, EntityLocalRemovedEvent as ie, EntityLocalUpdatedEvent as Y, parseRxDBChangeKey as Z, RxDBBranch as K, getEntityType as ee, TransactionBeginEvent as Be, TransactionRollbackEvent as Ue, TransactionCommitEvent as We, RxDBAdapterLocalBase as Ke, getEntityMutations as pe, uuid as He } from "@aiao/rxdb";
|
|
2
|
+
import { isString as Ve, isNil as Qe, traverseObjectKeys as Ge, EventDispatcher as Je, AsyncQueueExecutor as Te, get as Ye, isFunction as he } from "@aiao/utils";
|
|
3
|
+
import { wrap as me, proxy as Xe } from "comlink";
|
|
4
|
+
import we from "object-hash";
|
|
5
|
+
import { defer as te, of as ne, from as se, map as ze } from "rxjs";
|
|
6
|
+
import { Factory as Ze, SQLITE_ROW as et, SQLITE_UTF8 as Se, SQLITE_DETERMINISTIC as be } from "wa-sqlite";
|
|
7
|
+
const tt = (e) => `SELECT * FROM sqlite_master WHERE type='table' AND name='${e}' limit 1;`, nt = (e) => !!e.sql && (e.results.length === 0 || e.results[0].rows.length === 0), D = "__rowid", st = (e) => {
|
|
8
8
|
switch (e.type) {
|
|
9
|
-
case
|
|
10
|
-
case
|
|
11
|
-
case
|
|
12
|
-
case
|
|
13
|
-
case
|
|
14
|
-
case
|
|
9
|
+
case E.uuid:
|
|
10
|
+
case E.string:
|
|
11
|
+
case E.json:
|
|
12
|
+
case E.keyValue:
|
|
13
|
+
case E.stringArray:
|
|
14
|
+
case E.numberArray:
|
|
15
15
|
return "TEXT";
|
|
16
|
-
case
|
|
16
|
+
case E.number:
|
|
17
17
|
return "REAL";
|
|
18
|
-
case
|
|
19
|
-
case
|
|
18
|
+
case E.integer:
|
|
19
|
+
case E.boolean:
|
|
20
20
|
return "INTEGER";
|
|
21
21
|
default:
|
|
22
22
|
return "TEXT";
|
|
23
23
|
}
|
|
24
|
-
},
|
|
24
|
+
}, H = (e, t) => {
|
|
25
25
|
if (e === null && t.nullable) return null;
|
|
26
26
|
if (e !== void 0)
|
|
27
27
|
switch (t.type) {
|
|
28
|
-
case
|
|
28
|
+
case E.boolean:
|
|
29
29
|
return e ? 1 : 0;
|
|
30
|
-
case
|
|
30
|
+
case E.date:
|
|
31
31
|
return e instanceof Date ? e.toISOString() : e;
|
|
32
|
-
case
|
|
32
|
+
case E.keyValue: {
|
|
33
33
|
if (!e) return null;
|
|
34
34
|
if (t.properties && typeof e == "object" && !Array.isArray(e)) {
|
|
35
35
|
const n = { ...e };
|
|
36
36
|
return t.properties.forEach((s) => {
|
|
37
|
-
s.name in n && (n[s.name] =
|
|
37
|
+
s.name in n && (n[s.name] = H(n[s.name], s));
|
|
38
38
|
}), JSON.stringify(n);
|
|
39
39
|
}
|
|
40
40
|
return JSON.stringify(e);
|
|
41
41
|
}
|
|
42
|
-
case
|
|
43
|
-
case
|
|
44
|
-
case
|
|
42
|
+
case E.stringArray:
|
|
43
|
+
case E.numberArray:
|
|
44
|
+
case E.json:
|
|
45
45
|
return JSON.stringify(e);
|
|
46
46
|
default:
|
|
47
47
|
return e;
|
|
48
48
|
}
|
|
49
|
-
},
|
|
49
|
+
}, k = (e, t) => {
|
|
50
50
|
if (e === null && t.nullable) return null;
|
|
51
51
|
if (e !== void 0)
|
|
52
52
|
switch (t.type) {
|
|
53
|
-
case
|
|
53
|
+
case E.boolean:
|
|
54
54
|
return !!e;
|
|
55
|
-
case
|
|
55
|
+
case E.date:
|
|
56
56
|
return e instanceof Date ? e : typeof e == "string" ? new Date(e) : e;
|
|
57
|
-
case
|
|
57
|
+
case E.keyValue: {
|
|
58
58
|
if (!e) return null;
|
|
59
|
-
const n = JSON.parse(e);
|
|
59
|
+
const n = typeof e == "object" ? e : JSON.parse(e);
|
|
60
60
|
return t.properties && n && typeof n == "object" && t.properties.forEach((s) => {
|
|
61
|
-
s.name in n && (n[s.name] =
|
|
61
|
+
s.name in n && (n[s.name] = k(n[s.name], s));
|
|
62
62
|
}), n;
|
|
63
63
|
}
|
|
64
|
-
case
|
|
65
|
-
case
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
case E.stringArray:
|
|
65
|
+
case E.numberArray:
|
|
66
|
+
return Array.isArray(e) ? e : e ? JSON.parse(e) : null;
|
|
67
|
+
case E.json:
|
|
68
|
+
return e !== null && typeof e == "object" ? e : e ? JSON.parse(e) : null;
|
|
68
69
|
default:
|
|
69
70
|
return e;
|
|
70
71
|
}
|
|
71
|
-
},
|
|
72
|
+
}, P = (e, t) => `${t}$${e}`, rt = (e) => {
|
|
72
73
|
const t = e.indexOf("$");
|
|
73
74
|
return t === -1 ? ["", e] : [e.substring(0, t), e.substring(t + 1)];
|
|
74
|
-
},
|
|
75
|
-
class
|
|
75
|
+
}, b = (e) => P(e.tableName, e.namespace), Ee = (e) => b(w(e)), _e = (e, t) => `idx_${e.name}_${t.name}`;
|
|
76
|
+
class I extends Error {
|
|
76
77
|
constructor(t) {
|
|
77
|
-
super(t), this.name = "RxDBAdapterSqliteError", Object.setPrototypeOf(this,
|
|
78
|
+
super(t), this.name = "RxDBAdapterSqliteError", Object.setPrototypeOf(this, I.prototype);
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
|
-
const
|
|
81
|
+
const ce = (e, t) => {
|
|
81
82
|
const n = {}, s = Object.keys(t), r = e.foreignKeyNames || [], o = e.foreignKeyColumnNames || r;
|
|
82
83
|
for (let i = 0; i < s.length; i++) {
|
|
83
84
|
const c = s[i], a = r.indexOf(c);
|
|
@@ -95,17 +96,17 @@ const oe = (e, t) => {
|
|
|
95
96
|
}
|
|
96
97
|
const u = e.propertyMap.get(c);
|
|
97
98
|
if (u) {
|
|
98
|
-
n[u.columnName] =
|
|
99
|
+
n[u.columnName] = H(t[c], u);
|
|
99
100
|
continue;
|
|
100
101
|
}
|
|
101
102
|
const d = e.columnNameToPropertyName?.get(c);
|
|
102
103
|
if (d) {
|
|
103
104
|
const p = e.propertyMap.get(d);
|
|
104
|
-
p && (n[c] =
|
|
105
|
+
p && (n[c] = H(t[c], p));
|
|
105
106
|
}
|
|
106
107
|
}
|
|
107
108
|
return n;
|
|
108
|
-
},
|
|
109
|
+
}, Ae = (e, t) => {
|
|
109
110
|
const n = {};
|
|
110
111
|
for (const [o, i] of e.propertyMap)
|
|
111
112
|
o in t && (n[i.columnName] = t[o]);
|
|
@@ -115,7 +116,7 @@ const oe = (e, t) => {
|
|
|
115
116
|
i in t && (n[r[o]] = t[i]);
|
|
116
117
|
}
|
|
117
118
|
return n;
|
|
118
|
-
},
|
|
119
|
+
}, ot = (e, t) => {
|
|
119
120
|
const n = {};
|
|
120
121
|
for (const [o, i] of e.propertyMap)
|
|
121
122
|
o in t && i.readonly !== !0 && (n[i.columnName] = t[o]);
|
|
@@ -128,7 +129,7 @@ const oe = (e, t) => {
|
|
|
128
129
|
}
|
|
129
130
|
}
|
|
130
131
|
return n;
|
|
131
|
-
}, R = (e) =>
|
|
132
|
+
}, R = (e) => Ve(e) ? `'${e.replaceAll("'", "''")}'` : Qe(e) ? "NULL" : e, B = (e, t = []) => e.replace(/\?/g, () => R(t.shift())), re = (e, t, n) => {
|
|
132
133
|
const s = {};
|
|
133
134
|
return n.forEach((r, o) => {
|
|
134
135
|
const i = t[o];
|
|
@@ -141,24 +142,24 @@ const oe = (e, t) => {
|
|
|
141
142
|
const u = e.columnNameToPropertyName, f = u?.get(i);
|
|
142
143
|
if (f) {
|
|
143
144
|
const p = e.propertyMap.get(f);
|
|
144
|
-
p ? s[f] =
|
|
145
|
+
p ? s[f] = k(r, p) : console.log(`Property ${f} not found in metadata ${e.name}`);
|
|
145
146
|
return;
|
|
146
147
|
}
|
|
147
148
|
const d = e.computedPropertyMap?.get(i);
|
|
148
149
|
if (d) {
|
|
149
|
-
s[i] =
|
|
150
|
+
s[i] = k(r, d);
|
|
150
151
|
return;
|
|
151
152
|
}
|
|
152
153
|
if (!u) {
|
|
153
154
|
const p = e.propertyMap.get(i);
|
|
154
155
|
if (p) {
|
|
155
|
-
s[i] =
|
|
156
|
+
s[i] = k(r, p);
|
|
156
157
|
return;
|
|
157
158
|
}
|
|
158
159
|
}
|
|
159
160
|
console.log(`Column ${i}=${r} not found in metadata ${e.name}`);
|
|
160
161
|
}), s;
|
|
161
|
-
},
|
|
162
|
+
}, S = "_", at = {
|
|
162
163
|
"=": "=",
|
|
163
164
|
"!=": "!=",
|
|
164
165
|
">": ">",
|
|
@@ -175,16 +176,16 @@ const oe = (e, t) => {
|
|
|
175
176
|
notStartsWith: "NOT LIKE",
|
|
176
177
|
endsWith: "LIKE",
|
|
177
178
|
notEndsWith: "NOT LIKE"
|
|
178
|
-
},
|
|
179
|
+
}, oe = (e, t) => {
|
|
179
180
|
if (t && e.includes(".")) {
|
|
180
181
|
const n = e.split("."), s = t.propertyMap.get(n[0]);
|
|
181
182
|
if (!s) return e;
|
|
182
|
-
if (s.type ===
|
|
183
|
+
if (s.type === E.keyValue)
|
|
183
184
|
return s.columnName;
|
|
184
185
|
for (let o = 0; o < n.length - 1; o++) {
|
|
185
186
|
const i = t.propertyMap.get(n[o]);
|
|
186
187
|
if (!i) return e;
|
|
187
|
-
if (i.type ===
|
|
188
|
+
if (i.type === E.keyValue)
|
|
188
189
|
return i.columnName;
|
|
189
190
|
}
|
|
190
191
|
const r = t.propertyMap.get(n[n.length - 1]);
|
|
@@ -199,23 +200,23 @@ const oe = (e, t) => {
|
|
|
199
200
|
return r[o];
|
|
200
201
|
}
|
|
201
202
|
return e;
|
|
202
|
-
},
|
|
203
|
+
}, ye = (e, t, n) => {
|
|
203
204
|
if (t) return t;
|
|
204
205
|
if (!e.includes(".")) {
|
|
205
|
-
const c =
|
|
206
|
-
return `${
|
|
206
|
+
const c = oe(e, n);
|
|
207
|
+
return `${S}."${c}"`;
|
|
207
208
|
}
|
|
208
|
-
const s = e.lastIndexOf("."), r = e.slice(0, s), o = e.slice(s + 1), i =
|
|
209
|
+
const s = e.lastIndexOf("."), r = e.slice(0, s), o = e.slice(s + 1), i = oe(o, n);
|
|
209
210
|
return `"${r}"."${i}"`;
|
|
210
|
-
},
|
|
211
|
+
}, Re = (e) => {
|
|
211
212
|
const { operator: t, value: n } = e;
|
|
212
213
|
switch (t) {
|
|
213
214
|
case "in":
|
|
214
215
|
case "notIn":
|
|
215
|
-
return
|
|
216
|
+
return ct(n);
|
|
216
217
|
case "between":
|
|
217
218
|
case "notBetween":
|
|
218
|
-
return
|
|
219
|
+
return lt(n);
|
|
219
220
|
case "contains":
|
|
220
221
|
case "notContains":
|
|
221
222
|
return R(`%${n}%`);
|
|
@@ -226,103 +227,103 @@ const oe = (e, t) => {
|
|
|
226
227
|
case "notEndsWith":
|
|
227
228
|
return R(`%${n}`);
|
|
228
229
|
default:
|
|
229
|
-
return
|
|
230
|
+
return ut(n);
|
|
230
231
|
}
|
|
231
|
-
},
|
|
232
|
+
}, it = (e) => at[e] || e, V = (e, t, n) => e.length === 1 ? n.name : `${t}_${n.name}`, ct = (e) => !Array.isArray(e) || !e.length ? "(NULL)" : `(${e.map(R).join(", ")})`, lt = (e) => {
|
|
232
233
|
if (!Array.isArray(e) || e.length < 2) return "";
|
|
233
234
|
const [t, n] = e;
|
|
234
235
|
if (t == null || n == null) return "";
|
|
235
236
|
const s = t instanceof Date ? t.toISOString() : t, r = n instanceof Date ? n.toISOString() : n;
|
|
236
237
|
return `${R(s)} and ${R(r)}`;
|
|
237
|
-
},
|
|
238
|
+
}, ut = (e) => typeof e == "boolean" ? e ? "1" : "0" : typeof e == "string" ? R(e) : typeof e == "number" ? e.toString() : e instanceof Date ? R(e.toISOString()) : R(e), dt = (e, t, n) => {
|
|
238
239
|
const s = e.propertyMap.get(t);
|
|
239
|
-
if (!s || s.type !==
|
|
240
|
+
if (!s || s.type !== E.keyValue || typeof n.value != "object" || Array.isArray(n.value)) return null;
|
|
240
241
|
const r = Object.entries(n.value).filter(([, a]) => a != null);
|
|
241
242
|
if (!r.length) return "";
|
|
242
243
|
const o = n.operator === "notContains" ? "NOT LIKE" : "LIKE", i = n.operator === "contains" ? " OR " : " AND ";
|
|
243
244
|
return `(${r.map(([a, l]) => {
|
|
244
245
|
const u = l instanceof Date ? l.toISOString() : typeof l == "string" ? l : String(l);
|
|
245
|
-
return `json_extract(${
|
|
246
|
+
return `json_extract(${S}."${s.columnName}", '$.${a}') ${o} ${R(`%${u}%`)}`;
|
|
246
247
|
}).join(i)})`;
|
|
247
|
-
},
|
|
248
|
+
}, ft = (e, t, n) => {
|
|
248
249
|
const s = e.propertyMap.get(t);
|
|
249
|
-
if (!s || s.type !==
|
|
250
|
-
const r =
|
|
250
|
+
if (!s || s.type !== E.stringArray && s.type !== E.numberArray) return null;
|
|
251
|
+
const r = Re(n), o = `EXISTS (SELECT 1 FROM json_each(${S}."${s.columnName}") WHERE json_each.value IN ${r})`;
|
|
251
252
|
return n.operator === "notIn" ? `NOT ${o}` : o;
|
|
252
|
-
},
|
|
253
|
+
}, pt = (e, t, n, s, r) => {
|
|
253
254
|
if (n && s && r && (e.operator === "exists" || e.operator === "notExists")) {
|
|
254
|
-
const d =
|
|
255
|
-
const
|
|
256
|
-
return h.propertyMap.forEach((m,
|
|
257
|
-
|
|
258
|
-
}), r(p,
|
|
255
|
+
const d = yt(e, n, s, (p, h) => {
|
|
256
|
+
const _ = /* @__PURE__ */ new Map();
|
|
257
|
+
return h.propertyMap.forEach((m, g) => {
|
|
258
|
+
_.set(g, `"child"."${m.columnName}"`);
|
|
259
|
+
}), r(p, _, h, s);
|
|
259
260
|
});
|
|
260
261
|
if (d !== null) return d;
|
|
261
262
|
}
|
|
262
263
|
if (e.operator === "null" || e.operator === "notNull") {
|
|
263
|
-
const f = String(e.field), d = t.get(f), p =
|
|
264
|
+
const f = String(e.field), d = t.get(f), p = ye(f, d, n);
|
|
264
265
|
return e.operator === "null" ? `${p} IS NULL` : `${p} IS NOT NULL`;
|
|
265
266
|
}
|
|
266
|
-
const o = e.value === null, i = o ? "" :
|
|
267
|
+
const o = e.value === null, i = o ? "" : it(e.operator).toLowerCase(), c = o ? e.operator === "=" ? "IS NULL" : e.operator === "!=" ? "IS NOT NULL" : "" : Re(e);
|
|
267
268
|
if (!c && ["in", "notIn", "between", "notBetween"].includes(e.operator)) return "";
|
|
268
269
|
const a = String(e.field), l = t.get(a);
|
|
269
270
|
if (n && !a.includes(".") && (e.operator === "contains" || e.operator === "notContains")) {
|
|
270
|
-
const f =
|
|
271
|
+
const f = dt(n, a, e);
|
|
271
272
|
if (f !== null) return f;
|
|
272
273
|
}
|
|
273
274
|
if (n && !a.includes(".") && (e.operator === "in" || e.operator === "notIn")) {
|
|
274
|
-
const f =
|
|
275
|
+
const f = ft(n, a, e);
|
|
275
276
|
if (f !== null) return f;
|
|
276
277
|
}
|
|
277
|
-
return `${
|
|
278
|
-
},
|
|
278
|
+
return `${ye(a, l, n)} ${i} ${c}`.replace(/\s+/g, " ").trim();
|
|
279
|
+
}, le = (e) => e === S ? e : `"${e}"`, ht = (e, t, n) => {
|
|
279
280
|
if (e.kind !== A.ONE_TO_MANY)
|
|
280
281
|
throw new Error("_build_one_to_many_exists requires ONE_TO_MANY relation");
|
|
281
|
-
const s =
|
|
282
|
+
const s = P(t.tableName, t.namespace), r = "child", o = t.relations.find((a) => a.name === e.mappedProperty);
|
|
282
283
|
if (!o)
|
|
283
284
|
throw new Error(
|
|
284
285
|
`Cannot find mappedProperty relation "${e.mappedProperty}" in entity "${t.name}"`
|
|
285
286
|
);
|
|
286
287
|
const i = o.columnName;
|
|
287
288
|
let c = `EXISTS (SELECT 1 FROM "${s}" "${r}"`;
|
|
288
|
-
return c += ` WHERE "${r}"."${i}" = ${
|
|
289
|
-
},
|
|
289
|
+
return c += ` WHERE "${r}"."${i}" = ${S}."id"`, n && (c += ` AND ${n}`), c += ")", c;
|
|
290
|
+
}, mt = (e, t, n) => {
|
|
290
291
|
const s = e.columnName;
|
|
291
292
|
if (!n)
|
|
292
|
-
return `${
|
|
293
|
-
const r =
|
|
293
|
+
return `${S}."${s}" IS NOT NULL`;
|
|
294
|
+
const r = P(t.tableName, t.namespace), o = "child";
|
|
294
295
|
let i = `EXISTS (SELECT 1 FROM "${r}" "${o}"`;
|
|
295
|
-
return i += ` WHERE ${
|
|
296
|
-
},
|
|
296
|
+
return i += ` WHERE ${S}."${s}" = "${o}"."id"`, i += ` AND ${n}`, i += ")", i;
|
|
297
|
+
}, Et = (e, t, n, s, r) => {
|
|
297
298
|
const o = s.rxdb.schemaManager.findMappedRelation(e, t);
|
|
298
299
|
if (o?.relation) {
|
|
299
|
-
const i =
|
|
300
|
+
const i = P(n.tableName, n.namespace), c = "child", a = o.relation.columnName;
|
|
300
301
|
let l = `EXISTS (SELECT 1 FROM "${i}" "${c}"`;
|
|
301
|
-
return l += ` WHERE "${c}"."${a}" = ${
|
|
302
|
+
return l += ` WHERE "${c}"."${a}" = ${S}."id"`, r && (l += ` AND ${r}`), l += ")", l;
|
|
302
303
|
} else {
|
|
303
304
|
const i = t.columnName;
|
|
304
305
|
if (!r)
|
|
305
|
-
return `${
|
|
306
|
-
const c =
|
|
306
|
+
return `${S}."${i}" IS NOT NULL`;
|
|
307
|
+
const c = P(n.tableName, n.namespace), a = "child";
|
|
307
308
|
let l = `EXISTS (SELECT 1 FROM "${c}" "${a}"`;
|
|
308
|
-
return l += ` WHERE ${
|
|
309
|
+
return l += ` WHERE ${S}."${i}" = "${a}"."id"`, l += ` AND ${r}`, l += ")", l;
|
|
309
310
|
}
|
|
310
|
-
},
|
|
311
|
-
const r =
|
|
311
|
+
}, _t = (e, t, n, s) => {
|
|
312
|
+
const r = P(n.tableName, n.namespace), o = "child", i = t.junctionEntityType;
|
|
312
313
|
if (!i)
|
|
313
314
|
throw new Error(`MANY_TO_MANY relation "${t.name}" missing junctionEntityType`);
|
|
314
315
|
const c = w(i);
|
|
315
316
|
if (!c)
|
|
316
317
|
throw new Error("Cannot find metadata for junction entity");
|
|
317
|
-
const a =
|
|
318
|
-
(
|
|
318
|
+
const a = P(c.tableName, c.namespace), l = "junction", u = c.relations.find(
|
|
319
|
+
(_) => _.mappedEntity === e.name && _.mappedNamespace === e.namespace
|
|
319
320
|
);
|
|
320
321
|
if (!u)
|
|
321
322
|
throw new Error(
|
|
322
323
|
`Cannot find relation in junction entity ${c.name} pointing to ${e.name}`
|
|
323
324
|
);
|
|
324
325
|
const f = c.relations.find(
|
|
325
|
-
(
|
|
326
|
+
(_) => _.mappedEntity === n.name && _.mappedNamespace === n.namespace
|
|
326
327
|
);
|
|
327
328
|
if (!f)
|
|
328
329
|
throw new Error(
|
|
@@ -330,8 +331,8 @@ const oe = (e, t) => {
|
|
|
330
331
|
);
|
|
331
332
|
const d = u.columnName, p = f.columnName;
|
|
332
333
|
let h = `EXISTS (SELECT 1 FROM "${r}" "${o}"`;
|
|
333
|
-
return h += ` INNER JOIN "${a}" "${l}"`, h += ` ON "${l}"."${p}" = "${o}"."id"`, h += ` WHERE "${l}"."${d}" = ${
|
|
334
|
-
},
|
|
334
|
+
return h += ` INNER JOIN "${a}" "${l}"`, h += ` ON "${l}"."${p}" = "${o}"."id"`, h += ` WHERE "${l}"."${d}" = ${S}."id"`, s && (h += ` AND ${s}`), h += ")", h;
|
|
335
|
+
}, yt = (e, t, n, s) => {
|
|
335
336
|
if (e.operator !== "exists" && e.operator !== "notExists")
|
|
336
337
|
return null;
|
|
337
338
|
const r = t.relationMap.get(e.field);
|
|
@@ -347,25 +348,25 @@ const oe = (e, t) => {
|
|
|
347
348
|
let c;
|
|
348
349
|
switch (r.kind) {
|
|
349
350
|
case A.ONE_TO_MANY:
|
|
350
|
-
c =
|
|
351
|
+
c = ht(r, o, i);
|
|
351
352
|
break;
|
|
352
353
|
case A.MANY_TO_ONE:
|
|
353
|
-
c =
|
|
354
|
+
c = mt(r, o, i);
|
|
354
355
|
break;
|
|
355
356
|
case A.ONE_TO_ONE:
|
|
356
|
-
c =
|
|
357
|
+
c = Et(t, r, o, n, i);
|
|
357
358
|
break;
|
|
358
359
|
case A.MANY_TO_MANY:
|
|
359
|
-
c =
|
|
360
|
+
c = _t(t, r, o, i);
|
|
360
361
|
break;
|
|
361
362
|
}
|
|
362
363
|
return e.operator === "notExists" ? `NOT ${c}` : c;
|
|
363
|
-
},
|
|
364
|
+
}, Q = (e, t) => {
|
|
364
365
|
if (e.relationAliasMap.has(t))
|
|
365
366
|
return e.relationAliasMap.get(t);
|
|
366
|
-
const n = t.includes("_") ? t : t.split("_")[0], s =
|
|
367
|
+
const n = t.includes("_") ? t : t.split("_")[0], s = Oe(e, n);
|
|
367
368
|
return e.relationAliasMap.set(t, s), s;
|
|
368
|
-
},
|
|
369
|
+
}, gt = (e, t, n, s) => {
|
|
369
370
|
const r = n.slice(0, s);
|
|
370
371
|
let o = t;
|
|
371
372
|
const i = [];
|
|
@@ -376,22 +377,22 @@ const oe = (e, t) => {
|
|
|
376
377
|
i.push({ metadata: o, relation: a }), o = e.rxdb.schemaManager.getEntityMetadata(a.mappedEntity, a.mappedNamespace);
|
|
377
378
|
}
|
|
378
379
|
return { metaWalker: o, relPairs: i };
|
|
379
|
-
},
|
|
380
|
+
}, Nt = (e, t, n, s, r) => {
|
|
380
381
|
for (let o = r.length - 1; o > 0; o--) {
|
|
381
382
|
const i = r.slice(o);
|
|
382
383
|
if (i.length === 0) continue;
|
|
383
|
-
const { metaWalker: c, relPairs: a } =
|
|
384
|
+
const { metaWalker: c, relPairs: a } = gt(e, n, r, o);
|
|
384
385
|
if (!c || a.length === 0) continue;
|
|
385
386
|
const l = i[0], u = i.slice(1).join("."), f = c.propertyMap.get(l);
|
|
386
|
-
if (f && f.type ===
|
|
387
|
+
if (f && f.type === E.keyValue) {
|
|
387
388
|
const d = r.slice(0, o).join(".");
|
|
388
|
-
|
|
389
|
-
const p = a[a.length - 1].relation, h =
|
|
390
|
-
return t.fieldAliasMap.set(s, `json_extract("${
|
|
389
|
+
Ie(e, t, a, d);
|
|
390
|
+
const p = a[a.length - 1].relation, h = V(a, d, p), _ = Q(t, h), m = u ? `$.${u}` : "$";
|
|
391
|
+
return t.fieldAliasMap.set(s, `json_extract("${_}"."${f.columnName}", '${m}')`), !0;
|
|
391
392
|
}
|
|
392
393
|
}
|
|
393
394
|
return !1;
|
|
394
|
-
},
|
|
395
|
+
}, Ie = (e, t, n, s) => {
|
|
395
396
|
n.forEach(({ metadata: r, relation: o }, i) => {
|
|
396
397
|
let c = e.rxdb.schemaManager.findMappedRelation(r, o);
|
|
397
398
|
if (!c)
|
|
@@ -399,16 +400,16 @@ const oe = (e, t) => {
|
|
|
399
400
|
const f = r.relationMap.get(o.mappedProperty);
|
|
400
401
|
f && (c = { metadata: r, relation: f });
|
|
401
402
|
} else (o.kind === A.MANY_TO_ONE || o.kind === A.ONE_TO_ONE) && (c = { metadata: r, relation: o });
|
|
402
|
-
if (!c) throw new
|
|
403
|
-
const a =
|
|
404
|
-
let u =
|
|
403
|
+
if (!c) throw new I("mappedRelation not found");
|
|
404
|
+
const a = V(n, s, o), l = Q(t, a);
|
|
405
|
+
let u = S;
|
|
405
406
|
if (i > 0) {
|
|
406
|
-
const f = n[i - 1], d =
|
|
407
|
-
u =
|
|
407
|
+
const f = n[i - 1], d = V(n, s, f.relation);
|
|
408
|
+
u = Q(t, d);
|
|
408
409
|
}
|
|
409
410
|
switch (o.kind) {
|
|
410
411
|
case A.ONE_TO_MANY:
|
|
411
|
-
|
|
412
|
+
$t(
|
|
412
413
|
t,
|
|
413
414
|
c,
|
|
414
415
|
l,
|
|
@@ -417,7 +418,7 @@ const oe = (e, t) => {
|
|
|
417
418
|
break;
|
|
418
419
|
case A.ONE_TO_ONE:
|
|
419
420
|
case A.MANY_TO_ONE:
|
|
420
|
-
|
|
421
|
+
Tt(
|
|
421
422
|
t,
|
|
422
423
|
c,
|
|
423
424
|
l,
|
|
@@ -426,7 +427,7 @@ const oe = (e, t) => {
|
|
|
426
427
|
);
|
|
427
428
|
break;
|
|
428
429
|
case A.MANY_TO_MANY:
|
|
429
|
-
|
|
430
|
+
wt(
|
|
430
431
|
e,
|
|
431
432
|
t,
|
|
432
433
|
c,
|
|
@@ -437,84 +438,84 @@ const oe = (e, t) => {
|
|
|
437
438
|
break;
|
|
438
439
|
}
|
|
439
440
|
});
|
|
440
|
-
},
|
|
441
|
-
const r =
|
|
441
|
+
}, $t = (e, t, n, s) => {
|
|
442
|
+
const r = G(e, t.metadata), o = `"${n}".${t.relation.columnName} = ${le(s)}.id`;
|
|
442
443
|
r.find((c) => c.joinTableName === n && c.on === o) || r.push({
|
|
443
444
|
joinTableName: n,
|
|
444
445
|
on: o
|
|
445
446
|
});
|
|
446
|
-
},
|
|
447
|
-
const o =
|
|
447
|
+
}, Tt = (e, t, n, s, r) => {
|
|
448
|
+
const o = G(e, t.metadata), i = `"${n}".id = ${le(s)}.${r.columnName}`;
|
|
448
449
|
o.find((a) => a.joinTableName === n && a.on === i) || o.push({
|
|
449
450
|
joinTableName: n,
|
|
450
451
|
on: i
|
|
451
452
|
});
|
|
452
|
-
},
|
|
453
|
-
const i = w(o.junctionEntityType), c =
|
|
453
|
+
}, wt = (e, t, n, s, r, o) => {
|
|
454
|
+
const i = w(o.junctionEntityType), c = G(t, i), a = Oe(t, `${o.name}_m_n`), l = `"${a}".${n.relation.columnName} = ${le(r)}.id`;
|
|
454
455
|
c.find(
|
|
455
456
|
(h) => h.joinTableName === a && h.on === l
|
|
456
457
|
) || c.push({
|
|
457
458
|
joinTableName: a,
|
|
458
459
|
on: l
|
|
459
460
|
});
|
|
460
|
-
const f =
|
|
461
|
+
const f = G(t, n.metadata), d = `"${s}".id = "${a}".${o.columnName}`;
|
|
461
462
|
f.find((h) => h.joinTableName === s && h.on === d) || f.push({
|
|
462
463
|
joinTableName: s,
|
|
463
464
|
on: d
|
|
464
465
|
});
|
|
465
|
-
},
|
|
466
|
+
}, G = (e, t) => (e.joinMap.has(t) || e.joinMap.set(t, []), e.joinMap.get(t)), Oe = (e, t) => {
|
|
466
467
|
let n = t, s = 1;
|
|
467
468
|
for (; e.usedAliases.has(n); )
|
|
468
469
|
n = `${t}_${s}`, s++;
|
|
469
470
|
return e.usedAliases.add(n), n;
|
|
470
|
-
},
|
|
471
|
+
}, St = (e, t) => {
|
|
471
472
|
if (e?.length)
|
|
472
473
|
return e.map((n) => {
|
|
473
|
-
const s =
|
|
474
|
-
return `${
|
|
474
|
+
const s = oe(n.field, t);
|
|
475
|
+
return `${S}."${s}" ${n.sort}`;
|
|
475
476
|
}).join(", ");
|
|
476
|
-
},
|
|
477
|
+
}, U = (e, t = /* @__PURE__ */ new Map(), n, s) => {
|
|
477
478
|
if (!e?.rules) return "";
|
|
478
479
|
const r = e.rules.map(
|
|
479
|
-
(o) =>
|
|
480
|
+
(o) => fe(o) ? U(o, t, n, s) : pt(o, t, n, s, U)
|
|
480
481
|
).filter(Boolean);
|
|
481
|
-
return r.length ? r.length === 1 ? r[0] : `(${r.join(
|
|
482
|
-
},
|
|
482
|
+
return r.length ? r.length === 1 ? r[0] : `(${r.join(fe(e) ? ` ${e.combinator} ` : " ")})` : "";
|
|
483
|
+
}, Me = (e) => {
|
|
483
484
|
const { tableName: t, where: n, limit: s, offset: r, orderBy: o, join: i, hasJoin: c, metadata: a } = e;
|
|
484
|
-
let l = `${
|
|
485
|
+
let l = `${S}.rowid as ${D}, ${S}.*`;
|
|
485
486
|
if (a.features?.tree?.hasChildren && a.features?.tree?.type === "adjacency-list") {
|
|
486
487
|
const d = a.relationMap.get("parent").columnName;
|
|
487
|
-
l += `, EXISTS(SELECT 1 FROM "${t}" __sub WHERE __sub."${d}" = ${
|
|
488
|
+
l += `, EXISTS(SELECT 1 FROM "${t}" __sub WHERE __sub."${d}" = ${S}."id") AS "hasChildren"`;
|
|
488
489
|
}
|
|
489
|
-
const u = [`SELECT ${c ? "DISTINCT " : ""}${l} FROM "${t}" ${
|
|
490
|
+
const u = [`SELECT ${c ? "DISTINCT " : ""}${l} FROM "${t}" ${S}`];
|
|
490
491
|
return i && u.push(i), n && u.push(` WHERE ${n}`), o && u.push(` ORDER BY ${o}`), s && u.push(` LIMIT ${s}`), r && u.push(` OFFSET ${r}`), u.join("") + ";";
|
|
491
|
-
},
|
|
492
|
+
}, Ce = (e, t, n) => {
|
|
492
493
|
const s = {
|
|
493
494
|
joinMap: /* @__PURE__ */ new Map(),
|
|
494
495
|
usedAliases: /* @__PURE__ */ new Set(),
|
|
495
496
|
fieldAliasMap: /* @__PURE__ */ new Map(),
|
|
496
497
|
relationAliasMap: /* @__PURE__ */ new Map()
|
|
497
498
|
};
|
|
498
|
-
|
|
499
|
+
Ge(n, (o, i, c) => {
|
|
499
500
|
const a = i;
|
|
500
|
-
o !== "field" || !a.includes(".") ||
|
|
501
|
+
o !== "field" || !a.includes(".") || At(e, s, t, a, c);
|
|
501
502
|
});
|
|
502
503
|
const r = [];
|
|
503
504
|
for (const [o, i] of s.joinMap.entries()) {
|
|
504
|
-
const c =
|
|
505
|
+
const c = b(o);
|
|
505
506
|
for (const a of i)
|
|
506
507
|
r.push(` LEFT JOIN "${c}" "${a.joinTableName}" ON ${a.on}`);
|
|
507
508
|
}
|
|
508
509
|
return { joinSQL: r.join(""), fieldAliasMap: s.fieldAliasMap };
|
|
509
|
-
},
|
|
510
|
+
}, bt = (e, t, n, s) => {
|
|
510
511
|
if (s.length <= 1) return !1;
|
|
511
512
|
const [r, ...o] = s, i = t.propertyMap.get(r);
|
|
512
|
-
if (i && i.type ===
|
|
513
|
+
if (i && i.type === E.keyValue && o.length > 0) {
|
|
513
514
|
const c = o.join(".");
|
|
514
|
-
return e.fieldAliasMap.set(n, `json_extract(${
|
|
515
|
+
return e.fieldAliasMap.set(n, `json_extract(${S}."${i.columnName}", '$.${c}')`), !0;
|
|
515
516
|
}
|
|
516
517
|
return !1;
|
|
517
|
-
},
|
|
518
|
+
}, At = (e, t, n, s, r) => {
|
|
518
519
|
const o = s.split(".");
|
|
519
520
|
try {
|
|
520
521
|
const i = e.rxdb.schemaManager.getFieldRelations(n, s);
|
|
@@ -523,103 +524,103 @@ const oe = (e, t) => {
|
|
|
523
524
|
return;
|
|
524
525
|
}
|
|
525
526
|
const c = s.replace(`.${i.propertyName}`, "");
|
|
526
|
-
|
|
527
|
-
const a = i.relations[i.relations.length - 1], l =
|
|
527
|
+
Ie(e, t, i.relations, c);
|
|
528
|
+
const a = i.relations[i.relations.length - 1], l = V(i.relations, c, a.relation), u = Q(t, l);
|
|
528
529
|
t.fieldAliasMap.set(s, `"${u}"."${i.property.columnName}"`);
|
|
529
530
|
return;
|
|
530
531
|
} catch {
|
|
531
532
|
}
|
|
532
|
-
|
|
533
|
-
},
|
|
534
|
-
const n =
|
|
533
|
+
bt(t, n, s, o) || Nt(e, t, n, s, o);
|
|
534
|
+
}, Rt = (e, t) => {
|
|
535
|
+
const n = b(e), s = [t.id];
|
|
535
536
|
return {
|
|
536
537
|
sql: `DELETE FROM "${n}" WHERE id = ?;`,
|
|
537
538
|
params: s
|
|
538
539
|
};
|
|
539
|
-
},
|
|
540
|
-
const s =
|
|
540
|
+
}, Le = (e, t, n) => {
|
|
541
|
+
const s = b(e), r = Ae(e, t);
|
|
541
542
|
n?.userId && (e.propertyMap.has("createdBy") && (r.createdBy = n.userId), e.propertyMap.has("updatedBy") && (r.updatedBy = n.userId));
|
|
542
543
|
const o = /* @__PURE__ */ new Date();
|
|
543
544
|
e.propertyMap.has("createdAt") && r.createdAt === void 0 && (r.createdAt = n?.createdAt ?? o), e.propertyMap.has("updatedAt") && r.updatedAt === void 0 && (r.updatedAt = n?.updatedAt ?? o);
|
|
544
|
-
const i =
|
|
545
|
+
const i = ce(e, r), c = Object.keys(i), a = Array(c.length).fill("?").join(","), l = Object.values(i);
|
|
545
546
|
let f = `${n?.useReplace ? "INSERT OR REPLACE" : "INSERT"} INTO "${s}" (${c.join(",")}) VALUES (${a})`;
|
|
546
|
-
return n?.returning !== !1 ? f += ` RETURNING rowid as ${
|
|
547
|
+
return n?.returning !== !1 ? f += ` RETURNING rowid as ${D}, *;` : f += ";", {
|
|
547
548
|
sql: f,
|
|
548
549
|
params: l
|
|
549
550
|
};
|
|
550
|
-
},
|
|
551
|
-
const r =
|
|
551
|
+
}, ue = (e, t, n, s) => {
|
|
552
|
+
const r = ot(e, n);
|
|
552
553
|
e.propertyMap.has("updatedAt") && (r.updatedAt = s?.updatedAt ?? /* @__PURE__ */ new Date()), s?.userId && e.propertyMap.has("updatedBy") && (r.updatedBy = s.userId);
|
|
553
|
-
const o =
|
|
554
|
+
const o = ce(e, r), i = Object.keys(o).map((d) => `${d} = ?`).join(","), c = [...Object.values(o)], a = b(e), l = Array.isArray(t), u = l ? t : [t];
|
|
554
555
|
let f = `UPDATE "${a}" SET ${i} WHERE id `;
|
|
555
|
-
return l ? f += `in (${u.map((d) => R(d.id)).join(",")})` : (c.push(t.id), f += "= ?"), s?.returning !== !1 ? f += ` RETURNING rowid as ${
|
|
556
|
+
return l ? f += `in (${u.map((d) => R(d.id)).join(",")})` : (c.push(t.id), f += "= ?"), s?.returning !== !1 ? f += ` RETURNING rowid as ${D}, *;` : f += ";", {
|
|
556
557
|
sql: f,
|
|
557
558
|
params: c
|
|
558
559
|
};
|
|
559
|
-
},
|
|
560
|
+
}, It = (e, t, n) => {
|
|
560
561
|
if (n.groupBy)
|
|
561
|
-
throw new
|
|
562
|
-
const { joinSQL: s, fieldAliasMap: r } =
|
|
562
|
+
throw new I("groupBy not supported yet");
|
|
563
|
+
const { joinSQL: s, fieldAliasMap: r } = Ce(e, t, n.where), o = b(t), i = U(n.where, r, t, e), c = [`SELECT COUNT(${S}.rowid) AS count FROM "${o}" ${S}`];
|
|
563
564
|
return s && c.push(s), i && c.push(` WHERE ${i}`), { sql: c.join("") };
|
|
564
|
-
},
|
|
565
|
-
const { joinSQL: s, fieldAliasMap: r } =
|
|
566
|
-
return { sql:
|
|
567
|
-
tableName:
|
|
568
|
-
where:
|
|
569
|
-
orderBy:
|
|
565
|
+
}, ae = (e, t, n) => {
|
|
566
|
+
const { joinSQL: s, fieldAliasMap: r } = Ce(e, t, n.where);
|
|
567
|
+
return { sql: Me({
|
|
568
|
+
tableName: b(t),
|
|
569
|
+
where: U(n.where, r, t, e),
|
|
570
|
+
orderBy: St(n.orderBy, t),
|
|
570
571
|
join: s,
|
|
571
572
|
hasJoin: !!s,
|
|
572
573
|
metadata: t,
|
|
573
574
|
limit: n.limit,
|
|
574
575
|
offset: n.offset
|
|
575
576
|
}) };
|
|
576
|
-
},
|
|
577
|
-
tableName:
|
|
578
|
-
where: `${
|
|
577
|
+
}, Ot = (e, t) => ({ sql: Me({
|
|
578
|
+
tableName: b(e),
|
|
579
|
+
where: `${D} IN (${t.join(",")})`,
|
|
579
580
|
metadata: e
|
|
580
|
-
}) }),
|
|
581
|
+
}) }), J = (e, t, n, s = !1) => {
|
|
581
582
|
const r = [], o = w(t), i = e.rxdb.entityManager;
|
|
582
583
|
return n.results.forEach(({ columns: c, rows: a }) => {
|
|
583
|
-
const l = c.findIndex((f) => f === "id"), u = c.findIndex((f) => f ===
|
|
584
|
+
const l = c.findIndex((f) => f === "id"), u = c.findIndex((f) => f === D);
|
|
584
585
|
a.forEach((f) => {
|
|
585
586
|
const d = f[l];
|
|
586
587
|
let p;
|
|
587
588
|
if (e.rxdb.entityManager.hasEntityRef(t, d)) {
|
|
588
589
|
p = i.getEntityRef(t, d);
|
|
589
|
-
const m =
|
|
590
|
-
if (o.computedPropertyMap.forEach((
|
|
591
|
-
|
|
590
|
+
const m = re(o, c, f);
|
|
591
|
+
if (o.computedPropertyMap.forEach((g, N) => {
|
|
592
|
+
N in m && (p[N] = m[N]);
|
|
592
593
|
}), s) {
|
|
593
|
-
const
|
|
594
|
-
|
|
594
|
+
const g = q(p);
|
|
595
|
+
g.origin = { ...m }, Object.assign(p, m);
|
|
595
596
|
}
|
|
596
597
|
} else {
|
|
597
|
-
const m =
|
|
598
|
+
const m = re(o, c, f);
|
|
598
599
|
p = i.createEntityRef(t, m);
|
|
599
600
|
}
|
|
600
601
|
r.push(p);
|
|
601
|
-
const
|
|
602
|
-
if (
|
|
602
|
+
const _ = q(p);
|
|
603
|
+
if (_.local = !0, _.modified = !1, u !== -1) {
|
|
603
604
|
const m = BigInt(f[u]);
|
|
604
605
|
e.cacheRowIdEntity(m, p);
|
|
605
606
|
}
|
|
606
607
|
});
|
|
607
608
|
}), r;
|
|
608
|
-
},
|
|
609
|
+
}, Mt = (e, t, n) => {
|
|
609
610
|
n.forEach((s) => {
|
|
610
611
|
if (e.rxdb.entityManager.hasEntityRef(t, s)) {
|
|
611
|
-
const r = e.rxdb.entityManager.getEntityRef(t, s), o =
|
|
612
|
+
const r = e.rxdb.entityManager.getEntityRef(t, s), o = q(r);
|
|
612
613
|
o.local = !1, o.removed = !0, o.modified = !1;
|
|
613
614
|
}
|
|
614
615
|
});
|
|
615
616
|
};
|
|
616
|
-
class
|
|
617
|
+
class Ct extends Fe {
|
|
617
618
|
constructor(t, n) {
|
|
618
619
|
super(t.rxdb, n), this.adapter = t, this.metadata = w(n);
|
|
619
620
|
}
|
|
620
621
|
metadata;
|
|
621
622
|
async findByRowIds(t) {
|
|
622
|
-
const { sql: n, params: s } =
|
|
623
|
+
const { sql: n, params: s } = Ot(this.metadata, t), r = await this.adapter.query(n, s);
|
|
623
624
|
return this.addQueryCache(r);
|
|
624
625
|
}
|
|
625
626
|
/**
|
|
@@ -628,10 +629,10 @@ class It extends De {
|
|
|
628
629
|
* @param forcedUpdate 强制刷新,在数据有的情况下也会更新数据,在修改数据的情况下需要
|
|
629
630
|
*/
|
|
630
631
|
addQueryCache(t, n = !1) {
|
|
631
|
-
return
|
|
632
|
+
return J(this.adapter, this.EntityType, t, n);
|
|
632
633
|
}
|
|
633
634
|
}
|
|
634
|
-
class
|
|
635
|
+
class je extends Ct {
|
|
635
636
|
async get(t) {
|
|
636
637
|
const n = {
|
|
637
638
|
where: {
|
|
@@ -639,42 +640,42 @@ class Ce extends It {
|
|
|
639
640
|
rules: [{ field: "id", operator: "=", value: t }]
|
|
640
641
|
}
|
|
641
642
|
}, s = await this.findOne(n);
|
|
642
|
-
if (!s) throw new
|
|
643
|
+
if (!s) throw new I(`Entity (${t}) not found`);
|
|
643
644
|
return s;
|
|
644
645
|
}
|
|
645
646
|
async findOne(t) {
|
|
646
647
|
return (await this.find({ ...t, limit: 1, offset: 0 }))[0];
|
|
647
648
|
}
|
|
648
649
|
async find(t) {
|
|
649
|
-
const { sql: n, params: s } =
|
|
650
|
+
const { sql: n, params: s } = ae(this.adapter, this.metadata, t), r = await this.adapter.query(n, s);
|
|
650
651
|
return this.addQueryCache(r);
|
|
651
652
|
}
|
|
652
653
|
async count(t) {
|
|
653
|
-
const { sql: n, params: s } =
|
|
654
|
+
const { sql: n, params: s } = It(this.adapter, this.metadata, t);
|
|
654
655
|
return (await this.adapter.query(n, s)).results[0].rows[0][0];
|
|
655
656
|
}
|
|
656
657
|
async create(t) {
|
|
657
|
-
const { sql: n, params: s } =
|
|
658
|
+
const { sql: n, params: s } = Le(this.metadata, t, this.rxdb.context), r = await this.adapter.query(n, s);
|
|
658
659
|
return this.addQueryCache(r, !0), t;
|
|
659
660
|
}
|
|
660
661
|
async update(t, n) {
|
|
661
|
-
const { sql: s, params: r } =
|
|
662
|
+
const { sql: s, params: r } = ue(this.metadata, t, n, this.rxdb.context), o = await this.adapter.query(s, r);
|
|
662
663
|
return this.addQueryCache(o, !0), t;
|
|
663
664
|
}
|
|
664
665
|
async remove(t) {
|
|
665
|
-
const n =
|
|
666
|
+
const n = q(t), s = () => {
|
|
666
667
|
n.origin = structuredClone({ ...t }), n.modified = !1, n.removed = !0;
|
|
667
668
|
};
|
|
668
669
|
if (n.local === !0) {
|
|
669
|
-
const { sql: o, params: i } =
|
|
670
|
+
const { sql: o, params: i } = Rt(this.metadata, t);
|
|
670
671
|
return await this.adapter.query(o, i), s(), t;
|
|
671
672
|
}
|
|
672
673
|
const r = w(t);
|
|
673
|
-
throw new
|
|
674
|
+
throw new I(`Remove Error${r.name}(${t.id}) not saved local.`);
|
|
674
675
|
}
|
|
675
676
|
}
|
|
676
|
-
var
|
|
677
|
-
const
|
|
677
|
+
var v = /* @__PURE__ */ ((e) => (e[e.SQLITE_DELETE = 9] = "SQLITE_DELETE", e[e.SQLITE_INSERT = 18] = "SQLITE_INSERT", e[e.SQLITE_UPDATE = 23] = "SQLITE_UPDATE", e))(v || {});
|
|
678
|
+
const Lt = (e) => {
|
|
678
679
|
switch (e) {
|
|
679
680
|
case 18:
|
|
680
681
|
return "INSERT";
|
|
@@ -683,7 +684,7 @@ const Ot = (e) => {
|
|
|
683
684
|
case 23:
|
|
684
685
|
return "UPDATE";
|
|
685
686
|
}
|
|
686
|
-
},
|
|
687
|
+
}, jt = "sqlite", xt = () => import("wa-sqlite/dist/wa-sqlite-async.mjs").then((e) => e.default), Dt = () => import("wa-sqlite/dist/wa-sqlite.mjs").then((e) => e.default), qt = [
|
|
687
688
|
{
|
|
688
689
|
name: "MemoryVFS",
|
|
689
690
|
vfsModule: () => import("wa-sqlite/src/examples/MemoryVFS.js").then((e) => e.MemoryVFS),
|
|
@@ -767,28 +768,28 @@ const Ot = (e) => {
|
|
|
767
768
|
jsContext: !1,
|
|
768
769
|
multipleConnections: !0
|
|
769
770
|
}
|
|
770
|
-
],
|
|
771
|
-
const t =
|
|
772
|
-
if (!t) throw new
|
|
771
|
+
], xe = (e) => {
|
|
772
|
+
const t = qt.find((o) => o.name === e.vfs), { vfs: n, async: s, worker: r } = e;
|
|
773
|
+
if (!t) throw new I(`vfs ${n} not found`);
|
|
773
774
|
if (s !== void 0) {
|
|
774
775
|
if (s && !t.async)
|
|
775
|
-
throw new
|
|
776
|
+
throw new I(`vfs ${n} not support async: true`);
|
|
776
777
|
if (!s && !t.sync)
|
|
777
|
-
throw new
|
|
778
|
+
throw new I(`vfs ${n} not support async: false`);
|
|
778
779
|
}
|
|
779
|
-
if (r && !t.worker) throw new
|
|
780
|
-
if (!r && !t.jsContext) throw new
|
|
780
|
+
if (r && !t.worker) throw new I(`vfs ${n} not support worker`);
|
|
781
|
+
if (!r && !t.jsContext) throw new I(`vfs ${n} only support worker`);
|
|
781
782
|
return t;
|
|
782
|
-
},
|
|
783
|
-
const t =
|
|
783
|
+
}, vt = async (e) => {
|
|
784
|
+
const t = xe(e), n = e.async ?? !0;
|
|
784
785
|
let s;
|
|
785
|
-
n ? s =
|
|
786
|
+
n ? s = xt : s = Dt;
|
|
786
787
|
const [r, o] = await Promise.all([s(), t.vfsModule()]), i = {};
|
|
787
788
|
e.locateFile ? i.locateFile = e.locateFile : e.wasmPath && (i.locateFile = () => e.wasmPath);
|
|
788
|
-
const c = await r(i), a =
|
|
789
|
+
const c = await r(i), a = Ze(c), l = await o.create(e.vfs, c, t.vfsOptions);
|
|
789
790
|
return a.vfs_register(l, !0), a;
|
|
790
791
|
};
|
|
791
|
-
async function
|
|
792
|
+
async function kt(e, t, n, s) {
|
|
792
793
|
const r = performance.now(), o = s ? [s] : [[]], i = [];
|
|
793
794
|
let c = 0;
|
|
794
795
|
const a = {
|
|
@@ -800,7 +801,7 @@ async function vt(e, t, n, s) {
|
|
|
800
801
|
for (const d of o)
|
|
801
802
|
e.reset(l), e.bind_collection(l, d);
|
|
802
803
|
const u = [];
|
|
803
|
-
for (; await e.step(l) ===
|
|
804
|
+
for (; await e.step(l) === et; ) {
|
|
804
805
|
const d = e.row(l);
|
|
805
806
|
u.push(d);
|
|
806
807
|
}
|
|
@@ -813,10 +814,10 @@ async function vt(e, t, n, s) {
|
|
|
813
814
|
elapsed: performance.now() - r
|
|
814
815
|
};
|
|
815
816
|
}
|
|
816
|
-
const
|
|
817
|
+
const Pt = {
|
|
817
818
|
BALANCED: 16
|
|
818
|
-
},
|
|
819
|
-
class
|
|
819
|
+
}, ge = Pt.BALANCED, Ft = 50 * 1024, Bt = /* @__PURE__ */ new Set(["public$rxdb_change", "public$rxdb_branch", "public$rxdb_migration"]);
|
|
820
|
+
class Ut extends Je {
|
|
820
821
|
#n;
|
|
821
822
|
#e;
|
|
822
823
|
#r = !1;
|
|
@@ -824,7 +825,7 @@ class Pt extends He {
|
|
|
824
825
|
#c;
|
|
825
826
|
#o = [];
|
|
826
827
|
#a;
|
|
827
|
-
#t =
|
|
828
|
+
#t = ge;
|
|
828
829
|
/**
|
|
829
830
|
* 初始化数据库
|
|
830
831
|
*
|
|
@@ -833,16 +834,16 @@ class Pt extends He {
|
|
|
833
834
|
*/
|
|
834
835
|
async init(t, n) {
|
|
835
836
|
if (this.#r) return;
|
|
836
|
-
this.#r = !0, this.#c = new
|
|
837
|
-
const s = await
|
|
838
|
-
this.#e = await s.open_v2(r), this.#n = s, this.#u(s, this.#e), this.#t = n?.batchTimeout ??
|
|
839
|
-
const o = n?.cacheSizeKb ??
|
|
837
|
+
this.#r = !0, this.#c = new Te(1);
|
|
838
|
+
const s = await vt(n), r = `${t}.sqlite`;
|
|
839
|
+
this.#e = await s.open_v2(r), this.#n = s, this.#u(s, this.#e), this.#t = n?.batchTimeout ?? ge;
|
|
840
|
+
const o = n?.cacheSizeKb ?? Ft;
|
|
840
841
|
await this.execute(`
|
|
841
842
|
PRAGMA temp_store = memory;
|
|
842
843
|
PRAGMA foreign_keys = ON;
|
|
843
844
|
PRAGMA cache_size = -${o};
|
|
844
845
|
`), this.#n.update_hook(this.#e, (i, c, a, l) => {
|
|
845
|
-
!c || !a || !
|
|
846
|
+
!c || !a || !Bt.has(a) || (this.#o.push({ type: i, dbName: c, tableName: a, rowId: l }), this.#i());
|
|
846
847
|
});
|
|
847
848
|
}
|
|
848
849
|
/**
|
|
@@ -852,7 +853,7 @@ class Pt extends He {
|
|
|
852
853
|
*/
|
|
853
854
|
async version() {
|
|
854
855
|
const t = await this.execute("SELECT sqlite_version()");
|
|
855
|
-
return
|
|
856
|
+
return Ye(t, "results[0].rows[0][0]");
|
|
856
857
|
}
|
|
857
858
|
/**
|
|
858
859
|
* 断开数据库连接
|
|
@@ -883,7 +884,7 @@ class Pt extends He {
|
|
|
883
884
|
async execute(t, n) {
|
|
884
885
|
if (this.#s)
|
|
885
886
|
throw new Error("SqliteClient has been disconnected");
|
|
886
|
-
return this.#c.addTask(() =>
|
|
887
|
+
return this.#c.addTask(() => kt(this.#n, this.#e, t, n));
|
|
887
888
|
}
|
|
888
889
|
/**
|
|
889
890
|
* 调度批量发送
|
|
@@ -921,11 +922,11 @@ class Pt extends He {
|
|
|
921
922
|
* - `regexp_replace(pattern, text, replacement[, flags])` - 正则替换
|
|
922
923
|
*/
|
|
923
924
|
#u(t, n) {
|
|
924
|
-
|
|
925
|
+
Wt(t, n), Kt(t, n);
|
|
925
926
|
}
|
|
926
927
|
}
|
|
927
|
-
function
|
|
928
|
-
e.create_function(t, "regexp", 2,
|
|
928
|
+
function Wt(e, t) {
|
|
929
|
+
e.create_function(t, "regexp", 2, Se | be, 0, (n, s) => {
|
|
929
930
|
try {
|
|
930
931
|
const r = new RegExp(e.value_text(s[0])), o = e.value_text(s[1]);
|
|
931
932
|
e.result(n, r.test(o) ? 1 : 0);
|
|
@@ -934,8 +935,8 @@ function Ft(e, t) {
|
|
|
934
935
|
}
|
|
935
936
|
});
|
|
936
937
|
}
|
|
937
|
-
function
|
|
938
|
-
e.create_function(t, "regexp_replace", -1,
|
|
938
|
+
function Kt(e, t) {
|
|
939
|
+
e.create_function(t, "regexp_replace", -1, Se | be, 0, (n, s) => {
|
|
939
940
|
if (s.length < 3) {
|
|
940
941
|
e.result(n, "");
|
|
941
942
|
return;
|
|
@@ -948,7 +949,7 @@ function Bt(e, t) {
|
|
|
948
949
|
}
|
|
949
950
|
});
|
|
950
951
|
}
|
|
951
|
-
async function
|
|
952
|
+
async function Ht(e, t) {
|
|
952
953
|
const { vfs: n, async: s, worker: r, wasmPath: o, locateFile: i, workerInstance: c, sharedWorkerInstance: a, sharedWorker: l } = t, u = {
|
|
953
954
|
vfs: n,
|
|
954
955
|
async: s,
|
|
@@ -956,20 +957,20 @@ async function Wt(e, t) {
|
|
|
956
957
|
wasmPath: o,
|
|
957
958
|
locateFile: i
|
|
958
959
|
};
|
|
959
|
-
|
|
960
|
+
xe(u);
|
|
960
961
|
let f;
|
|
961
|
-
return r && c ? f =
|
|
962
|
+
return r && c ? f = me(c) : l && a ? f = me(a.port) : f = new Ut(), await f.init(e, u), f;
|
|
962
963
|
}
|
|
963
|
-
const
|
|
964
|
+
const Vt = (e, t) => t.map((n) => {
|
|
964
965
|
const s = e.rxdb.schemaManager.getEntityMetadata(n.entity, n.namespace);
|
|
965
966
|
return s ? (n.inversePatch && Object.keys(n.inversePatch).forEach((r) => {
|
|
966
967
|
const o = s.propertyMap.get(r);
|
|
967
|
-
o && (n.inversePatch[r] =
|
|
968
|
+
o && (n.inversePatch[r] = k(n.inversePatch[r], o));
|
|
968
969
|
}), n.patch && Object.keys(n.patch).forEach((r) => {
|
|
969
970
|
const o = s.propertyMap.get(r);
|
|
970
|
-
o && (n.patch[r] =
|
|
971
|
+
o && (n.patch[r] = k(n.patch[r], o));
|
|
971
972
|
})) : console.warn(`Entity metadata not found for ${n.namespace}.${n.entity}`), n;
|
|
972
|
-
}),
|
|
973
|
+
}), Qt = (e, t) => {
|
|
973
974
|
const n = Object.groupBy(t, (r) => r.type), s = Object.entries(n);
|
|
974
975
|
for (let r = 0; r < s.length; r++) {
|
|
975
976
|
const [o, i] = s[r];
|
|
@@ -986,30 +987,30 @@ const Ut = (e, t) => t.map((n) => {
|
|
|
986
987
|
switch (o) {
|
|
987
988
|
case "INSERT":
|
|
988
989
|
e.rxdb.dispatchEvent(
|
|
989
|
-
new
|
|
990
|
+
new W(c)
|
|
990
991
|
);
|
|
991
992
|
break;
|
|
992
993
|
case "UPDATE":
|
|
993
994
|
e.rxdb.dispatchEvent(
|
|
994
|
-
new
|
|
995
|
+
new Y(c)
|
|
995
996
|
);
|
|
996
997
|
break;
|
|
997
998
|
case "DELETE":
|
|
998
999
|
e.rxdb.dispatchEvent(
|
|
999
|
-
new
|
|
1000
|
+
new ie(c)
|
|
1000
1001
|
);
|
|
1001
1002
|
break;
|
|
1002
1003
|
}
|
|
1003
1004
|
}
|
|
1004
|
-
},
|
|
1005
|
-
const { tableName: n } = t, [s, r] =
|
|
1005
|
+
}, Gt = (e, t) => {
|
|
1006
|
+
const { tableName: n } = t, [s, r] = rt(n), o = e.rxdb.schemaManager.getEntityTypeByTableName(r, s);
|
|
1006
1007
|
if (!o) return;
|
|
1007
|
-
const i = e.getRepository(o), c = w(o), a = w(
|
|
1008
|
+
const i = e.getRepository(o), c = w(o), a = w(F);
|
|
1008
1009
|
i.findByRowIds(t.rowIds).then((l) => {
|
|
1009
1010
|
let u = l;
|
|
1010
1011
|
if (c === a) {
|
|
1011
|
-
if (u =
|
|
1012
|
-
|
|
1012
|
+
if (u = Vt(e, l), t.type === v.SQLITE_INSERT) {
|
|
1013
|
+
Qt(e, u);
|
|
1013
1014
|
const f = u.map((d) => ({
|
|
1014
1015
|
namespace: c.namespace,
|
|
1015
1016
|
entity: c.name,
|
|
@@ -1019,10 +1020,10 @@ const Ut = (e, t) => t.map((n) => {
|
|
|
1019
1020
|
inversePatch: null,
|
|
1020
1021
|
recordAt: d.createdAt
|
|
1021
1022
|
}));
|
|
1022
|
-
e.rxdb.dispatchEvent(new
|
|
1023
|
+
e.rxdb.dispatchEvent(new W(f));
|
|
1023
1024
|
}
|
|
1024
1025
|
} else {
|
|
1025
|
-
const f =
|
|
1026
|
+
const f = Lt(t.type), d = u.map((p) => {
|
|
1026
1027
|
const h = {
|
|
1027
1028
|
namespace: c.namespace,
|
|
1028
1029
|
entity: c.name,
|
|
@@ -1031,19 +1032,19 @@ const Ut = (e, t) => t.map((n) => {
|
|
|
1031
1032
|
recordAt: p.createdAt || /* @__PURE__ */ new Date()
|
|
1032
1033
|
};
|
|
1033
1034
|
switch (t.type) {
|
|
1034
|
-
case
|
|
1035
|
+
case v.SQLITE_INSERT:
|
|
1035
1036
|
return {
|
|
1036
1037
|
...h,
|
|
1037
1038
|
patch: { ...p },
|
|
1038
1039
|
inversePatch: null
|
|
1039
1040
|
};
|
|
1040
|
-
case
|
|
1041
|
+
case v.SQLITE_DELETE:
|
|
1041
1042
|
return {
|
|
1042
1043
|
...h,
|
|
1043
1044
|
patch: null,
|
|
1044
1045
|
inversePatch: { ...p }
|
|
1045
1046
|
};
|
|
1046
|
-
case
|
|
1047
|
+
case v.SQLITE_UPDATE:
|
|
1047
1048
|
return {
|
|
1048
1049
|
...h,
|
|
1049
1050
|
// TODO: 这里没有办法拿到变更前的数据,只能把整个 entity 作为 patch 返回, 可能会有问题,先这样处理
|
|
@@ -1055,17 +1056,17 @@ const Ut = (e, t) => t.map((n) => {
|
|
|
1055
1056
|
switch (f) {
|
|
1056
1057
|
case "UPDATE":
|
|
1057
1058
|
e.rxdb.dispatchEvent(
|
|
1058
|
-
new
|
|
1059
|
+
new Y(d)
|
|
1059
1060
|
);
|
|
1060
1061
|
break;
|
|
1061
1062
|
case "DELETE":
|
|
1062
1063
|
e.rxdb.dispatchEvent(
|
|
1063
|
-
new
|
|
1064
|
+
new ie(d)
|
|
1064
1065
|
);
|
|
1065
1066
|
break;
|
|
1066
1067
|
case "INSERT":
|
|
1067
1068
|
e.rxdb.dispatchEvent(
|
|
1068
|
-
new
|
|
1069
|
+
new W(d)
|
|
1069
1070
|
);
|
|
1070
1071
|
break;
|
|
1071
1072
|
}
|
|
@@ -1073,21 +1074,21 @@ const Ut = (e, t) => t.map((n) => {
|
|
|
1073
1074
|
}).catch((l) => {
|
|
1074
1075
|
console.error("Failed to handle RxDBChange insert event", l);
|
|
1075
1076
|
});
|
|
1076
|
-
},
|
|
1077
|
-
const { isCount: s, isFindDescendants: r, entityId: o, where: i } = n, c = !o, a =
|
|
1077
|
+
}, X = (e, t, n) => {
|
|
1078
|
+
const { isCount: s, isFindDescendants: r, entityId: o, where: i } = n, c = !o, a = b(t), u = t.relationMap.get("parent").columnName;
|
|
1078
1079
|
let f = "";
|
|
1079
|
-
const p = [`c.__level < ${n.level || 0}`, i &&
|
|
1080
|
+
const p = [`c.__level < ${n.level || 0}`, i && U(i, /* @__PURE__ */ new Map(), t, e)].filter(Boolean).join(" AND ");
|
|
1080
1081
|
p && (f = `WHERE ${p}`);
|
|
1081
1082
|
let h = "__children.*";
|
|
1082
1083
|
s ? c ? h = "count(*)" : h = "count(*)-1" : n.hasChildren && (h += `, EXISTS(SELECT 1 FROM "${a}" __sub WHERE __sub."${u}" = __children.id) AS hasChildren`);
|
|
1083
|
-
const
|
|
1084
|
+
const _ = c ? `"${u}" is null` : `id = '${o}'`;
|
|
1084
1085
|
return {
|
|
1085
1086
|
sql: `WITH RECURSIVE __children AS (
|
|
1086
|
-
SELECT *,rowid as ${
|
|
1087
|
+
SELECT *,rowid as ${D}, 0 AS __level
|
|
1087
1088
|
FROM "${a}"
|
|
1088
|
-
WHERE ${
|
|
1089
|
+
WHERE ${_}
|
|
1089
1090
|
UNION ALL
|
|
1090
|
-
SELECT children.*,children.rowid as ${
|
|
1091
|
+
SELECT children.*,children.rowid as ${D}, c.__level + 1 AS __level
|
|
1091
1092
|
FROM "${a}" children
|
|
1092
1093
|
JOIN __children c ON ${r ? `children."${u}" = c.id` : `children.id = c."${u}"`}
|
|
1093
1094
|
${f}
|
|
@@ -1095,45 +1096,45 @@ const Ut = (e, t) => t.map((n) => {
|
|
|
1095
1096
|
|
|
1096
1097
|
SELECT ${h} FROM __children ORDER BY __level, id;`
|
|
1097
1098
|
};
|
|
1098
|
-
},
|
|
1099
|
+
}, Jt = (e, t, n) => X(e, t, {
|
|
1099
1100
|
...n,
|
|
1100
1101
|
isFindDescendants: !0,
|
|
1101
1102
|
hasChildren: t.features?.tree?.hasChildren
|
|
1102
|
-
}),
|
|
1103
|
+
}), Yt = (e, t, n) => X(e, t, { ...n, isFindDescendants: !0, isCount: !0 }), Xt = (e, t, n) => X(e, t, {
|
|
1103
1104
|
...n,
|
|
1104
1105
|
isFindDescendants: !1,
|
|
1105
1106
|
hasChildren: t.features?.tree?.hasChildren
|
|
1106
|
-
}),
|
|
1107
|
-
class
|
|
1107
|
+
}), zt = (e, t, n) => X(e, t, { ...n, isFindDescendants: !1, isCount: !0 });
|
|
1108
|
+
class Zt extends je {
|
|
1108
1109
|
async findDescendants(t) {
|
|
1109
|
-
const { sql: n } =
|
|
1110
|
+
const { sql: n } = Jt(this.adapter, this.metadata, t), s = await this.adapter.query(n);
|
|
1110
1111
|
return this.addQueryCache(s, !0);
|
|
1111
1112
|
}
|
|
1112
1113
|
async countDescendants(t) {
|
|
1113
|
-
const { sql: n } =
|
|
1114
|
+
const { sql: n } = Yt(this.adapter, this.metadata, t);
|
|
1114
1115
|
return (await this.adapter.query(n)).results[0].rows[0][0];
|
|
1115
1116
|
}
|
|
1116
1117
|
async findAncestors(t) {
|
|
1117
|
-
const { sql: n } =
|
|
1118
|
+
const { sql: n } = Xt(this.adapter, this.metadata, t), s = await this.adapter.query(n);
|
|
1118
1119
|
return this.addQueryCache(s);
|
|
1119
1120
|
}
|
|
1120
1121
|
async countAncestors(t) {
|
|
1121
|
-
const { sql: n } =
|
|
1122
|
+
const { sql: n } = zt(this.adapter, this.metadata, t);
|
|
1122
1123
|
return (await this.adapter.query(n)).results[0].rows[0][0];
|
|
1123
1124
|
}
|
|
1124
1125
|
}
|
|
1125
|
-
const
|
|
1126
|
-
const n =
|
|
1126
|
+
const en = (e, t) => {
|
|
1127
|
+
const n = b(e), s = t.map((r) => R(r.id)).join(",");
|
|
1127
1128
|
return `DELETE FROM "${n}" WHERE id in (${s});`;
|
|
1128
|
-
},
|
|
1129
|
-
const s =
|
|
1129
|
+
}, De = (e, t, n) => {
|
|
1130
|
+
const s = b(e), r = n?.userId && e.propertyMap.has("createdBy"), o = n?.userId && e.propertyMap.has("updatedBy"), i = [
|
|
1130
1131
|
...Array.from(e.propertyMap.values()).map((l) => l.columnName),
|
|
1131
1132
|
...e.foreignKeyColumnNames || e.foreignKeyNames
|
|
1132
1133
|
], c = [];
|
|
1133
1134
|
t.forEach((l) => {
|
|
1134
|
-
const u =
|
|
1135
|
+
const u = Ae(e, l);
|
|
1135
1136
|
r && (u.createdBy = n.userId), o && (u.updatedBy = n.userId);
|
|
1136
|
-
const f =
|
|
1137
|
+
const f = ce(e, u), d = [];
|
|
1137
1138
|
i.forEach((p) => {
|
|
1138
1139
|
const h = R(f[p]);
|
|
1139
1140
|
d.push(h);
|
|
@@ -1141,60 +1142,60 @@ const Xt = (e, t) => {
|
|
|
1141
1142
|
});
|
|
1142
1143
|
const a = c.map((l) => `(${l.join(",")})`).join(",");
|
|
1143
1144
|
return `INSERT INTO "${s}" (${i.join(",")}) VALUES ${a};`;
|
|
1144
|
-
},
|
|
1145
|
+
}, Ne = async (e, t, n) => {
|
|
1145
1146
|
const s = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Date();
|
|
1146
1147
|
let o = "";
|
|
1147
1148
|
const i = /* @__PURE__ */ new Set();
|
|
1148
1149
|
return t.create.forEach((c, a) => {
|
|
1149
1150
|
const l = Array.from(c);
|
|
1150
1151
|
l.forEach((m) => i.add(m));
|
|
1151
|
-
const u = w(a), f =
|
|
1152
|
+
const u = w(a), f = De(u, l, e.rxdb.context), d = l.map((m) => m.id);
|
|
1152
1153
|
d.forEach((m) => s.set(m, a));
|
|
1153
|
-
const { sql: p, params: h } =
|
|
1154
|
+
const { sql: p, params: h } = ae(e, u, {
|
|
1154
1155
|
where: {
|
|
1155
1156
|
combinator: "and",
|
|
1156
1157
|
rules: [{ field: "id", operator: "in", value: d }]
|
|
1157
1158
|
}
|
|
1158
|
-
}),
|
|
1159
|
-
o += f +
|
|
1159
|
+
}), _ = B(p, h);
|
|
1160
|
+
o += f + _;
|
|
1160
1161
|
}), t.update.forEach((c, a) => {
|
|
1161
1162
|
const l = Array.from(c);
|
|
1162
1163
|
l.forEach((d) => i.add(d));
|
|
1163
1164
|
const u = w(a), f = Object.groupBy(l, (d) => {
|
|
1164
|
-
const p =
|
|
1165
|
-
return
|
|
1165
|
+
const p = q(d);
|
|
1166
|
+
return we(Object.keys(p.patch).sort());
|
|
1166
1167
|
});
|
|
1167
1168
|
Object.values(f).forEach((d) => {
|
|
1168
|
-
const p = d[0], h =
|
|
1169
|
+
const p = d[0], h = q(p), _ = ue(u, d, h.patch, {
|
|
1169
1170
|
...e.rxdb.context,
|
|
1170
1171
|
returning: !1,
|
|
1171
1172
|
updatedAt: r
|
|
1172
|
-
}), m =
|
|
1173
|
+
}), m = B(_.sql, _.params);
|
|
1173
1174
|
o += m;
|
|
1174
|
-
const
|
|
1175
|
-
|
|
1176
|
-
const
|
|
1175
|
+
const g = d.map((T) => T.id);
|
|
1176
|
+
g.forEach((T) => s.set(T, a));
|
|
1177
|
+
const N = ae(e, u, {
|
|
1177
1178
|
where: {
|
|
1178
1179
|
combinator: "and",
|
|
1179
|
-
rules: [{ field: "id", operator: "in", value:
|
|
1180
|
+
rules: [{ field: "id", operator: "in", value: g }]
|
|
1180
1181
|
}
|
|
1181
|
-
}), $ =
|
|
1182
|
+
}), $ = B(N.sql, N.params);
|
|
1182
1183
|
o += $;
|
|
1183
1184
|
});
|
|
1184
1185
|
}), t.remove.forEach((c, a) => {
|
|
1185
|
-
const l = Array.from(c), u = w(a), f =
|
|
1186
|
+
const l = Array.from(c), u = w(a), f = en(u, l);
|
|
1186
1187
|
o += f;
|
|
1187
1188
|
}), o && (await e.query(o)).results.forEach(({ columns: a, rows: l }) => {
|
|
1188
|
-
const u = a.findIndex((p) => p === "id"), f = a.findIndex((p) => p ===
|
|
1189
|
+
const u = a.findIndex((p) => p === "id"), f = a.findIndex((p) => p === D), d = e.rxdb.entityManager;
|
|
1189
1190
|
l.forEach((p) => {
|
|
1190
|
-
const h = p[u],
|
|
1191
|
-
if (d.hasEntityRef(
|
|
1192
|
-
const
|
|
1193
|
-
e.getRepository(
|
|
1194
|
-
const $ =
|
|
1191
|
+
const h = p[u], _ = s.get(h), m = w(_);
|
|
1192
|
+
if (d.hasEntityRef(_, h)) {
|
|
1193
|
+
const g = d.getEntityRef(_, h), N = re(m, a, p);
|
|
1194
|
+
e.getRepository(_).updateEntity(g, N);
|
|
1195
|
+
const $ = q(g);
|
|
1195
1196
|
if ($.local = !0, f !== -1) {
|
|
1196
1197
|
const T = BigInt(p[f]);
|
|
1197
|
-
e.cacheRowIdEntity(T,
|
|
1198
|
+
e.cacheRowIdEntity(T, g);
|
|
1198
1199
|
}
|
|
1199
1200
|
$.modified = !1;
|
|
1200
1201
|
}
|
|
@@ -1202,34 +1203,34 @@ const Xt = (e, t) => {
|
|
|
1202
1203
|
}), t.remove.forEach(
|
|
1203
1204
|
(c) => c.forEach((a) => {
|
|
1204
1205
|
i.add(a);
|
|
1205
|
-
const l =
|
|
1206
|
+
const l = q(a);
|
|
1206
1207
|
l.origin = structuredClone({ ...a }), l.modified = !1, l.removed = !0, l.local = !1;
|
|
1207
1208
|
})
|
|
1208
1209
|
), Array.from(i);
|
|
1209
|
-
},
|
|
1210
|
-
const n =
|
|
1210
|
+
}, tn = (e, t) => {
|
|
1211
|
+
const n = b(t);
|
|
1211
1212
|
let s = `CREATE TABLE "${n}" (`;
|
|
1212
1213
|
const r = [], o = [], i = [];
|
|
1213
1214
|
t.propertyMap.forEach((a) => {
|
|
1214
1215
|
const l = a.columnName;
|
|
1215
|
-
let u = `"${l}" ${
|
|
1216
|
-
if (a.type ===
|
|
1216
|
+
let u = `"${l}" ${st(a)}`;
|
|
1217
|
+
if (a.type === E.integer && a.primary ? u += " PRIMARY KEY AUTOINCREMENT" : (a.type === E.uuid || a.type === E.string) && a.primary && (u += " PRIMARY KEY", a.type === E.uuid && (u += " DEFAULT (lower(hex(randomblob(16))))")), !(a.type === E.uuid && a.primary) && Reflect.get(a, "default") !== void 0) {
|
|
1217
1218
|
let d = a.default;
|
|
1218
|
-
|
|
1219
|
+
he(a.default) && (d = a.default()), d === "CURRENT_TIMESTAMP" ? u += " DEFAULT(strftime('%FT%H:%M:%fZ'))" : (d = H(d, a), a.type === E.boolean || a.type === E.integer || a.type === E.number ? u += ` DEFAULT ${d}` : u += ` DEFAULT '${d}'`);
|
|
1219
1220
|
}
|
|
1220
1221
|
switch (a.nullable || (u += " NOT NULL"), a.type) {
|
|
1221
|
-
case
|
|
1222
|
-
case
|
|
1223
|
-
case
|
|
1224
|
-
case
|
|
1222
|
+
case E.json:
|
|
1223
|
+
case E.keyValue:
|
|
1224
|
+
case E.stringArray:
|
|
1225
|
+
case E.numberArray:
|
|
1225
1226
|
o.push(`CHECK ( JSON_VALID(${l})=1 )`);
|
|
1226
1227
|
break;
|
|
1227
|
-
case
|
|
1228
|
+
case E.boolean:
|
|
1228
1229
|
o.push(`CHECK (${l} in(0,1))`);
|
|
1229
1230
|
break;
|
|
1230
1231
|
}
|
|
1231
1232
|
a.unique && r.push(
|
|
1232
|
-
`CREATE UNIQUE INDEX ${
|
|
1233
|
+
`CREATE UNIQUE INDEX ${_e(t, a)} on "${n}"(${l});`
|
|
1233
1234
|
), i.push(u);
|
|
1234
1235
|
}), t.relationMap.forEach((a) => {
|
|
1235
1236
|
if (a.kind === A.ONE_TO_ONE || a.kind === A.MANY_TO_ONE) {
|
|
@@ -1239,26 +1240,26 @@ const Xt = (e, t) => {
|
|
|
1239
1240
|
);
|
|
1240
1241
|
let f = "TEXT";
|
|
1241
1242
|
const d = u.propertyMap.get("id");
|
|
1242
|
-
d.type ===
|
|
1243
|
+
d.type === E.integer ? f = "INTEGER" : (d.type === E.uuid || d.type === E.string) && (f = "TEXT");
|
|
1243
1244
|
const p = a.onDelete === "SET NULL" || a.onUpdate === "SET NULL";
|
|
1244
1245
|
let h = `"${l}" ${f}`;
|
|
1245
1246
|
if (!a.nullable && !p && (h += " NOT NULL"), a.kind === A.MANY_TO_ONE && Reflect.get(a, "default") !== void 0) {
|
|
1246
|
-
const
|
|
1247
|
-
let m =
|
|
1248
|
-
|
|
1247
|
+
const _ = a;
|
|
1248
|
+
let m = _.default;
|
|
1249
|
+
he(_.default) && (m = _.default()), h += ` DEFAULT ${m}`;
|
|
1249
1250
|
}
|
|
1250
1251
|
if (a.mappedEntity) {
|
|
1251
|
-
const
|
|
1252
|
+
const _ = e.rxdb.schemaManager.getEntityMetadata(
|
|
1252
1253
|
a.mappedEntity,
|
|
1253
1254
|
a.mappedNamespace
|
|
1254
|
-
), m =
|
|
1255
|
-
|
|
1255
|
+
), m = P(
|
|
1256
|
+
_?.tableName ?? a.mappedEntity,
|
|
1256
1257
|
a.mappedNamespace
|
|
1257
1258
|
);
|
|
1258
1259
|
h += ` REFERENCES ${m}(id)`, a.onDelete && (h += ` ON DELETE ${a.onDelete}`), a.onUpdate && (h += ` ON UPDATE ${a.onUpdate}`);
|
|
1259
1260
|
}
|
|
1260
1261
|
i.push(h), (a.unique || a.kind === A.ONE_TO_ONE) && r.push(
|
|
1261
|
-
`CREATE UNIQUE INDEX ${
|
|
1262
|
+
`CREATE UNIQUE INDEX ${_e(t, a)} on "${n}"(${l});`
|
|
1262
1263
|
);
|
|
1263
1264
|
}
|
|
1264
1265
|
});
|
|
@@ -1268,80 +1269,85 @@ const Xt = (e, t) => {
|
|
|
1268
1269
|
${a}`).join(","), s += `
|
|
1269
1270
|
);`;
|
|
1270
1271
|
else
|
|
1271
|
-
throw new
|
|
1272
|
+
throw new I("columns is empty!");
|
|
1272
1273
|
return r.length && (s += `
|
|
1273
1274
|
` + r.join(`
|
|
1274
1275
|
`)), t.indexes && t.indexes.length > 0 && t.indexes.forEach((a) => {
|
|
1275
1276
|
const l = `idx_${t.name}_${a.name}`, u = a.properties?.map((d) => {
|
|
1276
1277
|
const p = t.propertyMap.get(d);
|
|
1277
1278
|
if (p) return `"${p.columnName}"`;
|
|
1278
|
-
const h = t.foreignKeyNames,
|
|
1279
|
-
if (h &&
|
|
1279
|
+
const h = t.foreignKeyNames, _ = t.foreignKeyColumnNames;
|
|
1280
|
+
if (h && _) {
|
|
1280
1281
|
const m = h.indexOf(d);
|
|
1281
|
-
if (m >= 0) return `"${
|
|
1282
|
+
if (m >= 0) return `"${_[m]}"`;
|
|
1282
1283
|
}
|
|
1283
1284
|
return `"${d}"`;
|
|
1284
1285
|
}).join(", ") || `"${a.name}"`, f = a.unique ? "UNIQUE " : "";
|
|
1285
1286
|
s += `
|
|
1286
1287
|
CREATE ${f}INDEX "${l}" ON "${n}"(${u});`;
|
|
1287
1288
|
}), s;
|
|
1288
|
-
},
|
|
1289
|
-
const n =
|
|
1290
|
-
for (const [
|
|
1291
|
-
|
|
1289
|
+
}, nn = (e, t) => tn(e, t), de = (e, t = {}) => {
|
|
1290
|
+
const n = b(e), s = w(F), r = b(s), { propertyMap: o, name: i, foreignKeyNames: c, foreignKeyColumnNames: a, namespace: l } = e, u = [];
|
|
1291
|
+
for (const [y, C] of o)
|
|
1292
|
+
y !== "id" && u.push({ jsName: y, dbColumn: C.columnName });
|
|
1292
1293
|
const f = a || c;
|
|
1293
|
-
for (let
|
|
1294
|
-
c[
|
|
1295
|
-
const d = " type, namespace, entity, branchId, transactionId, entityId, inversePatch, patch", { transactionId: p, branchId: h } = t,
|
|
1294
|
+
for (let y = 0; y < c.length; y++)
|
|
1295
|
+
c[y] !== "id" && u.push({ jsName: c[y], dbColumn: f[y] });
|
|
1296
|
+
const d = " type, namespace, entity, branchId, transactionId, entityId, inversePatch, patch", { transactionId: p, branchId: h } = t, _ = R(p), m = R(h || "main"), g = `'${l}','${i}',${m},${_}`, N = (y) => y === E.stringArray || y === E.numberArray || y === E.json || y === E.keyValue, $ = (y, C, x) => {
|
|
1297
|
+
const z = o.get(C);
|
|
1298
|
+
return z?.type === E.boolean ? `CASE WHEN ${x}.${y} = 1 THEN 1 ELSE 0 END` : N(z?.type) ? `CASE WHEN ${x}.${y} IS NOT NULL THEN json(${x}.${y}) ELSE NULL END` : `${x}.${y}`;
|
|
1299
|
+
}, T = (y, C, x) => o.get(C)?.type === E.boolean ? `CASE WHEN ${x}.${y} = 1 THEN 1 ELSE 0 END` : `${x}.${y}`, L = `
|
|
1296
1300
|
DROP TRIGGER IF EXISTS ${n}_insert;
|
|
1297
1301
|
CREATE TRIGGER ${n}_insert AFTER INSERT ON "${n}"
|
|
1298
1302
|
BEGIN
|
|
1299
1303
|
INSERT INTO ${r} (${d}) VALUES (
|
|
1300
|
-
'INSERT',${
|
|
1301
|
-
json_object(${u.map((
|
|
1304
|
+
'INSERT',${g}, NEW.id, NULL,
|
|
1305
|
+
json_object(${u.map((y) => `'${y.jsName}', ${$(y.dbColumn, y.jsName, "NEW")}`).join(`,
|
|
1302
1306
|
`)})
|
|
1303
1307
|
);
|
|
1304
|
-
END;`,
|
|
1308
|
+
END;`, O = (y) => u.map((C) => {
|
|
1309
|
+
const x = N(o.get(C.jsName)?.type) ? 1 : 0;
|
|
1310
|
+
return `SELECT '${C.jsName}' AS key, ${T(C.dbColumn, C.jsName, y)} AS value, ${x} AS is_json WHERE OLD.${C.dbColumn} IS NOT NEW.${C.dbColumn}`;
|
|
1311
|
+
}).join(`
|
|
1312
|
+
UNION `), M = `
|
|
1305
1313
|
DROP TRIGGER IF EXISTS ${n}_update;
|
|
1306
1314
|
CREATE TRIGGER ${n}_update AFTER UPDATE ON "${n}"
|
|
1307
|
-
WHEN ( ${u.map((
|
|
1315
|
+
WHEN ( ${u.map((y) => `OLD.${y.dbColumn} IS NOT NEW.${y.dbColumn}`).join(` OR
|
|
1308
1316
|
`)} )
|
|
1309
1317
|
BEGIN
|
|
1310
1318
|
INSERT INTO ${r} (${d}) VALUES (
|
|
1311
|
-
'UPDATE',${
|
|
1319
|
+
'UPDATE',${g}, NEW.id,
|
|
1312
1320
|
(
|
|
1313
|
-
SELECT json_group_object(key, value) FROM (
|
|
1314
|
-
${
|
|
1315
|
-
UNION `)}
|
|
1321
|
+
SELECT json_group_object(key, CASE WHEN is_json AND value IS NOT NULL THEN json(value) ELSE value END) FROM (
|
|
1322
|
+
${O("OLD")}
|
|
1316
1323
|
)
|
|
1317
1324
|
),
|
|
1318
1325
|
(
|
|
1319
|
-
SELECT json_group_object(key, value) FROM (
|
|
1320
|
-
${
|
|
1321
|
-
UNION `)}
|
|
1326
|
+
SELECT json_group_object(key, CASE WHEN is_json AND value IS NOT NULL THEN json(value) ELSE value END) FROM (
|
|
1327
|
+
${O("NEW")}
|
|
1322
1328
|
)
|
|
1323
1329
|
)
|
|
1324
1330
|
);
|
|
1325
|
-
END;`,
|
|
1331
|
+
END;`, j = `
|
|
1326
1332
|
DROP TRIGGER IF EXISTS ${n}_delete;
|
|
1327
1333
|
CREATE TRIGGER ${n}_delete AFTER DELETE ON "${n}"
|
|
1328
1334
|
BEGIN
|
|
1329
1335
|
INSERT INTO ${r} (${d}) VALUES (
|
|
1330
|
-
'DELETE',${
|
|
1331
|
-
json_object(${u.map((
|
|
1336
|
+
'DELETE',${g}, OLD.id,
|
|
1337
|
+
json_object(${u.map((y) => `'${y.jsName}', ${$(y.dbColumn, y.jsName, "OLD")}`).join(`,
|
|
1332
1338
|
`)}), NULL
|
|
1333
1339
|
);
|
|
1334
1340
|
END;`;
|
|
1335
|
-
return
|
|
1336
|
-
` +
|
|
1337
|
-
` +
|
|
1338
|
-
},
|
|
1341
|
+
return L + `
|
|
1342
|
+
` + M + `
|
|
1343
|
+
` + j;
|
|
1344
|
+
}, sn = (e, t, n) => {
|
|
1339
1345
|
let s = "";
|
|
1340
1346
|
for (let r = 0; r < t.length; r++) {
|
|
1341
1347
|
const o = t[r], i = w(o);
|
|
1342
1348
|
if (s += `
|
|
1343
|
-
` +
|
|
1344
|
-
const c =
|
|
1349
|
+
` + nn(e, i), i.log !== !1) {
|
|
1350
|
+
const c = de(i);
|
|
1345
1351
|
s += `
|
|
1346
1352
|
` + c;
|
|
1347
1353
|
}
|
|
@@ -1353,39 +1359,39 @@ CREATE ${f}INDEX "${l}" ON "${n}"(${u});`;
|
|
|
1353
1359
|
r.has(i) === !1 && r.set(i, /* @__PURE__ */ new Set()), r.get(i).add(o);
|
|
1354
1360
|
});
|
|
1355
1361
|
for (const o of r.keys()) {
|
|
1356
|
-
const i =
|
|
1362
|
+
const i = De(o, Array.from(r.get(o)), e.rxdb.context);
|
|
1357
1363
|
s += `
|
|
1358
1364
|
` + i;
|
|
1359
1365
|
}
|
|
1360
1366
|
}
|
|
1361
1367
|
return s;
|
|
1362
|
-
},
|
|
1363
|
-
const t =
|
|
1368
|
+
}, rn = (e) => {
|
|
1369
|
+
const t = b(e);
|
|
1364
1370
|
return `DROP TRIGGER IF EXISTS ${t}_insert;
|
|
1365
1371
|
DROP TRIGGER IF EXISTS ${t}_update;
|
|
1366
1372
|
DROP TRIGGER IF EXISTS ${t}_delete;`;
|
|
1367
|
-
},
|
|
1373
|
+
}, qe = (e) => {
|
|
1368
1374
|
let t = "";
|
|
1369
1375
|
return e.rxdb.config.entities.forEach((n) => {
|
|
1370
1376
|
const s = w(n);
|
|
1371
|
-
s.log !== !1 && (t +=
|
|
1377
|
+
s.log !== !1 && (t += rn(s));
|
|
1372
1378
|
}), t;
|
|
1373
|
-
},
|
|
1379
|
+
}, ve = (e, t) => {
|
|
1374
1380
|
const { deletes: n, inserts: s, updates: r } = t, o = { deletes: [], inserts: [], updates: [] }, i = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map();
|
|
1375
1381
|
for (const [d, p] of n.entries()) {
|
|
1376
|
-
const [h,
|
|
1377
|
-
|
|
1378
|
-
let $ = c.get(
|
|
1379
|
-
$ || ($ = /* @__PURE__ */ new Map(), c.set(
|
|
1382
|
+
const [h, _, m] = Z(d), g = `${h}:${_}`, N = i.get(g);
|
|
1383
|
+
N ? N.add(m) : i.set(g, /* @__PURE__ */ new Set([m]));
|
|
1384
|
+
let $ = c.get(g);
|
|
1385
|
+
$ || ($ = /* @__PURE__ */ new Map(), c.set(g, $)), $.set(m, {
|
|
1380
1386
|
patch: p.patch,
|
|
1381
1387
|
inversePatch: p.inversePatch
|
|
1382
1388
|
});
|
|
1383
1389
|
}
|
|
1384
1390
|
for (const [d, p] of i) {
|
|
1385
|
-
const [h,
|
|
1391
|
+
const [h, _] = d.split(":"), m = e.rxdb.schemaManager.getEntityMetadata(_, h), g = b(m), N = m.propertyMap.get("id").type === "integer";
|
|
1386
1392
|
let $ = "";
|
|
1387
|
-
|
|
1388
|
-
const T = `DELETE FROM "${
|
|
1393
|
+
N ? $ = Array.from(p).join(",") : $ = Array.from(p).map((L) => R(L)).join(",");
|
|
1394
|
+
const T = `DELETE FROM "${g}" WHERE id in (${$});`;
|
|
1389
1395
|
o.deletes.push({
|
|
1390
1396
|
metadata: m,
|
|
1391
1397
|
ids: p,
|
|
@@ -1395,72 +1401,72 @@ DROP TRIGGER IF EXISTS ${t}_delete;`;
|
|
|
1395
1401
|
}
|
|
1396
1402
|
const a = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
|
|
1397
1403
|
for (const [d, p] of s.entries()) {
|
|
1398
|
-
const [h,
|
|
1399
|
-
|
|
1400
|
-
let T = l.get(
|
|
1401
|
-
T || (T = /* @__PURE__ */ new Map(), l.set(
|
|
1404
|
+
const [h, _, m] = Z(d), g = `${h}:${_}`, N = a.get(g), $ = { ...p.patch, id: m };
|
|
1405
|
+
N ? N.push($) : a.set(g, [$]);
|
|
1406
|
+
let T = l.get(g);
|
|
1407
|
+
T || (T = /* @__PURE__ */ new Map(), l.set(g, T)), T.set(m, {
|
|
1402
1408
|
patch: p.patch,
|
|
1403
1409
|
inversePatch: p.inversePatch
|
|
1404
1410
|
});
|
|
1405
1411
|
}
|
|
1406
1412
|
for (const [d, p] of a) {
|
|
1407
|
-
const [h,
|
|
1408
|
-
let
|
|
1409
|
-
p.forEach((
|
|
1410
|
-
for (const [
|
|
1411
|
-
|
|
1412
|
-
const { sql: $, params: T } =
|
|
1413
|
-
|
|
1413
|
+
const [h, _] = d.split(":"), m = e.rxdb.schemaManager.getEntityMetadata(_, h);
|
|
1414
|
+
let g = "";
|
|
1415
|
+
p.forEach((N) => {
|
|
1416
|
+
for (const [O, M] of m.propertyMap)
|
|
1417
|
+
N[O] === void 0 && M.default !== void 0 && (typeof M.default == "function" ? N[O] = M.default() : N[O] = M.default);
|
|
1418
|
+
const { sql: $, params: T } = Le(m, N, { useReplace: !0 }), L = B($, T);
|
|
1419
|
+
g += L;
|
|
1414
1420
|
}), o.inserts.push({
|
|
1415
1421
|
metadata: m,
|
|
1416
|
-
ids: new Set(p.filter((
|
|
1417
|
-
sql:
|
|
1422
|
+
ids: new Set(p.filter((N) => N != null).map((N) => N.id)),
|
|
1423
|
+
sql: g,
|
|
1418
1424
|
changes: l.get(d)
|
|
1419
1425
|
});
|
|
1420
1426
|
}
|
|
1421
1427
|
const u = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
|
|
1422
1428
|
for (const [d, p] of r.entries()) {
|
|
1423
|
-
const [h,
|
|
1424
|
-
|
|
1425
|
-
let T = f.get(
|
|
1426
|
-
T || (T = /* @__PURE__ */ new Map(), f.set(
|
|
1427
|
-
const
|
|
1428
|
-
|
|
1429
|
-
const
|
|
1430
|
-
|
|
1431
|
-
}),
|
|
1432
|
-
const
|
|
1433
|
-
|
|
1429
|
+
const [h, _, m] = Z(d), g = `${h}:${_}`, N = u.get(g), $ = { ...p.patch, id: m };
|
|
1430
|
+
N ? N.push($) : u.set(g, [$]);
|
|
1431
|
+
let T = f.get(g);
|
|
1432
|
+
T || (T = /* @__PURE__ */ new Map(), f.set(g, T));
|
|
1433
|
+
const L = e.rxdb.schemaManager.getEntityMetadata(_, h), O = p.patch ? { ...p.patch } : null, M = p.inversePatch ? { ...p.inversePatch } : null;
|
|
1434
|
+
L && (O && Object.keys(O).forEach((j) => {
|
|
1435
|
+
const y = L.propertyMap.get(j);
|
|
1436
|
+
y && (O[j] = k(O[j], y));
|
|
1437
|
+
}), M && Object.keys(M).forEach((j) => {
|
|
1438
|
+
const y = L.propertyMap.get(j);
|
|
1439
|
+
y && (M[j] = k(M[j], y));
|
|
1434
1440
|
})), T.set(m, {
|
|
1435
|
-
patch:
|
|
1436
|
-
inversePatch:
|
|
1441
|
+
patch: O,
|
|
1442
|
+
inversePatch: M
|
|
1437
1443
|
});
|
|
1438
1444
|
}
|
|
1439
1445
|
for (const [d, p] of u) {
|
|
1440
|
-
const [h,
|
|
1441
|
-
let
|
|
1442
|
-
p.forEach((
|
|
1446
|
+
const [h, _] = d.split(":"), m = e.rxdb.schemaManager.getEntityMetadata(_, h);
|
|
1447
|
+
let g = "";
|
|
1448
|
+
p.forEach((N) => {
|
|
1443
1449
|
let $;
|
|
1444
|
-
m.propertyMap.has("updatedAt") && ($ =
|
|
1445
|
-
const { id: T, ...
|
|
1450
|
+
m.propertyMap.has("updatedAt") && ($ = N.updatedAt);
|
|
1451
|
+
const { id: T, ...L } = N, { sql: O, params: M } = ue(m, { id: T }, L, {
|
|
1446
1452
|
updatedAt: $
|
|
1447
1453
|
});
|
|
1448
|
-
|
|
1454
|
+
g += B(O, M);
|
|
1449
1455
|
}), o.updates.push({
|
|
1450
1456
|
metadata: m,
|
|
1451
|
-
ids: new Set(p.filter((
|
|
1452
|
-
sql:
|
|
1457
|
+
ids: new Set(p.filter((N) => N != null).map((N) => N.id)),
|
|
1458
|
+
sql: g,
|
|
1453
1459
|
changes: f.get(d)
|
|
1454
1460
|
});
|
|
1455
1461
|
}
|
|
1456
1462
|
return o;
|
|
1457
|
-
},
|
|
1463
|
+
}, ke = (e, t) => {
|
|
1458
1464
|
let n = "";
|
|
1459
1465
|
e.rxdb.config.entities.forEach((i) => {
|
|
1460
1466
|
const c = w(i);
|
|
1461
1467
|
if (c.log !== !1)
|
|
1462
1468
|
try {
|
|
1463
|
-
const a =
|
|
1469
|
+
const a = de(c, {
|
|
1464
1470
|
branchId: t
|
|
1465
1471
|
});
|
|
1466
1472
|
a.trim() && (n += a);
|
|
@@ -1468,7 +1474,7 @@ DROP TRIGGER IF EXISTS ${t}_delete;`;
|
|
|
1468
1474
|
console.warn(`Failed to generate trigger SQL for entity ${c.name}:`, a);
|
|
1469
1475
|
}
|
|
1470
1476
|
});
|
|
1471
|
-
const s = w(
|
|
1477
|
+
const s = w(K), r = b(s), o = t.replace(/'/g, "''");
|
|
1472
1478
|
return n += `
|
|
1473
1479
|
UPDATE "${r}"
|
|
1474
1480
|
SET
|
|
@@ -1481,14 +1487,14 @@ DROP TRIGGER IF EXISTS ${t}_delete;`;
|
|
|
1481
1487
|
ELSE updatedAt
|
|
1482
1488
|
END
|
|
1483
1489
|
WHERE id = '${o}' OR activated = 1
|
|
1484
|
-
RETURNING rowid as ${
|
|
1490
|
+
RETURNING rowid as ${D},*;
|
|
1485
1491
|
`, n;
|
|
1486
|
-
},
|
|
1487
|
-
const { branchId: n, actions: s } = t, r = s &&
|
|
1492
|
+
}, on = async (e, t) => {
|
|
1493
|
+
const { branchId: n, actions: s } = t, r = s && ve(e, s);
|
|
1488
1494
|
let o;
|
|
1489
1495
|
try {
|
|
1490
1496
|
await e.transaction(async (a) => {
|
|
1491
|
-
const l =
|
|
1497
|
+
const l = qe(e);
|
|
1492
1498
|
if (l && await a.execute(l), r) {
|
|
1493
1499
|
if (r.deletes.length)
|
|
1494
1500
|
for (const u of r.deletes)
|
|
@@ -1502,7 +1508,7 @@ DROP TRIGGER IF EXISTS ${t}_delete;`;
|
|
|
1502
1508
|
}
|
|
1503
1509
|
s?.updateRxDBChangeSequence !== void 0 && await e.setRxDBChangeSequence(s.updateRxDBChangeSequence);
|
|
1504
1510
|
}, !1);
|
|
1505
|
-
const i =
|
|
1511
|
+
const i = ke(e, n);
|
|
1506
1512
|
o = await e.internalQuery(i);
|
|
1507
1513
|
const c = (a, l) => {
|
|
1508
1514
|
if (l.length === 0) return;
|
|
@@ -1518,21 +1524,21 @@ DROP TRIGGER IF EXISTS ${t}_delete;`;
|
|
|
1518
1524
|
recordAt: f.createdAt
|
|
1519
1525
|
};
|
|
1520
1526
|
});
|
|
1521
|
-
e.rxdb.dispatchEvent(new
|
|
1527
|
+
e.rxdb.dispatchEvent(new Y(u));
|
|
1522
1528
|
};
|
|
1523
1529
|
if (o) {
|
|
1524
|
-
const a =
|
|
1530
|
+
const a = J(e, K, o, !0), l = w(K);
|
|
1525
1531
|
c(l, a);
|
|
1526
1532
|
}
|
|
1527
|
-
r &&
|
|
1533
|
+
r && Pe(e, r);
|
|
1528
1534
|
} catch (i) {
|
|
1529
|
-
throw new
|
|
1535
|
+
throw new I(`switch branch ${n} failed: ` + i);
|
|
1530
1536
|
}
|
|
1531
1537
|
};
|
|
1532
|
-
async function
|
|
1538
|
+
async function an(e, t, n = !1) {
|
|
1533
1539
|
if (await e.transaction(async (s) => {
|
|
1534
1540
|
if (n) {
|
|
1535
|
-
const r =
|
|
1541
|
+
const r = qe(e);
|
|
1536
1542
|
r && await s.execute(r);
|
|
1537
1543
|
}
|
|
1538
1544
|
for (const r of t.deletes)
|
|
@@ -1542,15 +1548,15 @@ async function sn(e, t, n = !1) {
|
|
|
1542
1548
|
for (const r of t.updates)
|
|
1543
1549
|
r.successResults = await s.execute(r.sql);
|
|
1544
1550
|
}, !1), n) {
|
|
1545
|
-
const s = await e.rxdb.versionManager.getCurrentBranch(), r =
|
|
1551
|
+
const s = await e.rxdb.versionManager.getCurrentBranch(), r = ke(e, s.id);
|
|
1546
1552
|
await e.internalQuery(r);
|
|
1547
1553
|
}
|
|
1548
|
-
|
|
1554
|
+
Pe(e, t);
|
|
1549
1555
|
}
|
|
1550
|
-
function
|
|
1556
|
+
function Pe(e, t) {
|
|
1551
1557
|
for (const n of t.deletes) {
|
|
1552
|
-
const s =
|
|
1553
|
-
|
|
1558
|
+
const s = ee(n.metadata);
|
|
1559
|
+
Mt(e, s, Array.from(n.ids));
|
|
1554
1560
|
const r = n.metadata, o = Array.from(n.ids).map((i) => {
|
|
1555
1561
|
const c = n.changes.get(String(i));
|
|
1556
1562
|
return {
|
|
@@ -1563,10 +1569,10 @@ function qe(e, t) {
|
|
|
1563
1569
|
recordAt: /* @__PURE__ */ new Date()
|
|
1564
1570
|
};
|
|
1565
1571
|
});
|
|
1566
|
-
e.rxdb.dispatchEvent(new
|
|
1572
|
+
e.rxdb.dispatchEvent(new ie(o));
|
|
1567
1573
|
}
|
|
1568
1574
|
for (const n of t.inserts) {
|
|
1569
|
-
const s =
|
|
1575
|
+
const s = ee(n.metadata), r = J(e, s, n.successResults), o = n.metadata, i = r.map((c) => {
|
|
1570
1576
|
const a = n.changes.get(String(c.id));
|
|
1571
1577
|
return {
|
|
1572
1578
|
namespace: o.namespace,
|
|
@@ -1578,10 +1584,10 @@ function qe(e, t) {
|
|
|
1578
1584
|
recordAt: c.createdAt
|
|
1579
1585
|
};
|
|
1580
1586
|
});
|
|
1581
|
-
e.rxdb.dispatchEvent(new
|
|
1587
|
+
e.rxdb.dispatchEvent(new W(i));
|
|
1582
1588
|
}
|
|
1583
1589
|
for (const n of t.updates) {
|
|
1584
|
-
const s =
|
|
1590
|
+
const s = ee(n.metadata), r = J(e, s, n.successResults, !0), o = n.metadata, i = r.map((c) => {
|
|
1585
1591
|
const a = n.changes.get(String(c.id));
|
|
1586
1592
|
return {
|
|
1587
1593
|
namespace: o.namespace,
|
|
@@ -1593,15 +1599,15 @@ function qe(e, t) {
|
|
|
1593
1599
|
recordAt: c.updatedAt || c.createdAt || /* @__PURE__ */ new Date()
|
|
1594
1600
|
};
|
|
1595
1601
|
});
|
|
1596
|
-
e.rxdb.dispatchEvent(new
|
|
1602
|
+
e.rxdb.dispatchEvent(new Y(i));
|
|
1597
1603
|
}
|
|
1598
1604
|
}
|
|
1599
|
-
const
|
|
1605
|
+
const $e = (e, t, n) => {
|
|
1600
1606
|
let s = "";
|
|
1601
1607
|
return e.rxdb.config.entities.forEach((r) => {
|
|
1602
1608
|
const o = w(r);
|
|
1603
1609
|
if (o.log !== !1) {
|
|
1604
|
-
const i =
|
|
1610
|
+
const i = de(o, {
|
|
1605
1611
|
branchId: t,
|
|
1606
1612
|
transactionId: n
|
|
1607
1613
|
});
|
|
@@ -1610,17 +1616,17 @@ const ye = (e, t, n) => {
|
|
|
1610
1616
|
}
|
|
1611
1617
|
}), s;
|
|
1612
1618
|
};
|
|
1613
|
-
class
|
|
1619
|
+
class _n extends Ke {
|
|
1614
1620
|
constructor(t, n) {
|
|
1615
1621
|
super(t), this.options = n, n.repositories && Object.keys(n.repositories).forEach((r) => {
|
|
1616
1622
|
this.repository(r, n.repositories[r]);
|
|
1617
1623
|
});
|
|
1618
|
-
const s =
|
|
1619
|
-
this.#a ||
|
|
1624
|
+
const s = Xe((r) => {
|
|
1625
|
+
this.#a || Gt(this, r);
|
|
1620
1626
|
});
|
|
1621
1627
|
this.#t().then((r) => {
|
|
1622
|
-
r.addEventListener(
|
|
1623
|
-
}), this.repository("Repository",
|
|
1628
|
+
r.addEventListener(v.SQLITE_INSERT, s), r.addEventListener(v.SQLITE_UPDATE, s), r.addEventListener(v.SQLITE_DELETE, s);
|
|
1629
|
+
}), this.repository("Repository", je), this.repository("TreeRepository", Zt);
|
|
1624
1630
|
}
|
|
1625
1631
|
// SQLite 客户端缓存
|
|
1626
1632
|
#n;
|
|
@@ -1634,7 +1640,7 @@ class hn extends Be {
|
|
|
1634
1640
|
#r = /* @__PURE__ */ new Map();
|
|
1635
1641
|
#s = /* @__PURE__ */ new WeakMap();
|
|
1636
1642
|
// 查询任务队列执行器
|
|
1637
|
-
#c = new
|
|
1643
|
+
#c = new Te(1);
|
|
1638
1644
|
// sqlite 客户端
|
|
1639
1645
|
#o;
|
|
1640
1646
|
// 是否已断开连接
|
|
@@ -1642,7 +1648,7 @@ class hn extends Be {
|
|
|
1642
1648
|
/**
|
|
1643
1649
|
* 适配器名称
|
|
1644
1650
|
*/
|
|
1645
|
-
name =
|
|
1651
|
+
name = jt;
|
|
1646
1652
|
/**
|
|
1647
1653
|
* 获取实体仓库
|
|
1648
1654
|
* @param EntityType 实体类
|
|
@@ -1651,7 +1657,7 @@ class hn extends Be {
|
|
|
1651
1657
|
if (!this.repository_cache.has(t)) {
|
|
1652
1658
|
const n = w(t), s = this.repository_map.get(n.repository);
|
|
1653
1659
|
if (!s)
|
|
1654
|
-
throw new
|
|
1660
|
+
throw new I(`Repository '${n.repository}' not found`);
|
|
1655
1661
|
const r = new s(this, t);
|
|
1656
1662
|
return this.repository_cache.set(t, r), r;
|
|
1657
1663
|
}
|
|
@@ -1681,7 +1687,7 @@ class hn extends Be {
|
|
|
1681
1687
|
* @param entities
|
|
1682
1688
|
*/
|
|
1683
1689
|
async saveMany(t) {
|
|
1684
|
-
const n =
|
|
1690
|
+
const n = pe({
|
|
1685
1691
|
need_save_entities: t,
|
|
1686
1692
|
need_remove_entities: []
|
|
1687
1693
|
});
|
|
@@ -1693,7 +1699,7 @@ class hn extends Be {
|
|
|
1693
1699
|
* @returns
|
|
1694
1700
|
*/
|
|
1695
1701
|
async removeMany(t) {
|
|
1696
|
-
const n =
|
|
1702
|
+
const n = pe({
|
|
1697
1703
|
need_save_entities: [],
|
|
1698
1704
|
need_remove_entities: t
|
|
1699
1705
|
});
|
|
@@ -1704,15 +1710,15 @@ class hn extends Be {
|
|
|
1704
1710
|
* @param options
|
|
1705
1711
|
*/
|
|
1706
1712
|
async mutations(t) {
|
|
1707
|
-
return this.#e ? await
|
|
1713
|
+
return this.#e ? await Ne(this, t) : await this.transaction(() => Ne(this, t));
|
|
1708
1714
|
}
|
|
1709
1715
|
/**
|
|
1710
1716
|
* 判断表是否存在
|
|
1711
1717
|
* @param EntityType
|
|
1712
1718
|
*/
|
|
1713
1719
|
async isTableExisted(t) {
|
|
1714
|
-
const n = w(t), s =
|
|
1715
|
-
return
|
|
1720
|
+
const n = w(t), s = b(n), r = await this.#i(tt(s));
|
|
1721
|
+
return nt(r) === !1;
|
|
1716
1722
|
}
|
|
1717
1723
|
/**
|
|
1718
1724
|
* 创建表和初始化数据
|
|
@@ -1721,7 +1727,7 @@ class hn extends Be {
|
|
|
1721
1727
|
* @returns
|
|
1722
1728
|
*/
|
|
1723
1729
|
async createTables(t, n) {
|
|
1724
|
-
const s =
|
|
1730
|
+
const s = sn(this, t, n);
|
|
1725
1731
|
return await this.#i(s), !0;
|
|
1726
1732
|
}
|
|
1727
1733
|
/**
|
|
@@ -1730,7 +1736,7 @@ class hn extends Be {
|
|
|
1730
1736
|
* @returns
|
|
1731
1737
|
*/
|
|
1732
1738
|
async switchBranch(t) {
|
|
1733
|
-
return
|
|
1739
|
+
return on(this, t);
|
|
1734
1740
|
}
|
|
1735
1741
|
/**
|
|
1736
1742
|
* 应用压缩后的变更到本地实体表
|
|
@@ -1742,8 +1748,8 @@ class hn extends Be {
|
|
|
1742
1748
|
* @param disableTriggers - 是否禁用触发器(用于 pull 等操作,避免创建 RxDBChange)
|
|
1743
1749
|
*/
|
|
1744
1750
|
async mergeChanges(t, n, s = !1) {
|
|
1745
|
-
const r =
|
|
1746
|
-
await
|
|
1751
|
+
const r = ve(this, t);
|
|
1752
|
+
await an(this, r, s);
|
|
1747
1753
|
}
|
|
1748
1754
|
/**
|
|
1749
1755
|
* 缓存 RowId 与实体映射
|
|
@@ -1789,7 +1795,7 @@ class hn extends Be {
|
|
|
1789
1795
|
query(t, n) {
|
|
1790
1796
|
return this.#c.addTask(
|
|
1791
1797
|
async () => (await this.rxdb.connect(this.name), (await this.#t()).execute(t, n)),
|
|
1792
|
-
|
|
1798
|
+
we([t, n])
|
|
1793
1799
|
);
|
|
1794
1800
|
}
|
|
1795
1801
|
/**
|
|
@@ -1801,13 +1807,13 @@ class hn extends Be {
|
|
|
1801
1807
|
async transaction(t, n = !0) {
|
|
1802
1808
|
await this.rxdb.connect(this.name);
|
|
1803
1809
|
const s = await this.#t();
|
|
1804
|
-
this.#e = !0, this.rxdb.dispatchEvent(
|
|
1810
|
+
this.#e = !0, this.rxdb.dispatchEvent(cn);
|
|
1805
1811
|
let r = "", o = "";
|
|
1806
1812
|
if (n) {
|
|
1807
|
-
const i =
|
|
1813
|
+
const i = He(), c = await this.rxdb.versionManager.getCurrentBranch();
|
|
1808
1814
|
if (!c)
|
|
1809
1815
|
throw new Error("currentBranch is undefined! Cannot start transaction with logging.");
|
|
1810
|
-
r =
|
|
1816
|
+
r = $e(this, c.id, i), o = $e(this, c.id);
|
|
1811
1817
|
}
|
|
1812
1818
|
await s.execute(`
|
|
1813
1819
|
BEGIN;
|
|
@@ -1817,18 +1823,18 @@ class hn extends Be {
|
|
|
1817
1823
|
try {
|
|
1818
1824
|
const i = await t(s);
|
|
1819
1825
|
return await s.execute(`${o}
|
|
1820
|
-
COMMIT;`), this.#e = !1, this.rxdb.dispatchEvent(
|
|
1826
|
+
COMMIT;`), this.#e = !1, this.rxdb.dispatchEvent(un), i;
|
|
1821
1827
|
} catch (i) {
|
|
1822
|
-
await s.execute("ROLLBACK"), this.#e = !1, this.rxdb.dispatchEvent(
|
|
1828
|
+
await s.execute("ROLLBACK"), this.#e = !1, this.rxdb.dispatchEvent(ln);
|
|
1823
1829
|
const c = i?.message || "Transaction Error";
|
|
1824
|
-
throw new
|
|
1830
|
+
throw new I(c);
|
|
1825
1831
|
}
|
|
1826
1832
|
}
|
|
1827
1833
|
/**
|
|
1828
1834
|
* 本地分支仓库
|
|
1829
1835
|
*/
|
|
1830
1836
|
localRxDBBranch() {
|
|
1831
|
-
return this.getRepository(
|
|
1837
|
+
return this.getRepository(K);
|
|
1832
1838
|
}
|
|
1833
1839
|
/**
|
|
1834
1840
|
* 内部查询
|
|
@@ -1843,14 +1849,14 @@ COMMIT;`), this.#e = !1, this.rxdb.dispatchEvent(an), i;
|
|
|
1843
1849
|
* 本地变更仓库
|
|
1844
1850
|
*/
|
|
1845
1851
|
localRxDBChange() {
|
|
1846
|
-
return this.getRepository(
|
|
1852
|
+
return this.getRepository(F);
|
|
1847
1853
|
}
|
|
1848
1854
|
/**
|
|
1849
1855
|
* 获取 RxDBChange 表的当前序列值
|
|
1850
1856
|
* @returns
|
|
1851
1857
|
*/
|
|
1852
1858
|
async getRxDBChangeSequence() {
|
|
1853
|
-
const t =
|
|
1859
|
+
const t = Ee(F);
|
|
1854
1860
|
return (await this.#i(`SELECT seq FROM sqlite_sequence WHERE name='${t}'`)).results[0].rows[0][0];
|
|
1855
1861
|
}
|
|
1856
1862
|
/**
|
|
@@ -1858,7 +1864,7 @@ COMMIT;`), this.#e = !1, this.rxdb.dispatchEvent(an), i;
|
|
|
1858
1864
|
* @param sequence 序列值
|
|
1859
1865
|
*/
|
|
1860
1866
|
async setRxDBChangeSequence(t) {
|
|
1861
|
-
const n =
|
|
1867
|
+
const n = Ee(F);
|
|
1862
1868
|
await this.#i("UPDATE sqlite_sequence SET seq = ? WHERE name = ?", [t, n]);
|
|
1863
1869
|
}
|
|
1864
1870
|
// ============================================
|
|
@@ -1880,12 +1886,12 @@ COMMIT;`), this.#e = !1, this.rxdb.dispatchEvent(an), i;
|
|
|
1880
1886
|
* ```
|
|
1881
1887
|
*/
|
|
1882
1888
|
getMetadataByIds(t, n) {
|
|
1883
|
-
return
|
|
1889
|
+
return te(() => {
|
|
1884
1890
|
if (n.length === 0)
|
|
1885
|
-
return
|
|
1891
|
+
return ne(/* @__PURE__ */ new Map());
|
|
1886
1892
|
const s = n.map(() => "?").join(", "), r = `SELECT id, updatedAt FROM "${t}" WHERE id IN (${s})`;
|
|
1887
|
-
return
|
|
1888
|
-
|
|
1893
|
+
return se(this.internalQuery(r, n)).pipe(
|
|
1894
|
+
ze((o) => {
|
|
1889
1895
|
const i = /* @__PURE__ */ new Map();
|
|
1890
1896
|
if (o.results?.[0]?.rows)
|
|
1891
1897
|
for (const c of o.results[0].rows)
|
|
@@ -1911,7 +1917,7 @@ COMMIT;`), this.#e = !1, this.rxdb.dispatchEvent(an), i;
|
|
|
1911
1917
|
* ```
|
|
1912
1918
|
*/
|
|
1913
1919
|
upsertMany(t, n) {
|
|
1914
|
-
return
|
|
1920
|
+
return te(() => n.length === 0 ? ne(void 0) : se(
|
|
1915
1921
|
(async () => {
|
|
1916
1922
|
const s = Object.keys(n[0]), r = `(${s.map(() => "?").join(", ")})`, o = n.map(() => r).join(", "), i = `INSERT OR REPLACE INTO "${t}" (${s.join(", ")}) VALUES ${o}`, c = n.flatMap((a) => s.map((l) => a[l]));
|
|
1917
1923
|
await this.internalQuery(i, c);
|
|
@@ -1932,11 +1938,11 @@ COMMIT;`), this.#e = !1, this.rxdb.dispatchEvent(an), i;
|
|
|
1932
1938
|
* ```
|
|
1933
1939
|
*/
|
|
1934
1940
|
deleteByIds(t, n) {
|
|
1935
|
-
return
|
|
1941
|
+
return te(() => {
|
|
1936
1942
|
if (n.length === 0)
|
|
1937
|
-
return
|
|
1943
|
+
return ne(void 0);
|
|
1938
1944
|
const s = n.map(() => "?").join(", "), r = `DELETE FROM "${t}" WHERE id IN (${s})`;
|
|
1939
|
-
return
|
|
1945
|
+
return se(this.internalQuery(r, n).then(() => {
|
|
1940
1946
|
}));
|
|
1941
1947
|
});
|
|
1942
1948
|
}
|
|
@@ -1947,7 +1953,7 @@ COMMIT;`), this.#e = !1, this.rxdb.dispatchEvent(an), i;
|
|
|
1947
1953
|
* 获取 SQLite 客户端
|
|
1948
1954
|
*/
|
|
1949
1955
|
#t() {
|
|
1950
|
-
return this.#o || (this.#o =
|
|
1956
|
+
return this.#o || (this.#o = Ht(this.rxdb.config.dbName, this.options).then(
|
|
1951
1957
|
(t) => (this.#n = t, t)
|
|
1952
1958
|
)), this.#o;
|
|
1953
1959
|
}
|
|
@@ -1964,16 +1970,16 @@ COMMIT;`), this.#e = !1, this.rxdb.dispatchEvent(an), i;
|
|
|
1964
1970
|
return this.#r.has(t) === !1 && this.#r.set(t, /* @__PURE__ */ new Map()), this.#r.get(t);
|
|
1965
1971
|
}
|
|
1966
1972
|
}
|
|
1967
|
-
const
|
|
1973
|
+
const cn = new Be(), ln = new Ue(), un = new We();
|
|
1968
1974
|
export {
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1975
|
+
D as ROWID,
|
|
1976
|
+
_n as RxDBAdapterSqlite,
|
|
1977
|
+
I as RxDBAdapterSqliteError,
|
|
1978
|
+
Ut as SqliteClient,
|
|
1979
|
+
je as SqliteRepository,
|
|
1980
|
+
qt as WA_SQLITE_VFS_LIST,
|
|
1981
|
+
U as buildRuleGroup,
|
|
1982
|
+
P as sqliteGetTableName,
|
|
1983
|
+
b as sqliteGetTableNameByMetadata,
|
|
1984
|
+
vt as sqliteLoad
|
|
1979
1985
|
};
|