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