@aiao/rxdb-adapter-sqlite 0.0.14 → 0.0.16
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 +293 -291
- package/dist/rxdb_adapter_mutations.d.ts.map +1 -1
- package/dist/sqlite.utils.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getEntityMetadata as T, PropertyType as E, RelationKind as b, isRuleGroup as fe, getEntityStatus as
|
|
1
|
+
import { getEntityMetadata as T, PropertyType as E, RelationKind as b, isRuleGroup as fe, getEntityStatus as F, RepositoryBase as Be, RxDBChange as B, EntityLocalCreatedEvent as K, EntityLocalRemovedEvent as ce, EntityLocalUpdatedEvent as Y, parseRxDBChangeKey as ee, RxDBBranch as H, getEntityType as te, TransactionBeginEvent as Ue, TransactionRollbackEvent as We, TransactionCommitEvent as Ke, RxDBAdapterLocalBase as He, getEntityMutations as he, uuid as Ve } from "@aiao/rxdb";
|
|
2
2
|
import { isString as Qe, isNil as Ge, traverseObjectKeys as Je, EventDispatcher as Xe, AsyncQueueExecutor as we, get as Ye, isFunction as me } from "@aiao/utils";
|
|
3
3
|
import { wrap as Ee, proxy as ze } from "comlink";
|
|
4
4
|
import { defer as ne, of as se, from as re, map as Ze } from "rxjs";
|
|
@@ -49,7 +49,7 @@ const nt = (e) => ({
|
|
|
49
49
|
default:
|
|
50
50
|
return e;
|
|
51
51
|
}
|
|
52
|
-
},
|
|
52
|
+
}, v = (e, n) => {
|
|
53
53
|
if (e === null && n.nullable) return null;
|
|
54
54
|
if (e !== void 0)
|
|
55
55
|
switch (n.type) {
|
|
@@ -61,7 +61,7 @@ const nt = (e) => ({
|
|
|
61
61
|
if (!e) return null;
|
|
62
62
|
const t = typeof e == "object" ? e : JSON.parse(e);
|
|
63
63
|
return n.properties && t && typeof t == "object" && n.properties.forEach((s) => {
|
|
64
|
-
s.name in t && (t[s.name] =
|
|
64
|
+
s.name in t && (t[s.name] = v(t[s.name], s));
|
|
65
65
|
}), t;
|
|
66
66
|
}
|
|
67
67
|
case E.stringArray:
|
|
@@ -72,10 +72,10 @@ const nt = (e) => ({
|
|
|
72
72
|
default:
|
|
73
73
|
return e;
|
|
74
74
|
}
|
|
75
|
-
},
|
|
75
|
+
}, P = (e, n) => `${n}$${e}`, ot = (e) => {
|
|
76
76
|
const n = e.indexOf("$");
|
|
77
77
|
return n === -1 ? ["", e] : [e.substring(0, n), e.substring(n + 1)];
|
|
78
|
-
}, A = (e) =>
|
|
78
|
+
}, A = (e) => P(e.tableName, e.namespace), _e = (e) => A(T(e)), ye = (e, n) => `idx_${e.name}_${n.name}`;
|
|
79
79
|
class R extends Error {
|
|
80
80
|
constructor(n, t) {
|
|
81
81
|
super(n, t), this.name = "RxDBAdapterSqliteError", Object.setPrototypeOf(this, R.prototype);
|
|
@@ -97,15 +97,15 @@ const le = (e, n) => {
|
|
|
97
97
|
t[c] = n[c];
|
|
98
98
|
continue;
|
|
99
99
|
}
|
|
100
|
-
const
|
|
101
|
-
if (
|
|
102
|
-
t[
|
|
100
|
+
const u = e.propertyMap.get(c);
|
|
101
|
+
if (u) {
|
|
102
|
+
t[u.columnName] = V(n[c], u);
|
|
103
103
|
continue;
|
|
104
104
|
}
|
|
105
|
-
const
|
|
106
|
-
if (
|
|
107
|
-
const
|
|
108
|
-
|
|
105
|
+
const d = e.columnNameToPropertyName?.get(c);
|
|
106
|
+
if (d) {
|
|
107
|
+
const f = e.propertyMap.get(d);
|
|
108
|
+
f && (t[c] = V(n[c], f));
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
return t;
|
|
@@ -132,7 +132,10 @@ const le = (e, n) => {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
return t;
|
|
135
|
-
}, I = (e) => Qe(e) ? `'${e.replaceAll("\0", "").replaceAll("'", "''")}'` : Ge(e) ? "NULL" : e,
|
|
135
|
+
}, I = (e) => Qe(e) ? `'${e.replaceAll("\0", "").replaceAll("'", "''")}'` : Ge(e) ? "NULL" : e, k = (e, n = []) => {
|
|
136
|
+
let t = 0;
|
|
137
|
+
return e.replace(/\?/g, () => String(I(n[t++])));
|
|
138
|
+
}, oe = (e, n, t) => {
|
|
136
139
|
const s = {};
|
|
137
140
|
return t.forEach((r, o) => {
|
|
138
141
|
const i = n[o];
|
|
@@ -142,21 +145,21 @@ const le = (e, n) => {
|
|
|
142
145
|
s[c[l]] = r;
|
|
143
146
|
return;
|
|
144
147
|
}
|
|
145
|
-
const
|
|
148
|
+
const u = e.columnNameToPropertyName, p = u?.get(i);
|
|
146
149
|
if (p) {
|
|
147
|
-
const
|
|
148
|
-
|
|
150
|
+
const f = e.propertyMap.get(p);
|
|
151
|
+
f ? s[p] = v(r, f) : console.warn(`Property ${p} not found in metadata ${e.name}`);
|
|
149
152
|
return;
|
|
150
153
|
}
|
|
151
|
-
const
|
|
152
|
-
if (
|
|
153
|
-
s[i] =
|
|
154
|
+
const d = e.computedPropertyMap?.get(i);
|
|
155
|
+
if (d) {
|
|
156
|
+
s[i] = v(r, d);
|
|
154
157
|
return;
|
|
155
158
|
}
|
|
156
|
-
if (!
|
|
157
|
-
const
|
|
158
|
-
if (
|
|
159
|
-
s[i] =
|
|
159
|
+
if (!u) {
|
|
160
|
+
const f = e.propertyMap.get(i);
|
|
161
|
+
if (f) {
|
|
162
|
+
s[i] = v(r, f);
|
|
160
163
|
return;
|
|
161
164
|
}
|
|
162
165
|
}
|
|
@@ -245,8 +248,8 @@ const le = (e, n) => {
|
|
|
245
248
|
if (!r.length) return "";
|
|
246
249
|
const o = t.operator === "notContains" ? "NOT LIKE" : "LIKE", i = t.operator === "contains" ? " OR " : " AND ";
|
|
247
250
|
return `(${r.map(([a, l]) => {
|
|
248
|
-
const
|
|
249
|
-
return `json_extract(${w}."${s.columnName}", '$.${p}') ${o} ${I(`%${
|
|
251
|
+
const u = l instanceof Date ? l.toISOString() : typeof l == "string" ? l : String(l), p = a.replace(/'/g, "''");
|
|
252
|
+
return `json_extract(${w}."${s.columnName}", '$.${p}') ${o} ${I(`%${u}%`)}`;
|
|
250
253
|
}).join(i)})`;
|
|
251
254
|
}, ft = (e, n, t) => {
|
|
252
255
|
const s = e.propertyMap.get(n);
|
|
@@ -255,17 +258,17 @@ const le = (e, n) => {
|
|
|
255
258
|
return t.operator === "notIn" ? `NOT ${o}` : o;
|
|
256
259
|
}, ht = (e, n, t, s, r) => {
|
|
257
260
|
if (t && s && r && (e.operator === "exists" || e.operator === "notExists")) {
|
|
258
|
-
const
|
|
259
|
-
const
|
|
260
|
-
return
|
|
261
|
-
|
|
262
|
-
}), r(
|
|
261
|
+
const d = gt(e, t, s, (f, h) => {
|
|
262
|
+
const _ = /* @__PURE__ */ new Map();
|
|
263
|
+
return h.propertyMap.forEach((m, y) => {
|
|
264
|
+
_.set(y, `"child"."${m.columnName}"`);
|
|
265
|
+
}), r(f, _, h, s);
|
|
263
266
|
});
|
|
264
|
-
if (
|
|
267
|
+
if (d !== null) return d;
|
|
265
268
|
}
|
|
266
269
|
if (e.operator === "null" || e.operator === "notNull") {
|
|
267
|
-
const p = String(e.field),
|
|
268
|
-
return e.operator === "null" ? `${
|
|
270
|
+
const p = String(e.field), d = n.get(p), f = ge(p, d, t);
|
|
271
|
+
return e.operator === "null" ? `${f} IS NULL` : `${f} IS NOT NULL`;
|
|
269
272
|
}
|
|
270
273
|
const o = e.value === null, i = o ? "" : ct(e.operator).toLowerCase(), c = o ? e.operator === "=" ? "IS NULL" : e.operator === "!=" ? "IS NOT NULL" : "" : Re(e);
|
|
271
274
|
if (!c && ["in", "notIn", "between", "notBetween"].includes(e.operator)) return "";
|
|
@@ -282,7 +285,7 @@ const le = (e, n) => {
|
|
|
282
285
|
}, ue = (e) => e === w ? e : `"${e}"`, mt = (e, n, t) => {
|
|
283
286
|
if (e.kind !== b.ONE_TO_MANY)
|
|
284
287
|
throw new Error("_build_one_to_many_exists requires ONE_TO_MANY relation");
|
|
285
|
-
const s =
|
|
288
|
+
const s = P(n.tableName, n.namespace), r = "child", o = n.relations.find((a) => a.name === e.mappedProperty);
|
|
286
289
|
if (!o)
|
|
287
290
|
throw new Error(
|
|
288
291
|
`Cannot find mappedProperty relation "${e.mappedProperty}" in entity "${n.name}"`
|
|
@@ -294,47 +297,47 @@ const le = (e, n) => {
|
|
|
294
297
|
const s = e.columnName;
|
|
295
298
|
if (!t)
|
|
296
299
|
return `${w}."${s}" IS NOT NULL`;
|
|
297
|
-
const r =
|
|
300
|
+
const r = P(n.tableName, n.namespace), o = "child";
|
|
298
301
|
let i = `EXISTS (SELECT 1 FROM "${r}" "${o}"`;
|
|
299
302
|
return i += ` WHERE ${w}."${s}" = "${o}"."id"`, i += ` AND ${t}`, i += ")", i;
|
|
300
|
-
},
|
|
303
|
+
}, _t = (e, n, t, s, r) => {
|
|
301
304
|
const o = s.rxdb.schemaManager.findMappedRelation(e, n);
|
|
302
305
|
if (o?.relation) {
|
|
303
|
-
const i =
|
|
306
|
+
const i = P(t.tableName, t.namespace), c = "child", a = o.relation.columnName;
|
|
304
307
|
let l = `EXISTS (SELECT 1 FROM "${i}" "${c}"`;
|
|
305
308
|
return l += ` WHERE "${c}"."${a}" = ${w}."id"`, r && (l += ` AND ${r}`), l += ")", l;
|
|
306
309
|
} else {
|
|
307
310
|
const i = n.columnName;
|
|
308
311
|
if (!r)
|
|
309
312
|
return `${w}."${i}" IS NOT NULL`;
|
|
310
|
-
const c =
|
|
313
|
+
const c = P(t.tableName, t.namespace), a = "child";
|
|
311
314
|
let l = `EXISTS (SELECT 1 FROM "${c}" "${a}"`;
|
|
312
315
|
return l += ` WHERE ${w}."${i}" = "${a}"."id"`, l += ` AND ${r}`, l += ")", l;
|
|
313
316
|
}
|
|
314
|
-
},
|
|
315
|
-
const r =
|
|
317
|
+
}, yt = (e, n, t, s) => {
|
|
318
|
+
const r = P(t.tableName, t.namespace), o = "child", i = n.junctionEntityType;
|
|
316
319
|
if (!i)
|
|
317
320
|
throw new Error(`MANY_TO_MANY relation "${n.name}" missing junctionEntityType`);
|
|
318
321
|
const c = T(i);
|
|
319
322
|
if (!c)
|
|
320
323
|
throw new Error("Cannot find metadata for junction entity");
|
|
321
|
-
const a =
|
|
322
|
-
(
|
|
324
|
+
const a = P(c.tableName, c.namespace), l = "junction", u = c.relations.find(
|
|
325
|
+
(_) => _.mappedEntity === e.name && _.mappedNamespace === e.namespace
|
|
323
326
|
);
|
|
324
|
-
if (!
|
|
327
|
+
if (!u)
|
|
325
328
|
throw new Error(
|
|
326
329
|
`Cannot find relation in junction entity ${c.name} pointing to ${e.name}`
|
|
327
330
|
);
|
|
328
331
|
const p = c.relations.find(
|
|
329
|
-
(
|
|
332
|
+
(_) => _.mappedEntity === t.name && _.mappedNamespace === t.namespace
|
|
330
333
|
);
|
|
331
334
|
if (!p)
|
|
332
335
|
throw new Error(
|
|
333
336
|
`Cannot find relation in junction entity ${c.name} pointing to ${t.name}`
|
|
334
337
|
);
|
|
335
|
-
const
|
|
336
|
-
let
|
|
337
|
-
return
|
|
338
|
+
const d = u.columnName, f = p.columnName;
|
|
339
|
+
let h = `EXISTS (SELECT 1 FROM "${r}" "${o}"`;
|
|
340
|
+
return h += ` INNER JOIN "${a}" "${l}"`, h += ` ON "${l}"."${f}" = "${o}"."id"`, h += ` WHERE "${l}"."${d}" = ${w}."id"`, s && (h += ` AND ${s}`), h += ")", h;
|
|
338
341
|
}, gt = (e, n, t, s) => {
|
|
339
342
|
if (e.operator !== "exists" && e.operator !== "notExists")
|
|
340
343
|
return null;
|
|
@@ -357,10 +360,10 @@ const le = (e, n) => {
|
|
|
357
360
|
c = Et(r, o, i);
|
|
358
361
|
break;
|
|
359
362
|
case b.ONE_TO_ONE:
|
|
360
|
-
c =
|
|
363
|
+
c = _t(n, r, o, t, i);
|
|
361
364
|
break;
|
|
362
365
|
case b.MANY_TO_MANY:
|
|
363
|
-
c =
|
|
366
|
+
c = yt(n, r, o, i);
|
|
364
367
|
break;
|
|
365
368
|
}
|
|
366
369
|
return e.operator === "notExists" ? `NOT ${c}` : c;
|
|
@@ -386,12 +389,12 @@ const le = (e, n) => {
|
|
|
386
389
|
if (i.length === 0) continue;
|
|
387
390
|
const { metaWalker: c, relPairs: a } = Nt(e, t, r, o);
|
|
388
391
|
if (!c || a.length === 0) continue;
|
|
389
|
-
const l = i[0],
|
|
392
|
+
const l = i[0], u = i.slice(1).join("."), p = c.propertyMap.get(l);
|
|
390
393
|
if (p && p.type === E.keyValue) {
|
|
391
|
-
const
|
|
392
|
-
Ie(e, n, a,
|
|
393
|
-
const
|
|
394
|
-
return n.fieldAliasMap.set(s, `json_extract("${
|
|
394
|
+
const d = r.slice(0, o).join(".");
|
|
395
|
+
Ie(e, n, a, d);
|
|
396
|
+
const f = a[a.length - 1].relation, h = Q(a, d, f), _ = G(n, h), m = u ? `$.${u}` : "$";
|
|
397
|
+
return n.fieldAliasMap.set(s, `json_extract("${_}"."${p.columnName}", '${m}')`), !0;
|
|
395
398
|
}
|
|
396
399
|
}
|
|
397
400
|
return !1;
|
|
@@ -405,10 +408,10 @@ const le = (e, n) => {
|
|
|
405
408
|
} else (o.kind === b.MANY_TO_ONE || o.kind === b.ONE_TO_ONE) && (c = { metadata: r, relation: o });
|
|
406
409
|
if (!c) throw new R("mappedRelation not found");
|
|
407
410
|
const a = Q(t, s, o), l = G(n, a);
|
|
408
|
-
let
|
|
411
|
+
let u = w;
|
|
409
412
|
if (i > 0) {
|
|
410
|
-
const p = t[i - 1],
|
|
411
|
-
|
|
413
|
+
const p = t[i - 1], d = Q(t, s, p.relation);
|
|
414
|
+
u = G(n, d);
|
|
412
415
|
}
|
|
413
416
|
switch (o.kind) {
|
|
414
417
|
case b.ONE_TO_MANY:
|
|
@@ -416,7 +419,7 @@ const le = (e, n) => {
|
|
|
416
419
|
n,
|
|
417
420
|
c,
|
|
418
421
|
l,
|
|
419
|
-
|
|
422
|
+
u
|
|
420
423
|
);
|
|
421
424
|
break;
|
|
422
425
|
case b.ONE_TO_ONE:
|
|
@@ -425,7 +428,7 @@ const le = (e, n) => {
|
|
|
425
428
|
n,
|
|
426
429
|
c,
|
|
427
430
|
l,
|
|
428
|
-
|
|
431
|
+
u,
|
|
429
432
|
o
|
|
430
433
|
);
|
|
431
434
|
break;
|
|
@@ -435,7 +438,7 @@ const le = (e, n) => {
|
|
|
435
438
|
n,
|
|
436
439
|
c,
|
|
437
440
|
l,
|
|
438
|
-
|
|
441
|
+
u,
|
|
439
442
|
o
|
|
440
443
|
);
|
|
441
444
|
break;
|
|
@@ -456,15 +459,15 @@ const le = (e, n) => {
|
|
|
456
459
|
}, At = (e, n, t, s, r, o) => {
|
|
457
460
|
const i = T(o.junctionEntityType), c = J(n, i), a = Oe(n, `${o.name}_m_n`), l = `"${a}".${t.relation.columnName} = ${ue(r)}.id`;
|
|
458
461
|
c.find(
|
|
459
|
-
(
|
|
462
|
+
(h) => h.joinTableName === a && h.on === l
|
|
460
463
|
) || c.push({
|
|
461
464
|
joinTableName: a,
|
|
462
465
|
on: l
|
|
463
466
|
});
|
|
464
|
-
const p = J(n, t.metadata),
|
|
465
|
-
p.find((
|
|
467
|
+
const p = J(n, t.metadata), d = `"${s}".id = "${a}".${o.columnName}`;
|
|
468
|
+
p.find((h) => h.joinTableName === s && h.on === d) || p.push({
|
|
466
469
|
joinTableName: s,
|
|
467
|
-
on:
|
|
470
|
+
on: d
|
|
468
471
|
});
|
|
469
472
|
}, J = (e, n) => (e.joinMap.has(n) || e.joinMap.set(n, []), e.joinMap.get(n)), Oe = (e, n) => {
|
|
470
473
|
let t = n, s = 1;
|
|
@@ -487,11 +490,11 @@ const le = (e, n) => {
|
|
|
487
490
|
const { tableName: n, where: t, limit: s, offset: r, orderBy: o, join: i, hasJoin: c, metadata: a } = e;
|
|
488
491
|
let l = `${w}.rowid as ${q}, ${w}.*`;
|
|
489
492
|
if (a.features?.tree?.hasChildren && a.features?.tree?.type === "adjacency-list") {
|
|
490
|
-
const
|
|
491
|
-
l += `, EXISTS(SELECT 1 FROM "${n}" __sub WHERE __sub."${
|
|
493
|
+
const d = a.relationMap.get("parent").columnName;
|
|
494
|
+
l += `, EXISTS(SELECT 1 FROM "${n}" __sub WHERE __sub."${d}" = ${w}."id") AS "hasChildren"`;
|
|
492
495
|
}
|
|
493
|
-
const
|
|
494
|
-
return i &&
|
|
496
|
+
const u = [`SELECT ${c ? "DISTINCT " : ""}${l} FROM "${n}" ${w}`];
|
|
497
|
+
return i && u.push(i), t && u.push(` WHERE ${t}`), o && u.push(` ORDER BY ${o}`), s && u.push(` LIMIT ${s}`), r && u.push(` OFFSET ${r}`), u.join("") + ";";
|
|
495
498
|
}, Ce = (e, n, t) => {
|
|
496
499
|
const s = {
|
|
497
500
|
joinMap: /* @__PURE__ */ new Map(),
|
|
@@ -528,8 +531,8 @@ const le = (e, n) => {
|
|
|
528
531
|
}
|
|
529
532
|
const c = s.replace(`.${i.propertyName}`, "");
|
|
530
533
|
Ie(e, n, i.relations, c);
|
|
531
|
-
const a = i.relations[i.relations.length - 1], l = Q(i.relations, c, a.relation),
|
|
532
|
-
n.fieldAliasMap.set(s, `"${
|
|
534
|
+
const a = i.relations[i.relations.length - 1], l = Q(i.relations, c, a.relation), u = G(n, l);
|
|
535
|
+
n.fieldAliasMap.set(s, `"${u}"."${i.property.columnName}"`);
|
|
533
536
|
return;
|
|
534
537
|
} catch {
|
|
535
538
|
}
|
|
@@ -554,9 +557,9 @@ const le = (e, n) => {
|
|
|
554
557
|
}, de = (e, n, t, s) => {
|
|
555
558
|
const r = at(e, t);
|
|
556
559
|
e.propertyMap.has("updatedAt") && (r.updatedAt = s?.updatedAt ?? /* @__PURE__ */ new Date()), s?.userId && e.propertyMap.has("updatedBy") && (r.updatedBy = s.userId);
|
|
557
|
-
const o = le(e, r), i = Object.keys(o).map((
|
|
560
|
+
const o = le(e, r), i = Object.keys(o).map((d) => `${d} = ?`).join(","), c = [...Object.values(o)], a = A(e), l = Array.isArray(n), u = l ? n : [n];
|
|
558
561
|
let p = `UPDATE "${a}" SET ${i} WHERE id `;
|
|
559
|
-
return l ? p += `in (${
|
|
562
|
+
return l ? p += `in (${u.map((d) => I(d.id)).join(",")})` : (c.push(n.id), p += "= ?"), s?.returning !== !1 ? p += ` RETURNING rowid as ${q}, *;` : p += ";", {
|
|
560
563
|
sql: p,
|
|
561
564
|
params: c
|
|
562
565
|
};
|
|
@@ -587,39 +590,39 @@ const le = (e, n) => {
|
|
|
587
590
|
}, X = (e, n, t, s = !1, r = !1) => {
|
|
588
591
|
const o = [], i = T(n), c = e.rxdb.entityManager;
|
|
589
592
|
return t.results.forEach(({ columns: a, rows: l }) => {
|
|
590
|
-
const
|
|
591
|
-
l.forEach((
|
|
592
|
-
const
|
|
593
|
-
let
|
|
594
|
-
if (e.rxdb.entityManager.hasEntityRef(n,
|
|
595
|
-
|
|
596
|
-
const
|
|
593
|
+
const u = a.findIndex((d) => d === "id"), p = a.findIndex((d) => d === q);
|
|
594
|
+
l.forEach((d) => {
|
|
595
|
+
const f = d[u];
|
|
596
|
+
let h;
|
|
597
|
+
if (e.rxdb.entityManager.hasEntityRef(n, f)) {
|
|
598
|
+
h = c.getEntityRef(n, f);
|
|
599
|
+
const y = oe(i, a, d);
|
|
597
600
|
if (i.computedPropertyMap.forEach((N, $) => {
|
|
598
|
-
$ in
|
|
601
|
+
$ in y && (h[$] = y[$]);
|
|
599
602
|
}), s) {
|
|
600
|
-
const N =
|
|
601
|
-
N.origin = { ...
|
|
603
|
+
const N = F(h);
|
|
604
|
+
N.origin = { ...y }, Object.assign(h, y);
|
|
602
605
|
}
|
|
603
606
|
} else {
|
|
604
607
|
if (r)
|
|
605
608
|
return;
|
|
606
609
|
{
|
|
607
|
-
const
|
|
608
|
-
|
|
610
|
+
const y = oe(i, a, d);
|
|
611
|
+
h = c.createEntityRef(n, y);
|
|
609
612
|
}
|
|
610
613
|
}
|
|
611
|
-
o.push(
|
|
612
|
-
const m =
|
|
614
|
+
o.push(h);
|
|
615
|
+
const m = F(h);
|
|
613
616
|
if (m.local = !0, m.modified = !1, p !== -1) {
|
|
614
|
-
const
|
|
615
|
-
e.cacheRowIdEntity(
|
|
617
|
+
const y = BigInt(d[p]);
|
|
618
|
+
e.cacheRowIdEntity(y, h);
|
|
616
619
|
}
|
|
617
620
|
});
|
|
618
621
|
}), o;
|
|
619
622
|
}, Ct = (e, n, t) => {
|
|
620
623
|
t.forEach((s) => {
|
|
621
624
|
if (e.rxdb.entityManager.hasEntityRef(n, s)) {
|
|
622
|
-
const r = e.rxdb.entityManager.getEntityRef(n, s), o =
|
|
625
|
+
const r = e.rxdb.entityManager.getEntityRef(n, s), o = F(r);
|
|
623
626
|
o.local = !1, o.removed = !0, o.modified = !1;
|
|
624
627
|
}
|
|
625
628
|
});
|
|
@@ -673,7 +676,7 @@ class je extends Lt {
|
|
|
673
676
|
return this.addQueryCache(o, !0), n;
|
|
674
677
|
}
|
|
675
678
|
async remove(n) {
|
|
676
|
-
const t =
|
|
679
|
+
const t = F(n), s = () => {
|
|
677
680
|
t.origin = structuredClone({ ...n }), t.modified = !1, t.removed = !0;
|
|
678
681
|
};
|
|
679
682
|
if (t.local === !0) {
|
|
@@ -684,7 +687,7 @@ class je extends Lt {
|
|
|
684
687
|
throw new R(`Remove Error${r.name}(${n.id}) not saved local.`);
|
|
685
688
|
}
|
|
686
689
|
}
|
|
687
|
-
var
|
|
690
|
+
var D = /* @__PURE__ */ ((e) => (e[e.SQLITE_DELETE = 9] = "SQLITE_DELETE", e[e.SQLITE_INSERT = 18] = "SQLITE_INSERT", e[e.SQLITE_UPDATE = 23] = "SQLITE_UPDATE", e))(D || {});
|
|
688
691
|
const jt = (e) => {
|
|
689
692
|
switch (e) {
|
|
690
693
|
case 18:
|
|
@@ -808,13 +811,13 @@ async function kt(e, n, t, s) {
|
|
|
808
811
|
};
|
|
809
812
|
for await (const l of e.statements(n, t)) {
|
|
810
813
|
c && (e.reset(l), e.bind_collection(l, c), c = void 0);
|
|
811
|
-
const
|
|
814
|
+
const u = [];
|
|
812
815
|
for (; await e.step(l) === tt; ) {
|
|
813
|
-
const
|
|
814
|
-
|
|
816
|
+
const d = e.row(l);
|
|
817
|
+
u.push(d);
|
|
815
818
|
}
|
|
816
819
|
const p = e.column_names(l);
|
|
817
|
-
p.length && o.push({ columns: p, rows:
|
|
820
|
+
p.length && o.push({ columns: p, rows: u }), i += e.changes(n);
|
|
818
821
|
}
|
|
819
822
|
return {
|
|
820
823
|
...a,
|
|
@@ -969,28 +972,28 @@ function Vt(e, n) {
|
|
|
969
972
|
});
|
|
970
973
|
}
|
|
971
974
|
async function Qt(e, n) {
|
|
972
|
-
const { vfs: t, async: s, worker: r, wasmPath: o, locateFile: i, workerInstance: c, sharedWorkerInstance: a, sharedWorker: l } = n,
|
|
975
|
+
const { vfs: t, async: s, worker: r, wasmPath: o, locateFile: i, workerInstance: c, sharedWorkerInstance: a, sharedWorker: l } = n, u = {
|
|
973
976
|
vfs: t,
|
|
974
977
|
async: s,
|
|
975
978
|
worker: r,
|
|
976
979
|
wasmPath: o,
|
|
977
980
|
locateFile: i
|
|
978
981
|
};
|
|
979
|
-
xe(
|
|
982
|
+
xe(u);
|
|
980
983
|
let p;
|
|
981
|
-
return r && c ? p = Ee(c) : l && a ? p = Ee(a.port) : p = new Wt(), await p.init(e,
|
|
984
|
+
return r && c ? p = Ee(c) : l && a ? p = Ee(a.port) : p = new Wt(), await p.init(e, u), p;
|
|
982
985
|
}
|
|
983
986
|
const Gt = (e, n) => n.map((t) => {
|
|
984
987
|
const s = e.rxdb.schemaManager.getEntityMetadata(t.entity, t.namespace);
|
|
985
988
|
return s ? (t.inversePatch && Object.keys(t.inversePatch).forEach((r) => {
|
|
986
989
|
const o = s.propertyMap.get(r);
|
|
987
|
-
o && (t.inversePatch[r] =
|
|
990
|
+
o && (t.inversePatch[r] = v(
|
|
988
991
|
t.inversePatch[r],
|
|
989
992
|
o
|
|
990
993
|
));
|
|
991
994
|
}), t.patch && Object.keys(t.patch).forEach((r) => {
|
|
992
995
|
const o = s.propertyMap.get(r);
|
|
993
|
-
o && (t.patch[r] =
|
|
996
|
+
o && (t.patch[r] = v(
|
|
994
997
|
t.patch[r],
|
|
995
998
|
o
|
|
996
999
|
));
|
|
@@ -1045,96 +1048,96 @@ const Gt = (e, n) => n.map((t) => {
|
|
|
1045
1048
|
const i = e.getRepository(o), c = T(o), a = T(B);
|
|
1046
1049
|
i.findByRowIds(n.rowIds).then((l) => {
|
|
1047
1050
|
try {
|
|
1048
|
-
let
|
|
1051
|
+
let u = l;
|
|
1049
1052
|
if (c === a) {
|
|
1050
|
-
if (
|
|
1051
|
-
Jt(e,
|
|
1052
|
-
const p =
|
|
1053
|
+
if (u = Gt(e, l), n.type === D.SQLITE_INSERT) {
|
|
1054
|
+
Jt(e, u);
|
|
1055
|
+
const p = u.map((d) => ({
|
|
1053
1056
|
namespace: c.namespace,
|
|
1054
1057
|
entity: c.name,
|
|
1055
|
-
type:
|
|
1056
|
-
id:
|
|
1057
|
-
patch: { ...
|
|
1058
|
+
type: d.type,
|
|
1059
|
+
id: d.id,
|
|
1060
|
+
patch: { ...d },
|
|
1058
1061
|
inversePatch: null,
|
|
1059
|
-
recordAt:
|
|
1062
|
+
recordAt: d.createdAt
|
|
1060
1063
|
}));
|
|
1061
1064
|
e.rxdb.dispatchEvent(new K(p));
|
|
1062
1065
|
}
|
|
1063
1066
|
} else {
|
|
1064
|
-
const p = jt(n.type),
|
|
1065
|
-
const
|
|
1067
|
+
const p = jt(n.type), d = u.map((f) => {
|
|
1068
|
+
const h = {
|
|
1066
1069
|
namespace: c.namespace,
|
|
1067
1070
|
entity: c.name,
|
|
1068
1071
|
type: p,
|
|
1069
|
-
id:
|
|
1070
|
-
recordAt:
|
|
1072
|
+
id: f.id,
|
|
1073
|
+
recordAt: f.createdAt || /* @__PURE__ */ new Date()
|
|
1071
1074
|
};
|
|
1072
1075
|
switch (n.type) {
|
|
1073
|
-
case
|
|
1076
|
+
case D.SQLITE_INSERT:
|
|
1074
1077
|
return {
|
|
1075
|
-
...
|
|
1076
|
-
patch: { ...
|
|
1078
|
+
...h,
|
|
1079
|
+
patch: { ...f },
|
|
1077
1080
|
inversePatch: null
|
|
1078
1081
|
};
|
|
1079
|
-
case
|
|
1082
|
+
case D.SQLITE_DELETE:
|
|
1080
1083
|
return {
|
|
1081
|
-
...
|
|
1084
|
+
...h,
|
|
1082
1085
|
patch: null,
|
|
1083
|
-
inversePatch: { ...
|
|
1086
|
+
inversePatch: { ...f }
|
|
1084
1087
|
};
|
|
1085
|
-
case
|
|
1088
|
+
case D.SQLITE_UPDATE:
|
|
1086
1089
|
return {
|
|
1087
|
-
...
|
|
1090
|
+
...h,
|
|
1088
1091
|
inversePatch: null,
|
|
1089
|
-
patch: { ...
|
|
1092
|
+
patch: { ...f }
|
|
1090
1093
|
};
|
|
1091
1094
|
}
|
|
1092
1095
|
});
|
|
1093
1096
|
switch (p) {
|
|
1094
1097
|
case "UPDATE":
|
|
1095
1098
|
e.rxdb.dispatchEvent(
|
|
1096
|
-
new Y(
|
|
1099
|
+
new Y(d)
|
|
1097
1100
|
);
|
|
1098
1101
|
break;
|
|
1099
1102
|
case "DELETE":
|
|
1100
1103
|
e.rxdb.dispatchEvent(
|
|
1101
|
-
new ce(
|
|
1104
|
+
new ce(d)
|
|
1102
1105
|
);
|
|
1103
1106
|
break;
|
|
1104
1107
|
case "INSERT":
|
|
1105
1108
|
e.rxdb.dispatchEvent(
|
|
1106
|
-
new K(
|
|
1109
|
+
new K(d)
|
|
1107
1110
|
);
|
|
1108
1111
|
break;
|
|
1109
1112
|
}
|
|
1110
1113
|
}
|
|
1111
|
-
} catch (
|
|
1112
|
-
console.error(`[rxdb-adapter-sqlite] Error processing ${t} change event:`,
|
|
1114
|
+
} catch (u) {
|
|
1115
|
+
console.error(`[rxdb-adapter-sqlite] Error processing ${t} change event:`, u);
|
|
1113
1116
|
}
|
|
1114
1117
|
}).catch((l) => {
|
|
1115
1118
|
console.error(`[rxdb-adapter-sqlite] Failed to query ${t} change (rowIds: ${n.rowIds}):`, l);
|
|
1116
1119
|
});
|
|
1117
1120
|
}, z = (e, n, t) => {
|
|
1118
|
-
const { isCount: s, isFindDescendants: r, entityId: o, where: i } = t, c = !o, a = A(n),
|
|
1121
|
+
const { isCount: s, isFindDescendants: r, entityId: o, where: i } = t, c = !o, a = A(n), u = n.relationMap.get("parent").columnName;
|
|
1119
1122
|
let p = "";
|
|
1120
|
-
const
|
|
1121
|
-
|
|
1122
|
-
let
|
|
1123
|
-
s ? c ?
|
|
1124
|
-
const
|
|
1123
|
+
const f = [`c.__level < ${t.level || 0}`, i && U(i, /* @__PURE__ */ new Map(), n, e)].filter(Boolean).join(" AND ");
|
|
1124
|
+
f && (p = `WHERE ${f}`);
|
|
1125
|
+
let h = "__children.*";
|
|
1126
|
+
s ? c ? h = "count(*)" : h = "count(*)-1" : t.hasChildren && (h += `, EXISTS(SELECT 1 FROM "${a}" __sub WHERE __sub."${u}" = __children.id) AS hasChildren`);
|
|
1127
|
+
const _ = [];
|
|
1125
1128
|
let m;
|
|
1126
|
-
return c ? m = `"${
|
|
1129
|
+
return c ? m = `"${u}" is null` : (m = "id = ?", _.push(o)), { sql: `WITH RECURSIVE __children AS (
|
|
1127
1130
|
SELECT *,rowid as ${q}, 0 AS __level
|
|
1128
1131
|
FROM "${a}"
|
|
1129
1132
|
WHERE ${m}
|
|
1130
1133
|
UNION ALL
|
|
1131
1134
|
SELECT children.*,children.rowid as ${q}, c.__level + 1 AS __level
|
|
1132
1135
|
FROM "${a}" children
|
|
1133
|
-
JOIN __children c ON ${r ? `children."${
|
|
1136
|
+
JOIN __children c ON ${r ? `children."${u}" = c.id` : `children.id = c."${u}"`}
|
|
1134
1137
|
${p}
|
|
1135
1138
|
)
|
|
1136
1139
|
|
|
1137
|
-
SELECT ${
|
|
1140
|
+
SELECT ${h} FROM __children ORDER BY __level, id;`, params: _ };
|
|
1138
1141
|
}, Yt = (e, n, t) => z(e, n, {
|
|
1139
1142
|
...t,
|
|
1140
1143
|
isFindDescendants: !0,
|
|
@@ -1167,17 +1170,17 @@ const nn = (e, n) => {
|
|
|
1167
1170
|
return `DELETE FROM "${t}" WHERE id in (${s});`;
|
|
1168
1171
|
}, De = (e, n, t) => {
|
|
1169
1172
|
const s = A(e), r = t?.userId && e.propertyMap.has("createdBy"), o = t?.userId && e.propertyMap.has("updatedBy"), i = e.propertyMap.has("createdAt"), c = e.propertyMap.has("updatedAt"), a = /* @__PURE__ */ new Date(), l = [
|
|
1170
|
-
...Array.from(e.propertyMap.values()).map((
|
|
1173
|
+
...Array.from(e.propertyMap.values()).map((f) => f.columnName),
|
|
1171
1174
|
...e.foreignKeyColumnNames || e.foreignKeyNames
|
|
1172
|
-
],
|
|
1173
|
-
return n.forEach((
|
|
1174
|
-
const
|
|
1175
|
-
r && (
|
|
1176
|
-
const
|
|
1177
|
-
l.forEach((
|
|
1178
|
-
m.push("?"),
|
|
1175
|
+
], u = [], p = [];
|
|
1176
|
+
return n.forEach((f) => {
|
|
1177
|
+
const h = be(e, f);
|
|
1178
|
+
r && (h.createdBy = t.userId), o && (h.updatedBy = t.userId), i && h.createdAt === void 0 && (h.createdAt = a), c && h.updatedAt === void 0 && (h.updatedAt = a);
|
|
1179
|
+
const _ = le(e, h), m = [];
|
|
1180
|
+
l.forEach((y) => {
|
|
1181
|
+
m.push("?"), u.push(_[y] ?? null);
|
|
1179
1182
|
}), p.push(`(${m.join(",")})`);
|
|
1180
|
-
}), { sql: `INSERT INTO "${s}" (${l.join(",")}) VALUES ${p.join(",")};`, params:
|
|
1183
|
+
}), { sql: `INSERT INTO "${s}" (${l.join(",")}) VALUES ${p.join(",")};`, params: u };
|
|
1181
1184
|
}, $e = async (e, n) => {
|
|
1182
1185
|
const t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Date();
|
|
1183
1186
|
let r = "";
|
|
@@ -1185,52 +1188,51 @@ const nn = (e, n) => {
|
|
|
1185
1188
|
return n.create.forEach((i, c) => {
|
|
1186
1189
|
const a = Array.from(i);
|
|
1187
1190
|
a.forEach((m) => o.add(m));
|
|
1188
|
-
const l = T(c),
|
|
1189
|
-
|
|
1190
|
-
const { sql:
|
|
1191
|
+
const l = T(c), u = De(l, a, e.rxdb.context), p = k(u.sql, u.params), d = a.map((m) => m.id);
|
|
1192
|
+
d.forEach((m) => t.set(m, c));
|
|
1193
|
+
const { sql: f, params: h } = ie(e, l, {
|
|
1191
1194
|
where: {
|
|
1192
1195
|
combinator: "and",
|
|
1193
|
-
rules: [{ field: "id", operator: "in", value:
|
|
1196
|
+
rules: [{ field: "id", operator: "in", value: d }]
|
|
1194
1197
|
}
|
|
1195
|
-
}),
|
|
1196
|
-
r += p +
|
|
1198
|
+
}), _ = k(f, h);
|
|
1199
|
+
r += p + _;
|
|
1197
1200
|
}), n.update.forEach((i, c) => {
|
|
1198
1201
|
const a = Array.from(i);
|
|
1199
|
-
a.forEach((
|
|
1200
|
-
const l = T(c)
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
});
|
|
1204
|
-
Object.values(d).forEach((p) => {
|
|
1205
|
-
const u = p[0], h = D(u), f = de(l, p, h.patch, {
|
|
1202
|
+
a.forEach((f) => o.add(f));
|
|
1203
|
+
const l = T(c);
|
|
1204
|
+
a.forEach((f) => {
|
|
1205
|
+
const h = F(f), _ = de(l, f, h.patch, {
|
|
1206
1206
|
...e.rxdb.context,
|
|
1207
1207
|
returning: !1,
|
|
1208
1208
|
updatedAt: s
|
|
1209
|
-
})
|
|
1210
|
-
|
|
1211
|
-
const m =
|
|
1212
|
-
|
|
1213
|
-
const _ = ie(e, l, {
|
|
1214
|
-
where: {
|
|
1215
|
-
combinator: "and",
|
|
1216
|
-
rules: [{ field: "id", operator: "in", value: m }]
|
|
1217
|
-
}
|
|
1218
|
-
}), N = F(_.sql, _.params);
|
|
1219
|
-
r += N;
|
|
1209
|
+
});
|
|
1210
|
+
t.set(f.id, c);
|
|
1211
|
+
const m = k(_.sql, _.params);
|
|
1212
|
+
r += m;
|
|
1220
1213
|
});
|
|
1221
|
-
|
|
1222
|
-
|
|
1214
|
+
const u = a.map((f) => f.id);
|
|
1215
|
+
u.forEach((f) => t.set(f, c));
|
|
1216
|
+
const p = ie(e, l, {
|
|
1217
|
+
where: {
|
|
1218
|
+
combinator: "and",
|
|
1219
|
+
rules: [{ field: "id", operator: "in", value: u }]
|
|
1220
|
+
}
|
|
1221
|
+
}), d = k(p.sql, p.params);
|
|
1223
1222
|
r += d;
|
|
1223
|
+
}), n.remove.forEach((i, c) => {
|
|
1224
|
+
const a = Array.from(i), l = T(c), u = nn(l, a);
|
|
1225
|
+
r += u;
|
|
1224
1226
|
}), r && (await e.query(r)).results.forEach(({ columns: c, rows: a }) => {
|
|
1225
|
-
const l = c.findIndex((
|
|
1226
|
-
a.forEach((
|
|
1227
|
-
const
|
|
1228
|
-
if (p.hasEntityRef(
|
|
1229
|
-
const m = p.getEntityRef(
|
|
1230
|
-
e.getRepository(
|
|
1231
|
-
const N =
|
|
1232
|
-
if (N.local = !0,
|
|
1233
|
-
const $ = BigInt(u
|
|
1227
|
+
const l = c.findIndex((d) => d === "id"), u = c.findIndex((d) => d === q), p = e.rxdb.entityManager;
|
|
1228
|
+
a.forEach((d) => {
|
|
1229
|
+
const f = d[l], h = t.get(f), _ = T(h);
|
|
1230
|
+
if (p.hasEntityRef(h, f)) {
|
|
1231
|
+
const m = p.getEntityRef(h, f), y = oe(_, c, d);
|
|
1232
|
+
e.getRepository(h).updateEntity(m, y);
|
|
1233
|
+
const N = F(m);
|
|
1234
|
+
if (N.local = !0, u !== -1) {
|
|
1235
|
+
const $ = BigInt(d[u]);
|
|
1234
1236
|
e.cacheRowIdEntity($, m);
|
|
1235
1237
|
}
|
|
1236
1238
|
N.modified = !1;
|
|
@@ -1239,7 +1241,7 @@ const nn = (e, n) => {
|
|
|
1239
1241
|
}), n.remove.forEach(
|
|
1240
1242
|
(i) => i.forEach((c) => {
|
|
1241
1243
|
o.add(c);
|
|
1242
|
-
const a =
|
|
1244
|
+
const a = F(c);
|
|
1243
1245
|
a.origin = structuredClone({ ...c }), a.modified = !1, a.removed = !0, a.local = !1;
|
|
1244
1246
|
})
|
|
1245
1247
|
), Array.from(o);
|
|
@@ -1249,12 +1251,12 @@ const nn = (e, n) => {
|
|
|
1249
1251
|
const r = [], o = [], i = [];
|
|
1250
1252
|
n.propertyMap.forEach((a) => {
|
|
1251
1253
|
const l = a.columnName;
|
|
1252
|
-
let
|
|
1253
|
-
if (a.type === E.integer && a.primary ?
|
|
1254
|
-
let
|
|
1255
|
-
me(a.default) && (
|
|
1254
|
+
let u = `"${l}" ${rt(a)}`;
|
|
1255
|
+
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) && a.default !== void 0) {
|
|
1256
|
+
let d = a.default;
|
|
1257
|
+
me(a.default) && (d = a.default()), d === "CURRENT_TIMESTAMP" ? u += " DEFAULT(strftime('%FT%H:%M:%fZ'))" : (d = V(d, a), a.type === E.boolean || a.type === E.integer || a.type === E.number ? u += ` DEFAULT ${d}` : u += ` DEFAULT '${d}'`);
|
|
1256
1258
|
}
|
|
1257
|
-
switch (a.nullable || (
|
|
1259
|
+
switch (a.nullable || (u += " NOT NULL"), a.type) {
|
|
1258
1260
|
case E.json:
|
|
1259
1261
|
case E.keyValue:
|
|
1260
1262
|
case E.stringArray:
|
|
@@ -1266,42 +1268,42 @@ const nn = (e, n) => {
|
|
|
1266
1268
|
break;
|
|
1267
1269
|
case E.enum:
|
|
1268
1270
|
if ("enum" in a && a.enum && a.enum.length > 0) {
|
|
1269
|
-
const
|
|
1270
|
-
o.push(`CHECK (${l} in(${
|
|
1271
|
+
const d = a.enum.map((f) => `'${String(f).replace(/'/g, "''")}'`).join(",");
|
|
1272
|
+
o.push(`CHECK (${l} in(${d}))`);
|
|
1271
1273
|
}
|
|
1272
1274
|
break;
|
|
1273
1275
|
}
|
|
1274
1276
|
a.unique && r.push(
|
|
1275
|
-
`CREATE UNIQUE INDEX ${
|
|
1276
|
-
), i.push(
|
|
1277
|
+
`CREATE UNIQUE INDEX ${ye(n, a)} on "${t}"(${l});`
|
|
1278
|
+
), i.push(u);
|
|
1277
1279
|
}), n.relationMap.forEach((a) => {
|
|
1278
1280
|
if (a.kind === b.ONE_TO_ONE || a.kind === b.MANY_TO_ONE) {
|
|
1279
|
-
const l = a.columnName,
|
|
1281
|
+
const l = a.columnName, u = e.rxdb.schemaManager.getEntityMetadata(
|
|
1280
1282
|
a.mappedEntity,
|
|
1281
1283
|
a.mappedNamespace
|
|
1282
1284
|
);
|
|
1283
1285
|
let p = "TEXT";
|
|
1284
|
-
const
|
|
1285
|
-
|
|
1286
|
-
const
|
|
1287
|
-
let
|
|
1288
|
-
if (!a.nullable && !
|
|
1289
|
-
const
|
|
1290
|
-
let m =
|
|
1291
|
-
me(
|
|
1286
|
+
const d = u.propertyMap.get("id");
|
|
1287
|
+
d.type === E.integer ? p = "INTEGER" : (d.type === E.uuid || d.type === E.string) && (p = "TEXT");
|
|
1288
|
+
const f = a.onDelete === "SET NULL" || a.onUpdate === "SET NULL";
|
|
1289
|
+
let h = `"${l}" ${p}`;
|
|
1290
|
+
if (!a.nullable && !f && (h += " NOT NULL"), a.kind === b.MANY_TO_ONE && a.default !== void 0) {
|
|
1291
|
+
const _ = a;
|
|
1292
|
+
let m = _.default;
|
|
1293
|
+
me(_.default) && (m = _.default()), h += ` DEFAULT ${m}`;
|
|
1292
1294
|
}
|
|
1293
1295
|
if (a.mappedEntity) {
|
|
1294
|
-
const
|
|
1296
|
+
const _ = e.rxdb.schemaManager.getEntityMetadata(
|
|
1295
1297
|
a.mappedEntity,
|
|
1296
1298
|
a.mappedNamespace
|
|
1297
|
-
), m =
|
|
1298
|
-
|
|
1299
|
+
), m = P(
|
|
1300
|
+
_?.tableName ?? a.mappedEntity,
|
|
1299
1301
|
a.mappedNamespace
|
|
1300
1302
|
);
|
|
1301
|
-
|
|
1303
|
+
h += ` REFERENCES ${m}(id)`, a.onDelete && (h += ` ON DELETE ${a.onDelete}`), a.onUpdate && (h += ` ON UPDATE ${a.onUpdate}`);
|
|
1302
1304
|
}
|
|
1303
|
-
i.push(
|
|
1304
|
-
`CREATE UNIQUE INDEX ${
|
|
1305
|
+
i.push(h), (a.unique || a.kind === b.ONE_TO_ONE) && r.push(
|
|
1306
|
+
`CREATE UNIQUE INDEX ${ye(n, a)} on "${t}"(${l});`
|
|
1305
1307
|
);
|
|
1306
1308
|
}
|
|
1307
1309
|
});
|
|
@@ -1315,50 +1317,50 @@ ${a}`).join(","), s += `
|
|
|
1315
1317
|
return r.length && (s += `
|
|
1316
1318
|
` + r.join(`
|
|
1317
1319
|
`)), n.indexes && n.indexes.length > 0 && n.indexes.forEach((a) => {
|
|
1318
|
-
const l = `idx_${n.name}_${a.name}`,
|
|
1319
|
-
const
|
|
1320
|
-
if (
|
|
1321
|
-
const
|
|
1322
|
-
if (
|
|
1323
|
-
const m =
|
|
1324
|
-
if (m >= 0) return `"${
|
|
1320
|
+
const l = `idx_${n.name}_${a.name}`, u = a.properties?.map((d) => {
|
|
1321
|
+
const f = n.propertyMap.get(d);
|
|
1322
|
+
if (f) return `"${f.columnName}"`;
|
|
1323
|
+
const h = n.foreignKeyNames, _ = n.foreignKeyColumnNames;
|
|
1324
|
+
if (h && _) {
|
|
1325
|
+
const m = h.indexOf(d);
|
|
1326
|
+
if (m >= 0) return `"${_[m]}"`;
|
|
1325
1327
|
}
|
|
1326
|
-
return `"${
|
|
1328
|
+
return `"${d}"`;
|
|
1327
1329
|
}).join(", ") || `"${a.name}"`, p = a.unique ? "UNIQUE " : "";
|
|
1328
1330
|
s += `
|
|
1329
|
-
CREATE ${p}INDEX "${l}" ON "${t}"(${
|
|
1331
|
+
CREATE ${p}INDEX "${l}" ON "${t}"(${u});`;
|
|
1330
1332
|
}), s;
|
|
1331
1333
|
}, rn = (e, n) => sn(e, n), pe = (e, n = {}) => {
|
|
1332
|
-
const t = A(e), s = T(B), r = A(s), { propertyMap: o, name: i, foreignKeyNames: c, foreignKeyColumnNames: a, namespace: l } = e,
|
|
1334
|
+
const t = A(e), s = T(B), r = A(s), { propertyMap: o, name: i, foreignKeyNames: c, foreignKeyColumnNames: a, namespace: l } = e, u = [];
|
|
1333
1335
|
for (const [g, C] of o)
|
|
1334
|
-
g !== "id" &&
|
|
1336
|
+
g !== "id" && u.push({ jsName: g, dbColumn: C.columnName });
|
|
1335
1337
|
const p = a || c;
|
|
1336
1338
|
for (let g = 0; g < c.length; g++)
|
|
1337
|
-
c[g] !== "id" &&
|
|
1338
|
-
const
|
|
1339
|
+
c[g] !== "id" && u.push({ jsName: c[g], dbColumn: p[g] });
|
|
1340
|
+
const d = " type, namespace, entity, branchId, transactionId, entityId, inversePatch, patch", { transactionId: f, branchId: h } = n, _ = I(f), m = I(h || "main"), y = `'${l}','${i}',${m},${_}`, N = (g) => g === E.stringArray || g === E.numberArray || g === E.json || g === E.keyValue, $ = (g, C, x) => {
|
|
1339
1341
|
const Z = o.get(C);
|
|
1340
1342
|
return Z?.type === E.boolean ? `CASE WHEN ${x}.${g} = 1 THEN 1 ELSE 0 END` : N(Z?.type) ? `CASE WHEN ${x}.${g} IS NOT NULL THEN json(${x}.${g}) ELSE NULL END` : `${x}.${g}`;
|
|
1341
1343
|
}, S = (g, C, x) => o.get(C)?.type === E.boolean ? `CASE WHEN ${x}.${g} = 1 THEN 1 ELSE 0 END` : `${x}.${g}`, L = `
|
|
1342
1344
|
DROP TRIGGER IF EXISTS ${t}_insert;
|
|
1343
1345
|
CREATE TRIGGER ${t}_insert AFTER INSERT ON "${t}"
|
|
1344
1346
|
BEGIN
|
|
1345
|
-
INSERT INTO ${r} (${
|
|
1346
|
-
'INSERT',${
|
|
1347
|
-
json_object(${
|
|
1347
|
+
INSERT INTO ${r} (${d}) VALUES (
|
|
1348
|
+
'INSERT',${y}, NEW.id, NULL,
|
|
1349
|
+
json_object(${u.map((g) => `'${g.jsName}', ${$(g.dbColumn, g.jsName, "NEW")}`).join(`,
|
|
1348
1350
|
`)})
|
|
1349
1351
|
);
|
|
1350
|
-
END;`, O = (g) =>
|
|
1352
|
+
END;`, O = (g) => u.map((C) => {
|
|
1351
1353
|
const x = N(o.get(C.jsName)?.type) ? 1 : 0;
|
|
1352
1354
|
return `SELECT '${C.jsName}' AS key, ${S(C.dbColumn, C.jsName, g)} AS value, ${x} AS is_json WHERE OLD.${C.dbColumn} IS NOT NEW.${C.dbColumn}`;
|
|
1353
1355
|
}).join(`
|
|
1354
1356
|
UNION `), M = `
|
|
1355
1357
|
DROP TRIGGER IF EXISTS ${t}_update;
|
|
1356
1358
|
CREATE TRIGGER ${t}_update AFTER UPDATE ON "${t}"
|
|
1357
|
-
WHEN ( ${
|
|
1359
|
+
WHEN ( ${u.map((g) => `OLD.${g.dbColumn} IS NOT NEW.${g.dbColumn}`).join(` OR
|
|
1358
1360
|
`)} )
|
|
1359
1361
|
BEGIN
|
|
1360
|
-
INSERT INTO ${r} (${
|
|
1361
|
-
'UPDATE',${
|
|
1362
|
+
INSERT INTO ${r} (${d}) VALUES (
|
|
1363
|
+
'UPDATE',${y}, NEW.id,
|
|
1362
1364
|
(
|
|
1363
1365
|
SELECT json_group_object(key, CASE WHEN is_json AND value IS NOT NULL THEN json(value) ELSE value END) FROM (
|
|
1364
1366
|
${O("OLD")}
|
|
@@ -1374,9 +1376,9 @@ CREATE ${p}INDEX "${l}" ON "${t}"(${d});`;
|
|
|
1374
1376
|
DROP TRIGGER IF EXISTS ${t}_delete;
|
|
1375
1377
|
CREATE TRIGGER ${t}_delete AFTER DELETE ON "${t}"
|
|
1376
1378
|
BEGIN
|
|
1377
|
-
INSERT INTO ${r} (${
|
|
1378
|
-
'DELETE',${
|
|
1379
|
-
json_object(${
|
|
1379
|
+
INSERT INTO ${r} (${d}) VALUES (
|
|
1380
|
+
'DELETE',${y}, OLD.id,
|
|
1381
|
+
json_object(${u.map((g) => `'${g.jsName}', ${$(g.dbColumn, g.jsName, "OLD")}`).join(`,
|
|
1380
1382
|
`)}), NULL
|
|
1381
1383
|
);
|
|
1382
1384
|
END;`;
|
|
@@ -1407,7 +1409,7 @@ CREATE ${p}INDEX "${l}" ON "${t}"(${d});`;
|
|
|
1407
1409
|
e.rxdb.context
|
|
1408
1410
|
);
|
|
1409
1411
|
s += `
|
|
1410
|
-
` +
|
|
1412
|
+
` + k(i.sql, i.params);
|
|
1411
1413
|
}
|
|
1412
1414
|
}
|
|
1413
1415
|
return s;
|
|
@@ -1424,87 +1426,87 @@ DROP TRIGGER IF EXISTS ${n}_delete;`;
|
|
|
1424
1426
|
}), n;
|
|
1425
1427
|
}, Pe = (e, n) => {
|
|
1426
1428
|
const { deletes: t, inserts: s, updates: r } = n, o = { deletes: [], inserts: [], updates: [] }, i = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map();
|
|
1427
|
-
for (const [
|
|
1428
|
-
const [
|
|
1429
|
-
N ? N.add(m) : i.set(
|
|
1430
|
-
let $ = c.get(
|
|
1431
|
-
$ || ($ = /* @__PURE__ */ new Map(), c.set(
|
|
1432
|
-
patch:
|
|
1433
|
-
inversePatch:
|
|
1429
|
+
for (const [d, f] of t.entries()) {
|
|
1430
|
+
const [h, _, m] = ee(d), y = `${h}:${_}`, N = i.get(y);
|
|
1431
|
+
N ? N.add(m) : i.set(y, /* @__PURE__ */ new Set([m]));
|
|
1432
|
+
let $ = c.get(y);
|
|
1433
|
+
$ || ($ = /* @__PURE__ */ new Map(), c.set(y, $)), $.set(m, {
|
|
1434
|
+
patch: f.patch,
|
|
1435
|
+
inversePatch: f.inversePatch
|
|
1434
1436
|
});
|
|
1435
1437
|
}
|
|
1436
|
-
for (const [
|
|
1437
|
-
const [
|
|
1438
|
+
for (const [d, f] of i) {
|
|
1439
|
+
const [h, _] = d.split(":"), m = e.rxdb.schemaManager.getEntityMetadata(_, h), y = A(m), N = m.propertyMap.get("id").type === "integer";
|
|
1438
1440
|
let $ = "";
|
|
1439
|
-
N ? $ = Array.from(
|
|
1440
|
-
const S = `DELETE FROM "${
|
|
1441
|
+
N ? $ = Array.from(f).join(",") : $ = Array.from(f).map((L) => I(L)).join(",");
|
|
1442
|
+
const S = `DELETE FROM "${y}" WHERE id in (${$});`;
|
|
1441
1443
|
o.deletes.push({
|
|
1442
1444
|
metadata: m,
|
|
1443
|
-
ids:
|
|
1445
|
+
ids: f,
|
|
1444
1446
|
sql: S,
|
|
1445
|
-
changes: c.get(
|
|
1447
|
+
changes: c.get(d)
|
|
1446
1448
|
});
|
|
1447
1449
|
}
|
|
1448
1450
|
const a = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
|
|
1449
|
-
for (const [
|
|
1450
|
-
const [
|
|
1451
|
-
N ? N.push($) : a.set(
|
|
1452
|
-
let S = l.get(
|
|
1453
|
-
S || (S = /* @__PURE__ */ new Map(), l.set(
|
|
1454
|
-
patch:
|
|
1455
|
-
inversePatch:
|
|
1451
|
+
for (const [d, f] of s.entries()) {
|
|
1452
|
+
const [h, _, m] = ee(d), y = `${h}:${_}`, N = a.get(y), $ = { ...f.patch, id: m };
|
|
1453
|
+
N ? N.push($) : a.set(y, [$]);
|
|
1454
|
+
let S = l.get(y);
|
|
1455
|
+
S || (S = /* @__PURE__ */ new Map(), l.set(y, S)), S.set(m, {
|
|
1456
|
+
patch: f.patch,
|
|
1457
|
+
inversePatch: f.inversePatch
|
|
1456
1458
|
});
|
|
1457
1459
|
}
|
|
1458
|
-
for (const [
|
|
1459
|
-
const [
|
|
1460
|
-
let
|
|
1461
|
-
|
|
1460
|
+
for (const [d, f] of a) {
|
|
1461
|
+
const [h, _] = d.split(":"), m = e.rxdb.schemaManager.getEntityMetadata(_, h);
|
|
1462
|
+
let y = "";
|
|
1463
|
+
f.forEach((N) => {
|
|
1462
1464
|
for (const [O, M] of m.propertyMap)
|
|
1463
1465
|
N[O] === void 0 && M.default !== void 0 && (typeof M.default == "function" ? N[O] = M.default() : N[O] = M.default);
|
|
1464
1466
|
const { sql: $, params: S } = Le(m, N, {
|
|
1465
1467
|
useReplace: !0
|
|
1466
|
-
}), L =
|
|
1467
|
-
|
|
1468
|
+
}), L = k($, S);
|
|
1469
|
+
y += L;
|
|
1468
1470
|
}), o.inserts.push({
|
|
1469
1471
|
metadata: m,
|
|
1470
|
-
ids: new Set(
|
|
1471
|
-
sql:
|
|
1472
|
-
changes: l.get(
|
|
1472
|
+
ids: new Set(f.filter((N) => N != null).map((N) => N.id)),
|
|
1473
|
+
sql: y,
|
|
1474
|
+
changes: l.get(d)
|
|
1473
1475
|
});
|
|
1474
1476
|
}
|
|
1475
|
-
const
|
|
1476
|
-
for (const [
|
|
1477
|
-
const [
|
|
1478
|
-
N ? N.push($) :
|
|
1479
|
-
let S = p.get(
|
|
1480
|
-
S || (S = /* @__PURE__ */ new Map(), p.set(
|
|
1481
|
-
const L = e.rxdb.schemaManager.getEntityMetadata(
|
|
1477
|
+
const u = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map();
|
|
1478
|
+
for (const [d, f] of r.entries()) {
|
|
1479
|
+
const [h, _, m] = ee(d), y = `${h}:${_}`, N = u.get(y), $ = { ...f.patch, id: m };
|
|
1480
|
+
N ? N.push($) : u.set(y, [$]);
|
|
1481
|
+
let S = p.get(y);
|
|
1482
|
+
S || (S = /* @__PURE__ */ new Map(), p.set(y, S));
|
|
1483
|
+
const L = e.rxdb.schemaManager.getEntityMetadata(_, h), O = f.patch ? { ...f.patch } : null, M = f.inversePatch ? { ...f.inversePatch } : null;
|
|
1482
1484
|
L && (O && Object.keys(O).forEach((j) => {
|
|
1483
1485
|
const g = L.propertyMap.get(j);
|
|
1484
|
-
g && (O[j] =
|
|
1486
|
+
g && (O[j] = v(O[j], g));
|
|
1485
1487
|
}), M && Object.keys(M).forEach((j) => {
|
|
1486
1488
|
const g = L.propertyMap.get(j);
|
|
1487
|
-
g && (M[j] =
|
|
1489
|
+
g && (M[j] = v(M[j], g));
|
|
1488
1490
|
})), S.set(m, {
|
|
1489
1491
|
patch: O,
|
|
1490
1492
|
inversePatch: M
|
|
1491
1493
|
});
|
|
1492
1494
|
}
|
|
1493
|
-
for (const [
|
|
1494
|
-
const [
|
|
1495
|
-
let
|
|
1496
|
-
|
|
1495
|
+
for (const [d, f] of u) {
|
|
1496
|
+
const [h, _] = d.split(":"), m = e.rxdb.schemaManager.getEntityMetadata(_, h);
|
|
1497
|
+
let y = "";
|
|
1498
|
+
f.forEach((N) => {
|
|
1497
1499
|
let $;
|
|
1498
1500
|
m.propertyMap.has("updatedAt") && ($ = N.updatedAt);
|
|
1499
1501
|
const { id: S, ...L } = N, { sql: O, params: M } = de(m, { id: S }, L, {
|
|
1500
1502
|
updatedAt: $
|
|
1501
1503
|
});
|
|
1502
|
-
|
|
1504
|
+
y += k(O, M);
|
|
1503
1505
|
}), o.updates.push({
|
|
1504
1506
|
metadata: m,
|
|
1505
|
-
ids: new Set(
|
|
1506
|
-
sql:
|
|
1507
|
-
changes: p.get(
|
|
1507
|
+
ids: new Set(f.filter((N) => N != null).map((N) => N.id)),
|
|
1508
|
+
sql: y,
|
|
1509
|
+
changes: p.get(d)
|
|
1508
1510
|
});
|
|
1509
1511
|
}
|
|
1510
1512
|
return o;
|
|
@@ -1545,14 +1547,14 @@ DROP TRIGGER IF EXISTS ${n}_delete;`;
|
|
|
1545
1547
|
const l = ve(e);
|
|
1546
1548
|
if (l && await a.execute(l), r) {
|
|
1547
1549
|
if (r.deletes.length)
|
|
1548
|
-
for (const
|
|
1549
|
-
await a.execute(
|
|
1550
|
+
for (const u of r.deletes)
|
|
1551
|
+
await a.execute(u.sql);
|
|
1550
1552
|
if (r.inserts.length)
|
|
1551
|
-
for (const
|
|
1552
|
-
|
|
1553
|
+
for (const u of r.inserts)
|
|
1554
|
+
u.successResults = await a.execute(u.sql);
|
|
1553
1555
|
if (r.updates.length)
|
|
1554
|
-
for (const
|
|
1555
|
-
|
|
1556
|
+
for (const u of r.updates)
|
|
1557
|
+
u.successResults = await a.execute(u.sql);
|
|
1556
1558
|
}
|
|
1557
1559
|
s?.updateRxDBChangeSequence !== void 0 && await e.setRxDBChangeSequence(s.updateRxDBChangeSequence);
|
|
1558
1560
|
}, !1);
|
|
@@ -1560,19 +1562,19 @@ DROP TRIGGER IF EXISTS ${n}_delete;`;
|
|
|
1560
1562
|
o = await e.internalQuery(i);
|
|
1561
1563
|
const c = (a, l) => {
|
|
1562
1564
|
if (l.length === 0) return;
|
|
1563
|
-
const
|
|
1564
|
-
const
|
|
1565
|
+
const u = l.map((p) => {
|
|
1566
|
+
const d = { ...p };
|
|
1565
1567
|
return {
|
|
1566
1568
|
namespace: a.namespace,
|
|
1567
1569
|
entity: a.name,
|
|
1568
1570
|
type: "UPDATE",
|
|
1569
1571
|
id: p.id,
|
|
1570
|
-
patch:
|
|
1571
|
-
inversePatch:
|
|
1572
|
+
patch: d,
|
|
1573
|
+
inversePatch: d,
|
|
1572
1574
|
recordAt: p.createdAt
|
|
1573
1575
|
};
|
|
1574
1576
|
});
|
|
1575
|
-
e.rxdb.dispatchEvent(new Y(
|
|
1577
|
+
e.rxdb.dispatchEvent(new Y(u));
|
|
1576
1578
|
};
|
|
1577
1579
|
if (o) {
|
|
1578
1580
|
const a = X(e, H, o, !0), l = T(H);
|
|
@@ -1664,7 +1666,7 @@ const Te = (e, n, t) => {
|
|
|
1664
1666
|
}
|
|
1665
1667
|
}), s;
|
|
1666
1668
|
};
|
|
1667
|
-
class
|
|
1669
|
+
class yn extends He {
|
|
1668
1670
|
constructor(n, t) {
|
|
1669
1671
|
super(n), this.options = t, t.repositories && Object.keys(t.repositories).forEach((r) => {
|
|
1670
1672
|
this.repository(r, t.repositories[r]);
|
|
@@ -1673,7 +1675,7 @@ class _n extends He {
|
|
|
1673
1675
|
this.#t || Xt(this, r);
|
|
1674
1676
|
});
|
|
1675
1677
|
this.#r().then((r) => {
|
|
1676
|
-
r.addEventListener(
|
|
1678
|
+
r.addEventListener(D.SQLITE_INSERT, s), r.addEventListener(D.SQLITE_UPDATE, s), r.addEventListener(D.SQLITE_DELETE, s);
|
|
1677
1679
|
}).catch((r) => console.error("[RxDBAdapterSqlite] Failed to register event listeners", r)), this.repository("Repository", je), this.repository("TreeRepository", tn);
|
|
1678
1680
|
}
|
|
1679
1681
|
// SQLite 客户端缓存
|
|
@@ -1904,7 +1906,7 @@ COMMIT;`), this.#e = !1, this.rxdb.dispatchEvent(pn), i;
|
|
|
1904
1906
|
* @returns
|
|
1905
1907
|
*/
|
|
1906
1908
|
async getRxDBChangeSequence() {
|
|
1907
|
-
const n =
|
|
1909
|
+
const n = _e(B);
|
|
1908
1910
|
return (await this.#i("SELECT seq FROM sqlite_sequence WHERE name = ?", [n])).results[0]?.rows?.[0]?.[0] ?? 0;
|
|
1909
1911
|
}
|
|
1910
1912
|
/**
|
|
@@ -1912,7 +1914,7 @@ COMMIT;`), this.#e = !1, this.rxdb.dispatchEvent(pn), i;
|
|
|
1912
1914
|
* @param sequence 序列值
|
|
1913
1915
|
*/
|
|
1914
1916
|
async setRxDBChangeSequence(n) {
|
|
1915
|
-
const t =
|
|
1917
|
+
const t = _e(B);
|
|
1916
1918
|
await this.#i("UPDATE sqlite_sequence SET seq = ? WHERE name = ?", [n, t]);
|
|
1917
1919
|
}
|
|
1918
1920
|
// ============================================
|
|
@@ -2024,13 +2026,13 @@ COMMIT;`), this.#e = !1, this.rxdb.dispatchEvent(pn), i;
|
|
|
2024
2026
|
const un = new Ue(), dn = new We(), pn = new Ke();
|
|
2025
2027
|
export {
|
|
2026
2028
|
q as ROWID,
|
|
2027
|
-
|
|
2029
|
+
yn as RxDBAdapterSqlite,
|
|
2028
2030
|
R as RxDBAdapterSqliteError,
|
|
2029
2031
|
Wt as SqliteClient,
|
|
2030
2032
|
je as SqliteRepository,
|
|
2031
2033
|
vt as WA_SQLITE_VFS_LIST,
|
|
2032
2034
|
U as buildRuleGroup,
|
|
2033
|
-
|
|
2035
|
+
P as sqliteGetTableName,
|
|
2034
2036
|
A as sqliteGetTableNameByMetadata,
|
|
2035
2037
|
Pt as sqliteLoad
|
|
2036
2038
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rxdb_adapter_mutations.d.ts","sourceRoot":"","sources":["../src/rxdb_adapter_mutations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsC,gBAAgB,EAAQ,MAAM,YAAY,CAAC;AAMpG,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAGhE;;GAEG;AACH,eAAO,MAAM,sBAAsB,GAAU,CAAC,SAAS,UAAU,GAAG,GAAG,EACrE,SAAS,iBAAiB,EAC1B,WAAW,gBAAgB,CAAC,CAAC,CAAC,KAC7B,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"rxdb_adapter_mutations.d.ts","sourceRoot":"","sources":["../src/rxdb_adapter_mutations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsC,gBAAgB,EAAQ,MAAM,YAAY,CAAC;AAMpG,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAGhE;;GAEG;AACH,eAAO,MAAM,sBAAsB,GAAU,CAAC,SAAS,UAAU,GAAG,GAAG,EACrE,SAAS,iBAAiB,EAC1B,WAAW,gBAAgB,CAAC,CAAC,CAAC,KAC7B,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CA+G3B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqlite.utils.d.ts","sourceRoot":"","sources":["../src/sqlite.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,sBAAsB,EAEtB,UAAU,EAEV,wBAAwB,EAExB,UAAU,EACX,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,WAAW,MAAM;;YAE1B,CAAC,MAAM,CAAC;CAC/B,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,YAAY,YACiC,CAAC;AAEvF;;GAEG;AACH,eAAO,MAAM,KAAK,EAAG,SAAkB,CAAC;AAExC;;GAEG;AACH,eAAO,MAAM,0BAA0B,GAAI,UAAU,sBAAsB,KAAG,cAkB7E,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,GACnC,OAAO,UAAU,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,EAC7C,UAAU,sBAAsB,GAAG,wBAAwB,mEA+B5D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,GACnC,OAAO,oBAAoB,GAAG,SAAS,EACvC,UAAU,sBAAsB,GAAG,wBAAwB,QAmC5D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,EAAE,WAAW,MAAM,WAA2B,CAAC;AAE1F;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,WAAW,MAAM,KAAG,CAAC,MAAM,EAAE,MAAM,CAMtE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,GAAI,UAAU,cAAc,WACX,CAAC;AAEzD;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,GAAI,YAAY,UAAU,WACT,CAAC;AAE5D;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAClC,UAAU,cAAc,EACxB,UAAU,sBAAsB,GAAG,sBAAsB,WACf,CAAC;AAE7C;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;gBACnC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAKpD;AAED;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,GAAI,UAAU,cAAc,EAAE,QAAQ,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAmD9F,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,UAAU,cAAc,EAAE,QAAQ,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,wBAqB1F,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,UAAU,cAAc,EAAE,QAAQ,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,wBAwB1F,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,oBAAoB,GAAG,IAAI,GAAG,OAAO,KAAG,oBAO5E,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAkB,KAAK,MAAM,EAAE,SAAQ,GAAG,EAAO,
|
|
1
|
+
{"version":3,"file":"sqlite.utils.d.ts","sourceRoot":"","sources":["../src/sqlite.utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,sBAAsB,EAEtB,UAAU,EAEV,wBAAwB,EAExB,UAAU,EACX,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAEhE;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAAI,WAAW,MAAM;;YAE1B,CAAC,MAAM,CAAC;CAC/B,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,GAAI,QAAQ,YAAY,YACiC,CAAC;AAEvF;;GAEG;AACH,eAAO,MAAM,KAAK,EAAG,SAAkB,CAAC;AAExC;;GAEG;AACH,eAAO,MAAM,0BAA0B,GAAI,UAAU,sBAAsB,KAAG,cAkB7E,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,GACnC,OAAO,UAAU,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,EAC7C,UAAU,sBAAsB,GAAG,wBAAwB,mEA+B5D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,GACnC,OAAO,oBAAoB,GAAG,SAAS,EACvC,UAAU,sBAAsB,GAAG,wBAAwB,QAmC5D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,EAAE,WAAW,MAAM,WAA2B,CAAC;AAE1F;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,WAAW,MAAM,KAAG,CAAC,MAAM,EAAE,MAAM,CAMtE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,0BAA0B,GAAI,UAAU,cAAc,WACX,CAAC;AAEzD;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,GAAI,YAAY,UAAU,WACT,CAAC;AAE5D;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,GAClC,UAAU,cAAc,EACxB,UAAU,sBAAsB,GAAG,sBAAsB,WACf,CAAC;AAE7C;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;gBACnC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;CAKpD;AAED;;;;;GAKG;AACH,eAAO,MAAM,yBAAyB,GAAI,UAAU,cAAc,EAAE,QAAQ,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,QAmD9F,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,UAAU,cAAc,EAAE,QAAQ,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,wBAqB1F,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAAI,UAAU,cAAc,EAAE,QAAQ,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,wBAwB1F,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,oBAAoB,GAAG,IAAI,GAAG,OAAO,KAAG,oBAO5E,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,GAAkB,KAAK,MAAM,EAAE,SAAQ,GAAG,EAAO,WAGhF,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,GACpC,UAAU,cAAc,EACxB,SAAS,MAAM,EAAE,EACjB,MAAM,oBAAoB,EAAE,QAmD7B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,8BAA8B,GAAI,UAAU,cAAc,EAAE,QAAQ,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,wBAqCnG,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiao/rxdb-adapter-sqlite",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -31,11 +31,11 @@
|
|
|
31
31
|
"comlink": "^4.4.2",
|
|
32
32
|
"rxjs": "^7.8.2",
|
|
33
33
|
"wa-sqlite": "https://codeload.github.com/rhashimoto/wa-sqlite/tar.gz/refs/tags/v1.0.9",
|
|
34
|
-
"@aiao/rxdb": "0.0.
|
|
35
|
-
"@aiao/utils": "0.0.
|
|
34
|
+
"@aiao/rxdb": "0.0.16",
|
|
35
|
+
"@aiao/utils": "0.0.16"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"ms": "^2.1.3",
|
|
39
|
-
"@aiao/rxdb-test": "0.0.
|
|
39
|
+
"@aiao/rxdb-test": "0.0.16"
|
|
40
40
|
}
|
|
41
41
|
}
|