@picked/client 0.0.39-next.1 → 0.0.39-next.3

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.
@@ -6,42 +6,42 @@ const r = {
6
6
  deserialize(e) {
7
7
  return JSON.parse(e);
8
8
  }
9
- }, v = (e) => ({
9
+ }, x = (e) => ({
10
10
  name: "create-experience",
11
11
  setup: (o) => {
12
- e.experiences.forEach((n) => {
13
- const s = n.serialize(), d = r.deserialize(s);
14
- d.component = n.component, o.registerExperience(d), d.fields.forEach((N) => {
12
+ e.experiences.forEach((s) => {
13
+ const n = s.serialize(), d = r.deserialize(n);
14
+ d.component = s.component, o.registerExperience(d), d.fields.forEach((N) => {
15
15
  o.registerField(N);
16
16
  });
17
17
  });
18
18
  }
19
- }), g = (e, o) => ({
19
+ }), y = (e, o) => ({
20
20
  id: f("node"),
21
21
  position: [0, 0],
22
22
  experience: o,
23
23
  type: "action",
24
24
  action: e.action,
25
- addNext(s) {
26
- if (!s.node) throw new Error("Cannot connect to node");
25
+ addNext(n) {
26
+ if (!n.node) throw new Error("Cannot connect to node");
27
27
  const d = h(
28
- { sourceNode: this, destinationNode: s.node, sourceNodeHandle: null },
28
+ { sourceNode: this, destinationNode: n.node, sourceNodeHandle: null },
29
29
  o
30
30
  );
31
31
  o.edges.push(d);
32
32
  },
33
- onSuccess(s) {
34
- if (!s.node) throw new Error("Cannot connect to node");
33
+ onSuccess(n) {
34
+ if (!n.node) throw new Error("Cannot connect to node");
35
35
  const d = h(
36
- { sourceNode: this, destinationNode: s.node, sourceNodeHandle: "true" },
36
+ { sourceNode: this, destinationNode: n.node, sourceNodeHandle: "true" },
37
37
  o
38
38
  );
39
39
  o.edges.push(d);
40
40
  },
41
- onFail(s) {
42
- if (!s.node) throw new Error("Cannot connect to node");
41
+ onFail(n) {
42
+ if (!n.node) throw new Error("Cannot connect to node");
43
43
  const d = h(
44
- { sourceNode: this, destinationNode: s.node, sourceNodeHandle: "false" },
44
+ { sourceNode: this, destinationNode: n.node, sourceNodeHandle: "false" },
45
45
  o
46
46
  );
47
47
  o.edges.push(d);
@@ -54,51 +54,51 @@ const r = {
54
54
  position: this.position
55
55
  });
56
56
  }
57
- }), E = (e) => ({
57
+ }), V = (e) => ({
58
58
  id: e.id ?? f("step"),
59
59
  label: e.label,
60
60
  fields: e.fields ?? [],
61
61
  addField(o) {
62
- const n = "serialize" in o ? o : m(o);
63
- return this.fields?.includes(n) || this.fields?.push(n), n;
62
+ const s = "serialize" in o ? o : m(o);
63
+ return this.fields?.includes(s) || this.fields?.push(s), s;
64
64
  }
65
- }), y = (e, o) => {
66
- const n = {
65
+ }), z = (e, o) => {
66
+ const s = {
67
67
  id: e.id ?? f("step"),
68
68
  label: e.label,
69
69
  experience: o,
70
70
  fields: e.fields ?? [],
71
71
  node: null,
72
- nextStep(s) {
73
- return this.experience.addStep(s, this);
72
+ nextStep(n) {
73
+ return this.experience.addStep(n, this);
74
74
  },
75
- nextConditional(s) {
76
- return this.experience.addConditional(s, this);
75
+ nextConditional(n) {
76
+ return this.experience.addConditional(n, this);
77
77
  },
78
- addNextExperience(s) {
79
- return this.experience.addExperience(s, this);
78
+ addNextExperience(n) {
79
+ return this.experience.addExperience(n, this);
80
80
  },
81
- addField(s) {
82
- return this.experience.addField(s, this);
81
+ addField(n) {
82
+ return this.experience.addField(n, this);
83
83
  },
84
84
  serialize() {
85
85
  return r.serialize({
86
86
  id: this.id,
87
87
  label: this.label,
88
- fieldIds: this.fields.map((s) => s.id)
88
+ fieldIds: this.fields.map((n) => n.id)
89
89
  });
90
90
  }
91
91
  };
92
- return p({ step: n, type: "step" }, o), n;
93
- }, z = () => [0, 0], p = (e, o) => {
94
- const n = {
92
+ return p({ step: s, type: "step" }, o), s;
93
+ }, g = () => [0, 0], p = (e, o) => {
94
+ const s = {
95
95
  id: f("node"),
96
- position: z(),
96
+ position: g(),
97
97
  experience: o
98
98
  };
99
99
  if (e.type === "step") {
100
100
  const d = {
101
- ...n,
101
+ ...s,
102
102
  type: "step",
103
103
  connectedStep: e.step,
104
104
  serialize() {
@@ -115,7 +115,7 @@ const r = {
115
115
  }
116
116
  if (e.type === "conditional") {
117
117
  const d = {
118
- ...n,
118
+ ...s,
119
119
  type: "conditional",
120
120
  connectedConditional: e.conditional,
121
121
  serialize() {
@@ -130,7 +130,7 @@ const r = {
130
130
  return d.connectedConditional.node = d, d;
131
131
  }
132
132
  return e.type === "experience" ? {
133
- ...n,
133
+ ...s,
134
134
  type: "experience",
135
135
  connectedExperience: e.experience,
136
136
  serialize() {
@@ -142,7 +142,7 @@ const r = {
142
142
  });
143
143
  }
144
144
  } : {
145
- ...n,
145
+ ...s,
146
146
  type: "origin",
147
147
  serialize() {
148
148
  return r.serialize({
@@ -167,25 +167,25 @@ const r = {
167
167
  });
168
168
  }
169
169
  }), b = (e, o) => {
170
- const n = {
170
+ const s = {
171
171
  id: f("conditional"),
172
172
  condition: e.condition,
173
173
  node: null,
174
174
  experience: o,
175
- addTrue(s) {
176
- if (!this.node || !s.node)
175
+ addTrue(n) {
176
+ if (!this.node || !n.node)
177
177
  throw new Error("todo no node");
178
178
  const d = h(
179
- { sourceNode: this.node, destinationNode: s.node, sourceNodeHandle: "true" },
179
+ { sourceNode: this.node, destinationNode: n.node, sourceNodeHandle: "true" },
180
180
  this.experience
181
181
  );
182
182
  this.experience.edges.push(d);
183
183
  },
184
- addFalse(s) {
185
- if (!this.node || !s.node)
184
+ addFalse(n) {
185
+ if (!this.node || !n.node)
186
186
  throw new Error("todo no node");
187
187
  const d = h(
188
- { sourceNode: this.node, destinationNode: s.node, sourceNodeHandle: "false" },
188
+ { sourceNode: this.node, destinationNode: n.node, sourceNodeHandle: "false" },
189
189
  this.experience
190
190
  );
191
191
  this.experience.edges.push(d);
@@ -197,7 +197,7 @@ const r = {
197
197
  });
198
198
  }
199
199
  };
200
- return p({ conditional: n, type: "conditional" }, o), n;
200
+ return p({ conditional: s, type: "conditional" }, o), s;
201
201
  }, m = (e) => ({
202
202
  id: e.id,
203
203
  name: e.name,
@@ -211,12 +211,13 @@ const r = {
211
211
  validation: e.validation ?? {},
212
212
  condition: e.condition,
213
213
  required: e.required,
214
- options: e.options?.map((n) => ({
215
- ...n
214
+ options: e.options?.map((s) => ({
215
+ id: "id" in s ? s.id : f("option"),
216
+ ...s
216
217
  })) ?? null,
217
218
  policies: e.policies,
218
219
  serialize() {
219
- const n = {
220
+ const s = {
220
221
  id: this.id,
221
222
  name: this.name,
222
223
  label: this.label,
@@ -227,7 +228,7 @@ const r = {
227
228
  validation: this.validation,
228
229
  condition: this.condition,
229
230
  policies: this.policies
230
- }, s = typeof this.defaultValue == "string" ? this.defaultValue : void 0, d = typeof this.defaultValue == "number" ? this.defaultValue : void 0, N = typeof this.defaultValue == "boolean" ? this.defaultValue : void 0;
231
+ }, n = typeof this.defaultValue == "string" ? this.defaultValue : void 0, d = typeof this.defaultValue == "number" ? this.defaultValue : void 0, N = typeof this.defaultValue == "boolean" ? this.defaultValue : void 0;
231
232
  switch (this.type) {
232
233
  case "text":
233
234
  if (this.multiple) {
@@ -239,7 +240,7 @@ const r = {
239
240
  t.length === 0 && (t = void 0);
240
241
  }
241
242
  return r.serialize({
242
- ...n,
243
+ ...s,
243
244
  type: "text",
244
245
  multiple: !0,
245
246
  defaultValue: t,
@@ -252,10 +253,10 @@ const r = {
252
253
  });
253
254
  }
254
255
  return r.serialize({
255
- ...n,
256
+ ...s,
256
257
  type: "text",
257
258
  multiple: !1,
258
- defaultValue: s,
259
+ defaultValue: n,
259
260
  options: this.options ? this.options.map((t) => ({
260
261
  id: t.id,
261
262
  label: t.label,
@@ -273,7 +274,7 @@ const r = {
273
274
  t.length === 0 && (t = void 0);
274
275
  }
275
276
  return r.serialize({
276
- ...n,
277
+ ...s,
277
278
  type: "number",
278
279
  multiple: !0,
279
280
  defaultValue: t,
@@ -286,7 +287,7 @@ const r = {
286
287
  });
287
288
  }
288
289
  return r.serialize({
289
- ...n,
290
+ ...s,
290
291
  type: "number",
291
292
  multiple: !1,
292
293
  defaultValue: d,
@@ -307,7 +308,7 @@ const r = {
307
308
  t.length === 0 && (t = void 0);
308
309
  }
309
310
  return r.serialize({
310
- ...n,
311
+ ...s,
311
312
  type: "boolean",
312
313
  multiple: !0,
313
314
  defaultValue: t,
@@ -320,7 +321,7 @@ const r = {
320
321
  });
321
322
  }
322
323
  return r.serialize({
323
- ...n,
324
+ ...s,
324
325
  type: "boolean",
325
326
  multiple: !1,
326
327
  defaultValue: N,
@@ -331,30 +332,38 @@ const r = {
331
332
  condition: t.condition
332
333
  })) : null
333
334
  });
334
- // todo: support for object type fields
335
- // case 'object':
336
- // if (this.multiple) {
337
- // return serialization.serialize({
338
- // ...baseField,
339
- // type: 'object',
340
- // multiple: true,
341
- // defaultValue: this.defaultValue,
342
- // options: this.options,
343
- // })
344
- // }
345
- // return serialization.serialize({
346
- // ...baseField,
347
- // type: 'object',
348
- // multiple: false,
349
- // defaultValue: this.defaultValue,
350
- // options: this.options,
351
- // })
335
+ case "object":
336
+ return this.multiple ? r.serialize({
337
+ ...s,
338
+ type: "object",
339
+ multiple: !0,
340
+ defaultValue: this.defaultValue,
341
+ options: this.options ? this.options.map((t) => ({
342
+ id: t.id,
343
+ label: t.label,
344
+ description: t.description,
345
+ value: t.value,
346
+ condition: t.condition
347
+ })) : null
348
+ }) : r.serialize({
349
+ ...s,
350
+ type: "object",
351
+ multiple: !1,
352
+ defaultValue: this.defaultValue,
353
+ options: this.options ? this.options.map((t) => ({
354
+ id: t.id,
355
+ label: t.label,
356
+ description: t.description,
357
+ value: t.value,
358
+ condition: t.condition
359
+ })) : null
360
+ });
352
361
  default:
353
362
  throw new Error("Unsupported field type");
354
363
  }
355
364
  }
356
- }), V = (e) => {
357
- const o = [], n = [], s = [], d = [], N = [], t = e.condition ?? e.decide;
365
+ }), E = (e) => {
366
+ const o = [], s = [], n = [], d = [], N = [], t = e.condition ?? e.decide;
358
367
  return {
359
368
  id: e.id,
360
369
  component: e.component,
@@ -364,14 +373,14 @@ const r = {
364
373
  decide: e.decide,
365
374
  targets: e.targets,
366
375
  steps: o,
367
- nodes: n,
368
- edges: s,
376
+ nodes: s,
377
+ edges: n,
369
378
  fields: N,
370
379
  conditionals: d,
371
380
  addStep(i, u) {
372
381
  let l = u?.node;
373
382
  this.nodes.length === 0 && (l = p({ type: "origin" }, this), this.nodes.push(l));
374
- const a = "serialize" in i ? i : y(i, this);
383
+ const a = "serialize" in i ? i : z(i, this);
375
384
  if (l) {
376
385
  if (!a.node)
377
386
  throw new Error("todo no node");
@@ -388,7 +397,7 @@ const r = {
388
397
  addAction(i, u) {
389
398
  let l = u?.node;
390
399
  this.nodes.length === 0 && (l = p({ type: "origin" }, this), this.nodes.push(l));
391
- const a = "serialize" in i ? i : g(i, this);
400
+ const a = "serialize" in i ? i : y(i, this);
392
401
  if (l) {
393
402
  const c = h(
394
403
  { sourceNode: l, destinationNode: a, sourceNodeHandle: null },
@@ -456,10 +465,10 @@ const r = {
456
465
  export {
457
466
  b as createConditional,
458
467
  h as createEdge,
459
- V as createExperience,
460
- v as createExperiencePlugin,
468
+ E as createExperience,
469
+ x as createExperiencePlugin,
461
470
  m as createField,
462
471
  p as createNode,
463
- E as createStep,
472
+ V as createStep,
464
473
  r as serialization
465
474
  };
@@ -1,35 +1,34 @@
1
- import { createEffect as r, sample as i } from "effector";
1
+ import { createEffect as n, sample as i } from "effector";
2
2
  import { c, l as g, s as S } from "../../../storage-Co_LbKr_.js";
3
3
  import { l as f } from "../../../logger-C9a75KZn.js";
4
4
  const y = ({
5
5
  storage: a = "local"
6
6
  } = {}) => ({
7
7
  name: "experience-browser-storage-plugin",
8
- setup: (n) => {
9
- const o = a === "local" ? g : S, p = r(async (e) => {
8
+ setup: (s) => {
9
+ const r = a === "local" ? g : S, p = n(async (e) => {
10
10
  if (!e) {
11
11
  f("warn", "No experience instance provided to loadExperienceVisiblityFx.");
12
12
  return;
13
13
  }
14
- const t = c("open-close", "experience", e), s = o.get(t).boolean();
15
- e.setOpen(s ?? e.isOpenStore.getState());
14
+ const t = c("open-close", "experience", e), o = r.get(t).boolean();
15
+ e.setOpen(o ?? e.isOpenStore.getState());
16
16
  });
17
17
  i({
18
- source: n.eventBus,
19
- filter: (e) => e.type === "experience_initialize" && "experienceInstance" in e,
20
- // @ts-ignore todo
21
- fn: (e) => e.experienceInstance,
18
+ source: s.eventBus,
19
+ filter: (e) => e.type === "experience_initialize" && "experience" in e,
20
+ fn: (e) => e.experience,
22
21
  target: p
23
22
  });
24
- const l = r(async (e) => {
25
- const t = c("open-close", "experience", e), s = e.isOpenStore.getState();
26
- o.set(t, s);
23
+ const l = n(async (e) => {
24
+ const t = c("open-close", "experience", e), o = e.isOpenStore.getState();
25
+ r.set(t, o);
27
26
  }), x = (e) => i({
28
27
  source: e.isOpenStore,
29
28
  fn: () => e,
30
29
  target: l
31
30
  });
32
- n.experienceInstances.listStore.watch((e) => {
31
+ s.experienceInstances.listStore.watch((e) => {
33
32
  e.forEach((t) => x(t));
34
33
  });
35
34
  }
@@ -1,5 +1,5 @@
1
1
  import { createEvent as i, createStore as v, createEffect as C, sample as n, attach as S } from "effector";
2
- import { h as F } from "../../experience-instance-CKiUCMCP.js";
2
+ import { h as F } from "../../experience-instance-D0bQ9DzM.js";
3
3
  function R() {
4
4
  let c, p;
5
5
  return {