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