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