@picked/client 0.0.1-dev.1772168509010 → 0.0.1-dev.1772412203098
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/cjs/index.js +2 -2
- package/dist/cjs/plugins/create-experience/index.js +1 -1
- package/dist/cjs/plugins/experience-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/history-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/responses-indexeddb/index.js +1 -1
- package/dist/cjs/plugins/single-page-app/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/esm/index.js +691 -593
- package/dist/esm/plugins/create-experience/index.js +210 -236
- package/dist/esm/plugins/experience-browser-storage/index.js +1 -1
- package/dist/esm/plugins/history-browser-storage/index.js +1 -1
- package/dist/esm/plugins/responses-browser-storage/index.js +1 -1
- package/dist/esm/plugins/responses-indexeddb/index.js +51 -46
- package/dist/esm/plugins/single-page-app/index.js +24 -24
- package/dist/esm/server/index.js +1 -1
- package/dist/experience-instance-BX0aqKsC.cjs +1 -0
- package/dist/{experience-instance-fvSEb72i.js → experience-instance-DTyL1fNb.js} +205 -199
- package/dist/{object-JwZ58NOH.js → object-CJssU1Pm.js} +1 -1
- package/dist/object-mwaxtjLG.cjs +1 -0
- package/dist/storage-58NoTSsc.cjs +1 -0
- package/dist/{storage-Co_LbKr_.js → storage-B2d81EOI.js} +35 -30
- package/dist/types/entities/action/action.d.ts +5 -2
- package/dist/types/entities/action/action.d.ts.map +1 -1
- package/dist/types/entities/experience/experience.d.ts +5 -4
- package/dist/types/entities/experience/experience.d.ts.map +1 -1
- package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
- package/dist/types/entities/feature/feature.d.ts.map +1 -1
- package/dist/types/entities/field/field.d.ts +51 -14
- package/dist/types/entities/field/field.d.ts.map +1 -1
- package/dist/types/entities/history/history.d.ts.map +1 -1
- package/dist/types/entities/project/project.d.ts.map +1 -1
- package/dist/types/entities/response/response.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/logic-engine.d.ts +2 -8
- package/dist/types/logic-engine.d.ts.map +1 -1
- package/dist/types/picked.d.ts +16 -7
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/create-experience.d.ts +26 -21
- package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
- package/dist/types/plugins/experience-browser-storage/plugin.d.ts +2 -1
- package/dist/types/plugins/experience-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/plugins/history-browser-storage/plugin.d.ts +2 -1
- package/dist/types/plugins/history-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/plugins/responses-browser-storage/plugin.d.ts +2 -1
- package/dist/types/plugins/responses-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/plugins/responses-indexeddb/plugin.d.ts.map +1 -1
- package/dist/types/plugins/single-page-app/plugin.d.ts +1 -1
- package/dist/types/plugins/single-page-app/plugin.d.ts.map +1 -1
- package/dist/types/utils/dom.d.ts +0 -3
- package/dist/types/utils/dom.d.ts.map +1 -1
- package/dist/types/utils/events.d.ts +1 -1
- package/dist/types/utils/events.d.ts.map +1 -1
- package/dist/types/utils/get-step-fields.d.ts +2 -1
- package/dist/types/utils/get-step-fields.d.ts.map +1 -1
- package/dist/types/utils/global-obj.d.ts +0 -1
- package/dist/types/utils/global-obj.d.ts.map +1 -1
- package/dist/types/utils/indexed-db.d.ts +2 -1
- package/dist/types/utils/indexed-db.d.ts.map +1 -1
- package/dist/types/utils/logger.d.ts.map +1 -1
- package/dist/types/utils/node-tree/min-max-steps-to-leaf.d.ts.map +1 -1
- package/dist/types/utils/node-tree/min-max-steps-to-origin.d.ts.map +1 -1
- package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts.map +1 -1
- package/dist/types/utils/object.d.ts +0 -8
- package/dist/types/utils/object.d.ts.map +1 -1
- package/dist/types/utils/picked-config.d.ts +1 -1
- package/dist/types/utils/picked-config.d.ts.map +1 -1
- package/dist/types/utils/rules-logic.d.ts.map +1 -1
- package/dist/types/utils/search-params.d.ts.map +1 -1
- package/dist/types/utils/storage.d.ts.map +1 -1
- package/package.json +14 -2
- package/dist/experience-instance-BsXG5XJ4.cjs +0 -1
- package/dist/object-BbFTsGh3.cjs +0 -1
- package/dist/storage-Be5xWNPC.cjs +0 -1
|
@@ -1,108 +1,108 @@
|
|
|
1
1
|
import { g as f } from "../../../id-BW-g3y32.js";
|
|
2
|
-
const
|
|
3
|
-
serialize(
|
|
4
|
-
return JSON.stringify(
|
|
2
|
+
const a = {
|
|
3
|
+
serialize(i) {
|
|
4
|
+
return JSON.stringify(i);
|
|
5
5
|
},
|
|
6
|
-
deserialize(
|
|
7
|
-
return JSON.parse(
|
|
6
|
+
deserialize(i) {
|
|
7
|
+
return JSON.parse(i);
|
|
8
8
|
}
|
|
9
|
-
},
|
|
9
|
+
}, V = (i) => ({
|
|
10
10
|
name: "create-experience",
|
|
11
|
-
setup: (
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
d.component = s.component,
|
|
15
|
-
|
|
11
|
+
setup: (n) => {
|
|
12
|
+
i.experiences.forEach((s) => {
|
|
13
|
+
const t = s.serialize(), d = a.deserialize(t);
|
|
14
|
+
d.component = s.component, n.registerExperience(d), d.fields.forEach((N) => {
|
|
15
|
+
n.registerField(N);
|
|
16
16
|
});
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
}),
|
|
19
|
+
}), z = (i, n) => ({
|
|
20
20
|
id: f("node"),
|
|
21
21
|
position: [0, 0],
|
|
22
|
-
experience:
|
|
22
|
+
experience: n,
|
|
23
23
|
type: "action",
|
|
24
|
-
action:
|
|
25
|
-
addNext(
|
|
26
|
-
if (!
|
|
24
|
+
action: i.action,
|
|
25
|
+
addNext(t) {
|
|
26
|
+
if (!t.node) throw new Error("Cannot connect to node");
|
|
27
27
|
const d = h(
|
|
28
|
-
{ sourceNode: this, destinationNode:
|
|
29
|
-
|
|
28
|
+
{ sourceNode: this, destinationNode: t.node, sourceNodeHandle: null },
|
|
29
|
+
n
|
|
30
30
|
);
|
|
31
|
-
|
|
31
|
+
n.edges.push(d);
|
|
32
32
|
},
|
|
33
|
-
onSuccess(
|
|
34
|
-
if (!
|
|
33
|
+
onSuccess(t) {
|
|
34
|
+
if (!t.node) throw new Error("Cannot connect to node");
|
|
35
35
|
const d = h(
|
|
36
|
-
{ sourceNode: this, destinationNode:
|
|
37
|
-
|
|
36
|
+
{ sourceNode: this, destinationNode: t.node, sourceNodeHandle: "true" },
|
|
37
|
+
n
|
|
38
38
|
);
|
|
39
|
-
|
|
39
|
+
n.edges.push(d);
|
|
40
40
|
},
|
|
41
|
-
onFail(
|
|
42
|
-
if (!
|
|
41
|
+
onFail(t) {
|
|
42
|
+
if (!t.node) throw new Error("Cannot connect to node");
|
|
43
43
|
const d = h(
|
|
44
|
-
{ sourceNode: this, destinationNode:
|
|
45
|
-
|
|
44
|
+
{ sourceNode: this, destinationNode: t.node, sourceNodeHandle: "false" },
|
|
45
|
+
n
|
|
46
46
|
);
|
|
47
|
-
|
|
47
|
+
n.edges.push(d);
|
|
48
48
|
},
|
|
49
49
|
serialize() {
|
|
50
|
-
return
|
|
50
|
+
return a.serialize({
|
|
51
51
|
id: this.id,
|
|
52
52
|
type: this.type,
|
|
53
53
|
action: this.action,
|
|
54
54
|
position: this.position
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
-
}),
|
|
58
|
-
id:
|
|
59
|
-
label:
|
|
60
|
-
fields:
|
|
61
|
-
addField(
|
|
62
|
-
const s = "serialize" in
|
|
63
|
-
return this.fields
|
|
57
|
+
}), E = (i) => ({
|
|
58
|
+
id: i.id ?? f("step"),
|
|
59
|
+
label: i.label,
|
|
60
|
+
fields: i.fields ?? [],
|
|
61
|
+
addField(n) {
|
|
62
|
+
const s = "serialize" in n ? n : y(n);
|
|
63
|
+
return this.fields.includes(s) || this.fields.push(s), s;
|
|
64
64
|
}
|
|
65
|
-
}),
|
|
65
|
+
}), g = (i, n) => {
|
|
66
66
|
const s = {
|
|
67
|
-
id:
|
|
68
|
-
label:
|
|
69
|
-
experience:
|
|
70
|
-
fields:
|
|
67
|
+
id: i.id ?? f("step"),
|
|
68
|
+
label: i.label,
|
|
69
|
+
experience: n,
|
|
70
|
+
fields: i.fields ?? [],
|
|
71
71
|
node: null,
|
|
72
|
-
nextStep(
|
|
73
|
-
return this.experience.addStep(
|
|
72
|
+
nextStep(t) {
|
|
73
|
+
return this.experience.addStep(t, this);
|
|
74
74
|
},
|
|
75
|
-
nextConditional(
|
|
76
|
-
return this.experience.addConditional(
|
|
75
|
+
nextConditional(t) {
|
|
76
|
+
return this.experience.addConditional(t, this);
|
|
77
77
|
},
|
|
78
|
-
addNextExperience(
|
|
79
|
-
return this.experience.addExperience(
|
|
78
|
+
addNextExperience(t) {
|
|
79
|
+
return this.experience.addExperience(t, this);
|
|
80
80
|
},
|
|
81
|
-
addField(
|
|
82
|
-
return this.experience.addField(
|
|
81
|
+
addField(t) {
|
|
82
|
+
return this.experience.addField(t, this);
|
|
83
83
|
},
|
|
84
84
|
serialize() {
|
|
85
|
-
return
|
|
85
|
+
return a.serialize({
|
|
86
86
|
id: this.id,
|
|
87
87
|
label: this.label,
|
|
88
|
-
fieldIds: this.fields.map((
|
|
88
|
+
fieldIds: this.fields.map((t) => t.id)
|
|
89
89
|
});
|
|
90
90
|
}
|
|
91
91
|
};
|
|
92
|
-
return p({ step: s, type: "step" },
|
|
93
|
-
},
|
|
92
|
+
return p({ step: s, type: "step" }, n), s;
|
|
93
|
+
}, m = () => [0, 0], p = (i, n) => {
|
|
94
94
|
const s = {
|
|
95
95
|
id: f("node"),
|
|
96
|
-
position:
|
|
97
|
-
experience:
|
|
96
|
+
position: m(),
|
|
97
|
+
experience: n
|
|
98
98
|
};
|
|
99
|
-
if (
|
|
99
|
+
if (i.type === "step") {
|
|
100
100
|
const d = {
|
|
101
101
|
...s,
|
|
102
102
|
type: "step",
|
|
103
|
-
connectedStep:
|
|
103
|
+
connectedStep: i.step,
|
|
104
104
|
serialize() {
|
|
105
|
-
return
|
|
105
|
+
return a.serialize({
|
|
106
106
|
id: this.id,
|
|
107
107
|
type: this.type,
|
|
108
108
|
stepId: this.connectedStep.id,
|
|
@@ -113,13 +113,13 @@ const r = {
|
|
|
113
113
|
};
|
|
114
114
|
return d.connectedStep.node = d, d;
|
|
115
115
|
}
|
|
116
|
-
if (
|
|
116
|
+
if (i.type === "conditional") {
|
|
117
117
|
const d = {
|
|
118
118
|
...s,
|
|
119
119
|
type: "conditional",
|
|
120
|
-
connectedConditional:
|
|
120
|
+
connectedConditional: i.conditional,
|
|
121
121
|
serialize() {
|
|
122
|
-
return
|
|
122
|
+
return a.serialize({
|
|
123
123
|
id: this.id,
|
|
124
124
|
type: this.type,
|
|
125
125
|
conditionalId: this.connectedConditional.id,
|
|
@@ -129,12 +129,12 @@ const r = {
|
|
|
129
129
|
};
|
|
130
130
|
return d.connectedConditional.node = d, d;
|
|
131
131
|
}
|
|
132
|
-
return
|
|
132
|
+
return i.type === "experience" ? {
|
|
133
133
|
...s,
|
|
134
134
|
type: "experience",
|
|
135
|
-
connectedExperience:
|
|
135
|
+
connectedExperience: i.experience,
|
|
136
136
|
serialize() {
|
|
137
|
-
return
|
|
137
|
+
return a.serialize({
|
|
138
138
|
id: this.id,
|
|
139
139
|
type: this.type,
|
|
140
140
|
experienceId: this.connectedExperience.id,
|
|
@@ -145,77 +145,82 @@ const r = {
|
|
|
145
145
|
...s,
|
|
146
146
|
type: "origin",
|
|
147
147
|
serialize() {
|
|
148
|
-
return
|
|
148
|
+
return a.serialize({
|
|
149
149
|
id: this.id,
|
|
150
150
|
type: this.type,
|
|
151
151
|
position: this.position
|
|
152
152
|
});
|
|
153
153
|
}
|
|
154
154
|
};
|
|
155
|
-
}, h = (
|
|
155
|
+
}, h = (i, n) => ({
|
|
156
156
|
id: f("edge"),
|
|
157
|
-
sourceNode:
|
|
158
|
-
sourceNodeHandle:
|
|
159
|
-
destinationNode:
|
|
160
|
-
experience:
|
|
157
|
+
sourceNode: i.sourceNode,
|
|
158
|
+
sourceNodeHandle: i.sourceNodeHandle,
|
|
159
|
+
destinationNode: i.destinationNode,
|
|
160
|
+
experience: n,
|
|
161
161
|
serialize() {
|
|
162
|
-
return
|
|
162
|
+
return a.serialize({
|
|
163
163
|
id: this.id,
|
|
164
164
|
sourceNodeHandle: this.sourceNodeHandle ?? void 0,
|
|
165
165
|
sourceNodeId: this.sourceNode.id,
|
|
166
166
|
destinationNodeId: this.destinationNode.id
|
|
167
167
|
});
|
|
168
168
|
}
|
|
169
|
-
}), b = (
|
|
169
|
+
}), b = (i, n) => {
|
|
170
170
|
const s = {
|
|
171
171
|
id: f("conditional"),
|
|
172
|
-
|
|
172
|
+
label: i.label,
|
|
173
|
+
condition: i.condition,
|
|
173
174
|
node: null,
|
|
174
|
-
experience:
|
|
175
|
-
addTrue(
|
|
176
|
-
if (!this.node || !
|
|
175
|
+
experience: n,
|
|
176
|
+
addTrue(t) {
|
|
177
|
+
if (!this.node || !t.node)
|
|
177
178
|
throw new Error("todo no node");
|
|
178
179
|
const d = h(
|
|
179
|
-
{ sourceNode: this.node, destinationNode:
|
|
180
|
+
{ sourceNode: this.node, destinationNode: t.node, sourceNodeHandle: "true" },
|
|
180
181
|
this.experience
|
|
181
182
|
);
|
|
182
183
|
this.experience.edges.push(d);
|
|
183
184
|
},
|
|
184
|
-
addFalse(
|
|
185
|
-
if (!this.node || !
|
|
185
|
+
addFalse(t) {
|
|
186
|
+
if (!this.node || !t.node)
|
|
186
187
|
throw new Error("todo no node");
|
|
187
188
|
const d = h(
|
|
188
|
-
{ sourceNode: this.node, destinationNode:
|
|
189
|
+
{ sourceNode: this.node, destinationNode: t.node, sourceNodeHandle: "false" },
|
|
189
190
|
this.experience
|
|
190
191
|
);
|
|
191
192
|
this.experience.edges.push(d);
|
|
192
193
|
},
|
|
193
194
|
serialize() {
|
|
194
|
-
return
|
|
195
|
+
return a.serialize({
|
|
195
196
|
id: this.id,
|
|
197
|
+
label: this.label,
|
|
196
198
|
condition: this.condition
|
|
197
199
|
});
|
|
198
200
|
}
|
|
199
201
|
};
|
|
200
|
-
return p({ conditional: s, type: "conditional" },
|
|
201
|
-
},
|
|
202
|
-
id:
|
|
203
|
-
name:
|
|
204
|
-
type:
|
|
205
|
-
label:
|
|
206
|
-
placeholder:
|
|
207
|
-
description:
|
|
208
|
-
helpText:
|
|
209
|
-
defaultValue:
|
|
210
|
-
multiple:
|
|
211
|
-
validation:
|
|
212
|
-
condition:
|
|
213
|
-
required:
|
|
214
|
-
options:
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
202
|
+
return p({ conditional: s, type: "conditional" }, n), s;
|
|
203
|
+
}, y = (i) => ({
|
|
204
|
+
id: i.id,
|
|
205
|
+
name: i.name,
|
|
206
|
+
type: i.type,
|
|
207
|
+
label: i.label,
|
|
208
|
+
placeholder: i.placeholder,
|
|
209
|
+
description: i.description,
|
|
210
|
+
helpText: i.helpText,
|
|
211
|
+
defaultValue: i.defaultValue ?? null,
|
|
212
|
+
multiple: i.multiple,
|
|
213
|
+
validation: i.validation ?? {},
|
|
214
|
+
condition: i.condition,
|
|
215
|
+
required: i.required,
|
|
216
|
+
options: Array.isArray(i.options) ? i.options.map(({ id: s, ...t }) => ({
|
|
217
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- defensive fallback in case option id is omitted at runtime
|
|
218
|
+
id: s ?? f("option"),
|
|
219
|
+
...t
|
|
220
|
+
})) : i.options ?? null,
|
|
221
|
+
dependsOn: i.dependsOn,
|
|
222
|
+
policies: i.policies,
|
|
223
|
+
// eslint-disable-next-line sonarjs/cognitive-complexity -- field type serialization logic requires branching per type/multiple combination
|
|
219
224
|
serialize() {
|
|
220
225
|
const s = {
|
|
221
226
|
id: this.id,
|
|
@@ -227,237 +232,206 @@ const r = {
|
|
|
227
232
|
helpText: this.helpText,
|
|
228
233
|
validation: this.validation,
|
|
229
234
|
condition: this.condition,
|
|
235
|
+
dependsOn: this.dependsOn,
|
|
230
236
|
policies: this.policies
|
|
231
|
-
},
|
|
237
|
+
}, t = typeof this.defaultValue == "string" ? this.defaultValue : void 0, d = typeof this.defaultValue == "number" ? this.defaultValue : void 0, N = typeof this.defaultValue == "boolean" ? this.defaultValue : void 0, u = (e) => this.options ? Array.isArray(this.options) ? this.options.map((o) => ({
|
|
238
|
+
id: o.id,
|
|
239
|
+
label: o.label,
|
|
240
|
+
description: o.description,
|
|
241
|
+
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- option.value may be wider than JsonValue at this point; cast is safe before passing to castValue
|
|
242
|
+
value: e(o.value),
|
|
243
|
+
condition: o.condition
|
|
244
|
+
})) : this.options : null;
|
|
232
245
|
switch (this.type) {
|
|
233
246
|
case "text":
|
|
234
247
|
if (this.multiple) {
|
|
235
|
-
let
|
|
248
|
+
let e;
|
|
236
249
|
if (Array.isArray(this.defaultValue)) {
|
|
237
|
-
|
|
238
|
-
for (const
|
|
239
|
-
typeof
|
|
240
|
-
|
|
250
|
+
e = [];
|
|
251
|
+
for (const o of this.defaultValue)
|
|
252
|
+
typeof o == "string" && e.push(o);
|
|
253
|
+
e.length === 0 && (e = void 0);
|
|
241
254
|
}
|
|
242
|
-
return
|
|
255
|
+
return a.serialize({
|
|
243
256
|
...s,
|
|
244
257
|
type: "text",
|
|
245
258
|
multiple: !0,
|
|
246
|
-
defaultValue:
|
|
247
|
-
options:
|
|
248
|
-
id: i.id,
|
|
249
|
-
label: i.label,
|
|
250
|
-
value: `${i.value}`,
|
|
251
|
-
condition: i.condition
|
|
252
|
-
})) : null
|
|
259
|
+
defaultValue: e,
|
|
260
|
+
options: u((o) => `${o}`)
|
|
253
261
|
});
|
|
254
262
|
}
|
|
255
|
-
return
|
|
263
|
+
return a.serialize({
|
|
256
264
|
...s,
|
|
257
265
|
type: "text",
|
|
258
266
|
multiple: !1,
|
|
259
|
-
defaultValue:
|
|
260
|
-
options:
|
|
261
|
-
id: t.id,
|
|
262
|
-
label: t.label,
|
|
263
|
-
value: `${t.value}`,
|
|
264
|
-
condition: t.condition
|
|
265
|
-
})) : null
|
|
267
|
+
defaultValue: t,
|
|
268
|
+
options: u((e) => `${e}`)
|
|
266
269
|
});
|
|
267
270
|
case "number":
|
|
268
271
|
if (this.multiple) {
|
|
269
|
-
let
|
|
272
|
+
let e;
|
|
270
273
|
if (Array.isArray(this.defaultValue)) {
|
|
271
|
-
|
|
272
|
-
for (const
|
|
273
|
-
typeof
|
|
274
|
-
|
|
274
|
+
e = [];
|
|
275
|
+
for (const o of this.defaultValue)
|
|
276
|
+
typeof o == "number" && e.push(o);
|
|
277
|
+
e.length === 0 && (e = void 0);
|
|
275
278
|
}
|
|
276
|
-
return
|
|
279
|
+
return a.serialize({
|
|
277
280
|
...s,
|
|
278
281
|
type: "number",
|
|
279
282
|
multiple: !0,
|
|
280
|
-
defaultValue:
|
|
281
|
-
options:
|
|
282
|
-
id: i.id,
|
|
283
|
-
label: i.label,
|
|
284
|
-
value: Number(i.value),
|
|
285
|
-
condition: i.condition
|
|
286
|
-
})) : null
|
|
283
|
+
defaultValue: e,
|
|
284
|
+
options: u((o) => Number(o))
|
|
287
285
|
});
|
|
288
286
|
}
|
|
289
|
-
return
|
|
287
|
+
return a.serialize({
|
|
290
288
|
...s,
|
|
291
289
|
type: "number",
|
|
292
290
|
multiple: !1,
|
|
293
291
|
defaultValue: d,
|
|
294
|
-
options:
|
|
295
|
-
id: t.id,
|
|
296
|
-
label: t.label,
|
|
297
|
-
value: Number(t.value),
|
|
298
|
-
condition: t.condition
|
|
299
|
-
})) : null
|
|
292
|
+
options: u((e) => Number(e))
|
|
300
293
|
});
|
|
301
294
|
case "boolean":
|
|
302
295
|
if (this.multiple) {
|
|
303
|
-
let
|
|
296
|
+
let e;
|
|
304
297
|
if (Array.isArray(this.defaultValue)) {
|
|
305
|
-
|
|
306
|
-
for (const
|
|
307
|
-
typeof
|
|
308
|
-
|
|
298
|
+
e = [];
|
|
299
|
+
for (const o of this.defaultValue)
|
|
300
|
+
typeof o == "boolean" && e.push(o);
|
|
301
|
+
e.length === 0 && (e = void 0);
|
|
309
302
|
}
|
|
310
|
-
return
|
|
303
|
+
return a.serialize({
|
|
311
304
|
...s,
|
|
312
305
|
type: "boolean",
|
|
313
306
|
multiple: !0,
|
|
314
|
-
defaultValue:
|
|
315
|
-
options:
|
|
316
|
-
id: i.id,
|
|
317
|
-
label: i.label,
|
|
318
|
-
value: !!i.value,
|
|
319
|
-
condition: i.condition
|
|
320
|
-
})) : null
|
|
307
|
+
defaultValue: e,
|
|
308
|
+
options: u((o) => !!o)
|
|
321
309
|
});
|
|
322
310
|
}
|
|
323
|
-
return
|
|
311
|
+
return a.serialize({
|
|
324
312
|
...s,
|
|
325
313
|
type: "boolean",
|
|
326
314
|
multiple: !1,
|
|
327
315
|
defaultValue: N,
|
|
328
|
-
options:
|
|
329
|
-
id: t.id,
|
|
330
|
-
label: t.label,
|
|
331
|
-
value: !!t.value,
|
|
332
|
-
condition: t.condition
|
|
333
|
-
})) : null
|
|
316
|
+
options: u((e) => !!e)
|
|
334
317
|
});
|
|
335
318
|
case "object":
|
|
336
|
-
return this.multiple ?
|
|
319
|
+
return this.multiple ? a.serialize({
|
|
337
320
|
...s,
|
|
338
321
|
type: "object",
|
|
339
322
|
multiple: !0,
|
|
340
323
|
defaultValue: this.defaultValue,
|
|
341
|
-
options:
|
|
342
|
-
|
|
343
|
-
label: t.label,
|
|
344
|
-
description: t.description,
|
|
345
|
-
value: t.value,
|
|
346
|
-
condition: t.condition
|
|
347
|
-
})) : null
|
|
348
|
-
}) : r.serialize({
|
|
324
|
+
options: u((e) => e)
|
|
325
|
+
}) : a.serialize({
|
|
349
326
|
...s,
|
|
350
327
|
type: "object",
|
|
351
328
|
multiple: !1,
|
|
352
329
|
defaultValue: this.defaultValue,
|
|
353
|
-
options:
|
|
354
|
-
id: t.id,
|
|
355
|
-
label: t.label,
|
|
356
|
-
description: t.description,
|
|
357
|
-
value: t.value,
|
|
358
|
-
condition: t.condition
|
|
359
|
-
})) : null
|
|
330
|
+
options: u((e) => e)
|
|
360
331
|
});
|
|
361
332
|
default:
|
|
362
333
|
throw new Error("Unsupported field type");
|
|
363
334
|
}
|
|
364
335
|
}
|
|
365
|
-
}),
|
|
366
|
-
const
|
|
336
|
+
}), w = (i) => {
|
|
337
|
+
const n = [], s = [], t = [], d = [], N = [], u = i.condition ?? i.decide;
|
|
367
338
|
return {
|
|
368
|
-
id:
|
|
369
|
-
component:
|
|
370
|
-
name:
|
|
371
|
-
initializeOpen:
|
|
372
|
-
condition:
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
339
|
+
id: i.id,
|
|
340
|
+
component: i.component,
|
|
341
|
+
name: i.name,
|
|
342
|
+
initializeOpen: i.initializeOpen,
|
|
343
|
+
condition: u,
|
|
344
|
+
// eslint-disable-next-line sonarjs/deprecation -- kept for serialization backwards compatibility
|
|
345
|
+
decide: i.decide,
|
|
346
|
+
targets: i.targets,
|
|
347
|
+
steps: n,
|
|
376
348
|
nodes: s,
|
|
377
|
-
edges:
|
|
349
|
+
edges: t,
|
|
378
350
|
fields: N,
|
|
379
351
|
conditionals: d,
|
|
380
|
-
addStep(
|
|
381
|
-
let
|
|
382
|
-
this.nodes.length === 0 && (
|
|
383
|
-
const
|
|
384
|
-
if (
|
|
385
|
-
if (!
|
|
352
|
+
addStep(e, o) {
|
|
353
|
+
let r = o?.node;
|
|
354
|
+
this.nodes.length === 0 && (r = p({ type: "origin" }, this), this.nodes.push(r));
|
|
355
|
+
const l = "serialize" in e ? e : g(e, this);
|
|
356
|
+
if (r) {
|
|
357
|
+
if (!l.node)
|
|
386
358
|
throw new Error("todo no node");
|
|
387
359
|
const c = h(
|
|
388
|
-
{ sourceNode:
|
|
360
|
+
{ sourceNode: r, destinationNode: l.node, sourceNodeHandle: null },
|
|
389
361
|
this
|
|
390
362
|
);
|
|
391
363
|
this.edges.push(c);
|
|
392
364
|
}
|
|
393
|
-
return
|
|
365
|
+
return l.fields.length > 0 && l.fields.forEach((c) => {
|
|
394
366
|
this.fields.includes(c) || this.fields.push(c);
|
|
395
|
-
}), this.steps.includes(
|
|
367
|
+
}), this.steps.includes(l) || (this.steps.push(l), l.node && this.nodes.push(l.node)), l;
|
|
396
368
|
},
|
|
397
|
-
addAction(
|
|
398
|
-
let
|
|
399
|
-
this.nodes.length === 0 && (
|
|
400
|
-
const
|
|
401
|
-
if (
|
|
369
|
+
addAction(e, o) {
|
|
370
|
+
let r = o?.node;
|
|
371
|
+
this.nodes.length === 0 && (r = p({ type: "origin" }, this), this.nodes.push(r));
|
|
372
|
+
const l = "serialize" in e ? e : z(e, this);
|
|
373
|
+
if (r) {
|
|
402
374
|
const c = h(
|
|
403
|
-
{ sourceNode:
|
|
375
|
+
{ sourceNode: r, destinationNode: l, sourceNodeHandle: null },
|
|
404
376
|
this
|
|
405
377
|
);
|
|
406
378
|
this.edges.push(c);
|
|
407
379
|
}
|
|
408
|
-
return this.nodes.push(
|
|
380
|
+
return this.nodes.push(l), l;
|
|
409
381
|
},
|
|
410
|
-
addConditional(
|
|
411
|
-
let
|
|
412
|
-
this.nodes.length === 0 && (
|
|
413
|
-
const
|
|
414
|
-
if (
|
|
415
|
-
if (!
|
|
382
|
+
addConditional(e, o) {
|
|
383
|
+
let r = o?.node;
|
|
384
|
+
this.nodes.length === 0 && (r = p({ type: "origin" }, this), this.nodes.push(r));
|
|
385
|
+
const l = "serialize" in e ? e : b(e, this);
|
|
386
|
+
if (r) {
|
|
387
|
+
if (!l.node)
|
|
416
388
|
throw new Error("todo no node");
|
|
417
389
|
const c = h(
|
|
418
|
-
{ sourceNode:
|
|
390
|
+
{ sourceNode: r, destinationNode: l.node, sourceNodeHandle: null },
|
|
419
391
|
this
|
|
420
392
|
);
|
|
421
393
|
this.edges.push(c);
|
|
422
394
|
}
|
|
423
|
-
return this.conditionals.includes(
|
|
395
|
+
return this.conditionals.includes(l) || (this.conditionals.push(l), l.node && this.nodes.push(l.node)), l;
|
|
424
396
|
},
|
|
425
|
-
addExperience(
|
|
426
|
-
let
|
|
427
|
-
this.nodes.length === 0 && (
|
|
428
|
-
const
|
|
429
|
-
{ type: "experience", experience:
|
|
397
|
+
addExperience(e, o) {
|
|
398
|
+
let r = o?.node;
|
|
399
|
+
this.nodes.length === 0 && (r = p({ type: "origin" }, this), this.nodes.push(r));
|
|
400
|
+
const l = p(
|
|
401
|
+
{ type: "experience", experience: e },
|
|
430
402
|
this
|
|
431
403
|
);
|
|
432
|
-
if (this.nodes.push(
|
|
404
|
+
if (this.nodes.push(l), r) {
|
|
433
405
|
const c = h(
|
|
434
|
-
{ sourceNode:
|
|
406
|
+
{ sourceNode: r, destinationNode: l, sourceNodeHandle: null },
|
|
435
407
|
this
|
|
436
408
|
);
|
|
437
409
|
this.edges.push(c);
|
|
438
410
|
}
|
|
439
|
-
return
|
|
411
|
+
return e;
|
|
440
412
|
},
|
|
441
|
-
addField(
|
|
442
|
-
const
|
|
443
|
-
return
|
|
413
|
+
addField(e, o) {
|
|
414
|
+
const r = "serialize" in e ? e : y(e);
|
|
415
|
+
return o && o.fields.push(r), this.fields.includes(r) || this.fields.push(r), r;
|
|
444
416
|
},
|
|
445
417
|
serialize() {
|
|
446
|
-
return
|
|
418
|
+
return a.serialize({
|
|
447
419
|
id: this.id,
|
|
448
420
|
component: this.component,
|
|
449
421
|
name: this.name,
|
|
450
422
|
initializeOpen: this.initializeOpen,
|
|
423
|
+
// eslint-disable-next-line sonarjs/deprecation -- backwards compatibility: `decide` is deprecated but still supported
|
|
451
424
|
condition: this.condition ?? this.decide,
|
|
425
|
+
// eslint-disable-next-line sonarjs/deprecation -- kept for serialization backwards compatibility
|
|
452
426
|
decide: this.decide,
|
|
453
427
|
targets: this.targets,
|
|
454
|
-
steps: this.steps.map((
|
|
455
|
-
nodes: this.nodes.map((
|
|
456
|
-
edges: this.edges.map((
|
|
428
|
+
steps: this.steps.map((e) => a.deserialize(e.serialize())),
|
|
429
|
+
nodes: this.nodes.map((e) => a.deserialize(e.serialize())),
|
|
430
|
+
edges: this.edges.map((e) => a.deserialize(e.serialize())),
|
|
457
431
|
conditionals: this.conditionals.map(
|
|
458
|
-
(
|
|
432
|
+
(e) => a.deserialize(e.serialize())
|
|
459
433
|
),
|
|
460
|
-
fields: this.fields.map((
|
|
434
|
+
fields: this.fields.map((e) => a.deserialize(e.serialize()))
|
|
461
435
|
});
|
|
462
436
|
}
|
|
463
437
|
};
|
|
@@ -465,10 +439,10 @@ const r = {
|
|
|
465
439
|
export {
|
|
466
440
|
b as createConditional,
|
|
467
441
|
h as createEdge,
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
442
|
+
w as createExperience,
|
|
443
|
+
V as createExperiencePlugin,
|
|
444
|
+
y as createField,
|
|
471
445
|
p as createNode,
|
|
472
|
-
|
|
473
|
-
|
|
446
|
+
E as createStep,
|
|
447
|
+
a as serialization
|
|
474
448
|
};
|