interaqt 0.8.8 → 0.8.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3680,7 +3680,7 @@ class L {
3680
3680
  }), this.parentLinkQueryTree && (t[f] = this.parentLinkQueryTree.getData()), t;
3681
3681
  }
3682
3682
  }
3683
- const f = "&", Oe = "*";
3683
+ const f = "&", Fe = "*";
3684
3684
  class x {
3685
3685
  constructor(t, e, i = [], r, s, a) {
3686
3686
  this.recordName = t, this.map = e, this.data = i, this.parentRecord = r, this.attributeName = s, this.shouldQueryParentLinkData = a, this.relatedRecords = [], this.xToManyRecords = [], this.xToOneRecords = [], this.valueAttributes = [], this.id = Math.random();
@@ -3693,7 +3693,7 @@ class x {
3693
3693
  this.parentLinkRecordQuery = C.create(y.linkName, this.map, d, void 0);
3694
3694
  return;
3695
3695
  }
3696
- if (l === Oe) {
3696
+ if (l === Fe) {
3697
3697
  o = new Set(this.map.getRecordInfo(this.recordName).valueAttributes.map((y) => y.attributeName));
3698
3698
  return;
3699
3699
  }
@@ -3823,7 +3823,7 @@ class x {
3823
3823
  return this.parentLinkRecordQuery ? new x(this.recordName, this.map, this.data, this.parentRecord, this.attributeName, !0) : this;
3824
3824
  }
3825
3825
  }
3826
- function Fe(u) {
3826
+ function Oe(u) {
3827
3827
  const t = [];
3828
3828
  return u.forEach((e) => t.push(...Array.isArray(e) ? e : [e])), t;
3829
3829
  }
@@ -3833,7 +3833,7 @@ class V {
3833
3833
  const s = this.map.getRecordInfo(e);
3834
3834
  this.recordName = s.resolvedBaseRecordName;
3835
3835
  const [a, o, n] = this.map.groupAttributes(this.recordName, i ? Object.keys(i) : []);
3836
- this.relatedEntitiesData = Fe(o.map(
3836
+ this.relatedEntitiesData = Oe(o.map(
3837
3837
  (l) => Array.isArray(i[l.attributeName]) ? i[l.attributeName].map((d) => new V(this.map, l.recordName, d, l)) : new V(this.map, l.recordName, i[l.attributeName], l)
3838
3838
  )), this.valueAttributes = a, this.entityIdAttributes = n;
3839
3839
  const c = this.map.getRecordInfo(this.recordName);
@@ -6574,11 +6574,20 @@ class oi {
6574
6574
  for (let e of t)
6575
6575
  this.renameTableWithJoinedEntities(e);
6576
6576
  Object.entries(this.map.records).forEach(([e, i]) => {
6577
- !i.isFilteredEntity && !i.isFilteredRelation && (i.table = this.recordToTableMap.get(e)), Object.entries(i.attributes).forEach(([r, s]) => {
6578
- if (s.isRecord) return;
6579
- const a = s;
6580
- a.field = this.generateShortFieldName(`${e}_${r}`), a.fieldType = this.database.mapToDBFieldType(a.type, a.collection);
6577
+ !i.isFilteredEntity && !i.isFilteredRelation && (i.table = this.recordToTableMap.get(e)), !i.isFilteredEntity && !i.isFilteredRelation && Object.entries(i.attributes).forEach(([s, a]) => {
6578
+ if (a.isRecord) return;
6579
+ const o = a;
6580
+ o.field = this.generateShortFieldName(`${e}_${s}`), o.fieldType = this.database.mapToDBFieldType(o.type, o.collection);
6581
6581
  });
6582
+ }), Object.entries(this.map.records).forEach(([e, i]) => {
6583
+ if ((i.isFilteredEntity || i.isFilteredRelation) && i.resolvedBaseRecordName) {
6584
+ const s = this.map.records[i.resolvedBaseRecordName];
6585
+ s && Object.entries(i.attributes).forEach(([a, o]) => {
6586
+ if (o.isRecord) return;
6587
+ const n = o, c = s.attributes[a];
6588
+ c && c.field && (n.field = c.field, n.fieldType = c.fieldType);
6589
+ });
6590
+ }
6582
6591
  }), Object.entries(this.map.links).forEach(([e, i]) => {
6583
6592
  i.isSourceRelation || (i.table = this.recordToTableMap.get(e));
6584
6593
  }), Object.entries(this.map.records).forEach(([e, i]) => {
@@ -8249,8 +8258,8 @@ class $i {
8249
8258
  return a;
8250
8259
  }
8251
8260
  }
8252
- const Oi = [Pi, $i];
8253
- class Fi {
8261
+ const Fi = [Pi, $i];
8262
+ class Oi {
8254
8263
  constructor(t, e, i) {
8255
8264
  if (this.controller = t, this.args = e, this.dataContext = i, this.useLastValue = !0, this.dataDeps = {}, this.record = this.args.record, !this.args.attributeQuery || this.args.attributeQuery.length === 0)
8256
8265
  throw new Error("Average computation requires attributeQuery with at least one field");
@@ -8407,7 +8416,7 @@ class Di {
8407
8416
  return await this.state.count.set(e.record, a), a > 0 ? o / a : 0;
8408
8417
  }
8409
8418
  }
8410
- const Qi = [Fi, Di];
8419
+ const Qi = [Oi, Di];
8411
8420
  class St {
8412
8421
  constructor(t, e, i) {
8413
8422
  this.controller = t, this.args = e, this.dataContext = i, this.state = {}, this.dataDeps = {}, this.useLastValue = e.useLastValue !== void 0 ? e.useLastValue : !0, e.dataDeps && (this.dataDeps = e.dataDeps), e.compute && (this.computeCallback = e.compute, this.compute = async (...r) => {
@@ -8632,7 +8641,7 @@ Stack trace:`, r.stack.split(`
8632
8641
  return null;
8633
8642
  }
8634
8643
  }
8635
- var F = /* @__PURE__ */ ((u) => (u.LOW = "low", u.MEDIUM = "medium", u.HIGH = "high", u.CRITICAL = "critical", u))(F || {}), j = /* @__PURE__ */ ((u) => (u.VALIDATION = "validation", u.PERMISSION = "permission", u.COMPUTATION = "computation", u.STORAGE = "storage", u.INTERACTION = "interaction", u.ACTIVITY = "activity", u.SYSTEM = "system", u.CONFIGURATION = "configuration", u))(j || {});
8644
+ var O = /* @__PURE__ */ ((u) => (u.LOW = "low", u.MEDIUM = "medium", u.HIGH = "high", u.CRITICAL = "critical", u))(O || {}), j = /* @__PURE__ */ ((u) => (u.VALIDATION = "validation", u.PERMISSION = "permission", u.COMPUTATION = "computation", u.STORAGE = "storage", u.INTERACTION = "interaction", u.ACTIVITY = "activity", u.SYSTEM = "system", u.CONFIGURATION = "configuration", u))(j || {});
8636
8645
  class Z extends W {
8637
8646
  constructor(t, e = {}) {
8638
8647
  super(t, {
@@ -8646,7 +8655,7 @@ class Z extends W {
8646
8655
  ...e.context
8647
8656
  },
8648
8657
  causedBy: e.causedBy
8649
- }), this.interactionName = e.interactionName, this.userId = e.userId, this.payload = e.payload, this.executionPhase = e.executionPhase, this.severity = e.severity || F.HIGH;
8658
+ }), this.interactionName = e.interactionName, this.userId = e.userId, this.payload = e.payload, this.executionPhase = e.executionPhase, this.severity = e.severity || O.HIGH;
8650
8659
  }
8651
8660
  }
8652
8661
  class se extends W {
@@ -8662,7 +8671,7 @@ class se extends W {
8662
8671
  ...e.context
8663
8672
  },
8664
8673
  causedBy: e.causedBy
8665
- }), this.activityName = e.activityName, this.activityId = e.activityId, this.activityInstanceId = e.activityInstanceId, this.currentState = e.currentState, this.severity = e.severity || F.MEDIUM;
8674
+ }), this.activityName = e.activityName, this.activityId = e.activityId, this.activityInstanceId = e.activityInstanceId, this.currentState = e.currentState, this.severity = e.severity || O.MEDIUM;
8666
8675
  }
8667
8676
  }
8668
8677
  class Q extends W {
@@ -8678,14 +8687,14 @@ class Q extends W {
8678
8687
  ...e.context
8679
8688
  },
8680
8689
  causedBy: e.causedBy
8681
- }), this.handleName = e.handleName, this.computationName = e.computationName, this.dataContext = e.dataContext, this.computationPhase = e.computationPhase, this.severity = e.severity || F.MEDIUM;
8690
+ }), this.handleName = e.handleName, this.computationName = e.computationName, this.dataContext = e.dataContext, this.computationPhase = e.computationPhase, this.severity = e.severity || O.MEDIUM;
8682
8691
  }
8683
8692
  }
8684
8693
  class ae extends Q {
8685
8694
  constructor(t, e = {}) {
8686
8695
  super(t, {
8687
8696
  ...e,
8688
- severity: F.HIGH,
8697
+ severity: O.HIGH,
8689
8698
  context: {
8690
8699
  errorType: "ComputationStateError",
8691
8700
  stateKey: e.stateKey,
@@ -8700,7 +8709,7 @@ class H extends Q {
8700
8709
  constructor(t, e = {}) {
8701
8710
  super(t, {
8702
8711
  ...e,
8703
- severity: F.MEDIUM,
8712
+ severity: O.MEDIUM,
8704
8713
  context: {
8705
8714
  errorType: "ComputationDataDepError",
8706
8715
  depName: e.depName,
@@ -8722,7 +8731,7 @@ class xt extends W {
8722
8731
  ...e.context
8723
8732
  },
8724
8733
  causedBy: e.causedBy
8725
- }), this.schedulingPhase = e.schedulingPhase, this.failedComputations = e.failedComputations, this.severity = F.HIGH;
8734
+ }), this.schedulingPhase = e.schedulingPhase, this.failedComputations = e.failedComputations, this.severity = O.HIGH;
8726
8735
  }
8727
8736
  }
8728
8737
  class Wi extends W {
@@ -8738,10 +8747,10 @@ class Wi extends W {
8738
8747
  ...e.context
8739
8748
  },
8740
8749
  causedBy: e.causedBy
8741
- }), this.sideEffectName = e.sideEffectName, this.recordName = e.recordName, this.mutationType = e.mutationType, this.severity = F.MEDIUM;
8750
+ }), this.sideEffectName = e.sideEffectName, this.recordName = e.recordName, this.mutationType = e.mutationType, this.severity = O.MEDIUM;
8742
8751
  }
8743
8752
  }
8744
- class O extends W {
8753
+ class F extends W {
8745
8754
  constructor(t, e) {
8746
8755
  super(t, {
8747
8756
  errorType: e.context?.errorType || "ConditionError",
@@ -8754,16 +8763,16 @@ class O extends W {
8754
8763
  ...e.context
8755
8764
  },
8756
8765
  causedBy: e.causedBy
8757
- }), this.checkType = e.checkType, this.fieldName = e.fieldName, this.payload = e.payload, this.evaluationError = e.evaluationError, this.error = e.evaluationError, this.type = e.type || t, this.severity = e.severity || F.HIGH;
8766
+ }), this.checkType = e.checkType, this.fieldName = e.fieldName, this.payload = e.payload, this.evaluationError = e.evaluationError, this.error = e.evaluationError, this.type = e.type || t, this.severity = e.severity || O.HIGH;
8758
8767
  }
8759
8768
  /**
8760
8769
  * Helper factory methods for common condition error scenarios
8761
8770
  */
8762
8771
  static userCheckFailed(t, e) {
8763
- return new O("User check failed", {
8772
+ return new F("User check failed", {
8764
8773
  checkType: "user",
8765
8774
  evaluationError: t,
8766
- severity: F.HIGH,
8775
+ severity: O.HIGH,
8767
8776
  context: e,
8768
8777
  type: "check user failed"
8769
8778
  // For backward compatibility
@@ -8771,21 +8780,21 @@ class O extends W {
8771
8780
  }
8772
8781
  static payloadValidationFailed(t, e, i, r) {
8773
8782
  const s = `${t} ${e}`;
8774
- return new O(`Payload validation failed for field '${t}': ${e}`, {
8783
+ return new F(`Payload validation failed for field '${t}': ${e}`, {
8775
8784
  checkType: "payload",
8776
8785
  fieldName: t,
8777
8786
  payload: i,
8778
8787
  evaluationError: r,
8779
- severity: F.MEDIUM,
8788
+ severity: O.MEDIUM,
8780
8789
  type: s
8781
8790
  // For backward compatibility
8782
8791
  });
8783
8792
  }
8784
8793
  static conditionCheckFailed(t, e) {
8785
- return new O(`Condition check failed: ${t.data.name}`, {
8794
+ return new F(`Condition check failed: ${t.data.name}`, {
8786
8795
  checkType: "condition",
8787
8796
  evaluationError: t,
8788
- severity: F.HIGH,
8797
+ severity: O.HIGH,
8789
8798
  context: e,
8790
8799
  type: "condition check failed"
8791
8800
  // For backward compatibility
@@ -8793,22 +8802,22 @@ class O extends W {
8793
8802
  }
8794
8803
  static attributiveCheckFailed(t, e, i, r) {
8795
8804
  const s = `${t} ${e}`;
8796
- return new O(`Attributive check failed for field '${t}': ${e}`, {
8805
+ return new F(`Attributive check failed for field '${t}': ${e}`, {
8797
8806
  checkType: "attributive",
8798
8807
  fieldName: t,
8799
8808
  payload: i,
8800
8809
  evaluationError: r,
8801
- severity: F.MEDIUM,
8810
+ severity: O.MEDIUM,
8802
8811
  type: s
8803
8812
  // For backward compatibility
8804
8813
  });
8805
8814
  }
8806
8815
  static conceptCheckFailed(t, e) {
8807
- return new O(`Concept check failed for field '${t}'`, {
8816
+ return new F(`Concept check failed for field '${t}'`, {
8808
8817
  checkType: "concept",
8809
8818
  fieldName: t,
8810
8819
  evaluationError: e,
8811
- severity: F.MEDIUM,
8820
+ severity: O.MEDIUM,
8812
8821
  type: `${t} check concept failed`
8813
8822
  // For backward compatibility
8814
8823
  });
@@ -9400,7 +9409,7 @@ class we {
9400
9409
  this.interaction.userAttributives
9401
9410
  ), a = (o) => o.isRef ? i(o, t.user, e) : this.checkAttributive(o, t, t.user);
9402
9411
  if (r = await this.checkAttributives(s, a, []), r === !0) return r;
9403
- throw O.userCheckFailed(r);
9412
+ throw F.userCheckFailed(r);
9404
9413
  }
9405
9414
  // 用来check attributive 形容的后面的 target 到底是不是那个概念的实例。
9406
9415
  async checkConcept(t, e, i, r = []) {
@@ -9448,25 +9457,25 @@ class we {
9448
9457
  throw new Error(`${s} in payload is not defined in interaction ${this.interaction.name}`);
9449
9458
  for (let s of i) {
9450
9459
  if (s.required && !(s.name in e))
9451
- throw O.payloadValidationFailed(s.name, "missing", e);
9460
+ throw F.payloadValidationFailed(s.name, "missing", e);
9452
9461
  const a = e[s.name];
9453
9462
  if (a === void 0) return;
9454
9463
  if (s.isCollection && !Array.isArray(a))
9455
- throw O.payloadValidationFailed(s.name, "data is not array", a);
9464
+ throw F.payloadValidationFailed(s.name, "data is not array", a);
9456
9465
  if (s.isCollection) {
9457
9466
  if (s.isRef && !a.every((o) => !!o.id))
9458
- throw O.payloadValidationFailed(s.name, "data not every is ref", a);
9467
+ throw F.payloadValidationFailed(s.name, "data not every is ref", a);
9459
9468
  } else if (s.isRef && !a.id)
9460
- throw O.payloadValidationFailed(s.name, "data is not a ref", a);
9469
+ throw F.payloadValidationFailed(s.name, "data is not a ref", a);
9461
9470
  if (s.base)
9462
9471
  if (s.isCollection) {
9463
9472
  const o = await di(a, (n) => this.checkConcept(n, s.base));
9464
9473
  if (o !== !0)
9465
- throw O.conceptCheckFailed(s.name, o);
9474
+ throw F.conceptCheckFailed(s.name, o);
9466
9475
  } else {
9467
9476
  const o = await this.checkConcept(a, s.base);
9468
9477
  if (o !== !0)
9469
- throw O.conceptCheckFailed(s.name, o);
9478
+ throw F.conceptCheckFailed(s.name, o);
9470
9479
  }
9471
9480
  if (s.isRef) {
9472
9481
  const o = s.isCollection ? m.atom({
@@ -9498,7 +9507,7 @@ class we {
9498
9507
  return !0;
9499
9508
  }, r = await e.evaluateAsync(i);
9500
9509
  if (r !== !0)
9501
- throw O.conditionCheckFailed(r);
9510
+ throw F.conditionCheckFailed(r);
9502
9511
  }
9503
9512
  }
9504
9513
  // CAUTION sideEffect 是并行的。如果要串行,用户应该自己写在一个里面
@@ -9808,8 +9817,8 @@ class Ki extends $ {
9808
9817
  // 可以根据 group 上的具体配置逻辑,来动态决定。
9809
9818
  }
9810
9819
  $.GroupStateNodeType.set("program", Ki);
9811
- const ne = new le(), Ot = "_Interaction_", bt = "_Activity_", Ne = I.create({
9812
- name: Ot,
9820
+ const ne = new le(), Ft = "_Interaction_", bt = "_Activity_", Ne = I.create({
9821
+ name: Ft,
9813
9822
  properties: [
9814
9823
  N.create({
9815
9824
  name: "interactionId",
@@ -9982,10 +9991,10 @@ class Xi {
9982
9991
  }));
9983
9992
  }
9984
9993
  async saveEvent(t) {
9985
- return this.controller.system.storage.create(Ot, t);
9994
+ return this.controller.system.storage.create(Ft, t);
9986
9995
  }
9987
9996
  async getEvent(t) {
9988
- return (await this.controller.system.storage.find(Ot, t, void 0, ["*"])).map((e) => ({
9997
+ return (await this.controller.system.storage.find(Ft, t, void 0, ["*"])).map((e) => ({
9989
9998
  ...e
9990
9999
  }));
9991
10000
  }
@@ -10019,10 +10028,10 @@ class Te {
10019
10028
  return new Te(t);
10020
10029
  }
10021
10030
  }
10022
- const Ft = "_isDeleted_", Ar = {
10031
+ const Ot = "_isDeleted_", Ar = {
10023
10032
  create() {
10024
10033
  return N.create({
10025
- name: Ft,
10034
+ name: Ot,
10026
10035
  type: "boolean"
10027
10036
  });
10028
10037
  }
@@ -10053,7 +10062,7 @@ class Sr {
10053
10062
  ...Ti,
10054
10063
  ...wi,
10055
10064
  ...gi,
10056
- ...Oi,
10065
+ ...Fi,
10057
10066
  ...Qi,
10058
10067
  ...Mi,
10059
10068
  ...fi,
@@ -10099,7 +10108,7 @@ class Sr {
10099
10108
  await this.system.storage.create(r.id.name, a);
10100
10109
  } else {
10101
10110
  const r = t;
10102
- r.id.name === Ft && e ? await this.system.storage.delete(r.host.name, R.atom({ key: "id", value: ["=", i.id] })) : await this.system.storage.update(r.host.name, R.atom({ key: "id", value: ["=", i.id] }), { [r.id.name]: e });
10111
+ r.id.name === Ot && e ? await this.system.storage.delete(r.host.name, R.atom({ key: "id", value: ["=", i.id] })) : await this.system.storage.update(r.host.name, R.atom({ key: "id", value: ["=", i.id] }), { [r.id.name]: e });
10103
10112
  }
10104
10113
  }
10105
10114
  }
@@ -10122,7 +10131,7 @@ class Sr {
10122
10131
  }
10123
10132
  } else {
10124
10133
  const a = t;
10125
- a.id.name === Ft && s.data ? (k(s.type !== "delete", "Hard deletion property cannot be deleted"), await this.system.storage.delete(a.host.name, R.atom({ key: "id", value: ["=", i.id] }))) : s.type === "insert" ? await this.system.storage.update(a.host.name, R.atom({ key: "id", value: ["=", i.id] }), { [a.id.name]: s.data }) : s.type === "update" ? await this.system.storage.update(a.host.name, R.atom({ key: "id", value: ["=", i.id] }), { [a.id.name]: s.data }) : s.type === "delete" && await this.system.storage.update(a.host.name, R.atom({ key: "id", value: ["=", i.id] }), { [a.id.name]: null });
10134
+ a.id.name === Ot && s.data ? (k(s.type !== "delete", "Hard deletion property cannot be deleted"), await this.system.storage.delete(a.host.name, R.atom({ key: "id", value: ["=", i.id] }))) : s.type === "insert" ? await this.system.storage.update(a.host.name, R.atom({ key: "id", value: ["=", i.id] }), { [a.id.name]: s.data }) : s.type === "update" ? await this.system.storage.update(a.host.name, R.atom({ key: "id", value: ["=", i.id] }), { [a.id.name]: s.data }) : s.type === "delete" && await this.system.storage.update(a.host.name, R.atom({ key: "id", value: ["=", i.id] }), { [a.id.name]: null });
10126
10135
  }
10127
10136
  }
10128
10137
  }
@@ -10363,7 +10372,7 @@ class Ir {
10363
10372
  }
10364
10373
  export {
10365
10374
  bt as ACTIVITY_RECORD,
10366
- Oe as ALL_ATTR_SYMBOL,
10375
+ Fe as ALL_ATTR_SYMBOL,
10367
10376
  Ct as ASYNC_TASK_RECORD,
10368
10377
  Tt as Action,
10369
10378
  qt as Activity,
@@ -10394,7 +10403,7 @@ export {
10394
10403
  wt as ComputationResultSkip,
10395
10404
  ae as ComputationStateError,
10396
10405
  Bt as Condition,
10397
- O as ConditionError,
10406
+ F as ConditionError,
10398
10407
  At as Conditions,
10399
10408
  Sr as Controller,
10400
10409
  lt as Count,
@@ -10424,7 +10433,7 @@ export {
10424
10433
  it as Gateway,
10425
10434
  Me as GetAction,
10426
10435
  Ni as GlobalAnyHandle,
10427
- Fi as GlobalAverageHandle,
10436
+ Oi as GlobalAverageHandle,
10428
10437
  B as GlobalBoundState,
10429
10438
  ki as GlobalCountHandle,
10430
10439
  Vi as GlobalCustomHandle,
@@ -10433,10 +10442,10 @@ export {
10433
10442
  hi as GlobalStateMachineHandle,
10434
10443
  Pi as GlobalSumHandle,
10435
10444
  mi as GlobalWeightedSummationHandle,
10436
- Ft as HARD_DELETION_PROPERTY_NAME,
10445
+ Ot as HARD_DELETION_PROPERTY_NAME,
10437
10446
  Ar as HardDeletionProperty,
10438
10447
  ie as ID_ATTR,
10439
- Ot as INTERACTION_RECORD,
10448
+ Ft as INTERACTION_RECORD,
10440
10449
  Nt as Inequality,
10441
10450
  Lt as Interaction,
10442
10451
  we as InteractionCall,
@@ -10492,7 +10501,7 @@ export {
10492
10501
  G as StateNode,
10493
10502
  Jt as StateTransfer,
10494
10503
  ut as Summation,
10495
- Oi as SummationHandles,
10504
+ Fi as SummationHandles,
10496
10505
  te as SystemConsoleLogger,
10497
10506
  ni as SystemEntity,
10498
10507
  ir as SystemLogLevel,