@picked/client 0.0.1-dev.1787788898336 → 0.0.1-dev.1789541668638

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.
Files changed (72) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/{api-DU4j3Qw0.js → api-C7q_7vxn.js} +1 -1
  3. package/dist/{api-9gq3GBPF.cjs → api-Ctvh1qkk.cjs} +1 -1
  4. package/dist/cjs/index.js +2 -2
  5. package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
  6. package/dist/cjs/plugins/responses-browser-storage/index.js +1 -1
  7. package/dist/cjs/plugins/responses-indexeddb/index.js +1 -1
  8. package/dist/cjs/plugins/telemetry/index.js +1 -1
  9. package/dist/cjs/server/index.js +1 -1
  10. package/dist/docs/how-to/invite-and-remove-members.md +3 -2
  11. package/dist/docs/reference/dashboard/fields.mdx +17 -11
  12. package/dist/docs/reference/sdk/features.md +5 -0
  13. package/dist/docs/reference/sdk/fields.md +38 -6
  14. package/dist/docs/reference/sdk/type-generation.md +18 -7
  15. package/dist/docs/reference/tools/mcp.md +3 -1
  16. package/dist/esm/index.js +258 -239
  17. package/dist/esm/plugins/dynamic-experiences/index.js +2 -2
  18. package/dist/esm/plugins/responses-browser-storage/index.js +50 -16
  19. package/dist/esm/plugins/responses-indexeddb/index.js +1 -1
  20. package/dist/esm/plugins/telemetry/index.js +6 -3
  21. package/dist/esm/server/index.js +13 -13
  22. package/dist/{experience-instance-DGk11d8a.js → experience-instance-B9S6Yf0N.js} +302 -154
  23. package/dist/experience-instance-D8rOg6We.cjs +1 -0
  24. package/dist/{plugin-CYXHEafF.js → plugin-ChafFq6S.js} +3 -2
  25. package/dist/{plugin-rwzR9hVc.cjs → plugin-Dn25Gffy.cjs} +1 -1
  26. package/dist/{provider-BWDd3oaq.js → provider-B8wvmeC8.js} +15 -11
  27. package/dist/provider-BBLlQOjV.cjs +1 -0
  28. package/dist/types/client.d.ts +21 -0
  29. package/dist/types/client.d.ts.map +1 -1
  30. package/dist/types/data-source/provider.d.ts +3 -3
  31. package/dist/types/data-source/provider.d.ts.map +1 -1
  32. package/dist/types/data-source/request-observer.d.ts +23 -19
  33. package/dist/types/data-source/request-observer.d.ts.map +1 -1
  34. package/dist/types/entities/experience/experience.d.ts +8 -0
  35. package/dist/types/entities/experience/experience.d.ts.map +1 -1
  36. package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
  37. package/dist/types/entities/feature/feature.d.ts.map +1 -1
  38. package/dist/types/entities/field/field.d.ts +26 -7
  39. package/dist/types/entities/field/field.d.ts.map +1 -1
  40. package/dist/types/entities/field/policies.d.ts +35 -0
  41. package/dist/types/entities/field/policies.d.ts.map +1 -0
  42. package/dist/types/index.d.ts +1 -0
  43. package/dist/types/index.d.ts.map +1 -1
  44. package/dist/types/lifecycle/lifecycle.d.ts +1 -1
  45. package/dist/types/lifecycle/lifecycle.d.ts.map +1 -1
  46. package/dist/types/picked.d.ts +4 -13
  47. package/dist/types/picked.d.ts.map +1 -1
  48. package/dist/types/plugins/create-experience/create-experience.d.ts +3 -8
  49. package/dist/types/plugins/create-experience/create-experience.d.ts.map +1 -1
  50. package/dist/types/plugins/responses-browser-storage/plugin.d.ts +11 -0
  51. package/dist/types/plugins/responses-browser-storage/plugin.d.ts.map +1 -1
  52. package/dist/types/plugins/telemetry/plugin.d.ts +2 -2
  53. package/dist/types/plugins/telemetry/plugin.d.ts.map +1 -1
  54. package/dist/types/utils/client-telemetry.d.ts +25 -0
  55. package/dist/types/utils/client-telemetry.d.ts.map +1 -0
  56. package/dist/types/utils/node-tree/min-max-steps-to-leaf.d.ts +16 -6
  57. package/dist/types/utils/node-tree/min-max-steps-to-leaf.d.ts.map +1 -1
  58. package/dist/types/utils/node-tree/min-max-steps-to-origin.d.ts +18 -7
  59. package/dist/types/utils/node-tree/min-max-steps-to-origin.d.ts.map +1 -1
  60. package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts +30 -6
  61. package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts.map +1 -1
  62. package/dist/types/utils/node-tree/node-adjacency.d.ts +50 -0
  63. package/dist/types/utils/node-tree/node-adjacency.d.ts.map +1 -0
  64. package/dist/types/utils/node-tree/node-tree-index.d.ts +57 -0
  65. package/dist/types/utils/node-tree/node-tree-index.d.ts.map +1 -0
  66. package/dist/{version-BaI_1eQx.cjs → version-CLjPfmxk.cjs} +1 -1
  67. package/dist/{version-DXDZM7eT.js → version-CPKulHMH.js} +2 -2
  68. package/package.json +5 -5
  69. package/dist/experience-instance-Dej3P1sE.cjs +0 -1
  70. package/dist/provider-lgLyP_0N.cjs +0 -1
  71. package/dist/types/ping.d.ts +0 -11
  72. package/dist/types/ping.d.ts.map +0 -1
