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