@timeax/digital-service-engine 0.2.4 → 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 +146 -1
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +8 -1
- package/dist/core/index.d.ts +8 -1
- package/dist/core/index.js +146 -1
- package/dist/core/index.js.map +1 -1
- package/dist/react/index.cjs +382 -96
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +11 -1
- package/dist/react/index.d.ts +11 -1
- package/dist/react/index.js +382 -96
- package/dist/react/index.js.map +1 -1
- package/dist/schema/index.d.cts +9 -2
- package/dist/schema/index.d.ts +9 -2
- package/dist/workspace/index.cjs +373 -96
- package/dist/workspace/index.cjs.map +1 -1
- package/dist/workspace/index.d.cts +5 -1
- package/dist/workspace/index.d.ts +5 -1
- package/dist/workspace/index.js +373 -96
- package/dist/workspace/index.js.map +1 -1
- package/package.json +3 -2
- package/schema/editor-snapshot.schema.json +6 -0
- package/schema/order-snapshot.schema.json +667 -0
- package/schema/service-props.schema.json +6 -0
package/dist/workspace/index.js
CHANGED
|
@@ -3484,6 +3484,7 @@ function normalise(input, opts = {}) {
|
|
|
3484
3484
|
const excludes_for_buttons = toStringArrayMap(
|
|
3485
3485
|
obj.excludes_for_buttons
|
|
3486
3486
|
);
|
|
3487
|
+
const orderKinds = toStringMap(obj.orderKinds);
|
|
3487
3488
|
const notices = toNoticeArray(obj.notices);
|
|
3488
3489
|
let filters = rawFilters.map((t) => coerceTag(t, constraints));
|
|
3489
3490
|
const fields = rawFields.map((f) => coerceField(f, defRole));
|
|
@@ -3495,6 +3496,7 @@ function normalise(input, opts = {}) {
|
|
|
3495
3496
|
filters,
|
|
3496
3497
|
fields,
|
|
3497
3498
|
order_for_tags: obj.order_for_tags,
|
|
3499
|
+
...isNonEmpty(orderKinds) && { orderKinds },
|
|
3498
3500
|
...isNonEmpty(includes_for_buttons) && { includes_for_buttons },
|
|
3499
3501
|
...isNonEmpty(excludes_for_buttons) && { excludes_for_buttons },
|
|
3500
3502
|
...fallbacks && (isNonEmpty(fallbacks.nodes) || isNonEmpty(fallbacks.global)) && {
|
|
@@ -3705,6 +3707,15 @@ function normaliseBindId(bind) {
|
|
|
3705
3707
|
}
|
|
3706
3708
|
return void 0;
|
|
3707
3709
|
}
|
|
3710
|
+
function toStringMap(src) {
|
|
3711
|
+
if (!src || typeof src !== "object") return void 0;
|
|
3712
|
+
const out = {};
|
|
3713
|
+
for (const [k, v] of Object.entries(src)) {
|
|
3714
|
+
if (!k || typeof v !== "string") continue;
|
|
3715
|
+
out[k] = v;
|
|
3716
|
+
}
|
|
3717
|
+
return Object.keys(out).length ? out : void 0;
|
|
3718
|
+
}
|
|
3708
3719
|
function toStringArrayMap(src) {
|
|
3709
3720
|
if (!src || typeof src !== "object") return void 0;
|
|
3710
3721
|
const out = {};
|
|
@@ -4523,6 +4534,129 @@ function validateOptionMaps(v) {
|
|
|
4523
4534
|
}
|
|
4524
4535
|
}
|
|
4525
4536
|
|
|
4537
|
+
// src/utils/order-kind.ts
|
|
4538
|
+
function normalizeSelectedTriggerKey(key, nodeMap) {
|
|
4539
|
+
if (!key) return void 0;
|
|
4540
|
+
const compositeIdx = key.indexOf("::");
|
|
4541
|
+
if (compositeIdx !== -1) {
|
|
4542
|
+
const fieldId = key.slice(0, compositeIdx).trim();
|
|
4543
|
+
const optionId = key.slice(compositeIdx + 2).trim();
|
|
4544
|
+
if (optionId) {
|
|
4545
|
+
const optionRef = nodeMap.get(optionId);
|
|
4546
|
+
if ((optionRef == null ? void 0 : optionRef.kind) === "option") {
|
|
4547
|
+
return { nodeId: optionRef.id, nodeKind: "option" };
|
|
4548
|
+
}
|
|
4549
|
+
}
|
|
4550
|
+
if (fieldId) {
|
|
4551
|
+
const fieldRef = nodeMap.get(fieldId);
|
|
4552
|
+
if ((fieldRef == null ? void 0 : fieldRef.kind) === "field") {
|
|
4553
|
+
return { nodeId: fieldRef.id, nodeKind: "field" };
|
|
4554
|
+
}
|
|
4555
|
+
}
|
|
4556
|
+
return void 0;
|
|
4557
|
+
}
|
|
4558
|
+
const ref = nodeMap.get(key);
|
|
4559
|
+
if (!ref) return void 0;
|
|
4560
|
+
if (ref.kind !== "field" && ref.kind !== "option") return void 0;
|
|
4561
|
+
return { nodeId: ref.id, nodeKind: ref.kind };
|
|
4562
|
+
}
|
|
4563
|
+
function normalizeSelectedOrderKindTriggers(selectedTriggerKeys, nodeMap) {
|
|
4564
|
+
if (!selectedTriggerKeys) return [];
|
|
4565
|
+
const out = [];
|
|
4566
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4567
|
+
for (const rawKey of selectedTriggerKeys) {
|
|
4568
|
+
const key = String(rawKey != null ? rawKey : "");
|
|
4569
|
+
const normalized = normalizeSelectedTriggerKey(key, nodeMap);
|
|
4570
|
+
if (!normalized) continue;
|
|
4571
|
+
const dedupeKey = `${normalized.nodeKind}:${normalized.nodeId}`;
|
|
4572
|
+
if (seen.has(dedupeKey)) continue;
|
|
4573
|
+
seen.add(dedupeKey);
|
|
4574
|
+
out.push(normalized);
|
|
4575
|
+
}
|
|
4576
|
+
return out;
|
|
4577
|
+
}
|
|
4578
|
+
function resolveOrderKind(params) {
|
|
4579
|
+
var _a, _b;
|
|
4580
|
+
const nodeMap = (_a = params.nodeMap) != null ? _a : buildNodeMap(params.props);
|
|
4581
|
+
const orderKinds = (_b = params.props.orderKinds) != null ? _b : {};
|
|
4582
|
+
const normalizedSelected = normalizeSelectedOrderKindTriggers(
|
|
4583
|
+
params.selectedTriggerKeys,
|
|
4584
|
+
nodeMap
|
|
4585
|
+
);
|
|
4586
|
+
const selectedKindToSource = /* @__PURE__ */ new Map();
|
|
4587
|
+
const selectedNodeIdsForKinds = /* @__PURE__ */ new Map();
|
|
4588
|
+
for (const trigger of normalizedSelected) {
|
|
4589
|
+
const mappedKind = orderKinds[trigger.nodeId];
|
|
4590
|
+
if (typeof mappedKind !== "string") continue;
|
|
4591
|
+
if (!selectedKindToSource.has(mappedKind)) {
|
|
4592
|
+
selectedKindToSource.set(mappedKind, {
|
|
4593
|
+
nodeId: trigger.nodeId,
|
|
4594
|
+
nodeKind: trigger.nodeKind
|
|
4595
|
+
});
|
|
4596
|
+
}
|
|
4597
|
+
if (!selectedNodeIdsForKinds.has(mappedKind)) {
|
|
4598
|
+
selectedNodeIdsForKinds.set(mappedKind, /* @__PURE__ */ new Set());
|
|
4599
|
+
}
|
|
4600
|
+
selectedNodeIdsForKinds.get(mappedKind).add(trigger.nodeId);
|
|
4601
|
+
}
|
|
4602
|
+
const selectedKinds = Array.from(selectedKindToSource.keys());
|
|
4603
|
+
if (selectedKinds.length > 1) {
|
|
4604
|
+
const conflictingNodeIds = Array.from(selectedNodeIdsForKinds.values()).flatMap((ids) => Array.from(ids)).filter((id, idx, arr) => arr.indexOf(id) === idx);
|
|
4605
|
+
return {
|
|
4606
|
+
kind: null,
|
|
4607
|
+
source: null,
|
|
4608
|
+
error: "multiple_order_kinds_selected",
|
|
4609
|
+
conflictingKinds: selectedKinds,
|
|
4610
|
+
conflictingNodeIds
|
|
4611
|
+
};
|
|
4612
|
+
}
|
|
4613
|
+
if (selectedKinds.length === 1) {
|
|
4614
|
+
const selectedKind = selectedKinds[0];
|
|
4615
|
+
return {
|
|
4616
|
+
kind: selectedKind,
|
|
4617
|
+
source: selectedKindToSource.get(selectedKind)
|
|
4618
|
+
};
|
|
4619
|
+
}
|
|
4620
|
+
const activeTagId = params.activeTagId;
|
|
4621
|
+
if (activeTagId) {
|
|
4622
|
+
const tagKind = orderKinds[activeTagId];
|
|
4623
|
+
if (typeof tagKind === "string") {
|
|
4624
|
+
return {
|
|
4625
|
+
kind: tagKind,
|
|
4626
|
+
source: { nodeId: activeTagId, nodeKind: "tag" }
|
|
4627
|
+
};
|
|
4628
|
+
}
|
|
4629
|
+
}
|
|
4630
|
+
return { kind: null, source: null };
|
|
4631
|
+
}
|
|
4632
|
+
|
|
4633
|
+
// src/core/validate/steps/order-kinds.ts
|
|
4634
|
+
function validateOrderKinds(v) {
|
|
4635
|
+
var _a, _b, _c;
|
|
4636
|
+
const selectedTriggerKeys = Array.from((_a = v.selectedKeys) != null ? _a : []);
|
|
4637
|
+
if (!selectedTriggerKeys.length) return;
|
|
4638
|
+
const resolved = resolveOrderKind({
|
|
4639
|
+
props: v.props,
|
|
4640
|
+
selectedTriggerKeys,
|
|
4641
|
+
nodeMap: v.nodeMap
|
|
4642
|
+
});
|
|
4643
|
+
if (resolved.error !== "multiple_order_kinds_selected") return;
|
|
4644
|
+
const conflicts = (_b = resolved.conflictingKinds) != null ? _b : [];
|
|
4645
|
+
const affected = (_c = resolved.conflictingNodeIds) != null ? _c : [];
|
|
4646
|
+
v.errors.push({
|
|
4647
|
+
code: "multiple_order_kinds_selected",
|
|
4648
|
+
severity: "error",
|
|
4649
|
+
message: "Multiple selected triggers resolve to different order kinds. Select triggers that resolve to a single order kind.",
|
|
4650
|
+
details: withAffected(
|
|
4651
|
+
{
|
|
4652
|
+
conflictingKinds: conflicts,
|
|
4653
|
+
conflictingNodeIds: affected
|
|
4654
|
+
},
|
|
4655
|
+
affected
|
|
4656
|
+
)
|
|
4657
|
+
});
|
|
4658
|
+
}
|
|
4659
|
+
|
|
4526
4660
|
// src/core/validate/steps/service-vs-input.ts
|
|
4527
4661
|
function validateServiceVsUserInput(v) {
|
|
4528
4662
|
for (const f of v.fields) {
|
|
@@ -5846,6 +5980,7 @@ var BuilderImpl = class {
|
|
|
5846
5980
|
const out = {
|
|
5847
5981
|
filters: this.props.filters.slice(),
|
|
5848
5982
|
fields,
|
|
5983
|
+
...this.props.orderKinds ? { orderKinds: this.props.orderKinds } : {},
|
|
5849
5984
|
...includes_for_buttons && { includes_for_buttons },
|
|
5850
5985
|
...excludes_for_buttons && { excludes_for_buttons },
|
|
5851
5986
|
schema_version: (_e = this.props.schema_version) != null ? _e : "1.0",
|
|
@@ -6178,6 +6313,7 @@ function validate(props, ctx = {}) {
|
|
|
6178
6313
|
validateStructure(v);
|
|
6179
6314
|
validateIdentity(v);
|
|
6180
6315
|
validateOptionMaps(v);
|
|
6316
|
+
validateOrderKinds(v);
|
|
6181
6317
|
v.fieldsVisibleUnder = createFieldsVisibleUnder(v);
|
|
6182
6318
|
const visSim = readVisibilitySimOpts(options);
|
|
6183
6319
|
validateVisibility(v, visSim);
|
|
@@ -6475,7 +6611,7 @@ function createNodeIndex(builder) {
|
|
|
6475
6611
|
for (const fieldId of visible) {
|
|
6476
6612
|
const node = getField(fieldId);
|
|
6477
6613
|
if (!node) continue;
|
|
6478
|
-
const explicit = includes.has(fieldId)
|
|
6614
|
+
const explicit = includes.has(fieldId);
|
|
6479
6615
|
results.push(explicit ? node : { ...node, isInherited: true });
|
|
6480
6616
|
}
|
|
6481
6617
|
return Object.freeze(results);
|
|
@@ -8100,6 +8236,88 @@ function normalizeQuantityRule(input) {
|
|
|
8100
8236
|
return out;
|
|
8101
8237
|
}
|
|
8102
8238
|
|
|
8239
|
+
// src/react/canvas/editor/editor-order-kinds.ts
|
|
8240
|
+
function normalizeKind(kind) {
|
|
8241
|
+
const next = String(kind != null ? kind : "").trim();
|
|
8242
|
+
if (!next) {
|
|
8243
|
+
throw new Error("setOrderKind: kind must be a non-empty string");
|
|
8244
|
+
}
|
|
8245
|
+
return next;
|
|
8246
|
+
}
|
|
8247
|
+
function assertCanonicalNodeId(ctx, nodeId) {
|
|
8248
|
+
const id = String(nodeId != null ? nodeId : "").trim();
|
|
8249
|
+
if (!id) throw new Error("setOrderKind: nodeId is required");
|
|
8250
|
+
if (id.includes("::")) {
|
|
8251
|
+
throw new Error(
|
|
8252
|
+
"setOrderKind: composite/internal trigger keys are not allowed; use canonical tag/field/option ids"
|
|
8253
|
+
);
|
|
8254
|
+
}
|
|
8255
|
+
if (!ctx.isTagId(id) && !ctx.isFieldId(id) && !ctx.isOptionId(id)) {
|
|
8256
|
+
throw new Error(
|
|
8257
|
+
`setOrderKind: node id '${id}' is not a known tag, field, or option`
|
|
8258
|
+
);
|
|
8259
|
+
}
|
|
8260
|
+
if (ctx.isFieldId(id)) {
|
|
8261
|
+
const node = ctx.getNode(id);
|
|
8262
|
+
if (node.kind !== "field" || !isActualButtonField(node.data)) {
|
|
8263
|
+
throw new Error(
|
|
8264
|
+
`setOrderKind: field '${id}' must be a button field without options`
|
|
8265
|
+
);
|
|
8266
|
+
}
|
|
8267
|
+
}
|
|
8268
|
+
}
|
|
8269
|
+
function setOrderKind(ctx, nodeId, kind) {
|
|
8270
|
+
const id = String(nodeId != null ? nodeId : "").trim();
|
|
8271
|
+
const nextKind = normalizeKind(kind);
|
|
8272
|
+
assertCanonicalNodeId(ctx, id);
|
|
8273
|
+
ctx.exec({
|
|
8274
|
+
name: "setOrderKind",
|
|
8275
|
+
do: () => ctx.patchProps((p) => {
|
|
8276
|
+
if (!p.orderKinds) p.orderKinds = {};
|
|
8277
|
+
p.orderKinds[id] = nextKind;
|
|
8278
|
+
}),
|
|
8279
|
+
undo: () => ctx.undo()
|
|
8280
|
+
});
|
|
8281
|
+
}
|
|
8282
|
+
function deleteOrderKind(ctx, nodeId) {
|
|
8283
|
+
const id = String(nodeId != null ? nodeId : "").trim();
|
|
8284
|
+
if (!id) return;
|
|
8285
|
+
ctx.exec({
|
|
8286
|
+
name: "deleteOrderKind",
|
|
8287
|
+
do: () => ctx.patchProps((p) => {
|
|
8288
|
+
if (!p.orderKinds || !Object.prototype.hasOwnProperty.call(p.orderKinds, id)) {
|
|
8289
|
+
return;
|
|
8290
|
+
}
|
|
8291
|
+
delete p.orderKinds[id];
|
|
8292
|
+
if (!Object.keys(p.orderKinds).length) {
|
|
8293
|
+
delete p.orderKinds;
|
|
8294
|
+
}
|
|
8295
|
+
}),
|
|
8296
|
+
undo: () => ctx.undo()
|
|
8297
|
+
});
|
|
8298
|
+
}
|
|
8299
|
+
function pruneOrderKind(ctx, kind) {
|
|
8300
|
+
const target = normalizeKind(kind);
|
|
8301
|
+
let removedCount = 0;
|
|
8302
|
+
ctx.exec({
|
|
8303
|
+
name: "pruneOrderKind",
|
|
8304
|
+
do: () => ctx.patchProps((p) => {
|
|
8305
|
+
if (!p.orderKinds) return;
|
|
8306
|
+
removedCount = 0;
|
|
8307
|
+
for (const [nodeId, mapped] of Object.entries(p.orderKinds)) {
|
|
8308
|
+
if (mapped !== target) continue;
|
|
8309
|
+
delete p.orderKinds[nodeId];
|
|
8310
|
+
removedCount++;
|
|
8311
|
+
}
|
|
8312
|
+
if (!Object.keys(p.orderKinds).length) {
|
|
8313
|
+
delete p.orderKinds;
|
|
8314
|
+
}
|
|
8315
|
+
}),
|
|
8316
|
+
undo: () => ctx.undo()
|
|
8317
|
+
});
|
|
8318
|
+
return removedCount;
|
|
8319
|
+
}
|
|
8320
|
+
|
|
8103
8321
|
// src/react/canvas/editor/editor-relations.ts
|
|
8104
8322
|
function wouldCreateTagCycle(_ctx, p, parentId, childId) {
|
|
8105
8323
|
var _a, _b;
|
|
@@ -8147,7 +8365,9 @@ function include(ctx, receiverId, idOrIds) {
|
|
|
8147
8365
|
const ids = Array.isArray(idOrIds) ? idOrIds : [idOrIds];
|
|
8148
8366
|
if (receiver.kind === "tag" || receiver.kind === "field" && isActualButtonField(receiver.data) || receiver.kind === "option") {
|
|
8149
8367
|
if (receiver.kind === "tag") {
|
|
8150
|
-
const t = ((_a = p.filters) != null ? _a : []).find(
|
|
8368
|
+
const t = ((_a = p.filters) != null ? _a : []).find(
|
|
8369
|
+
(x) => x.id === receiverId
|
|
8370
|
+
);
|
|
8151
8371
|
if (t) {
|
|
8152
8372
|
const accepted = [];
|
|
8153
8373
|
const next = new Set((_b = t.includes) != null ? _b : []);
|
|
@@ -8189,7 +8409,12 @@ function include(ctx, receiverId, idOrIds) {
|
|
|
8189
8409
|
const current = (_f = (_e = p.includes_for_buttons) == null ? void 0 : _e[receiverId]) != null ? _f : [];
|
|
8190
8410
|
const next = new Set(current);
|
|
8191
8411
|
for (const id of ids) {
|
|
8192
|
-
if (wouldCreateIncludeExcludeCycle(
|
|
8412
|
+
if (wouldCreateIncludeExcludeCycle(
|
|
8413
|
+
ctx,
|
|
8414
|
+
p,
|
|
8415
|
+
receiverId,
|
|
8416
|
+
id
|
|
8417
|
+
)) {
|
|
8193
8418
|
ctx.emit("editor:error", {
|
|
8194
8419
|
message: `Cycle detected: ${receiverId} including ${id} would create a cycle.`,
|
|
8195
8420
|
code: "cycle_detected",
|
|
@@ -8205,7 +8430,8 @@ function include(ctx, receiverId, idOrIds) {
|
|
|
8205
8430
|
accepted.push(id);
|
|
8206
8431
|
}
|
|
8207
8432
|
if (accepted.length > 0 || current.length > 0) {
|
|
8208
|
-
if (!p.includes_for_buttons)
|
|
8433
|
+
if (!p.includes_for_buttons)
|
|
8434
|
+
p.includes_for_buttons = {};
|
|
8209
8435
|
p.includes_for_buttons[receiverId] = Array.from(next);
|
|
8210
8436
|
}
|
|
8211
8437
|
if ((_g = p.excludes_for_buttons) == null ? void 0 : _g[receiverId]) {
|
|
@@ -8220,7 +8446,9 @@ function include(ctx, receiverId, idOrIds) {
|
|
|
8220
8446
|
if (!p.fields) p.fields = [];
|
|
8221
8447
|
if (!p.filters) p.filters = [];
|
|
8222
8448
|
} else {
|
|
8223
|
-
throw new Error(
|
|
8449
|
+
throw new Error(
|
|
8450
|
+
"Receiver must be a tag, button field, or option"
|
|
8451
|
+
);
|
|
8224
8452
|
}
|
|
8225
8453
|
}),
|
|
8226
8454
|
undo: () => ctx.undo()
|
|
@@ -8235,7 +8463,9 @@ function exclude(ctx, receiverId, idOrIds) {
|
|
|
8235
8463
|
const ids = Array.isArray(idOrIds) ? idOrIds : [idOrIds];
|
|
8236
8464
|
if (receiver.kind === "tag" || receiver.kind === "field" && isActualButtonField(receiver.data) || receiver.kind === "option") {
|
|
8237
8465
|
if (receiver.kind === "tag") {
|
|
8238
|
-
const t = ((_a = p.filters) != null ? _a : []).find(
|
|
8466
|
+
const t = ((_a = p.filters) != null ? _a : []).find(
|
|
8467
|
+
(x) => x.id === receiverId
|
|
8468
|
+
);
|
|
8239
8469
|
if (t) {
|
|
8240
8470
|
const accepted = [];
|
|
8241
8471
|
const next = new Set((_b = t.excludes) != null ? _b : []);
|
|
@@ -8277,7 +8507,12 @@ function exclude(ctx, receiverId, idOrIds) {
|
|
|
8277
8507
|
const current = (_f = (_e = p.excludes_for_buttons) == null ? void 0 : _e[receiverId]) != null ? _f : [];
|
|
8278
8508
|
const next = new Set(current);
|
|
8279
8509
|
for (const id of ids) {
|
|
8280
|
-
if (wouldCreateIncludeExcludeCycle(
|
|
8510
|
+
if (wouldCreateIncludeExcludeCycle(
|
|
8511
|
+
ctx,
|
|
8512
|
+
p,
|
|
8513
|
+
receiverId,
|
|
8514
|
+
id
|
|
8515
|
+
)) {
|
|
8281
8516
|
ctx.emit("editor:error", {
|
|
8282
8517
|
message: `Cycle detected: ${receiverId} excluding ${id} would create a cycle.`,
|
|
8283
8518
|
code: "cycle_detected",
|
|
@@ -8293,7 +8528,8 @@ function exclude(ctx, receiverId, idOrIds) {
|
|
|
8293
8528
|
accepted.push(id);
|
|
8294
8529
|
}
|
|
8295
8530
|
if (accepted.length > 0 || current.length > 0) {
|
|
8296
|
-
if (!p.excludes_for_buttons)
|
|
8531
|
+
if (!p.excludes_for_buttons)
|
|
8532
|
+
p.excludes_for_buttons = {};
|
|
8297
8533
|
p.excludes_for_buttons[receiverId] = Array.from(next);
|
|
8298
8534
|
}
|
|
8299
8535
|
if ((_g = p.includes_for_buttons) == null ? void 0 : _g[receiverId]) {
|
|
@@ -8308,7 +8544,9 @@ function exclude(ctx, receiverId, idOrIds) {
|
|
|
8308
8544
|
if (!p.fields) p.fields = [];
|
|
8309
8545
|
if (!p.filters) p.filters = [];
|
|
8310
8546
|
} else {
|
|
8311
|
-
throw new Error(
|
|
8547
|
+
throw new Error(
|
|
8548
|
+
"Receiver must be a tag, button field, or option"
|
|
8549
|
+
);
|
|
8312
8550
|
}
|
|
8313
8551
|
}),
|
|
8314
8552
|
undo: () => ctx.undo()
|
|
@@ -8318,87 +8556,98 @@ function connect(ctx, kind, fromId, toId2) {
|
|
|
8318
8556
|
ctx.exec({
|
|
8319
8557
|
name: `connect:${kind}`,
|
|
8320
8558
|
do: () => ctx.patchProps((p) => {
|
|
8321
|
-
var _a, _b, _c, _d, _e;
|
|
8559
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
8322
8560
|
if (kind === "bind") {
|
|
8323
8561
|
if (ctx.isTagId(fromId) && ctx.isTagId(toId2)) {
|
|
8324
8562
|
if (wouldCreateTagCycle(ctx, p, fromId, toId2)) {
|
|
8325
|
-
throw new Error(
|
|
8563
|
+
throw new Error(
|
|
8564
|
+
`bind would create a cycle: ${fromId} ? ${toId2}`
|
|
8565
|
+
);
|
|
8326
8566
|
}
|
|
8327
|
-
const child = ((_a = p.filters) != null ? _a : []).find(
|
|
8567
|
+
const child = ((_a = p.filters) != null ? _a : []).find(
|
|
8568
|
+
(t) => t.id === toId2
|
|
8569
|
+
);
|
|
8328
8570
|
if (child) child.bind_id = fromId;
|
|
8329
8571
|
return;
|
|
8330
8572
|
}
|
|
8331
8573
|
if (ctx.isTagId(fromId) && ctx.isFieldId(toId2) || ctx.isFieldId(fromId) && ctx.isTagId(toId2)) {
|
|
8332
8574
|
const fieldId = ctx.isFieldId(toId2) ? toId2 : fromId;
|
|
8333
8575
|
const tagId = ctx.isTagId(fromId) ? fromId : toId2;
|
|
8334
|
-
const f = ((_b = p.fields) != null ? _b : []).find(
|
|
8576
|
+
const f = ((_b = p.fields) != null ? _b : []).find(
|
|
8577
|
+
(x) => x.id === fieldId
|
|
8578
|
+
);
|
|
8335
8579
|
if (!f) return;
|
|
8336
8580
|
if (!f.bind_id) {
|
|
8337
8581
|
f.bind_id = tagId;
|
|
8338
8582
|
return;
|
|
8339
8583
|
}
|
|
8340
8584
|
if (typeof f.bind_id === "string") {
|
|
8341
|
-
if (f.bind_id !== tagId)
|
|
8585
|
+
if (f.bind_id !== tagId) {
|
|
8586
|
+
f.bind_id = [f.bind_id, tagId];
|
|
8587
|
+
}
|
|
8342
8588
|
return;
|
|
8343
8589
|
}
|
|
8344
|
-
if (!f.bind_id.includes(tagId))
|
|
8590
|
+
if (!f.bind_id.includes(tagId)) {
|
|
8591
|
+
f.bind_id.push(tagId);
|
|
8592
|
+
}
|
|
8345
8593
|
return;
|
|
8346
8594
|
}
|
|
8347
|
-
throw new Error(
|
|
8595
|
+
throw new Error(
|
|
8596
|
+
`bind: unsupported route ${fromId} ? ${toId2}`
|
|
8597
|
+
);
|
|
8348
8598
|
}
|
|
8349
8599
|
if (kind === "include" || kind === "exclude") {
|
|
8350
|
-
const
|
|
8600
|
+
const tagKey = kind === "include" ? "includes" : "excludes";
|
|
8601
|
+
const mapKey = kind === "include" ? "includes_for_buttons" : "excludes_for_buttons";
|
|
8351
8602
|
if (ctx.isTagId(fromId) && ctx.isFieldId(toId2)) {
|
|
8352
|
-
const t = ((_c = p.filters) != null ? _c : []).find(
|
|
8603
|
+
const t = ((_c = p.filters) != null ? _c : []).find(
|
|
8604
|
+
(x) => x.id === fromId
|
|
8605
|
+
);
|
|
8353
8606
|
if (!t) return;
|
|
8354
|
-
const arr = (_d = t[
|
|
8607
|
+
const arr = (_d = t[tagKey]) != null ? _d : t[tagKey] = [];
|
|
8355
8608
|
if (!arr.includes(toId2)) arr.push(toId2);
|
|
8356
8609
|
return;
|
|
8357
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
|
+
}
|
|
8358
8623
|
if (ctx.isOptionId(fromId) && ctx.isFieldId(toId2)) {
|
|
8359
|
-
|
|
8360
|
-
const maps = p[mapKey];
|
|
8361
|
-
const next = { ...maps != null ? maps : {} };
|
|
8362
|
-
const arr = (_e = next[fromId]) != null ? _e : [];
|
|
8363
|
-
if (!arr.includes(toId2)) arr.push(toId2);
|
|
8364
|
-
next[fromId] = arr;
|
|
8365
|
-
p[mapKey] = next;
|
|
8624
|
+
addMappedField(p, mapKey, fromId, toId2);
|
|
8366
8625
|
return;
|
|
8367
8626
|
}
|
|
8368
|
-
throw new Error(
|
|
8627
|
+
throw new Error(
|
|
8628
|
+
`${kind}: unsupported route ${fromId} ? ${toId2}`
|
|
8629
|
+
);
|
|
8369
8630
|
}
|
|
8370
8631
|
if (kind === "service") {
|
|
8371
8632
|
ensureServiceExists(ctx.opts, fromId);
|
|
8372
8633
|
if (toId2.startsWith("t:")) {
|
|
8373
|
-
|
|
8374
|
-
|
|
8375
|
-
do: () => ctx.patchProps((next) => {
|
|
8376
|
-
var _a2;
|
|
8377
|
-
const t = ((_a2 = next.filters) != null ? _a2 : []).find((x) => x.id === toId2);
|
|
8378
|
-
if (t) t.service_id = fromId;
|
|
8379
|
-
}),
|
|
8380
|
-
undo: () => ctx.undo()
|
|
8381
|
-
});
|
|
8634
|
+
const t = ((_f = p.filters) != null ? _f : []).find((x) => x.id === toId2);
|
|
8635
|
+
if (t) t.service_id = fromId;
|
|
8382
8636
|
return;
|
|
8383
8637
|
}
|
|
8384
8638
|
if (toId2.startsWith("o:")) {
|
|
8385
|
-
|
|
8386
|
-
|
|
8387
|
-
|
|
8388
|
-
|
|
8389
|
-
|
|
8390
|
-
|
|
8391
|
-
|
|
8392
|
-
o.service_id = fromId;
|
|
8393
|
-
return;
|
|
8394
|
-
}
|
|
8395
|
-
}
|
|
8396
|
-
}),
|
|
8397
|
-
undo: () => ctx.undo()
|
|
8398
|
-
});
|
|
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
|
+
}
|
|
8399
8646
|
return;
|
|
8400
8647
|
}
|
|
8401
|
-
throw new Error(
|
|
8648
|
+
throw new Error(
|
|
8649
|
+
'service: to must be a tag ("t:*") or option ("o:*")'
|
|
8650
|
+
);
|
|
8402
8651
|
}
|
|
8403
8652
|
throw new Error(`Unknown connect kind: ${kind}`);
|
|
8404
8653
|
}),
|
|
@@ -8409,90 +8658,109 @@ function disconnect(ctx, kind, fromId, toId2) {
|
|
|
8409
8658
|
ctx.exec({
|
|
8410
8659
|
name: `disconnect:${kind}`,
|
|
8411
8660
|
do: () => ctx.patchProps((p) => {
|
|
8412
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
8661
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
8413
8662
|
if (kind === "bind") {
|
|
8414
8663
|
if (ctx.isTagId(fromId) && ctx.isTagId(toId2)) {
|
|
8415
|
-
const child = ((_a = p.filters) != null ? _a : []).find(
|
|
8416
|
-
|
|
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
|
+
}
|
|
8417
8670
|
return;
|
|
8418
8671
|
}
|
|
8419
8672
|
if (ctx.isTagId(fromId) && ctx.isFieldId(toId2) || ctx.isFieldId(fromId) && ctx.isTagId(toId2)) {
|
|
8420
8673
|
const fieldId = ctx.isFieldId(toId2) ? toId2 : fromId;
|
|
8421
8674
|
const tagId = ctx.isTagId(fromId) ? fromId : toId2;
|
|
8422
|
-
const f = ((_b = p.fields) != null ? _b : []).find(
|
|
8675
|
+
const f = ((_b = p.fields) != null ? _b : []).find(
|
|
8676
|
+
(x) => x.id === fieldId
|
|
8677
|
+
);
|
|
8423
8678
|
if (!(f == null ? void 0 : f.bind_id)) return;
|
|
8424
8679
|
if (typeof f.bind_id === "string") {
|
|
8425
|
-
if (f.bind_id === tagId)
|
|
8680
|
+
if (f.bind_id === tagId) {
|
|
8681
|
+
delete f.bind_id;
|
|
8682
|
+
}
|
|
8426
8683
|
return;
|
|
8427
8684
|
}
|
|
8428
8685
|
f.bind_id = f.bind_id.filter((x) => x !== tagId);
|
|
8429
|
-
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
|
+
}
|
|
8430
8689
|
return;
|
|
8431
8690
|
}
|
|
8432
|
-
throw new Error(
|
|
8691
|
+
throw new Error(
|
|
8692
|
+
`unbind: unsupported route ${fromId} ? ${toId2}`
|
|
8693
|
+
);
|
|
8433
8694
|
}
|
|
8434
8695
|
if (kind === "include" || kind === "exclude") {
|
|
8435
|
-
const
|
|
8696
|
+
const tagKey = kind === "include" ? "includes" : "excludes";
|
|
8697
|
+
const mapKey = kind === "include" ? "includes_for_buttons" : "excludes_for_buttons";
|
|
8436
8698
|
if (ctx.isTagId(fromId) && ctx.isFieldId(toId2)) {
|
|
8437
|
-
const t = ((_d = p.filters) != null ? _d : []).find(
|
|
8699
|
+
const t = ((_d = p.filters) != null ? _d : []).find(
|
|
8700
|
+
(x) => x.id === fromId
|
|
8701
|
+
);
|
|
8438
8702
|
if (!t) return;
|
|
8439
|
-
t[
|
|
8440
|
-
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
|
+
}
|
|
8441
8707
|
return;
|
|
8442
8708
|
}
|
|
8443
|
-
if (ctx.isOptionId(fromId) && ctx.isFieldId(toId2)) {
|
|
8444
|
-
const mapKey = kind === "include" ? "includes_for_options" : "excludes_for_options";
|
|
8709
|
+
if ((ctx.isFieldId(fromId) || ctx.isOptionId(fromId)) && ctx.isFieldId(toId2)) {
|
|
8445
8710
|
const maps = p[mapKey];
|
|
8446
|
-
if (!maps) return;
|
|
8447
|
-
|
|
8448
|
-
|
|
8449
|
-
|
|
8450
|
-
|
|
8451
|
-
|
|
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];
|
|
8452
8720
|
}
|
|
8453
|
-
if (!Object.keys(maps).length) delete p[mapKey];
|
|
8454
8721
|
return;
|
|
8455
8722
|
}
|
|
8456
|
-
throw new Error(
|
|
8723
|
+
throw new Error(
|
|
8724
|
+
`${kind}: unsupported route ${fromId} ? ${toId2}`
|
|
8725
|
+
);
|
|
8457
8726
|
}
|
|
8458
8727
|
if (kind === "service") {
|
|
8459
8728
|
ensureServiceExists(ctx.opts, fromId);
|
|
8460
8729
|
if (toId2.startsWith("t:")) {
|
|
8461
|
-
|
|
8462
|
-
|
|
8463
|
-
|
|
8464
|
-
|
|
8465
|
-
const t = ((_a2 = next.filters) != null ? _a2 : []).find((x) => x.id === toId2);
|
|
8466
|
-
if (t) delete t.service_id;
|
|
8467
|
-
}),
|
|
8468
|
-
undo: () => ctx.undo()
|
|
8469
|
-
});
|
|
8730
|
+
const t = ((_h = p.filters) != null ? _h : []).find((x) => x.id === toId2);
|
|
8731
|
+
if (t) {
|
|
8732
|
+
delete t.service_id;
|
|
8733
|
+
}
|
|
8470
8734
|
return;
|
|
8471
8735
|
}
|
|
8472
8736
|
if (toId2.startsWith("o:")) {
|
|
8473
|
-
|
|
8474
|
-
|
|
8475
|
-
|
|
8476
|
-
|
|
8477
|
-
|
|
8478
|
-
|
|
8479
|
-
|
|
8480
|
-
delete o.service_id;
|
|
8481
|
-
return;
|
|
8482
|
-
}
|
|
8483
|
-
}
|
|
8484
|
-
}),
|
|
8485
|
-
undo: () => ctx.undo()
|
|
8486
|
-
});
|
|
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
|
+
}
|
|
8487
8744
|
return;
|
|
8488
8745
|
}
|
|
8489
|
-
throw new Error(
|
|
8746
|
+
throw new Error(
|
|
8747
|
+
'service: to must be a tag ("t:*") or option ("o:*")'
|
|
8748
|
+
);
|
|
8490
8749
|
}
|
|
8491
8750
|
throw new Error(`Unknown disconnect kind: ${kind}`);
|
|
8492
8751
|
}),
|
|
8493
8752
|
undo: () => ctx.undo()
|
|
8494
8753
|
});
|
|
8495
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
|
+
}
|
|
8496
8764
|
|
|
8497
8765
|
// src/react/canvas/editor/editor-service-filter.ts
|
|
8498
8766
|
function filterServicesForVisibleGroup2(ctx, candidates, input) {
|
|
@@ -9080,6 +9348,15 @@ var Editor = class {
|
|
|
9080
9348
|
clearFieldValidation(id) {
|
|
9081
9349
|
return clearFieldValidation(this.moduleCtx(), id);
|
|
9082
9350
|
}
|
|
9351
|
+
setOrderKind(nodeId, kind) {
|
|
9352
|
+
return setOrderKind(this.moduleCtx(), nodeId, kind);
|
|
9353
|
+
}
|
|
9354
|
+
deleteOrderKind(nodeId) {
|
|
9355
|
+
return deleteOrderKind(this.moduleCtx(), nodeId);
|
|
9356
|
+
}
|
|
9357
|
+
pruneKind(kind) {
|
|
9358
|
+
return pruneOrderKind(this.moduleCtx(), kind);
|
|
9359
|
+
}
|
|
9083
9360
|
getCatalog() {
|
|
9084
9361
|
return cloneDeep4(this.catalog);
|
|
9085
9362
|
}
|