@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.js
CHANGED
|
@@ -3955,7 +3955,7 @@ function createNodeIndex(builder) {
|
|
|
3955
3955
|
for (const fieldId of visible) {
|
|
3956
3956
|
const node = getField(fieldId);
|
|
3957
3957
|
if (!node) continue;
|
|
3958
|
-
const explicit = includes.has(fieldId)
|
|
3958
|
+
const explicit = includes.has(fieldId);
|
|
3959
3959
|
results.push(explicit ? node : { ...node, isInherited: true });
|
|
3960
3960
|
}
|
|
3961
3961
|
return Object.freeze(results);
|
|
@@ -7063,7 +7063,9 @@ function include(ctx, receiverId, idOrIds) {
|
|
|
7063
7063
|
const ids = Array.isArray(idOrIds) ? idOrIds : [idOrIds];
|
|
7064
7064
|
if (receiver.kind === "tag" || receiver.kind === "field" && isActualButtonField(receiver.data) || receiver.kind === "option") {
|
|
7065
7065
|
if (receiver.kind === "tag") {
|
|
7066
|
-
const t = ((_a = p.filters) != null ? _a : []).find(
|
|
7066
|
+
const t = ((_a = p.filters) != null ? _a : []).find(
|
|
7067
|
+
(x) => x.id === receiverId
|
|
7068
|
+
);
|
|
7067
7069
|
if (t) {
|
|
7068
7070
|
const accepted = [];
|
|
7069
7071
|
const next = new Set((_b = t.includes) != null ? _b : []);
|
|
@@ -7105,7 +7107,12 @@ function include(ctx, receiverId, idOrIds) {
|
|
|
7105
7107
|
const current = (_f = (_e = p.includes_for_buttons) == null ? void 0 : _e[receiverId]) != null ? _f : [];
|
|
7106
7108
|
const next = new Set(current);
|
|
7107
7109
|
for (const id of ids) {
|
|
7108
|
-
if (wouldCreateIncludeExcludeCycle(
|
|
7110
|
+
if (wouldCreateIncludeExcludeCycle(
|
|
7111
|
+
ctx,
|
|
7112
|
+
p,
|
|
7113
|
+
receiverId,
|
|
7114
|
+
id
|
|
7115
|
+
)) {
|
|
7109
7116
|
ctx.emit("editor:error", {
|
|
7110
7117
|
message: `Cycle detected: ${receiverId} including ${id} would create a cycle.`,
|
|
7111
7118
|
code: "cycle_detected",
|
|
@@ -7121,7 +7128,8 @@ function include(ctx, receiverId, idOrIds) {
|
|
|
7121
7128
|
accepted.push(id);
|
|
7122
7129
|
}
|
|
7123
7130
|
if (accepted.length > 0 || current.length > 0) {
|
|
7124
|
-
if (!p.includes_for_buttons)
|
|
7131
|
+
if (!p.includes_for_buttons)
|
|
7132
|
+
p.includes_for_buttons = {};
|
|
7125
7133
|
p.includes_for_buttons[receiverId] = Array.from(next);
|
|
7126
7134
|
}
|
|
7127
7135
|
if ((_g = p.excludes_for_buttons) == null ? void 0 : _g[receiverId]) {
|
|
@@ -7136,7 +7144,9 @@ function include(ctx, receiverId, idOrIds) {
|
|
|
7136
7144
|
if (!p.fields) p.fields = [];
|
|
7137
7145
|
if (!p.filters) p.filters = [];
|
|
7138
7146
|
} else {
|
|
7139
|
-
throw new Error(
|
|
7147
|
+
throw new Error(
|
|
7148
|
+
"Receiver must be a tag, button field, or option"
|
|
7149
|
+
);
|
|
7140
7150
|
}
|
|
7141
7151
|
}),
|
|
7142
7152
|
undo: () => ctx.undo()
|
|
@@ -7151,7 +7161,9 @@ function exclude(ctx, receiverId, idOrIds) {
|
|
|
7151
7161
|
const ids = Array.isArray(idOrIds) ? idOrIds : [idOrIds];
|
|
7152
7162
|
if (receiver.kind === "tag" || receiver.kind === "field" && isActualButtonField(receiver.data) || receiver.kind === "option") {
|
|
7153
7163
|
if (receiver.kind === "tag") {
|
|
7154
|
-
const t = ((_a = p.filters) != null ? _a : []).find(
|
|
7164
|
+
const t = ((_a = p.filters) != null ? _a : []).find(
|
|
7165
|
+
(x) => x.id === receiverId
|
|
7166
|
+
);
|
|
7155
7167
|
if (t) {
|
|
7156
7168
|
const accepted = [];
|
|
7157
7169
|
const next = new Set((_b = t.excludes) != null ? _b : []);
|
|
@@ -7193,7 +7205,12 @@ function exclude(ctx, receiverId, idOrIds) {
|
|
|
7193
7205
|
const current = (_f = (_e = p.excludes_for_buttons) == null ? void 0 : _e[receiverId]) != null ? _f : [];
|
|
7194
7206
|
const next = new Set(current);
|
|
7195
7207
|
for (const id of ids) {
|
|
7196
|
-
if (wouldCreateIncludeExcludeCycle(
|
|
7208
|
+
if (wouldCreateIncludeExcludeCycle(
|
|
7209
|
+
ctx,
|
|
7210
|
+
p,
|
|
7211
|
+
receiverId,
|
|
7212
|
+
id
|
|
7213
|
+
)) {
|
|
7197
7214
|
ctx.emit("editor:error", {
|
|
7198
7215
|
message: `Cycle detected: ${receiverId} excluding ${id} would create a cycle.`,
|
|
7199
7216
|
code: "cycle_detected",
|
|
@@ -7209,7 +7226,8 @@ function exclude(ctx, receiverId, idOrIds) {
|
|
|
7209
7226
|
accepted.push(id);
|
|
7210
7227
|
}
|
|
7211
7228
|
if (accepted.length > 0 || current.length > 0) {
|
|
7212
|
-
if (!p.excludes_for_buttons)
|
|
7229
|
+
if (!p.excludes_for_buttons)
|
|
7230
|
+
p.excludes_for_buttons = {};
|
|
7213
7231
|
p.excludes_for_buttons[receiverId] = Array.from(next);
|
|
7214
7232
|
}
|
|
7215
7233
|
if ((_g = p.includes_for_buttons) == null ? void 0 : _g[receiverId]) {
|
|
@@ -7224,7 +7242,9 @@ function exclude(ctx, receiverId, idOrIds) {
|
|
|
7224
7242
|
if (!p.fields) p.fields = [];
|
|
7225
7243
|
if (!p.filters) p.filters = [];
|
|
7226
7244
|
} else {
|
|
7227
|
-
throw new Error(
|
|
7245
|
+
throw new Error(
|
|
7246
|
+
"Receiver must be a tag, button field, or option"
|
|
7247
|
+
);
|
|
7228
7248
|
}
|
|
7229
7249
|
}),
|
|
7230
7250
|
undo: () => ctx.undo()
|
|
@@ -7234,87 +7254,98 @@ function connect(ctx, kind, fromId, toId2) {
|
|
|
7234
7254
|
ctx.exec({
|
|
7235
7255
|
name: `connect:${kind}`,
|
|
7236
7256
|
do: () => ctx.patchProps((p) => {
|
|
7237
|
-
var _a, _b, _c, _d, _e;
|
|
7257
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
7238
7258
|
if (kind === "bind") {
|
|
7239
7259
|
if (ctx.isTagId(fromId) && ctx.isTagId(toId2)) {
|
|
7240
7260
|
if (wouldCreateTagCycle(ctx, p, fromId, toId2)) {
|
|
7241
|
-
throw new Error(
|
|
7261
|
+
throw new Error(
|
|
7262
|
+
`bind would create a cycle: ${fromId} ? ${toId2}`
|
|
7263
|
+
);
|
|
7242
7264
|
}
|
|
7243
|
-
const child = ((_a = p.filters) != null ? _a : []).find(
|
|
7265
|
+
const child = ((_a = p.filters) != null ? _a : []).find(
|
|
7266
|
+
(t) => t.id === toId2
|
|
7267
|
+
);
|
|
7244
7268
|
if (child) child.bind_id = fromId;
|
|
7245
7269
|
return;
|
|
7246
7270
|
}
|
|
7247
7271
|
if (ctx.isTagId(fromId) && ctx.isFieldId(toId2) || ctx.isFieldId(fromId) && ctx.isTagId(toId2)) {
|
|
7248
7272
|
const fieldId = ctx.isFieldId(toId2) ? toId2 : fromId;
|
|
7249
7273
|
const tagId = ctx.isTagId(fromId) ? fromId : toId2;
|
|
7250
|
-
const f = ((_b = p.fields) != null ? _b : []).find(
|
|
7274
|
+
const f = ((_b = p.fields) != null ? _b : []).find(
|
|
7275
|
+
(x) => x.id === fieldId
|
|
7276
|
+
);
|
|
7251
7277
|
if (!f) return;
|
|
7252
7278
|
if (!f.bind_id) {
|
|
7253
7279
|
f.bind_id = tagId;
|
|
7254
7280
|
return;
|
|
7255
7281
|
}
|
|
7256
7282
|
if (typeof f.bind_id === "string") {
|
|
7257
|
-
if (f.bind_id !== tagId)
|
|
7283
|
+
if (f.bind_id !== tagId) {
|
|
7284
|
+
f.bind_id = [f.bind_id, tagId];
|
|
7285
|
+
}
|
|
7258
7286
|
return;
|
|
7259
7287
|
}
|
|
7260
|
-
if (!f.bind_id.includes(tagId))
|
|
7288
|
+
if (!f.bind_id.includes(tagId)) {
|
|
7289
|
+
f.bind_id.push(tagId);
|
|
7290
|
+
}
|
|
7261
7291
|
return;
|
|
7262
7292
|
}
|
|
7263
|
-
throw new Error(
|
|
7293
|
+
throw new Error(
|
|
7294
|
+
`bind: unsupported route ${fromId} ? ${toId2}`
|
|
7295
|
+
);
|
|
7264
7296
|
}
|
|
7265
7297
|
if (kind === "include" || kind === "exclude") {
|
|
7266
|
-
const
|
|
7298
|
+
const tagKey = kind === "include" ? "includes" : "excludes";
|
|
7299
|
+
const mapKey = kind === "include" ? "includes_for_buttons" : "excludes_for_buttons";
|
|
7267
7300
|
if (ctx.isTagId(fromId) && ctx.isFieldId(toId2)) {
|
|
7268
|
-
const t = ((_c = p.filters) != null ? _c : []).find(
|
|
7301
|
+
const t = ((_c = p.filters) != null ? _c : []).find(
|
|
7302
|
+
(x) => x.id === fromId
|
|
7303
|
+
);
|
|
7269
7304
|
if (!t) return;
|
|
7270
|
-
const arr = (_d = t[
|
|
7305
|
+
const arr = (_d = t[tagKey]) != null ? _d : t[tagKey] = [];
|
|
7271
7306
|
if (!arr.includes(toId2)) arr.push(toId2);
|
|
7272
7307
|
return;
|
|
7273
7308
|
}
|
|
7309
|
+
if (ctx.isFieldId(fromId) && ctx.isFieldId(toId2)) {
|
|
7310
|
+
const source = ((_e = p.fields) != null ? _e : []).find(
|
|
7311
|
+
(x) => x.id === fromId
|
|
7312
|
+
);
|
|
7313
|
+
if (!(source == null ? void 0 : source.button)) {
|
|
7314
|
+
throw new Error(
|
|
7315
|
+
`${kind}: source field must be button=true: ${fromId} ? ${toId2}`
|
|
7316
|
+
);
|
|
7317
|
+
}
|
|
7318
|
+
addMappedField(p, mapKey, fromId, toId2);
|
|
7319
|
+
return;
|
|
7320
|
+
}
|
|
7274
7321
|
if (ctx.isOptionId(fromId) && ctx.isFieldId(toId2)) {
|
|
7275
|
-
|
|
7276
|
-
const maps = p[mapKey];
|
|
7277
|
-
const next = { ...maps != null ? maps : {} };
|
|
7278
|
-
const arr = (_e = next[fromId]) != null ? _e : [];
|
|
7279
|
-
if (!arr.includes(toId2)) arr.push(toId2);
|
|
7280
|
-
next[fromId] = arr;
|
|
7281
|
-
p[mapKey] = next;
|
|
7322
|
+
addMappedField(p, mapKey, fromId, toId2);
|
|
7282
7323
|
return;
|
|
7283
7324
|
}
|
|
7284
|
-
throw new Error(
|
|
7325
|
+
throw new Error(
|
|
7326
|
+
`${kind}: unsupported route ${fromId} ? ${toId2}`
|
|
7327
|
+
);
|
|
7285
7328
|
}
|
|
7286
7329
|
if (kind === "service") {
|
|
7287
7330
|
ensureServiceExists(ctx.opts, fromId);
|
|
7288
7331
|
if (toId2.startsWith("t:")) {
|
|
7289
|
-
|
|
7290
|
-
|
|
7291
|
-
do: () => ctx.patchProps((next) => {
|
|
7292
|
-
var _a2;
|
|
7293
|
-
const t = ((_a2 = next.filters) != null ? _a2 : []).find((x) => x.id === toId2);
|
|
7294
|
-
if (t) t.service_id = fromId;
|
|
7295
|
-
}),
|
|
7296
|
-
undo: () => ctx.undo()
|
|
7297
|
-
});
|
|
7332
|
+
const t = ((_f = p.filters) != null ? _f : []).find((x) => x.id === toId2);
|
|
7333
|
+
if (t) t.service_id = fromId;
|
|
7298
7334
|
return;
|
|
7299
7335
|
}
|
|
7300
7336
|
if (toId2.startsWith("o:")) {
|
|
7301
|
-
|
|
7302
|
-
|
|
7303
|
-
|
|
7304
|
-
|
|
7305
|
-
|
|
7306
|
-
|
|
7307
|
-
|
|
7308
|
-
o.service_id = fromId;
|
|
7309
|
-
return;
|
|
7310
|
-
}
|
|
7311
|
-
}
|
|
7312
|
-
}),
|
|
7313
|
-
undo: () => ctx.undo()
|
|
7314
|
-
});
|
|
7337
|
+
for (const f of (_g = p.fields) != null ? _g : []) {
|
|
7338
|
+
const o = (_h = f.options) == null ? void 0 : _h.find((x) => x.id === toId2);
|
|
7339
|
+
if (o) {
|
|
7340
|
+
o.service_id = fromId;
|
|
7341
|
+
return;
|
|
7342
|
+
}
|
|
7343
|
+
}
|
|
7315
7344
|
return;
|
|
7316
7345
|
}
|
|
7317
|
-
throw new Error(
|
|
7346
|
+
throw new Error(
|
|
7347
|
+
'service: to must be a tag ("t:*") or option ("o:*")'
|
|
7348
|
+
);
|
|
7318
7349
|
}
|
|
7319
7350
|
throw new Error(`Unknown connect kind: ${kind}`);
|
|
7320
7351
|
}),
|
|
@@ -7325,90 +7356,109 @@ function disconnect(ctx, kind, fromId, toId2) {
|
|
|
7325
7356
|
ctx.exec({
|
|
7326
7357
|
name: `disconnect:${kind}`,
|
|
7327
7358
|
do: () => ctx.patchProps((p) => {
|
|
7328
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
7359
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
7329
7360
|
if (kind === "bind") {
|
|
7330
7361
|
if (ctx.isTagId(fromId) && ctx.isTagId(toId2)) {
|
|
7331
|
-
const child = ((_a = p.filters) != null ? _a : []).find(
|
|
7332
|
-
|
|
7362
|
+
const child = ((_a = p.filters) != null ? _a : []).find(
|
|
7363
|
+
(t) => t.id === toId2
|
|
7364
|
+
);
|
|
7365
|
+
if ((child == null ? void 0 : child.bind_id) === fromId) {
|
|
7366
|
+
delete child.bind_id;
|
|
7367
|
+
}
|
|
7333
7368
|
return;
|
|
7334
7369
|
}
|
|
7335
7370
|
if (ctx.isTagId(fromId) && ctx.isFieldId(toId2) || ctx.isFieldId(fromId) && ctx.isTagId(toId2)) {
|
|
7336
7371
|
const fieldId = ctx.isFieldId(toId2) ? toId2 : fromId;
|
|
7337
7372
|
const tagId = ctx.isTagId(fromId) ? fromId : toId2;
|
|
7338
|
-
const f = ((_b = p.fields) != null ? _b : []).find(
|
|
7373
|
+
const f = ((_b = p.fields) != null ? _b : []).find(
|
|
7374
|
+
(x) => x.id === fieldId
|
|
7375
|
+
);
|
|
7339
7376
|
if (!(f == null ? void 0 : f.bind_id)) return;
|
|
7340
7377
|
if (typeof f.bind_id === "string") {
|
|
7341
|
-
if (f.bind_id === tagId)
|
|
7378
|
+
if (f.bind_id === tagId) {
|
|
7379
|
+
delete f.bind_id;
|
|
7380
|
+
}
|
|
7342
7381
|
return;
|
|
7343
7382
|
}
|
|
7344
7383
|
f.bind_id = f.bind_id.filter((x) => x !== tagId);
|
|
7345
|
-
if (((_c = f.bind_id) == null ? void 0 : _c.length) === 0)
|
|
7384
|
+
if (((_c = f.bind_id) == null ? void 0 : _c.length) === 0) {
|
|
7385
|
+
delete f.bind_id;
|
|
7386
|
+
}
|
|
7346
7387
|
return;
|
|
7347
7388
|
}
|
|
7348
|
-
throw new Error(
|
|
7389
|
+
throw new Error(
|
|
7390
|
+
`unbind: unsupported route ${fromId} ? ${toId2}`
|
|
7391
|
+
);
|
|
7349
7392
|
}
|
|
7350
7393
|
if (kind === "include" || kind === "exclude") {
|
|
7351
|
-
const
|
|
7394
|
+
const tagKey = kind === "include" ? "includes" : "excludes";
|
|
7395
|
+
const mapKey = kind === "include" ? "includes_for_buttons" : "excludes_for_buttons";
|
|
7352
7396
|
if (ctx.isTagId(fromId) && ctx.isFieldId(toId2)) {
|
|
7353
|
-
const t = ((_d = p.filters) != null ? _d : []).find(
|
|
7397
|
+
const t = ((_d = p.filters) != null ? _d : []).find(
|
|
7398
|
+
(x) => x.id === fromId
|
|
7399
|
+
);
|
|
7354
7400
|
if (!t) return;
|
|
7355
|
-
t[
|
|
7356
|
-
if (!((_f = t[
|
|
7401
|
+
t[tagKey] = ((_e = t[tagKey]) != null ? _e : []).filter((x) => x !== toId2);
|
|
7402
|
+
if (!((_f = t[tagKey]) == null ? void 0 : _f.length)) {
|
|
7403
|
+
delete t[tagKey];
|
|
7404
|
+
}
|
|
7357
7405
|
return;
|
|
7358
7406
|
}
|
|
7359
|
-
if (ctx.isOptionId(fromId) && ctx.isFieldId(toId2)) {
|
|
7360
|
-
const mapKey = kind === "include" ? "includes_for_options" : "excludes_for_options";
|
|
7407
|
+
if ((ctx.isFieldId(fromId) || ctx.isOptionId(fromId)) && ctx.isFieldId(toId2)) {
|
|
7361
7408
|
const maps = p[mapKey];
|
|
7362
|
-
if (!maps) return;
|
|
7363
|
-
|
|
7364
|
-
|
|
7365
|
-
|
|
7366
|
-
|
|
7367
|
-
|
|
7409
|
+
if (!(maps == null ? void 0 : maps[fromId])) return;
|
|
7410
|
+
maps[fromId] = maps[fromId].filter(
|
|
7411
|
+
(fid) => fid !== toId2
|
|
7412
|
+
);
|
|
7413
|
+
if (!((_g = maps[fromId]) == null ? void 0 : _g.length)) {
|
|
7414
|
+
delete maps[fromId];
|
|
7415
|
+
}
|
|
7416
|
+
if (!Object.keys(maps).length) {
|
|
7417
|
+
delete p[mapKey];
|
|
7368
7418
|
}
|
|
7369
|
-
if (!Object.keys(maps).length) delete p[mapKey];
|
|
7370
7419
|
return;
|
|
7371
7420
|
}
|
|
7372
|
-
throw new Error(
|
|
7421
|
+
throw new Error(
|
|
7422
|
+
`${kind}: unsupported route ${fromId} ? ${toId2}`
|
|
7423
|
+
);
|
|
7373
7424
|
}
|
|
7374
7425
|
if (kind === "service") {
|
|
7375
7426
|
ensureServiceExists(ctx.opts, fromId);
|
|
7376
7427
|
if (toId2.startsWith("t:")) {
|
|
7377
|
-
|
|
7378
|
-
|
|
7379
|
-
|
|
7380
|
-
|
|
7381
|
-
const t = ((_a2 = next.filters) != null ? _a2 : []).find((x) => x.id === toId2);
|
|
7382
|
-
if (t) delete t.service_id;
|
|
7383
|
-
}),
|
|
7384
|
-
undo: () => ctx.undo()
|
|
7385
|
-
});
|
|
7428
|
+
const t = ((_h = p.filters) != null ? _h : []).find((x) => x.id === toId2);
|
|
7429
|
+
if (t) {
|
|
7430
|
+
delete t.service_id;
|
|
7431
|
+
}
|
|
7386
7432
|
return;
|
|
7387
7433
|
}
|
|
7388
7434
|
if (toId2.startsWith("o:")) {
|
|
7389
|
-
|
|
7390
|
-
|
|
7391
|
-
|
|
7392
|
-
|
|
7393
|
-
|
|
7394
|
-
|
|
7395
|
-
|
|
7396
|
-
delete o.service_id;
|
|
7397
|
-
return;
|
|
7398
|
-
}
|
|
7399
|
-
}
|
|
7400
|
-
}),
|
|
7401
|
-
undo: () => ctx.undo()
|
|
7402
|
-
});
|
|
7435
|
+
for (const f of (_i = p.fields) != null ? _i : []) {
|
|
7436
|
+
const o = (_j = f.options) == null ? void 0 : _j.find((x) => x.id === toId2);
|
|
7437
|
+
if (o) {
|
|
7438
|
+
delete o.service_id;
|
|
7439
|
+
return;
|
|
7440
|
+
}
|
|
7441
|
+
}
|
|
7403
7442
|
return;
|
|
7404
7443
|
}
|
|
7405
|
-
throw new Error(
|
|
7444
|
+
throw new Error(
|
|
7445
|
+
'service: to must be a tag ("t:*") or option ("o:*")'
|
|
7446
|
+
);
|
|
7406
7447
|
}
|
|
7407
7448
|
throw new Error(`Unknown disconnect kind: ${kind}`);
|
|
7408
7449
|
}),
|
|
7409
7450
|
undo: () => ctx.undo()
|
|
7410
7451
|
});
|
|
7411
7452
|
}
|
|
7453
|
+
function addMappedField(p, mapKey, fromId, toId2) {
|
|
7454
|
+
var _a, _b;
|
|
7455
|
+
const maps = (_a = p[mapKey]) != null ? _a : {};
|
|
7456
|
+
const arr = (_b = maps[fromId]) != null ? _b : [];
|
|
7457
|
+
if (!arr.includes(toId2)) {
|
|
7458
|
+
maps[fromId] = [...arr, toId2];
|
|
7459
|
+
}
|
|
7460
|
+
p[mapKey] = maps;
|
|
7461
|
+
}
|
|
7412
7462
|
|
|
7413
7463
|
// src/react/canvas/editor/editor-service-filter.ts
|
|
7414
7464
|
function filterServicesForVisibleGroup2(ctx, candidates, input) {
|