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