@picked/client 0.0.1-dev.1774231221701 → 0.0.1-dev.1774912386475
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-BEXzPJHZ.cjs → api-B-wGEgt8.cjs} +1 -1
- package/dist/{api-oudcFuUX.js → api-DwERBrAZ.js} +1 -1
- package/dist/cjs/form/index.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/responses-browser-storage/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/form/index.js +128 -84
- package/dist/esm/index.js +393 -334
- package/dist/esm/plugins/create-experience/index.js +183 -151
- package/dist/esm/plugins/dynamic-experiences/index.js +52 -30
- package/dist/esm/plugins/responses-browser-storage/index.js +47 -20
- package/dist/esm/plugins/web-components/index.js +1 -1
- package/dist/esm/server/index.js +1 -1
- package/dist/{experience-instance-DZiAwXph.js → experience-instance-CwwrKUI8.js} +50 -46
- package/dist/experience-instance-DdFUcVRd.cjs +1 -0
- package/dist/{rules-logic-B7vJrWyO.js → rules-logic-BIkBWZmf.js} +4 -2
- package/dist/rules-logic-DDxCiq4P.cjs +1 -0
- 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 +40 -35
- package/dist/types/entities/experience/experience.d.ts.map +1 -1
- package/dist/types/entities/experience-instance/experience-instance.d.ts +21 -2
- package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
- package/dist/types/entities/field/field.d.ts +13 -2
- package/dist/types/entities/field/field.d.ts.map +1 -1
- package/dist/types/entities/response/response-validation.d.ts +76 -0
- package/dist/types/entities/response/response-validation.d.ts.map +1 -0
- package/dist/types/entities/response/response.d.ts +24 -17
- package/dist/types/entities/response/response.d.ts.map +1 -1
- package/dist/types/entities/step/step.d.ts +36 -0
- package/dist/types/entities/step/step.d.ts.map +1 -0
- package/dist/types/form/build-responses.d.ts +12 -9
- package/dist/types/form/build-responses.d.ts.map +1 -1
- package/dist/types/form/create-field-evaluator.d.ts +11 -3
- package/dist/types/form/create-field-evaluator.d.ts.map +1 -1
- package/dist/types/form/create-field-validation.d.ts +21 -6
- package/dist/types/form/create-field-validation.d.ts.map +1 -1
- package/dist/types/form/create-form.d.ts +42 -11
- package/dist/types/form/create-form.d.ts.map +1 -1
- package/dist/types/form/create-submit-pipeline.d.ts +21 -9
- package/dist/types/form/create-submit-pipeline.d.ts.map +1 -1
- package/dist/types/form/get-step-fields.d.ts +13 -0
- package/dist/types/form/get-step-fields.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/logic-engine.d.ts +10 -2
- package/dist/types/logic-engine.d.ts.map +1 -1
- package/dist/types/picked.d.ts +68 -32
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/create-experience/create-experience.d.ts +51 -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/create-experience/serialization.d.ts +1 -0
- package/dist/types/plugins/create-experience/serialization.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 +41 -0
- package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
- package/dist/types/plugins/responses-browser-storage/plugin.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/node-tree/get-next-node-from-condition.d.ts +3 -0
- package/dist/types/utils/node-tree/get-next-node-from-condition.d.ts.map +1 -0
- package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts +10 -6
- package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts.map +1 -1
- package/dist/types/utils/nodes.d.ts +74 -2
- package/dist/types/utils/nodes.d.ts.map +1 -1
- package/dist/types/utils/rules-logic.d.ts +31 -0
- package/dist/types/utils/rules-logic.d.ts.map +1 -1
- package/package.json +32 -6
- package/dist/experience-instance-Ddk4Jktn.cjs +0 -1
- package/dist/rules-logic-CXr4wXcG.cjs +0 -1
- package/dist/types/utils/node-tree/get-next-node-from-conditional.d.ts +0 -3
- package/dist/types/utils/node-tree/get-next-node-from-conditional.d.ts.map +0 -1
|
@@ -12,8 +12,14 @@ var t = {
|
|
|
12
12
|
setup: (n) => {
|
|
13
13
|
e.experiences.forEach((e) => {
|
|
14
14
|
let r = e.serialize(), i = t.deserialize(r);
|
|
15
|
-
i.component = e.component
|
|
15
|
+
i.component = e.component;
|
|
16
|
+
let { steps: a, conditions: o, fields: s, ...c } = i;
|
|
17
|
+
n.registerExperience(c), s.forEach((e) => {
|
|
16
18
|
n.registerField(e);
|
|
19
|
+
}), a.forEach((e) => {
|
|
20
|
+
n.registerStep(e);
|
|
21
|
+
}), o.forEach((e) => {
|
|
22
|
+
n.registerCondition(e);
|
|
17
23
|
});
|
|
18
24
|
});
|
|
19
25
|
}
|
|
@@ -56,26 +62,36 @@ var t = {
|
|
|
56
62
|
action: this.action
|
|
57
63
|
});
|
|
58
64
|
}
|
|
59
|
-
}), i = (t) =>
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
}), i = (t) => {
|
|
66
|
+
let n = t.name, r = t.id ?? e("step");
|
|
67
|
+
return {
|
|
68
|
+
id: r,
|
|
69
|
+
name: n,
|
|
70
|
+
key: t.key ?? r,
|
|
71
|
+
label: n,
|
|
72
|
+
fields: t.fields ?? [],
|
|
73
|
+
addField(e) {
|
|
74
|
+
let t = "serialize" in e ? e : l(e);
|
|
75
|
+
return this.fields.includes(t) || this.fields.push(t), t;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}, a = (n, r) => {
|
|
79
|
+
let i = n.name, a = n.id ?? e("step"), s = {
|
|
80
|
+
id: a,
|
|
81
|
+
name: i,
|
|
82
|
+
key: n.key ?? a,
|
|
83
|
+
label: i,
|
|
71
84
|
experience: r,
|
|
72
85
|
fields: n.fields ?? [],
|
|
73
86
|
node: null,
|
|
74
87
|
nextStep(e) {
|
|
75
88
|
return this.experience.addStep(e, this);
|
|
76
89
|
},
|
|
90
|
+
nextCondition(e) {
|
|
91
|
+
return this.experience.addCondition(e, this);
|
|
92
|
+
},
|
|
77
93
|
nextConditional(e) {
|
|
78
|
-
return this.
|
|
94
|
+
return this.nextCondition(e);
|
|
79
95
|
},
|
|
80
96
|
addNextExperience(e) {
|
|
81
97
|
return this.experience.addExperience(e, this);
|
|
@@ -86,15 +102,17 @@ var t = {
|
|
|
86
102
|
serialize() {
|
|
87
103
|
return t.serialize({
|
|
88
104
|
id: this.id,
|
|
105
|
+
key: this.key,
|
|
106
|
+
name: this.name,
|
|
89
107
|
label: this.label,
|
|
90
108
|
fieldIds: this.fields.map((e) => e.id)
|
|
91
109
|
});
|
|
92
110
|
}
|
|
93
111
|
};
|
|
94
112
|
return o({
|
|
95
|
-
step:
|
|
113
|
+
step: s,
|
|
96
114
|
type: "step"
|
|
97
|
-
}, r),
|
|
115
|
+
}, r), s;
|
|
98
116
|
}, o = (n, r) => {
|
|
99
117
|
let i = {
|
|
100
118
|
id: e("node"),
|
|
@@ -110,26 +128,27 @@ var t = {
|
|
|
110
128
|
id: this.id,
|
|
111
129
|
type: this.type,
|
|
112
130
|
stepId: this.connectedStep.id,
|
|
131
|
+
name: this.connectedStep.name,
|
|
113
132
|
label: this.connectedStep.label
|
|
114
133
|
});
|
|
115
134
|
}
|
|
116
135
|
};
|
|
117
136
|
return e.connectedStep.node = e, e;
|
|
118
137
|
}
|
|
119
|
-
if (n.type === "
|
|
138
|
+
if (n.type === "condition") {
|
|
120
139
|
let e = {
|
|
121
140
|
...i,
|
|
122
|
-
type: "
|
|
123
|
-
|
|
141
|
+
type: "condition",
|
|
142
|
+
connectedCondition: n.condition,
|
|
124
143
|
serialize() {
|
|
125
144
|
return t.serialize({
|
|
126
145
|
id: this.id,
|
|
127
146
|
type: this.type,
|
|
128
|
-
|
|
147
|
+
conditionId: this.connectedCondition.id
|
|
129
148
|
});
|
|
130
149
|
}
|
|
131
150
|
};
|
|
132
|
-
return e.
|
|
151
|
+
return e.connectedCondition.node = e, e;
|
|
133
152
|
}
|
|
134
153
|
return n.type === "experience" ? {
|
|
135
154
|
...i,
|
|
@@ -167,10 +186,12 @@ var t = {
|
|
|
167
186
|
});
|
|
168
187
|
}
|
|
169
188
|
}), c = (n, r) => {
|
|
170
|
-
let i = {
|
|
171
|
-
id:
|
|
189
|
+
let i = e("conditional"), a = n.name ?? n.label ?? i, c = {
|
|
190
|
+
id: i,
|
|
191
|
+
key: n.key ?? i,
|
|
192
|
+
name: a,
|
|
172
193
|
label: n.label,
|
|
173
|
-
|
|
194
|
+
logic: n.condition,
|
|
174
195
|
node: null,
|
|
175
196
|
experience: r,
|
|
176
197
|
addTrue(e) {
|
|
@@ -194,59 +215,77 @@ var t = {
|
|
|
194
215
|
serialize() {
|
|
195
216
|
return t.serialize({
|
|
196
217
|
id: this.id,
|
|
197
|
-
|
|
198
|
-
|
|
218
|
+
key: this.key,
|
|
219
|
+
name: this.name,
|
|
220
|
+
logic: this.logic
|
|
199
221
|
});
|
|
200
222
|
}
|
|
201
223
|
};
|
|
202
224
|
return o({
|
|
203
|
-
|
|
204
|
-
type: "
|
|
205
|
-
}, r),
|
|
206
|
-
}, l = (n) =>
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
225
|
+
condition: c,
|
|
226
|
+
type: "condition"
|
|
227
|
+
}, r), c;
|
|
228
|
+
}, l = (n) => {
|
|
229
|
+
let r = n.id ?? e("field");
|
|
230
|
+
return {
|
|
231
|
+
id: r,
|
|
232
|
+
key: n.key ?? r,
|
|
233
|
+
name: n.name,
|
|
234
|
+
type: n.type,
|
|
235
|
+
label: n.label,
|
|
236
|
+
placeholder: n.placeholder,
|
|
237
|
+
description: n.description,
|
|
238
|
+
helpText: n.helpText,
|
|
239
|
+
defaultValue: n.defaultValue ?? null,
|
|
240
|
+
multiple: n.multiple,
|
|
241
|
+
validation: n.validation ?? {},
|
|
242
|
+
condition: n.condition,
|
|
243
|
+
required: n.required,
|
|
244
|
+
options: n.options?.map((t) => ({
|
|
245
|
+
id: "id" in t ? t.id : e("option"),
|
|
246
|
+
...t
|
|
247
|
+
})) ?? null,
|
|
248
|
+
policies: n.policies,
|
|
249
|
+
serialize() {
|
|
250
|
+
let e = {
|
|
251
|
+
id: this.id,
|
|
252
|
+
key: this.key,
|
|
253
|
+
name: this.name,
|
|
254
|
+
label: this.label,
|
|
255
|
+
placeholder: this.placeholder,
|
|
256
|
+
required: this.required,
|
|
257
|
+
description: this.description,
|
|
258
|
+
helpText: this.helpText,
|
|
259
|
+
validation: this.validation,
|
|
260
|
+
condition: this.condition,
|
|
261
|
+
policies: this.policies
|
|
262
|
+
}, n = typeof this.defaultValue == "string" ? this.defaultValue : void 0, r = typeof this.defaultValue == "number" ? this.defaultValue : void 0, i = typeof this.defaultValue == "boolean" ? this.defaultValue : void 0;
|
|
263
|
+
switch (this.type) {
|
|
264
|
+
case "text":
|
|
265
|
+
if (this.multiple) {
|
|
266
|
+
let n;
|
|
267
|
+
if (Array.isArray(this.defaultValue)) {
|
|
268
|
+
n = [];
|
|
269
|
+
for (let e of this.defaultValue) typeof e == "string" && n.push(e);
|
|
270
|
+
n.length === 0 && (n = void 0);
|
|
271
|
+
}
|
|
272
|
+
return t.serialize({
|
|
273
|
+
...e,
|
|
274
|
+
type: "text",
|
|
275
|
+
multiple: !0,
|
|
276
|
+
defaultValue: n,
|
|
277
|
+
options: this.options ? this.options.map((e) => ({
|
|
278
|
+
id: e.id,
|
|
279
|
+
label: e.label,
|
|
280
|
+
value: `${e.value}`,
|
|
281
|
+
condition: e.condition
|
|
282
|
+
})) : null
|
|
283
|
+
});
|
|
245
284
|
}
|
|
246
285
|
return t.serialize({
|
|
247
286
|
...e,
|
|
248
287
|
type: "text",
|
|
249
|
-
multiple: !
|
|
288
|
+
multiple: !1,
|
|
250
289
|
defaultValue: n,
|
|
251
290
|
options: this.options ? this.options.map((e) => ({
|
|
252
291
|
id: e.id,
|
|
@@ -255,32 +294,32 @@ var t = {
|
|
|
255
294
|
condition: e.condition
|
|
256
295
|
})) : null
|
|
257
296
|
});
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
297
|
+
case "number":
|
|
298
|
+
if (this.multiple) {
|
|
299
|
+
let n;
|
|
300
|
+
if (Array.isArray(this.defaultValue)) {
|
|
301
|
+
n = [];
|
|
302
|
+
for (let e of this.defaultValue) typeof e == "number" && n.push(e);
|
|
303
|
+
n.length === 0 && (n = void 0);
|
|
304
|
+
}
|
|
305
|
+
return t.serialize({
|
|
306
|
+
...e,
|
|
307
|
+
type: "number",
|
|
308
|
+
multiple: !0,
|
|
309
|
+
defaultValue: n,
|
|
310
|
+
options: this.options ? this.options.map((e) => ({
|
|
311
|
+
id: e.id,
|
|
312
|
+
label: e.label,
|
|
313
|
+
value: Number(e.value),
|
|
314
|
+
condition: e.condition
|
|
315
|
+
})) : null
|
|
316
|
+
});
|
|
278
317
|
}
|
|
279
318
|
return t.serialize({
|
|
280
319
|
...e,
|
|
281
320
|
type: "number",
|
|
282
|
-
multiple: !
|
|
283
|
-
defaultValue:
|
|
321
|
+
multiple: !1,
|
|
322
|
+
defaultValue: r,
|
|
284
323
|
options: this.options ? this.options.map((e) => ({
|
|
285
324
|
id: e.id,
|
|
286
325
|
label: e.label,
|
|
@@ -288,32 +327,32 @@ var t = {
|
|
|
288
327
|
condition: e.condition
|
|
289
328
|
})) : null
|
|
290
329
|
});
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
330
|
+
case "boolean":
|
|
331
|
+
if (this.multiple) {
|
|
332
|
+
let n;
|
|
333
|
+
if (Array.isArray(this.defaultValue)) {
|
|
334
|
+
n = [];
|
|
335
|
+
for (let e of this.defaultValue) typeof e == "boolean" && n.push(e);
|
|
336
|
+
n.length === 0 && (n = void 0);
|
|
337
|
+
}
|
|
338
|
+
return t.serialize({
|
|
339
|
+
...e,
|
|
340
|
+
type: "boolean",
|
|
341
|
+
multiple: !0,
|
|
342
|
+
defaultValue: n,
|
|
343
|
+
options: this.options ? this.options.map((e) => ({
|
|
344
|
+
id: e.id,
|
|
345
|
+
label: e.label,
|
|
346
|
+
value: !!e.value,
|
|
347
|
+
condition: e.condition
|
|
348
|
+
})) : null
|
|
349
|
+
});
|
|
311
350
|
}
|
|
312
351
|
return t.serialize({
|
|
313
352
|
...e,
|
|
314
353
|
type: "boolean",
|
|
315
|
-
multiple: !
|
|
316
|
-
defaultValue:
|
|
354
|
+
multiple: !1,
|
|
355
|
+
defaultValue: i,
|
|
317
356
|
options: this.options ? this.options.map((e) => ({
|
|
318
357
|
id: e.id,
|
|
319
358
|
label: e.label,
|
|
@@ -321,49 +360,38 @@ var t = {
|
|
|
321
360
|
condition: e.condition
|
|
322
361
|
})) : null
|
|
323
362
|
});
|
|
324
|
-
|
|
325
|
-
return t.serialize({
|
|
363
|
+
case "object": return this.multiple ? t.serialize({
|
|
326
364
|
...e,
|
|
327
|
-
type: "
|
|
365
|
+
type: "object",
|
|
366
|
+
multiple: !0,
|
|
367
|
+
defaultValue: this.defaultValue,
|
|
368
|
+
options: this.options ? this.options.map((e) => ({
|
|
369
|
+
id: e.id,
|
|
370
|
+
label: e.label,
|
|
371
|
+
description: e.description,
|
|
372
|
+
value: e.value,
|
|
373
|
+
condition: e.condition
|
|
374
|
+
})) : null
|
|
375
|
+
}) : t.serialize({
|
|
376
|
+
...e,
|
|
377
|
+
type: "object",
|
|
328
378
|
multiple: !1,
|
|
329
|
-
defaultValue:
|
|
379
|
+
defaultValue: this.defaultValue,
|
|
330
380
|
options: this.options ? this.options.map((e) => ({
|
|
331
381
|
id: e.id,
|
|
332
382
|
label: e.label,
|
|
333
|
-
|
|
383
|
+
description: e.description,
|
|
384
|
+
value: e.value,
|
|
334
385
|
condition: e.condition
|
|
335
386
|
})) : null
|
|
336
387
|
});
|
|
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");
|
|
388
|
+
default: throw Error("Unsupported field type");
|
|
389
|
+
}
|
|
363
390
|
}
|
|
364
|
-
}
|
|
365
|
-
}
|
|
391
|
+
};
|
|
392
|
+
}, u = (e) => ({
|
|
366
393
|
id: e.id,
|
|
394
|
+
key: e.key,
|
|
367
395
|
component: e.component,
|
|
368
396
|
name: e.name,
|
|
369
397
|
initializeOpen: e.initializeOpen,
|
|
@@ -373,7 +401,7 @@ var t = {
|
|
|
373
401
|
nodes: [],
|
|
374
402
|
edges: [],
|
|
375
403
|
fields: [],
|
|
376
|
-
|
|
404
|
+
conditions: [],
|
|
377
405
|
addStep(e, t) {
|
|
378
406
|
let n = t?.node;
|
|
379
407
|
this.nodes.length === 0 && (n = o({ type: "origin" }, this), this.nodes.push(n));
|
|
@@ -405,7 +433,7 @@ var t = {
|
|
|
405
433
|
}
|
|
406
434
|
return this.nodes.push(i), i;
|
|
407
435
|
},
|
|
408
|
-
|
|
436
|
+
addCondition(e, t) {
|
|
409
437
|
let n = t?.node;
|
|
410
438
|
this.nodes.length === 0 && (n = o({ type: "origin" }, this), this.nodes.push(n));
|
|
411
439
|
let r = "serialize" in e ? e : c(e, this);
|
|
@@ -418,7 +446,10 @@ var t = {
|
|
|
418
446
|
}, this);
|
|
419
447
|
this.edges.push(e);
|
|
420
448
|
}
|
|
421
|
-
return this.
|
|
449
|
+
return this.conditions.includes(r) || (this.conditions.push(r), r.node && this.nodes.push(r.node)), r;
|
|
450
|
+
},
|
|
451
|
+
addConditional(e, t) {
|
|
452
|
+
return this.addCondition(e, t);
|
|
422
453
|
},
|
|
423
454
|
addExperience(e, t) {
|
|
424
455
|
let n = t?.node;
|
|
@@ -444,6 +475,7 @@ var t = {
|
|
|
444
475
|
serialize() {
|
|
445
476
|
return t.serialize({
|
|
446
477
|
id: this.id,
|
|
478
|
+
key: this.key,
|
|
447
479
|
component: this.component,
|
|
448
480
|
name: this.name,
|
|
449
481
|
initializeOpen: this.initializeOpen,
|
|
@@ -452,10 +484,10 @@ var t = {
|
|
|
452
484
|
steps: this.steps.map((e) => t.deserialize(e.serialize())),
|
|
453
485
|
nodes: this.nodes.map((e) => t.deserialize(e.serialize())),
|
|
454
486
|
edges: this.edges.map((e) => t.deserialize(e.serialize())),
|
|
455
|
-
|
|
487
|
+
conditions: this.conditions.map((e) => t.deserialize(e.serialize())),
|
|
456
488
|
fields: this.fields.map((e) => t.deserialize(e.serialize()))
|
|
457
489
|
});
|
|
458
490
|
}
|
|
459
491
|
});
|
|
460
492
|
//#endregion
|
|
461
|
-
export { c as
|
|
493
|
+
export { c as createCondition, s as createEdge, u as createExperience, n as createExperiencePlugin, l as createField, o as createNode, i as createStep };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../../../logger-6z_gb4rA.js";
|
|
2
|
-
import { i as e, t } from "../../../api-
|
|
2
|
+
import { i as e, t } from "../../../api-DwERBrAZ.js";
|
|
3
3
|
//#region src/plugins/dynamic-experiences/hash.ts
|
|
4
4
|
function n(e) {
|
|
5
5
|
let t = 2166136261;
|
|
@@ -15,16 +15,38 @@ function i(e, t) {
|
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region src/plugins/dynamic-experiences/plugin.ts
|
|
17
17
|
function a(e) {
|
|
18
|
-
return typeof e
|
|
18
|
+
return typeof e == "object" && !!e && "features" in e && Array.isArray(e.features);
|
|
19
19
|
}
|
|
20
|
-
function o(e) {
|
|
21
|
-
|
|
20
|
+
function o(e, t) {
|
|
21
|
+
for (let n of t.conditions) e.registerCondition(n);
|
|
22
22
|
}
|
|
23
|
-
function s(e) {
|
|
23
|
+
function s(e, t) {
|
|
24
|
+
e.registerExperience({
|
|
25
|
+
id: t.id,
|
|
26
|
+
key: t.key,
|
|
27
|
+
name: t.name,
|
|
28
|
+
targets: t.targets,
|
|
29
|
+
nodes: t.nodes,
|
|
30
|
+
edges: t.edges,
|
|
31
|
+
condition: t.condition,
|
|
32
|
+
initializeOpen: t.initializeOpen,
|
|
33
|
+
componentName: t.componentName
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function c(e, t) {
|
|
37
|
+
for (let n of t.fields) e.registerField(n);
|
|
38
|
+
}
|
|
39
|
+
function l(e, t) {
|
|
40
|
+
for (let n of t.steps) e.registerStep(n);
|
|
41
|
+
}
|
|
42
|
+
function u(e, t) {
|
|
43
|
+
for (let n of t.experiences) s(e, n);
|
|
44
|
+
}
|
|
45
|
+
function d(e) {
|
|
24
46
|
let t = e.searchParams["preview-token"];
|
|
25
47
|
if (t && t.length > 0) return t[0];
|
|
26
48
|
}
|
|
27
|
-
function
|
|
49
|
+
function f(e) {
|
|
28
50
|
let t = /* @__PURE__ */ new Set(), n = e.searchParams.feature;
|
|
29
51
|
if (!n) return t;
|
|
30
52
|
for (let e of n) {
|
|
@@ -33,13 +55,13 @@ function c(e) {
|
|
|
33
55
|
}
|
|
34
56
|
return t;
|
|
35
57
|
}
|
|
36
|
-
function
|
|
37
|
-
let i =
|
|
58
|
+
function p(e, t, n) {
|
|
59
|
+
let i = f(e), a = e.session?.id;
|
|
38
60
|
if (!a) throw Error("Session ID is required for feature registration");
|
|
39
61
|
let o = r(a);
|
|
40
|
-
for (let r of t.features) i.has(r.id) ||
|
|
62
|
+
for (let r of t.features) i.has(r.id) || m(e, r, n, o);
|
|
41
63
|
}
|
|
42
|
-
function
|
|
64
|
+
function m(e, t, n, r) {
|
|
43
65
|
e.registerFeature(t.id, {
|
|
44
66
|
key: `v${t.version}`,
|
|
45
67
|
name: t.name,
|
|
@@ -47,7 +69,7 @@ function u(e, t, n, r) {
|
|
|
47
69
|
decide: () => t.enabled ? i(r, t.weight) : !1
|
|
48
70
|
});
|
|
49
71
|
}
|
|
50
|
-
function
|
|
72
|
+
function h() {
|
|
51
73
|
let e;
|
|
52
74
|
try {
|
|
53
75
|
e = __PICKED_PROJECT_CONFIG__;
|
|
@@ -62,9 +84,9 @@ function d() {
|
|
|
62
84
|
return;
|
|
63
85
|
}
|
|
64
86
|
else t = e;
|
|
65
|
-
if (
|
|
87
|
+
if (a(t)) return t;
|
|
66
88
|
}
|
|
67
|
-
function
|
|
89
|
+
function g(e) {
|
|
68
90
|
try {
|
|
69
91
|
let t = new URL(e).hostname;
|
|
70
92
|
return t === "localhost" || t === "127.0.0.1" || t === "::1";
|
|
@@ -72,49 +94,49 @@ function f(e) {
|
|
|
72
94
|
return !1;
|
|
73
95
|
}
|
|
74
96
|
}
|
|
75
|
-
function
|
|
97
|
+
function _(e) {
|
|
76
98
|
if (typeof e != "object" || !e || !("cause" in e)) return !1;
|
|
77
99
|
let { cause: t } = e;
|
|
78
100
|
return typeof t != "object" || !t || !("code" in t) ? !1 : t.code === "ECONNREFUSED";
|
|
79
101
|
}
|
|
80
|
-
async function
|
|
81
|
-
let i = r?.previewToken ? `projects/${n}?preview_token=${encodeURIComponent(r.previewToken)}` : `projects/${n}`,
|
|
102
|
+
async function v(e, n, r) {
|
|
103
|
+
let i = r?.previewToken ? `projects/${n}?preview_token=${encodeURIComponent(r.previewToken)}` : `projects/${n}`, o;
|
|
82
104
|
try {
|
|
83
|
-
|
|
105
|
+
o = await t(e, i, r?.headers);
|
|
84
106
|
} catch (t) {
|
|
85
|
-
return
|
|
107
|
+
return g(e) && _(t), null;
|
|
86
108
|
}
|
|
87
|
-
if (!
|
|
109
|
+
if (!o.ok) return `${o.status.toString()}`, null;
|
|
88
110
|
let s;
|
|
89
111
|
try {
|
|
90
|
-
s = await
|
|
112
|
+
s = await o.json();
|
|
91
113
|
} catch {
|
|
92
114
|
return null;
|
|
93
115
|
}
|
|
94
|
-
return
|
|
116
|
+
return a(s) ? s : null;
|
|
95
117
|
}
|
|
96
|
-
function
|
|
118
|
+
function y(e) {
|
|
97
119
|
return {
|
|
98
120
|
name: "dynamic-experiences",
|
|
99
121
|
setup: (t) => {
|
|
100
122
|
let n = e?.apiUrl ?? t.apiUrl;
|
|
101
123
|
return { onStart: async () => {
|
|
102
|
-
let r =
|
|
124
|
+
let r = d(t);
|
|
103
125
|
if (r) {
|
|
104
|
-
let e = await
|
|
105
|
-
e &&
|
|
126
|
+
let e = await v(n, t.projectId, { previewToken: r });
|
|
127
|
+
e && (p(t, e, !0), o(t, e), c(t, e), l(t, e), u(t, e));
|
|
106
128
|
return;
|
|
107
129
|
}
|
|
108
|
-
let i = e?.projectConfig ??
|
|
130
|
+
let i = e?.projectConfig ?? h();
|
|
109
131
|
if (i) {
|
|
110
|
-
|
|
132
|
+
p(t, i, !1), o(t, i), c(t, i), l(t, i), u(t, i);
|
|
111
133
|
return;
|
|
112
134
|
}
|
|
113
|
-
let a = await
|
|
114
|
-
a &&
|
|
135
|
+
let a = await v(n, t.projectId);
|
|
136
|
+
a && (p(t, a, !1), o(t, a), c(t, a), l(t, a), u(t, a));
|
|
115
137
|
} };
|
|
116
138
|
}
|
|
117
139
|
};
|
|
118
140
|
}
|
|
119
141
|
//#endregion
|
|
120
|
-
export { e as createClientHeaders,
|
|
142
|
+
export { e as createClientHeaders, y as dynamicExperiencesPlugin, v as fetchProject };
|