interaqt 4.0.2 → 4.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agent/agentspace/knowledge/usage/07-payload-parameters.md +7 -1
- package/agent/agentspace/knowledge/usage/12-data-querying.md +8 -0
- package/dist/builtins/interaction/Payload.d.ts.map +1 -1
- package/dist/builtins/interaction/PayloadItem.d.ts +1 -0
- package/dist/builtins/interaction/PayloadItem.d.ts.map +1 -1
- package/dist/core/BoolExp.d.ts.map +1 -1
- package/dist/index.js +912 -828
- package/dist/index.js.map +1 -1
- package/dist/runtime/Scheduler.d.ts +21 -0
- package/dist/runtime/Scheduler.d.ts.map +1 -1
- package/dist/storage/erstorage/MatchExp.d.ts.map +1 -1
- package/dist/storage/erstorage/RecordQueryAgent.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { AsyncLocalStorage as
|
|
1
|
+
import { AsyncLocalStorage as Ai } from "node:async_hooks";
|
|
2
2
|
import { AsyncLocalStorage as Or } from "async_hooks";
|
|
3
|
-
import { createHash as
|
|
4
|
-
function
|
|
3
|
+
import { createHash as Lr } from "node:crypto";
|
|
4
|
+
function Fr(s) {
|
|
5
5
|
return s !== null && typeof s == "object";
|
|
6
6
|
}
|
|
7
|
-
function
|
|
8
|
-
if (!
|
|
7
|
+
function nt(s) {
|
|
8
|
+
if (!Fr(s)) return !1;
|
|
9
9
|
const e = Object.getPrototypeOf(s);
|
|
10
10
|
return e === null ? !0 : e === Object.prototype || e === null;
|
|
11
11
|
}
|
|
@@ -16,10 +16,10 @@ function $o(s, e) {
|
|
|
16
16
|
return t;
|
|
17
17
|
}
|
|
18
18
|
function Ia(s) {
|
|
19
|
-
return
|
|
19
|
+
return Fr(s) && !nt(s) && typeof s.uuid == "string" && typeof s._type == "string";
|
|
20
20
|
}
|
|
21
21
|
function se(s) {
|
|
22
|
-
return typeof s == "function" ? `func::${s.toString()}` : Array.isArray(s) ? s.map((e) => se(e)) : Ia(s) ? `uuid::${s.uuid}` :
|
|
22
|
+
return typeof s == "function" ? `func::${s.toString()}` : Array.isArray(s) ? s.map((e) => se(e)) : Ia(s) ? `uuid::${s.uuid}` : nt(s) ? Object.fromEntries(Object.entries(s).map(([e, t]) => [e, se(t)])) : s;
|
|
23
23
|
}
|
|
24
24
|
function B(s, e) {
|
|
25
25
|
const t = {};
|
|
@@ -36,17 +36,17 @@ function B(s, e) {
|
|
|
36
36
|
return JSON.stringify(i);
|
|
37
37
|
}
|
|
38
38
|
function M(s) {
|
|
39
|
-
return typeof s == "string" && s.startsWith("func::") ? new Function("return " + s.substring(6))() : Array.isArray(s) ? s.map((e) => M(e)) :
|
|
39
|
+
return typeof s == "string" && s.startsWith("func::") ? new Function("return " + s.substring(6))() : Array.isArray(s) ? s.map((e) => M(e)) : nt(s) ? Object.fromEntries(Object.entries(s).map(([e, t]) => [e, M(t)])) : s;
|
|
40
40
|
}
|
|
41
|
-
function
|
|
41
|
+
function bt(s, e) {
|
|
42
42
|
if (s == null || typeof s != "object") return s;
|
|
43
|
-
if (Array.isArray(s)) return s.map((i) =>
|
|
44
|
-
if (
|
|
45
|
-
return Object.fromEntries(Object.entries(s).map(([i, r]) => [i,
|
|
43
|
+
if (Array.isArray(s)) return s.map((i) => bt(i, e));
|
|
44
|
+
if (nt(s))
|
|
45
|
+
return Object.fromEntries(Object.entries(s).map(([i, r]) => [i, bt(r, e)]));
|
|
46
46
|
if (s instanceof Set)
|
|
47
|
-
return new Set(Array.from(s.values()).map((i) =>
|
|
47
|
+
return new Set(Array.from(s.values()).map((i) => bt(i, e)));
|
|
48
48
|
if (s instanceof Map)
|
|
49
|
-
return new Map(Array.from(s.entries()).map(([i, r]) => [i,
|
|
49
|
+
return new Map(Array.from(s.entries()).map(([i, r]) => [i, bt(r, e)]));
|
|
50
50
|
const t = s;
|
|
51
51
|
return e && t._type && t.constructor?.clone ? t.constructor.clone(s, e) : s;
|
|
52
52
|
}
|
|
@@ -54,13 +54,13 @@ function ko(...s) {
|
|
|
54
54
|
for (const e of s)
|
|
55
55
|
e.instances.length = 0;
|
|
56
56
|
}
|
|
57
|
-
const
|
|
57
|
+
const Ot = /* @__PURE__ */ new Map();
|
|
58
58
|
function Vr(s, e) {
|
|
59
|
-
e && e.isKlass && e.displayName &&
|
|
59
|
+
e && e.isKlass && e.displayName && Ot.set(s, e);
|
|
60
60
|
}
|
|
61
61
|
function To() {
|
|
62
62
|
const s = [];
|
|
63
|
-
return Array.from(
|
|
63
|
+
return Array.from(Ot.entries()).forEach(([, e]) => {
|
|
64
64
|
e.instances && Array.isArray(e.instances) && e.stringify && s.push(...e.instances.map((t) => e.stringify(t)));
|
|
65
65
|
}), `[${s.join(",")}]`;
|
|
66
66
|
}
|
|
@@ -71,7 +71,7 @@ function Co(s) {
|
|
|
71
71
|
function Pa(s) {
|
|
72
72
|
const e = /* @__PURE__ */ new Map();
|
|
73
73
|
for (const u of s) {
|
|
74
|
-
if (!
|
|
74
|
+
if (!Ot.get(u.type))
|
|
75
75
|
throw new Error(`Cannot create instance of unknown class "${u.type}". Make sure the class is registered via registerKlass (see core/init.ts and builtins/init.ts).`);
|
|
76
76
|
if (e.has(u.uuid))
|
|
77
77
|
throw new Error(`Duplicate uuid "${u.uuid}" in serialized instances`);
|
|
@@ -102,7 +102,7 @@ function Pa(s) {
|
|
|
102
102
|
d[m] = f;
|
|
103
103
|
})), l(d);
|
|
104
104
|
}
|
|
105
|
-
if (
|
|
105
|
+
if (nt(u)) {
|
|
106
106
|
const d = {};
|
|
107
107
|
return Object.entries(u).forEach(([h, m]) => a(m, (f) => {
|
|
108
108
|
d[h] = f;
|
|
@@ -115,18 +115,18 @@ function Pa(s) {
|
|
|
115
115
|
const { type: l, options: d = {}, uuid: h, public: m } = u, f = t.get(h);
|
|
116
116
|
if (f) return f;
|
|
117
117
|
i.add(h);
|
|
118
|
-
const p =
|
|
118
|
+
const p = Ot.get(l), y = {};
|
|
119
119
|
let b;
|
|
120
|
-
Object.entries(m || {}).forEach(([w,
|
|
120
|
+
Object.entries(m || {}).forEach(([w, R]) => {
|
|
121
121
|
if (n.has(w)) {
|
|
122
122
|
o.push(() => {
|
|
123
|
-
a(
|
|
123
|
+
a(R, (S) => {
|
|
124
124
|
b[w] = S;
|
|
125
125
|
});
|
|
126
126
|
});
|
|
127
127
|
return;
|
|
128
128
|
}
|
|
129
|
-
a(
|
|
129
|
+
a(R, (S) => {
|
|
130
130
|
b ? b[w] = S : y[w] = S;
|
|
131
131
|
});
|
|
132
132
|
}), b = p.create(y, { ...d, uuid: h }), i.delete(h), t.set(h, b);
|
|
@@ -157,7 +157,7 @@ function _r(s, e, t) {
|
|
|
157
157
|
r.add(a.name);
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
|
-
const
|
|
160
|
+
const ri = /^[a-zA-Z0-9_]+$/;
|
|
161
161
|
class j {
|
|
162
162
|
constructor(e, t) {
|
|
163
163
|
this._type = "Entity", this._options = t, this.uuid = q(t), this.name = e.name, this.properties = e.properties || [], this.computation = e.computation, this.baseEntity = e.baseEntity, this.matchExpression = e.matchExpression, this.inputEntities = e.inputEntities, this.commonProperties = e.commonProperties, this.constraints = e.constraints;
|
|
@@ -177,7 +177,7 @@ class j {
|
|
|
177
177
|
type: "string",
|
|
178
178
|
required: !0,
|
|
179
179
|
constraints: {
|
|
180
|
-
nameFormat: ({ name: e }) =>
|
|
180
|
+
nameFormat: ({ name: e }) => ri.test(e)
|
|
181
181
|
}
|
|
182
182
|
},
|
|
183
183
|
properties: {
|
|
@@ -230,8 +230,8 @@ class j {
|
|
|
230
230
|
};
|
|
231
231
|
}
|
|
232
232
|
static create(e, t) {
|
|
233
|
-
if (typeof e.name != "string" || !
|
|
234
|
-
throw new Error(`Entity name "${e.name}" is invalid. Entity names must match ${
|
|
233
|
+
if (typeof e.name != "string" || !ri.test(e.name))
|
|
234
|
+
throw new Error(`Entity name "${e.name}" is invalid. Entity names must match ${ri} (letters, numbers and underscore only).`);
|
|
235
235
|
if (e.baseEntity && !e.matchExpression)
|
|
236
236
|
throw new Error(`Filtered entity "${e.name}" declares baseEntity but no matchExpression. A filtered entity is a predicate view over its base — declare matchExpression, or use the base entity directly.`);
|
|
237
237
|
if (e.matchExpression && !e.baseEntity)
|
|
@@ -274,9 +274,9 @@ class j {
|
|
|
274
274
|
return this.create(M(t.public), { ...t.options, uuid: t.uuid });
|
|
275
275
|
}
|
|
276
276
|
}
|
|
277
|
-
var
|
|
278
|
-
const
|
|
279
|
-
class
|
|
277
|
+
var Ii = /* @__PURE__ */ ((s) => (s.String = "string", s.Number = "number", s.Boolean = "boolean", s.Timestamp = "timestamp", s))(Ii || {});
|
|
278
|
+
const ai = /^[a-zA-Z0-9_]+$/;
|
|
279
|
+
class Pi {
|
|
280
280
|
constructor(e, t) {
|
|
281
281
|
this._type = "Dictionary", this._options = t, this.uuid = q(t), this.name = e.name, this.type = e.type, this.collection = e.collection ?? !1, this.args = e.args, this.defaultValue = e.defaultValue, this.computation = e.computation;
|
|
282
282
|
}
|
|
@@ -296,14 +296,14 @@ class Ii {
|
|
|
296
296
|
required: !0,
|
|
297
297
|
collection: !1,
|
|
298
298
|
constraints: {
|
|
299
|
-
format: ({ name: e }) =>
|
|
299
|
+
format: ({ name: e }) => ai.test(e)
|
|
300
300
|
}
|
|
301
301
|
},
|
|
302
302
|
type: {
|
|
303
303
|
type: "string",
|
|
304
304
|
required: !0,
|
|
305
305
|
collection: !1,
|
|
306
|
-
options: Array.from(Object.values(
|
|
306
|
+
options: Array.from(Object.values(Ii))
|
|
307
307
|
},
|
|
308
308
|
collection: {
|
|
309
309
|
type: "boolean",
|
|
@@ -329,9 +329,9 @@ class Ii {
|
|
|
329
329
|
};
|
|
330
330
|
}
|
|
331
331
|
static create(e, t) {
|
|
332
|
-
if (typeof e.name != "string" || !
|
|
333
|
-
throw new Error(`Dictionary name "${e.name}" is invalid. Dictionary names must match ${
|
|
334
|
-
const i = new
|
|
332
|
+
if (typeof e.name != "string" || !ai.test(e.name))
|
|
333
|
+
throw new Error(`Dictionary name "${e.name}" is invalid. Dictionary names must match ${ai} (letters, numbers and underscore only).`);
|
|
334
|
+
const i = new Pi(e, t);
|
|
335
335
|
if (this.instances.find((a) => a.uuid === i.uuid))
|
|
336
336
|
throw new Error(`duplicate uuid in options ${i.uuid}, Dictionary`);
|
|
337
337
|
return this.instances.push(i), i;
|
|
@@ -358,7 +358,7 @@ class Ii {
|
|
|
358
358
|
return this.create(M(t.public), { ...t.options, uuid: t.uuid });
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
|
-
const
|
|
361
|
+
const ni = /^[a-zA-Z0-9_]+$/;
|
|
362
362
|
class x {
|
|
363
363
|
constructor(e, t) {
|
|
364
364
|
this._type = "Property", this._options = t, this.uuid = q(t), this.name = e.name, this.type = e.type, this.collection = e.collection, this.defaultValue = e.defaultValue, this.computed = e.computed, this.computation = e.computation;
|
|
@@ -378,13 +378,13 @@ class x {
|
|
|
378
378
|
type: "string",
|
|
379
379
|
required: !0,
|
|
380
380
|
constraints: {
|
|
381
|
-
format: ({ name: e }) =>
|
|
381
|
+
format: ({ name: e }) => ni.test(e)
|
|
382
382
|
}
|
|
383
383
|
},
|
|
384
384
|
type: {
|
|
385
385
|
type: "string",
|
|
386
386
|
required: !0,
|
|
387
|
-
options: () => Object.values(
|
|
387
|
+
options: () => Object.values(Ii)
|
|
388
388
|
},
|
|
389
389
|
collection: {
|
|
390
390
|
type: "boolean",
|
|
@@ -406,8 +406,8 @@ class x {
|
|
|
406
406
|
};
|
|
407
407
|
}
|
|
408
408
|
static create(e, t) {
|
|
409
|
-
if (typeof e.name != "string" || !
|
|
410
|
-
throw new Error(`Property name "${e.name}" is invalid. Property names must match ${
|
|
409
|
+
if (typeof e.name != "string" || !ni.test(e.name))
|
|
410
|
+
throw new Error(`Property name "${e.name}" is invalid. Property names must match ${ni} (letters, numbers and underscore only).`);
|
|
411
411
|
if (e.computed && e.computation)
|
|
412
412
|
throw new Error(`Property "${e.name}" declares both computed and computation. They are competing write channels for the same column (computed re-evaluates on every write and silently overwrites the computation's output) — keep exactly one.`);
|
|
413
413
|
const i = new x(e, t);
|
|
@@ -437,7 +437,7 @@ class x {
|
|
|
437
437
|
return this.create(M(t.public), { ...t.options, uuid: t.uuid });
|
|
438
438
|
}
|
|
439
439
|
}
|
|
440
|
-
const
|
|
440
|
+
const Le = /^[a-zA-Z0-9_]+$/, sr = ["1:1", "1:n", "n:1", "n:n"];
|
|
441
441
|
class Y {
|
|
442
442
|
constructor(e, t) {
|
|
443
443
|
if (this._type = "Relation", this._options = t, this.uuid = q(t), e.inputRelations && e.baseRelation)
|
|
@@ -603,12 +603,12 @@ class Y {
|
|
|
603
603
|
};
|
|
604
604
|
}
|
|
605
605
|
static create(e, t) {
|
|
606
|
-
if (e.name !== void 0 && (typeof e.name != "string" || !
|
|
607
|
-
throw new Error(`Relation name "${e.name}" is invalid. Relation names must match ${
|
|
608
|
-
if (e.sourceProperty !== void 0 && !
|
|
609
|
-
throw new Error(`Relation sourceProperty "${e.sourceProperty}" is invalid. Property names must match ${
|
|
610
|
-
if (e.targetProperty !== void 0 && !
|
|
611
|
-
throw new Error(`Relation targetProperty "${e.targetProperty}" is invalid. Property names must match ${
|
|
606
|
+
if (e.name !== void 0 && (typeof e.name != "string" || !Le.test(e.name)))
|
|
607
|
+
throw new Error(`Relation name "${e.name}" is invalid. Relation names must match ${Le} (letters, numbers and underscore only).`);
|
|
608
|
+
if (e.sourceProperty !== void 0 && !Le.test(e.sourceProperty))
|
|
609
|
+
throw new Error(`Relation sourceProperty "${e.sourceProperty}" is invalid. Property names must match ${Le} (letters, numbers and underscore only).`);
|
|
610
|
+
if (e.targetProperty !== void 0 && !Le.test(e.targetProperty))
|
|
611
|
+
throw new Error(`Relation targetProperty "${e.targetProperty}" is invalid. Property names must match ${Le} (letters, numbers and underscore only).`);
|
|
612
612
|
if (e.type !== void 0 && !sr.includes(e.type))
|
|
613
613
|
throw new Error(`Relation type "${e.type}" is invalid. Valid types: ${sr.map((a) => `'${a}'`).join(", ")}.`);
|
|
614
614
|
_r(e.name ?? `${e.source?.name}_${e.sourceProperty}_${e.targetProperty}_${e.target?.name}`, e.properties, "Relation");
|
|
@@ -653,7 +653,7 @@ class Y {
|
|
|
653
653
|
}
|
|
654
654
|
}
|
|
655
655
|
const Qe = /^[a-zA-Z0-9_]+$/;
|
|
656
|
-
class
|
|
656
|
+
class Kt {
|
|
657
657
|
constructor(e, t) {
|
|
658
658
|
this._type = "UniqueConstraint", this._options = t, this.uuid = q(t), this.name = e.name, this.properties = e.properties, this.where = e.where, this.violationCode = e.violationCode;
|
|
659
659
|
}
|
|
@@ -699,7 +699,7 @@ class Ht {
|
|
|
699
699
|
static create(e, t) {
|
|
700
700
|
if (typeof e.name != "string" || !Qe.test(e.name))
|
|
701
701
|
throw new Error(`UniqueConstraint name "${e.name}" is invalid. Constraint names must match ${Qe} (letters, numbers and underscore only).`);
|
|
702
|
-
const i = new
|
|
702
|
+
const i = new Kt(e, t);
|
|
703
703
|
if (this.instances.find((a) => a.uuid === i.uuid))
|
|
704
704
|
throw new Error(`duplicate uuid in options ${i.uuid}, UniqueConstraint`);
|
|
705
705
|
return this.instances.push(i), i;
|
|
@@ -726,7 +726,7 @@ class Ht {
|
|
|
726
726
|
return this.create(M(t.public), { ...t.options, uuid: t.uuid });
|
|
727
727
|
}
|
|
728
728
|
}
|
|
729
|
-
class
|
|
729
|
+
class Mi {
|
|
730
730
|
constructor(e, t) {
|
|
731
731
|
this._type = "NonNullConstraint", this._options = t, this.uuid = q(t), this.name = e.name, this.property = e.property, this.violationCode = e.violationCode;
|
|
732
732
|
}
|
|
@@ -761,7 +761,7 @@ class Pi {
|
|
|
761
761
|
static create(e, t) {
|
|
762
762
|
if (typeof e.name != "string" || !Qe.test(e.name))
|
|
763
763
|
throw new Error(`NonNullConstraint name "${e.name}" is invalid. Constraint names must match ${Qe} (letters, numbers and underscore only).`);
|
|
764
|
-
const i = new
|
|
764
|
+
const i = new Mi(e, t);
|
|
765
765
|
if (this.instances.find((a) => a.uuid === i.uuid))
|
|
766
766
|
throw new Error(`duplicate uuid in options ${i.uuid}, NonNullConstraint`);
|
|
767
767
|
return this.instances.push(i), i;
|
|
@@ -787,7 +787,7 @@ class Pi {
|
|
|
787
787
|
return this.create(M(t.public), { ...t.options, uuid: t.uuid });
|
|
788
788
|
}
|
|
789
789
|
}
|
|
790
|
-
class
|
|
790
|
+
class Wt {
|
|
791
791
|
constructor(e, t) {
|
|
792
792
|
if (this._type = "Custom", this._options = t, this.uuid = q(t), this.name = e.name, this.dataDeps = e.dataDeps, this.incrementalDataDeps = e.incrementalDataDeps, this.planIncremental = e.planIncremental, this.compute = e.compute, this.incrementalCompute = e.incrementalCompute, this.incrementalPatchCompute = e.incrementalPatchCompute, this.createState = e.createState, this.getInitialValue = e.getInitialValue, this.asyncReturn = e.asyncReturn, this.useLastValue = e.useLastValue, e.concurrency !== void 0 && e.concurrency !== "serializable" && e.concurrency !== "atomic-safe")
|
|
793
793
|
throw new Error(`Invalid Custom concurrency '${e.concurrency}'. Expected 'serializable' or 'atomic-safe'.`);
|
|
@@ -867,7 +867,7 @@ class Kt {
|
|
|
867
867
|
};
|
|
868
868
|
}
|
|
869
869
|
static create(e, t) {
|
|
870
|
-
const i = new
|
|
870
|
+
const i = new Wt(e, t);
|
|
871
871
|
if (this.instances.find((a) => a.uuid === i.uuid))
|
|
872
872
|
throw new Error(`duplicate uuid in options ${i.uuid}, Custom`);
|
|
873
873
|
return this.instances.push(i), i;
|
|
@@ -955,7 +955,7 @@ class We {
|
|
|
955
955
|
return this.create(M(t.public), { ...t.options, uuid: t.uuid });
|
|
956
956
|
}
|
|
957
957
|
}
|
|
958
|
-
class
|
|
958
|
+
class qi {
|
|
959
959
|
constructor(e, t) {
|
|
960
960
|
this._type = "StateTransfer", this._options = t, this.uuid = q(t), this.trigger = e.trigger, this.current = e.current, this.next = e.next, this.computeTarget = e.computeTarget;
|
|
961
961
|
}
|
|
@@ -993,7 +993,7 @@ class Mi {
|
|
|
993
993
|
};
|
|
994
994
|
}
|
|
995
995
|
static create(e, t) {
|
|
996
|
-
const i = new
|
|
996
|
+
const i = new qi(e, t);
|
|
997
997
|
if (this.instances.find((a) => a.uuid === i.uuid))
|
|
998
998
|
throw new Error(`duplicate uuid in options ${i.uuid}, StateTransfer`);
|
|
999
999
|
return this.instances.push(i), i;
|
|
@@ -1020,7 +1020,7 @@ class Mi {
|
|
|
1020
1020
|
return this.create(M(t.public), { ...t.options, uuid: t.uuid });
|
|
1021
1021
|
}
|
|
1022
1022
|
}
|
|
1023
|
-
class
|
|
1023
|
+
class st {
|
|
1024
1024
|
constructor(e, t) {
|
|
1025
1025
|
this._type = "StateMachine", this._options = t, this.uuid = q(t), this.states = e.states, this.transfers = e.transfers, this.initialState = e.initialState;
|
|
1026
1026
|
}
|
|
@@ -1053,7 +1053,7 @@ class nt {
|
|
|
1053
1053
|
};
|
|
1054
1054
|
}
|
|
1055
1055
|
static create(e, t) {
|
|
1056
|
-
const i = new
|
|
1056
|
+
const i = new st(e, t);
|
|
1057
1057
|
if (this.instances.find((a) => a.uuid === i.uuid))
|
|
1058
1058
|
throw new Error(`duplicate uuid in options ${i.uuid}, StateMachine`);
|
|
1059
1059
|
return this.instances.push(i), i;
|
|
@@ -1079,7 +1079,7 @@ class nt {
|
|
|
1079
1079
|
return this.create(M(t.public), { ...t.options, uuid: t.uuid });
|
|
1080
1080
|
}
|
|
1081
1081
|
}
|
|
1082
|
-
class
|
|
1082
|
+
class ot {
|
|
1083
1083
|
constructor(e, t) {
|
|
1084
1084
|
this._type = "WeightedSummation", this._options = t, this.uuid = q(t), this.record = e.record, this.property = e.property, this.direction = e.direction, this.callback = e.callback, this.attributeQuery = e.attributeQuery, this.dataDeps = e.dataDeps;
|
|
1085
1085
|
}
|
|
@@ -1127,7 +1127,7 @@ class st {
|
|
|
1127
1127
|
};
|
|
1128
1128
|
}
|
|
1129
1129
|
static create(e, t) {
|
|
1130
|
-
const i = new
|
|
1130
|
+
const i = new ot(e, t);
|
|
1131
1131
|
if (this.instances.find((a) => a.uuid === i.uuid))
|
|
1132
1132
|
throw new Error(`duplicate uuid in options ${i.uuid}, WeightedSummation`);
|
|
1133
1133
|
return this.instances.push(i), i;
|
|
@@ -1156,7 +1156,7 @@ class st {
|
|
|
1156
1156
|
return this.create(M(t.public), { ...t.options, uuid: t.uuid });
|
|
1157
1157
|
}
|
|
1158
1158
|
}
|
|
1159
|
-
class
|
|
1159
|
+
class ct {
|
|
1160
1160
|
constructor(e, t) {
|
|
1161
1161
|
this._type = "Count", this._options = t, this.uuid = q(t), this.record = e.record, this.property = e.property, this.direction = e.direction, this.callback = e.callback, this.attributeQuery = e.attributeQuery, this.dataDeps = e.dataDeps;
|
|
1162
1162
|
}
|
|
@@ -1204,7 +1204,7 @@ class ot {
|
|
|
1204
1204
|
};
|
|
1205
1205
|
}
|
|
1206
1206
|
static create(e, t) {
|
|
1207
|
-
const i = new
|
|
1207
|
+
const i = new ct(e, t);
|
|
1208
1208
|
if (this.instances.find((a) => a.uuid === i.uuid))
|
|
1209
1209
|
throw new Error(`duplicate uuid in options ${i.uuid}, Count`);
|
|
1210
1210
|
return this.instances.push(i), i;
|
|
@@ -1234,7 +1234,7 @@ class ot {
|
|
|
1234
1234
|
return this.create(M(t.public), { ...t.options, uuid: t.uuid });
|
|
1235
1235
|
}
|
|
1236
1236
|
}
|
|
1237
|
-
class
|
|
1237
|
+
class ut {
|
|
1238
1238
|
constructor(e, t) {
|
|
1239
1239
|
this._type = "Summation", this._options = t, this.uuid = q(t), this.record = e.record, this.property = e.property, this.direction = e.direction, this.attributeQuery = e.attributeQuery;
|
|
1240
1240
|
}
|
|
@@ -1272,7 +1272,7 @@ class ct {
|
|
|
1272
1272
|
};
|
|
1273
1273
|
}
|
|
1274
1274
|
static create(e, t) {
|
|
1275
|
-
const i = new
|
|
1275
|
+
const i = new ut(e, t);
|
|
1276
1276
|
if (this.instances.find((a) => a.uuid === i.uuid))
|
|
1277
1277
|
throw new Error(`duplicate uuid in options ${i.uuid}, Summation`);
|
|
1278
1278
|
return this.instances.push(i), i;
|
|
@@ -1299,7 +1299,7 @@ class ct {
|
|
|
1299
1299
|
return this.create(M(t.public), { ...t.options, uuid: t.uuid });
|
|
1300
1300
|
}
|
|
1301
1301
|
}
|
|
1302
|
-
class
|
|
1302
|
+
class lt {
|
|
1303
1303
|
constructor(e, t) {
|
|
1304
1304
|
this._type = "Average", this._options = t, this.uuid = q(t), this.record = e.record, this.property = e.property, this.direction = e.direction, this.attributeQuery = e.attributeQuery;
|
|
1305
1305
|
}
|
|
@@ -1337,7 +1337,7 @@ class ut {
|
|
|
1337
1337
|
};
|
|
1338
1338
|
}
|
|
1339
1339
|
static create(e, t) {
|
|
1340
|
-
const i = new
|
|
1340
|
+
const i = new lt(e, t);
|
|
1341
1341
|
if (this.instances.find((a) => a.uuid === i.uuid))
|
|
1342
1342
|
throw new Error(`duplicate uuid in options ${i.uuid}, Average`);
|
|
1343
1343
|
return this.instances.push(i), i;
|
|
@@ -1364,7 +1364,7 @@ class ut {
|
|
|
1364
1364
|
return this.create(M(t.public), { ...t.options, uuid: t.uuid });
|
|
1365
1365
|
}
|
|
1366
1366
|
}
|
|
1367
|
-
class
|
|
1367
|
+
class dt {
|
|
1368
1368
|
constructor(e, t) {
|
|
1369
1369
|
this._type = "Every", this._options = t, this.uuid = q(t), this.record = e.record, this.property = e.property, this.direction = e.direction, this.callback = e.callback, this.attributeQuery = e.attributeQuery, this.dataDeps = e.dataDeps, this.notEmpty = e.notEmpty;
|
|
1370
1370
|
}
|
|
@@ -1417,7 +1417,7 @@ class lt {
|
|
|
1417
1417
|
};
|
|
1418
1418
|
}
|
|
1419
1419
|
static create(e, t) {
|
|
1420
|
-
const i = new
|
|
1420
|
+
const i = new dt(e, t);
|
|
1421
1421
|
if (this.instances.find((a) => a.uuid === i.uuid))
|
|
1422
1422
|
throw new Error(`duplicate uuid in options ${i.uuid}, Every`);
|
|
1423
1423
|
return this.instances.push(i), i;
|
|
@@ -1443,7 +1443,7 @@ class lt {
|
|
|
1443
1443
|
return this.create(M(t.public), { ...t.options, uuid: t.uuid });
|
|
1444
1444
|
}
|
|
1445
1445
|
}
|
|
1446
|
-
class
|
|
1446
|
+
class ht {
|
|
1447
1447
|
constructor(e, t) {
|
|
1448
1448
|
this._type = "Any", this._options = t, this.uuid = q(t), this.record = e.record, this.property = e.property, this.direction = e.direction, this.callback = e.callback, this.attributeQuery = e.attributeQuery, this.dataDeps = e.dataDeps;
|
|
1449
1449
|
}
|
|
@@ -1491,7 +1491,7 @@ class dt {
|
|
|
1491
1491
|
};
|
|
1492
1492
|
}
|
|
1493
1493
|
static create(e, t) {
|
|
1494
|
-
const i = new
|
|
1494
|
+
const i = new ht(e, t);
|
|
1495
1495
|
if (this.instances.find((a) => a.uuid === i.uuid))
|
|
1496
1496
|
throw new Error(`duplicate uuid in options ${i.uuid}, Any`);
|
|
1497
1497
|
return this.instances.push(i), i;
|
|
@@ -1520,7 +1520,7 @@ class dt {
|
|
|
1520
1520
|
return this.create(M(t.public), { ...t.options, uuid: t.uuid });
|
|
1521
1521
|
}
|
|
1522
1522
|
}
|
|
1523
|
-
class
|
|
1523
|
+
class zt {
|
|
1524
1524
|
constructor(e, t) {
|
|
1525
1525
|
this._type = "Transform", this._options = t, this.uuid = q(t), this.record = e.record, this.eventDeps = e.eventDeps, this.attributeQuery = e.attributeQuery, this.callback = e.callback;
|
|
1526
1526
|
}
|
|
@@ -1558,7 +1558,7 @@ class Wt {
|
|
|
1558
1558
|
};
|
|
1559
1559
|
}
|
|
1560
1560
|
static create(e, t) {
|
|
1561
|
-
const i = new
|
|
1561
|
+
const i = new zt(e, t);
|
|
1562
1562
|
if (this.instances.find((a) => a.uuid === i.uuid))
|
|
1563
1563
|
throw new Error(`duplicate uuid in options ${i.uuid}, Transform`);
|
|
1564
1564
|
return this.instances.push(i), i;
|
|
@@ -1585,7 +1585,7 @@ class Wt {
|
|
|
1585
1585
|
return this.create(M(t.public), { ...t.options, uuid: t.uuid });
|
|
1586
1586
|
}
|
|
1587
1587
|
}
|
|
1588
|
-
class
|
|
1588
|
+
class pt {
|
|
1589
1589
|
constructor(e, t) {
|
|
1590
1590
|
this._type = "RealTimeValue", this._options = t, this.uuid = q(t), this.attributeQuery = e.attributeQuery, this.dataDeps = e.dataDeps, this.nextRecomputeTime = e.nextRecomputeTime, this.callback = e.callback;
|
|
1591
1591
|
}
|
|
@@ -1623,7 +1623,7 @@ class ht {
|
|
|
1623
1623
|
};
|
|
1624
1624
|
}
|
|
1625
1625
|
static create(e, t) {
|
|
1626
|
-
const i = new
|
|
1626
|
+
const i = new pt(e, t);
|
|
1627
1627
|
if (this.instances.find((a) => a.uuid === i.uuid))
|
|
1628
1628
|
throw new Error(`duplicate uuid in options ${i.uuid}, RealTimeValue`);
|
|
1629
1629
|
return this.instances.push(i), i;
|
|
@@ -1648,7 +1648,7 @@ class ht {
|
|
|
1648
1648
|
return this.create(M(t.public), { ...t.options, uuid: t.uuid });
|
|
1649
1649
|
}
|
|
1650
1650
|
}
|
|
1651
|
-
class
|
|
1651
|
+
class Di {
|
|
1652
1652
|
constructor(e, t) {
|
|
1653
1653
|
this._type = "SideEffect", this._options = t, this.uuid = q(t), this.name = e.name, this.handle = e.handle;
|
|
1654
1654
|
}
|
|
@@ -1676,7 +1676,7 @@ class qi {
|
|
|
1676
1676
|
};
|
|
1677
1677
|
}
|
|
1678
1678
|
static create(e, t) {
|
|
1679
|
-
const i = new
|
|
1679
|
+
const i = new Di(e, t);
|
|
1680
1680
|
if (this.instances.find((a) => a.uuid === i.uuid))
|
|
1681
1681
|
throw new Error(`duplicate uuid in options ${i.uuid}, SideEffect`);
|
|
1682
1682
|
return this.instances.push(i), i;
|
|
@@ -1701,7 +1701,7 @@ class qi {
|
|
|
1701
1701
|
return this.create(M(t.public), { ...t.options, uuid: t.uuid });
|
|
1702
1702
|
}
|
|
1703
1703
|
}
|
|
1704
|
-
class
|
|
1704
|
+
class Gt {
|
|
1705
1705
|
constructor(e, t) {
|
|
1706
1706
|
this._type = "BoolAtomData", this._options = t, this.uuid = q(t), this.type = e.type || "atom", this.data = e.data;
|
|
1707
1707
|
}
|
|
@@ -1730,7 +1730,7 @@ class zt {
|
|
|
1730
1730
|
};
|
|
1731
1731
|
}
|
|
1732
1732
|
static create(e, t) {
|
|
1733
|
-
const i = new
|
|
1733
|
+
const i = new Gt(e, t);
|
|
1734
1734
|
if (this.instances.find((a) => a.uuid === i.uuid))
|
|
1735
1735
|
throw new Error(`duplicate uuid in options ${i.uuid}, BoolAtomData`);
|
|
1736
1736
|
return this.instances.push(i), i;
|
|
@@ -1755,7 +1755,7 @@ class zt {
|
|
|
1755
1755
|
return this.create(M(t.public), { ...t.options, uuid: t.uuid });
|
|
1756
1756
|
}
|
|
1757
1757
|
}
|
|
1758
|
-
class
|
|
1758
|
+
class Jt {
|
|
1759
1759
|
constructor(e, t) {
|
|
1760
1760
|
this._type = "BoolExpressionData", this._options = t, this.uuid = q(t), this.type = e.type || "expression", this.operator = e.operator || "and", this.left = e.left, this.right = e.right;
|
|
1761
1761
|
}
|
|
@@ -1796,7 +1796,7 @@ class Gt {
|
|
|
1796
1796
|
};
|
|
1797
1797
|
}
|
|
1798
1798
|
static create(e, t) {
|
|
1799
|
-
const i = new
|
|
1799
|
+
const i = new Jt(e, t);
|
|
1800
1800
|
if (this.instances.find((a) => a.uuid === i.uuid))
|
|
1801
1801
|
throw new Error(`duplicate uuid in options ${i.uuid}, BoolExpressionData`);
|
|
1802
1802
|
return this.instances.push(i), i;
|
|
@@ -1951,6 +1951,8 @@ class k {
|
|
|
1951
1951
|
throw new Error("BoolExp.evaluate received a Promise from the atom handler. Use evaluateAsync for async handlers.");
|
|
1952
1952
|
if (typeof n == "string")
|
|
1953
1953
|
return { data: a, inverse: i, stack: t, error: n };
|
|
1954
|
+
if (typeof n != "boolean")
|
|
1955
|
+
return { data: a, inverse: i, stack: t, error: `atom handler returned ${n === void 0 ? "undefined" : JSON.stringify(n)} (${typeof n}); it must explicitly return a boolean or an error string (did you forget a return statement, or a !! coercion?)` };
|
|
1954
1956
|
const o = n;
|
|
1955
1957
|
return o && !i || !o && i ? !0 : { data: a, inverse: i, stack: t, error: "atom evaluate error" };
|
|
1956
1958
|
}
|
|
@@ -1975,6 +1977,8 @@ class k {
|
|
|
1975
1977
|
const a = this.raw.data, n = await e(a);
|
|
1976
1978
|
if (typeof n == "string")
|
|
1977
1979
|
return { data: a, inverse: i, stack: t, error: n };
|
|
1980
|
+
if (typeof n != "boolean")
|
|
1981
|
+
return { data: a, inverse: i, stack: t, error: `atom handler returned ${n === void 0 ? "undefined" : JSON.stringify(n)} (${typeof n}); it must explicitly return a boolean or an error string (did you forget a return statement, or a !! coercion?)` };
|
|
1978
1982
|
const o = n;
|
|
1979
1983
|
return o && !i || !o && i ? !0 : { data: a, inverse: i, stack: t, error: "atom evaluate error" };
|
|
1980
1984
|
}
|
|
@@ -2005,7 +2009,7 @@ function Br(s) {
|
|
|
2005
2009
|
}
|
|
2006
2010
|
return e;
|
|
2007
2011
|
}
|
|
2008
|
-
function
|
|
2012
|
+
function kt(s, e) {
|
|
2009
2013
|
if (typeof s != "string" || !s || s.includes("..") || s.startsWith(".") || s.endsWith("."))
|
|
2010
2014
|
throw new Error(`${e} must declare a stable path`);
|
|
2011
2015
|
if (s.split(".").some((i) => !$e.test(i)))
|
|
@@ -2016,16 +2020,16 @@ function qa(s, e) {
|
|
|
2016
2020
|
if (t.length !== 1 && !(t.length === 2 && t[1] === "id"))
|
|
2017
2021
|
throw new Error(`${e} only supports top-level fields and ref id paths`);
|
|
2018
2022
|
}
|
|
2019
|
-
function
|
|
2023
|
+
function mi(s) {
|
|
2020
2024
|
if (s === null || typeof s != "object") return JSON.stringify(s);
|
|
2021
|
-
if (Array.isArray(s)) return `[${s.map(
|
|
2025
|
+
if (Array.isArray(s)) return `[${s.map(mi).join(",")}]`;
|
|
2022
2026
|
const e = s;
|
|
2023
|
-
return `{${Object.keys(e).sort().map((t) => `${JSON.stringify(t)}:${
|
|
2027
|
+
return `{${Object.keys(e).sort().map((t) => `${JSON.stringify(t)}:${mi(e[t])}`).join(",")}}`;
|
|
2024
2028
|
}
|
|
2025
2029
|
function Da(s) {
|
|
2026
2030
|
return JSON.parse(JSON.stringify(s));
|
|
2027
2031
|
}
|
|
2028
|
-
function
|
|
2032
|
+
function Re(s) {
|
|
2029
2033
|
if (s === void 0) return;
|
|
2030
2034
|
const e = s instanceof k ? s.raw : s;
|
|
2031
2035
|
if (!k.isExpressionData(e))
|
|
@@ -2033,13 +2037,13 @@ function Ne(s) {
|
|
|
2033
2037
|
return Da(e);
|
|
2034
2038
|
}
|
|
2035
2039
|
function or(s) {
|
|
2036
|
-
return
|
|
2040
|
+
return mi(Re(s));
|
|
2037
2041
|
}
|
|
2038
2042
|
function Oa(s) {
|
|
2039
|
-
return
|
|
2043
|
+
return Re(s.initializeFrom?.match ?? s.match);
|
|
2040
2044
|
}
|
|
2041
|
-
function
|
|
2042
|
-
const t =
|
|
2045
|
+
function La(s, e) {
|
|
2046
|
+
const t = Re(s);
|
|
2043
2047
|
if (!t) return;
|
|
2044
2048
|
const i = (r) => {
|
|
2045
2049
|
if (r.type === "atom") {
|
|
@@ -2056,8 +2060,8 @@ function Fa(s, e) {
|
|
|
2056
2060
|
i(t);
|
|
2057
2061
|
}
|
|
2058
2062
|
function cr(s, e) {
|
|
2059
|
-
|
|
2060
|
-
if (
|
|
2063
|
+
La(s, (t) => {
|
|
2064
|
+
if (kt(t.key, `${e} atom key`), qa(t.key, `${e} atom key`), !Array.isArray(t.value) || t.value.length !== 2)
|
|
2061
2065
|
throw new Error(`${e} atom value must be [operator, operand]`);
|
|
2062
2066
|
const [i, r] = t.value;
|
|
2063
2067
|
if (!["=", "!=", "is null", "is not null", "in", "not in"].includes(i))
|
|
@@ -2072,17 +2076,17 @@ function cr(s, e) {
|
|
|
2072
2076
|
}
|
|
2073
2077
|
});
|
|
2074
2078
|
}
|
|
2075
|
-
function
|
|
2079
|
+
function Fa(s) {
|
|
2076
2080
|
return s.type === "ref" ? { ...s, base: Br(s.base) } : s;
|
|
2077
2081
|
}
|
|
2078
2082
|
function Va(s) {
|
|
2079
2083
|
return s ? { ...s, record: Br(s.record) } : void 0;
|
|
2080
2084
|
}
|
|
2081
|
-
class
|
|
2085
|
+
class et {
|
|
2082
2086
|
constructor(e, t) {
|
|
2083
|
-
this._type = "ScopedSequence",
|
|
2087
|
+
this._type = "ScopedSequence", et.validate(e), this._options = t, this.uuid = q(t), this.name = e.name, this.scope = e.scope, this.match = Re(e.match), this.initialValue = e.initialValue, this.step = e.step, this.allowManualValue = e.allowManualValue, this.initializeFrom = e.initializeFrom ? {
|
|
2084
2088
|
...e.initializeFrom,
|
|
2085
|
-
match:
|
|
2089
|
+
match: Re(e.initializeFrom.match)
|
|
2086
2090
|
} : void 0;
|
|
2087
2091
|
}
|
|
2088
2092
|
static {
|
|
@@ -2133,7 +2137,7 @@ class Ze {
|
|
|
2133
2137
|
};
|
|
2134
2138
|
}
|
|
2135
2139
|
static create(e, t) {
|
|
2136
|
-
const i = new
|
|
2140
|
+
const i = new et(e, t);
|
|
2137
2141
|
if (this.instances.find((a) => a.uuid === i.uuid))
|
|
2138
2142
|
throw new Error(`duplicate uuid in options ${i.uuid}, ScopedSequence`);
|
|
2139
2143
|
return this.instances.push(i), i;
|
|
@@ -2149,7 +2153,7 @@ class Ze {
|
|
|
2149
2153
|
throw new Error(`ScopedSequence scope item name "${i.name}" must match ${$e}`);
|
|
2150
2154
|
if (t.has(i.name))
|
|
2151
2155
|
throw new Error(`ScopedSequence scope item name "${i.name}" is duplicated`);
|
|
2152
|
-
if (t.add(i.name),
|
|
2156
|
+
if (t.add(i.name), kt(i.path, `ScopedSequence scope item "${i.name}"`), i.type === "ref" && !i.base?.name)
|
|
2153
2157
|
throw new Error(`ScopedSequence ref scope item "${i.name}" must declare a base entity`);
|
|
2154
2158
|
}
|
|
2155
2159
|
if (e.step !== void 0 && (!Number.isInteger(e.step) || e.step <= 0))
|
|
@@ -2159,7 +2163,7 @@ class Ze {
|
|
|
2159
2163
|
if (cr(e.match, "ScopedSequence.match"), e.initializeFrom) {
|
|
2160
2164
|
if (!e.initializeFrom.record?.name)
|
|
2161
2165
|
throw new Error("ScopedSequence initializeFrom.record must declare a source entity");
|
|
2162
|
-
if (
|
|
2166
|
+
if (kt(e.initializeFrom.valuePath, "ScopedSequence initializeFrom.valuePath"), e.initializeFrom.aggregate !== "max")
|
|
2163
2167
|
throw new Error('ScopedSequence initializeFrom currently supports only aggregate "max"');
|
|
2164
2168
|
if (!Array.isArray(e.initializeFrom.scope))
|
|
2165
2169
|
throw new Error("ScopedSequence initializeFrom.scope must be an array");
|
|
@@ -2171,7 +2175,7 @@ class Ze {
|
|
|
2171
2175
|
throw new Error(`ScopedSequence initializeFrom.scope item name "${a.name}" is duplicated`);
|
|
2172
2176
|
if (r.add(a.name), !i.has(a.name))
|
|
2173
2177
|
throw new Error(`ScopedSequence initializeFrom.scope item "${a.name}" is not declared in scope`);
|
|
2174
|
-
|
|
2178
|
+
kt(a.path, `ScopedSequence initializeFrom.scope item "${a.name}"`);
|
|
2175
2179
|
}
|
|
2176
2180
|
for (const a of i)
|
|
2177
2181
|
if (!r.has(a))
|
|
@@ -2189,7 +2193,7 @@ class Ze {
|
|
|
2189
2193
|
return this.create({
|
|
2190
2194
|
name: e.name,
|
|
2191
2195
|
scope: [...e.scope],
|
|
2192
|
-
match:
|
|
2196
|
+
match: Re(e.match),
|
|
2193
2197
|
initialValue: e.initialValue,
|
|
2194
2198
|
step: e.step,
|
|
2195
2199
|
allowManualValue: e.allowManualValue,
|
|
@@ -2206,12 +2210,12 @@ class Ze {
|
|
|
2206
2210
|
const t = JSON.parse(e);
|
|
2207
2211
|
return this.create({
|
|
2208
2212
|
...t.public,
|
|
2209
|
-
scope: t.public.scope.map(
|
|
2213
|
+
scope: t.public.scope.map(Fa),
|
|
2210
2214
|
initializeFrom: Va(t.public.initializeFrom)
|
|
2211
2215
|
}, { ...t.options, uuid: t.uuid });
|
|
2212
2216
|
}
|
|
2213
2217
|
}
|
|
2214
|
-
class
|
|
2218
|
+
class Oi {
|
|
2215
2219
|
constructor(e, t) {
|
|
2216
2220
|
this._type = "EventSource", this._options = t, this.uuid = q(t), this.name = e.name, this.entity = e.entity, this.guard = e.guard, this.mapEventData = e.mapEventData, this.resolve = e.resolve, this.afterDispatch = e.afterDispatch, this.postCommit = e.postCommit;
|
|
2217
2221
|
}
|
|
@@ -2264,7 +2268,7 @@ class Di {
|
|
|
2264
2268
|
};
|
|
2265
2269
|
}
|
|
2266
2270
|
static create(e, t) {
|
|
2267
|
-
const i = new
|
|
2271
|
+
const i = new Oi(e, t);
|
|
2268
2272
|
if (this.instances.find((a) => a.uuid === i.uuid))
|
|
2269
2273
|
throw new Error(`duplicate uuid in options ${i.uuid}, EventSource`);
|
|
2270
2274
|
return this.instances.push(i), i;
|
|
@@ -2302,31 +2306,31 @@ const _a = [
|
|
|
2302
2306
|
j,
|
|
2303
2307
|
Y,
|
|
2304
2308
|
x,
|
|
2305
|
-
Ht,
|
|
2306
|
-
Pi,
|
|
2307
2309
|
Kt,
|
|
2308
|
-
We,
|
|
2309
2310
|
Mi,
|
|
2310
|
-
|
|
2311
|
+
Wt,
|
|
2312
|
+
We,
|
|
2313
|
+
qi,
|
|
2311
2314
|
st,
|
|
2312
2315
|
ot,
|
|
2313
2316
|
ct,
|
|
2314
2317
|
ut,
|
|
2315
2318
|
lt,
|
|
2316
2319
|
dt,
|
|
2317
|
-
Wt,
|
|
2318
2320
|
ht,
|
|
2319
|
-
qi,
|
|
2320
|
-
Ii,
|
|
2321
|
-
Ze,
|
|
2322
2321
|
zt,
|
|
2322
|
+
pt,
|
|
2323
|
+
Di,
|
|
2324
|
+
Pi,
|
|
2325
|
+
et,
|
|
2323
2326
|
Gt,
|
|
2324
|
-
|
|
2327
|
+
Jt,
|
|
2328
|
+
Oi
|
|
2325
2329
|
];
|
|
2326
2330
|
_a.forEach((s) => {
|
|
2327
2331
|
s && s.displayName && Vr(s.displayName, s);
|
|
2328
2332
|
});
|
|
2329
|
-
class
|
|
2333
|
+
class fi {
|
|
2330
2334
|
constructor(e = [], t = []) {
|
|
2331
2335
|
this.clonedEntities = /* @__PURE__ */ new Map(), this.clonedRelations = /* @__PURE__ */ new Map(), this.reverseEntityMap = /* @__PURE__ */ new Map(), this.reverseRelationMap = /* @__PURE__ */ new Map(), this.originalEntities = [...e], this.originalRelations = [...t], (e.length > 0 || t.length > 0) && this.initializeClones();
|
|
2332
2336
|
}
|
|
@@ -2541,7 +2545,7 @@ function T(s, e) {
|
|
|
2541
2545
|
if (!s)
|
|
2542
2546
|
throw new Error(e);
|
|
2543
2547
|
}
|
|
2544
|
-
function
|
|
2548
|
+
function wt(s, e, t) {
|
|
2545
2549
|
const i = [...e];
|
|
2546
2550
|
let r = s, a;
|
|
2547
2551
|
const n = i.pop();
|
|
@@ -2549,14 +2553,14 @@ function bt(s, e, t) {
|
|
|
2549
2553
|
r[a] || (r[a] = {}), r = r[a];
|
|
2550
2554
|
return r[n] = t, !0;
|
|
2551
2555
|
}
|
|
2552
|
-
function
|
|
2553
|
-
return JSON.stringify(
|
|
2556
|
+
function Tt(s) {
|
|
2557
|
+
return JSON.stringify(yi(s));
|
|
2554
2558
|
}
|
|
2555
|
-
function
|
|
2556
|
-
if (Array.isArray(s)) return s.map((e) =>
|
|
2559
|
+
function yi(s) {
|
|
2560
|
+
if (Array.isArray(s)) return s.map((e) => yi(e));
|
|
2557
2561
|
if (s !== null && typeof s == "object" && Object.getPrototypeOf(s) === Object.prototype) {
|
|
2558
2562
|
const e = s;
|
|
2559
|
-
return Object.fromEntries(Object.keys(e).sort().map((t) => [t,
|
|
2563
|
+
return Object.fromEntries(Object.keys(e).sort().map((t) => [t, yi(e[t])]));
|
|
2560
2564
|
}
|
|
2561
2565
|
return s;
|
|
2562
2566
|
}
|
|
@@ -2841,7 +2845,7 @@ class E {
|
|
|
2841
2845
|
u = [];
|
|
2842
2846
|
} else if (a?.toLowerCase() === "json" && (i[0] === "=" || i[0] === "!=")) {
|
|
2843
2847
|
const h = o?.parseMatchExpression?.(t, i, r, a, e, this.getReferenceFieldValue.bind(this), n);
|
|
2844
|
-
h ? (c = h.fieldValue, u = h.fieldParams || []) : (c = `${i[0]} ${n()}`, u = [
|
|
2848
|
+
h ? (c = h.fieldValue, u = h.fieldParams || []) : (c = `${i[0]} ${n()}`, u = [Tt(i[1])]);
|
|
2845
2849
|
} else
|
|
2846
2850
|
c = `${i[0]} ${n()}`, u = [i[1]];
|
|
2847
2851
|
else if (d === "is null" || d === "is not null") {
|
|
@@ -2859,7 +2863,7 @@ class E {
|
|
|
2859
2863
|
c = a?.toLowerCase() === "json" ? "IS NOT NULL AND 1=0" : "IN (NULL) AND 1=0", u = [];
|
|
2860
2864
|
else if (a?.toLowerCase() === "json") {
|
|
2861
2865
|
const h = o?.parseMatchExpression?.(t, i, r, a, e, this.getReferenceFieldValue.bind(this), n);
|
|
2862
|
-
h ? (c = h.fieldValue, u = h.fieldParams || []) : (c = `IN (${i[1].map((m) => n()).join(",")})`, u = i[1].map((m) =>
|
|
2866
|
+
h ? (c = h.fieldValue, u = h.fieldParams || []) : (c = `IN (${i[1].map((m) => n()).join(",")})`, u = i[1].map((m) => Tt(m)));
|
|
2863
2867
|
} else
|
|
2864
2868
|
c = `IN (${i[1].map((h) => n()).join(",")})`, u = i[1];
|
|
2865
2869
|
} else if (d === "not in") {
|
|
@@ -2869,12 +2873,16 @@ class E {
|
|
|
2869
2873
|
c = a?.toLowerCase() === "json" ? "IS NULL OR 1=1" : "NOT IN (NULL) OR 1=1", u = [];
|
|
2870
2874
|
else if (a?.toLowerCase() === "json") {
|
|
2871
2875
|
const h = o?.parseMatchExpression?.(t, i, r, a, e, this.getReferenceFieldValue.bind(this), n);
|
|
2872
|
-
h ? (c = h.fieldValue, u = h.fieldParams || []) : (c = `NOT IN (${i[1].map((m) => n()).join(",")})`, u = i[1].map((m) =>
|
|
2876
|
+
h ? (c = h.fieldValue, u = h.fieldParams || []) : (c = `NOT IN (${i[1].map((m) => n()).join(",")})`, u = i[1].map((m) => Tt(m)));
|
|
2873
2877
|
} else
|
|
2874
2878
|
c = `NOT IN (${i[1].map((h) => n()).join(",")})`, u = i[1];
|
|
2875
2879
|
} else if (d === "between") {
|
|
2876
2880
|
if (!Array.isArray(i[1]) || i[1].length !== 2)
|
|
2877
2881
|
throw new Error(`match operator 'between' requires a two-element array value [min, max], got: ${JSON.stringify(i[1])} for key "${t}"`);
|
|
2882
|
+
if (!e && (i[1][0] === null || i[1][0] === void 0 || i[1][1] === null || i[1][1] === void 0))
|
|
2883
|
+
throw new Error(
|
|
2884
|
+
`match operator 'between' does not support null/undefined bounds (got: ${JSON.stringify(i[1])} for key "${t}"). SQL evaluates BETWEEN with a NULL bound as UNKNOWN and silently matches no rows. Use ['>=', min] or ['<=', max] for a single-bounded range.`
|
|
2885
|
+
);
|
|
2878
2886
|
if (e) {
|
|
2879
2887
|
const h = this.getReferenceFieldValue(i[1][0]), m = this.getReferenceFieldValue(i[1][1]);
|
|
2880
2888
|
c = `BETWEEN "${h.split(".")[0]}"."${h.split(".")[1]}" AND "${m.split(".")[0]}"."${m.split(".")[1]}"`, u = [];
|
|
@@ -3218,7 +3226,7 @@ class K {
|
|
|
3218
3226
|
let f = l, p = d;
|
|
3219
3227
|
if (m.isLinkFiltered()) {
|
|
3220
3228
|
f = m.getBaseAttributeInfo().attributeName;
|
|
3221
|
-
const b = d.matchExpression, g = m.getLinkInfo().getBaseLinkInfo(),
|
|
3229
|
+
const b = d.matchExpression, g = m.getLinkInfo().getBaseLinkInfo(), R = new E(g.name, this.map, m.getMatchExpression()).rebase(m.isRecordSource() ? "target" : "source"), S = b ? R.and(b) : R;
|
|
3222
3230
|
p = {
|
|
3223
3231
|
...d,
|
|
3224
3232
|
matchExpression: S.data
|
|
@@ -3803,22 +3811,22 @@ class ja {
|
|
|
3803
3811
|
* 这是一个辅助方法,实际的删除逻辑在 RecordQueryAgent 中
|
|
3804
3812
|
*/
|
|
3805
3813
|
}
|
|
3806
|
-
const
|
|
3807
|
-
function
|
|
3808
|
-
let e =
|
|
3809
|
-
return e || (e = /* @__PURE__ */ new Map(),
|
|
3814
|
+
const si = /* @__PURE__ */ new WeakMap(), gi = /* @__PURE__ */ new WeakMap(), Fe = /* @__PURE__ */ new WeakMap();
|
|
3815
|
+
function Ct(s) {
|
|
3816
|
+
let e = gi.get(s);
|
|
3817
|
+
return e || (e = /* @__PURE__ */ new Map(), gi.set(s, e)), e;
|
|
3810
3818
|
}
|
|
3811
|
-
function
|
|
3819
|
+
function oi(s, e) {
|
|
3812
3820
|
return `${s}:${e}`;
|
|
3813
3821
|
}
|
|
3814
3822
|
function ur(s, e) {
|
|
3815
|
-
!s || !e || s === e ||
|
|
3823
|
+
!s || !e || s === e || gi.set(s, Ct(e));
|
|
3816
3824
|
}
|
|
3817
3825
|
class Ha {
|
|
3818
3826
|
constructor(e, t) {
|
|
3819
3827
|
this.map = e, this.queryAgent = t;
|
|
3820
|
-
const i =
|
|
3821
|
-
i ? this.dependencies = i : (this.dependencies = /* @__PURE__ */ new Map(),
|
|
3828
|
+
const i = si.get(e.data);
|
|
3829
|
+
i ? this.dependencies = i : (this.dependencies = /* @__PURE__ */ new Map(), si.set(e.data, this.dependencies), this.initializeDependencies());
|
|
3822
3830
|
}
|
|
3823
3831
|
/**
|
|
3824
3832
|
* 初始化所有 filtered entity 的依赖关系(每个 MapData 只计算一次)
|
|
@@ -3894,7 +3902,7 @@ class Ha {
|
|
|
3894
3902
|
* 清除所有依赖关系(同时失效按 MapData 共享的缓存)
|
|
3895
3903
|
*/
|
|
3896
3904
|
clear() {
|
|
3897
|
-
this.dependencies.clear(),
|
|
3905
|
+
this.dependencies.clear(), si.delete(this.map.data);
|
|
3898
3906
|
}
|
|
3899
3907
|
// ============ 成员资格求值(唯一真相源:SQL 谓词求值) ============
|
|
3900
3908
|
/**
|
|
@@ -4003,7 +4011,7 @@ class Ha {
|
|
|
4003
4011
|
*/
|
|
4004
4012
|
async settleMembershipChecks(e, t) {
|
|
4005
4013
|
if (!t || !e.length) return;
|
|
4006
|
-
const i =
|
|
4014
|
+
const i = Ct(t);
|
|
4007
4015
|
for (const r of e) {
|
|
4008
4016
|
const { dependency: a, recordIds: n, beforeMemberIds: o } = r;
|
|
4009
4017
|
if (!n.length) continue;
|
|
@@ -4021,7 +4029,7 @@ class Ha {
|
|
|
4021
4029
|
a.matchExpression
|
|
4022
4030
|
);
|
|
4023
4031
|
for (const d of u) {
|
|
4024
|
-
const h =
|
|
4032
|
+
const h = oi(a.filteredEntityName, d.id), m = l.has(d.id), f = i.has(h) ? i.get(h) : o.has(d.id);
|
|
4025
4033
|
m !== f && t.push({
|
|
4026
4034
|
type: m ? "create" : "delete",
|
|
4027
4035
|
recordName: a.filteredEntityName,
|
|
@@ -4038,9 +4046,9 @@ class Ha {
|
|
|
4038
4046
|
if (!r) return;
|
|
4039
4047
|
const a = this.getFilteredEntitiesForBase(e);
|
|
4040
4048
|
if (!a.length) return;
|
|
4041
|
-
const n =
|
|
4049
|
+
const n = Ct(r);
|
|
4042
4050
|
for (const o of a) {
|
|
4043
|
-
const c =
|
|
4051
|
+
const c = oi(o.name, t), u = await this.checkRecordMatchesFilter(t, e, o.matchExpression), l = n.has(c) ? n.get(c) : !1;
|
|
4044
4052
|
u && !l && r.push({
|
|
4045
4053
|
type: "create",
|
|
4046
4054
|
recordName: o.name,
|
|
@@ -4055,8 +4063,8 @@ class Ha {
|
|
|
4055
4063
|
*/
|
|
4056
4064
|
enqueuePostWriteCreationCheck(e, t, i, r) {
|
|
4057
4065
|
if (!e || !this.getFilteredEntitiesForBase(t).length) return;
|
|
4058
|
-
let a =
|
|
4059
|
-
a || (a = [],
|
|
4066
|
+
let a = Fe.get(e);
|
|
4067
|
+
a || (a = [], Fe.set(e, a)), a.push({ kind: "creation", recordName: t, recordId: i, fullRecord: r });
|
|
4060
4068
|
}
|
|
4061
4069
|
/**
|
|
4062
4070
|
* 登记一个行内记录的原地更新(同 id `&` 关系属性 / combined 嵌套值)。
|
|
@@ -4066,17 +4074,17 @@ class Ha {
|
|
|
4066
4074
|
if (!e) return;
|
|
4067
4075
|
const a = await this.collectMembershipChecks(t, [i], r, e);
|
|
4068
4076
|
if (!a.length) return;
|
|
4069
|
-
let n =
|
|
4070
|
-
n || (n = [],
|
|
4077
|
+
let n = Fe.get(e);
|
|
4078
|
+
n || (n = [], Fe.set(e, n)), n.push({ kind: "update", checks: a });
|
|
4071
4079
|
}
|
|
4072
4080
|
/**
|
|
4073
4081
|
* 写入完成点:结算全部挂起的行内视图成员资格任务(顺序与登记顺序一致)。
|
|
4074
4082
|
*/
|
|
4075
4083
|
async settlePostWriteChecks(e) {
|
|
4076
4084
|
if (!e) return;
|
|
4077
|
-
const t =
|
|
4085
|
+
const t = Fe.get(e);
|
|
4078
4086
|
if (t?.length) {
|
|
4079
|
-
|
|
4087
|
+
Fe.delete(e);
|
|
4080
4088
|
for (const i of t)
|
|
4081
4089
|
i.kind === "creation" ? await this.handleRecordCreation(i.recordName, i.recordId, i.fullRecord, e) : await this.settleMembershipChecks(i.checks, e);
|
|
4082
4090
|
}
|
|
@@ -4161,10 +4169,10 @@ class Ha {
|
|
|
4161
4169
|
if (!e || !a) return;
|
|
4162
4170
|
const n = e.recordName === t ? e : e.children.find((c) => c.recordName === t);
|
|
4163
4171
|
if (!n) return;
|
|
4164
|
-
const o =
|
|
4172
|
+
const o = Ct(a);
|
|
4165
4173
|
for (const c of i)
|
|
4166
4174
|
for (const [u, l] of n.membersByFilteredEntity) {
|
|
4167
|
-
const d =
|
|
4175
|
+
const d = oi(u, c.id);
|
|
4168
4176
|
if (o.has(d) ? o.get(d) : l.has(c.id)) {
|
|
4169
4177
|
const m = n.recordsById.get(c.id) || c;
|
|
4170
4178
|
r.push({
|
|
@@ -4497,10 +4505,10 @@ WHERE "${a.idField}" = ${r()}
|
|
|
4497
4505
|
* 依赖写入与匹配两侧的序列化一致,非规范形会让键序不同的等价对象匹配失败。
|
|
4498
4506
|
*/
|
|
4499
4507
|
prepareFieldValue(e, t) {
|
|
4500
|
-
return t?.toLowerCase() === "json" ?
|
|
4508
|
+
return t?.toLowerCase() === "json" ? Tt(e) : e;
|
|
4501
4509
|
}
|
|
4502
4510
|
}
|
|
4503
|
-
const
|
|
4511
|
+
const Lt = ":root";
|
|
4504
4512
|
class je {
|
|
4505
4513
|
constructor(e, t, i = []) {
|
|
4506
4514
|
this.label = e, this.parent = t, this.stack = i;
|
|
@@ -4520,7 +4528,7 @@ class je {
|
|
|
4520
4528
|
}
|
|
4521
4529
|
class za {
|
|
4522
4530
|
constructor(e) {
|
|
4523
|
-
this.recordQuery = e, this.recordQueryByName = /* @__PURE__ */ new Map(), this.set(
|
|
4531
|
+
this.recordQuery = e, this.recordQueryByName = /* @__PURE__ */ new Map(), this.set(Lt, e), this.recursiveSaveLabelledRecordQuery(e);
|
|
4524
4532
|
}
|
|
4525
4533
|
recursiveSaveLabelledRecordQuery(e) {
|
|
4526
4534
|
e.attributeQuery?.relatedRecords.forEach((t) => {
|
|
@@ -4572,7 +4580,7 @@ class Ga {
|
|
|
4572
4580
|
throw new Error(`Failed to parse JSON field "${t}.${d.join(".")}": ${m instanceof Error ? m.message : String(m)}. Raw value: ${l.slice(0, 200)}`);
|
|
4573
4581
|
}
|
|
4574
4582
|
else typeof l == "number" && h === "boolean" && (l = l !== 0);
|
|
4575
|
-
l !== null &&
|
|
4583
|
+
l !== null && wt(c, d, l);
|
|
4576
4584
|
}), c;
|
|
4577
4585
|
});
|
|
4578
4586
|
}
|
|
@@ -4594,7 +4602,7 @@ class Ga {
|
|
|
4594
4602
|
* 查找记录(主查询方法)
|
|
4595
4603
|
* CAUTION findRelatedRecords 中的递归调用会使得 includeRelationData 变为 true
|
|
4596
4604
|
*/
|
|
4597
|
-
async findRecords(e, t = "", i, r = new je(
|
|
4605
|
+
async findRecords(e, t = "", i, r = new je(Lt), a = !1) {
|
|
4598
4606
|
if (i || (i = new za(e)), e.goto) {
|
|
4599
4607
|
if (e.exit && await e.exit(r))
|
|
4600
4608
|
return [];
|
|
@@ -4635,14 +4643,14 @@ FOR UPDATE OF "${e.recordName}"` : u,
|
|
|
4635
4643
|
for (let b of e.attributeQuery.xToOneRecords)
|
|
4636
4644
|
if (b.goto) {
|
|
4637
4645
|
const w = this.map.getInfo(b.parentRecord, b.attributeName).getReverseInfo()?.attributeName;
|
|
4638
|
-
for (let
|
|
4646
|
+
for (let R of p) {
|
|
4639
4647
|
const S = b.matchExpression.and({
|
|
4640
4648
|
key: `${w}.id`,
|
|
4641
|
-
value: ["=",
|
|
4642
|
-
}),
|
|
4649
|
+
value: ["=", R.id]
|
|
4650
|
+
}), N = b.derive({
|
|
4643
4651
|
matchExpression: S
|
|
4644
|
-
}), $ = e.label ? y.concat(
|
|
4645
|
-
|
|
4652
|
+
}), $ = e.label ? y.concat(R) : y;
|
|
4653
|
+
R[b.alias || b.attributeName] = await this.findRecords(N, t, i, $);
|
|
4646
4654
|
}
|
|
4647
4655
|
}
|
|
4648
4656
|
for (let b of e.attributeQuery.xToOneRecords) {
|
|
@@ -4650,22 +4658,22 @@ FOR UPDATE OF "${e.recordName}"` : u,
|
|
|
4650
4658
|
if (g)
|
|
4651
4659
|
for (let w of g.attributeQuery.xToManyRecords) {
|
|
4652
4660
|
const S = this.map.getInfo(w.parentRecord, w.attributeName).getReverseInfo()?.attributeName;
|
|
4653
|
-
for (let
|
|
4654
|
-
if (!
|
|
4655
|
-
const $ =
|
|
4661
|
+
for (let N of p) {
|
|
4662
|
+
if (!N[b.attributeName]?.[v]) continue;
|
|
4663
|
+
const $ = N[b.attributeName][v].id, I = w.derive({
|
|
4656
4664
|
matchExpression: w.matchExpression.and({
|
|
4657
4665
|
key: `${S}.id`,
|
|
4658
4666
|
value: ["=", $]
|
|
4659
4667
|
})
|
|
4660
|
-
}),
|
|
4661
|
-
|
|
4662
|
-
|
|
4668
|
+
}), D = e.label ? y.concat(N) : y;
|
|
4669
|
+
wt(
|
|
4670
|
+
N,
|
|
4663
4671
|
[b.alias || b.attributeName, v, w.attributeName],
|
|
4664
4672
|
await this.findRecords(
|
|
4665
4673
|
I,
|
|
4666
4674
|
`finding relation data: ${e.recordName}.${b.attributeName}.&.${w.attributeName}`,
|
|
4667
4675
|
i,
|
|
4668
|
-
|
|
4676
|
+
D
|
|
4669
4677
|
)
|
|
4670
4678
|
);
|
|
4671
4679
|
}
|
|
@@ -4738,7 +4746,7 @@ FOR UPDATE OF "${e.recordName}"` : u,
|
|
|
4738
4746
|
for (let y = 0; y < i.length; y += 500) {
|
|
4739
4747
|
const b = i.slice(y, y + 500), g = r.matchExpression.and({
|
|
4740
4748
|
key: `${u}.id`,
|
|
4741
|
-
value: ["in", b.map((
|
|
4749
|
+
value: ["in", b.map((N) => N.id)]
|
|
4742
4750
|
}), w = new K(
|
|
4743
4751
|
r.recordName,
|
|
4744
4752
|
this.map,
|
|
@@ -4746,34 +4754,34 @@ FOR UPDATE OF "${e.recordName}"` : u,
|
|
|
4746
4754
|
r.parentRecord,
|
|
4747
4755
|
r.attributeName,
|
|
4748
4756
|
p
|
|
4749
|
-
),
|
|
4757
|
+
), R = r.derive({
|
|
4750
4758
|
matchExpression: g,
|
|
4751
4759
|
attributeQuery: w
|
|
4752
4760
|
}), S = await this.findRecords(
|
|
4753
|
-
|
|
4761
|
+
R,
|
|
4754
4762
|
`finding related records in batch: ${r.parentRecord}.${r.attributeName}`,
|
|
4755
4763
|
a,
|
|
4756
4764
|
n
|
|
4757
4765
|
);
|
|
4758
|
-
for (const
|
|
4759
|
-
const $ =
|
|
4760
|
-
if (p ? (
|
|
4761
|
-
for (let
|
|
4762
|
-
const W =
|
|
4763
|
-
|
|
4764
|
-
|
|
4765
|
-
[v,
|
|
4766
|
+
for (const N of S) {
|
|
4767
|
+
const $ = N[u]?.id, I = $ !== void 0 ? d.get(String($)) : void 0;
|
|
4768
|
+
if (p ? (N[v] = N[u]?.[v], delete N[u]) : h || delete N[u], f)
|
|
4769
|
+
for (let D of f.attributeQuery.xToManyRecords) {
|
|
4770
|
+
const W = N[v].id;
|
|
4771
|
+
wt(
|
|
4772
|
+
N,
|
|
4773
|
+
[v, D.attributeName],
|
|
4766
4774
|
await this.findXToManyRelatedRecords(
|
|
4767
|
-
|
|
4768
|
-
|
|
4775
|
+
D.parentRecord,
|
|
4776
|
+
D.attributeName,
|
|
4769
4777
|
W,
|
|
4770
|
-
|
|
4778
|
+
D,
|
|
4771
4779
|
a,
|
|
4772
4780
|
n
|
|
4773
4781
|
)
|
|
4774
4782
|
);
|
|
4775
4783
|
}
|
|
4776
|
-
I && I[l].push(
|
|
4784
|
+
I && I[l].push(N);
|
|
4777
4785
|
}
|
|
4778
4786
|
}
|
|
4779
4787
|
}
|
|
@@ -4847,23 +4855,23 @@ FOR UPDATE OF "${e.recordName}"` : u,
|
|
|
4847
4855
|
});
|
|
4848
4856
|
else {
|
|
4849
4857
|
const b = r.attributeQuery.data.find(
|
|
4850
|
-
(
|
|
4851
|
-
)?.[1]?.attributeQuery || [], g = (
|
|
4858
|
+
(N) => Array.isArray(N) && N[0] === v
|
|
4859
|
+
)?.[1]?.attributeQuery || [], g = (N) => b.some(($) => $ === N || Array.isArray($) && $[0] === N), w = g("source"), R = g("target"), S = /* @__PURE__ */ new Set();
|
|
4852
4860
|
m = [];
|
|
4853
|
-
for (const
|
|
4861
|
+
for (const N of h) {
|
|
4854
4862
|
const $ = (A, ne) => {
|
|
4855
4863
|
if (!A?.id) return;
|
|
4856
|
-
const
|
|
4857
|
-
return String(ye) === String(i) && String(
|
|
4858
|
-
}, I = $(
|
|
4864
|
+
const F = ne ? A.source?.id : A.target?.id, ye = ne ? A.target?.id : A.source?.id;
|
|
4865
|
+
return String(ye) === String(i) && String(F) === String(N.id) ? A : void 0;
|
|
4866
|
+
}, I = $(N[`${c}:source`]?.[v], !0) ?? $(N[`${c}:target`]?.[v], !1);
|
|
4859
4867
|
if (!I) continue;
|
|
4860
|
-
const
|
|
4861
|
-
if (S.has(
|
|
4862
|
-
S.add(
|
|
4868
|
+
const D = `${N.id}::${I.id}`;
|
|
4869
|
+
if (S.has(D)) continue;
|
|
4870
|
+
S.add(D);
|
|
4863
4871
|
const W = { ...I };
|
|
4864
|
-
w || delete W.source,
|
|
4872
|
+
w || delete W.source, R || delete W.target;
|
|
4865
4873
|
const P = {
|
|
4866
|
-
...
|
|
4874
|
+
...N,
|
|
4867
4875
|
[v]: W
|
|
4868
4876
|
};
|
|
4869
4877
|
delete P[`${c}:source`], delete P[`${c}:target`], m.push(P);
|
|
@@ -4874,7 +4882,7 @@ FOR UPDATE OF "${e.recordName}"` : u,
|
|
|
4874
4882
|
for (let y of p.attributeQuery.xToManyRecords)
|
|
4875
4883
|
for (let b of m) {
|
|
4876
4884
|
const g = b[v].id, w = d.label ? f.concat(b) : f;
|
|
4877
|
-
|
|
4885
|
+
wt(
|
|
4878
4886
|
b,
|
|
4879
4887
|
[v, y.attributeName],
|
|
4880
4888
|
await this.findXToManyRelatedRecords(
|
|
@@ -5128,17 +5136,17 @@ class Xa {
|
|
|
5128
5136
|
if (h)
|
|
5129
5137
|
for (const S of ["source", "target"]) {
|
|
5130
5138
|
if (!Object.prototype.hasOwnProperty.call(i.rawData || {}, S)) continue;
|
|
5131
|
-
const
|
|
5132
|
-
if (!
|
|
5139
|
+
const N = i.rawData[S];
|
|
5140
|
+
if (!N?.id || f[S]?.id !== N.id)
|
|
5133
5141
|
throw new Error(
|
|
5134
|
-
`cannot change ${S} of relation record "${e}" through update (current ${S}.id: ${JSON.stringify(f[S]?.id)}, new: ${JSON.stringify(
|
|
5142
|
+
`cannot change ${S} of relation record "${e}" through update (current ${S}.id: ${JSON.stringify(f[S]?.id)}, new: ${JSON.stringify(N?.id ?? N)}). Relation endpoints are immutable — remove the old relation and add a new one instead.`
|
|
5135
5143
|
);
|
|
5136
5144
|
}
|
|
5137
5145
|
const p = Array.from(/* @__PURE__ */ new Set([
|
|
5138
5146
|
...d,
|
|
5139
5147
|
...i.getSameRowFieldAndValue(f).map((S) => S.name)
|
|
5140
|
-
])), y = await this.filteredEntityManager.collectMembershipChecks(u.recordName, [f.id], p, r), b = r ? await this.collectUpdateLinkChecks(i, r) : [], g = await this.agent.createRecordDependency(i, r), w = await this.updateSameRowData(u.recordName, f, g, r),
|
|
5141
|
-
await this.filteredEntityManager.settleMembershipChecks(y.concat(b), r), m.push({ ...i.getData(), ...w.getData(), ...
|
|
5148
|
+
])), y = await this.filteredEntityManager.collectMembershipChecks(u.recordName, [f.id], p, r), b = r ? await this.collectUpdateLinkChecks(i, r) : [], g = await this.agent.createRecordDependency(i, r), w = await this.updateSameRowData(u.recordName, f, g, r), R = await this.handleUpdateReliance(u.recordName, f, i, r);
|
|
5149
|
+
await this.filteredEntityManager.settleMembershipChecks(y.concat(b), r), m.push({ ...i.getData(), ...w.getData(), ...R });
|
|
5142
5150
|
}
|
|
5143
5151
|
return m;
|
|
5144
5152
|
}
|
|
@@ -5256,11 +5264,11 @@ class Ya {
|
|
|
5256
5264
|
* 查找记录(主查询方法)- 委托给 QueryExecutor
|
|
5257
5265
|
* CAUTION findRelatedRecords 中的递归调用会使得 includeRelationData 变为 true
|
|
5258
5266
|
*/
|
|
5259
|
-
async findRecords(e, t = "", i, r = new je(
|
|
5267
|
+
async findRecords(e, t = "", i, r = new je(Lt)) {
|
|
5260
5268
|
return this.queryExecutor.findRecords(e, t, i, r);
|
|
5261
5269
|
}
|
|
5262
5270
|
async lockRecords(e, t = "") {
|
|
5263
|
-
return this.queryExecutor.findRecords(e, t, void 0, new je(
|
|
5271
|
+
return this.queryExecutor.findRecords(e, t, void 0, new je(Lt), !0);
|
|
5264
5272
|
}
|
|
5265
5273
|
// 委托给 CreationExecutor
|
|
5266
5274
|
async createRecordDependency(e, t) {
|
|
@@ -5312,7 +5320,13 @@ class Ya {
|
|
|
5312
5320
|
id: f.id,
|
|
5313
5321
|
source: { id: f.source?.id },
|
|
5314
5322
|
target: { id: f.target?.id }
|
|
5315
|
-
}
|
|
5323
|
+
};
|
|
5324
|
+
m.push(...await this.filteredEntityManager.collectLinkMembershipChecks(
|
|
5325
|
+
e.recordName,
|
|
5326
|
+
{ sourceIds: [f.source?.id], targetIds: [f.target?.id] },
|
|
5327
|
+
t
|
|
5328
|
+
));
|
|
5329
|
+
const y = await this.filteredEntityManager.collectInlineDeletionSnapshot(e.recordName, [p], t);
|
|
5316
5330
|
t?.push({
|
|
5317
5331
|
type: "delete",
|
|
5318
5332
|
recordName: e.recordName,
|
|
@@ -5329,61 +5343,67 @@ class Ya {
|
|
|
5329
5343
|
));
|
|
5330
5344
|
const y = f.id ? f[p.info?.attributeName][v] : void 0, b = y?.id ? await this.filteredEntityManager.collectInlineDeletionSnapshot(p.info.linkName, [y], t) : void 0, g = /* @__PURE__ */ new Map();
|
|
5331
5345
|
if (h) {
|
|
5332
|
-
const
|
|
5333
|
-
for (const
|
|
5334
|
-
if (
|
|
5335
|
-
const $ = N
|
|
5336
|
-
if (
|
|
5337
|
-
const
|
|
5338
|
-
|
|
5346
|
+
const R = f[p.info?.attributeName], S = this.map.getRecordInfo(p.recordName);
|
|
5347
|
+
for (const N of S.mergedRecordAttributes) {
|
|
5348
|
+
if (N.linkName !== e.recordName) continue;
|
|
5349
|
+
const $ = R[N.attributeName], I = $?.[v];
|
|
5350
|
+
if (!I?.id) continue;
|
|
5351
|
+
const D = await this.filteredEntityManager.collectInlineDeletionSnapshot(N.linkName, [I], t);
|
|
5352
|
+
D && g.set(N.attributeName, D);
|
|
5353
|
+
const W = !this.map.getLinkInfoByName(e.recordName).isRelationSource(p.recordName, N.attributeName);
|
|
5354
|
+
m.push(...await this.filteredEntityManager.collectLinkMembershipChecks(
|
|
5355
|
+
N.linkName,
|
|
5356
|
+
W ? { sourceIds: [R.id], targetIds: [$.id] } : { sourceIds: [$.id], targetIds: [R.id] },
|
|
5357
|
+
t
|
|
5358
|
+
));
|
|
5339
5359
|
}
|
|
5340
5360
|
}
|
|
5341
|
-
if (await this.deleteRecordSameRowData(p.recordName, [{ id: f[p.info?.attributeName].id }]), f.id && (t?.push({
|
|
5361
|
+
if (await this.deleteRecordSameRowData(p.recordName, [{ id: f[p.info?.attributeName].id }]), f.id && !p.info.isLinkSourceRelation() && (t?.push({
|
|
5342
5362
|
type: "delete",
|
|
5343
5363
|
recordName: p.info.linkName,
|
|
5344
5364
|
record: f[p.info?.attributeName][v]
|
|
5345
5365
|
}), t && b && this.filteredEntityManager.settleDeletionMemberships(b, p.info.linkName, [y], t, t)), T(!n[p.info?.attributeName], `should not have same combined record, conflict attribute: ${p.info?.attributeName}`), n[p.info?.attributeName] = {
|
|
5346
5366
|
...f[p.info?.attributeName]
|
|
5347
5367
|
}, this.map.getRecordInfo(e.recordName).isRelation && this.map.data.links[e.recordName]) {
|
|
5348
|
-
const
|
|
5349
|
-
for (const
|
|
5350
|
-
if (
|
|
5351
|
-
const $ = N
|
|
5368
|
+
const R = n[p.info?.attributeName], S = this.map.getRecordInfo(p.recordName);
|
|
5369
|
+
for (const N of S.mergedRecordAttributes) {
|
|
5370
|
+
if (N.linkName !== e.recordName) continue;
|
|
5371
|
+
const $ = R[N.attributeName];
|
|
5352
5372
|
if ($?.id === void 0) continue;
|
|
5353
|
-
const I = $[v],
|
|
5373
|
+
const I = $[v], D = !this.map.getLinkInfoByName(e.recordName).isRelationSource(p.recordName, N.attributeName), W = {
|
|
5354
5374
|
...I || {},
|
|
5355
|
-
source:
|
|
5356
|
-
target:
|
|
5375
|
+
source: D ? { id: R.id } : { id: $.id },
|
|
5376
|
+
target: D ? { id: $.id } : { id: R.id }
|
|
5357
5377
|
};
|
|
5358
5378
|
t?.push({
|
|
5359
5379
|
type: "delete",
|
|
5360
5380
|
recordName: e.recordName,
|
|
5361
5381
|
record: W
|
|
5362
5382
|
});
|
|
5363
|
-
const P = g.get(
|
|
5364
|
-
t && P && this.filteredEntityManager.settleDeletionMemberships(P, e.recordName, [W], t, t), delete N
|
|
5383
|
+
const P = g.get(N.attributeName);
|
|
5384
|
+
t && P && this.filteredEntityManager.settleDeletionMemberships(P, e.recordName, [W], t, t), delete R[N.attributeName];
|
|
5365
5385
|
}
|
|
5366
5386
|
}
|
|
5367
5387
|
if (!p.info.isLinkSourceRelation()) {
|
|
5368
|
-
const
|
|
5388
|
+
const R = { id: p.getRef().id }, S = { id: a ?? e.getData().id };
|
|
5369
5389
|
n[p.info?.attributeName][v] = {
|
|
5370
5390
|
...p.linkRecordData?.getData() || {},
|
|
5371
5391
|
id: await this.database.getAutoId(p.info.linkName)
|
|
5372
5392
|
};
|
|
5373
|
-
const
|
|
5393
|
+
const N = {
|
|
5374
5394
|
...n[p.info?.attributeName][v],
|
|
5375
5395
|
[p.info.isRecordSource() ? "source" : "target"]: S,
|
|
5376
|
-
[p.info.isRecordSource() ? "target" : "source"]:
|
|
5396
|
+
[p.info.isRecordSource() ? "target" : "source"]: R
|
|
5377
5397
|
};
|
|
5378
5398
|
t?.push({
|
|
5379
5399
|
type: "create",
|
|
5380
5400
|
recordName: p.info.linkName,
|
|
5381
|
-
record:
|
|
5401
|
+
record: N
|
|
5382
5402
|
}), this.filteredEntityManager.enqueuePostWriteCreationCheck(
|
|
5383
5403
|
t,
|
|
5384
5404
|
p.info.linkName,
|
|
5385
|
-
|
|
5386
|
-
|
|
5405
|
+
N.id,
|
|
5406
|
+
N
|
|
5387
5407
|
);
|
|
5388
5408
|
}
|
|
5389
5409
|
}
|
|
@@ -5458,19 +5478,19 @@ class Ya {
|
|
|
5458
5478
|
}
|
|
5459
5479
|
}
|
|
5460
5480
|
const pe = "__type";
|
|
5461
|
-
function
|
|
5481
|
+
function mt(s) {
|
|
5462
5482
|
return !("sourceProperty" in s);
|
|
5463
5483
|
}
|
|
5464
5484
|
function H(s) {
|
|
5465
|
-
if (
|
|
5485
|
+
if (mt(s)) return s.name;
|
|
5466
5486
|
const e = s;
|
|
5467
5487
|
return e.name || `${e.source.name}_${e.sourceProperty}_${e.targetProperty}_${e.target.name}`;
|
|
5468
5488
|
}
|
|
5469
5489
|
function De(s) {
|
|
5470
|
-
return
|
|
5490
|
+
return mt(s) ? s.inputEntities : s.inputRelations;
|
|
5471
5491
|
}
|
|
5472
5492
|
function Te(s) {
|
|
5473
|
-
return
|
|
5493
|
+
return mt(s) ? s.baseEntity : s.baseRelation;
|
|
5474
5494
|
}
|
|
5475
5495
|
function Qr(s) {
|
|
5476
5496
|
let e = s, t;
|
|
@@ -5497,7 +5517,7 @@ function lr(s) {
|
|
|
5497
5517
|
return s.forEach(a), t;
|
|
5498
5518
|
}
|
|
5499
5519
|
function Za(s, e) {
|
|
5500
|
-
const t = new
|
|
5520
|
+
const t = new fi(s, e), i = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Map(), n = [...s, ...e], o = /* @__PURE__ */ new Map();
|
|
5501
5521
|
for (const f of n) {
|
|
5502
5522
|
const p = H(f), { root: y } = Qr(f);
|
|
5503
5523
|
De(y) ? i.add(p) : o.set(p, H(y));
|
|
@@ -5555,47 +5575,47 @@ function en(s, e, t) {
|
|
|
5555
5575
|
function hr(s, e, t, i, r, a, n, o, c) {
|
|
5556
5576
|
const u = t === "entity", l = H(s), d = De(s) || [];
|
|
5557
5577
|
if (s.commonProperties) {
|
|
5558
|
-
const
|
|
5559
|
-
if (
|
|
5560
|
-
throw new Error(`Merged ${t} ${l} defined commonProperties, but these ${t}s do not have commonProperties: ${
|
|
5561
|
-
}
|
|
5562
|
-
for (const
|
|
5563
|
-
if (
|
|
5564
|
-
throw new Error(`Property name "${pe}" on ${t} "${H(
|
|
5565
|
-
const h = d.map((
|
|
5566
|
-
inputItem:
|
|
5567
|
-
...en(
|
|
5578
|
+
const N = d.filter(($) => s.commonProperties.some((I) => !$.properties.some((D) => D.name === I.name && D.type === I.type)));
|
|
5579
|
+
if (N.length > 0)
|
|
5580
|
+
throw new Error(`Merged ${t} ${l} defined commonProperties, but these ${t}s do not have commonProperties: ${N.map(($) => H($)).join(", ")}`);
|
|
5581
|
+
}
|
|
5582
|
+
for (const N of d)
|
|
5583
|
+
if (N.properties.some(($) => $.name === pe))
|
|
5584
|
+
throw new Error(`Property name "${pe}" on ${t} "${H(N)}" conflicts with the merged ${t} discriminator column. Please rename the property.`);
|
|
5585
|
+
const h = d.map((N) => ({
|
|
5586
|
+
inputItem: N,
|
|
5587
|
+
...en(N, r, a)
|
|
5568
5588
|
})), m = /* @__PURE__ */ new Set();
|
|
5569
|
-
h.forEach((
|
|
5589
|
+
h.forEach((N) => N.hostedTypes.forEach(($) => m.add($)));
|
|
5570
5590
|
let f = h[0]?.memberCondition;
|
|
5571
|
-
for (let
|
|
5572
|
-
f = f.or(h[
|
|
5591
|
+
for (let N = 1; N < h.length; N++)
|
|
5592
|
+
f = f.or(h[N].memberCondition);
|
|
5573
5593
|
const p = u ? e.getEntityByName(l) : e.getRelationByName(l), y = [
|
|
5574
5594
|
...rn(p, i, e),
|
|
5575
5595
|
tn(r),
|
|
5576
5596
|
...s.properties
|
|
5577
|
-
], b = d.some((
|
|
5597
|
+
], b = d.some((N) => Te(N)), [g, w] = an(
|
|
5578
5598
|
p,
|
|
5579
5599
|
y,
|
|
5580
5600
|
b ? f : void 0
|
|
5581
5601
|
);
|
|
5582
5602
|
e.replace(g, p);
|
|
5583
|
-
let
|
|
5584
|
-
w !== g && (
|
|
5603
|
+
let R = w;
|
|
5604
|
+
w !== g && (R = e.add(w), mt(g) ? g.baseEntity = R : g.baseRelation = R, n.add(H(R))), a.set(l, {
|
|
5585
5605
|
memberCondition: f,
|
|
5586
5606
|
hostedTypes: m,
|
|
5587
|
-
physicalBaseName: H(
|
|
5588
|
-
}), o.add(H(
|
|
5607
|
+
physicalBaseName: H(R)
|
|
5608
|
+
}), o.add(H(R));
|
|
5589
5609
|
const S = /* @__PURE__ */ new Map();
|
|
5590
|
-
for (const { inputItem:
|
|
5591
|
-
const I = H(
|
|
5592
|
-
c.set(I, pr(I, e, u)), mr(I,
|
|
5610
|
+
for (const { inputItem: N, memberCondition: $ } of h) {
|
|
5611
|
+
const I = H(N);
|
|
5612
|
+
c.set(I, pr(I, e, u)), mr(I, R, $, e, u);
|
|
5593
5613
|
}
|
|
5594
|
-
for (const { rootToRebase:
|
|
5595
|
-
|
|
5596
|
-
for (const [
|
|
5597
|
-
const $ = E.atom({ key: pe, value: ["=",
|
|
5598
|
-
c.set(
|
|
5614
|
+
for (const { rootToRebase: N } of h)
|
|
5615
|
+
N && H(N) !== H(R) && S.set(H(N), N);
|
|
5616
|
+
for (const [N] of S) {
|
|
5617
|
+
const $ = E.atom({ key: pe, value: ["=", N] });
|
|
5618
|
+
c.set(N, pr(N, e, u)), mr(N, R, $, e, u);
|
|
5599
5619
|
}
|
|
5600
5620
|
}
|
|
5601
5621
|
function pr(s, e, t) {
|
|
@@ -5673,7 +5693,7 @@ function rn(s, e, t) {
|
|
|
5673
5693
|
return r;
|
|
5674
5694
|
}
|
|
5675
5695
|
function an(s, e, t) {
|
|
5676
|
-
if (
|
|
5696
|
+
if (mt(s)) {
|
|
5677
5697
|
const i = j.create({ name: s.name });
|
|
5678
5698
|
if (t) {
|
|
5679
5699
|
const r = j.create({
|
|
@@ -5709,7 +5729,7 @@ function an(s, e, t) {
|
|
|
5709
5729
|
return a.properties = e, [a, a];
|
|
5710
5730
|
}
|
|
5711
5731
|
}
|
|
5712
|
-
class
|
|
5732
|
+
class bi {
|
|
5713
5733
|
constructor(e, t) {
|
|
5714
5734
|
this.map = e, this.database = t, this.agent = new Ya(e, t);
|
|
5715
5735
|
}
|
|
@@ -5842,7 +5862,7 @@ class gi {
|
|
|
5842
5862
|
return this.map.getInfo(e, t).recordName;
|
|
5843
5863
|
}
|
|
5844
5864
|
}
|
|
5845
|
-
class
|
|
5865
|
+
class tt {
|
|
5846
5866
|
constructor(e, t) {
|
|
5847
5867
|
this.name = e, this.map = t, this.data = this.map.data.records[e];
|
|
5848
5868
|
}
|
|
@@ -5915,7 +5935,7 @@ class et {
|
|
|
5915
5935
|
return this.data.matchExpression;
|
|
5916
5936
|
}
|
|
5917
5937
|
get filteredBy() {
|
|
5918
|
-
return this.data.filteredBy?.map((e) => new
|
|
5938
|
+
return this.data.filteredBy?.map((e) => new tt(e, this.map));
|
|
5919
5939
|
}
|
|
5920
5940
|
get isFilteredEntity() {
|
|
5921
5941
|
return this.data?.isFilteredEntity;
|
|
@@ -5965,10 +5985,10 @@ class Ft {
|
|
|
5965
5985
|
return this.data.sourceRecord;
|
|
5966
5986
|
}
|
|
5967
5987
|
get sourceRecordInfo() {
|
|
5968
|
-
return new
|
|
5988
|
+
return new tt(this.data.sourceRecord, this.map);
|
|
5969
5989
|
}
|
|
5970
5990
|
get targetRecordInfo() {
|
|
5971
|
-
return new
|
|
5991
|
+
return new tt(this.data.targetRecord, this.map);
|
|
5972
5992
|
}
|
|
5973
5993
|
get targetRecord() {
|
|
5974
5994
|
return this.data.targetRecord;
|
|
@@ -6059,7 +6079,7 @@ class qe {
|
|
|
6059
6079
|
}
|
|
6060
6080
|
getRecordInfo(e) {
|
|
6061
6081
|
let t = this.recordInfoCache.get(e);
|
|
6062
|
-
return t || (t = new
|
|
6082
|
+
return t || (t = new tt(e, this), this.recordInfoCache.set(e, t)), t;
|
|
6063
6083
|
}
|
|
6064
6084
|
getInfo(e, t) {
|
|
6065
6085
|
const i = this.getInfoByPath([e, ...t.split(".")]);
|
|
@@ -6135,8 +6155,8 @@ class qe {
|
|
|
6135
6155
|
if (l.isMergedWithParent() || l.isLinkMergedWithParent())
|
|
6136
6156
|
c = n;
|
|
6137
6157
|
else if (l.isLinkIsolated()) {
|
|
6138
|
-
const
|
|
6139
|
-
c = this.aliasManager?.registerTablePath(
|
|
6158
|
+
const R = `REL_${g}`;
|
|
6159
|
+
c = this.aliasManager?.registerTablePath(R) || R;
|
|
6140
6160
|
} else
|
|
6141
6161
|
c = w;
|
|
6142
6162
|
l.isMergedWithParent() || (n = w), a = l.table, r = b, o = l.getLinkInfo()?.table, u = !1;
|
|
@@ -6406,7 +6426,7 @@ function Q(s) {
|
|
|
6406
6426
|
function ce(s, e) {
|
|
6407
6427
|
return e.name === "mysql" ? `\`${s.replace(/`/g, "``")}\`` : `"${s.replace(/"/g, '""')}"`;
|
|
6408
6428
|
}
|
|
6409
|
-
function
|
|
6429
|
+
function Nt(s, e) {
|
|
6410
6430
|
return e.encodeLiteral(s);
|
|
6411
6431
|
}
|
|
6412
6432
|
function sn(s, e, t) {
|
|
@@ -6417,20 +6437,20 @@ function sn(s, e, t) {
|
|
|
6417
6437
|
case "isNotNull":
|
|
6418
6438
|
return `${i} IS NOT NULL`;
|
|
6419
6439
|
case "equals":
|
|
6420
|
-
return e.value === null ? `${i} IS NULL` : `${i} = ${
|
|
6440
|
+
return e.value === null ? `${i} IS NULL` : `${i} = ${Nt(e.value, t)}`;
|
|
6421
6441
|
case "notEquals":
|
|
6422
|
-
return e.value === null ? `${i} IS NOT NULL` : `${i} != ${
|
|
6442
|
+
return e.value === null ? `${i} IS NOT NULL` : `${i} != ${Nt(e.value, t)}`;
|
|
6423
6443
|
case "in": {
|
|
6424
6444
|
const r = e.value.filter((n) => n !== null), a = [];
|
|
6425
|
-
return e.value.some((n) => n === null) && a.push(`${i} IS NULL`), r.length && a.push(`${i} IN (${r.map((n) =>
|
|
6445
|
+
return e.value.some((n) => n === null) && a.push(`${i} IS NULL`), r.length && a.push(`${i} IN (${r.map((n) => Nt(n, t)).join(", ")})`), `(${a.join(" OR ")})`;
|
|
6426
6446
|
}
|
|
6427
6447
|
case "notIn": {
|
|
6428
6448
|
const r = e.value.filter((n) => n !== null), a = [];
|
|
6429
|
-
return e.value.some((n) => n === null) && a.push(`${i} IS NOT NULL`), r.length && a.push(`${i} NOT IN (${r.map((n) =>
|
|
6449
|
+
return e.value.some((n) => n === null) && a.push(`${i} IS NOT NULL`), r.length && a.push(`${i} NOT IN (${r.map((n) => Nt(n, t)).join(", ")})`), `(${a.join(" AND ")})`;
|
|
6430
6450
|
}
|
|
6431
6451
|
}
|
|
6432
6452
|
}
|
|
6433
|
-
function
|
|
6453
|
+
function wi(s, e, t, i, r, a) {
|
|
6434
6454
|
const n = i.supportsCreateIndexIfNotExists ? " IF NOT EXISTS" : "", o = t.map((u) => ce(u, i)).join(", "), c = r ? `
|
|
6435
6455
|
WHERE ${Object.entries(r).map(([u, l]) => {
|
|
6436
6456
|
const d = a?.(u) ?? u;
|
|
@@ -6445,7 +6465,7 @@ function on(s, e, t) {
|
|
|
6445
6465
|
throw new Error(`filtered unique constraints are not supported by ${e.name} schema dialect`);
|
|
6446
6466
|
return {
|
|
6447
6467
|
item: s,
|
|
6448
|
-
sql:
|
|
6468
|
+
sql: wi(
|
|
6449
6469
|
s.physicalName,
|
|
6450
6470
|
s.tableName,
|
|
6451
6471
|
s.fields,
|
|
@@ -7212,7 +7232,7 @@ ${Object.values(this.tables[e].columns).map((i) => ` "${i.name}" ${i.fieldTyp
|
|
|
7212
7232
|
for (const a of r || []) {
|
|
7213
7233
|
if (e.has(a.name))
|
|
7214
7234
|
throw new Error(`duplicate constraint name "${a.name}"`);
|
|
7215
|
-
if (e.add(a.name),
|
|
7235
|
+
if (e.add(a.name), Kt.is(a)) {
|
|
7216
7236
|
this.validateUniqueConstraintRecord(i, a);
|
|
7217
7237
|
const n = a.properties.map((o) => this.resolveConstraintField(i, o));
|
|
7218
7238
|
this.constraintSchemaItems.push({
|
|
@@ -7466,7 +7486,7 @@ class V extends ae {
|
|
|
7466
7486
|
}), this.handleName = t.handleName, this.computationName = t.computationName, this.dataContext = t.dataContext, this.computationPhase = t.computationPhase, this.severity = t.severity || te.MEDIUM;
|
|
7467
7487
|
}
|
|
7468
7488
|
}
|
|
7469
|
-
class
|
|
7489
|
+
class ci extends V {
|
|
7470
7490
|
constructor(e, t = {}) {
|
|
7471
7491
|
super(e, {
|
|
7472
7492
|
...t,
|
|
@@ -7572,7 +7592,7 @@ function dn(s) {
|
|
|
7572
7592
|
fields: i.map((a) => a.split(".").at(-1).replace(/^"|"$/g, ""))
|
|
7573
7593
|
};
|
|
7574
7594
|
}
|
|
7575
|
-
function
|
|
7595
|
+
function xt(s, e) {
|
|
7576
7596
|
const t = s && typeof s == "object" ? s : {}, i = s instanceof Error ? s.message : String(s), r = t.code ?? t.errno, a = ln(t, ["constraint", "constraintName", "index", "sqlMessage"]), n = dn(i), o = r === "23505" || r === "SQLITE_CONSTRAINT_UNIQUE" || r === "SQLITE_CONSTRAINT" || r === 1062 || i.includes("UNIQUE constraint failed") || i.includes("duplicate key value violates unique constraint") || i.includes("Duplicate entry");
|
|
7577
7597
|
return {
|
|
7578
7598
|
driver: e?.constructor?.name,
|
|
@@ -7615,7 +7635,7 @@ class br extends ae {
|
|
|
7615
7635
|
}), this.sideEffectName = t.sideEffectName, this.recordName = t.recordName, this.mutationType = t.mutationType, this.severity = te.MEDIUM;
|
|
7616
7636
|
}
|
|
7617
7637
|
}
|
|
7618
|
-
class
|
|
7638
|
+
class Ni extends ae {
|
|
7619
7639
|
constructor(e, t) {
|
|
7620
7640
|
super(e, {
|
|
7621
7641
|
errorType: t.context?.errorType || "ConditionError",
|
|
@@ -7635,7 +7655,7 @@ class wi extends ae {
|
|
|
7635
7655
|
*/
|
|
7636
7656
|
static payloadValidationFailed(e, t, i, r) {
|
|
7637
7657
|
const a = `${e} ${t}`;
|
|
7638
|
-
return new
|
|
7658
|
+
return new Ni(`Payload validation failed for field '${e}': ${t}`, {
|
|
7639
7659
|
checkType: "payload",
|
|
7640
7660
|
fieldName: e,
|
|
7641
7661
|
payload: i,
|
|
@@ -7646,7 +7666,7 @@ class wi extends ae {
|
|
|
7646
7666
|
});
|
|
7647
7667
|
}
|
|
7648
7668
|
static conditionCheckFailed(e, t) {
|
|
7649
|
-
return new
|
|
7669
|
+
return new Ni(`Condition check failed: ${e.data.name}`, {
|
|
7650
7670
|
checkType: "condition",
|
|
7651
7671
|
evaluationError: e,
|
|
7652
7672
|
severity: te.HIGH,
|
|
@@ -7712,7 +7732,7 @@ class Wr {
|
|
|
7712
7732
|
return this.data.transfers.filter((t) => wr(e, t.trigger));
|
|
7713
7733
|
}
|
|
7714
7734
|
}
|
|
7715
|
-
const Ao = 0,
|
|
7735
|
+
const Ao = 0, ui = 1, Io = 2;
|
|
7716
7736
|
class zr {
|
|
7717
7737
|
constructor(e, t) {
|
|
7718
7738
|
this.controller = e, this.scheduler = t, this.sourceMaps = [], this.sourceMapTree = {}, this.filteredToPhysicalName = /* @__PURE__ */ new Map(), this.knownRecordNames = /* @__PURE__ */ new Set();
|
|
@@ -7823,7 +7843,7 @@ class zr {
|
|
|
7823
7843
|
}
|
|
7824
7844
|
);
|
|
7825
7845
|
const o = this.convertDataDepToERMutationEventsSourceMap(a, n, i);
|
|
7826
|
-
r[n.phase ||
|
|
7846
|
+
r[n.phase || ui].push(...o);
|
|
7827
7847
|
}), i.dataContext.type === "property" && Object.values(i.dataDeps).some((a) => a.type === "global")) {
|
|
7828
7848
|
const a = i.dataContext.host.name;
|
|
7829
7849
|
if (!r.some(
|
|
@@ -7833,7 +7853,7 @@ class zr {
|
|
|
7833
7853
|
type: "records",
|
|
7834
7854
|
source: i.dataContext.host
|
|
7835
7855
|
};
|
|
7836
|
-
r[
|
|
7856
|
+
r[ui].push(...this.convertDataDepToERMutationEventsSourceMap("_self", o, i, "create"));
|
|
7837
7857
|
}
|
|
7838
7858
|
}
|
|
7839
7859
|
r.forEach((a, n) => {
|
|
@@ -7842,7 +7862,7 @@ class zr {
|
|
|
7842
7862
|
} else {
|
|
7843
7863
|
const { eventDeps: r } = i;
|
|
7844
7864
|
for (const a of Object.values(r))
|
|
7845
|
-
t[a.phase ||
|
|
7865
|
+
t[a.phase || ui].push({
|
|
7846
7866
|
type: a.type,
|
|
7847
7867
|
recordName: a.recordName,
|
|
7848
7868
|
record: a.record,
|
|
@@ -8112,10 +8132,10 @@ class U {
|
|
|
8112
8132
|
this.skip = () => new Oe();
|
|
8113
8133
|
}
|
|
8114
8134
|
static {
|
|
8115
|
-
this.resolved = (e, t) => new
|
|
8135
|
+
this.resolved = (e, t) => new Xt(e, t);
|
|
8116
8136
|
}
|
|
8117
8137
|
static {
|
|
8118
|
-
this.async = (e) => new
|
|
8138
|
+
this.async = (e) => new ft(e);
|
|
8119
8139
|
}
|
|
8120
8140
|
static {
|
|
8121
8141
|
this.fullRecompute = (e) => new Gr(e);
|
|
@@ -8128,17 +8148,17 @@ class Gr extends U {
|
|
|
8128
8148
|
super(), this.reason = e;
|
|
8129
8149
|
}
|
|
8130
8150
|
}
|
|
8131
|
-
class
|
|
8151
|
+
class ft extends U {
|
|
8132
8152
|
constructor(e) {
|
|
8133
8153
|
super(), this.args = e;
|
|
8134
8154
|
}
|
|
8135
8155
|
}
|
|
8136
|
-
class
|
|
8156
|
+
class Xt extends U {
|
|
8137
8157
|
constructor(e, t) {
|
|
8138
8158
|
super(), this.result = e, this.args = t;
|
|
8139
8159
|
}
|
|
8140
8160
|
}
|
|
8141
|
-
class
|
|
8161
|
+
class O {
|
|
8142
8162
|
constructor(e, t) {
|
|
8143
8163
|
this.defaultValue = e, this.record = t;
|
|
8144
8164
|
}
|
|
@@ -8331,7 +8351,7 @@ function Xr(s, e, t) {
|
|
|
8331
8351
|
c.has(m) || (h.has(m) && a(`trigger.keys ["${m}"] refers to a relation attribute. Relation replacement does not emit a host update event carrying this key, so the transfer would never fire. Declare the trigger on the relation record's create/delete events instead (e.g. { recordName: '<relationName>', type: 'create' }).`), a(`trigger.keys ["${m}"] does not match any declared property of "${r.recordName}", so the transfer would never fire. Declare the property or fix the key name.`));
|
|
8332
8352
|
}
|
|
8333
8353
|
}
|
|
8334
|
-
async function
|
|
8354
|
+
async function Vt(s, e, t, i, r) {
|
|
8335
8355
|
if (!e.computeValue) return e.name;
|
|
8336
8356
|
const a = await e.computeValue.call(s, t, i);
|
|
8337
8357
|
if (a === void 0)
|
|
@@ -8384,7 +8404,7 @@ class yn {
|
|
|
8384
8404
|
}
|
|
8385
8405
|
}
|
|
8386
8406
|
static {
|
|
8387
|
-
this.computationType =
|
|
8407
|
+
this.computationType = st;
|
|
8388
8408
|
}
|
|
8389
8409
|
static {
|
|
8390
8410
|
this.contextType = "global";
|
|
@@ -8395,7 +8415,7 @@ class yn {
|
|
|
8395
8415
|
};
|
|
8396
8416
|
}
|
|
8397
8417
|
async getInitialValue(e) {
|
|
8398
|
-
return
|
|
8418
|
+
return Vt(this.controller, this.initialState, void 0, e, () => this.describeContext());
|
|
8399
8419
|
}
|
|
8400
8420
|
describeContext() {
|
|
8401
8421
|
return `of global dictionary "${this.dataContext.id?.name ?? String(this.dataContext.id)}"`;
|
|
@@ -8405,7 +8425,7 @@ class yn {
|
|
|
8405
8425
|
if (!a) return U.skip();
|
|
8406
8426
|
await this.state.currentState.setInternal(a.name);
|
|
8407
8427
|
const n = await this.controller.retrieveLastValue(this.dataContext);
|
|
8408
|
-
return
|
|
8428
|
+
return Vt(this.controller, a, n, t, () => this.describeContext());
|
|
8409
8429
|
}
|
|
8410
8430
|
}
|
|
8411
8431
|
class gn {
|
|
@@ -8424,14 +8444,14 @@ class gn {
|
|
|
8424
8444
|
}
|
|
8425
8445
|
}
|
|
8426
8446
|
static {
|
|
8427
|
-
this.computationType =
|
|
8447
|
+
this.computationType = st;
|
|
8428
8448
|
}
|
|
8429
8449
|
static {
|
|
8430
8450
|
this.contextType = "property";
|
|
8431
8451
|
}
|
|
8432
8452
|
createState() {
|
|
8433
8453
|
return {
|
|
8434
|
-
currentState: new
|
|
8454
|
+
currentState: new O(this.initialState.name)
|
|
8435
8455
|
};
|
|
8436
8456
|
}
|
|
8437
8457
|
async getInitialValue(e) {
|
|
@@ -8442,7 +8462,7 @@ class gn {
|
|
|
8442
8462
|
if you want to save the use the initial value, you need to define computeValue in initialState to save it.
|
|
8443
8463
|
Or if you want to use state name as value, you should not set ${this.dataContext.host.name}.${this.dataContext.id.name} when ${this.dataContext.host.name} created.
|
|
8444
8464
|
`
|
|
8445
|
-
),
|
|
8465
|
+
), Vt(this.controller, this.initialState, t, void 0, () => this.describeContext());
|
|
8446
8466
|
}
|
|
8447
8467
|
describeContext() {
|
|
8448
8468
|
return `of property "${this.dataContext.host.name}.${this.dataContext.id.name}"`;
|
|
@@ -8466,7 +8486,7 @@ Or if you want to use state name as value, you should not set ${this.dataContext
|
|
|
8466
8486
|
if (!n) return U.skip();
|
|
8467
8487
|
await this.state.currentState.setInternal(r, n.name);
|
|
8468
8488
|
const o = r[this.dataContext.id.name];
|
|
8469
|
-
return
|
|
8489
|
+
return Vt(this.controller, n, o, t, () => this.describeContext());
|
|
8470
8490
|
}
|
|
8471
8491
|
// 给外部用的,因为可能在 Transform 里面设置初始值。
|
|
8472
8492
|
async createStateData(e) {
|
|
@@ -8475,17 +8495,17 @@ Or if you want to use state name as value, you should not set ${this.dataContext
|
|
|
8475
8495
|
};
|
|
8476
8496
|
}
|
|
8477
8497
|
}
|
|
8478
|
-
const
|
|
8498
|
+
const Lo = We.create({
|
|
8479
8499
|
name: "nonExistent",
|
|
8480
8500
|
computeValue: () => null
|
|
8481
|
-
}),
|
|
8501
|
+
}), Fo = We.create({
|
|
8482
8502
|
name: "nonDeleted",
|
|
8483
8503
|
computeValue: () => !1
|
|
8484
8504
|
}), Vo = We.create({
|
|
8485
8505
|
name: "deleted",
|
|
8486
8506
|
computeValue: () => !0
|
|
8487
8507
|
}), bn = [yn, gn];
|
|
8488
|
-
function
|
|
8508
|
+
function Yt(s, e) {
|
|
8489
8509
|
const t = [];
|
|
8490
8510
|
let i = s;
|
|
8491
8511
|
for (; i; ) {
|
|
@@ -8701,12 +8721,12 @@ function Zr(s) {
|
|
|
8701
8721
|
const e = Number(s.weight) * Number(s.value);
|
|
8702
8722
|
return Number.isFinite(e) ? e : 0;
|
|
8703
8723
|
}
|
|
8704
|
-
class
|
|
8724
|
+
class Nn extends ze {
|
|
8705
8725
|
constructor(e, t, i) {
|
|
8706
8726
|
super(e, t, i, { computationName: "WeightedSummation", requireCallback: !0 }), this.itemStateKey = "itemResult", this.emptyItemValue = 0;
|
|
8707
8727
|
}
|
|
8708
8728
|
static {
|
|
8709
|
-
this.computationType =
|
|
8729
|
+
this.computationType = ot;
|
|
8710
8730
|
}
|
|
8711
8731
|
static {
|
|
8712
8732
|
this.contextType = "global";
|
|
@@ -8714,7 +8734,7 @@ class Rn extends ze {
|
|
|
8714
8734
|
createState() {
|
|
8715
8735
|
return {
|
|
8716
8736
|
total: new me(0),
|
|
8717
|
-
itemResult: new
|
|
8737
|
+
itemResult: new O(0, this.record.name)
|
|
8718
8738
|
};
|
|
8719
8739
|
}
|
|
8720
8740
|
getInitialValue() {
|
|
@@ -8731,20 +8751,20 @@ class Rn extends ze {
|
|
|
8731
8751
|
return await this.state.total.setInternal(t), t;
|
|
8732
8752
|
}
|
|
8733
8753
|
}
|
|
8734
|
-
class
|
|
8754
|
+
class Rn extends Ge {
|
|
8735
8755
|
constructor(e, t, i) {
|
|
8736
8756
|
super(e, t, i, { computationName: "WeightedSummation", requireCallback: !0 }), this.itemStateKey = "itemResult", this.emptyItemValue = 0;
|
|
8737
8757
|
}
|
|
8738
8758
|
static {
|
|
8739
|
-
this.computationType =
|
|
8759
|
+
this.computationType = ot;
|
|
8740
8760
|
}
|
|
8741
8761
|
static {
|
|
8742
8762
|
this.contextType = "property";
|
|
8743
8763
|
}
|
|
8744
8764
|
createState() {
|
|
8745
8765
|
return {
|
|
8746
|
-
total: new
|
|
8747
|
-
itemResult: new
|
|
8766
|
+
total: new O(0, this.dataContext.host.name),
|
|
8767
|
+
itemResult: new O(0, this.relation.name)
|
|
8748
8768
|
};
|
|
8749
8769
|
}
|
|
8750
8770
|
getInitialValue() {
|
|
@@ -8761,13 +8781,13 @@ class Nn extends Ge {
|
|
|
8761
8781
|
return await this.state.total.setInternal(e, i), i;
|
|
8762
8782
|
}
|
|
8763
8783
|
}
|
|
8764
|
-
const vn = [
|
|
8784
|
+
const vn = [Nn, Rn];
|
|
8765
8785
|
class Sn extends ze {
|
|
8766
8786
|
constructor(e, t, i) {
|
|
8767
8787
|
super(e, t, i, { computationName: "Every", requireCallback: !0 }), this.itemStateKey = "isItemMatch", this.emptyItemValue = !1, this.defaultValue = !this.args.notEmpty;
|
|
8768
8788
|
}
|
|
8769
8789
|
static {
|
|
8770
|
-
this.computationType =
|
|
8790
|
+
this.computationType = dt;
|
|
8771
8791
|
}
|
|
8772
8792
|
static {
|
|
8773
8793
|
this.contextType = "global";
|
|
@@ -8775,7 +8795,7 @@ class Sn extends ze {
|
|
|
8775
8795
|
createState() {
|
|
8776
8796
|
return {
|
|
8777
8797
|
aggregate: new me({ matchCount: 0, totalCount: 0 }),
|
|
8778
|
-
isItemMatch: new
|
|
8798
|
+
isItemMatch: new O(!1, this.record.name)
|
|
8779
8799
|
};
|
|
8780
8800
|
}
|
|
8781
8801
|
getInitialValue() {
|
|
@@ -8806,16 +8826,16 @@ class En extends Ge {
|
|
|
8806
8826
|
super(e, t, i, { computationName: "Every", requireCallback: !0, requireXToMany: !0 }), this.itemStateKey = "isItemMatch", this.emptyItemValue = !1, this.defaultValue = !this.args.notEmpty;
|
|
8807
8827
|
}
|
|
8808
8828
|
static {
|
|
8809
|
-
this.computationType =
|
|
8829
|
+
this.computationType = dt;
|
|
8810
8830
|
}
|
|
8811
8831
|
static {
|
|
8812
8832
|
this.contextType = "property";
|
|
8813
8833
|
}
|
|
8814
8834
|
createState() {
|
|
8815
8835
|
return {
|
|
8816
|
-
matchCount: new
|
|
8817
|
-
totalCount: new
|
|
8818
|
-
isItemMatch: new
|
|
8836
|
+
matchCount: new O(0),
|
|
8837
|
+
totalCount: new O(0),
|
|
8838
|
+
isItemMatch: new O(!1, this.relation.name)
|
|
8819
8839
|
};
|
|
8820
8840
|
}
|
|
8821
8841
|
getInitialValue() {
|
|
@@ -8839,7 +8859,7 @@ class kn extends ze {
|
|
|
8839
8859
|
super(e, t, i, { computationName: "Any", requireCallback: !0 }), this.itemStateKey = "isItemMatch", this.emptyItemValue = !1;
|
|
8840
8860
|
}
|
|
8841
8861
|
static {
|
|
8842
|
-
this.computationType =
|
|
8862
|
+
this.computationType = ht;
|
|
8843
8863
|
}
|
|
8844
8864
|
static {
|
|
8845
8865
|
this.contextType = "global";
|
|
@@ -8847,7 +8867,7 @@ class kn extends ze {
|
|
|
8847
8867
|
createState() {
|
|
8848
8868
|
return {
|
|
8849
8869
|
matchCount: new me(0),
|
|
8850
|
-
isItemMatch: new
|
|
8870
|
+
isItemMatch: new O(!1, this.record.name)
|
|
8851
8871
|
};
|
|
8852
8872
|
}
|
|
8853
8873
|
getInitialValue() {
|
|
@@ -8870,15 +8890,15 @@ class Tn extends Ge {
|
|
|
8870
8890
|
super(e, t, i, { computationName: "Any", requireCallback: !0, requireXToMany: !0 }), this.itemStateKey = "isItemMatch", this.emptyItemValue = !1;
|
|
8871
8891
|
}
|
|
8872
8892
|
static {
|
|
8873
|
-
this.computationType =
|
|
8893
|
+
this.computationType = ht;
|
|
8874
8894
|
}
|
|
8875
8895
|
static {
|
|
8876
8896
|
this.contextType = "property";
|
|
8877
8897
|
}
|
|
8878
8898
|
createState() {
|
|
8879
8899
|
return {
|
|
8880
|
-
matchCount: new
|
|
8881
|
-
isItemMatch: new
|
|
8900
|
+
matchCount: new O(0),
|
|
8901
|
+
isItemMatch: new O(!1, this.relation.name)
|
|
8882
8902
|
};
|
|
8883
8903
|
}
|
|
8884
8904
|
getInitialValue() {
|
|
@@ -8902,7 +8922,7 @@ class xn extends ze {
|
|
|
8902
8922
|
super(e, t, i, { computationName: "Count" }), this.itemStateKey = "isItemMatch", this.emptyItemValue = !1;
|
|
8903
8923
|
}
|
|
8904
8924
|
static {
|
|
8905
|
-
this.computationType =
|
|
8925
|
+
this.computationType = ct;
|
|
8906
8926
|
}
|
|
8907
8927
|
static {
|
|
8908
8928
|
this.contextType = "global";
|
|
@@ -8910,7 +8930,7 @@ class xn extends ze {
|
|
|
8910
8930
|
createState() {
|
|
8911
8931
|
return {
|
|
8912
8932
|
count: new me(0),
|
|
8913
|
-
isItemMatch: new
|
|
8933
|
+
isItemMatch: new O(!1, this.record.name)
|
|
8914
8934
|
};
|
|
8915
8935
|
}
|
|
8916
8936
|
getInitialValue() {
|
|
@@ -8937,7 +8957,7 @@ class An extends Ge {
|
|
|
8937
8957
|
super(e, t, i, { computationName: "Count", allowRecordFallback: !0 }), this.emptyItemValue = !1;
|
|
8938
8958
|
}
|
|
8939
8959
|
static {
|
|
8940
|
-
this.computationType =
|
|
8960
|
+
this.computationType = ct;
|
|
8941
8961
|
}
|
|
8942
8962
|
static {
|
|
8943
8963
|
this.contextType = "property";
|
|
@@ -8951,9 +8971,9 @@ class An extends Ge {
|
|
|
8951
8971
|
}
|
|
8952
8972
|
createState() {
|
|
8953
8973
|
return {
|
|
8954
|
-
count: new
|
|
8974
|
+
count: new O(0, this.dataContext.host.name),
|
|
8955
8975
|
...this.callback ? {
|
|
8956
|
-
isItemMatchCount: new
|
|
8976
|
+
isItemMatchCount: new O(!1, this.relation.name)
|
|
8957
8977
|
} : {}
|
|
8958
8978
|
};
|
|
8959
8979
|
}
|
|
@@ -8992,7 +9012,7 @@ class Pn extends ae {
|
|
|
8992
9012
|
);
|
|
8993
9013
|
}
|
|
8994
9014
|
}
|
|
8995
|
-
class
|
|
9015
|
+
class At extends ae {
|
|
8996
9016
|
constructor(e) {
|
|
8997
9017
|
super(
|
|
8998
9018
|
`Transaction capability requirement is not satisfied: ${e.reason}`,
|
|
@@ -9032,8 +9052,8 @@ function On(s, e) {
|
|
|
9032
9052
|
function _o(s, e) {
|
|
9033
9053
|
return On(s, e) !== void 0;
|
|
9034
9054
|
}
|
|
9035
|
-
const
|
|
9036
|
-
function
|
|
9055
|
+
const Nr = [10, 25, 60, 150, 350];
|
|
9056
|
+
function Ln(s) {
|
|
9037
9057
|
return new Promise((e) => setTimeout(e, s));
|
|
9038
9058
|
}
|
|
9039
9059
|
function Rt(s, e, t, i) {
|
|
@@ -9043,7 +9063,7 @@ function Rt(s, e, t, i) {
|
|
|
9043
9063
|
transactionName: i
|
|
9044
9064
|
}), s;
|
|
9045
9065
|
}
|
|
9046
|
-
class
|
|
9066
|
+
class It extends Error {
|
|
9047
9067
|
constructor(e, t, i, r) {
|
|
9048
9068
|
super(`Transaction retry exhausted for ${e} after ${t} attempts`, { cause: r }), this.name = "TransactionRetryExhaustedError", this.transactionAttempts = t, this.transactionIsolation = i, this.transactionName = e, Object.assign(this, {
|
|
9049
9069
|
transactionAttempts: t,
|
|
@@ -9053,12 +9073,12 @@ class At extends Error {
|
|
|
9053
9073
|
}
|
|
9054
9074
|
}
|
|
9055
9075
|
function Bo(s) {
|
|
9056
|
-
return we(s).some((e) => e instanceof
|
|
9076
|
+
return we(s).some((e) => e instanceof It);
|
|
9057
9077
|
}
|
|
9058
9078
|
function Uo(s) {
|
|
9059
|
-
return we(s).some((e) => e instanceof
|
|
9079
|
+
return we(s).some((e) => e instanceof At);
|
|
9060
9080
|
}
|
|
9061
|
-
async function
|
|
9081
|
+
async function Li(s, e, t = {}) {
|
|
9062
9082
|
const i = t.maxAttempts ?? 5;
|
|
9063
9083
|
let r = "READ COMMITTED", a = 0, n;
|
|
9064
9084
|
for (; a < i; ) {
|
|
@@ -9068,7 +9088,7 @@ async function Oi(s, e, t = {}) {
|
|
|
9068
9088
|
} catch (o) {
|
|
9069
9089
|
if (n = o, Mn(o)) {
|
|
9070
9090
|
if (r = "SERIALIZABLE", a < i) continue;
|
|
9071
|
-
throw new
|
|
9091
|
+
throw new It(
|
|
9072
9092
|
s,
|
|
9073
9093
|
a,
|
|
9074
9094
|
r,
|
|
@@ -9077,11 +9097,11 @@ async function Oi(s, e, t = {}) {
|
|
|
9077
9097
|
}
|
|
9078
9098
|
if (Dn(o)) {
|
|
9079
9099
|
if (a < i) {
|
|
9080
|
-
const c =
|
|
9081
|
-
await
|
|
9100
|
+
const c = Nr[Math.min(a - 1, Nr.length - 1)], u = Math.floor(Math.random() * c);
|
|
9101
|
+
await Ln(c + u);
|
|
9082
9102
|
continue;
|
|
9083
9103
|
}
|
|
9084
|
-
throw new
|
|
9104
|
+
throw new It(
|
|
9085
9105
|
s,
|
|
9086
9106
|
a,
|
|
9087
9107
|
r,
|
|
@@ -9091,16 +9111,16 @@ async function Oi(s, e, t = {}) {
|
|
|
9091
9111
|
throw Rt(o, a, r, s);
|
|
9092
9112
|
}
|
|
9093
9113
|
}
|
|
9094
|
-
throw new
|
|
9114
|
+
throw new It(s, a, r, Rt(n, a, r, s));
|
|
9095
9115
|
}
|
|
9096
|
-
function
|
|
9116
|
+
function vt(s, e) {
|
|
9097
9117
|
if (s.id !== void 0 && s.id !== null)
|
|
9098
9118
|
throw new V(
|
|
9099
9119
|
`Transform callback for ${e.type} "${e.id.name}" returned a record with a top-level "id" field (${JSON.stringify(s.id)}). Derived record identity is managed by the framework; an explicit id collides with the target entity's own id sequence and silently corrupts data. Strip it before returning, e.g. callback: ({id: _, ...rest}) => ({...rest}).`,
|
|
9100
9120
|
{ computationName: "Transform", computationPhase: "transform-callback-result" }
|
|
9101
9121
|
);
|
|
9102
9122
|
}
|
|
9103
|
-
class
|
|
9123
|
+
class Fn {
|
|
9104
9124
|
constructor(e, t, i) {
|
|
9105
9125
|
this.controller = e, this.args = t, this.dataContext = i, this.useLastValue = !1, this.dataDeps = {}, this.primaryDataDepKeys = ["_source"], _(!(this.args.record && this.args.eventDeps), "Transform must have either record or eventDep"), this.transformCallback = this.args.callback.bind(this.controller), this.args.eventDeps ? this.eventDeps = this.args.eventDeps : this.dataDeps = {
|
|
9106
9126
|
_source: {
|
|
@@ -9111,13 +9131,13 @@ class Ln {
|
|
|
9111
9131
|
};
|
|
9112
9132
|
}
|
|
9113
9133
|
static {
|
|
9114
|
-
this.computationType =
|
|
9134
|
+
this.computationType = zt;
|
|
9115
9135
|
}
|
|
9116
9136
|
static {
|
|
9117
9137
|
this.contextType = ["entity", "relation"];
|
|
9118
9138
|
}
|
|
9119
9139
|
createState() {
|
|
9120
|
-
const e = new
|
|
9140
|
+
const e = new O(""), t = new O(0);
|
|
9121
9141
|
return e.unique = !this.eventDeps, {
|
|
9122
9142
|
sourceRecordId: e,
|
|
9123
9143
|
transformIndex: t
|
|
@@ -9132,7 +9152,7 @@ class Ln {
|
|
|
9132
9152
|
for (const i of e) {
|
|
9133
9153
|
const r = await this.transformCallback.call(this.controller, i);
|
|
9134
9154
|
(Array.isArray(r) ? r : [r]).forEach((n, o) => {
|
|
9135
|
-
n && (
|
|
9155
|
+
n && (vt(n, this.dataContext), t.push({
|
|
9136
9156
|
...n,
|
|
9137
9157
|
[this.state.sourceRecordId.key]: i.id,
|
|
9138
9158
|
[this.state.transformIndex.key]: o
|
|
@@ -9153,7 +9173,7 @@ class Ln {
|
|
|
9153
9173
|
async eventBasedIncrementalPatchCompute(e, t) {
|
|
9154
9174
|
const i = [], r = await this.transformCallback.call(this.controller, t);
|
|
9155
9175
|
return (Array.isArray(r) ? r : [r]).forEach((n, o) => {
|
|
9156
|
-
n && (
|
|
9176
|
+
n && (vt(n, this.dataContext), i.push({
|
|
9157
9177
|
type: "insert",
|
|
9158
9178
|
data: {
|
|
9159
9179
|
...n,
|
|
@@ -9168,7 +9188,7 @@ class Ln {
|
|
|
9168
9188
|
if (t.type === "create") {
|
|
9169
9189
|
const a = E.atom({ key: "id", value: ["=", t.record.id] }), n = this.dataDeps._source, o = await this.controller.system.storage.findOne(n.source.name, a, void 0, n.attributeQuery), c = await this.transformCallback.call(this.controller, o);
|
|
9170
9190
|
(Array.isArray(c) ? c : [c]).forEach((l, d) => {
|
|
9171
|
-
l && (
|
|
9191
|
+
l && (vt(l, this.dataContext), r.push({
|
|
9172
9192
|
type: "insert",
|
|
9173
9193
|
data: {
|
|
9174
9194
|
...l,
|
|
@@ -9195,7 +9215,7 @@ class Ln {
|
|
|
9195
9215
|
}
|
|
9196
9216
|
const o = E.atom({ key: this.state.sourceRecordId.key, value: ["=", a] }), u = (await this.controller.system.storage.atomic.lockRows(i.id.name, o, ["*"])).reduce((l, d) => (l[Number(d[this.state.transformIndex.key])] = d, l), {});
|
|
9197
9217
|
n.forEach((l, d) => {
|
|
9198
|
-
l && (
|
|
9218
|
+
l && (vt(l, this.dataContext), u[d] ? (r.push({
|
|
9199
9219
|
type: "update",
|
|
9200
9220
|
data: {
|
|
9201
9221
|
...l,
|
|
@@ -9221,7 +9241,7 @@ class Ln {
|
|
|
9221
9241
|
return r;
|
|
9222
9242
|
}
|
|
9223
9243
|
}
|
|
9224
|
-
const Vn = [
|
|
9244
|
+
const Vn = [Fn];
|
|
9225
9245
|
class J {
|
|
9226
9246
|
constructor(e) {
|
|
9227
9247
|
this.node = e;
|
|
@@ -9320,10 +9340,10 @@ class J {
|
|
|
9320
9340
|
}
|
|
9321
9341
|
}
|
|
9322
9342
|
gt(e) {
|
|
9323
|
-
return new
|
|
9343
|
+
return new _t(this, ">", e);
|
|
9324
9344
|
}
|
|
9325
9345
|
lt(e) {
|
|
9326
|
-
return new
|
|
9346
|
+
return new _t(this, "<", e);
|
|
9327
9347
|
}
|
|
9328
9348
|
eq(e) {
|
|
9329
9349
|
return new Fi(this, e);
|
|
@@ -9423,7 +9443,7 @@ class J {
|
|
|
9423
9443
|
}
|
|
9424
9444
|
}
|
|
9425
9445
|
}
|
|
9426
|
-
class
|
|
9446
|
+
class _t {
|
|
9427
9447
|
constructor(e, t, i) {
|
|
9428
9448
|
this.left = e, this.operator = t, this.right = i;
|
|
9429
9449
|
}
|
|
@@ -9520,7 +9540,7 @@ class _n {
|
|
|
9520
9540
|
this.controller = e, this.args = t, this.dataContext = i, this.useLastValue = !1, this.dataDeps = this.args.dataDeps ?? {}, this.callback = (r, a) => this.args.callback.call(this.controller, r, a), this.nextRecomputeTime = this.args.nextRecomputeTime ? (r, a) => this.args.nextRecomputeTime.call(this.controller, r, a) : void 0;
|
|
9521
9541
|
}
|
|
9522
9542
|
static {
|
|
9523
|
-
this.computationType =
|
|
9543
|
+
this.computationType = pt;
|
|
9524
9544
|
}
|
|
9525
9545
|
static {
|
|
9526
9546
|
this.contextType = "global";
|
|
@@ -9537,7 +9557,7 @@ class _n {
|
|
|
9537
9557
|
// TODO now 是不是应该用 dataDeps 动态注入???这样能手动测试。改成在哪里配置?
|
|
9538
9558
|
async compute(e) {
|
|
9539
9559
|
const t = await this.args.callback(J.variable("now"), e), i = Date.now();
|
|
9540
|
-
if (!(t instanceof J) && !(t instanceof
|
|
9560
|
+
if (!(t instanceof J) && !(t instanceof _t) && !(t instanceof Fi))
|
|
9541
9561
|
throw new Error("Invalid result type");
|
|
9542
9562
|
const r = t.evaluate({ now: i }), a = ea(t, i, e, this.nextRecomputeTime, `global:${this.dataContext.id?.name ?? String(this.dataContext.id)}`);
|
|
9543
9563
|
return await this.state.lastRecomputeTime.setInternal(i), await this.state.nextRecomputeTime.setInternal(a), r;
|
|
@@ -9563,15 +9583,15 @@ class Bn {
|
|
|
9563
9583
|
this.isResultNumber = this.dataContext.id.type === "number", this.callback = (r, a) => this.args.callback.call(this.controller, r, a), this.nextRecomputeTime = this.args.nextRecomputeTime ? (r, a) => this.args.nextRecomputeTime.call(this.controller, r, a) : void 0;
|
|
9564
9584
|
}
|
|
9565
9585
|
static {
|
|
9566
|
-
this.computationType =
|
|
9586
|
+
this.computationType = pt;
|
|
9567
9587
|
}
|
|
9568
9588
|
static {
|
|
9569
9589
|
this.contextType = "property";
|
|
9570
9590
|
}
|
|
9571
9591
|
createState() {
|
|
9572
9592
|
return {
|
|
9573
|
-
lastRecomputeTime: new
|
|
9574
|
-
nextRecomputeTime: new
|
|
9593
|
+
lastRecomputeTime: new O(null),
|
|
9594
|
+
nextRecomputeTime: new O(null)
|
|
9575
9595
|
};
|
|
9576
9596
|
}
|
|
9577
9597
|
getInitialValue() {
|
|
@@ -9580,7 +9600,7 @@ class Bn {
|
|
|
9580
9600
|
// TODO now 是不是应该用 dataDeps 动态注入???这样能手动测试。改成在哪里配置?
|
|
9581
9601
|
async compute(e, t) {
|
|
9582
9602
|
const i = await this.args.callback(J.variable("now"), e), r = Date.now();
|
|
9583
|
-
if (!(i instanceof J) && !(i instanceof
|
|
9603
|
+
if (!(i instanceof J) && !(i instanceof _t) && !(i instanceof Fi))
|
|
9584
9604
|
throw new Error("Invalid result type");
|
|
9585
9605
|
const a = i.evaluate({ now: r }), n = ea(i, r, e, this.nextRecomputeTime, `property:${this.dataContext.host?.name ?? ""}.${this.dataContext.id?.name ?? String(this.dataContext.id)}`);
|
|
9586
9606
|
return await this.state.lastRecomputeTime.setInternal(t, r), await this.state.nextRecomputeTime.setInternal(t, n), a;
|
|
@@ -9595,10 +9615,10 @@ function ta(s, e) {
|
|
|
9595
9615
|
}
|
|
9596
9616
|
class Qn extends ze {
|
|
9597
9617
|
constructor(e, t, i) {
|
|
9598
|
-
super(e, t, i, { computationName: "Summation", requireAttributeQueryField: !0 }), this.itemStateKey = "itemValue", this.emptyItemValue = 0, this.sumFieldPath =
|
|
9618
|
+
super(e, t, i, { computationName: "Summation", requireAttributeQueryField: !0 }), this.itemStateKey = "itemValue", this.emptyItemValue = 0, this.sumFieldPath = Yt(this.args.attributeQuery, () => `Summation computation of ${X(i)}`);
|
|
9599
9619
|
}
|
|
9600
9620
|
static {
|
|
9601
|
-
this.computationType =
|
|
9621
|
+
this.computationType = ut;
|
|
9602
9622
|
}
|
|
9603
9623
|
static {
|
|
9604
9624
|
this.contextType = "global";
|
|
@@ -9606,7 +9626,7 @@ class Qn extends ze {
|
|
|
9606
9626
|
createState() {
|
|
9607
9627
|
return {
|
|
9608
9628
|
sum: new me(0),
|
|
9609
|
-
itemValue: new
|
|
9629
|
+
itemValue: new O(0, this.record.name)
|
|
9610
9630
|
};
|
|
9611
9631
|
}
|
|
9612
9632
|
getInitialValue() {
|
|
@@ -9625,18 +9645,18 @@ class Qn extends ze {
|
|
|
9625
9645
|
}
|
|
9626
9646
|
class jn extends Ge {
|
|
9627
9647
|
constructor(e, t, i) {
|
|
9628
|
-
super(e, t, i, { computationName: "Summation", requireAttributeQueryField: !0 }), this.itemStateKey = "itemResult", this.emptyItemValue = 0, this.sumFieldPath =
|
|
9648
|
+
super(e, t, i, { computationName: "Summation", requireAttributeQueryField: !0 }), this.itemStateKey = "itemResult", this.emptyItemValue = 0, this.sumFieldPath = Yt(this.args.attributeQuery, () => `Summation computation of ${X(i)}`);
|
|
9629
9649
|
}
|
|
9630
9650
|
static {
|
|
9631
|
-
this.computationType =
|
|
9651
|
+
this.computationType = ut;
|
|
9632
9652
|
}
|
|
9633
9653
|
static {
|
|
9634
9654
|
this.contextType = "property";
|
|
9635
9655
|
}
|
|
9636
9656
|
createState() {
|
|
9637
9657
|
return {
|
|
9638
|
-
sum: new
|
|
9639
|
-
itemResult: new
|
|
9658
|
+
sum: new O(0, this.dataContext.host.name),
|
|
9659
|
+
itemResult: new O(0, this.relation.name)
|
|
9640
9660
|
};
|
|
9641
9661
|
}
|
|
9642
9662
|
getInitialValue() {
|
|
@@ -9662,10 +9682,10 @@ function ia(s, e) {
|
|
|
9662
9682
|
}
|
|
9663
9683
|
class Kn extends ze {
|
|
9664
9684
|
constructor(e, t, i) {
|
|
9665
|
-
super(e, t, i, { computationName: "Average", requireAttributeQueryField: !0 }), this.itemStateKey = "itemValue", this.emptyItemValue = 0, this.avgFieldPath =
|
|
9685
|
+
super(e, t, i, { computationName: "Average", requireAttributeQueryField: !0 }), this.itemStateKey = "itemValue", this.emptyItemValue = 0, this.avgFieldPath = Yt(this.args.attributeQuery, () => `Average computation of ${X(i)}`);
|
|
9666
9686
|
}
|
|
9667
9687
|
static {
|
|
9668
|
-
this.computationType =
|
|
9688
|
+
this.computationType = lt;
|
|
9669
9689
|
}
|
|
9670
9690
|
static {
|
|
9671
9691
|
this.contextType = "global";
|
|
@@ -9673,7 +9693,7 @@ class Kn extends ze {
|
|
|
9673
9693
|
createState() {
|
|
9674
9694
|
return {
|
|
9675
9695
|
aggregate: new me({ sum: 0, count: 0 }),
|
|
9676
|
-
itemValue: new
|
|
9696
|
+
itemValue: new O(0, this.record.name)
|
|
9677
9697
|
};
|
|
9678
9698
|
}
|
|
9679
9699
|
getInitialValue() {
|
|
@@ -9701,19 +9721,19 @@ class Kn extends ze {
|
|
|
9701
9721
|
}
|
|
9702
9722
|
class Wn extends Ge {
|
|
9703
9723
|
constructor(e, t, i) {
|
|
9704
|
-
super(e, t, i, { computationName: "Average", requireAttributeQueryField: !0 }), this.itemStateKey = "itemResult", this.emptyItemValue = 0, this.avgFieldPath =
|
|
9724
|
+
super(e, t, i, { computationName: "Average", requireAttributeQueryField: !0 }), this.itemStateKey = "itemResult", this.emptyItemValue = 0, this.avgFieldPath = Yt(this.args.attributeQuery, () => `Average computation of ${X(i)}`);
|
|
9705
9725
|
}
|
|
9706
9726
|
static {
|
|
9707
|
-
this.computationType =
|
|
9727
|
+
this.computationType = lt;
|
|
9708
9728
|
}
|
|
9709
9729
|
static {
|
|
9710
9730
|
this.contextType = "property";
|
|
9711
9731
|
}
|
|
9712
9732
|
createState() {
|
|
9713
9733
|
return {
|
|
9714
|
-
sum: new
|
|
9715
|
-
count: new
|
|
9716
|
-
itemResult: new
|
|
9734
|
+
sum: new O(0, this.dataContext.host.name),
|
|
9735
|
+
count: new O(0, this.dataContext.host.name),
|
|
9736
|
+
itemResult: new O(0, this.relation.name)
|
|
9717
9737
|
};
|
|
9718
9738
|
}
|
|
9719
9739
|
getInitialValue() {
|
|
@@ -9732,7 +9752,7 @@ class Wn extends Ge {
|
|
|
9732
9752
|
}
|
|
9733
9753
|
}
|
|
9734
9754
|
const zn = [Kn, Wn];
|
|
9735
|
-
class
|
|
9755
|
+
class Zt {
|
|
9736
9756
|
constructor(e, t, i) {
|
|
9737
9757
|
this.controller = e, this.args = t, this.dataContext = i, this.state = {}, this.dataDeps = {};
|
|
9738
9758
|
const r = i.type === "entity" || i.type === "relation";
|
|
@@ -9796,7 +9816,7 @@ class Yt {
|
|
|
9796
9816
|
}));
|
|
9797
9817
|
}
|
|
9798
9818
|
static {
|
|
9799
|
-
this.computationType =
|
|
9819
|
+
this.computationType = Wt;
|
|
9800
9820
|
}
|
|
9801
9821
|
createState() {
|
|
9802
9822
|
if (this.createStateCallback) {
|
|
@@ -9843,22 +9863,22 @@ class Yt {
|
|
|
9843
9863
|
};
|
|
9844
9864
|
}
|
|
9845
9865
|
}
|
|
9846
|
-
class Gn extends
|
|
9866
|
+
class Gn extends Zt {
|
|
9847
9867
|
static {
|
|
9848
9868
|
this.contextType = "global";
|
|
9849
9869
|
}
|
|
9850
9870
|
}
|
|
9851
|
-
class Jn extends
|
|
9871
|
+
class Jn extends Zt {
|
|
9852
9872
|
static {
|
|
9853
9873
|
this.contextType = "entity";
|
|
9854
9874
|
}
|
|
9855
9875
|
}
|
|
9856
|
-
class Xn extends
|
|
9876
|
+
class Xn extends Zt {
|
|
9857
9877
|
static {
|
|
9858
9878
|
this.contextType = "relation";
|
|
9859
9879
|
}
|
|
9860
9880
|
}
|
|
9861
|
-
class Yn extends
|
|
9881
|
+
class Yn extends Zt {
|
|
9862
9882
|
static {
|
|
9863
9883
|
this.contextType = "property";
|
|
9864
9884
|
}
|
|
@@ -9879,7 +9899,7 @@ const Zn = [
|
|
|
9879
9899
|
Xn,
|
|
9880
9900
|
Yn
|
|
9881
9901
|
];
|
|
9882
|
-
function
|
|
9902
|
+
function vi(s, e) {
|
|
9883
9903
|
const t = e.split(".");
|
|
9884
9904
|
let i = s;
|
|
9885
9905
|
for (const r of t) {
|
|
@@ -9924,7 +9944,7 @@ function aa(s, e) {
|
|
|
9924
9944
|
function es(s, e) {
|
|
9925
9945
|
const t = [];
|
|
9926
9946
|
for (const i of s)
|
|
9927
|
-
t.push(aa(i.name, ra(i,
|
|
9947
|
+
t.push(aa(i.name, ra(i, vi(e, i.path))));
|
|
9928
9948
|
return t;
|
|
9929
9949
|
}
|
|
9930
9950
|
function na(s, e) {
|
|
@@ -9938,11 +9958,11 @@ function na(s, e) {
|
|
|
9938
9958
|
function Ee(s) {
|
|
9939
9959
|
return s == null;
|
|
9940
9960
|
}
|
|
9941
|
-
function
|
|
9961
|
+
function Rr(s) {
|
|
9942
9962
|
return typeof s == "object" && s !== null && "id" in s ? s.id : s;
|
|
9943
9963
|
}
|
|
9944
|
-
function
|
|
9945
|
-
return
|
|
9964
|
+
function St(s, e) {
|
|
9965
|
+
return Rr(s) === Rr(e);
|
|
9946
9966
|
}
|
|
9947
9967
|
function ts(s, e) {
|
|
9948
9968
|
const t = e.split(".");
|
|
@@ -9963,16 +9983,16 @@ function is(s, e) {
|
|
|
9963
9983
|
case "is not null":
|
|
9964
9984
|
return !Ee(r);
|
|
9965
9985
|
case "=":
|
|
9966
|
-
return i === null ? Ee(r) : !Ee(r) &&
|
|
9986
|
+
return i === null ? Ee(r) : !Ee(r) && St(r, i);
|
|
9967
9987
|
case "!=":
|
|
9968
|
-
return i === null ? !Ee(r) : !Ee(r) && !
|
|
9988
|
+
return i === null ? !Ee(r) : !Ee(r) && !St(r, i);
|
|
9969
9989
|
case "in": {
|
|
9970
9990
|
if (!Array.isArray(i)) throw new Error("ScopedSequence.match in value must be an array");
|
|
9971
|
-
return Ee(r) ? i.includes(null) : i.some((a) => a !== null &&
|
|
9991
|
+
return Ee(r) ? i.includes(null) : i.some((a) => a !== null && St(r, a));
|
|
9972
9992
|
}
|
|
9973
9993
|
case "not in": {
|
|
9974
9994
|
if (!Array.isArray(i)) throw new Error("ScopedSequence.match not in value must be an array");
|
|
9975
|
-
return Ee(r) ? !1 : i.every((a) => a === null || !
|
|
9995
|
+
return Ee(r) ? !1 : i.every((a) => a === null || !St(r, a));
|
|
9976
9996
|
}
|
|
9977
9997
|
}
|
|
9978
9998
|
}
|
|
@@ -9984,11 +10004,11 @@ function _e(s, e) {
|
|
|
9984
10004
|
throw new Error(`ScopedSequence.match has unsupported boolean operator "${String(s.operator)}"`);
|
|
9985
10005
|
}
|
|
9986
10006
|
function sa(s, e) {
|
|
9987
|
-
const t =
|
|
10007
|
+
const t = Re(s);
|
|
9988
10008
|
return t ? _e(t, e) : !0;
|
|
9989
10009
|
}
|
|
9990
10010
|
function oa(s) {
|
|
9991
|
-
const e =
|
|
10011
|
+
const e = Re(s), t = [];
|
|
9992
10012
|
if (!e) return t;
|
|
9993
10013
|
const i = (r) => {
|
|
9994
10014
|
if (r.type === "atom") {
|
|
@@ -10026,7 +10046,7 @@ class ns {
|
|
|
10026
10046
|
throw new Error("ScopedSequence is not supported by the current storage driver");
|
|
10027
10047
|
}
|
|
10028
10048
|
static {
|
|
10029
|
-
this.computationType =
|
|
10049
|
+
this.computationType = et;
|
|
10030
10050
|
}
|
|
10031
10051
|
static {
|
|
10032
10052
|
this.contextType = "property";
|
|
@@ -10064,16 +10084,16 @@ class ns {
|
|
|
10064
10084
|
}
|
|
10065
10085
|
}
|
|
10066
10086
|
const ss = [ns];
|
|
10067
|
-
function
|
|
10087
|
+
function Si(s) {
|
|
10068
10088
|
if (s === null || typeof s != "object")
|
|
10069
10089
|
return typeof s == "function" ? "[Function]" : JSON.stringify(s);
|
|
10070
10090
|
if (Array.isArray(s))
|
|
10071
|
-
return `[${s.map(
|
|
10091
|
+
return `[${s.map(Si).join(",")}]`;
|
|
10072
10092
|
const e = s;
|
|
10073
|
-
return `{${Object.keys(e).sort().map((t) => `${JSON.stringify(t)}:${
|
|
10093
|
+
return `{${Object.keys(e).sort().map((t) => `${JSON.stringify(t)}:${Si(e[t])}`).join(",")}}`;
|
|
10074
10094
|
}
|
|
10075
10095
|
function Sr(s) {
|
|
10076
|
-
return
|
|
10096
|
+
return Lr("sha256").update(Si(s)).digest("hex");
|
|
10077
10097
|
}
|
|
10078
10098
|
function os(s) {
|
|
10079
10099
|
if (s._type !== "ScopedSequence") return;
|
|
@@ -10082,7 +10102,7 @@ function os(s) {
|
|
|
10082
10102
|
type: r.type,
|
|
10083
10103
|
path: r.path,
|
|
10084
10104
|
base: r.type === "ref" ? r.base?.name : void 0
|
|
10085
|
-
})), t = s.initializeFrom, i =
|
|
10105
|
+
})), t = s.initializeFrom, i = Re(s.match);
|
|
10086
10106
|
return {
|
|
10087
10107
|
kind: "scoped-sequence",
|
|
10088
10108
|
timing: "post-create-pre-commit",
|
|
@@ -10113,10 +10133,10 @@ function ca(s) {
|
|
|
10113
10133
|
function cs(s, e) {
|
|
10114
10134
|
return `computation:property:${s}.${e}:ScopedSequence`;
|
|
10115
10135
|
}
|
|
10116
|
-
const
|
|
10117
|
-
class
|
|
10136
|
+
const li = "_ASYNC_TASK_";
|
|
10137
|
+
class Bt {
|
|
10118
10138
|
constructor(e, t, i, r, a) {
|
|
10119
|
-
this.controller = e, this.computationsHandles = /* @__PURE__ */ new Map(), this.computationHandleMap = /* @__PURE__ */ new Map(), this.registeredMutationListeners = [], this.erMutationEventSources = [], this.dataSourceMapTree = {}, this.scopedSequenceScopeGuards = [], this.propagationContext = new
|
|
10139
|
+
this.controller = e, this.computationsHandles = /* @__PURE__ */ new Map(), this.computationHandleMap = /* @__PURE__ */ new Map(), this.registeredMutationListeners = [], this.erMutationEventSources = [], this.dataSourceMapTree = {}, this.scopedSequenceScopeGuards = [], this.propagationContext = new Ai(), this.plainValuePropertyNamesBySource = /* @__PURE__ */ new WeakMap(), this.sourceMapManager = new zr(this.controller, this), this.buildComputationHandleMap(a);
|
|
10120
10140
|
const n = [];
|
|
10121
10141
|
r.forEach((o) => {
|
|
10122
10142
|
o.computation && n.push({ dataContext: { type: "global", id: o }, args: o.computation });
|
|
@@ -10283,7 +10303,7 @@ class _t {
|
|
|
10283
10303
|
const i = t.createState();
|
|
10284
10304
|
e.push({ dataContext: t.dataContext, state: i }), t.state = i;
|
|
10285
10305
|
for (let [r, a] of Object.entries(i))
|
|
10286
|
-
if (a.controller = this.controller, a.key = this.getBoundStateName(t.dataContext, r, a), a instanceof
|
|
10306
|
+
if (a.controller = this.controller, a.key = this.getBoundStateName(t.dataContext, r, a), a instanceof O && !a.record)
|
|
10287
10307
|
if (t.dataContext.type === "property")
|
|
10288
10308
|
a.record = t.dataContext.host.name;
|
|
10289
10309
|
else if (t.dataContext.type === "entity")
|
|
@@ -10447,10 +10467,10 @@ class _t {
|
|
|
10447
10467
|
buildComputationMutationListener() {
|
|
10448
10468
|
return this.sourceMapManager.initialize(new Set(this.computationsHandles.values())), this.dataSourceMapTree = this.sourceMapManager.getSourceMapTree(), this.buildScopedSequenceScopeGuards(), (async (e) => {
|
|
10449
10469
|
const t = this.propagationContext.getStore(), i = (t?.depth ?? 0) + 1;
|
|
10450
|
-
if (i >
|
|
10470
|
+
if (i > Bt.MAX_COMPUTATION_PROPAGATION_DEPTH) {
|
|
10451
10471
|
const a = (t?.trail ?? []).slice(-10).join(" -> ");
|
|
10452
10472
|
throw new Be(
|
|
10453
|
-
`Computation propagation exceeded the maximum depth of ${
|
|
10473
|
+
`Computation propagation exceeded the maximum depth of ${Bt.MAX_COMPUTATION_PROPAGATION_DEPTH}. This almost always means circular computation dependencies (e.g. two Transforms deriving records from each other, or a computation whose dataDeps include its own output). Recent propagation trail: ${a}`,
|
|
10454
10474
|
{ schedulingPhase: "computation-propagation-depth-guard" }
|
|
10455
10475
|
);
|
|
10456
10476
|
}
|
|
@@ -10629,8 +10649,8 @@ class _t {
|
|
|
10629
10649
|
getAsyncTaskRecordKey(e) {
|
|
10630
10650
|
if (e.dataContext.type === "property") {
|
|
10631
10651
|
const t = e.dataContext;
|
|
10632
|
-
return `${
|
|
10633
|
-
} else return e.dataContext.type === "global" ? `${
|
|
10652
|
+
return `${li}_${t.host.name}_${t.id.name}`;
|
|
10653
|
+
} else return e.dataContext.type === "global" ? `${li}_${e.dataContext.id.name}` : `${li}_${e.dataContext.type}_${e.dataContext.id?.name}`;
|
|
10634
10654
|
}
|
|
10635
10655
|
getComputationName(e) {
|
|
10636
10656
|
return e.args.name || e.args.constructor.displayName;
|
|
@@ -10650,54 +10670,101 @@ class _t {
|
|
|
10650
10670
|
const t = e.modifier;
|
|
10651
10671
|
return t.limit !== void 0 || t.offset !== void 0 || t.orderBy !== void 0;
|
|
10652
10672
|
}
|
|
10673
|
+
/**
|
|
10674
|
+
* 从 match key 路径读取事件快照上的值。
|
|
10675
|
+
* CAUTION 「键缺席」与「值为 null」必须区分(r21 F-1):事件快照只携带写入时的字段——
|
|
10676
|
+
* computed 列、未涉及的关系属性都可能缺席但在库里有值。把缺席当 undefined 参与比较
|
|
10677
|
+
* 会让本地判定与 SQL 判定分裂(`=` 误判 false → 错误 skip → 计算静默陈旧;
|
|
10678
|
+
* `!=` 误判 true → 幻影 entered → 计算多计)。
|
|
10679
|
+
* 中段值为 null(快照如实携带的空关系)按 LEFT JOIN 语义解析为终端 NULL——
|
|
10680
|
+
* 与 SQL 的三值逻辑照常比较。
|
|
10681
|
+
*/
|
|
10653
10682
|
readMatchPath(e, t) {
|
|
10654
|
-
if (!e) return;
|
|
10655
10683
|
let i = e;
|
|
10656
10684
|
for (const r of t.split(".")) {
|
|
10657
|
-
if (i
|
|
10685
|
+
if (i === null) return { resolved: !0, value: null };
|
|
10686
|
+
if (i === void 0 || typeof i != "object" || Array.isArray(i)) return { resolved: !1 };
|
|
10687
|
+
if (!Object.prototype.hasOwnProperty.call(i, r)) return { resolved: !1 };
|
|
10658
10688
|
i = i[r];
|
|
10659
10689
|
}
|
|
10660
|
-
return i;
|
|
10690
|
+
return { resolved: !0, value: i === void 0 ? null : i };
|
|
10661
10691
|
}
|
|
10692
|
+
/**
|
|
10693
|
+
* 本地比较必须与 SQL 谓词求值(MatchExp 编译结果 + 三值逻辑)语义一致,
|
|
10694
|
+
* 不可判定时返回 undefined(上层走保守的 full recompute)。
|
|
10695
|
+
* - `=`/`!=` 对 null 操作数按 IS NULL / IS NOT NULL(与 MatchExp 编译一致);
|
|
10696
|
+
* NULL 行对非 null 操作数的任何比较都是 UNKNOWN(不匹配)。
|
|
10697
|
+
* - in/not in 按 r20 编译期 null 拆分后的语义(in 含 null → IS NULL OR IN(非空集);
|
|
10698
|
+
* not in 无论列表是否含 null,NULL 行都不匹配)。
|
|
10699
|
+
* - like 的大小写敏感性因驱动而异(PG 敏感 / SQLite ASCII 不敏感)且 `_` 通配未实现——不可判定。
|
|
10700
|
+
* - 对象/数组值(json 列、ref 对象、Date)无法在本地忠实模拟 SQL 比较——不可判定。
|
|
10701
|
+
*/
|
|
10662
10702
|
compareMatchValue(e, t, i) {
|
|
10663
|
-
|
|
10703
|
+
const r = typeof t == "string" ? t.toLowerCase() : t, a = (n) => typeof n == "string" || typeof n == "number" || typeof n == "boolean";
|
|
10704
|
+
switch (r) {
|
|
10664
10705
|
case "=":
|
|
10665
10706
|
case "==":
|
|
10666
|
-
return e === i;
|
|
10707
|
+
return i === null ? e === null : e === null ? !1 : !a(e) || !a(i) ? void 0 : e === i;
|
|
10667
10708
|
case "!=":
|
|
10668
10709
|
case "<>":
|
|
10669
|
-
return e !== i;
|
|
10710
|
+
return i === null ? e !== null : e === null ? !1 : !a(e) || !a(i) ? void 0 : e !== i;
|
|
10711
|
+
case "not":
|
|
10712
|
+
return i === null ? e !== null : void 0;
|
|
10713
|
+
case "is null":
|
|
10714
|
+
return e === null;
|
|
10715
|
+
case "is not null":
|
|
10716
|
+
return e !== null;
|
|
10670
10717
|
case ">":
|
|
10671
|
-
return typeof e == "number" && typeof i == "number" ? e > i : void 0;
|
|
10718
|
+
return e === null || i === null ? !1 : typeof e == "number" && typeof i == "number" ? e > i : void 0;
|
|
10672
10719
|
case ">=":
|
|
10673
|
-
return typeof e == "number" && typeof i == "number" ? e >= i : void 0;
|
|
10720
|
+
return e === null || i === null ? !1 : typeof e == "number" && typeof i == "number" ? e >= i : void 0;
|
|
10674
10721
|
case "<":
|
|
10675
|
-
return typeof e == "number" && typeof i == "number" ? e < i : void 0;
|
|
10722
|
+
return e === null || i === null ? !1 : typeof e == "number" && typeof i == "number" ? e < i : void 0;
|
|
10676
10723
|
case "<=":
|
|
10677
|
-
return typeof e == "number" && typeof i == "number" ? e <= i : void 0;
|
|
10724
|
+
return e === null || i === null ? !1 : typeof e == "number" && typeof i == "number" ? e <= i : void 0;
|
|
10678
10725
|
case "in":
|
|
10679
|
-
return Array.isArray(i) ? i.includes(e) : void 0;
|
|
10726
|
+
return Array.isArray(i) ? e === null ? i.includes(null) : a(e) ? i.includes(e) : void 0 : void 0;
|
|
10680
10727
|
case "not in":
|
|
10681
|
-
return Array.isArray(i) ? !i.includes(e) : void 0;
|
|
10682
|
-
case "not":
|
|
10683
|
-
return e !== i;
|
|
10684
|
-
case "like":
|
|
10685
|
-
return typeof e != "string" || typeof i != "string" ? void 0 : new RegExp(`^${i.split("%").map((r) => r.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join(".*")}$`).test(e);
|
|
10728
|
+
return Array.isArray(i) ? e === null ? !1 : a(e) ? !i.includes(e) : void 0 : void 0;
|
|
10686
10729
|
default:
|
|
10687
10730
|
return;
|
|
10688
10731
|
}
|
|
10689
10732
|
}
|
|
10690
|
-
|
|
10733
|
+
getPlainValuePropertyNames(e) {
|
|
10734
|
+
const t = this.plainValuePropertyNamesBySource.get(e);
|
|
10735
|
+
if (t) return t;
|
|
10736
|
+
const i = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), a = (n) => {
|
|
10737
|
+
if (!n || typeof n != "object" || r.has(n)) return;
|
|
10738
|
+
r.add(n);
|
|
10739
|
+
const o = n;
|
|
10740
|
+
for (const c of o.properties || [])
|
|
10741
|
+
!c?.name || c.computed || c.computation || i.add(c.name);
|
|
10742
|
+
a(o.baseEntity), a(o.baseRelation);
|
|
10743
|
+
for (const c of o.inputEntities || []) a(c);
|
|
10744
|
+
for (const c of o.inputRelations || []) a(c);
|
|
10745
|
+
};
|
|
10746
|
+
return a(e), this.plainValuePropertyNamesBySource.set(e, i), i;
|
|
10747
|
+
}
|
|
10748
|
+
evaluateRecordsMatch(e, t, i) {
|
|
10691
10749
|
if (!e) return !0;
|
|
10692
10750
|
if (!t) return;
|
|
10693
|
-
const
|
|
10694
|
-
if (
|
|
10695
|
-
const
|
|
10696
|
-
|
|
10751
|
+
const r = e, a = r.raw || r;
|
|
10752
|
+
if (a.type === "atom") {
|
|
10753
|
+
const n = a.data;
|
|
10754
|
+
if (!n || typeof n.key != "string" || !Array.isArray(n.value) || n.isReferenceValue) return;
|
|
10755
|
+
const o = this.readMatchPath(t, n.key);
|
|
10756
|
+
let c;
|
|
10757
|
+
if (o.resolved)
|
|
10758
|
+
c = o.value;
|
|
10759
|
+
else if (!n.key.includes(".") && i.has(n.key))
|
|
10760
|
+
c = null;
|
|
10761
|
+
else
|
|
10762
|
+
return;
|
|
10763
|
+
return this.compareMatchValue(c, n.value[0], n.value[1]);
|
|
10697
10764
|
}
|
|
10698
|
-
if (
|
|
10699
|
-
const
|
|
10700
|
-
return
|
|
10765
|
+
if (a.type === "expression") {
|
|
10766
|
+
const n = this.evaluateRecordsMatch(a.left, t, i), o = a.right ? this.evaluateRecordsMatch(a.right, t, i) : void 0;
|
|
10767
|
+
return a.operator === "and" ? n === !1 || o === !1 ? !1 : n === void 0 || o === void 0 ? void 0 : !0 : a.operator === "or" ? n === !0 || o === !0 ? !0 : n === void 0 || o === void 0 ? void 0 : !1 : a.operator === "not" ? n === void 0 ? void 0 : !n : void 0;
|
|
10701
10768
|
}
|
|
10702
10769
|
}
|
|
10703
10770
|
buildMatchEventContext(e, t) {
|
|
@@ -10708,21 +10775,21 @@ class _t {
|
|
|
10708
10775
|
requiresFullRecompute: !0,
|
|
10709
10776
|
reason: "records match over related path requires full recompute"
|
|
10710
10777
|
};
|
|
10711
|
-
const i = t.oldRecord,
|
|
10712
|
-
return
|
|
10778
|
+
const i = this.getPlainValuePropertyNames(e.source), r = t.oldRecord, a = t.type === "update" ? { ...t.oldRecord || {}, ...t.record || {} } : t.record, n = t.type === "create" ? !1 : this.evaluateRecordsMatch(e.match, r, i), o = t.type === "delete" ? !1 : this.evaluateRecordsMatch(e.match, a, i);
|
|
10779
|
+
return n === void 0 || o === void 0 ? {
|
|
10713
10780
|
membershipChange: "unknown",
|
|
10714
10781
|
requiresFullRecompute: !0,
|
|
10715
10782
|
reason: "records match membership could not be evaluated locally"
|
|
10716
|
-
} : !
|
|
10783
|
+
} : !n && !o ? {
|
|
10717
10784
|
membershipChange: "none",
|
|
10718
10785
|
requiresFullRecompute: !1,
|
|
10719
10786
|
skip: !0,
|
|
10720
10787
|
reason: "records match excludes mutation event"
|
|
10721
|
-
} : !
|
|
10788
|
+
} : !n && o ? {
|
|
10722
10789
|
membershipChange: "entered",
|
|
10723
10790
|
requiresFullRecompute: t.type === "update",
|
|
10724
10791
|
reason: t.type === "update" ? "records match membership entered on update" : void 0
|
|
10725
|
-
} :
|
|
10792
|
+
} : n && !o ? {
|
|
10726
10793
|
membershipChange: "left",
|
|
10727
10794
|
requiresFullRecompute: t.type === "update",
|
|
10728
10795
|
reason: t.type === "update" ? "records match membership left on update" : void 0
|
|
@@ -10761,7 +10828,7 @@ class _t {
|
|
|
10761
10828
|
try {
|
|
10762
10829
|
return await this.controller.retrieveLastValue(e.dataContext, t);
|
|
10763
10830
|
} catch (n) {
|
|
10764
|
-
throw new
|
|
10831
|
+
throw new ci("Failed to retrieve planned last value for incremental computation", {
|
|
10765
10832
|
handleName: e.constructor.name,
|
|
10766
10833
|
computationName: e.args.constructor.displayName,
|
|
10767
10834
|
dataContext: e.dataContext,
|
|
@@ -10883,7 +10950,7 @@ class _t {
|
|
|
10883
10950
|
throw new Error(`Async computation for ${e.dataContext.type} is not implemented yet`);
|
|
10884
10951
|
}
|
|
10885
10952
|
async handleAsyncReturn(e, t) {
|
|
10886
|
-
return
|
|
10953
|
+
return Li(`asyncReturn:${this.getAsyncTaskRecordKey(e)}`, async (i) => this.controller.system.storage.runInTransaction({ name: `asyncReturn:${this.getAsyncTaskRecordKey(e)}`, isolation: i }, async () => {
|
|
10887
10954
|
const r = this.getAsyncTaskRecordKey(e), a = e.dataContext.type === "property" ? ["*", ["record", { attributeQuery: ["id"] }]] : ["*"], n = await this.controller.system.storage.findOne(
|
|
10888
10955
|
r,
|
|
10889
10956
|
E.atom({ key: "id", value: ["=", t.id] }),
|
|
@@ -10959,7 +11026,7 @@ class _t {
|
|
|
10959
11026
|
try {
|
|
10960
11027
|
c = await this.controller.retrieveLastValue(e.dataContext, i);
|
|
10961
11028
|
} catch (u) {
|
|
10962
|
-
throw new
|
|
11029
|
+
throw new ci("Failed to retrieve last value for incremental computation", {
|
|
10963
11030
|
handleName: e.constructor.name,
|
|
10964
11031
|
computationName: e.args.constructor.displayName,
|
|
10965
11032
|
dataContext: e.dataContext,
|
|
@@ -10973,7 +11040,7 @@ class _t {
|
|
|
10973
11040
|
try {
|
|
10974
11041
|
c = await this.controller.retrieveLastValue(e.dataContext, i);
|
|
10975
11042
|
} catch (u) {
|
|
10976
|
-
throw new
|
|
11043
|
+
throw new ci("Failed to retrieve last value for incremental patch computation", {
|
|
10977
11044
|
handleName: e.constructor.name,
|
|
10978
11045
|
computationName: e.args.constructor.displayName,
|
|
10979
11046
|
dataContext: e.dataContext,
|
|
@@ -10999,7 +11066,7 @@ class _t {
|
|
|
10999
11066
|
}
|
|
11000
11067
|
if (a instanceof Oe)
|
|
11001
11068
|
return;
|
|
11002
|
-
if (a instanceof
|
|
11069
|
+
if (a instanceof ft)
|
|
11003
11070
|
try {
|
|
11004
11071
|
return await this.createAsyncTask(e, a.args, i);
|
|
11005
11072
|
} catch (c) {
|
|
@@ -11012,7 +11079,7 @@ class _t {
|
|
|
11012
11079
|
});
|
|
11013
11080
|
}
|
|
11014
11081
|
try {
|
|
11015
|
-
const c = a instanceof
|
|
11082
|
+
const c = a instanceof Xt ? await e.asyncReturn(a.result, a.args) : a;
|
|
11016
11083
|
if (n === "patch") {
|
|
11017
11084
|
if (this.requiresSerializablePatchApply(e) && this.controller.system.storage.getTransactionIsolation() !== "SERIALIZABLE")
|
|
11018
11085
|
throw new de(`entity/relation patch from custom computation ${this.getComputationName(e)}`);
|
|
@@ -11131,37 +11198,37 @@ class _t {
|
|
|
11131
11198
|
}
|
|
11132
11199
|
}
|
|
11133
11200
|
}
|
|
11134
|
-
const
|
|
11201
|
+
const Vi = new Or();
|
|
11135
11202
|
function us() {
|
|
11136
|
-
return
|
|
11203
|
+
return Vi.getStore()?.effects;
|
|
11137
11204
|
}
|
|
11138
11205
|
function Er(s) {
|
|
11139
|
-
const e =
|
|
11206
|
+
const e = Vi.getStore();
|
|
11140
11207
|
e?.effects && e.effects.push(...s);
|
|
11141
11208
|
}
|
|
11142
|
-
const ls = new Or(),
|
|
11209
|
+
const ls = new Or(), _i = "_MigrationManifest_", Bi = "current", Pt = "3", ei = "_isDeleted_";
|
|
11143
11210
|
class C extends Error {
|
|
11144
11211
|
constructor(e, t) {
|
|
11145
11212
|
super(e), this.details = t, this.name = new.target.name;
|
|
11146
11213
|
}
|
|
11147
11214
|
}
|
|
11148
|
-
class
|
|
11215
|
+
class Mt extends C {
|
|
11149
11216
|
}
|
|
11150
11217
|
class Qo extends C {
|
|
11151
11218
|
}
|
|
11152
|
-
class
|
|
11219
|
+
class it extends C {
|
|
11153
11220
|
}
|
|
11154
|
-
class
|
|
11221
|
+
class Ui extends C {
|
|
11155
11222
|
}
|
|
11156
11223
|
class he extends C {
|
|
11157
11224
|
}
|
|
11158
11225
|
class ua extends C {
|
|
11159
11226
|
}
|
|
11160
|
-
function
|
|
11161
|
-
return
|
|
11227
|
+
function Ne(s) {
|
|
11228
|
+
return Lr("sha256").update(fe(s)).digest("hex");
|
|
11162
11229
|
}
|
|
11163
11230
|
function ds(s) {
|
|
11164
|
-
return
|
|
11231
|
+
return Ne(s);
|
|
11165
11232
|
}
|
|
11166
11233
|
function fe(s) {
|
|
11167
11234
|
if (s === null || typeof s != "object")
|
|
@@ -11182,12 +11249,12 @@ function xe(s, e, t) {
|
|
|
11182
11249
|
uuid: t
|
|
11183
11250
|
};
|
|
11184
11251
|
}
|
|
11185
|
-
function
|
|
11252
|
+
function Ei(s) {
|
|
11186
11253
|
if (s === null || typeof s != "object") return s;
|
|
11187
|
-
if (Array.isArray(s)) return s.map((i) =>
|
|
11254
|
+
if (Array.isArray(s)) return s.map((i) => Ei(i));
|
|
11188
11255
|
const e = s, t = {};
|
|
11189
11256
|
for (const i of Object.keys(e))
|
|
11190
|
-
i === "uuid" && "kind" in e && "namePath" in e && "key" in e || (t[i] =
|
|
11257
|
+
i === "uuid" && "kind" in e && "namePath" in e && "key" in e || (t[i] = Ei(e[i]));
|
|
11191
11258
|
return t;
|
|
11192
11259
|
}
|
|
11193
11260
|
function hs(s) {
|
|
@@ -11199,21 +11266,21 @@ function hs(s) {
|
|
|
11199
11266
|
e.set(i, t);
|
|
11200
11267
|
}
|
|
11201
11268
|
}
|
|
11202
|
-
function
|
|
11269
|
+
function L(s) {
|
|
11203
11270
|
return s.type === "property" ? `property:${s.host.name}.${s.id.name}` : `${s.type}:${s.id.name}`;
|
|
11204
11271
|
}
|
|
11205
11272
|
function la(s) {
|
|
11206
11273
|
const e = s.constructor?.computationType?.displayName || s.args._type || s.args.constructor?.displayName || s.constructor?.displayName;
|
|
11207
11274
|
if (!e) {
|
|
11208
|
-
const t = s.dataContext ? ` for ${
|
|
11275
|
+
const t = s.dataContext ? ` for ${L(s.dataContext)}` : "";
|
|
11209
11276
|
throw new ua(
|
|
11210
11277
|
`Cannot derive a stable migration identity${t}: the computation type must declare an explicit name. Set a static 'displayName' on the computation type (or handle class), or an '_type' string on the computation args. Class names are not accepted because minified builds rewrite them.`
|
|
11211
11278
|
);
|
|
11212
11279
|
}
|
|
11213
11280
|
return e;
|
|
11214
11281
|
}
|
|
11215
|
-
function
|
|
11216
|
-
return `computation:${
|
|
11282
|
+
function yt(s) {
|
|
11283
|
+
return `computation:${L(s.dataContext)}:${la(s)}`;
|
|
11217
11284
|
}
|
|
11218
11285
|
function ps(s) {
|
|
11219
11286
|
if (s.allocation?.kind !== "scoped-sequence" || !s.allocation.initializeFrom) return;
|
|
@@ -11293,7 +11360,7 @@ function gs(s) {
|
|
|
11293
11360
|
}
|
|
11294
11361
|
function bs(s) {
|
|
11295
11362
|
return Object.values(s.state || {}).map((e) => {
|
|
11296
|
-
const t = "record" in e, i = e.defaultValue, r = typeof i == "function" ? `[Function:${
|
|
11363
|
+
const t = "record" in e, i = e.defaultValue, r = typeof i == "function" ? `[Function:${Ne(String(i))}]` : fe(i);
|
|
11297
11364
|
return {
|
|
11298
11365
|
key: e.key,
|
|
11299
11366
|
scope: t ? "record" : "global",
|
|
@@ -11303,23 +11370,23 @@ function bs(s) {
|
|
|
11303
11370
|
};
|
|
11304
11371
|
});
|
|
11305
11372
|
}
|
|
11306
|
-
const
|
|
11373
|
+
const Qi = ["Entity", "Relation", "Property", "Dictionary"], ha = {
|
|
11307
11374
|
StateNode: ["computeValue"],
|
|
11308
11375
|
StateTransfer: ["computeTarget"]
|
|
11309
11376
|
};
|
|
11310
|
-
function
|
|
11377
|
+
function $i(s, e = /* @__PURE__ */ new WeakSet(), t = !0) {
|
|
11311
11378
|
if (typeof s == "function") return !0;
|
|
11312
11379
|
if (s === null || typeof s != "object" || e.has(s)) return !1;
|
|
11313
11380
|
e.add(s);
|
|
11314
11381
|
const i = s;
|
|
11315
11382
|
if (!t && typeof i._type == "string") {
|
|
11316
|
-
if (
|
|
11383
|
+
if (Qi.includes(i._type)) return !1;
|
|
11317
11384
|
const r = ha[i._type];
|
|
11318
11385
|
if (r) return r.some((a) => typeof i[a] == "function");
|
|
11319
11386
|
}
|
|
11320
|
-
return Array.isArray(s) ? s.some((r) =>
|
|
11387
|
+
return Array.isArray(s) ? s.some((r) => $i(r, e, !1)) : Object.values(i).some((r) => $i(r, e, !1));
|
|
11321
11388
|
}
|
|
11322
|
-
function
|
|
11389
|
+
function ki(s, e = "args", t = /* @__PURE__ */ new WeakSet()) {
|
|
11323
11390
|
if (typeof s == "function")
|
|
11324
11391
|
return [{ path: e, text: s.toString() }];
|
|
11325
11392
|
if (s === null || typeof s != "object") return [];
|
|
@@ -11327,19 +11394,19 @@ function $i(s, e = "args", t = /* @__PURE__ */ new WeakSet()) {
|
|
|
11327
11394
|
t.add(s);
|
|
11328
11395
|
const i = s;
|
|
11329
11396
|
if (typeof i._type == "string") {
|
|
11330
|
-
if (
|
|
11397
|
+
if (Qi.includes(i._type)) return [];
|
|
11331
11398
|
const r = ha[i._type];
|
|
11332
11399
|
if (r)
|
|
11333
11400
|
return r.filter((a) => typeof i[a] == "function").map((a) => ({ path: `${e}.${a}`, text: i[a].toString() }));
|
|
11334
11401
|
}
|
|
11335
|
-
return Array.isArray(s) ? s.flatMap((r, a) =>
|
|
11402
|
+
return Array.isArray(s) ? s.flatMap((r, a) => ki(r, `${e}[${a}]`, t)) : Object.keys(i).sort().flatMap((r) => ki(i[r], `${e}.${r}`, t));
|
|
11336
11403
|
}
|
|
11337
11404
|
function ws(s, e = !1) {
|
|
11338
|
-
const t =
|
|
11339
|
-
if (!(!t.length &&
|
|
11405
|
+
const t = ki(s);
|
|
11406
|
+
if (!(!t.length && !$i(s)))
|
|
11340
11407
|
return {
|
|
11341
11408
|
hasFunction: t.length > 0,
|
|
11342
|
-
hash:
|
|
11409
|
+
hash: Ne(t.map((i) => ({ path: i.path, text: i.text }))),
|
|
11343
11410
|
text: e ? t.map((i) => `// ${i.path}
|
|
11344
11411
|
${i.text}`).join(`
|
|
11345
11412
|
|
|
@@ -11347,25 +11414,25 @@ ${i.text}`).join(`
|
|
|
11347
11414
|
callbackPaths: t.map((i) => i.path)
|
|
11348
11415
|
};
|
|
11349
11416
|
}
|
|
11350
|
-
const
|
|
11351
|
-
function
|
|
11417
|
+
const Ns = /* @__PURE__ */ new Set(["uuid", "_type", "_options"]);
|
|
11418
|
+
function Ti(s, e = /* @__PURE__ */ new WeakSet()) {
|
|
11352
11419
|
if (typeof s == "function") return "[Function]";
|
|
11353
11420
|
if (s === null || typeof s != "object") return s;
|
|
11354
11421
|
if (e.has(s)) return "[Circular]";
|
|
11355
|
-
if (e.add(s), Array.isArray(s)) return s.map((r) =>
|
|
11422
|
+
if (e.add(s), Array.isArray(s)) return s.map((r) => Ti(r, e));
|
|
11356
11423
|
const t = s;
|
|
11357
|
-
if (typeof t._type == "string" &&
|
|
11424
|
+
if (typeof t._type == "string" && Qi.includes(t._type))
|
|
11358
11425
|
return `[${t._type}:${t.name ?? ""}]`;
|
|
11359
11426
|
const i = {};
|
|
11360
11427
|
for (const r of Object.keys(t).sort())
|
|
11361
|
-
|
|
11428
|
+
Ns.has(r) || (i[r] = Ti(t[r], e));
|
|
11362
11429
|
return i;
|
|
11363
11430
|
}
|
|
11364
|
-
function
|
|
11365
|
-
return
|
|
11431
|
+
function Rs(s) {
|
|
11432
|
+
return Ne(Ti(s));
|
|
11366
11433
|
}
|
|
11367
11434
|
function vs(s, e = !1) {
|
|
11368
|
-
const t = s.args, i = ys(s), r = gs(s), a = bs(s), n = a.map((S) => S.key), o =
|
|
11435
|
+
const t = s.args, i = ys(s), r = gs(s), a = bs(s), n = a.map((S) => S.key), o = yt(s), c = L(s.dataContext), u = s.dataContext.type === "entity" || s.dataContext.type === "relation" ? s.dataContext.id.name : void 0, l = la(s), d = xe("computation", o, s.args.uuid), h = ws(t, e), m = Rs(t), { allocation: f, scopeSignature: p, allocationSignature: y } = ca(t), b = Ne({
|
|
11369
11436
|
type: l,
|
|
11370
11437
|
dataContext: c,
|
|
11371
11438
|
dataDeps: i,
|
|
@@ -11374,7 +11441,7 @@ function vs(s, e = !1) {
|
|
|
11374
11441
|
hasCompute: typeof s.compute == "function",
|
|
11375
11442
|
hasIncrementalCompute: typeof s.incrementalCompute == "function",
|
|
11376
11443
|
hasIncrementalPatchCompute: typeof s.incrementalPatchCompute == "function"
|
|
11377
|
-
}), g =
|
|
11444
|
+
}), g = Ne({ stateKeys: n, boundStates: a }), w = Ne({
|
|
11378
11445
|
type: l,
|
|
11379
11446
|
dataContext: c,
|
|
11380
11447
|
outputRecord: u,
|
|
@@ -11390,7 +11457,7 @@ function vs(s, e = !1) {
|
|
|
11390
11457
|
hasCompute: typeof s.compute == "function",
|
|
11391
11458
|
hasIncrementalCompute: typeof s.incrementalCompute == "function",
|
|
11392
11459
|
hasIncrementalPatchCompute: typeof s.incrementalPatchCompute == "function"
|
|
11393
|
-
}),
|
|
11460
|
+
}), R = Ne({ structuralSignature: w, stateSignature: g, functionHash: h?.hash, allocationSignature: y });
|
|
11394
11461
|
return {
|
|
11395
11462
|
id: o,
|
|
11396
11463
|
identity: d,
|
|
@@ -11419,10 +11486,10 @@ function vs(s, e = !1) {
|
|
|
11419
11486
|
allocation: f,
|
|
11420
11487
|
allocationSignature: y,
|
|
11421
11488
|
scopeSignature: p,
|
|
11422
|
-
signature:
|
|
11489
|
+
signature: R
|
|
11423
11490
|
};
|
|
11424
11491
|
}
|
|
11425
|
-
function
|
|
11492
|
+
function Et(s, e = s.system.storage.schema, t = {}) {
|
|
11426
11493
|
const i = [
|
|
11427
11494
|
...s.entities.map((l) => {
|
|
11428
11495
|
const d = xe("entity", `entity:${l.name}`, l.uuid);
|
|
@@ -11498,11 +11565,11 @@ function St(s, e = s.system.storage.schema, t = {}) {
|
|
|
11498
11565
|
...l.functionSignature,
|
|
11499
11566
|
text: void 0
|
|
11500
11567
|
} : void 0
|
|
11501
|
-
})), u =
|
|
11568
|
+
})), u = Ei({ records: i, relations: r, dictionaries: a, computations: c, sequences: o, storage: e });
|
|
11502
11569
|
return {
|
|
11503
11570
|
version: 2,
|
|
11504
|
-
frameworkVersion:
|
|
11505
|
-
modelHash:
|
|
11571
|
+
frameworkVersion: Pt,
|
|
11572
|
+
modelHash: Ne(u),
|
|
11506
11573
|
records: i,
|
|
11507
11574
|
relations: r,
|
|
11508
11575
|
dictionaries: a,
|
|
@@ -11519,10 +11586,10 @@ function jo(s, e) {
|
|
|
11519
11586
|
});
|
|
11520
11587
|
}
|
|
11521
11588
|
function $r(s) {
|
|
11522
|
-
if (s.frameworkVersion !==
|
|
11523
|
-
throw new
|
|
11524
|
-
`Migration manifest was written by an incompatible interaqt manifest generator (found '${s.frameworkVersion}', expected '${
|
|
11525
|
-
{ foundGeneratorVersion: s.frameworkVersion, expectedGeneratorVersion:
|
|
11589
|
+
if (s.frameworkVersion !== Pt)
|
|
11590
|
+
throw new Mt(
|
|
11591
|
+
`Migration manifest was written by an incompatible interaqt manifest generator (found '${s.frameworkVersion}', expected '${Pt}'). Verify that the current definitions match the existing schema, then re-baseline with controller.createMigrationBaseline().`,
|
|
11592
|
+
{ foundGeneratorVersion: s.frameworkVersion, expectedGeneratorVersion: Pt }
|
|
11526
11593
|
);
|
|
11527
11594
|
}
|
|
11528
11595
|
function re(s) {
|
|
@@ -11540,27 +11607,27 @@ function Ss(s) {
|
|
|
11540
11607
|
const e = s.kind === "destructive-scope" && s.recordName || "";
|
|
11541
11608
|
return s.kind === "empty-fact-record-removal" ? `${s.kind}:${s.recordName}` : `${s.kind}:${s.dataContext}:${e}`;
|
|
11542
11609
|
}
|
|
11543
|
-
function
|
|
11610
|
+
function ji(s) {
|
|
11544
11611
|
return s.kind === "computation" ? `computation:${s.id}` : s.kind === "computation-takeover" ? `computation-takeover:${s.dataContext}` : s.kind === "empty-fact-record-removal" ? `empty-fact-record-removal:${s.recordName}` : s.kind === "dictionary" ? `dictionary:${s.id}` : s.kind === "record" ? `record:${s.id}` : s.kind === "property" ? `property:${s.id}` : s.kind === "relation" ? `relation:${s.id}` : `storage:${s.dataContext}`;
|
|
11545
11612
|
}
|
|
11546
11613
|
function Xe(s, e) {
|
|
11547
11614
|
return (s?.decisions || []).some(e);
|
|
11548
11615
|
}
|
|
11549
|
-
function
|
|
11616
|
+
function Ut(s, e) {
|
|
11550
11617
|
return (s?.decisions || []).find(e);
|
|
11551
11618
|
}
|
|
11552
11619
|
function pa(s, e) {
|
|
11553
11620
|
return e ? s?.[e] : void 0;
|
|
11554
11621
|
}
|
|
11555
|
-
function
|
|
11556
|
-
const t =
|
|
11622
|
+
function qt(s, e) {
|
|
11623
|
+
const t = Ut(s?.approvedDiff, (i) => i.kind === "event-rebuild-handler" && i.dataContext === e);
|
|
11557
11624
|
return pa(s?.handlers?.eventRebuild, t?.handlerRef);
|
|
11558
11625
|
}
|
|
11559
11626
|
function ma(s, e) {
|
|
11560
|
-
const t =
|
|
11627
|
+
const t = Ut(s?.approvedDiff, (i) => i.kind === "async-completion-handler" && i.dataContext === e);
|
|
11561
11628
|
return pa(s?.handlers?.asyncCompletion, t?.handlerRef);
|
|
11562
11629
|
}
|
|
11563
|
-
function
|
|
11630
|
+
function Hi(s, e) {
|
|
11564
11631
|
return s?.decisions.find(
|
|
11565
11632
|
(t) => t.kind === "computation-takeover" && t.dataContext === e
|
|
11566
11633
|
);
|
|
@@ -11612,7 +11679,7 @@ function $s(s) {
|
|
|
11612
11679
|
return s.kind === "unsupported-destructive-schema-change" && s.reason === "fact record was removed from the new schema" && s.oldPhysicalPath !== void 0;
|
|
11613
11680
|
}
|
|
11614
11681
|
async function ks(s, e, t, i) {
|
|
11615
|
-
const r = /* @__PURE__ */ new Set(), a = new Map(e.changes.map((o) => [
|
|
11682
|
+
const r = /* @__PURE__ */ new Set(), a = new Map(e.changes.map((o) => [ji(o), o])), n = new Map(e.requiredDecisions.map((o) => [re(o), o]));
|
|
11616
11683
|
for (const o of e.safety.blockingChanges) {
|
|
11617
11684
|
if (!$s(o)) continue;
|
|
11618
11685
|
const c = o.logicalPath;
|
|
@@ -11653,14 +11720,14 @@ async function Ts(s, e, t, i, r) {
|
|
|
11653
11720
|
(h) => h.kind === "computation" && h.id === o.id && h.recommendedDecision === "unrebuildable"
|
|
11654
11721
|
)) continue;
|
|
11655
11722
|
const u = i.computations.find((h) => h.id === o.id), l = u ? ms(u) : void 0;
|
|
11656
|
-
!l || (await
|
|
11723
|
+
!l || (await Qt(s, t, l.hostRecord, ["id"], r)).length !== 0 || (a.set(re(l), l), n = !0);
|
|
11657
11724
|
}
|
|
11658
11725
|
return n && (e.requiredDecisions = Array.from(a.values()), e.summary = {
|
|
11659
11726
|
...e.summary,
|
|
11660
11727
|
requiredDecisionCount: e.requiredDecisions.length
|
|
11661
11728
|
}), e;
|
|
11662
11729
|
}
|
|
11663
|
-
async function
|
|
11730
|
+
async function Na(s, e, t) {
|
|
11664
11731
|
const i = (e?.decisions || []).filter((a) => a.kind === "empty-fact-record-removal"), r = /* @__PURE__ */ new Set();
|
|
11665
11732
|
for (const a of i) {
|
|
11666
11733
|
if (a.expectedCount !== 0)
|
|
@@ -11679,12 +11746,12 @@ async function Cs(s, e, t, i) {
|
|
|
11679
11746
|
for (const a of r) {
|
|
11680
11747
|
if (a.expectedHostCount !== 0)
|
|
11681
11748
|
throw new C(`Invalid scoped sequence no-seed expectedHostCount for ${a.dataContext}`);
|
|
11682
|
-
if ((await
|
|
11749
|
+
if ((await Qt(s, t, a.hostRecord, ["id"], i)).length !== 0)
|
|
11683
11750
|
throw new C(`ScopedSequence ${a.sequenceName} no-seed decision requires empty host record ${a.hostRecord}`);
|
|
11684
11751
|
}
|
|
11685
11752
|
}
|
|
11686
11753
|
async function xs(s, e, t) {
|
|
11687
|
-
await
|
|
11754
|
+
await Na(s, e, t);
|
|
11688
11755
|
}
|
|
11689
11756
|
function As(s, e) {
|
|
11690
11757
|
return s.storage.records.filter((t) => e.has(t.recordName)).map((t) => ({
|
|
@@ -11704,9 +11771,9 @@ function kr(s, e) {
|
|
|
11704
11771
|
if (!t) return;
|
|
11705
11772
|
const i = s.system.storage.db || s.system.db;
|
|
11706
11773
|
if (i)
|
|
11707
|
-
return new
|
|
11774
|
+
return new bi(new qe(t.map, t.aliasManager), i);
|
|
11708
11775
|
}
|
|
11709
|
-
async function
|
|
11776
|
+
async function Qt(s, e, t, i, r) {
|
|
11710
11777
|
if (r)
|
|
11711
11778
|
return r.find(t, void 0, void 0, i);
|
|
11712
11779
|
if (s.system.storage.queryHandle)
|
|
@@ -11715,27 +11782,27 @@ async function Ut(s, e, t, i, r) {
|
|
|
11715
11782
|
throw new C(`Cannot read migration takeover scope for ${t} before storage query handle is initialized`);
|
|
11716
11783
|
return [];
|
|
11717
11784
|
}
|
|
11718
|
-
async function
|
|
11785
|
+
async function Ra(s, e, t, i) {
|
|
11719
11786
|
if (e.startsWith("property:")) {
|
|
11720
11787
|
const n = e.match(/^property:([^.]*)\.([^.]*)$/);
|
|
11721
11788
|
if (!n) throw new C(`Invalid property data context for computation takeover: ${e}`);
|
|
11722
|
-
const [, o, c] = n, u = await
|
|
11789
|
+
const [, o, c] = n, u = await Qt(s, t, o, ["id", c], i);
|
|
11723
11790
|
return {
|
|
11724
11791
|
expectedExistingCount: u.filter((l) => l[c] !== void 0 && l[c] !== null).length,
|
|
11725
11792
|
expectedHostCount: u.length
|
|
11726
11793
|
};
|
|
11727
11794
|
}
|
|
11728
|
-
const [, r] = e.split(":"), a = await
|
|
11795
|
+
const [, r] = e.split(":"), a = await Qt(s, t, r, ["id"], i);
|
|
11729
11796
|
return {
|
|
11730
11797
|
expectedExistingCount: a.length,
|
|
11731
11798
|
ids: a.map((n) => String(n.id)).sort()
|
|
11732
11799
|
};
|
|
11733
11800
|
}
|
|
11734
11801
|
async function Is(s, e, t, i, r) {
|
|
11735
|
-
const a = new Map(e.changes.map((c) => [
|
|
11802
|
+
const a = new Map(e.changes.map((c) => [ji(c), c])), n = new Map(e.requiredDecisions.map((c) => [re(c), c])), o = new Map(e.safety.destructiveScopes.map((c) => [`${c.dataContext}:${c.recordName || ""}`, c]));
|
|
11736
11803
|
for (const c of i.computations) {
|
|
11737
11804
|
if (!fa(t, i, c)) continue;
|
|
11738
|
-
const u = ya(c.dataContext), l = await
|
|
11805
|
+
const u = ya(c.dataContext), l = await Ra(s, c.dataContext, t, r), d = {
|
|
11739
11806
|
kind: "computation-takeover",
|
|
11740
11807
|
dataContext: c.dataContext,
|
|
11741
11808
|
computationId: c.id,
|
|
@@ -11830,8 +11897,8 @@ function Ps(s, e, t, i) {
|
|
|
11830
11897
|
reason: "property no longer exists in the new model"
|
|
11831
11898
|
});
|
|
11832
11899
|
for (const w of p.properties) {
|
|
11833
|
-
const
|
|
11834
|
-
|
|
11900
|
+
const R = b.get(w.id);
|
|
11901
|
+
R ? (R.name !== w.name || R.type !== w.type || R.collection !== w.collection || R.computed !== w.computed) && r.push({
|
|
11835
11902
|
kind: "property",
|
|
11836
11903
|
id: w.id,
|
|
11837
11904
|
changeType: "changed",
|
|
@@ -11902,8 +11969,8 @@ function Ps(s, e, t, i) {
|
|
|
11902
11969
|
});
|
|
11903
11970
|
for (const p of e.computations) {
|
|
11904
11971
|
const y = n.get(p.id), b = {
|
|
11905
|
-
dataDepsChanged: y ? !
|
|
11906
|
-
eventDepsChanged: y ? !
|
|
11972
|
+
dataDepsChanged: y ? !rt(y.deps, p.deps) : !0,
|
|
11973
|
+
eventDepsChanged: y ? !rt(y.eventDeps, p.eventDeps) : !0,
|
|
11907
11974
|
outputSignatureChanged: y ? y.outputSignature !== p.outputSignature : !0,
|
|
11908
11975
|
stateSignatureChanged: y ? y.stateSignature !== p.stateSignature : !0,
|
|
11909
11976
|
allocationSignatureChanged: y ? y.allocationSignature !== p.allocationSignature : p.allocationSignature !== void 0,
|
|
@@ -11917,8 +11984,8 @@ function Ps(s, e, t, i) {
|
|
|
11917
11984
|
needsEventRebuildHandler: p.eventDeps.length > 0,
|
|
11918
11985
|
needsAsyncCompletionHandler: p.asyncReturn
|
|
11919
11986
|
};
|
|
11920
|
-
let g = "unchanged", w = "ignore",
|
|
11921
|
-
if (y ? y.allocationSignature !== p.allocationSignature ? (g = "changed", w = "needs-review",
|
|
11987
|
+
let g = "unchanged", w = "ignore", R = "unchanged", S = "computation is structurally unchanged";
|
|
11988
|
+
if (y ? y.allocationSignature !== p.allocationSignature ? (g = "changed", w = "needs-review", R = "unrebuildable", S = "scoped allocation args changed") : y.structuralSignature !== p.structuralSignature ? (g = "changed", w = "needs-review", R = "changed", S = "computation structure changed") : y.stateSignature !== p.stateSignature && y.outputSignature === p.outputSignature ? (g = "state-only", w = "needs-review", R = "state-only", S = "computation state changed without output structure changes") : y.functionSignature?.hash !== p.functionSignature?.hash ? (g = "possibly-changed", w = "needs-review", R = "changed", S = "function text changed and requires human semantic review") : p.functionSignature?.hasFunction && (w = "needs-review", S = "function callback has closure risk and requires human review") : (g = "added", w = p.allocation?.kind === "scoped-sequence" ? "needs-review" : "rebuild", R = p.allocation?.kind === "scoped-sequence" ? "unrebuildable" : "changed", S = p.allocation?.kind === "scoped-sequence" ? "new scoped allocation computation requires approved sequence initialization" : "new computation requires approved rebuild"), r.push({
|
|
11922
11989
|
kind: "computation",
|
|
11923
11990
|
id: p.id,
|
|
11924
11991
|
dataContext: p.dataContext,
|
|
@@ -11932,14 +11999,14 @@ function Ps(s, e, t, i) {
|
|
|
11932
11999
|
kind: "computation",
|
|
11933
12000
|
id: p.id,
|
|
11934
12001
|
dataContext: p.dataContext,
|
|
11935
|
-
recommendedDecision:
|
|
12002
|
+
recommendedDecision: R,
|
|
11936
12003
|
reason: S
|
|
11937
12004
|
});
|
|
11938
|
-
const
|
|
11939
|
-
|
|
12005
|
+
const N = ps(p);
|
|
12006
|
+
N && a.push(N);
|
|
11940
12007
|
}
|
|
11941
12008
|
}
|
|
11942
|
-
for (const p of
|
|
12009
|
+
for (const p of zi(s, e))
|
|
11943
12010
|
p.changeType === "predicate-changed" && r.push({
|
|
11944
12011
|
kind: "storage",
|
|
11945
12012
|
id: `filtered-predicate:${p.recordName}`,
|
|
@@ -11992,7 +12059,7 @@ function Ps(s, e, t, i) {
|
|
|
11992
12059
|
};
|
|
11993
12060
|
}
|
|
11994
12061
|
function Ms(s, e, t) {
|
|
11995
|
-
const i =
|
|
12062
|
+
const i = Ki(e), r = new Map(s.requiredDecisions.map((a) => [re(a), a]));
|
|
11996
12063
|
for (const a of t) {
|
|
11997
12064
|
if (!a.rebuildOutput) continue;
|
|
11998
12065
|
const n = i.get(a.computationId);
|
|
@@ -12032,7 +12099,7 @@ function qs(s, e, t, i, r) {
|
|
|
12032
12099
|
const a = r || s, n = new Set(s.requiredDecisions.map(re)), o = /* @__PURE__ */ new Set([
|
|
12033
12100
|
...a.requiredDecisions.map(re),
|
|
12034
12101
|
...n
|
|
12035
|
-
]), c = new Set(a.changes.map(
|
|
12102
|
+
]), c = new Set(a.changes.map(ji)), u = /* @__PURE__ */ new Set();
|
|
12036
12103
|
for (const d of s.decisions) {
|
|
12037
12104
|
const h = Ss(d);
|
|
12038
12105
|
if (u.has(h))
|
|
@@ -12164,7 +12231,7 @@ function Os(s) {
|
|
|
12164
12231
|
reason: e.reason
|
|
12165
12232
|
}));
|
|
12166
12233
|
}
|
|
12167
|
-
function
|
|
12234
|
+
function Ls(s) {
|
|
12168
12235
|
return s.decisions.filter((e) => e.kind === "scoped-sequence-no-seed").map((e) => ({
|
|
12169
12236
|
id: e.id,
|
|
12170
12237
|
dataContext: e.dataContext,
|
|
@@ -12176,13 +12243,13 @@ function Fs(s) {
|
|
|
12176
12243
|
reason: e.reason
|
|
12177
12244
|
}));
|
|
12178
12245
|
}
|
|
12179
|
-
function
|
|
12180
|
-
return new Map(Array.from(s.scheduler.computationsHandles.values()).map((e) => [
|
|
12246
|
+
function Ki(s) {
|
|
12247
|
+
return new Map(Array.from(s.scheduler.computationsHandles.values()).map((e) => [yt(e), e]));
|
|
12181
12248
|
}
|
|
12182
|
-
function
|
|
12249
|
+
function $t(s) {
|
|
12183
12250
|
return s.dataContext;
|
|
12184
12251
|
}
|
|
12185
|
-
function
|
|
12252
|
+
function Fs(s, e, t) {
|
|
12186
12253
|
return s.relations.find(
|
|
12187
12254
|
(i) => i.source === e && i.sourceProperty === t || i.target === e && i.targetProperty === t
|
|
12188
12255
|
);
|
|
@@ -12201,21 +12268,21 @@ function va(s, e) {
|
|
|
12201
12268
|
}
|
|
12202
12269
|
return t;
|
|
12203
12270
|
}
|
|
12204
|
-
function
|
|
12271
|
+
function jt(s, e) {
|
|
12205
12272
|
return va(s, e).map((t) => Vs(s, t));
|
|
12206
12273
|
}
|
|
12207
12274
|
function _s(s, e, t) {
|
|
12208
12275
|
return va(s, e).flatMap((i) => {
|
|
12209
12276
|
const r = s.records.find((n) => n.name === i);
|
|
12210
|
-
return [...t.includes("*") ? (r?.properties || []).map((n) => `property:${i}.${n.name}`) : t.filter((n) => typeof n == "string" && n !== "*" && n !== "id").map((n) => `property:${i}.${n}`), ...
|
|
12277
|
+
return [...t.includes("*") ? (r?.properties || []).map((n) => `property:${i}.${n.name}`) : t.filter((n) => typeof n == "string" && n !== "*" && n !== "id").map((n) => `property:${i}.${n}`), ...Wi(s, i, t)];
|
|
12211
12278
|
});
|
|
12212
12279
|
}
|
|
12213
|
-
function
|
|
12280
|
+
function Wi(s, e, t) {
|
|
12214
12281
|
return t.flatMap((i) => {
|
|
12215
12282
|
if (!Array.isArray(i) || typeof i[0] != "string") return [];
|
|
12216
|
-
const r =
|
|
12283
|
+
const r = Fs(s, e, i[0]);
|
|
12217
12284
|
if (!r) return [];
|
|
12218
|
-
const a = r.source === e ? r.target : r.source, n = i[1], c = (Array.isArray(n?.attributeQuery) ? n.attributeQuery : []).flatMap((u) => typeof u == "string" && u !== "*" && u !== v ? [`property:${a}.${u}`] : Array.isArray(u) && u[0] === v ? [`relation:${r.name}`] : Array.isArray(u) ?
|
|
12285
|
+
const a = r.source === e ? r.target : r.source, n = i[1], c = (Array.isArray(n?.attributeQuery) ? n.attributeQuery : []).flatMap((u) => typeof u == "string" && u !== "*" && u !== v ? [`property:${a}.${u}`] : Array.isArray(u) && u[0] === v ? [`relation:${r.name}`] : Array.isArray(u) ? Wi(s, a, [u]) : []);
|
|
12219
12286
|
return [`relation:${r.name}`, ...c];
|
|
12220
12287
|
});
|
|
12221
12288
|
}
|
|
@@ -12224,20 +12291,20 @@ function Tr(s, e, t) {
|
|
|
12224
12291
|
if (s.type === "records" && s.source) {
|
|
12225
12292
|
const i = Array.isArray(s.attributeQuery) ? s.attributeQuery : [];
|
|
12226
12293
|
return [
|
|
12227
|
-
...
|
|
12294
|
+
...jt(t, s.source),
|
|
12228
12295
|
..._s(t, s.source, i)
|
|
12229
12296
|
];
|
|
12230
12297
|
}
|
|
12231
12298
|
if (s.type === "property") {
|
|
12232
12299
|
const i = e.dataContext.match(/^property:([^.]*)\./);
|
|
12233
12300
|
if (!i) return [];
|
|
12234
|
-
const r = i[1], a = Array.isArray(s.attributeQuery) ? s.attributeQuery : [], n =
|
|
12235
|
-
return c.length ? c :
|
|
12301
|
+
const r = i[1], a = Array.isArray(s.attributeQuery) ? s.attributeQuery : [], n = Wi(t, r, a), c = [...a.filter((u) => typeof u == "string" && u !== "*").map((u) => `property:${r}.${u}`), ...n];
|
|
12302
|
+
return c.length ? c : jt(t, r);
|
|
12236
12303
|
}
|
|
12237
12304
|
return [];
|
|
12238
12305
|
}
|
|
12239
12306
|
function Cr(s, e) {
|
|
12240
|
-
const t =
|
|
12307
|
+
const t = jt(e, s.recordName);
|
|
12241
12308
|
if (s.type === "update") {
|
|
12242
12309
|
const i = e.records.find((r) => r.name === s.recordName);
|
|
12243
12310
|
t.push(...(i?.properties || []).map((r) => `property:${s.recordName}.${r.name}`));
|
|
@@ -12245,72 +12312,72 @@ function Cr(s, e) {
|
|
|
12245
12312
|
return t;
|
|
12246
12313
|
}
|
|
12247
12314
|
function xr(s, e, t, i = [], r = {}) {
|
|
12248
|
-
const a = new Map(e.computations.map((g) => [
|
|
12315
|
+
const a = new Map(e.computations.map((g) => [$t(g), g])), n = new Map(s.computations.map((g) => [g.id, g])), o = /* @__PURE__ */ new Map();
|
|
12249
12316
|
for (const g of e.computations) {
|
|
12250
12317
|
for (const w of g.deps)
|
|
12251
|
-
for (const
|
|
12252
|
-
o.has(
|
|
12318
|
+
for (const R of Tr(w, g, e))
|
|
12319
|
+
o.has(R) || o.set(R, /* @__PURE__ */ new Set()), o.get(R).add(g.id);
|
|
12253
12320
|
for (const w of g.eventDeps)
|
|
12254
|
-
for (const
|
|
12255
|
-
|
|
12321
|
+
for (const R of Cr(w, e))
|
|
12322
|
+
R !== g.dataContext && (o.has(R) || o.set(R, /* @__PURE__ */ new Set()), o.get(R).add(g.id));
|
|
12256
12323
|
}
|
|
12257
12324
|
const c = (g) => {
|
|
12258
12325
|
const w = g.match(/^property:([^.]*)\._isDeleted_$/);
|
|
12259
|
-
return w ?
|
|
12326
|
+
return w ? jt(e, w[1]) : [];
|
|
12260
12327
|
}, u = /* @__PURE__ */ new Map();
|
|
12261
12328
|
for (const g of e.computations)
|
|
12262
12329
|
for (const w of c(g.dataContext))
|
|
12263
12330
|
u.set(w, g);
|
|
12264
12331
|
const l = (g) => {
|
|
12265
|
-
const w = [],
|
|
12266
|
-
|
|
12332
|
+
const w = [], R = a.get(g);
|
|
12333
|
+
R && w.push(R);
|
|
12267
12334
|
const S = u.get(g);
|
|
12268
|
-
return S && S !==
|
|
12335
|
+
return S && S !== R && w.push(S), w;
|
|
12269
12336
|
}, d = new Set(t.map((g) => g.id)), m = [...t.filter((g) => {
|
|
12270
12337
|
const w = n.get(g.id);
|
|
12271
12338
|
return r.outputChangedIds?.has(g.id) || !w || w.outputSignature !== g.outputSignature;
|
|
12272
|
-
}).flatMap((g) => [
|
|
12339
|
+
}).flatMap((g) => [$t(g), ...c($t(g))]), ...i];
|
|
12273
12340
|
for (; m.length; ) {
|
|
12274
12341
|
const g = m.shift();
|
|
12275
12342
|
for (const w of o.get(g) || []) {
|
|
12276
12343
|
if (d.has(w)) continue;
|
|
12277
12344
|
d.add(w);
|
|
12278
|
-
const
|
|
12279
|
-
|
|
12345
|
+
const R = e.computations.find((S) => S.id === w);
|
|
12346
|
+
R && m.push($t(R));
|
|
12280
12347
|
}
|
|
12281
12348
|
}
|
|
12282
12349
|
const f = /* @__PURE__ */ new Set(), p = /* @__PURE__ */ new Set(), y = [], b = (g) => {
|
|
12283
12350
|
if (p.has(g)) return;
|
|
12284
12351
|
if (f.has(g))
|
|
12285
|
-
throw new
|
|
12352
|
+
throw new it(`Migration detected a derived computation cycle at ${g}`);
|
|
12286
12353
|
f.add(g);
|
|
12287
|
-
const w = e.computations.find((
|
|
12354
|
+
const w = e.computations.find((R) => R.id === g);
|
|
12288
12355
|
if (w) {
|
|
12289
|
-
for (const
|
|
12290
|
-
for (const S of Tr(
|
|
12291
|
-
for (const
|
|
12292
|
-
|
|
12293
|
-
for (const
|
|
12294
|
-
for (const S of Cr(
|
|
12356
|
+
for (const R of w.deps)
|
|
12357
|
+
for (const S of Tr(R, w, e))
|
|
12358
|
+
for (const N of l(S))
|
|
12359
|
+
N.id !== g && d.has(N.id) && b(N.id);
|
|
12360
|
+
for (const R of w.eventDeps)
|
|
12361
|
+
for (const S of Cr(R, e))
|
|
12295
12362
|
if (S !== w.dataContext)
|
|
12296
|
-
for (const
|
|
12297
|
-
|
|
12363
|
+
for (const N of l(S))
|
|
12364
|
+
N.id !== g && d.has(N.id) && b(N.id);
|
|
12298
12365
|
}
|
|
12299
12366
|
f.delete(g), p.add(g), y.push(g);
|
|
12300
12367
|
};
|
|
12301
12368
|
return d.forEach(b), y.map((g) => {
|
|
12302
|
-
const w = e.computations.find((
|
|
12369
|
+
const w = e.computations.find((D) => D.id === g), R = n.get(g), S = r.stateOnlyIds?.has(g) === !0, N = r.outputChangedIds?.has(g) || !R || R.outputSignature !== w.outputSignature, $ = !R || R.stateSignature !== w.stateSignature, I = t.some((D) => D.id === g);
|
|
12303
12370
|
return {
|
|
12304
12371
|
computationId: g,
|
|
12305
12372
|
dataContext: w.dataContext,
|
|
12306
12373
|
rebuildState: (S || $) && w.boundStates.length > 0,
|
|
12307
|
-
rebuildOutput: S ? !1 :
|
|
12308
|
-
propagateOutputEvents: S ? !1 :
|
|
12374
|
+
rebuildOutput: S ? !1 : N || !I,
|
|
12375
|
+
propagateOutputEvents: S ? !1 : N || !I,
|
|
12309
12376
|
isSeed: I
|
|
12310
12377
|
};
|
|
12311
12378
|
});
|
|
12312
12379
|
}
|
|
12313
|
-
function
|
|
12380
|
+
function di(s, e) {
|
|
12314
12381
|
return `${s || "?"}.${e || "?"}`;
|
|
12315
12382
|
}
|
|
12316
12383
|
function Ar(s, e) {
|
|
@@ -12344,7 +12411,7 @@ function Ar(s, e) {
|
|
|
12344
12411
|
t.push({
|
|
12345
12412
|
kind: "unsupported-destructive-schema-change",
|
|
12346
12413
|
logicalPath: `${l.recordName}.${f.name}`,
|
|
12347
|
-
oldPhysicalPath:
|
|
12414
|
+
oldPhysicalPath: di(f.tableName, f.fieldName || f.sourceField || f.targetField),
|
|
12348
12415
|
reason: y ? "computed attribute physical cleanup is not supported by compute-route schema migration" : "fact attribute was removed from the new schema"
|
|
12349
12416
|
});
|
|
12350
12417
|
}
|
|
@@ -12353,8 +12420,8 @@ function Ar(s, e) {
|
|
|
12353
12420
|
!p || m(l.recordName, f.name, s) || m(u.recordName, f.name, e) || ((p.kind !== f.kind || p.tableName !== f.tableName || p.fieldName !== f.fieldName || p.sourceField !== f.sourceField || p.targetField !== f.targetField) && t.push({
|
|
12354
12421
|
kind: "physical-path-move",
|
|
12355
12422
|
logicalPath: `${u.recordName}.${f.name}`,
|
|
12356
|
-
oldPhysicalPath:
|
|
12357
|
-
newPhysicalPath:
|
|
12423
|
+
oldPhysicalPath: di(p.tableName, p.fieldName || p.sourceField || p.targetField),
|
|
12424
|
+
newPhysicalPath: di(f.tableName, f.fieldName || f.sourceField || f.targetField),
|
|
12358
12425
|
reason: "fact attribute physical path changed"
|
|
12359
12426
|
}), (p.type !== f.type || p.fieldType !== f.fieldType || p.collection !== f.collection) && t.push({
|
|
12360
12427
|
kind: "unsupported-destructive-schema-change",
|
|
@@ -12372,15 +12439,15 @@ function Bs(s, e, t, i) {
|
|
|
12372
12439
|
return r ? r.owner === "exclusive" && r.ownershipProof?.kind === "computed-output" && r.ownershipProof.owner === "exclusive" && r.ownershipProof.ownerComputationId === e && r.ownershipProof.dataContext === t && r.ownershipProof.outputRecord === r.outputRecord : !(i !== void 0 && (s.records.some((n) => n.name === i) || s.storage.records.some((n) => n.recordName === i)));
|
|
12373
12440
|
}
|
|
12374
12441
|
function Us(s, e, t, i) {
|
|
12375
|
-
const r =
|
|
12442
|
+
const r = Hi(s.approvedDiff, i);
|
|
12376
12443
|
return !r || r.computationId !== t || r.oldDataStrategy !== "discard-and-rebuild" ? !1 : e === void 0 || e.computations.every((a) => a.dataContext !== i);
|
|
12377
12444
|
}
|
|
12378
12445
|
function Qs(s, e, t = {}, i) {
|
|
12379
12446
|
const r = [], a = new Set(e.filter((n) => n.rebuildOutput).map((n) => n.computationId));
|
|
12380
12447
|
for (const n of s.scheduler.computationsHandles.values()) {
|
|
12381
|
-
const o =
|
|
12448
|
+
const o = yt(n);
|
|
12382
12449
|
if (!a.has(o)) continue;
|
|
12383
|
-
const c =
|
|
12450
|
+
const c = L(n.dataContext);
|
|
12384
12451
|
if (n.args._type === "ScopedSequence") {
|
|
12385
12452
|
const u = !!n.args.initializeFrom;
|
|
12386
12453
|
if (u && Xe(
|
|
@@ -12398,7 +12465,7 @@ function Qs(s, e, t = {}, i) {
|
|
|
12398
12465
|
});
|
|
12399
12466
|
continue;
|
|
12400
12467
|
}
|
|
12401
|
-
if (n.dataContext.type === "property" && n.dataContext.id.name ===
|
|
12468
|
+
if (n.dataContext.type === "property" && n.dataContext.id.name === ei && !Xe(t.approvedDiff, (u) => u.kind === "destructive-scope" && u.dataContext === c) && r.push({ kind: "destructive-computed-output", logicalPath: c, reason: "destructive computed output requires an approved destructive-scope decision" }), n.asyncReturn && !ma(t, c) && r.push({ kind: "async-computation", logicalPath: c, reason: "async computation requires an approved async-completion-handler decision and runtime handler" }), (n.dataContext.type === "entity" || n.dataContext.type === "relation") && !n.compute && r.push({ kind: "unrebuildable-computation", logicalPath: c, reason: "entity/relation output lacks a full compute contract" }), n.dataContext.type === "entity" || n.dataContext.type === "relation") {
|
|
12402
12469
|
const u = n.state?.sourceRecordId?.key, l = n.state?.transformIndex?.key;
|
|
12403
12470
|
(!u || !l || typeof n.eventDeps == "object") && r.push({
|
|
12404
12471
|
kind: "unrebuildable-computation",
|
|
@@ -12410,7 +12477,7 @@ function Qs(s, e, t = {}, i) {
|
|
|
12410
12477
|
kind: "destructive-computed-output",
|
|
12411
12478
|
logicalPath: c,
|
|
12412
12479
|
reason: "entity/relation output replacement requires exclusive output ownership proof in the previous manifest"
|
|
12413
|
-
}), typeof n.eventDeps == "object" && !
|
|
12480
|
+
}), typeof n.eventDeps == "object" && !qt(t, c) && r.push({ kind: "unrebuildable-computation", logicalPath: c, reason: "event-based computation requires an approved event-rebuild-handler decision and runtime handler" });
|
|
12414
12481
|
}
|
|
12415
12482
|
return r;
|
|
12416
12483
|
}
|
|
@@ -12428,22 +12495,22 @@ async function js(s, e, t, i, r, a, n, o) {
|
|
|
12428
12495
|
if (h.some((P) => !P)) return;
|
|
12429
12496
|
const m = Q(c), f = (P) => ce(P, m), p = Hs(o, l, m);
|
|
12430
12497
|
if (!p) return;
|
|
12431
|
-
const y = f(u.tableName), b = f(d.fieldName), g = p.sql ? ` WHERE ${p.sql}` : "",
|
|
12498
|
+
const y = f(u.tableName), b = f(d.fieldName), g = p.sql ? ` WHERE ${p.sql}` : "", R = (await c.query(
|
|
12432
12499
|
`SELECT COUNT(*) AS ${f("__rowCount")}, COUNT(${b}) AS ${f("__validValueCount")} FROM ${y}${g}`,
|
|
12433
12500
|
p.params
|
|
12434
|
-
))[0], S = Number(
|
|
12435
|
-
if (S !==
|
|
12501
|
+
))[0], S = Number(R?.__rowCount ?? 0), N = Number(R?.__validValueCount ?? 0);
|
|
12502
|
+
if (S !== N)
|
|
12436
12503
|
throw new C(`ScopedSequence ${n} initializeFrom valuePath must be present for every matched host row`);
|
|
12437
12504
|
if (S === 0) return [];
|
|
12438
|
-
const $ = h.map((P, A) => `${f(P.fieldName)} AS ${f(`__scope_${A}`)}`), I = h.map((P) => f(P.fieldName)),
|
|
12505
|
+
const $ = h.map((P, A) => `${f(P.fieldName)} AS ${f(`__scope_${A}`)}`), I = h.map((P) => f(P.fieldName)), D = await c.query(
|
|
12439
12506
|
`SELECT ${[...$, `MAX(${b}) AS ${f("__maxValue")}`].join(", ")} FROM ${y}${g} GROUP BY ${I.join(", ")}`,
|
|
12440
12507
|
p.params
|
|
12441
12508
|
), W = new Map(a.map((P) => [String(P.name), P]));
|
|
12442
|
-
return
|
|
12509
|
+
return D.map((P) => {
|
|
12443
12510
|
const A = /* @__PURE__ */ new Map();
|
|
12444
|
-
r.forEach((
|
|
12445
|
-
if (!W.has(
|
|
12446
|
-
A.set(
|
|
12511
|
+
r.forEach((F, ye) => {
|
|
12512
|
+
if (!W.has(F.name)) throw new Error(`ScopedSequence ${n} initializeFrom scope "${F.name}" is not declared`);
|
|
12513
|
+
A.set(F.name, P[`__scope_${ye}`]);
|
|
12447
12514
|
});
|
|
12448
12515
|
const ne = Number(P.__maxValue);
|
|
12449
12516
|
if (!Number.isFinite(ne))
|
|
@@ -12474,17 +12541,17 @@ function Hs(s, e, t) {
|
|
|
12474
12541
|
return i.push(o(p)), f === "=" ? `(${y} IS NOT NULL AND ${y} = ${b})` : `(${y} IS NOT NULL AND ${y} != ${b})`;
|
|
12475
12542
|
}
|
|
12476
12543
|
if (f === "in" || f === "not in") {
|
|
12477
|
-
if (!Array.isArray(p) || p.some((
|
|
12478
|
-
const b = p.filter((
|
|
12544
|
+
if (!Array.isArray(p) || p.some((R) => R === void 0)) return;
|
|
12545
|
+
const b = p.filter((R) => R !== null).map(o), g = p.length !== b.length;
|
|
12479
12546
|
if (f === "in" && p.length === 0) return "1 = 0";
|
|
12480
12547
|
if (f === "not in" && p.length === 0) return `${y} IS NOT NULL`;
|
|
12481
|
-
const w = b.map((
|
|
12548
|
+
const w = b.map((R) => {
|
|
12482
12549
|
const S = a();
|
|
12483
|
-
return i.push(
|
|
12550
|
+
return i.push(R), S;
|
|
12484
12551
|
});
|
|
12485
12552
|
if (f === "in") {
|
|
12486
|
-
const
|
|
12487
|
-
return g ? `(${y} IS NULL OR ${
|
|
12553
|
+
const R = w.length ? `${y} IN (${w.join(", ")})` : "1 = 0";
|
|
12554
|
+
return g ? `(${y} IS NULL OR ${R})` : `(${y} IS NOT NULL AND ${R})`;
|
|
12488
12555
|
}
|
|
12489
12556
|
return g && w.length === 0 ? `${y} IS NOT NULL` : g ? `(${y} IS NOT NULL AND ${y} NOT IN (${w.join(", ")}))` : `(${y} IS NOT NULL AND ${y} NOT IN (${w.join(", ")}))`;
|
|
12490
12557
|
}
|
|
@@ -12507,7 +12574,7 @@ async function Ks(s, e, t) {
|
|
|
12507
12574
|
for (const i of s.scheduler.computationsHandles.values()) {
|
|
12508
12575
|
const r = i.args;
|
|
12509
12576
|
if (r._type !== "ScopedSequence" || !r.initializeFrom) continue;
|
|
12510
|
-
const a =
|
|
12577
|
+
const a = yt(i), n = L(i.dataContext);
|
|
12511
12578
|
if (!Xe(
|
|
12512
12579
|
e,
|
|
12513
12580
|
($) => $.kind === "scoped-sequence-seed" && $.id === a && $.dataContext === n
|
|
@@ -12546,25 +12613,25 @@ async function Ks(s, e, t) {
|
|
|
12546
12613
|
String(o.valuePath),
|
|
12547
12614
|
...m.map(($) => $.path),
|
|
12548
12615
|
...rs(p)
|
|
12549
|
-
])), g = b.includes("*") ? ["*"] : b, w = (await s.system.storage.find(c, void 0, void 0, g)).filter(($) => sa(p, $)),
|
|
12550
|
-
let
|
|
12616
|
+
])), g = b.includes("*") ? ["*"] : b, w = (await s.system.storage.find(c, void 0, void 0, g)).filter(($) => sa(p, $)), R = new Map(f.map(($) => [String($.name), $])), S = /* @__PURE__ */ new Map();
|
|
12617
|
+
let N = 0;
|
|
12551
12618
|
for (const $ of w) {
|
|
12552
|
-
const I =
|
|
12619
|
+
const I = vi($, String(o.valuePath));
|
|
12553
12620
|
if (I == null)
|
|
12554
12621
|
throw new C(`ScopedSequence ${String(r.name)} initializeFrom valuePath must be present for every matched host row`);
|
|
12555
|
-
const
|
|
12556
|
-
if (!Number.isFinite(
|
|
12622
|
+
const D = Number(I);
|
|
12623
|
+
if (!Number.isFinite(D))
|
|
12557
12624
|
throw new Error(`ScopedSequence ${String(r.name)} initializeFrom valuePath must resolve to numbers`);
|
|
12558
|
-
|
|
12625
|
+
N += 1;
|
|
12559
12626
|
const W = /* @__PURE__ */ new Map();
|
|
12560
|
-
for (const
|
|
12561
|
-
if (!
|
|
12562
|
-
W.set(
|
|
12627
|
+
for (const F of m) {
|
|
12628
|
+
if (!R.get(F.name)) throw new Error(`ScopedSequence ${String(r.name)} initializeFrom scope "${F.name}" is not declared`);
|
|
12629
|
+
W.set(F.name, vi($, F.path));
|
|
12563
12630
|
}
|
|
12564
12631
|
const P = na(f, W), A = JSON.stringify(P), ne = S.get(A);
|
|
12565
|
-
(!ne ||
|
|
12632
|
+
(!ne || D > ne.max) && S.set(A, { scope: P, max: D });
|
|
12566
12633
|
}
|
|
12567
|
-
if (
|
|
12634
|
+
if (N !== w.length)
|
|
12568
12635
|
throw new C(`ScopedSequence ${String(r.name)} initializeFrom did not validate every matched host row`);
|
|
12569
12636
|
for (const $ of S.values())
|
|
12570
12637
|
await s.system.storage.atomic.seedSequenceValue({
|
|
@@ -12615,7 +12682,7 @@ async function Gs(s, e, t, i) {
|
|
|
12615
12682
|
return [n, await i.find(o.source.name, o.match, o.modifier ?? {}, o.attributeQuery)];
|
|
12616
12683
|
if (o.type === "property") {
|
|
12617
12684
|
if (t?.id === void 0)
|
|
12618
|
-
throw new C(`Record ID is required to resolve property data dependency '${n}' for ${
|
|
12685
|
+
throw new C(`Record ID is required to resolve property data dependency '${n}' for ${L(e.dataContext)}`);
|
|
12619
12686
|
const c = e.dataContext.host.name;
|
|
12620
12687
|
return [n, await i.findOne(c, E.atom({ key: "id", value: ["=", t.id] }), {}, o.attributeQuery)];
|
|
12621
12688
|
}
|
|
@@ -12625,12 +12692,12 @@ async function Gs(s, e, t, i) {
|
|
|
12625
12692
|
const u = s.dict.find((l) => l.name === o.source.name);
|
|
12626
12693
|
return [n, u?.defaultValue !== void 0 ? u.defaultValue() : void 0];
|
|
12627
12694
|
}
|
|
12628
|
-
throw new C(`Unknown data dependency type '${o.type}' for ${
|
|
12695
|
+
throw new C(`Unknown data dependency type '${o.type}' for ${L(e.dataContext)}`);
|
|
12629
12696
|
}));
|
|
12630
12697
|
return Object.fromEntries(a);
|
|
12631
12698
|
}
|
|
12632
|
-
async function
|
|
12633
|
-
const r =
|
|
12699
|
+
async function Ci(s, e, t, i) {
|
|
12700
|
+
const r = Ki(s), a = [], n = async (o) => {
|
|
12634
12701
|
if (s.system.storage.queryHandle)
|
|
12635
12702
|
return s.system.storage.find(o, void 0, void 0, ["*"]);
|
|
12636
12703
|
if (!t) return;
|
|
@@ -12643,7 +12710,7 @@ async function Ti(s, e, t, i) {
|
|
|
12643
12710
|
};
|
|
12644
12711
|
for (const o of e) {
|
|
12645
12712
|
const c = r.get(o.computationId);
|
|
12646
|
-
if (c?.dataContext.type === "property" && c.dataContext.id.name ===
|
|
12713
|
+
if (c?.dataContext.type === "property" && c.dataContext.id.name === ei) {
|
|
12647
12714
|
const u = c.dataContext.host.name, l = await n(u), d = [];
|
|
12648
12715
|
if (l && typeof c.compute == "function")
|
|
12649
12716
|
for (const h of l)
|
|
@@ -12652,7 +12719,7 @@ async function Ti(s, e, t, i) {
|
|
|
12652
12719
|
h
|
|
12653
12720
|
) === !0 && d.push(String(h.id));
|
|
12654
12721
|
a.push({
|
|
12655
|
-
dataContext:
|
|
12722
|
+
dataContext: L(c.dataContext),
|
|
12656
12723
|
recordName: u,
|
|
12657
12724
|
ids: d,
|
|
12658
12725
|
count: d.length || l?.length,
|
|
@@ -12667,7 +12734,7 @@ async function Ti(s, e, t, i) {
|
|
|
12667
12734
|
if (!Array.isArray(h)) continue;
|
|
12668
12735
|
const m = new Set(h.map((y) => `${y[l]}:${y[d]}`)), p = (await n(u) || []).filter((y) => !m.has(`${y[l]}:${y[d]}`)).map((y) => String(y.id));
|
|
12669
12736
|
p.length && a.push({
|
|
12670
|
-
dataContext:
|
|
12737
|
+
dataContext: L(c.dataContext),
|
|
12671
12738
|
recordName: u,
|
|
12672
12739
|
ids: p,
|
|
12673
12740
|
count: p.length,
|
|
@@ -12691,7 +12758,7 @@ function Ea(s, e) {
|
|
|
12691
12758
|
async function Ir(s, e, t, i) {
|
|
12692
12759
|
const r = (e.approvedDiff?.decisions || []).filter((a) => a.kind === "computation-takeover");
|
|
12693
12760
|
for (const a of r) {
|
|
12694
|
-
const n = await
|
|
12761
|
+
const n = await Ra(s, a.dataContext, t, i);
|
|
12695
12762
|
if (n.expectedExistingCount !== a.expectedExistingCount)
|
|
12696
12763
|
throw new he(`Computation takeover count mismatch for ${a.dataContext}`);
|
|
12697
12764
|
if (a.expectedHostCount !== void 0 && n.expectedHostCount !== a.expectedHostCount)
|
|
@@ -12705,7 +12772,7 @@ async function Ir(s, e, t, i) {
|
|
|
12705
12772
|
}
|
|
12706
12773
|
}
|
|
12707
12774
|
}
|
|
12708
|
-
function
|
|
12775
|
+
function zi(s, e) {
|
|
12709
12776
|
const t = new Map(s.storage.records.filter((r) => r.isFiltered).map((r) => [r.recordName, r])), i = [];
|
|
12710
12777
|
for (const r of e.storage.records) {
|
|
12711
12778
|
if (!r.isFiltered) continue;
|
|
@@ -12715,7 +12782,7 @@ function Wi(s, e) {
|
|
|
12715
12782
|
return i;
|
|
12716
12783
|
}
|
|
12717
12784
|
function Pr(s, e) {
|
|
12718
|
-
return
|
|
12785
|
+
return zi(s, e).map((t) => `${t.isRelation ? "relation" : "entity"}:${t.recordName}`);
|
|
12719
12786
|
}
|
|
12720
12787
|
function Js(s) {
|
|
12721
12788
|
return s.map((e) => {
|
|
@@ -12725,23 +12792,23 @@ function Js(s) {
|
|
|
12725
12792
|
}
|
|
12726
12793
|
async function Mr(s) {
|
|
12727
12794
|
const e = s.system;
|
|
12728
|
-
return e.readMigrationManifest ? e.readMigrationManifest() : s.system.storage.get(
|
|
12795
|
+
return e.readMigrationManifest ? e.readMigrationManifest() : s.system.storage.get(_i, Bi);
|
|
12729
12796
|
}
|
|
12730
|
-
async function
|
|
12797
|
+
async function hi(s, e) {
|
|
12731
12798
|
const t = s.system;
|
|
12732
12799
|
if (t.writeMigrationManifest) {
|
|
12733
12800
|
await t.writeMigrationManifest(e);
|
|
12734
12801
|
return;
|
|
12735
12802
|
}
|
|
12736
|
-
await s.system.storage.set(
|
|
12803
|
+
await s.system.storage.set(_i, Bi, e);
|
|
12737
12804
|
}
|
|
12738
|
-
function
|
|
12805
|
+
function rt(s, e) {
|
|
12739
12806
|
return fe(s) === fe(e);
|
|
12740
12807
|
}
|
|
12741
|
-
async function
|
|
12742
|
-
const a = ma(r,
|
|
12808
|
+
async function Gi(s, e, t, i, r = {}) {
|
|
12809
|
+
const a = ma(r, L(e.dataContext));
|
|
12743
12810
|
if (!a)
|
|
12744
|
-
throw new
|
|
12811
|
+
throw new Ui(`Migration cannot treat async task creation as completion for ${L(e.dataContext)}`);
|
|
12745
12812
|
return a({
|
|
12746
12813
|
controller: s,
|
|
12747
12814
|
dataContext: e.dataContext,
|
|
@@ -12757,19 +12824,19 @@ async function Ae(s, e, t, i, r = {}, a = {}) {
|
|
|
12757
12824
|
if (s.system.storage.schema.constraints.some(
|
|
12758
12825
|
(u) => u.kind === "non-null" && u.recordName === o.host.name && u.property === o.id.name
|
|
12759
12826
|
))
|
|
12760
|
-
throw new C(`Computation takeover cannot keep old value for non-null property ${
|
|
12827
|
+
throw new C(`Computation takeover cannot keep old value for non-null property ${L(e.dataContext)} when computation returns skip`);
|
|
12761
12828
|
t = null;
|
|
12762
12829
|
}
|
|
12763
|
-
if (t instanceof
|
|
12764
|
-
throw new
|
|
12830
|
+
if (t instanceof ft && (t = await Gi(s, e, t, i, r)), t instanceof Xt)
|
|
12831
|
+
throw new Ui(`Migration requires direct final output, not asyncReturn resolution, for ${L(e.dataContext)}`);
|
|
12765
12832
|
const n = await s.retrieveLastValue(e.dataContext, i);
|
|
12766
|
-
if (!(!a.forceMutationEvent &&
|
|
12767
|
-
return
|
|
12833
|
+
if (!(!a.forceMutationEvent && rt(n, t)))
|
|
12834
|
+
return rt(n, t) || await s.applyResult(e.dataContext, t, i), $a(e.dataContext, t, n, i);
|
|
12768
12835
|
}
|
|
12769
12836
|
async function Xs(s, e, t, i, r = {}) {
|
|
12770
12837
|
if (t instanceof Oe || t === void 0) return [];
|
|
12771
|
-
if (t instanceof
|
|
12772
|
-
throw new
|
|
12838
|
+
if (t instanceof ft && (t = await Gi(s, e, t, i, r)), t instanceof Xt)
|
|
12839
|
+
throw new Ui(`Migration requires direct final output for ${L(e.dataContext)}`);
|
|
12773
12840
|
const a = Array.isArray(t) ? t : [t], n = [];
|
|
12774
12841
|
for (const o of a) {
|
|
12775
12842
|
if (!o || typeof o != "object" || !("type" in o)) {
|
|
@@ -12779,7 +12846,7 @@ async function Xs(s, e, t, i, r = {}) {
|
|
|
12779
12846
|
}
|
|
12780
12847
|
const c = o;
|
|
12781
12848
|
if (c.type === "delete" && (e.dataContext.type === "entity" || e.dataContext.type === "relation"))
|
|
12782
|
-
throw new he(`Migration refuses delete patch for ${
|
|
12849
|
+
throw new he(`Migration refuses delete patch for ${L(e.dataContext)} without explicit audited scope`);
|
|
12783
12850
|
if (await s.applyResultPatch(e.dataContext, c, i), e.dataContext.type === "entity" || e.dataContext.type === "relation")
|
|
12784
12851
|
n.push({
|
|
12785
12852
|
recordName: e.dataContext.id.name,
|
|
@@ -12805,7 +12872,7 @@ function $a(s, e, t, i) {
|
|
|
12805
12872
|
keys: ["value"]
|
|
12806
12873
|
};
|
|
12807
12874
|
if (s.type === "property" && i)
|
|
12808
|
-
return s.id.name ===
|
|
12875
|
+
return s.id.name === ei && e ? {
|
|
12809
12876
|
recordName: s.host.name,
|
|
12810
12877
|
type: "delete",
|
|
12811
12878
|
record: i
|
|
@@ -12829,21 +12896,21 @@ function Ye(s, e, t = /* @__PURE__ */ new WeakSet()) {
|
|
|
12829
12896
|
async function Ys(s, e, t = {}) {
|
|
12830
12897
|
if (e.dataContext.type !== "entity" && e.dataContext.type !== "relation") return [];
|
|
12831
12898
|
let i = await e.compute(await s.scheduler.resolveDataDeps(e));
|
|
12832
|
-
if (i instanceof
|
|
12833
|
-
throw new
|
|
12899
|
+
if (i instanceof ft && (i = await Gi(s, e, i, void 0, t)), !Array.isArray(i))
|
|
12900
|
+
throw new it(`Entity/relation migration compute must return an array for ${L(e.dataContext)}`);
|
|
12834
12901
|
const r = e.dataContext.id.name, a = e.state?.sourceRecordId?.key, n = e.state?.transformIndex?.key;
|
|
12835
12902
|
if (!a || !n)
|
|
12836
|
-
throw new
|
|
12837
|
-
if (
|
|
12838
|
-
const d =
|
|
12903
|
+
throw new it(`Transform migration requires sourceRecordId and transformIndex state for ${L(e.dataContext)}`);
|
|
12904
|
+
if (Hi(t.approvedDiff, L(e.dataContext))?.targetType === e.dataContext.type) {
|
|
12905
|
+
const d = Ut(
|
|
12839
12906
|
t.approvedDiff,
|
|
12840
|
-
(y) => y.kind === "destructive-scope" && y.dataContext ===
|
|
12907
|
+
(y) => y.kind === "destructive-scope" && y.dataContext === L(e.dataContext) && y.recordName === r
|
|
12841
12908
|
);
|
|
12842
12909
|
if (!d)
|
|
12843
12910
|
throw new he(`Migration takeover requires approved destructive scope before clearing ${r}`);
|
|
12844
12911
|
const h = await s.system.storage.find(r, void 0, void 0, ["*"]), m = new Set(d.ids.map(String)), f = new Set(h.map((y) => String(y.id)));
|
|
12845
12912
|
if (m.size !== f.size || [...f].some((y) => !m.has(y)))
|
|
12846
|
-
throw new he(`Migration takeover destructive scope mismatch for ${
|
|
12913
|
+
throw new he(`Migration takeover destructive scope mismatch for ${L(e.dataContext)}`);
|
|
12847
12914
|
const p = [];
|
|
12848
12915
|
for (const y of h)
|
|
12849
12916
|
await s.system.storage.delete(r, E.atom({ key: "id", value: ["=", y.id] })), p.push({ recordName: r, type: "delete", record: y });
|
|
@@ -12857,16 +12924,16 @@ async function Ys(s, e, t = {}) {
|
|
|
12857
12924
|
for (const d of i) {
|
|
12858
12925
|
const h = `${d[a]}:${d[n]}`, m = u.get(h);
|
|
12859
12926
|
if (u.delete(h), m)
|
|
12860
|
-
|
|
12927
|
+
rt({ ...m, id: void 0 }, { ...d, id: void 0 }) || (await s.system.storage.update(r, E.atom({ key: "id", value: ["=", m.id] }), d), l.push({ recordName: r, type: "update", record: { ...m, ...d }, oldRecord: m, keys: Object.keys(d) }));
|
|
12861
12928
|
else {
|
|
12862
12929
|
const f = await s.system.storage.create(r, d);
|
|
12863
12930
|
l.push({ recordName: r, type: "create", record: f });
|
|
12864
12931
|
}
|
|
12865
12932
|
}
|
|
12866
12933
|
for (const d of u.values()) {
|
|
12867
|
-
if (!
|
|
12934
|
+
if (!Ut(
|
|
12868
12935
|
t.approvedDiff,
|
|
12869
|
-
(m) => m.kind === "destructive-scope" && m.dataContext ===
|
|
12936
|
+
(m) => m.kind === "destructive-scope" && m.dataContext === L(e.dataContext) && m.recordName === r
|
|
12870
12937
|
)?.ids.map(String).includes(String(d.id)))
|
|
12871
12938
|
throw new he(`Migration would delete stale derived ${r} record ${d.id}; approve destructive scope before executing`);
|
|
12872
12939
|
await s.system.storage.delete(r, E.atom({ key: "id", value: ["=", d.id] })), l.push({ recordName: r, type: "delete", record: d });
|
|
@@ -12874,11 +12941,11 @@ async function Ys(s, e, t = {}) {
|
|
|
12874
12941
|
return l;
|
|
12875
12942
|
}
|
|
12876
12943
|
async function Zs(s, e, t = {}, i = [], r) {
|
|
12877
|
-
return Ea(t, await
|
|
12944
|
+
return Ea(t, await Ci(s, e, r)), new eo(s, e, t, i).run();
|
|
12878
12945
|
}
|
|
12879
12946
|
class eo {
|
|
12880
12947
|
constructor(e, t, i = {}, r = []) {
|
|
12881
|
-
this.controller = e, this.rebuildPlan = t, this.options = i, this.initialEvents = r, this.handles =
|
|
12948
|
+
this.controller = e, this.rebuildPlan = t, this.options = i, this.initialEvents = r, this.handles = Ki(this.controller), this.sourceMapManager = new zr(this.controller, this.controller.scheduler), this.affectedIds = new Set(this.rebuildPlan.map((a) => a.computationId)), this.pendingEventsByComputation = /* @__PURE__ */ new Map(), this.sourceMapManager.initialize(new Set(
|
|
12882
12949
|
Array.from(this.handles.entries()).filter(([a]) => this.affectedIds.has(a)).map(([, a]) => a)
|
|
12883
12950
|
));
|
|
12884
12951
|
}
|
|
@@ -12888,10 +12955,10 @@ class eo {
|
|
|
12888
12955
|
for (const t of this.rebuildPlan) {
|
|
12889
12956
|
const i = this.handles.get(t.computationId);
|
|
12890
12957
|
if (!i) continue;
|
|
12891
|
-
if (i.dataContext.type === "property" && i.dataContext.id.name ===
|
|
12892
|
-
throw new he(`Migration refuses to recompute destructive property ${
|
|
12893
|
-
if (typeof i.compute != "function" && !
|
|
12894
|
-
throw new
|
|
12958
|
+
if (i.dataContext.type === "property" && i.dataContext.id.name === ei && !Xe(this.options.approvedDiff, (n) => n.kind === "destructive-scope" && n.dataContext === L(i.dataContext)))
|
|
12959
|
+
throw new he(`Migration refuses to recompute destructive property ${L(i.dataContext)} without approved destructive scope`);
|
|
12960
|
+
if (typeof i.compute != "function" && !qt(this.options, L(i.dataContext)))
|
|
12961
|
+
throw new it(`Migration requires full compute support for ${L(i.dataContext)}`);
|
|
12895
12962
|
if (t.rebuildState && !t.rebuildOutput) {
|
|
12896
12963
|
await this.rebuildStateDefaults(i);
|
|
12897
12964
|
continue;
|
|
@@ -12905,13 +12972,13 @@ class eo {
|
|
|
12905
12972
|
for (const i of e) {
|
|
12906
12973
|
const r = this.sourceMapManager.findSourceMapsForMutation(i);
|
|
12907
12974
|
for (const a of r) {
|
|
12908
|
-
const n =
|
|
12975
|
+
const n = yt(a.computation);
|
|
12909
12976
|
n === t || !this.affectedIds.has(n) || this.sourceMapManager.shouldTriggerUpdateComputation(a, i) && (!("dataDep" in a) && !this.sourceMapManager.shouldTriggerEventBasedComputation(a, i) || (this.pendingEventsByComputation.has(n) || this.pendingEventsByComputation.set(n, []), this.pendingEventsByComputation.get(n).push(i)));
|
|
12910
12977
|
}
|
|
12911
12978
|
}
|
|
12912
12979
|
}
|
|
12913
12980
|
async runFullRecompute(e) {
|
|
12914
|
-
const t =
|
|
12981
|
+
const t = Hi(this.options.approvedDiff, L(e.dataContext)), i = t?.targetType === "property" ? { forceMutationEvent: !0, skipAsNull: !0 } : {}, r = qt(this.options, L(e.dataContext));
|
|
12915
12982
|
if (r && typeof e.compute != "function") {
|
|
12916
12983
|
if (e.dataContext.type === "property") {
|
|
12917
12984
|
const l = e.dataContext.host.name, d = await this.controller.system.storage.find(l, void 0, void 0, ["*"]), h = [];
|
|
@@ -12960,9 +13027,9 @@ class eo {
|
|
|
12960
13027
|
const n = this.sourceMapManager.findSourceMapsForMutation(a).filter((o) => o.computation === e);
|
|
12961
13028
|
for (const o of n) {
|
|
12962
13029
|
if (!("dataDep" in o)) {
|
|
12963
|
-
const l =
|
|
13030
|
+
const l = qt(this.options, L(e.dataContext));
|
|
12964
13031
|
if (!l)
|
|
12965
|
-
throw new
|
|
13032
|
+
throw new it(`Event-based migration requires an approved event rebuild handler for ${L(e.dataContext)}`);
|
|
12966
13033
|
if (e.dataContext.type === "property") {
|
|
12967
13034
|
r || (r = !0, i.push(...await this.runFullRecompute(e)));
|
|
12968
13035
|
continue;
|
|
@@ -12991,7 +13058,7 @@ class eo {
|
|
|
12991
13058
|
}
|
|
12992
13059
|
async function to(s, e, t) {
|
|
12993
13060
|
const i = [], r = (a) => a ? k.fromValue(a) : void 0;
|
|
12994
|
-
for (const a of
|
|
13061
|
+
for (const a of zi(e, t)) {
|
|
12995
13062
|
const n = a.newRecord, o = n.resolvedBaseRecordName;
|
|
12996
13063
|
if (!o || !n.resolvedMatchExpression) continue;
|
|
12997
13064
|
const c = await s.system.storage.find(o, r(n.resolvedMatchExpression), void 0, ["*"]);
|
|
@@ -13030,10 +13097,10 @@ class ka {
|
|
|
13030
13097
|
return new ka(e);
|
|
13031
13098
|
}
|
|
13032
13099
|
}
|
|
13033
|
-
const
|
|
13100
|
+
const Dt = "_isDeleted_", qr = new Ai(), Ko = {
|
|
13034
13101
|
create() {
|
|
13035
13102
|
return x.create({
|
|
13036
|
-
name:
|
|
13103
|
+
name: Dt,
|
|
13037
13104
|
type: "boolean"
|
|
13038
13105
|
});
|
|
13039
13106
|
}
|
|
@@ -13082,7 +13149,7 @@ class Wo {
|
|
|
13082
13149
|
...ss,
|
|
13083
13150
|
...c
|
|
13084
13151
|
];
|
|
13085
|
-
this.scheduler = new
|
|
13152
|
+
this.scheduler = new Bt(this, this.entities, this.relations, this.dict, h), o.forEach((m) => {
|
|
13086
13153
|
let f = this.recordNameToSideEffects.get(m.record.name);
|
|
13087
13154
|
f || this.recordNameToSideEffects.set(m.record.name, f = /* @__PURE__ */ new Set()), f.add(m);
|
|
13088
13155
|
});
|
|
@@ -13100,16 +13167,16 @@ class Wo {
|
|
|
13100
13167
|
const o = this.system, c = o.prepareMigrationSchema;
|
|
13101
13168
|
if (typeof c != "function")
|
|
13102
13169
|
throw new Error("Current system does not support migration manifest validation");
|
|
13103
|
-
const u = await c.call(o, this.entities, this.relations, r, { internalRequirements: a }), l =
|
|
13170
|
+
const u = await c.call(o, this.entities, this.relations, r, { internalRequirements: a }), l = Et(this, u.schema), d = await Mr(this);
|
|
13104
13171
|
if (d && $r(d), d && d.modelHash !== l.modelHash)
|
|
13105
|
-
throw new Error(`Model manifest mismatch. Call controller.generateMigrationDiff(), review it, then call controller.migrate({ approvedDiff }). Manifest key: ${
|
|
13172
|
+
throw new Error(`Model manifest mismatch. Call controller.generateMigrationDiff(), review it, then call controller.migrate({ approvedDiff }). Manifest key: ${_i}/${Bi}`);
|
|
13106
13173
|
if (!d && await this.system.hasExistingData?.())
|
|
13107
|
-
throw new
|
|
13174
|
+
throw new Mt("Existing database has no migration manifest. Call controller.createMigrationBaseline() before normal setup or migration.");
|
|
13108
13175
|
await this.system.setup(this.entities, this.relations, r, { install: t, internalRequirements: a }), await this.scheduler.setup(t);
|
|
13109
13176
|
return;
|
|
13110
13177
|
}
|
|
13111
13178
|
await this.system.setup(this.entities, this.relations, r, { install: t, internalRequirements: a });
|
|
13112
|
-
const n =
|
|
13179
|
+
const n = Et(this);
|
|
13113
13180
|
try {
|
|
13114
13181
|
await this.scheduler.setup(t);
|
|
13115
13182
|
} catch (o) {
|
|
@@ -13121,7 +13188,7 @@ class Wo {
|
|
|
13121
13188
|
}
|
|
13122
13189
|
);
|
|
13123
13190
|
}
|
|
13124
|
-
t && await
|
|
13191
|
+
t && await hi(this, n);
|
|
13125
13192
|
}
|
|
13126
13193
|
/**
|
|
13127
13194
|
* Detach this controller from the system: unregister all reactive computation
|
|
@@ -13147,21 +13214,21 @@ class Wo {
|
|
|
13147
13214
|
_(typeof i.prepareMigrationSchema == "function", "Current system does not support migration baseline");
|
|
13148
13215
|
const r = await i.prepareMigrationSchema(this.entities, this.relations, e, { internalRequirements: t });
|
|
13149
13216
|
if (r.preRecomputeDDL.length > 0 || r.blockingChanges.length > 0)
|
|
13150
|
-
throw new
|
|
13217
|
+
throw new Mt("Cannot create migration baseline because current definitions do not match the existing schema", {
|
|
13151
13218
|
missingDDL: r.preRecomputeDDL,
|
|
13152
13219
|
blockingChanges: r.blockingChanges
|
|
13153
13220
|
});
|
|
13154
|
-
const a =
|
|
13155
|
-
return await
|
|
13221
|
+
const a = Et(this, r.schema);
|
|
13222
|
+
return await hi(this, a), a;
|
|
13156
13223
|
}
|
|
13157
13224
|
async prepareMigrationContext(e = {}) {
|
|
13158
13225
|
const t = this.scheduler.createStates(), i = this.scheduler.createInternalSchemaRequirements(), r = this.system;
|
|
13159
13226
|
_(typeof r.prepareMigrationSchema == "function", "Current system does not support schema migration planning");
|
|
13160
13227
|
const a = await r.prepareMigrationSchema(this.entities, this.relations, t, { internalRequirements: i }), n = await Mr(this);
|
|
13161
13228
|
if (!n)
|
|
13162
|
-
throw new
|
|
13229
|
+
throw new Mt("Migration baseline manifest not found. Run setup(true) with the current framework first or createMigrationBaseline().");
|
|
13163
13230
|
$r(n);
|
|
13164
|
-
const o =
|
|
13231
|
+
const o = Et(this, a.schema, { includeFunctionText: e.includeFunctionText === !0 });
|
|
13165
13232
|
return { states: t, migrationSystem: r, schemaPlan: a, previousManifest: n, nextManifest: o };
|
|
13166
13233
|
}
|
|
13167
13234
|
async buildCurrentMigrationDiff(e, t, i, r = {}) {
|
|
@@ -13173,7 +13240,7 @@ class Wo {
|
|
|
13173
13240
|
a,
|
|
13174
13241
|
n,
|
|
13175
13242
|
{ outputChangedIds: new Set(a.map((p) => p.id)) }
|
|
13176
|
-
), c = Ar(t, i), u = kr(this, e), l = r.includeDestructiveScope === !0 ? await
|
|
13243
|
+
), c = Ar(t, i), u = kr(this, e), l = r.includeDestructiveScope === !0 ? await Ci(this, o, t, u) : [], d = {
|
|
13177
13244
|
blockingChanges: [
|
|
13178
13245
|
...e.blockingChanges,
|
|
13179
13246
|
...c
|
|
@@ -13193,27 +13260,27 @@ class Wo {
|
|
|
13193
13260
|
_(typeof r.applyMigrationSchema == "function", "Current system does not support schema migration application");
|
|
13194
13261
|
const { schemaPlan: a, previousManifest: n, nextManifest: o } = i, c = await this.buildCurrentMigrationDiff(a, n, o, { includeDestructiveScope: !1 });
|
|
13195
13262
|
qs(t.approvedDiff, n, o, t.handlers, c);
|
|
13196
|
-
const u = t.approvedDiff, l = ds(u), d = Os(u), h =
|
|
13263
|
+
const u = t.approvedDiff, l = ds(u), d = Os(u), h = Ls(u), m = Ds(n, o, u), f = m.changedComputations, p = Pr(n, o), y = xr(n, o, f, p, {
|
|
13197
13264
|
outputChangedIds: m.outputChangedIds,
|
|
13198
13265
|
stateOnlyIds: m.stateOnlyIds
|
|
13199
|
-
}), b = await
|
|
13266
|
+
}), b = await Na(this, t.approvedDiff, n), g = As(n, b), w = {
|
|
13200
13267
|
...a,
|
|
13201
13268
|
postRecomputeDDL: [
|
|
13202
13269
|
...a.postRecomputeDDL,
|
|
13203
13270
|
...g
|
|
13204
13271
|
]
|
|
13205
|
-
},
|
|
13272
|
+
}, R = Ar(n, o).filter((F) => !(F.kind === "unsupported-destructive-schema-change" && b.has(F.logicalPath))), S = Qs(
|
|
13206
13273
|
this,
|
|
13207
13274
|
y,
|
|
13208
13275
|
t,
|
|
13209
13276
|
n
|
|
13210
|
-
),
|
|
13277
|
+
), N = [
|
|
13211
13278
|
...a.blockingChanges,
|
|
13212
|
-
...
|
|
13279
|
+
...R,
|
|
13213
13280
|
...m.blocking,
|
|
13214
13281
|
...S
|
|
13215
|
-
], $ = Js(
|
|
13216
|
-
Ea(t,
|
|
13282
|
+
], $ = Js(N), I = kr(this, a), D = await Ci(this, y, n, I);
|
|
13283
|
+
Ea(t, D), await Ir(this, t, n, I), await Cs(this, t.approvedDiff, n, I);
|
|
13217
13284
|
const W = Ws(this, n, o), P = {
|
|
13218
13285
|
mode: "compute",
|
|
13219
13286
|
dryRun: t.dryRun === !0,
|
|
@@ -13227,10 +13294,10 @@ class Wo {
|
|
|
13227
13294
|
preRecomputeDDL: w.preRecomputeDDL,
|
|
13228
13295
|
postRecomputeDDL: w.postRecomputeDDL,
|
|
13229
13296
|
verificationDDL: w.verificationDDL,
|
|
13230
|
-
blockingChanges:
|
|
13297
|
+
blockingChanges: N
|
|
13231
13298
|
},
|
|
13232
13299
|
blockingChanges: $,
|
|
13233
|
-
deletionScope:
|
|
13300
|
+
deletionScope: D,
|
|
13234
13301
|
approvedDiffHash: l
|
|
13235
13302
|
};
|
|
13236
13303
|
if (P.dryRun) return P;
|
|
@@ -13239,9 +13306,9 @@ class Wo {
|
|
|
13239
13306
|
${$.join(`
|
|
13240
13307
|
`)}`);
|
|
13241
13308
|
let A;
|
|
13242
|
-
const ne = (
|
|
13243
|
-
const
|
|
13244
|
-
return
|
|
13309
|
+
const ne = (F, ye) => {
|
|
13310
|
+
const ii = ["pending", "schema-applied", "computation-applied", "constraints-applied", "manifest-written", "succeeded"];
|
|
13311
|
+
return ii.indexOf(F) >= ii.indexOf(ye);
|
|
13245
13312
|
};
|
|
13246
13313
|
this.scheduler.teardown(), this.scheduler.registerDictDefaults();
|
|
13247
13314
|
try {
|
|
@@ -13251,28 +13318,28 @@ ${$.join(`
|
|
|
13251
13318
|
u.summary,
|
|
13252
13319
|
u.decisions.length
|
|
13253
13320
|
);
|
|
13254
|
-
const
|
|
13255
|
-
await r.applyMigrationSchema(w, A?.id), ne(
|
|
13256
|
-
if (!ne(
|
|
13321
|
+
const F = A?.phase || "pending";
|
|
13322
|
+
await r.applyMigrationSchema(w, A?.id), ne(F, "schema-applied") || A && await r.updateMigrationPhase?.(A.id, "schema-applied"), ne(F, "manifest-written") || await this.system.storage.runInTransaction({ name: "migration recompute", isolation: "SERIALIZABLE" }, async () => {
|
|
13323
|
+
if (!ne(F, "computation-applied")) {
|
|
13257
13324
|
await zs(this, W);
|
|
13258
13325
|
const Aa = await to(this, n, o);
|
|
13259
13326
|
await Ir(this, t, n), await Zs(this, y, t, Aa, n), await Ks(this, u, n), A && await r.updateMigrationPhase?.(A.id, "computation-applied");
|
|
13260
13327
|
}
|
|
13261
|
-
ne(
|
|
13328
|
+
ne(F, "constraints-applied") || (await xs(this, t.approvedDiff, n), await r.verifyMigrationSchema?.(w, A?.id), await r.applyMigrationPostSchema?.(w, A?.id), A && await r.updateMigrationPhase?.(A.id, "constraints-applied"));
|
|
13262
13329
|
const ye = `manifest:current:${o.modelHash}:${l}`;
|
|
13263
|
-
await r.isMigrationOperationComplete?.(A?.id, ye) || (await
|
|
13330
|
+
await r.isMigrationOperationComplete?.(A?.id, ye) || (await hi(this, o), await r.markMigrationOperationComplete?.(A?.id, ye)), A && await r.updateMigrationPhase?.(A.id, "manifest-written");
|
|
13264
13331
|
}), A && await r.finishMigration?.(A.id, "succeeded");
|
|
13265
|
-
} catch (
|
|
13266
|
-
throw A && await r.finishMigration?.(A.id, "failed",
|
|
13332
|
+
} catch (F) {
|
|
13333
|
+
throw A && await r.finishMigration?.(A.id, "failed", F), F;
|
|
13267
13334
|
}
|
|
13268
13335
|
try {
|
|
13269
13336
|
await this.scheduler.setup(!1);
|
|
13270
|
-
} catch (
|
|
13337
|
+
} catch (F) {
|
|
13271
13338
|
throw new Be(
|
|
13272
13339
|
"Migration completed successfully (database schema, data and manifest are all migrated), but scheduler setup failed afterwards: the reactive computation layer is NOT active in this process. Fix the underlying error and call controller.setup() (without install) to register computation listeners; do NOT retry the migration.",
|
|
13273
13340
|
{
|
|
13274
13341
|
schedulingPhase: "post-migration-scheduler-setup",
|
|
13275
|
-
causedBy:
|
|
13342
|
+
causedBy: F instanceof Error ? F : new Error(String(F))
|
|
13276
13343
|
}
|
|
13277
13344
|
);
|
|
13278
13345
|
}
|
|
@@ -13312,7 +13379,7 @@ ${$.join(`
|
|
|
13312
13379
|
await this.system.storage.create(r.id.name, n);
|
|
13313
13380
|
} else {
|
|
13314
13381
|
const r = e;
|
|
13315
|
-
r.id.name ===
|
|
13382
|
+
r.id.name === Dt && t ? await this.system.storage.delete(r.host.name, k.atom({ key: "id", value: ["=", i.id] })) : await this.system.storage.update(r.host.name, k.atom({ key: "id", value: ["=", i.id] }), { [r.id.name]: t });
|
|
13316
13383
|
}
|
|
13317
13384
|
}
|
|
13318
13385
|
}
|
|
@@ -13339,7 +13406,7 @@ ${$.join(`
|
|
|
13339
13406
|
}
|
|
13340
13407
|
async applyInitialValue(e, t, i) {
|
|
13341
13408
|
if (t instanceof Oe) return;
|
|
13342
|
-
if (this.assertNotComputationEnvelope(e, t), e.id.name ===
|
|
13409
|
+
if (this.assertNotComputationEnvelope(e, t), e.id.name === Dt && t) {
|
|
13343
13410
|
await this.system.storage.delete(e.host.name, k.atom({ key: "id", value: ["=", i.id] }));
|
|
13344
13411
|
return;
|
|
13345
13412
|
}
|
|
@@ -13380,7 +13447,7 @@ ${$.join(`
|
|
|
13380
13447
|
}
|
|
13381
13448
|
} else {
|
|
13382
13449
|
const n = e;
|
|
13383
|
-
n.id.name ===
|
|
13450
|
+
n.id.name === Dt && a.data ? (_(a.type !== "delete", "Hard deletion property cannot be deleted"), await this.system.storage.delete(n.host.name, k.atom({ key: "id", value: ["=", i.id] }))) : a.type === "insert" ? await this.system.storage.update(n.host.name, k.atom({ key: "id", value: ["=", i.id] }), { [n.id.name]: a.data }) : a.type === "update" ? await this.system.storage.update(n.host.name, k.atom({ key: "id", value: ["=", i.id] }), { [n.id.name]: a.data }) : a.type === "delete" && await this.system.storage.update(n.host.name, k.atom({ key: "id", value: ["=", i.id] }), { [n.id.name]: null });
|
|
13384
13451
|
}
|
|
13385
13452
|
}
|
|
13386
13453
|
}
|
|
@@ -13417,9 +13484,9 @@ ${$.join(`
|
|
|
13417
13484
|
};
|
|
13418
13485
|
let n;
|
|
13419
13486
|
try {
|
|
13420
|
-
n = await ls.run(a, () =>
|
|
13487
|
+
n = await ls.run(a, () => Li(e.name || "dispatch", async (o) => {
|
|
13421
13488
|
const c = this.cloneDispatchArgs(t), u = { effects: [] };
|
|
13422
|
-
return
|
|
13489
|
+
return Vi.run(u, async () => this.system.storage.runInTransaction({ name: e.name, isolation: o }, async () => qr.run({ eventSourceName: e.name }, async () => {
|
|
13423
13490
|
!this.ignoreGuard && e.guard && await e.guard.call(this, c);
|
|
13424
13491
|
const l = e.mapEventData ? await e.mapEventData(c) : {};
|
|
13425
13492
|
await this.system.storage.create(e.entity.name, l);
|
|
@@ -13527,7 +13594,7 @@ class ro {
|
|
|
13527
13594
|
records: [],
|
|
13528
13595
|
tables: [],
|
|
13529
13596
|
constraints: []
|
|
13530
|
-
}, this.transactionContext = new
|
|
13597
|
+
}, this.transactionContext = new Ai(), this.dictDefaults = /* @__PURE__ */ new Map(), this.callbacks = /* @__PURE__ */ new Set(), this.transactionQueue = Promise.resolve(), this.dict = {
|
|
13531
13598
|
get: async (t) => {
|
|
13532
13599
|
const i = E.atom({ key: "key", value: ["=", t] }), r = await this.queryHandle.findOne(Z, i, void 0, ["value"]);
|
|
13533
13600
|
if (!r) {
|
|
@@ -13578,14 +13645,14 @@ class ro {
|
|
|
13578
13645
|
async runInTransaction(e, t) {
|
|
13579
13646
|
const i = e.isolation ?? "READ COMMITTED", r = this.getTransactionCapability();
|
|
13580
13647
|
if (!r.transactions)
|
|
13581
|
-
throw new
|
|
13648
|
+
throw new At({
|
|
13582
13649
|
transactionName: e.name,
|
|
13583
13650
|
requestedIsolation: i,
|
|
13584
13651
|
capability: r,
|
|
13585
13652
|
reason: "driver does not support transactions"
|
|
13586
13653
|
});
|
|
13587
13654
|
if (!r.isolationLevels.includes(i))
|
|
13588
|
-
throw new
|
|
13655
|
+
throw new At({
|
|
13589
13656
|
transactionName: e.name,
|
|
13590
13657
|
requestedIsolation: i,
|
|
13591
13658
|
capability: r,
|
|
@@ -13629,14 +13696,14 @@ class ro {
|
|
|
13629
13696
|
throw new Error(`${e} requires an active transaction`);
|
|
13630
13697
|
}
|
|
13631
13698
|
async withAtomicTransaction(e, t) {
|
|
13632
|
-
return this.isInTransaction() ? t() :
|
|
13699
|
+
return this.isInTransaction() ? t() : Li(e, (i) => this.runInTransaction({ name: e, isolation: i }, t));
|
|
13633
13700
|
}
|
|
13634
13701
|
normalizeSequenceScope(e) {
|
|
13635
13702
|
return e.map((t) => ({ name: t.name, type: t.type, value: t.value }));
|
|
13636
13703
|
}
|
|
13637
13704
|
validateAtomicSequenceTarget(e) {
|
|
13638
13705
|
if (!this.db.atomicSequenceCapability || typeof this.db.setupScopedSequenceState != "function")
|
|
13639
|
-
throw new
|
|
13706
|
+
throw new At({
|
|
13640
13707
|
transactionName: `atomic scoped sequence ${e.sequenceName || ""}`,
|
|
13641
13708
|
requestedIsolation: this.getTransactionIsolation() || "READ COMMITTED",
|
|
13642
13709
|
capability: this.getTransactionCapability(),
|
|
@@ -13720,7 +13787,7 @@ class ro {
|
|
|
13720
13787
|
};
|
|
13721
13788
|
}));
|
|
13722
13789
|
}
|
|
13723
|
-
this.queryHandle = new
|
|
13790
|
+
this.queryHandle = new bi(new qe(a.map, a.aliasManager), this.db), this.map = a.map, this.constraintSchemaItems = a.constraintSchemaItems, this.schema = this.createSchemaMetadata(a);
|
|
13724
13791
|
}
|
|
13725
13792
|
async prepareMigrationAdditive(e, t, i) {
|
|
13726
13793
|
await this.ensureDbOpenForSchemaRead(), this.db.setupInternalComputationState;
|
|
@@ -13807,7 +13874,7 @@ class ro {
|
|
|
13807
13874
|
};
|
|
13808
13875
|
}));
|
|
13809
13876
|
}
|
|
13810
|
-
this.queryHandle = new
|
|
13877
|
+
this.queryHandle = new bi(new qe(i.map, i.aliasManager), this.db), this.map = i.map, this.constraintSchemaItems = i.constraintSchemaItems, this.schema = this.createSchemaMetadata(i);
|
|
13811
13878
|
}
|
|
13812
13879
|
async applyPostRecomputeSchemaPlan(e, t) {
|
|
13813
13880
|
await this.applyMigrationOperations("constraints", e.postRecomputeDDL, t);
|
|
@@ -14030,7 +14097,7 @@ class ro {
|
|
|
14030
14097
|
tableName: r.tableName,
|
|
14031
14098
|
properties: r.kind === "unique" ? r.properties : [r.property],
|
|
14032
14099
|
driver: this.db.constructor?.name,
|
|
14033
|
-
rawCode:
|
|
14100
|
+
rawCode: xt(a, this.db).rawCode,
|
|
14034
14101
|
causedBy: a instanceof Error ? a : void 0
|
|
14035
14102
|
}
|
|
14036
14103
|
);
|
|
@@ -14128,18 +14195,18 @@ RETURNING "numberValue" AS value`,
|
|
|
14128
14195
|
async () => {
|
|
14129
14196
|
const r = this.getPlaceholder();
|
|
14130
14197
|
if (this.isRecordTarget(t)) {
|
|
14131
|
-
const { tableName: y, idField: b, fieldName: g } = this.resolveRecordTarget(t), w = r(),
|
|
14198
|
+
const { tableName: y, idField: b, fieldName: g } = this.resolveRecordTarget(t), w = r(), R = await this.db.query(
|
|
14132
14199
|
`SELECT "${g}" AS value FROM "${y}" WHERE "${b}" = ${w}${this.supportsForUpdate() ? " FOR UPDATE" : ""}`,
|
|
14133
14200
|
[t.id],
|
|
14134
14201
|
`atomic replace lock ${t.recordName}.${t.field}`
|
|
14135
14202
|
);
|
|
14136
|
-
if (!
|
|
14137
|
-
const S = this.getPlaceholder(),
|
|
14138
|
-
`UPDATE "${y}" SET "${g}" = ${
|
|
14203
|
+
if (!R.length) throw new Error(`Atomic replace target not found: ${t.recordName}.${String(t.id)}.${t.field}`);
|
|
14204
|
+
const S = this.getPlaceholder(), N = S(), $ = S(), I = await this.db.query(
|
|
14205
|
+
`UPDATE "${y}" SET "${g}" = ${N} WHERE "${b}" = ${$} RETURNING "${g}" AS value`,
|
|
14139
14206
|
[i, t.id],
|
|
14140
14207
|
`atomic replace ${t.recordName}.${t.field}`
|
|
14141
14208
|
);
|
|
14142
|
-
return { oldValue:
|
|
14209
|
+
return { oldValue: R[0].value ?? null, newValue: I[0]?.value ?? i };
|
|
14143
14210
|
}
|
|
14144
14211
|
const a = this.resolveGlobalColumn(t, i), n = this.normalizeGlobalValue(i, a);
|
|
14145
14212
|
await this.ensureGlobalStateRow(t, a);
|
|
@@ -14158,9 +14225,9 @@ RETURNING "numberValue" AS value`,
|
|
|
14158
14225
|
compareAndSet: async (t, i, r, a) => {
|
|
14159
14226
|
const n = this.getPlaceholder(), o = a?.defaultValue;
|
|
14160
14227
|
if (this.isRecordTarget(t)) {
|
|
14161
|
-
const { tableName: S, idField:
|
|
14228
|
+
const { tableName: S, idField: N, fieldName: $ } = this.resolveRecordTarget(t), I = n(), D = n(), W = n(), P = n();
|
|
14162
14229
|
return (await this.db.query(
|
|
14163
|
-
`UPDATE "${S}" SET "${$}" = ${I} WHERE "${
|
|
14230
|
+
`UPDATE "${S}" SET "${$}" = ${I} WHERE "${N}" = ${D} AND COALESCE("${$}", ${W}) = ${P} RETURNING "${$}" AS value`,
|
|
14164
14231
|
[r, t.id, o, i],
|
|
14165
14232
|
`atomic compareAndSet ${t.recordName}.${t.field}`
|
|
14166
14233
|
)).length > 0;
|
|
@@ -14315,7 +14382,7 @@ RETURNING "lastValue" AS value`,
|
|
|
14315
14382
|
return this.callWithEvents(this.queryHandle.delete.bind(this.queryHandle), [e, t], i);
|
|
14316
14383
|
}
|
|
14317
14384
|
findConstraintForError(e) {
|
|
14318
|
-
const t =
|
|
14385
|
+
const t = xt(e, this.db);
|
|
14319
14386
|
if (t.constraintName) {
|
|
14320
14387
|
const r = this.constraintSchemaItems.find((a) => a.physicalName === t.constraintName || a.constraintName === t.constraintName);
|
|
14321
14388
|
if (r) return r;
|
|
@@ -14329,7 +14396,7 @@ RETURNING "lastValue" AS value`,
|
|
|
14329
14396
|
mapConstraintError(e) {
|
|
14330
14397
|
const t = un(e);
|
|
14331
14398
|
if (t) return t;
|
|
14332
|
-
const i =
|
|
14399
|
+
const i = xt(e, this.db);
|
|
14333
14400
|
if (!i.isUniqueViolation) return e;
|
|
14334
14401
|
const r = this.findConstraintForError(e);
|
|
14335
14402
|
return new Hr(
|
|
@@ -14398,7 +14465,7 @@ RETURNING "lastValue" AS value`,
|
|
|
14398
14465
|
}
|
|
14399
14466
|
}
|
|
14400
14467
|
var ao = /* @__PURE__ */ ((s) => (s[s.ERROR = 0] = "ERROR", s[s.INFO = 1] = "INFO", s))(ao || {});
|
|
14401
|
-
class
|
|
14468
|
+
class Ji {
|
|
14402
14469
|
constructor(e = 0, t = {}) {
|
|
14403
14470
|
this.level = e, this.fixed = t;
|
|
14404
14471
|
}
|
|
@@ -14409,11 +14476,11 @@ class Gi {
|
|
|
14409
14476
|
this.level >= 0 && console.error({ ...this.fixed, type: e, name: t, sql: i, params: r, error: a });
|
|
14410
14477
|
}
|
|
14411
14478
|
child(e = {}) {
|
|
14412
|
-
return new
|
|
14479
|
+
return new Ji(this.level, { ...this.fixed, ...e });
|
|
14413
14480
|
}
|
|
14414
14481
|
}
|
|
14415
14482
|
var no = /* @__PURE__ */ ((s) => (s[s.MUTE = -1] = "MUTE", s[s.ERROR = 0] = "ERROR", s[s.INFO = 1] = "INFO", s[s.DEBUG = 2] = "DEBUG", s))(no || {});
|
|
14416
|
-
class
|
|
14483
|
+
class Xi {
|
|
14417
14484
|
constructor(e = 0, t = {}) {
|
|
14418
14485
|
this.level = e, this.fixed = t;
|
|
14419
14486
|
}
|
|
@@ -14427,10 +14494,10 @@ class Ji {
|
|
|
14427
14494
|
this.level >= 2 && console.debug(`[DEBUG] ${e}: ${t}`, { ...this.fixed, ...i });
|
|
14428
14495
|
}
|
|
14429
14496
|
child(e) {
|
|
14430
|
-
return new
|
|
14497
|
+
return new Xi(this.level, { ...this.fixed, ...e });
|
|
14431
14498
|
}
|
|
14432
14499
|
}
|
|
14433
|
-
const zo = new
|
|
14500
|
+
const zo = new Ji(), so = new Xi();
|
|
14434
14501
|
class Go {
|
|
14435
14502
|
constructor(e, t = so) {
|
|
14436
14503
|
this.logger = t, this.conceptClass = /* @__PURE__ */ new Map(), this.storage = new ro(e);
|
|
@@ -14525,7 +14592,7 @@ CREATE TABLE IF NOT EXISTS "__interaqt_migration_operation_log" (
|
|
|
14525
14592
|
"acquire migration lock"
|
|
14526
14593
|
);
|
|
14527
14594
|
} catch (r) {
|
|
14528
|
-
throw
|
|
14595
|
+
throw xt(r, this.db).isUniqueViolation ? new Error("Migration is already running (lock held by another process). If that process crashed, call controller.forceReleaseMigrationLock() after confirming no migration is actually running, then retry.") : r;
|
|
14529
14596
|
}
|
|
14530
14597
|
}
|
|
14531
14598
|
async beginMigration(e, t, i, r = 0) {
|
|
@@ -14596,10 +14663,10 @@ CREATE TABLE IF NOT EXISTS "__interaqt_migration_operation_log" (
|
|
|
14596
14663
|
await this.ensureMigrationManifestTable(), await this.storage.markMigrationOperationComplete(e, t);
|
|
14597
14664
|
}
|
|
14598
14665
|
async setup(e, t, i, r = !1) {
|
|
14599
|
-
const a = typeof r == "boolean" ? r : r.install === !0, n = typeof r == "boolean" ? { install: a } : r, o = new
|
|
14666
|
+
const a = typeof r == "boolean" ? r : r.install === !0, n = typeof r == "boolean" ? { install: a } : r, o = new fi(e, t), { entities: c, relations: u } = o.getAll();
|
|
14600
14667
|
i.forEach(({ dataContext: l, state: d }) => {
|
|
14601
14668
|
Object.entries(d).forEach(([h, m]) => {
|
|
14602
|
-
if (m instanceof
|
|
14669
|
+
if (m instanceof O) {
|
|
14603
14670
|
if (!m.record)
|
|
14604
14671
|
return;
|
|
14605
14672
|
let f = o.getEntityByName(m.record);
|
|
@@ -14629,10 +14696,10 @@ CREATE TABLE IF NOT EXISTS "__interaqt_migration_operation_log" (
|
|
|
14629
14696
|
), await this.setupTransformUniqueIndexes(i);
|
|
14630
14697
|
}
|
|
14631
14698
|
prepareEntitiesForStorage(e, t, i) {
|
|
14632
|
-
const r = new
|
|
14699
|
+
const r = new fi(e, t), { entities: a, relations: n } = r.getAll();
|
|
14633
14700
|
return i.forEach(({ state: o }) => {
|
|
14634
14701
|
Object.entries(o).forEach(([, c]) => {
|
|
14635
|
-
if (c instanceof
|
|
14702
|
+
if (c instanceof O) {
|
|
14636
14703
|
if (!c.record)
|
|
14637
14704
|
return;
|
|
14638
14705
|
let u = r.getEntityByName(c.record);
|
|
@@ -14693,11 +14760,11 @@ CREATE TABLE IF NOT EXISTS "__interaqt_migration_operation_log" (
|
|
|
14693
14760
|
async setupTransformUniqueIndexes(e) {
|
|
14694
14761
|
for (const { dataContext: t, state: i } of e) {
|
|
14695
14762
|
const r = i.sourceRecordId, a = i.transformIndex;
|
|
14696
|
-
if (!(r instanceof
|
|
14763
|
+
if (!(r instanceof O) || !(a instanceof O) || r.unique === !1 || t.type !== "entity" && t.type !== "relation")
|
|
14697
14764
|
continue;
|
|
14698
14765
|
const n = t.id.name, o = this.storage, c = o.queryHandle.map, u = c.getRecordInfo(n), [, l] = c.getTableAliasAndFieldName([n], r.key, !0), [, d] = c.getTableAliasAndFieldName([n], a.key, !0), h = `idx_transform_${this.hashIdentifier(`${u.table}_${l}_${d}`)}`, m = Q(o.db);
|
|
14699
14766
|
await o.db.scheme(
|
|
14700
|
-
|
|
14767
|
+
wi(h, u.table, [l, d], m),
|
|
14701
14768
|
`setup transform unique index ${n}`
|
|
14702
14769
|
);
|
|
14703
14770
|
}
|
|
@@ -14708,12 +14775,12 @@ CREATE TABLE IF NOT EXISTS "__interaqt_migration_operation_log" (
|
|
|
14708
14775
|
const r = new qe(i.map, i.aliasManager), a = Q(this.storage.db);
|
|
14709
14776
|
return t.flatMap(({ dataContext: n, state: o }) => {
|
|
14710
14777
|
const c = o.sourceRecordId, u = o.transformIndex;
|
|
14711
|
-
if (!(c instanceof
|
|
14778
|
+
if (!(c instanceof O) || !(u instanceof O) || c.unique === !1 || n.type !== "entity" && n.type !== "relation")
|
|
14712
14779
|
return [];
|
|
14713
14780
|
const l = n.id.name, d = r.getRecordInfo(l), [, h] = r.getTableAliasAndFieldName([l], c.key, !0), [, m] = r.getTableAliasAndFieldName([l], u.key, !0), f = `idx_transform_${this.hashIdentifier(`${d.table}_${h}_${m}`)}`;
|
|
14714
14781
|
return [{
|
|
14715
14782
|
kind: "create-constraint",
|
|
14716
|
-
sql:
|
|
14783
|
+
sql: wi(f, d.table, [h, m], a),
|
|
14717
14784
|
tableName: d.table,
|
|
14718
14785
|
logicalPath: `${l}.${c.key}.${u.key}`,
|
|
14719
14786
|
description: `migration setup transform unique index ${l}`
|
|
@@ -14724,7 +14791,7 @@ CREATE TABLE IF NOT EXISTS "__interaqt_migration_operation_log" (
|
|
|
14724
14791
|
await this.storage.destroy();
|
|
14725
14792
|
}
|
|
14726
14793
|
}
|
|
14727
|
-
class
|
|
14794
|
+
class ti {
|
|
14728
14795
|
constructor(e, t) {
|
|
14729
14796
|
this._type = "Action", this._options = t, this.uuid = q(t), this.name = e.name;
|
|
14730
14797
|
}
|
|
@@ -14746,13 +14813,13 @@ class ei {
|
|
|
14746
14813
|
};
|
|
14747
14814
|
}
|
|
14748
14815
|
static create(e, t) {
|
|
14749
|
-
if (t?.uuid ===
|
|
14816
|
+
if (t?.uuid === Ht) {
|
|
14750
14817
|
if (e.name !== "get")
|
|
14751
14818
|
throw new Error(`Action with the reserved GetAction uuid must be named "get", got "${e.name}". The GET_ACTION_UUID identity is reserved for the built-in query action.`);
|
|
14752
|
-
const a = this.instances.find((n) => n.uuid ===
|
|
14819
|
+
const a = this.instances.find((n) => n.uuid === Ht);
|
|
14753
14820
|
if (a) return a;
|
|
14754
14821
|
}
|
|
14755
|
-
const i = new
|
|
14822
|
+
const i = new ti(e, t);
|
|
14756
14823
|
if (this.instances.find((a) => a.uuid === i.uuid))
|
|
14757
14824
|
throw new Error(`duplicate uuid in options ${i.uuid}, Action`);
|
|
14758
14825
|
return this.instances.push(i), i;
|
|
@@ -14784,25 +14851,25 @@ class ei {
|
|
|
14784
14851
|
return this.create(M(t.public), { ...t.options, uuid: t.uuid });
|
|
14785
14852
|
}
|
|
14786
14853
|
}
|
|
14787
|
-
const
|
|
14788
|
-
function
|
|
14854
|
+
const Ht = "interaqt:builtin:action:get", Jo = ti.create({ name: "get" }, { uuid: Ht });
|
|
14855
|
+
function xi(s) {
|
|
14789
14856
|
if (!s) return;
|
|
14790
14857
|
if (s.raw.type === "atom")
|
|
14791
|
-
return
|
|
14858
|
+
return Gt.create({
|
|
14792
14859
|
type: "atom",
|
|
14793
14860
|
data: s.raw.data
|
|
14794
14861
|
});
|
|
14795
14862
|
const e = s.raw;
|
|
14796
|
-
return
|
|
14863
|
+
return Jt.create({
|
|
14797
14864
|
type: "expression",
|
|
14798
14865
|
operator: e.operator,
|
|
14799
|
-
left:
|
|
14800
|
-
right:
|
|
14866
|
+
left: xi(s.left),
|
|
14867
|
+
right: xi(s.right)
|
|
14801
14868
|
});
|
|
14802
14869
|
}
|
|
14803
|
-
class
|
|
14870
|
+
class gt {
|
|
14804
14871
|
constructor(e, t) {
|
|
14805
|
-
this._type = "Conditions", this._options = t, this.uuid = q(t), e.content && e.content instanceof k ? this.content =
|
|
14872
|
+
this._type = "Conditions", this._options = t, this.uuid = q(t), e.content && e.content instanceof k ? this.content = xi(e.content) : this.content = e.content;
|
|
14806
14873
|
}
|
|
14807
14874
|
static {
|
|
14808
14875
|
this.isKlass = !0;
|
|
@@ -14823,7 +14890,7 @@ class yt {
|
|
|
14823
14890
|
};
|
|
14824
14891
|
}
|
|
14825
14892
|
static create(e, t) {
|
|
14826
|
-
const i = new
|
|
14893
|
+
const i = new gt(e, t);
|
|
14827
14894
|
if (this.instances.find((a) => a.uuid === i.uuid))
|
|
14828
14895
|
throw new Error(`duplicate uuid in options ${i.uuid}, Conditions`);
|
|
14829
14896
|
return this.instances.push(i), i;
|
|
@@ -14854,7 +14921,7 @@ class yt {
|
|
|
14854
14921
|
return this.create(M(t.public), { ...t.options, uuid: t.uuid });
|
|
14855
14922
|
}
|
|
14856
14923
|
}
|
|
14857
|
-
const oo = "_Interaction_",
|
|
14924
|
+
const oo = "_Interaction_", Yi = j.create({
|
|
14858
14925
|
name: oo,
|
|
14859
14926
|
properties: [
|
|
14860
14927
|
x.create({ name: "interactionId", type: "string", collection: !1 }),
|
|
@@ -14865,7 +14932,7 @@ const oo = "_Interaction_", Xi = j.create({
|
|
|
14865
14932
|
x.create({ name: "context", type: "object", collection: !1 })
|
|
14866
14933
|
]
|
|
14867
14934
|
});
|
|
14868
|
-
class
|
|
14935
|
+
class Zi {
|
|
14869
14936
|
constructor(e, t) {
|
|
14870
14937
|
this._type = "Interaction", this._options = t, this.uuid = q(t), this.name = e.name, this.conditions = e.conditions, this.action = e.action, this.payload = e.payload, this.data = e.data, this.dataPolicy = e.dataPolicy;
|
|
14871
14938
|
}
|
|
@@ -14912,7 +14979,7 @@ class Yi {
|
|
|
14912
14979
|
};
|
|
14913
14980
|
}
|
|
14914
14981
|
static create(e, t) {
|
|
14915
|
-
if (
|
|
14982
|
+
if (gt.is(e.conditions) && !e.conditions.content)
|
|
14916
14983
|
throw new Error(`Interaction "${e.name}" declares conditions with a Conditions instance that has no content. Provide content (a Condition BoolExp), or omit the conditions field.`);
|
|
14917
14984
|
const i = e;
|
|
14918
14985
|
for (const o of ["userAttributives", "userRef"])
|
|
@@ -14920,15 +14987,15 @@ class Yi {
|
|
|
14920
14987
|
throw new Error(
|
|
14921
14988
|
`Interaction "${e.name}" declares "${o}", but the Attributive concept has been removed. Express the check as a Condition (conditions receives the full event args: user, payload, activityId).`
|
|
14922
14989
|
);
|
|
14923
|
-
const r = e.action?.uuid ===
|
|
14990
|
+
const r = e.action?.uuid === Ht;
|
|
14924
14991
|
if (!r && (e.data !== void 0 || e.dataPolicy !== void 0)) {
|
|
14925
14992
|
const o = e.action?.name === "get" ? ' An Action merely named "get" is not the query action.' : "";
|
|
14926
14993
|
throw new Error(`Interaction "${e.name}" declares data/dataPolicy but its action "${e.action?.name}" is not the built-in query action.${o} Import { GetAction } from 'interaqt' and declare action: GetAction, or remove data/dataPolicy.`);
|
|
14927
14994
|
}
|
|
14928
|
-
const a = new
|
|
14995
|
+
const a = new Zi(e, t);
|
|
14929
14996
|
if (this.instances.find((o) => o.uuid === a.uuid))
|
|
14930
14997
|
throw new Error(`duplicate uuid in options ${a.uuid}, Interaction`);
|
|
14931
|
-
return a.entity =
|
|
14998
|
+
return a.entity = Yi, a.guard = co(a), a.mapEventData = uo(a), r && (a.resolve = lo(a)), this.instances.push(a), a;
|
|
14932
14999
|
}
|
|
14933
15000
|
// CAUTION 必须走统一的 stringifyInstance 管线:嵌套的 Klass 实例(Action/Conditions/Payload/Entity 等)
|
|
14934
15001
|
// 会被编码为 `uuid::` 引用、函数编码为 `func::`。此前手写的 JSON.stringify 会把嵌套实例内联成
|
|
@@ -14987,7 +15054,7 @@ async function Ta(s, e, t) {
|
|
|
14987
15054
|
}
|
|
14988
15055
|
async function ho(s, e, t) {
|
|
14989
15056
|
if (!e.conditions) return;
|
|
14990
|
-
const i =
|
|
15057
|
+
const i = gt.is(e.conditions) ? new k(e.conditions.content) : k.atom(e.conditions), r = async (n) => {
|
|
14991
15058
|
if (!n || !n.content)
|
|
14992
15059
|
return `Condition '${n?.name ?? "(unnamed)"}' has no content to execute`;
|
|
14993
15060
|
let o;
|
|
@@ -15089,7 +15156,7 @@ async function fo(s, e, t) {
|
|
|
15089
15156
|
return s.system.storage.find(i, u, n, o);
|
|
15090
15157
|
}
|
|
15091
15158
|
}
|
|
15092
|
-
class
|
|
15159
|
+
class er {
|
|
15093
15160
|
constructor(e, t) {
|
|
15094
15161
|
this._type = "Activity", this._options = t, this.uuid = q(t), this.name = e.name, this.interactions = e.interactions || [], this.gateways = e.gateways || [], this.transfers = e.transfers || [], this.groups = e.groups || [], this.events = e.events || [];
|
|
15095
15162
|
}
|
|
@@ -15137,7 +15204,7 @@ class Zi {
|
|
|
15137
15204
|
};
|
|
15138
15205
|
}
|
|
15139
15206
|
static create(e, t) {
|
|
15140
|
-
const i = new
|
|
15207
|
+
const i = new er(e, t);
|
|
15141
15208
|
if (this.instances.find((a) => a.uuid === i.uuid))
|
|
15142
15209
|
throw new Error(`duplicate uuid in options ${i.uuid}, Activity`);
|
|
15143
15210
|
return this.instances.push(i), i;
|
|
@@ -15241,7 +15308,7 @@ class He {
|
|
|
15241
15308
|
return this.create(M(t.public), { ...t.options, uuid: t.uuid });
|
|
15242
15309
|
}
|
|
15243
15310
|
}
|
|
15244
|
-
class
|
|
15311
|
+
class tr {
|
|
15245
15312
|
constructor(e, t) {
|
|
15246
15313
|
this._type = "Transfer", this._options = t, this.uuid = q(t), this.name = e.name, this.source = e.source, this.target = e.target;
|
|
15247
15314
|
}
|
|
@@ -15274,7 +15341,7 @@ class er {
|
|
|
15274
15341
|
};
|
|
15275
15342
|
}
|
|
15276
15343
|
static create(e, t) {
|
|
15277
|
-
const i = new
|
|
15344
|
+
const i = new tr(e, t);
|
|
15278
15345
|
if (this.instances.find((a) => a.uuid === i.uuid))
|
|
15279
15346
|
throw new Error(`duplicate uuid in options ${i.uuid}, Transfer`);
|
|
15280
15347
|
return this.instances.push(i), i;
|
|
@@ -15322,7 +15389,7 @@ function Xo(s) {
|
|
|
15322
15389
|
function Yo(s) {
|
|
15323
15390
|
return null;
|
|
15324
15391
|
}
|
|
15325
|
-
class
|
|
15392
|
+
class ir {
|
|
15326
15393
|
constructor(e, t) {
|
|
15327
15394
|
this._type = "Condition", this._options = t, this.uuid = q(t), this.content = e.content, this.name = e.name;
|
|
15328
15395
|
}
|
|
@@ -15352,7 +15419,7 @@ class tr {
|
|
|
15352
15419
|
throw new Error(
|
|
15353
15420
|
`Condition${e.name ? ` "${e.name}"` : ""} requires a function "content" (got ${e.content === void 0 ? "undefined" : typeof e.content}). Provide the guard callback, e.g. Condition.create({ name, content: async function(event) { return !!event.user.isAdmin } }).`
|
|
15354
15421
|
);
|
|
15355
|
-
const i = new
|
|
15422
|
+
const i = new ir(e, t);
|
|
15356
15423
|
if (this.instances.find((a) => a.uuid === i.uuid))
|
|
15357
15424
|
throw new Error(`duplicate uuid in options ${i.uuid}, Condition`);
|
|
15358
15425
|
return this.instances.push(i), i;
|
|
@@ -15386,7 +15453,7 @@ class tr {
|
|
|
15386
15453
|
return this.create(M(t.public), { ...t.options, uuid: t.uuid });
|
|
15387
15454
|
}
|
|
15388
15455
|
}
|
|
15389
|
-
class
|
|
15456
|
+
class rr {
|
|
15390
15457
|
constructor(e, t) {
|
|
15391
15458
|
this._type = "DataPolicy", this._options = t, this.uuid = q(t), this.match = e.match, this.modifier = e.modifier, this.attributeQuery = e.attributeQuery;
|
|
15392
15459
|
}
|
|
@@ -15419,7 +15486,7 @@ class ir {
|
|
|
15419
15486
|
};
|
|
15420
15487
|
}
|
|
15421
15488
|
static create(e, t) {
|
|
15422
|
-
const i = new
|
|
15489
|
+
const i = new rr(e, t);
|
|
15423
15490
|
if (this.instances.find((a) => a.uuid === i.uuid))
|
|
15424
15491
|
throw new Error(`duplicate uuid in options ${i.uuid}, DataPolicy`);
|
|
15425
15492
|
return this.instances.push(i), i;
|
|
@@ -15444,7 +15511,7 @@ class ir {
|
|
|
15444
15511
|
return this.create(M(t.public), { ...t.options, uuid: t.uuid });
|
|
15445
15512
|
}
|
|
15446
15513
|
}
|
|
15447
|
-
class
|
|
15514
|
+
class at {
|
|
15448
15515
|
constructor(e, t) {
|
|
15449
15516
|
this._type = "Gateway", this._options = t, this.uuid = q(t), this.name = e.name;
|
|
15450
15517
|
}
|
|
@@ -15466,7 +15533,7 @@ class rt {
|
|
|
15466
15533
|
};
|
|
15467
15534
|
}
|
|
15468
15535
|
static create(e, t) {
|
|
15469
|
-
const i = new
|
|
15536
|
+
const i = new at(e, t);
|
|
15470
15537
|
if (this.instances.find((a) => a.uuid === i.uuid))
|
|
15471
15538
|
throw new Error(`duplicate uuid in options ${i.uuid}, Gateway`);
|
|
15472
15539
|
return this.instances.push(i), i;
|
|
@@ -15498,7 +15565,7 @@ class rt {
|
|
|
15498
15565
|
return this.create(M(t.public), { ...t.options, uuid: t.uuid });
|
|
15499
15566
|
}
|
|
15500
15567
|
}
|
|
15501
|
-
class
|
|
15568
|
+
class ar {
|
|
15502
15569
|
constructor(e, t) {
|
|
15503
15570
|
this._type = "Event", this._options = t, this.uuid = q(t), this.name = e.name;
|
|
15504
15571
|
}
|
|
@@ -15520,7 +15587,7 @@ class rr {
|
|
|
15520
15587
|
};
|
|
15521
15588
|
}
|
|
15522
15589
|
static create(e, t) {
|
|
15523
|
-
const i = new
|
|
15590
|
+
const i = new ar(e, t);
|
|
15524
15591
|
if (this.instances.find((a) => a.uuid === i.uuid))
|
|
15525
15592
|
throw new Error(`duplicate uuid in options ${i.uuid}, Event`);
|
|
15526
15593
|
return this.instances.push(i), i;
|
|
@@ -15552,7 +15619,7 @@ class rr {
|
|
|
15552
15619
|
return this.create(M(t.public), { ...t.options, uuid: t.uuid });
|
|
15553
15620
|
}
|
|
15554
15621
|
}
|
|
15555
|
-
class
|
|
15622
|
+
class Ze {
|
|
15556
15623
|
constructor(e, t) {
|
|
15557
15624
|
this._type = "PayloadItem", this._options = t, this.uuid = q(t), this.name = e.name, this.base = e.base, this.type = e.type, this.isRef = e.isRef ?? !1, this.required = e.required ?? !1, this.isCollection = e.isCollection ?? !1;
|
|
15558
15625
|
}
|
|
@@ -15597,9 +15664,20 @@ class ar {
|
|
|
15597
15664
|
}
|
|
15598
15665
|
};
|
|
15599
15666
|
}
|
|
15667
|
+
static {
|
|
15668
|
+
this.allowedTypes = ["string", "number", "boolean", "object", "Entity", "Relation"];
|
|
15669
|
+
}
|
|
15600
15670
|
static create(e, t) {
|
|
15601
15671
|
if (e.isRef && !e.base)
|
|
15602
15672
|
throw new Error(`PayloadItem '${e.name}' has isRef: true but no base. Declare base (the referenced Entity/Relation) so the guard can verify the referenced record exists.`);
|
|
15673
|
+
if (e.type !== void 0 && !Ze.allowedTypes.includes(e.type))
|
|
15674
|
+
throw new Error(
|
|
15675
|
+
`PayloadItem '${e.name}' declares unsupported type "${e.type}". Runtime validation exists only for: ${Ze.allowedTypes.join(", ")}. An unknown type is silently unvalidated — declare one of the supported types, or omit type and validate the content with a Condition on the interaction.`
|
|
15676
|
+
);
|
|
15677
|
+
if ((e.type === "Entity" || e.type === "Relation") && !e.base)
|
|
15678
|
+
throw new Error(
|
|
15679
|
+
`PayloadItem '${e.name}' declares type: '${e.type}' but no base. Concept validation needs the Entity/Relation instance — declare base, or use a primitive type ('string'/'number'/'boolean'/'object') for plain data.`
|
|
15680
|
+
);
|
|
15603
15681
|
if (e.base !== void 0 && !j.is(e.base) && !Y.is(e.base))
|
|
15604
15682
|
throw new Error(
|
|
15605
15683
|
`PayloadItem '${e.name}' has an invalid base: expected an Entity or Relation instance. To validate payload contents, use the interaction's conditions instead.`
|
|
@@ -15610,7 +15688,7 @@ class ar {
|
|
|
15610
15688
|
throw new Error(
|
|
15611
15689
|
`PayloadItem '${e.name}' declares "${n}", but the Attributive concept has been removed. Express the check as a Condition on the interaction (conditions receives the full event args: user, payload, activityId).`
|
|
15612
15690
|
);
|
|
15613
|
-
const r = new
|
|
15691
|
+
const r = new Ze(e, t);
|
|
15614
15692
|
if (this.instances.find((n) => n.uuid === r.uuid))
|
|
15615
15693
|
throw new Error(`duplicate uuid in options ${r.uuid}, PayloadItem`);
|
|
15616
15694
|
return this.instances.push(r), r;
|
|
@@ -15662,10 +15740,16 @@ class nr {
|
|
|
15662
15740
|
};
|
|
15663
15741
|
}
|
|
15664
15742
|
static create(e, t) {
|
|
15665
|
-
const i = new
|
|
15666
|
-
|
|
15667
|
-
|
|
15668
|
-
|
|
15743
|
+
const i = /* @__PURE__ */ new Set();
|
|
15744
|
+
for (const n of e.items || []) {
|
|
15745
|
+
if (i.has(n.name))
|
|
15746
|
+
throw new Error(`Payload declares duplicate item name "${n.name}". Each payload item name must be unique.`);
|
|
15747
|
+
i.add(n.name);
|
|
15748
|
+
}
|
|
15749
|
+
const r = new nr(e, t);
|
|
15750
|
+
if (this.instances.find((n) => n.uuid === r.uuid))
|
|
15751
|
+
throw new Error(`duplicate uuid in options ${r.uuid}, Payload`);
|
|
15752
|
+
return this.instances.push(r), r;
|
|
15669
15753
|
}
|
|
15670
15754
|
// CAUTION 必须走统一的 stringifyInstance 管线:items 编码为 uuid:: 引用,
|
|
15671
15755
|
// 否则 graph round-trip 后 items 变成与 PayloadItem 实例失去身份关联的裸对象。
|
|
@@ -15689,21 +15773,21 @@ class nr {
|
|
|
15689
15773
|
}
|
|
15690
15774
|
}
|
|
15691
15775
|
const yo = [
|
|
15692
|
-
Yi,
|
|
15693
15776
|
Zi,
|
|
15777
|
+
er,
|
|
15694
15778
|
// CAUTION Transfer/ActivityGroup 必须注册:
|
|
15695
15779
|
// Activity.stringify 把 transfers/groups 编码为 `uuid::` 引用,
|
|
15696
15780
|
// 未注册的类型在 createInstancesFromString(graph 级反序列化)中无法还原。
|
|
15697
15781
|
He,
|
|
15698
|
-
er,
|
|
15699
15782
|
tr,
|
|
15700
15783
|
ir,
|
|
15701
|
-
ei,
|
|
15702
|
-
rt,
|
|
15703
15784
|
rr,
|
|
15785
|
+
ti,
|
|
15786
|
+
at,
|
|
15704
15787
|
ar,
|
|
15788
|
+
Ze,
|
|
15705
15789
|
nr,
|
|
15706
|
-
|
|
15790
|
+
gt
|
|
15707
15791
|
];
|
|
15708
15792
|
yo.forEach((s) => {
|
|
15709
15793
|
s && s.displayName && Vr(s.displayName, s);
|
|
@@ -15813,7 +15897,7 @@ class ee {
|
|
|
15813
15897
|
this.parent.transferToNext(this.node.uuid);
|
|
15814
15898
|
}
|
|
15815
15899
|
}
|
|
15816
|
-
class
|
|
15900
|
+
class pi {
|
|
15817
15901
|
constructor(e, t) {
|
|
15818
15902
|
this.graph = t, this.root = Ke.create(e, this.graph);
|
|
15819
15903
|
}
|
|
@@ -15838,7 +15922,7 @@ class Ue {
|
|
|
15838
15922
|
this.activity = e, this.uuidToNode = /* @__PURE__ */ new Map(), this.rawToNode = /* @__PURE__ */ new Map(), this.graph = this.buildGraph(e);
|
|
15839
15923
|
}
|
|
15840
15924
|
buildGraph(e, t) {
|
|
15841
|
-
if (e.gateways?.length || e.transfers?.some((n) =>
|
|
15925
|
+
if (e.gateways?.length || e.transfers?.some((n) => at.is(n.source) || at.is(n.target)))
|
|
15842
15926
|
throw new be(`Activity "${e.name}" uses Gateway nodes, which are not supported by the activity runtime. Model branching with ActivityGroup (type 'any'/'every'/'race') instead.`, { activityName: e.name });
|
|
15843
15927
|
const i = {};
|
|
15844
15928
|
for (let n of e.interactions) {
|
|
@@ -15882,7 +15966,7 @@ class Ue {
|
|
|
15882
15966
|
this.ACTIVITY_RECORD = "_Activity_";
|
|
15883
15967
|
}
|
|
15884
15968
|
async create(e) {
|
|
15885
|
-
const t =
|
|
15969
|
+
const t = pi.createInitialState(this.graph.head);
|
|
15886
15970
|
return {
|
|
15887
15971
|
activityId: (await e.system.storage.create(Ue.ACTIVITY_RECORD, {
|
|
15888
15972
|
name: this.activity.name,
|
|
@@ -15937,7 +16021,7 @@ class Ue {
|
|
|
15937
16021
|
const r = await this.getState(e, t);
|
|
15938
16022
|
if (!r)
|
|
15939
16023
|
throw new Me(`activity ${t} not found for activity "${this.activity.name}"`, { activityName: this.activity.name, activityInstanceId: t });
|
|
15940
|
-
if (!new
|
|
16024
|
+
if (!new pi(r, this).isInteractionAvailable(i))
|
|
15941
16025
|
throw new Me(`interaction ${i} not available`, { activityName: this.activity.name, activityInstanceId: t, currentState: r });
|
|
15942
16026
|
}
|
|
15943
16027
|
// 与独立 interaction 的 guard 共用同一个 runner(runInteractionGuard),
|
|
@@ -15950,7 +16034,7 @@ class Ue {
|
|
|
15950
16034
|
const r = await this.getActivity(e, t);
|
|
15951
16035
|
if (!r)
|
|
15952
16036
|
throw new Me(`activity ${t} not found for activity "${this.activity.name}"`, { activityName: this.activity.name, activityInstanceId: t });
|
|
15953
|
-
const a = new
|
|
16037
|
+
const a = new pi(r.state, this);
|
|
15954
16038
|
a.completeInteraction(i);
|
|
15955
16039
|
const n = a.toJSON(), o = r.stateVersion ?? 0;
|
|
15956
16040
|
if (!await e.system.storage.atomic.compareAndSet(
|
|
@@ -15988,8 +16072,8 @@ class wo extends ee {
|
|
|
15988
16072
|
}
|
|
15989
16073
|
}
|
|
15990
16074
|
ee.GroupStateNodeType.set("race", wo);
|
|
15991
|
-
const
|
|
15992
|
-
name:
|
|
16075
|
+
const No = "_Activity_", xa = j.create({
|
|
16076
|
+
name: No,
|
|
15993
16077
|
properties: [
|
|
15994
16078
|
x.create({
|
|
15995
16079
|
name: "name",
|
|
@@ -16014,17 +16098,17 @@ const Ro = "_Activity_", xa = j.create({
|
|
|
16014
16098
|
collection: !1
|
|
16015
16099
|
})
|
|
16016
16100
|
]
|
|
16017
|
-
}),
|
|
16101
|
+
}), Ro = Y.create({
|
|
16018
16102
|
name: "activityInteraction",
|
|
16019
16103
|
source: xa,
|
|
16020
16104
|
sourceProperty: "interaction",
|
|
16021
|
-
target:
|
|
16105
|
+
target: Yi,
|
|
16022
16106
|
targetProperty: "activity",
|
|
16023
16107
|
type: "1:n"
|
|
16024
16108
|
});
|
|
16025
16109
|
class Zo {
|
|
16026
16110
|
constructor(e) {
|
|
16027
|
-
this.activityCalls = /* @__PURE__ */ new Map(), this.activityCallsByName = /* @__PURE__ */ new Map(), this.activityEventSources = [], this.requiredEntities = [], this.requiredRelations = [], e.length > 0 && (this.requiredEntities.push(xa,
|
|
16111
|
+
this.activityCalls = /* @__PURE__ */ new Map(), this.activityCallsByName = /* @__PURE__ */ new Map(), this.activityEventSources = [], this.requiredEntities = [], this.requiredRelations = [], e.length > 0 && (this.requiredEntities.push(xa, Yi), this.requiredRelations.push(Ro)), e.forEach((t) => {
|
|
16028
16112
|
const i = new Ue(t);
|
|
16029
16113
|
this.activityCalls.set(t.uuid, i), t.name && (_(!this.activityCallsByName.has(t.name), `activity name ${t.name} is duplicated`), this.activityCallsByName.set(t.name, i));
|
|
16030
16114
|
});
|
|
@@ -16117,75 +16201,75 @@ class ec extends ae {
|
|
|
16117
16201
|
}
|
|
16118
16202
|
}
|
|
16119
16203
|
export {
|
|
16120
|
-
|
|
16204
|
+
No as ACTIVITY_RECORD,
|
|
16121
16205
|
Ba as ALL_ATTR_SYMBOL,
|
|
16122
|
-
|
|
16123
|
-
|
|
16124
|
-
|
|
16206
|
+
li as ASYNC_TASK_RECORD,
|
|
16207
|
+
ti as Action,
|
|
16208
|
+
er as Activity,
|
|
16125
16209
|
Ue as ActivityCall,
|
|
16126
16210
|
be as ActivityError,
|
|
16127
16211
|
He as ActivityGroup,
|
|
16128
|
-
|
|
16212
|
+
Ro as ActivityInteractionRelation,
|
|
16129
16213
|
Zo as ActivityManager,
|
|
16130
16214
|
xa as ActivityStateEntity,
|
|
16131
16215
|
Me as ActivityStateError,
|
|
16132
16216
|
nn as AliasManager,
|
|
16133
16217
|
ua as AmbiguousComputationSignatureError,
|
|
16134
|
-
|
|
16218
|
+
ht as Any,
|
|
16135
16219
|
Cn as AnyHandles,
|
|
16136
|
-
|
|
16220
|
+
Ui as AsyncMigrationComputationError,
|
|
16137
16221
|
ke as AttributeInfo,
|
|
16138
16222
|
K as AttributeQuery,
|
|
16139
|
-
|
|
16223
|
+
lt as Average,
|
|
16140
16224
|
zn as AverageHandles,
|
|
16141
|
-
|
|
16225
|
+
Gt as BoolAtomData,
|
|
16142
16226
|
k as BoolExp,
|
|
16143
|
-
|
|
16227
|
+
Jt as BoolExpressionData,
|
|
16144
16228
|
Se as ComputationDataDepError,
|
|
16145
16229
|
V as ComputationError,
|
|
16146
16230
|
z as ComputationProtocolError,
|
|
16147
16231
|
U as ComputationResult,
|
|
16148
|
-
|
|
16232
|
+
ft as ComputationResultAsync,
|
|
16149
16233
|
Gr as ComputationResultFullRecompute,
|
|
16150
|
-
|
|
16234
|
+
Xt as ComputationResultResolved,
|
|
16151
16235
|
Oe as ComputationResultSkip,
|
|
16152
|
-
|
|
16153
|
-
|
|
16154
|
-
|
|
16155
|
-
|
|
16236
|
+
ci as ComputationStateError,
|
|
16237
|
+
ir as Condition,
|
|
16238
|
+
Ni as ConditionError,
|
|
16239
|
+
gt as Conditions,
|
|
16156
16240
|
Ce as ConstraintSetupError,
|
|
16157
16241
|
Hr as ConstraintViolationError,
|
|
16158
16242
|
Wo as Controller,
|
|
16159
|
-
|
|
16243
|
+
ct as Count,
|
|
16160
16244
|
In as CountHandles,
|
|
16161
16245
|
ja as CreationExecutor,
|
|
16162
|
-
|
|
16246
|
+
Wt as Custom,
|
|
16163
16247
|
Zn as CustomHandles,
|
|
16164
|
-
|
|
16248
|
+
Ji as DBConsoleLogger,
|
|
16165
16249
|
ao as DBLogLevel,
|
|
16166
16250
|
le as DBSetup,
|
|
16167
16251
|
fr as DEFAULT_SCHEMA_DIALECT,
|
|
16168
16252
|
Vo as DELETED_STATE,
|
|
16169
16253
|
Z as DICTIONARY_RECORD,
|
|
16170
|
-
|
|
16254
|
+
rr as DataPolicy,
|
|
16171
16255
|
he as DestructiveComputedOutputError,
|
|
16172
|
-
|
|
16256
|
+
Pi as Dictionary,
|
|
16173
16257
|
gr as DictionaryEntity,
|
|
16174
16258
|
j as Entity,
|
|
16175
16259
|
Jn as EntityCustomHandle,
|
|
16176
|
-
|
|
16260
|
+
bi as EntityQueryHandle,
|
|
16177
16261
|
qe as EntityToTableMap,
|
|
16178
16262
|
Fi as Equation,
|
|
16179
16263
|
ve as ErrorCategory,
|
|
16180
16264
|
te as ErrorSeverity,
|
|
16181
|
-
|
|
16182
|
-
|
|
16183
|
-
|
|
16265
|
+
ar as Event,
|
|
16266
|
+
Oi as EventSource,
|
|
16267
|
+
dt as Every,
|
|
16184
16268
|
$n as EveryHandles,
|
|
16185
16269
|
J as Expression,
|
|
16186
16270
|
ae as FrameworkError,
|
|
16187
|
-
|
|
16188
|
-
|
|
16271
|
+
Ht as GET_ACTION_UUID,
|
|
16272
|
+
at as Gateway,
|
|
16189
16273
|
Jo as GetAction,
|
|
16190
16274
|
kn as GlobalAnyHandle,
|
|
16191
16275
|
Kn as GlobalAverageHandle,
|
|
@@ -16196,36 +16280,36 @@ export {
|
|
|
16196
16280
|
_n as GlobalRealTimeComputation,
|
|
16197
16281
|
yn as GlobalStateMachineHandle,
|
|
16198
16282
|
Qn as GlobalSumHandle,
|
|
16199
|
-
|
|
16200
|
-
|
|
16283
|
+
Nn as GlobalWeightedSummationHandle,
|
|
16284
|
+
Dt as HARD_DELETION_PROPERTY_NAME,
|
|
16201
16285
|
Ko as HardDeletionProperty,
|
|
16202
16286
|
Ie as ID_ATTR,
|
|
16203
16287
|
oo as INTERACTION_RECORD,
|
|
16204
|
-
|
|
16205
|
-
|
|
16206
|
-
|
|
16288
|
+
_t as Inequality,
|
|
16289
|
+
Zi as Interaction,
|
|
16290
|
+
Yi as InteractionEventEntity,
|
|
16207
16291
|
ec as InteractionExecutionError,
|
|
16208
16292
|
ge as InteractionGuardError,
|
|
16209
|
-
|
|
16293
|
+
Ot as KlassByName,
|
|
16210
16294
|
v as LINK_SYMBOL,
|
|
16211
16295
|
Ft as LinkInfo,
|
|
16212
|
-
|
|
16213
|
-
|
|
16296
|
+
_i as MIGRATION_MANIFEST_CONCEPT,
|
|
16297
|
+
Bi as MIGRATION_MANIFEST_CURRENT_KEY,
|
|
16214
16298
|
E as MatchExp,
|
|
16215
|
-
|
|
16299
|
+
Mt as MigrationBaselineError,
|
|
16216
16300
|
C as MigrationError,
|
|
16217
16301
|
Ur as Modifier,
|
|
16218
16302
|
Go as MonoSystem,
|
|
16219
|
-
|
|
16220
|
-
|
|
16303
|
+
Fo as NON_DELETED_STATE,
|
|
16304
|
+
Lo as NON_EXIST_STATE,
|
|
16221
16305
|
Pn as NestedDispatchError,
|
|
16222
16306
|
ie as NewRecordData,
|
|
16223
|
-
|
|
16307
|
+
Mi as NonNullConstraint,
|
|
16224
16308
|
Io as PHASE_AFTER_ALL,
|
|
16225
16309
|
Ao as PHASE_BEFORE_ALL,
|
|
16226
|
-
|
|
16310
|
+
ui as PHASE_NORMAL,
|
|
16227
16311
|
nr as Payload,
|
|
16228
|
-
|
|
16312
|
+
Ze as PayloadItem,
|
|
16229
16313
|
Qo as PhysicalLayoutChangeError,
|
|
16230
16314
|
x as Property,
|
|
16231
16315
|
Tn as PropertyAnyHandle,
|
|
@@ -16237,50 +16321,50 @@ export {
|
|
|
16237
16321
|
ns as PropertyScopedSequenceHandle,
|
|
16238
16322
|
gn as PropertyStateMachineHandle,
|
|
16239
16323
|
jn as PropertySumHandle,
|
|
16240
|
-
|
|
16241
|
-
|
|
16324
|
+
Ii as PropertyTypes,
|
|
16325
|
+
Rn as PropertyWeightedSummationHandle,
|
|
16242
16326
|
Ga as QueryExecutor,
|
|
16243
|
-
|
|
16327
|
+
Lt as ROOT_LABEL,
|
|
16244
16328
|
Pe as ROW_ID_ATTR,
|
|
16245
|
-
|
|
16329
|
+
pt as RealTime,
|
|
16246
16330
|
Un as RealTimeHandles,
|
|
16247
|
-
|
|
16248
|
-
|
|
16331
|
+
O as RecordBoundState,
|
|
16332
|
+
tt as RecordInfo,
|
|
16249
16333
|
ka as RecordMutationSideEffect,
|
|
16250
16334
|
G as RecordQuery,
|
|
16251
16335
|
Ya as RecordQueryAgent,
|
|
16252
16336
|
za as RecordQueryRef,
|
|
16253
16337
|
oe as RecordQueryTree,
|
|
16254
|
-
|
|
16338
|
+
Fn as RecordsTransformHandle,
|
|
16255
16339
|
je as RecursiveContext,
|
|
16256
|
-
|
|
16340
|
+
fi as RefContainer,
|
|
16257
16341
|
Y as Relation,
|
|
16258
16342
|
Xn as RelationCustomHandle,
|
|
16259
16343
|
de as RequireSerializableRetry,
|
|
16260
16344
|
Wa as SQLBuilder,
|
|
16261
16345
|
Je as SYSTEM_RECORD,
|
|
16262
|
-
|
|
16263
|
-
|
|
16346
|
+
Bt as Scheduler,
|
|
16347
|
+
et as ScopedSequence,
|
|
16264
16348
|
ss as ScopedSequenceHandles,
|
|
16265
|
-
|
|
16266
|
-
|
|
16349
|
+
Di as SideEffect,
|
|
16350
|
+
st as StateMachine,
|
|
16267
16351
|
bn as StateMachineHandles,
|
|
16268
16352
|
We as StateNode,
|
|
16269
|
-
|
|
16270
|
-
|
|
16353
|
+
qi as StateTransfer,
|
|
16354
|
+
ut as Summation,
|
|
16271
16355
|
Hn as SummationHandles,
|
|
16272
|
-
|
|
16356
|
+
Xi as SystemConsoleLogger,
|
|
16273
16357
|
yr as SystemEntity,
|
|
16274
16358
|
no as SystemLogLevel,
|
|
16275
|
-
|
|
16276
|
-
|
|
16277
|
-
|
|
16278
|
-
|
|
16359
|
+
At as TransactionCapabilityError,
|
|
16360
|
+
It as TransactionRetryExhaustedError,
|
|
16361
|
+
tr as Transfer,
|
|
16362
|
+
zt as Transform,
|
|
16279
16363
|
Vn as TransformHandles,
|
|
16280
16364
|
Ho as USER_ENTITY,
|
|
16281
|
-
|
|
16282
|
-
|
|
16283
|
-
|
|
16365
|
+
Kt as UniqueConstraint,
|
|
16366
|
+
it as UnrebuildableComputationError,
|
|
16367
|
+
ot as WeightedSummation,
|
|
16284
16368
|
vn as WeightedSummationHandles,
|
|
16285
16369
|
Is as addComputationTakeoverReview,
|
|
16286
16370
|
ks as addEmptyFactRecordRemovalReview,
|
|
@@ -16294,7 +16378,7 @@ export {
|
|
|
16294
16378
|
Ea as assertDestructiveScopeAllowed,
|
|
16295
16379
|
$r as assertManifestGeneratorCurrent,
|
|
16296
16380
|
Cs as assertScopedSequenceNoSeedDecisions,
|
|
16297
|
-
|
|
16381
|
+
Vi as asyncEffectsContext,
|
|
16298
16382
|
ls as asyncInteractionContext,
|
|
16299
16383
|
zs as backfillNewFactPropertyDefaults,
|
|
16300
16384
|
xr as buildAffectedRebuildPlan,
|
|
@@ -16304,20 +16388,20 @@ export {
|
|
|
16304
16388
|
mo as checkPayload,
|
|
16305
16389
|
ko as clearAllInstances,
|
|
16306
16390
|
we as collectErrorChain,
|
|
16307
|
-
|
|
16391
|
+
yt as computationManifestId,
|
|
16308
16392
|
As as createEmptyFactRecordRemovalOperations,
|
|
16309
16393
|
Pa as createInstances,
|
|
16310
16394
|
Co as createInstancesFromString,
|
|
16311
|
-
|
|
16395
|
+
Et as createMigrationManifest,
|
|
16312
16396
|
kr as createMigrationReadHandle,
|
|
16313
16397
|
cn as createNonNullConstraintStatement,
|
|
16314
16398
|
Js as createPlanBlockingMessages,
|
|
16315
16399
|
on as createUniqueConstraintStatement,
|
|
16316
|
-
|
|
16317
|
-
|
|
16400
|
+
wi as createUniqueIndexSQL,
|
|
16401
|
+
L as dataContextPath,
|
|
16318
16402
|
zo as dbConsoleLogger,
|
|
16319
16403
|
M as decodeFunctionValues,
|
|
16320
|
-
|
|
16404
|
+
bt as deepClone,
|
|
16321
16405
|
Jr as defaultDataBasedIncrementalPlan,
|
|
16322
16406
|
jr as defaultEncodeLiteral,
|
|
16323
16407
|
X as describeDataContext,
|
|
@@ -16330,42 +16414,42 @@ export {
|
|
|
16330
16414
|
Yo as findRootActivity,
|
|
16331
16415
|
Ca as forEachInteraction,
|
|
16332
16416
|
q as generateUUID,
|
|
16333
|
-
|
|
16417
|
+
Na as getApprovedEmptyFactRecordRemovals,
|
|
16334
16418
|
jo as getChangedComputations,
|
|
16335
16419
|
Ds as getChangedComputationsFromApprovedDiff,
|
|
16336
16420
|
us as getCurrentEffects,
|
|
16337
|
-
|
|
16421
|
+
Ci as getDestructiveDeletionScope,
|
|
16338
16422
|
Oa as getEffectiveScopedSequenceInitializerMatch,
|
|
16339
|
-
|
|
16423
|
+
zi as getFilteredRecordChanges,
|
|
16340
16424
|
Xo as getInteractions,
|
|
16341
16425
|
Ws as getNewFactPropertyBackfills,
|
|
16342
16426
|
Pr as getNewFilteredDataContexts,
|
|
16343
16427
|
Qs as getRecomputeBlockingChanges,
|
|
16344
16428
|
Q as getSchemaDialect,
|
|
16345
|
-
|
|
16429
|
+
Ls as getScopedSequenceNoSeedOperations,
|
|
16346
16430
|
Os as getScopedSequenceSeedOperations,
|
|
16347
16431
|
Ar as getStorageBlockingChanges,
|
|
16348
16432
|
_o as hasErrorCode,
|
|
16349
16433
|
ds as hashMigrationDiff,
|
|
16350
16434
|
$o as indexBy,
|
|
16351
|
-
|
|
16352
|
-
|
|
16435
|
+
Fr as isObject,
|
|
16436
|
+
nt as isPlainObject,
|
|
16353
16437
|
Mn as isRequireSerializableRetry,
|
|
16354
16438
|
Dn as isRetryableTransactionError,
|
|
16355
16439
|
Uo as isTransactionCapabilityError,
|
|
16356
16440
|
Bo as isTransactionRetryExhaustedError,
|
|
16357
16441
|
Mo as mapObject,
|
|
16358
|
-
|
|
16359
|
-
|
|
16442
|
+
xt as normalizeDatabaseError,
|
|
16443
|
+
Re as normalizeScopedSequenceMatchExpression,
|
|
16360
16444
|
sn as predicateSQLForOperator,
|
|
16361
16445
|
ce as quoteIdentifier,
|
|
16362
|
-
|
|
16446
|
+
Nt as quoteLiteral,
|
|
16363
16447
|
Mr as readMigrationManifest,
|
|
16364
16448
|
Zs as recomputeChangedComputations,
|
|
16365
16449
|
to as recomputeFilteredMemberships,
|
|
16366
16450
|
Vr as registerKlass,
|
|
16367
16451
|
Ta as runInteractionGuard,
|
|
16368
|
-
|
|
16452
|
+
Li as runWithTransactionRetry,
|
|
16369
16453
|
Ks as seedScopedSequenceInitializers,
|
|
16370
16454
|
Do as someAsync,
|
|
16371
16455
|
xo as sqliteEncodeLiteral,
|
|
@@ -16375,6 +16459,6 @@ export {
|
|
|
16375
16459
|
B as stringifyInstance,
|
|
16376
16460
|
so as systemConsoleLogger,
|
|
16377
16461
|
qs as validateApprovedDiff,
|
|
16378
|
-
|
|
16462
|
+
hi as writeMigrationManifest
|
|
16379
16463
|
};
|
|
16380
16464
|
//# sourceMappingURL=index.js.map
|