@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/react/index.cjs
CHANGED
|
@@ -4019,7 +4019,7 @@ function createNodeIndex(builder) {
|
|
|
4019
4019
|
for (const fieldId of visible) {
|
|
4020
4020
|
const node = getField(fieldId);
|
|
4021
4021
|
if (!node) continue;
|
|
4022
|
-
const explicit = includes.has(fieldId)
|
|
4022
|
+
const explicit = includes.has(fieldId);
|
|
4023
4023
|
results.push(explicit ? node : { ...node, isInherited: true });
|
|
4024
4024
|
}
|
|
4025
4025
|
return Object.freeze(results);
|
|
@@ -7127,7 +7127,9 @@ function include(ctx, receiverId, idOrIds) {
|
|
|
7127
7127
|
const ids = Array.isArray(idOrIds) ? idOrIds : [idOrIds];
|
|
7128
7128
|
if (receiver.kind === "tag" || receiver.kind === "field" && isActualButtonField(receiver.data) || receiver.kind === "option") {
|
|
7129
7129
|
if (receiver.kind === "tag") {
|
|
7130
|
-
const t = ((_a = p.filters) != null ? _a : []).find(
|
|
7130
|
+
const t = ((_a = p.filters) != null ? _a : []).find(
|
|
7131
|
+
(x) => x.id === receiverId
|
|
7132
|
+
);
|
|
7131
7133
|
if (t) {
|
|
7132
7134
|
const accepted = [];
|
|
7133
7135
|
const next = new Set((_b = t.includes) != null ? _b : []);
|
|
@@ -7169,7 +7171,12 @@ function include(ctx, receiverId, idOrIds) {
|
|
|
7169
7171
|
const current = (_f = (_e = p.includes_for_buttons) == null ? void 0 : _e[receiverId]) != null ? _f : [];
|
|
7170
7172
|
const next = new Set(current);
|
|
7171
7173
|
for (const id of ids) {
|
|
7172
|
-
if (wouldCreateIncludeExcludeCycle(
|
|
7174
|
+
if (wouldCreateIncludeExcludeCycle(
|
|
7175
|
+
ctx,
|
|
7176
|
+
p,
|
|
7177
|
+
receiverId,
|
|
7178
|
+
id
|
|
7179
|
+
)) {
|
|
7173
7180
|
ctx.emit("editor:error", {
|
|
7174
7181
|
message: `Cycle detected: ${receiverId} including ${id} would create a cycle.`,
|
|
7175
7182
|
code: "cycle_detected",
|
|
@@ -7185,7 +7192,8 @@ function include(ctx, receiverId, idOrIds) {
|
|
|
7185
7192
|
accepted.push(id);
|
|
7186
7193
|
}
|
|
7187
7194
|
if (accepted.length > 0 || current.length > 0) {
|
|
7188
|
-
if (!p.includes_for_buttons)
|
|
7195
|
+
if (!p.includes_for_buttons)
|
|
7196
|
+
p.includes_for_buttons = {};
|
|
7189
7197
|
p.includes_for_buttons[receiverId] = Array.from(next);
|
|
7190
7198
|
}
|
|
7191
7199
|
if ((_g = p.excludes_for_buttons) == null ? void 0 : _g[receiverId]) {
|
|
@@ -7200,7 +7208,9 @@ function include(ctx, receiverId, idOrIds) {
|
|
|
7200
7208
|
if (!p.fields) p.fields = [];
|
|
7201
7209
|
if (!p.filters) p.filters = [];
|
|
7202
7210
|
} else {
|
|
7203
|
-
throw new Error(
|
|
7211
|
+
throw new Error(
|
|
7212
|
+
"Receiver must be a tag, button field, or option"
|
|
7213
|
+
);
|
|
7204
7214
|
}
|
|
7205
7215
|
}),
|
|
7206
7216
|
undo: () => ctx.undo()
|
|
@@ -7215,7 +7225,9 @@ function exclude(ctx, receiverId, idOrIds) {
|
|
|
7215
7225
|
const ids = Array.isArray(idOrIds) ? idOrIds : [idOrIds];
|
|
7216
7226
|
if (receiver.kind === "tag" || receiver.kind === "field" && isActualButtonField(receiver.data) || receiver.kind === "option") {
|
|
7217
7227
|
if (receiver.kind === "tag") {
|
|
7218
|
-
const t = ((_a = p.filters) != null ? _a : []).find(
|
|
7228
|
+
const t = ((_a = p.filters) != null ? _a : []).find(
|
|
7229
|
+
(x) => x.id === receiverId
|
|
7230
|
+
);
|
|
7219
7231
|
if (t) {
|
|
7220
7232
|
const accepted = [];
|
|
7221
7233
|
const next = new Set((_b = t.excludes) != null ? _b : []);
|
|
@@ -7257,7 +7269,12 @@ function exclude(ctx, receiverId, idOrIds) {
|
|
|
7257
7269
|
const current = (_f = (_e = p.excludes_for_buttons) == null ? void 0 : _e[receiverId]) != null ? _f : [];
|
|
7258
7270
|
const next = new Set(current);
|
|
7259
7271
|
for (const id of ids) {
|
|
7260
|
-
if (wouldCreateIncludeExcludeCycle(
|
|
7272
|
+
if (wouldCreateIncludeExcludeCycle(
|
|
7273
|
+
ctx,
|
|
7274
|
+
p,
|
|
7275
|
+
receiverId,
|
|
7276
|
+
id
|
|
7277
|
+
)) {
|
|
7261
7278
|
ctx.emit("editor:error", {
|
|
7262
7279
|
message: `Cycle detected: ${receiverId} excluding ${id} would create a cycle.`,
|
|
7263
7280
|
code: "cycle_detected",
|
|
@@ -7273,7 +7290,8 @@ function exclude(ctx, receiverId, idOrIds) {
|
|
|
7273
7290
|
accepted.push(id);
|
|
7274
7291
|
}
|
|
7275
7292
|
if (accepted.length > 0 || current.length > 0) {
|
|
7276
|
-
if (!p.excludes_for_buttons)
|
|
7293
|
+
if (!p.excludes_for_buttons)
|
|
7294
|
+
p.excludes_for_buttons = {};
|
|
7277
7295
|
p.excludes_for_buttons[receiverId] = Array.from(next);
|
|
7278
7296
|
}
|
|
7279
7297
|
if ((_g = p.includes_for_buttons) == null ? void 0 : _g[receiverId]) {
|
|
@@ -7288,7 +7306,9 @@ function exclude(ctx, receiverId, idOrIds) {
|
|
|
7288
7306
|
if (!p.fields) p.fields = [];
|
|
7289
7307
|
if (!p.filters) p.filters = [];
|
|
7290
7308
|
} else {
|
|
7291
|
-
throw new Error(
|
|
7309
|
+
throw new Error(
|
|
7310
|
+
"Receiver must be a tag, button field, or option"
|
|
7311
|
+
);
|
|
7292
7312
|
}
|
|
7293
7313
|
}),
|
|
7294
7314
|
undo: () => ctx.undo()
|
|
@@ -7298,87 +7318,98 @@ function connect(ctx, kind, fromId, toId2) {
|
|
|
7298
7318
|
ctx.exec({
|
|
7299
7319
|
name: `connect:${kind}`,
|
|
7300
7320
|
do: () => ctx.patchProps((p) => {
|
|
7301
|
-
var _a, _b, _c, _d, _e;
|
|
7321
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
7302
7322
|
if (kind === "bind") {
|
|
7303
7323
|
if (ctx.isTagId(fromId) && ctx.isTagId(toId2)) {
|
|
7304
7324
|
if (wouldCreateTagCycle(ctx, p, fromId, toId2)) {
|
|
7305
|
-
throw new Error(
|
|
7325
|
+
throw new Error(
|
|
7326
|
+
`bind would create a cycle: ${fromId} ? ${toId2}`
|
|
7327
|
+
);
|
|
7306
7328
|
}
|
|
7307
|
-
const child = ((_a = p.filters) != null ? _a : []).find(
|
|
7329
|
+
const child = ((_a = p.filters) != null ? _a : []).find(
|
|
7330
|
+
(t) => t.id === toId2
|
|
7331
|
+
);
|
|
7308
7332
|
if (child) child.bind_id = fromId;
|
|
7309
7333
|
return;
|
|
7310
7334
|
}
|
|
7311
7335
|
if (ctx.isTagId(fromId) && ctx.isFieldId(toId2) || ctx.isFieldId(fromId) && ctx.isTagId(toId2)) {
|
|
7312
7336
|
const fieldId = ctx.isFieldId(toId2) ? toId2 : fromId;
|
|
7313
7337
|
const tagId = ctx.isTagId(fromId) ? fromId : toId2;
|
|
7314
|
-
const f = ((_b = p.fields) != null ? _b : []).find(
|
|
7338
|
+
const f = ((_b = p.fields) != null ? _b : []).find(
|
|
7339
|
+
(x) => x.id === fieldId
|
|
7340
|
+
);
|
|
7315
7341
|
if (!f) return;
|
|
7316
7342
|
if (!f.bind_id) {
|
|
7317
7343
|
f.bind_id = tagId;
|
|
7318
7344
|
return;
|
|
7319
7345
|
}
|
|
7320
7346
|
if (typeof f.bind_id === "string") {
|
|
7321
|
-
if (f.bind_id !== tagId)
|
|
7347
|
+
if (f.bind_id !== tagId) {
|
|
7348
|
+
f.bind_id = [f.bind_id, tagId];
|
|
7349
|
+
}
|
|
7322
7350
|
return;
|
|
7323
7351
|
}
|
|
7324
|
-
if (!f.bind_id.includes(tagId))
|
|
7352
|
+
if (!f.bind_id.includes(tagId)) {
|
|
7353
|
+
f.bind_id.push(tagId);
|
|
7354
|
+
}
|
|
7325
7355
|
return;
|
|
7326
7356
|
}
|
|
7327
|
-
throw new Error(
|
|
7357
|
+
throw new Error(
|
|
7358
|
+
`bind: unsupported route ${fromId} ? ${toId2}`
|
|
7359
|
+
);
|
|
7328
7360
|
}
|
|
7329
7361
|
if (kind === "include" || kind === "exclude") {
|
|
7330
|
-
const
|
|
7362
|
+
const tagKey = kind === "include" ? "includes" : "excludes";
|
|
7363
|
+
const mapKey = kind === "include" ? "includes_for_buttons" : "excludes_for_buttons";
|
|
7331
7364
|
if (ctx.isTagId(fromId) && ctx.isFieldId(toId2)) {
|
|
7332
|
-
const t = ((_c = p.filters) != null ? _c : []).find(
|
|
7365
|
+
const t = ((_c = p.filters) != null ? _c : []).find(
|
|
7366
|
+
(x) => x.id === fromId
|
|
7367
|
+
);
|
|
7333
7368
|
if (!t) return;
|
|
7334
|
-
const arr = (_d = t[
|
|
7369
|
+
const arr = (_d = t[tagKey]) != null ? _d : t[tagKey] = [];
|
|
7335
7370
|
if (!arr.includes(toId2)) arr.push(toId2);
|
|
7336
7371
|
return;
|
|
7337
7372
|
}
|
|
7373
|
+
if (ctx.isFieldId(fromId) && ctx.isFieldId(toId2)) {
|
|
7374
|
+
const source = ((_e = p.fields) != null ? _e : []).find(
|
|
7375
|
+
(x) => x.id === fromId
|
|
7376
|
+
);
|
|
7377
|
+
if (!(source == null ? void 0 : source.button)) {
|
|
7378
|
+
throw new Error(
|
|
7379
|
+
`${kind}: source field must be button=true: ${fromId} ? ${toId2}`
|
|
7380
|
+
);
|
|
7381
|
+
}
|
|
7382
|
+
addMappedField(p, mapKey, fromId, toId2);
|
|
7383
|
+
return;
|
|
7384
|
+
}
|
|
7338
7385
|
if (ctx.isOptionId(fromId) && ctx.isFieldId(toId2)) {
|
|
7339
|
-
|
|
7340
|
-
const maps = p[mapKey];
|
|
7341
|
-
const next = { ...maps != null ? maps : {} };
|
|
7342
|
-
const arr = (_e = next[fromId]) != null ? _e : [];
|
|
7343
|
-
if (!arr.includes(toId2)) arr.push(toId2);
|
|
7344
|
-
next[fromId] = arr;
|
|
7345
|
-
p[mapKey] = next;
|
|
7386
|
+
addMappedField(p, mapKey, fromId, toId2);
|
|
7346
7387
|
return;
|
|
7347
7388
|
}
|
|
7348
|
-
throw new Error(
|
|
7389
|
+
throw new Error(
|
|
7390
|
+
`${kind}: unsupported route ${fromId} ? ${toId2}`
|
|
7391
|
+
);
|
|
7349
7392
|
}
|
|
7350
7393
|
if (kind === "service") {
|
|
7351
7394
|
ensureServiceExists(ctx.opts, fromId);
|
|
7352
7395
|
if (toId2.startsWith("t:")) {
|
|
7353
|
-
|
|
7354
|
-
|
|
7355
|
-
do: () => ctx.patchProps((next) => {
|
|
7356
|
-
var _a2;
|
|
7357
|
-
const t = ((_a2 = next.filters) != null ? _a2 : []).find((x) => x.id === toId2);
|
|
7358
|
-
if (t) t.service_id = fromId;
|
|
7359
|
-
}),
|
|
7360
|
-
undo: () => ctx.undo()
|
|
7361
|
-
});
|
|
7396
|
+
const t = ((_f = p.filters) != null ? _f : []).find((x) => x.id === toId2);
|
|
7397
|
+
if (t) t.service_id = fromId;
|
|
7362
7398
|
return;
|
|
7363
7399
|
}
|
|
7364
7400
|
if (toId2.startsWith("o:")) {
|
|
7365
|
-
|
|
7366
|
-
|
|
7367
|
-
|
|
7368
|
-
|
|
7369
|
-
|
|
7370
|
-
|
|
7371
|
-
|
|
7372
|
-
o.service_id = fromId;
|
|
7373
|
-
return;
|
|
7374
|
-
}
|
|
7375
|
-
}
|
|
7376
|
-
}),
|
|
7377
|
-
undo: () => ctx.undo()
|
|
7378
|
-
});
|
|
7401
|
+
for (const f of (_g = p.fields) != null ? _g : []) {
|
|
7402
|
+
const o = (_h = f.options) == null ? void 0 : _h.find((x) => x.id === toId2);
|
|
7403
|
+
if (o) {
|
|
7404
|
+
o.service_id = fromId;
|
|
7405
|
+
return;
|
|
7406
|
+
}
|
|
7407
|
+
}
|
|
7379
7408
|
return;
|
|
7380
7409
|
}
|
|
7381
|
-
throw new Error(
|
|
7410
|
+
throw new Error(
|
|
7411
|
+
'service: to must be a tag ("t:*") or option ("o:*")'
|
|
7412
|
+
);
|
|
7382
7413
|
}
|
|
7383
7414
|
throw new Error(`Unknown connect kind: ${kind}`);
|
|
7384
7415
|
}),
|
|
@@ -7389,90 +7420,109 @@ function disconnect(ctx, kind, fromId, toId2) {
|
|
|
7389
7420
|
ctx.exec({
|
|
7390
7421
|
name: `disconnect:${kind}`,
|
|
7391
7422
|
do: () => ctx.patchProps((p) => {
|
|
7392
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
7423
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
7393
7424
|
if (kind === "bind") {
|
|
7394
7425
|
if (ctx.isTagId(fromId) && ctx.isTagId(toId2)) {
|
|
7395
|
-
const child = ((_a = p.filters) != null ? _a : []).find(
|
|
7396
|
-
|
|
7426
|
+
const child = ((_a = p.filters) != null ? _a : []).find(
|
|
7427
|
+
(t) => t.id === toId2
|
|
7428
|
+
);
|
|
7429
|
+
if ((child == null ? void 0 : child.bind_id) === fromId) {
|
|
7430
|
+
delete child.bind_id;
|
|
7431
|
+
}
|
|
7397
7432
|
return;
|
|
7398
7433
|
}
|
|
7399
7434
|
if (ctx.isTagId(fromId) && ctx.isFieldId(toId2) || ctx.isFieldId(fromId) && ctx.isTagId(toId2)) {
|
|
7400
7435
|
const fieldId = ctx.isFieldId(toId2) ? toId2 : fromId;
|
|
7401
7436
|
const tagId = ctx.isTagId(fromId) ? fromId : toId2;
|
|
7402
|
-
const f = ((_b = p.fields) != null ? _b : []).find(
|
|
7437
|
+
const f = ((_b = p.fields) != null ? _b : []).find(
|
|
7438
|
+
(x) => x.id === fieldId
|
|
7439
|
+
);
|
|
7403
7440
|
if (!(f == null ? void 0 : f.bind_id)) return;
|
|
7404
7441
|
if (typeof f.bind_id === "string") {
|
|
7405
|
-
if (f.bind_id === tagId)
|
|
7442
|
+
if (f.bind_id === tagId) {
|
|
7443
|
+
delete f.bind_id;
|
|
7444
|
+
}
|
|
7406
7445
|
return;
|
|
7407
7446
|
}
|
|
7408
7447
|
f.bind_id = f.bind_id.filter((x) => x !== tagId);
|
|
7409
|
-
if (((_c = f.bind_id) == null ? void 0 : _c.length) === 0)
|
|
7448
|
+
if (((_c = f.bind_id) == null ? void 0 : _c.length) === 0) {
|
|
7449
|
+
delete f.bind_id;
|
|
7450
|
+
}
|
|
7410
7451
|
return;
|
|
7411
7452
|
}
|
|
7412
|
-
throw new Error(
|
|
7453
|
+
throw new Error(
|
|
7454
|
+
`unbind: unsupported route ${fromId} ? ${toId2}`
|
|
7455
|
+
);
|
|
7413
7456
|
}
|
|
7414
7457
|
if (kind === "include" || kind === "exclude") {
|
|
7415
|
-
const
|
|
7458
|
+
const tagKey = kind === "include" ? "includes" : "excludes";
|
|
7459
|
+
const mapKey = kind === "include" ? "includes_for_buttons" : "excludes_for_buttons";
|
|
7416
7460
|
if (ctx.isTagId(fromId) && ctx.isFieldId(toId2)) {
|
|
7417
|
-
const t = ((_d = p.filters) != null ? _d : []).find(
|
|
7461
|
+
const t = ((_d = p.filters) != null ? _d : []).find(
|
|
7462
|
+
(x) => x.id === fromId
|
|
7463
|
+
);
|
|
7418
7464
|
if (!t) return;
|
|
7419
|
-
t[
|
|
7420
|
-
if (!((_f = t[
|
|
7465
|
+
t[tagKey] = ((_e = t[tagKey]) != null ? _e : []).filter((x) => x !== toId2);
|
|
7466
|
+
if (!((_f = t[tagKey]) == null ? void 0 : _f.length)) {
|
|
7467
|
+
delete t[tagKey];
|
|
7468
|
+
}
|
|
7421
7469
|
return;
|
|
7422
7470
|
}
|
|
7423
|
-
if (ctx.isOptionId(fromId) && ctx.isFieldId(toId2)) {
|
|
7424
|
-
const mapKey = kind === "include" ? "includes_for_options" : "excludes_for_options";
|
|
7471
|
+
if ((ctx.isFieldId(fromId) || ctx.isOptionId(fromId)) && ctx.isFieldId(toId2)) {
|
|
7425
7472
|
const maps = p[mapKey];
|
|
7426
|
-
if (!maps) return;
|
|
7427
|
-
|
|
7428
|
-
|
|
7429
|
-
|
|
7430
|
-
|
|
7431
|
-
|
|
7473
|
+
if (!(maps == null ? void 0 : maps[fromId])) return;
|
|
7474
|
+
maps[fromId] = maps[fromId].filter(
|
|
7475
|
+
(fid) => fid !== toId2
|
|
7476
|
+
);
|
|
7477
|
+
if (!((_g = maps[fromId]) == null ? void 0 : _g.length)) {
|
|
7478
|
+
delete maps[fromId];
|
|
7479
|
+
}
|
|
7480
|
+
if (!Object.keys(maps).length) {
|
|
7481
|
+
delete p[mapKey];
|
|
7432
7482
|
}
|
|
7433
|
-
if (!Object.keys(maps).length) delete p[mapKey];
|
|
7434
7483
|
return;
|
|
7435
7484
|
}
|
|
7436
|
-
throw new Error(
|
|
7485
|
+
throw new Error(
|
|
7486
|
+
`${kind}: unsupported route ${fromId} ? ${toId2}`
|
|
7487
|
+
);
|
|
7437
7488
|
}
|
|
7438
7489
|
if (kind === "service") {
|
|
7439
7490
|
ensureServiceExists(ctx.opts, fromId);
|
|
7440
7491
|
if (toId2.startsWith("t:")) {
|
|
7441
|
-
|
|
7442
|
-
|
|
7443
|
-
|
|
7444
|
-
|
|
7445
|
-
const t = ((_a2 = next.filters) != null ? _a2 : []).find((x) => x.id === toId2);
|
|
7446
|
-
if (t) delete t.service_id;
|
|
7447
|
-
}),
|
|
7448
|
-
undo: () => ctx.undo()
|
|
7449
|
-
});
|
|
7492
|
+
const t = ((_h = p.filters) != null ? _h : []).find((x) => x.id === toId2);
|
|
7493
|
+
if (t) {
|
|
7494
|
+
delete t.service_id;
|
|
7495
|
+
}
|
|
7450
7496
|
return;
|
|
7451
7497
|
}
|
|
7452
7498
|
if (toId2.startsWith("o:")) {
|
|
7453
|
-
|
|
7454
|
-
|
|
7455
|
-
|
|
7456
|
-
|
|
7457
|
-
|
|
7458
|
-
|
|
7459
|
-
|
|
7460
|
-
delete o.service_id;
|
|
7461
|
-
return;
|
|
7462
|
-
}
|
|
7463
|
-
}
|
|
7464
|
-
}),
|
|
7465
|
-
undo: () => ctx.undo()
|
|
7466
|
-
});
|
|
7499
|
+
for (const f of (_i = p.fields) != null ? _i : []) {
|
|
7500
|
+
const o = (_j = f.options) == null ? void 0 : _j.find((x) => x.id === toId2);
|
|
7501
|
+
if (o) {
|
|
7502
|
+
delete o.service_id;
|
|
7503
|
+
return;
|
|
7504
|
+
}
|
|
7505
|
+
}
|
|
7467
7506
|
return;
|
|
7468
7507
|
}
|
|
7469
|
-
throw new Error(
|
|
7508
|
+
throw new Error(
|
|
7509
|
+
'service: to must be a tag ("t:*") or option ("o:*")'
|
|
7510
|
+
);
|
|
7470
7511
|
}
|
|
7471
7512
|
throw new Error(`Unknown disconnect kind: ${kind}`);
|
|
7472
7513
|
}),
|
|
7473
7514
|
undo: () => ctx.undo()
|
|
7474
7515
|
});
|
|
7475
7516
|
}
|
|
7517
|
+
function addMappedField(p, mapKey, fromId, toId2) {
|
|
7518
|
+
var _a, _b;
|
|
7519
|
+
const maps = (_a = p[mapKey]) != null ? _a : {};
|
|
7520
|
+
const arr = (_b = maps[fromId]) != null ? _b : [];
|
|
7521
|
+
if (!arr.includes(toId2)) {
|
|
7522
|
+
maps[fromId] = [...arr, toId2];
|
|
7523
|
+
}
|
|
7524
|
+
p[mapKey] = maps;
|
|
7525
|
+
}
|
|
7476
7526
|
|
|
7477
7527
|
// src/react/canvas/editor/editor-service-filter.ts
|
|
7478
7528
|
function filterServicesForVisibleGroup2(ctx, candidates, input) {
|