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