@@ -1,5 +1,5 @@
1
- import { t as e } from "../../../plugin-CYXHEafF.js";
2
- import { n as t, t as n } from "../../../api-DU4j3Qw0.js";
1
+ import { t as e } from "../../../plugin-ChafFq6S.js";
2
+ import { n as t, t as n } from "../../../api-C7q_7vxn.js";
3
3
  import { n as r } from "../../../registry-CXZv0uLg.js";
4
4
  import { createClientHeaders as i, fetchSchema as a } from "@picked/delivery-api-client";
5
5
  export { i as createClientHeaders, e as dynamicExperiencesPlugin, n as fetchExperienceContent, t as fetchProject, a as fetchSchema, r as registerPickedBundle };
@@ -3,35 +3,69 @@ import { n as t, r as n, t as r } from "../../../storage-1MW3-_As.js";
3
3
  import { attach as i, createEffect as a, sample as o } from "effector";
4
4
  //#region src/plugins/responses-browser-storage/plugin.ts
5
5
  var s = r("responses", "global");
6
- function c(e, t) {
7
- return Object.fromEntries(Object.entries(e).flatMap(([e, n]) => t.find((t) => t.key === e)?.policies?.doNotStoreValue === !1 ? [[e, n]] : []));
6
+ function c(e, t, n) {
7
+ let r = new Map(n.map((e) => [e.key, e])), i = {};
8
+ for (let [t, n] of Object.entries(e ?? {})) {
9
+ let e = r.get(t);
10
+ (!e || e.policies?.storeValue === !0) && (i[t] = n);
11
+ }
12
+ for (let e of n) {
13
+ let n = t[e.key];
14
+ e.policies?.storeValue === !0 && n !== void 0 && (i[e.key] = n);
15
+ }
16
+ return i;
17
+ }
18
+ function l(e, t) {
19
+ let n = Object.keys(e);
20
+ return n.length === Object.keys(t).length && n.every((n) => JSON.stringify(e[n]) === JSON.stringify(t[n]));
8
21
  }
9
- var l = ({ storage: r = "local" } = {}) => ({
22
+ var u = ({ storage: r = "local" } = {}) => ({
10
23
  name: "responses-browser-storage-plugin",
11
- setup: (l) => {
24
+ setup: (u) => {
12
25
  if (!e()) return;
13
- let u = r === "local" ? t : n, d = a(async () => {
14
- let e = u.get(s).json();
26
+ let d = r === "local" ? t : n, f = a(async () => {
27
+ let e = d.get(s).json();
15
28
  if (!e) return null;
16
- l.responses.register(e);
17
- }), f = i({
29
+ u.responses.register(e);
30
+ }), p = (e) => {
31
+ if (Object.keys(e).length === 0) {
32
+ d.remove(s);
33
+ return;
34
+ }
35
+ d.set(s, e);
36
+ }, m = i({
18
37
  source: {
19
- responses: l.responses.getAllStore,
20
- fields: l.fields.listStore
38
+ responses: u.responses.getAllStore,
39
+ fields: u.fields.listStore
21
40
  },
22
41
  effect: ({ responses: e, fields: t }) => {
23
- t.length !== 0 && u.set(s, c(e, t));
42
+ let n = d.get(s).json(), r = c(n, e, t);
43
+ n !== null && l(n, r) || (n !== null || Object.keys(r).length !== 0) && p(r);
24
44
  }
45
+ }), h = a(() => {
46
+ d.remove(s);
47
+ }), g = a((e) => {
48
+ let t = d.get(s).json();
49
+ !t || !Object.hasOwn(t, e) || p(Object.fromEntries(Object.entries(t).filter(([t]) => t !== e)));
25
50
  });
26
51
  o({
27
- source: l.eventBus,
52
+ source: u.eventBus,
28
53
  filter: (e) => e.type === "load",
29
- target: d
30
- }), o({
31
- source: l.responses.getAllStore,
32
54
  target: f
55
+ }), o({
56
+ source: u.responses.getAllStore,
57
+ target: m
58
+ }), o({
59
+ source: u.fields.listStore,
60
+ target: m
61
+ }), o({
62
+ clock: u.responses.clearAll,
63
+ target: h
64
+ }), o({
65
+ clock: u.responses.clear,
66
+ target: g
33
67
  });
34
68
  }
35
69
  });
36
70
  //#endregion
37
- export { l as responsesBrowserStoragePlugin };
71
+ export { u as responsesBrowserStoragePlugin };
@@ -69,7 +69,7 @@ var l = "responses", u = {
69
69
  fields: r.fields.listStore
70
70
  },
71
71
  fn: ({ responses: e, fields: t }) => {
72
- let n = new Set(t.filter((e) => e.policies?.doNotStoreValue === !1).map((e) => e.key));
72
+ let n = new Set(t.filter((e) => e.policies?.storeValue === !0).map((e) => e.key));
73
73
  return e.filter((e) => n.has(e.fieldKey)).map((e) => ({
74
74
  fieldKey: e.fieldKey,
75
75
  value: e.value
@@ -36,11 +36,11 @@ function p(t) {
36
36
  }, b = () => {
37
37
  v ??= setTimeout(y, l);
38
38
  };
39
- f(y), o.setDeliveryRequestObserver({ onRequest: (e) => {
39
+ f(y), o.telemetry.observeDeliveryAPIRequests({ onRequest: (e) => {
40
40
  let t = n(), r = d();
41
41
  return {
42
42
  headers: { traceparent: i(c, t, !0) },
43
- onSettled: (n) => {
43
+ onSettled: (n, i) => {
44
44
  _.push({
45
45
  name: `picked.delivery.${e}`,
46
46
  traceId: c,
@@ -48,7 +48,10 @@ function p(t) {
48
48
  parentSpanId: p,
49
49
  startTimeUnixNano: a(r),
50
50
  endTimeUnixNano: a(d()),
51
- attributes: { "picked.endpoint": e },
51
+ attributes: {
52
+ "picked.endpoint": e,
53
+ ...i !== void 0 && { "http.response.status_code": i }
54
+ },
52
55
  status: n ? "ok" : "error"
53
56
  }), _.length >= 50 ? y() : b();
54
57
  }
@@ -1,5 +1,5 @@
1
- import { a as e, c as t, i as n, o as r, s as i, t as a, u as o } from "../../experience-instance-DGk11d8a.js";
2
- import { n as s } from "../../plugin-CYXHEafF.js";
1
+ import { a as e, c as t, d as n, i as r, o as i, s as a, t as o } from "../../experience-instance-B9S6Yf0N.js";
2
+ import { n as s } from "../../plugin-ChafFq6S.js";
3
3
  import { attach as c, createEffect as l, createEvent as u, createStore as d, sample as f } from "effector";
4
4
  //#region src/server/serialize.ts
5
5
  var p = 1e4;
@@ -7,22 +7,22 @@ function m(e) {
7
7
  if (e?.location !== void 0) return { location: e.location };
8
8
  }
9
9
  function h(e, t) {
10
- return e.nodes.filter(o).some((e) => t.get(e.stepId) === !0);
10
+ return e.nodes.filter(n).some((e) => t.get(e.stepId) === !0);
11
11
  }
12
12
  async function g(e, n = {}) {
13
- let i = n.previewToken === void 0 ? void 0 : { previewToken: n.previewToken }, a = await e.getProjectConfig(i), o = e.session.store.getState().id;
13
+ let r = n.previewToken === void 0 ? void 0 : { previewToken: n.previewToken }, a = await e.getProjectConfig(r), o = e.session.store.getState().id;
14
14
  e.conditionResults.reset(), s(e, a, {
15
15
  isPreview: !1,
16
16
  sessionId: o
17
17
  });
18
18
  let c = m(n.attributes), l = n.timeoutMs ?? p, u = new Map(a.steps.map((e) => [e.id, e.layoutContentId !== void 0 && e.layoutContentId !== null])), d = Object.fromEntries(a.conditions.map((e) => [e.key, e])), f = a.experiences.filter((e) => !t(e.condition, d)), g = (await Promise.all(f.map(async (t) => ({
19
19
  experience: t,
20
- active: await r(e, { condition: t.condition }, { context: c })
20
+ active: await i(e, { condition: t.condition }, { context: c })
21
21
  })))).filter((e) => e.active).map((e) => e.experience), _ = await Promise.all(g.filter((e) => h(e, u)).map((t) => e.getExperienceContent({
22
22
  id: t.id,
23
23
  key: t.key
24
24
  }, {
25
- ...i,
25
+ ...r,
26
26
  signal: AbortSignal.timeout(l)
27
27
  }))), v = /* @__PURE__ */ new Map();
28
28
  for (let e of _) if (e) for (let t of [...e.references ?? [], ...e.content]) v.set(t.id, t);
@@ -46,7 +46,7 @@ function _() {
46
46
  };
47
47
  }
48
48
  function v(e, t) {
49
- let { promise: n, resolve: r } = _(), i = u(), o = u(), s = u(), p = u(), m = u(), h = e.experiences.listStore.map((t) => t.map((t) => a({
49
+ let { promise: n, resolve: r } = _(), i = u(), a = u(), s = u(), p = u(), m = u(), h = e.experiences.listStore.map((t) => t.map((t) => o({
50
50
  client: e,
51
51
  experience: t
52
52
  }))), g = d({
@@ -86,9 +86,9 @@ function v(e, t) {
86
86
  isComplete: !0
87
87
  })).reset(i), f({
88
88
  clock: i,
89
- target: o
89
+ target: a
90
90
  }), f({
91
- clock: o,
91
+ clock: a,
92
92
  source: {
93
93
  experiences: h,
94
94
  state: g
@@ -107,17 +107,17 @@ function v(e, t) {
107
107
  target: s
108
108
  }), f({
109
109
  clock: s,
110
- target: o
110
+ target: a
111
111
  }), f({
112
112
  clock: y.doneData,
113
113
  filter: (e) => e === null,
114
114
  target: m
115
115
  }), f({
116
116
  clock: m,
117
- target: o
117
+ target: a
118
118
  }), f({
119
119
  clock: [
120
- o,
120
+ a,
121
121
  m,
122
122
  s
123
123
  ],
@@ -140,4 +140,4 @@ function v(e, t) {
140
140
  }), i(), n;
141
141
  }
142
142
  //#endregion
143
- export { a as createExperienceInstance, n as evaluateConditionMemo, e as hashRule, r as isExperienceActive, s as registerProjectConfig, v as render, i as ruleReferencesAction, t as ruleReferencesActionDeep, g as serialize };
143
+ export { o as createExperienceInstance, r as evaluateConditionMemo, e as hashRule, i as isExperienceActive, s as registerProjectConfig, v as render, a as ruleReferencesAction, t as ruleReferencesActionDeep, g as serialize };