@timeax/digital-service-engine 0.2.5 → 0.2.6
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/core/index.cjs +1 -1
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/react/index.cjs +146 -96
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +146 -96
- package/dist/react/index.js.map +1 -1
- package/dist/workspace/index.cjs +146 -96
- package/dist/workspace/index.cjs.map +1 -1
- package/dist/workspace/index.js +146 -96
- package/dist/workspace/index.js.map +1 -1
- package/package.json +7 -7
package/dist/workspace/index.js
CHANGED
|
@@ -6611,7 +6611,7 @@ function createNodeIndex(builder) {
|
|
|
6611
6611
|
for (const fieldId of visible) {
|
|
6612
6612
|
const node = getField(fieldId);
|
|
6613
6613
|
if (!node) continue;
|
|
6614
|
-
const explicit = includes.has(fieldId)
|
|
6614
|
+
const explicit = includes.has(fieldId);
|
|
6615
6615
|
results.push(explicit ? node : { ...node, isInherited: true });
|
|
6616
6616
|
}
|
|
6617
6617
|
return Object.freeze(results);
|
|
@@ -8365,7 +8365,9 @@ function include(ctx, receiverId, idOrIds) {
|
|
|
8365
8365
|
const ids = Array.isArray(idOrIds) ? idOrIds : [idOrIds];
|
|
8366
8366
|
if (receiver.kind === "tag" || receiver.kind === "field" && isActualButtonField(receiver.data) || receiver.kind === "option") {
|
|
8367
8367
|
if (receiver.kind === "tag") {
|
|
8368
|
-
const t = ((_a = p.filters) != null ? _a : []).find(
|
|
8368
|
+
const t = ((_a = p.filters) != null ? _a : []).find(
|
|
8369
|
+
(x) => x.id === receiverId
|
|
8370
|
+
);
|
|
8369
8371
|
if (t) {
|
|
8370
8372
|
const accepted = [];
|
|
8371
8373
|
const next = new Set((_b = t.includes) != null ? _b : []);
|
|
@@ -8407,7 +8409,12 @@ function include(ctx, receiverId, idOrIds) {
|
|
|
8407
8409
|
const current = (_f = (_e = p.includes_for_buttons) == null ? void 0 : _e[receiverId]) != null ? _f : [];
|
|
8408
8410
|
const next = new Set(current);
|
|
8409
8411
|
for (const id of ids) {
|
|
8410
|
-
if (wouldCreateIncludeExcludeCycle(
|
|
8412
|
+
if (wouldCreateIncludeExcludeCycle(
|
|
8413
|
+
ctx,
|
|
8414
|
+
p,
|
|
8415
|
+
receiverId,
|
|
8416
|
+
id
|
|
8417
|
+
)) {
|
|
8411
8418
|
ctx.emit("editor:error", {
|
|
8412
8419
|
message: `Cycle detected: ${receiverId} including ${id} would create a cycle.`,
|
|
8413
8420
|
code: "cycle_detected",
|
|
@@ -8423,7 +8430,8 @@ function include(ctx, receiverId, idOrIds) {
|
|
|
8423
8430
|
accepted.push(id);
|
|
8424
8431
|
}
|
|
8425
8432
|
if (accepted.length > 0 || current.length > 0) {
|
|
8426
|
-
if (!p.includes_for_buttons)
|
|
8433
|
+
if (!p.includes_for_buttons)
|
|
8434
|
+
p.includes_for_buttons = {};
|
|
8427
8435
|
p.includes_for_buttons[receiverId] = Array.from(next);
|
|
8428
8436
|
}
|
|
8429
8437
|
if ((_g = p.excludes_for_buttons) == null ? void 0 : _g[receiverId]) {
|
|
@@ -8438,7 +8446,9 @@ function include(ctx, receiverId, idOrIds) {
|
|
|
8438
8446
|
if (!p.fields) p.fields = [];
|
|
8439
8447
|
if (!p.filters) p.filters = [];
|
|
8440
8448
|
} else {
|
|
8441
|
-
throw new Error(
|
|
8449
|
+
throw new Error(
|
|
8450
|
+
"Receiver must be a tag, button field, or option"
|
|
8451
|
+
);
|
|
8442
8452
|
}
|
|
8443
8453
|
}),
|
|
8444
8454
|
undo: () => ctx.undo()
|
|
@@ -8453,7 +8463,9 @@ function exclude(ctx, receiverId, idOrIds) {
|
|
|
8453
8463
|
const ids = Array.isArray(idOrIds) ? idOrIds : [idOrIds];
|
|
8454
8464
|
if (receiver.kind === "tag" || receiver.kind === "field" && isActualButtonField(receiver.data) || receiver.kind === "option") {
|
|
8455
8465
|
if (receiver.kind === "tag") {
|
|
8456
|
-
const t = ((_a = p.filters) != null ? _a : []).find(
|
|
8466
|
+
const t = ((_a = p.filters) != null ? _a : []).find(
|
|
8467
|
+
(x) => x.id === receiverId
|
|
8468
|
+
);
|
|
8457
8469
|
if (t) {
|
|
8458
8470
|
const accepted = [];
|
|
8459
8471
|
const next = new Set((_b = t.excludes) != null ? _b : []);
|
|
@@ -8495,7 +8507,12 @@ function exclude(ctx, receiverId, idOrIds) {
|
|
|
8495
8507
|
const current = (_f = (_e = p.excludes_for_buttons) == null ? void 0 : _e[receiverId]) != null ? _f : [];
|
|
8496
8508
|
const next = new Set(current);
|
|
8497
8509
|
for (const id of ids) {
|
|
8498
|
-
if (wouldCreateIncludeExcludeCycle(
|
|
8510
|
+
if (wouldCreateIncludeExcludeCycle(
|
|
8511
|
+
ctx,
|
|
8512
|
+
p,
|
|
8513
|
+
receiverId,
|
|
8514
|
+
id
|
|
8515
|
+
)) {
|
|
8499
8516
|
ctx.emit("editor:error", {
|
|
8500
8517
|
message: `Cycle detected: ${receiverId} excluding ${id} would create a cycle.`,
|
|
8501
8518
|
code: "cycle_detected",
|
|
@@ -8511,7 +8528,8 @@ function exclude(ctx, receiverId, idOrIds) {
|
|
|
8511
8528
|
accepted.push(id);
|
|
8512
8529
|
}
|
|
8513
8530
|
if (accepted.length > 0 || current.length > 0) {
|
|
8514
|
-
if (!p.excludes_for_buttons)
|
|
8531
|
+
if (!p.excludes_for_buttons)
|
|
8532
|
+
p.excludes_for_buttons = {};
|
|
8515
8533
|
p.excludes_for_buttons[receiverId] = Array.from(next);
|
|
8516
8534
|
}
|
|
8517
8535
|
if ((_g = p.includes_for_buttons) == null ? void 0 : _g[receiverId]) {
|
|
@@ -8526,7 +8544,9 @@ function exclude(ctx, receiverId, idOrIds) {
|
|
|
8526
8544
|
if (!p.fields) p.fields = [];
|
|
8527
8545
|
if (!p.filters) p.filters = [];
|
|
8528
8546
|
} else {
|
|
8529
|
-
throw new Error(
|
|
8547
|
+
throw new Error(
|
|
8548
|
+
"Receiver must be a tag, button field, or option"
|
|
8549
|
+
);
|
|
8530
8550
|
}
|
|
8531
8551
|
}),
|
|
8532
8552
|
undo: () => ctx.undo()
|
|
@@ -8536,87 +8556,98 @@ function connect(ctx, kind, fromId, toId2) {
|
|
|
8536
8556
|
ctx.exec({
|
|
8537
8557
|
name: `connect:${kind}`,
|
|
8538
8558
|
do: () => ctx.patchProps((p) => {
|
|
8539
|
-
var _a, _b, _c, _d, _e;
|
|
8559
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
8540
8560
|
if (kind === "bind") {
|
|
8541
8561
|
if (ctx.isTagId(fromId) && ctx.isTagId(toId2)) {
|
|
8542
8562
|
if (wouldCreateTagCycle(ctx, p, fromId, toId2)) {
|
|
8543
|
-
throw new Error(
|
|
8563
|
+
throw new Error(
|
|
8564
|
+
`bind would create a cycle: ${fromId} ? ${toId2}`
|
|
8565
|
+
);
|
|
8544
8566
|
}
|
|
8545
|
-
const child = ((_a = p.filters) != null ? _a : []).find(
|
|
8567
|
+
const child = ((_a = p.filters) != null ? _a : []).find(
|
|
8568
|
+
(t) => t.id === toId2
|
|
8569
|
+
);
|
|
8546
8570
|
if (child) child.bind_id = fromId;
|
|
8547
8571
|
return;
|
|
8548
8572
|
}
|
|
8549
8573
|
if (ctx.isTagId(fromId) && ctx.isFieldId(toId2) || ctx.isFieldId(fromId) && ctx.isTagId(toId2)) {
|
|
8550
8574
|
const fieldId = ctx.isFieldId(toId2) ? toId2 : fromId;
|
|
8551
8575
|
const tagId = ctx.isTagId(fromId) ? fromId : toId2;
|
|
8552
|
-
const f = ((_b = p.fields) != null ? _b : []).find(
|
|
8576
|
+
const f = ((_b = p.fields) != null ? _b : []).find(
|
|
8577
|
+
(x) => x.id === fieldId
|
|
8578
|
+
);
|
|
8553
8579
|
if (!f) return;
|
|
8554
8580
|
if (!f.bind_id) {
|
|
8555
8581
|
f.bind_id = tagId;
|
|
8556
8582
|
return;
|
|
8557
8583
|
}
|
|
8558
8584
|
if (typeof f.bind_id === "string") {
|
|
8559
|
-
if (f.bind_id !== tagId)
|
|
8585
|
+
if (f.bind_id !== tagId) {
|
|
8586
|
+
f.bind_id = [f.bind_id, tagId];
|
|
8587
|
+
}
|
|
8560
8588
|
return;
|
|
8561
8589
|
}
|
|
8562
|
-
if (!f.bind_id.includes(tagId))
|
|
8590
|
+
if (!f.bind_id.includes(tagId)) {
|
|
8591
|
+
f.bind_id.push(tagId);
|
|
8592
|
+
}
|
|
8563
8593
|
return;
|
|
8564
8594
|
}
|
|
8565
|
-
throw new Error(
|
|
8595
|
+
throw new Error(
|
|
8596
|
+
`bind: unsupported route ${fromId} ? ${toId2}`
|
|
8597
|
+
);
|
|
8566
8598
|
}
|
|
8567
8599
|
if (kind === "include" || kind === "exclude") {
|
|
8568
|
-
const
|
|
8600
|
+
const tagKey = kind === "include" ? "includes" : "excludes";
|
|
8601
|
+
const mapKey = kind === "include" ? "includes_for_buttons" : "excludes_for_buttons";
|
|
8569
8602
|
if (ctx.isTagId(fromId) && ctx.isFieldId(toId2)) {
|
|
8570
|
-
const t = ((_c = p.filters) != null ? _c : []).find(
|
|
8603
|
+
const t = ((_c = p.filters) != null ? _c : []).find(
|
|
8604
|
+
(x) => x.id === fromId
|
|
8605
|
+
);
|
|
8571
8606
|
if (!t) return;
|
|
8572
|
-
const arr = (_d = t[
|
|
8607
|
+
const arr = (_d = t[tagKey]) != null ? _d : t[tagKey] = [];
|
|
8573
8608
|
if (!arr.includes(toId2)) arr.push(toId2);
|
|
8574
8609
|
return;
|
|
8575
8610
|
}
|
|
8611
|
+
if (ctx.isFieldId(fromId) && ctx.isFieldId(toId2)) {
|
|
8612
|
+
const source = ((_e = p.fields) != null ? _e : []).find(
|
|
8613
|
+
(x) => x.id === fromId
|
|
8614
|
+
);
|
|
8615
|
+
if (!(source == null ? void 0 : source.button)) {
|
|
8616
|
+
throw new Error(
|
|
8617
|
+
`${kind}: source field must be button=true: ${fromId} ? ${toId2}`
|
|
8618
|
+
);
|
|
8619
|
+
}
|
|
8620
|
+
addMappedField(p, mapKey, fromId, toId2);
|
|
8621
|
+
return;
|
|
8622
|
+
}
|
|
8576
8623
|
if (ctx.isOptionId(fromId) && ctx.isFieldId(toId2)) {
|
|
8577
|
-
|
|
8578
|
-
const maps = p[mapKey];
|
|
8579
|
-
const next = { ...maps != null ? maps : {} };
|
|
8580
|
-
const arr = (_e = next[fromId]) != null ? _e : [];
|
|
8581
|
-
if (!arr.includes(toId2)) arr.push(toId2);
|
|
8582
|
-
next[fromId] = arr;
|
|
8583
|
-
p[mapKey] = next;
|
|
8624
|
+
addMappedField(p, mapKey, fromId, toId2);
|
|
8584
8625
|
return;
|
|
8585
8626
|
}
|
|
8586
|
-
throw new Error(
|
|
8627
|
+
throw new Error(
|
|
8628
|
+
`${kind}: unsupported route ${fromId} ? ${toId2}`
|
|
8629
|
+
);
|
|
8587
8630
|
}
|
|
8588
8631
|
if (kind === "service") {
|
|
8589
8632
|
ensureServiceExists(ctx.opts, fromId);
|
|
8590
8633
|
if (toId2.startsWith("t:")) {
|
|
8591
|
-
|
|
8592
|
-
|
|
8593
|
-
do: () => ctx.patchProps((next) => {
|
|
8594
|
-
var _a2;
|
|
8595
|
-
const t = ((_a2 = next.filters) != null ? _a2 : []).find((x) => x.id === toId2);
|
|
8596
|
-
if (t) t.service_id = fromId;
|
|
8597
|
-
}),
|
|
8598
|
-
undo: () => ctx.undo()
|
|
8599
|
-
});
|
|
8634
|
+
const t = ((_f = p.filters) != null ? _f : []).find((x) => x.id === toId2);
|
|
8635
|
+
if (t) t.service_id = fromId;
|
|
8600
8636
|
return;
|
|
8601
8637
|
}
|
|
8602
8638
|
if (toId2.startsWith("o:")) {
|
|
8603
|
-
|
|
8604
|
-
|
|
8605
|
-
|
|
8606
|
-
|
|
8607
|
-
|
|
8608
|
-
|
|
8609
|
-
|
|
8610
|
-
o.service_id = fromId;
|
|
8611
|
-
return;
|
|
8612
|
-
}
|
|
8613
|
-
}
|
|
8614
|
-
}),
|
|
8615
|
-
undo: () => ctx.undo()
|
|
8616
|
-
});
|
|
8639
|
+
for (const f of (_g = p.fields) != null ? _g : []) {
|
|
8640
|
+
const o = (_h = f.options) == null ? void 0 : _h.find((x) => x.id === toId2);
|
|
8641
|
+
if (o) {
|
|
8642
|
+
o.service_id = fromId;
|
|
8643
|
+
return;
|
|
8644
|
+
}
|
|
8645
|
+
}
|
|
8617
8646
|
return;
|
|
8618
8647
|
}
|
|
8619
|
-
throw new Error(
|
|
8648
|
+
throw new Error(
|
|
8649
|
+
'service: to must be a tag ("t:*") or option ("o:*")'
|
|
8650
|
+
);
|
|
8620
8651
|
}
|
|
8621
8652
|
throw new Error(`Unknown connect kind: ${kind}`);
|
|
8622
8653
|
}),
|
|
@@ -8627,90 +8658,109 @@ function disconnect(ctx, kind, fromId, toId2) {
|
|
|
8627
8658
|
ctx.exec({
|
|
8628
8659
|
name: `disconnect:${kind}`,
|
|
8629
8660
|
do: () => ctx.patchProps((p) => {
|
|
8630
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
8661
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
8631
8662
|
if (kind === "bind") {
|
|
8632
8663
|
if (ctx.isTagId(fromId) && ctx.isTagId(toId2)) {
|
|
8633
|
-
const child = ((_a = p.filters) != null ? _a : []).find(
|
|
8634
|
-
|
|
8664
|
+
const child = ((_a = p.filters) != null ? _a : []).find(
|
|
8665
|
+
(t) => t.id === toId2
|
|
8666
|
+
);
|
|
8667
|
+
if ((child == null ? void 0 : child.bind_id) === fromId) {
|
|
8668
|
+
delete child.bind_id;
|
|
8669
|
+
}
|
|
8635
8670
|
return;
|
|
8636
8671
|
}
|
|
8637
8672
|
if (ctx.isTagId(fromId) && ctx.isFieldId(toId2) || ctx.isFieldId(fromId) && ctx.isTagId(toId2)) {
|
|
8638
8673
|
const fieldId = ctx.isFieldId(toId2) ? toId2 : fromId;
|
|
8639
8674
|
const tagId = ctx.isTagId(fromId) ? fromId : toId2;
|
|
8640
|
-
const f = ((_b = p.fields) != null ? _b : []).find(
|
|
8675
|
+
const f = ((_b = p.fields) != null ? _b : []).find(
|
|
8676
|
+
(x) => x.id === fieldId
|
|
8677
|
+
);
|
|
8641
8678
|
if (!(f == null ? void 0 : f.bind_id)) return;
|
|
8642
8679
|
if (typeof f.bind_id === "string") {
|
|
8643
|
-
if (f.bind_id === tagId)
|
|
8680
|
+
if (f.bind_id === tagId) {
|
|
8681
|
+
delete f.bind_id;
|
|
8682
|
+
}
|
|
8644
8683
|
return;
|
|
8645
8684
|
}
|
|
8646
8685
|
f.bind_id = f.bind_id.filter((x) => x !== tagId);
|
|
8647
|
-
if (((_c = f.bind_id) == null ? void 0 : _c.length) === 0)
|
|
8686
|
+
if (((_c = f.bind_id) == null ? void 0 : _c.length) === 0) {
|
|
8687
|
+
delete f.bind_id;
|
|
8688
|
+
}
|
|
8648
8689
|
return;
|
|
8649
8690
|
}
|
|
8650
|
-
throw new Error(
|
|
8691
|
+
throw new Error(
|
|
8692
|
+
`unbind: unsupported route ${fromId} ? ${toId2}`
|
|
8693
|
+
);
|
|
8651
8694
|
}
|
|
8652
8695
|
if (kind === "include" || kind === "exclude") {
|
|
8653
|
-
const
|
|
8696
|
+
const tagKey = kind === "include" ? "includes" : "excludes";
|
|
8697
|
+
const mapKey = kind === "include" ? "includes_for_buttons" : "excludes_for_buttons";
|
|
8654
8698
|
if (ctx.isTagId(fromId) && ctx.isFieldId(toId2)) {
|
|
8655
|
-
const t = ((_d = p.filters) != null ? _d : []).find(
|
|
8699
|
+
const t = ((_d = p.filters) != null ? _d : []).find(
|
|
8700
|
+
(x) => x.id === fromId
|
|
8701
|
+
);
|
|
8656
8702
|
if (!t) return;
|
|
8657
|
-
t[
|
|
8658
|
-
if (!((_f = t[
|
|
8703
|
+
t[tagKey] = ((_e = t[tagKey]) != null ? _e : []).filter((x) => x !== toId2);
|
|
8704
|
+
if (!((_f = t[tagKey]) == null ? void 0 : _f.length)) {
|
|
8705
|
+
delete t[tagKey];
|
|
8706
|
+
}
|
|
8659
8707
|
return;
|
|
8660
8708
|
}
|
|
8661
|
-
if (ctx.isOptionId(fromId) && ctx.isFieldId(toId2)) {
|
|
8662
|
-
const mapKey = kind === "include" ? "includes_for_options" : "excludes_for_options";
|
|
8709
|
+
if ((ctx.isFieldId(fromId) || ctx.isOptionId(fromId)) && ctx.isFieldId(toId2)) {
|
|
8663
8710
|
const maps = p[mapKey];
|
|
8664
|
-
if (!maps) return;
|
|
8665
|
-
|
|
8666
|
-
|
|
8667
|
-
|
|
8668
|
-
|
|
8669
|
-
|
|
8711
|
+
if (!(maps == null ? void 0 : maps[fromId])) return;
|
|
8712
|
+
maps[fromId] = maps[fromId].filter(
|
|
8713
|
+
(fid) => fid !== toId2
|
|
8714
|
+
);
|
|
8715
|
+
if (!((_g = maps[fromId]) == null ? void 0 : _g.length)) {
|
|
8716
|
+
delete maps[fromId];
|
|
8717
|
+
}
|
|
8718
|
+
if (!Object.keys(maps).length) {
|
|
8719
|
+
delete p[mapKey];
|
|
8670
8720
|
}
|
|
8671
|
-
if (!Object.keys(maps).length) delete p[mapKey];
|
|
8672
8721
|
return;
|
|
8673
8722
|
}
|
|
8674
|
-
throw new Error(
|
|
8723
|
+
throw new Error(
|
|
8724
|
+
`${kind}: unsupported route ${fromId} ? ${toId2}`
|
|
8725
|
+
);
|
|
8675
8726
|
}
|
|
8676
8727
|
if (kind === "service") {
|
|
8677
8728
|
ensureServiceExists(ctx.opts, fromId);
|
|
8678
8729
|
if (toId2.startsWith("t:")) {
|
|
8679
|
-
|
|
8680
|
-
|
|
8681
|
-
|
|
8682
|
-
|
|
8683
|
-
const t = ((_a2 = next.filters) != null ? _a2 : []).find((x) => x.id === toId2);
|
|
8684
|
-
if (t) delete t.service_id;
|
|
8685
|
-
}),
|
|
8686
|
-
undo: () => ctx.undo()
|
|
8687
|
-
});
|
|
8730
|
+
const t = ((_h = p.filters) != null ? _h : []).find((x) => x.id === toId2);
|
|
8731
|
+
if (t) {
|
|
8732
|
+
delete t.service_id;
|
|
8733
|
+
}
|
|
8688
8734
|
return;
|
|
8689
8735
|
}
|
|
8690
8736
|
if (toId2.startsWith("o:")) {
|
|
8691
|
-
|
|
8692
|
-
|
|
8693
|
-
|
|
8694
|
-
|
|
8695
|
-
|
|
8696
|
-
|
|
8697
|
-
|
|
8698
|
-
delete o.service_id;
|
|
8699
|
-
return;
|
|
8700
|
-
}
|
|
8701
|
-
}
|
|
8702
|
-
}),
|
|
8703
|
-
undo: () => ctx.undo()
|
|
8704
|
-
});
|
|
8737
|
+
for (const f of (_i = p.fields) != null ? _i : []) {
|
|
8738
|
+
const o = (_j = f.options) == null ? void 0 : _j.find((x) => x.id === toId2);
|
|
8739
|
+
if (o) {
|
|
8740
|
+
delete o.service_id;
|
|
8741
|
+
return;
|
|
8742
|
+
}
|
|
8743
|
+
}
|
|
8705
8744
|
return;
|
|
8706
8745
|
}
|
|
8707
|
-
throw new Error(
|
|
8746
|
+
throw new Error(
|
|
8747
|
+
'service: to must be a tag ("t:*") or option ("o:*")'
|
|
8748
|
+
);
|
|
8708
8749
|
}
|
|
8709
8750
|
throw new Error(`Unknown disconnect kind: ${kind}`);
|
|
8710
8751
|
}),
|
|
8711
8752
|
undo: () => ctx.undo()
|
|
8712
8753
|
});
|
|
8713
8754
|
}
|
|
8755
|
+
function addMappedField(p, mapKey, fromId, toId2) {
|
|
8756
|
+
var _a, _b;
|
|
8757
|
+
const maps = (_a = p[mapKey]) != null ? _a : {};
|
|
8758
|
+
const arr = (_b = maps[fromId]) != null ? _b : [];
|
|
8759
|
+
if (!arr.includes(toId2)) {
|
|
8760
|
+
maps[fromId] = [...arr, toId2];
|
|
8761
|
+
}
|
|
8762
|
+
p[mapKey] = maps;
|
|
8763
|
+
}
|
|
8714
8764
|
|
|
8715
8765
|
// src/react/canvas/editor/editor-service-filter.ts
|
|
8716
8766
|
function filterServicesForVisibleGroup2(ctx, candidates, input) {
|