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