@picked/client 0.0.1-dev.1788925875333 → 0.0.1-dev.1793753513002
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/LICENSE +1 -0
- package/README.md +34 -158
- package/dist/.tsbuildinfo +1 -1
- package/dist/api-ZkaFvphK.cjs +1 -0
- package/dist/{api-DbMJli3H.js → api-nJ3O-8r5.js} +1 -1
- package/dist/cjs/form/index.js +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/logic-engine.js +1 -0
- package/dist/cjs/plugins/dom-observer/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/responses-browser-storage/index.js +1 -1
- package/dist/cjs/plugins/telemetry/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/cjs/storage.js +1 -0
- package/dist/dom-7g2LZCIp.cjs +1 -0
- package/dist/{dom-BqcToNL0.js → dom-v6ulxr_z.js} +1 -5
- package/dist/esm/form/index.js +5 -16
- package/dist/esm/index.js +576 -615
- package/dist/esm/logic-engine.js +208 -0
- package/dist/esm/plugins/dom-observer/index.js +1 -1
- package/dist/esm/plugins/dynamic-experiences/index.js +4 -4
- package/dist/esm/plugins/experience-browser-storage/index.js +12 -10
- package/dist/esm/plugins/responses-browser-storage/index.js +2 -6
- package/dist/esm/plugins/telemetry/index.js +26 -15
- package/dist/esm/preview/index.js +1 -2
- package/dist/esm/server/index.js +47 -43
- package/dist/esm/storage.js +1 -0
- package/dist/experience-instance-4D6Yk-h0.js +774 -0
- package/dist/experience-instance-D2FAkiPx.cjs +1 -0
- package/dist/plugin-B1kexnbX.js +256 -0
- package/dist/plugin-Bnmk8pN8.cjs +1 -0
- package/dist/preview-channel-BMOEreho.cjs +1 -0
- package/dist/{preview-channel-CSr96XAo.js → preview-channel-CLXVoL_j.js} +2 -5
- package/dist/{version-VvasRUfR.js → preview-unavailable-BaHYVZQD.js} +100 -61
- package/dist/preview-unavailable-ClBw_DDY.cjs +1 -0
- package/dist/provider-BFdnIgeH.cjs +1 -0
- package/dist/provider-C98VWkEj.js +115 -0
- package/dist/{rules-logic-HesIUCu6.js → rules-logic-9hh8y_1b.js} +1 -1
- package/dist/rules-logic-VUbvWqdi.cjs +1 -0
- package/dist/types/data-source/preview-unavailable.d.ts +18 -0
- package/dist/types/data-source/preview-unavailable.d.ts.map +1 -0
- package/dist/types/data-source/provider.d.ts +5 -0
- package/dist/types/data-source/provider.d.ts.map +1 -1
- package/dist/types/data-source/request-observer.d.ts +21 -8
- package/dist/types/data-source/request-observer.d.ts.map +1 -1
- package/dist/types/entities/action/action.d.ts +94 -23
- package/dist/types/entities/action/action.d.ts.map +1 -1
- package/dist/types/entities/experience/experience.d.ts +8 -0
- package/dist/types/entities/experience/experience.d.ts.map +1 -1
- package/dist/types/entities/experience-instance/experience-instance.d.ts +14 -1
- package/dist/types/entities/experience-instance/experience-instance.d.ts.map +1 -1
- package/dist/types/exports.d.ts +1 -0
- package/dist/types/exports.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lifecycle/rules-logic.d.ts.map +1 -1
- package/dist/types/logic-engine.d.ts +9 -0
- package/dist/types/logic-engine.d.ts.map +1 -1
- package/dist/types/picked.d.ts +38 -8
- package/dist/types/picked.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.map +1 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts +5 -2
- package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
- package/dist/types/plugins/experience-browser-storage/plugin.d.ts.map +1 -1
- package/dist/types/plugins/telemetry/plugin.d.ts +2 -0
- package/dist/types/plugins/telemetry/plugin.d.ts.map +1 -1
- package/dist/types/schema-registry.d.ts +34 -0
- package/dist/types/schema-registry.d.ts.map +1 -1
- package/dist/types/server/serialize.d.ts +1 -0
- package/dist/types/server/serialize.d.ts.map +1 -1
- package/dist/types/storage.d.ts +6 -0
- package/dist/types/storage.d.ts.map +1 -0
- package/dist/types/typed-content.d.ts +14 -1
- package/dist/types/typed-content.d.ts.map +1 -1
- package/dist/types/utils/events.d.ts +4 -0
- package/dist/types/utils/events.d.ts.map +1 -1
- package/dist/types/utils/node-tree/min-max-steps-to-leaf.d.ts +16 -6
- 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 +18 -7
- 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 +30 -6
- package/dist/types/utils/node-tree/next-reachable-step-nodes.d.ts.map +1 -1
- package/dist/types/utils/node-tree/node-adjacency.d.ts +50 -0
- package/dist/types/utils/node-tree/node-adjacency.d.ts.map +1 -0
- package/dist/types/utils/node-tree/node-tree-index.d.ts +57 -0
- package/dist/types/utils/node-tree/node-tree-index.d.ts.map +1 -0
- package/dist/types/utils/rules-logic.d.ts +3 -2
- package/dist/types/utils/rules-logic.d.ts.map +1 -1
- package/dist/types/utils/search-params.d.ts +20 -0
- package/dist/types/utils/search-params.d.ts.map +1 -1
- package/package.json +39 -13
- package/dist/api-qiqq8lgz.cjs +0 -1
- package/dist/docs/_root.css +0 -101
- package/dist/docs/explanation/conditions-and-the-logic-engine.md +0 -94
- package/dist/docs/explanation/content-references.md +0 -99
- package/dist/docs/explanation/feature-flag-allocation.md +0 -218
- package/dist/docs/explanation/how-picked-works.md +0 -124
- package/dist/docs/explanation/how-pickedql-works.md +0 -76
- package/dist/docs/explanation/pages-and-flows.md +0 -64
- package/dist/docs/explanation/the-content-model.md +0 -87
- package/dist/docs/explanation/the-two-apis.md +0 -68
- package/dist/docs/explanation/why-server-side-rendering.md +0 -76
- package/dist/docs/explanation/workspaces-and-versions.md +0 -71
- package/dist/docs/how-to/add-a-step-field-or-action.md +0 -43
- package/dist/docs/how-to/analytics/index.md +0 -316
- package/dist/docs/how-to/archive-or-delete-a-workspace.md +0 -46
- package/dist/docs/how-to/authenticate-the-cli.md +0 -97
- package/dist/docs/how-to/authenticate-with-a-magic-link.md +0 -40
- package/dist/docs/how-to/authenticate-with-a-password.md +0 -51
- package/dist/docs/how-to/authenticate-with-an-api-key.md +0 -51
- package/dist/docs/how-to/authenticate-with-oauth.md +0 -40
- package/dist/docs/how-to/build-a-flow.md +0 -83
- package/dist/docs/how-to/connect-the-mcp-server.md +0 -38
- package/dist/docs/how-to/create-a-content-entry.md +0 -48
- package/dist/docs/how-to/create-a-project.md +0 -29
- package/dist/docs/how-to/create-an-experience.md +0 -42
- package/dist/docs/how-to/create-and-revoke-an-api-key.md +0 -42
- package/dist/docs/how-to/debug-with-the-chrome-extension.md +0 -57
- package/dist/docs/how-to/define-a-page-layout.md +0 -46
- package/dist/docs/how-to/fill-and-publish-a-page.md +0 -66
- package/dist/docs/how-to/install-the-gtm-template.md +0 -84
- package/dist/docs/how-to/install-the-sdk.md +0 -93
- package/dist/docs/how-to/install-the-vite-plugin.md +0 -69
- package/dist/docs/how-to/invite-and-remove-members.md +0 -34
- package/dist/docs/how-to/point-one-entry-at-another.md +0 -61
- package/dist/docs/how-to/preview-a-workspace.md +0 -28
- package/dist/docs/how-to/publish-a-workspace.md +0 -30
- package/dist/docs/how-to/read-a-feature-flag.md +0 -113
- package/dist/docs/how-to/read-a-referenced-entry.md +0 -109
- package/dist/docs/how-to/register-a-component.md +0 -55
- package/dist/docs/how-to/register-an-action-handler.md +0 -67
- package/dist/docs/how-to/render-a-step-form.md +0 -131
- package/dist/docs/how-to/render-an-unpublished-preview.md +0 -41
- package/dist/docs/how-to/reuse-a-section.md +0 -53
- package/dist/docs/how-to/reuse-a-step-field-or-action.md +0 -28
- package/dist/docs/how-to/roll-back-a-published-version.md +0 -26
- package/dist/docs/how-to/run-an-ab-test.md +0 -49
- package/dist/docs/how-to/run-code-on-a-form-submission.md +0 -125
- package/dist/docs/how-to/server-render-a-page.md +0 -81
- package/dist/docs/how-to/set-a-content-security-policy.md +0 -32
- package/dist/docs/how-to/set-up-mfa.md +0 -69
- package/dist/docs/how-to/switch-workspaces.md +0 -122
- package/dist/docs/how-to/upload-and-use-an-asset.mdx +0 -73
- package/dist/docs/how-to/validate-a-field.md +0 -52
- package/dist/docs/how-to/write-a-condition.md +0 -45
- package/dist/docs/how-to/write-a-predicate.md +0 -60
- package/dist/docs/index.md +0 -59
- package/dist/docs/reference/dashboard/actions.mdx +0 -53
- package/dist/docs/reference/dashboard/api-keys.mdx +0 -38
- package/dist/docs/reference/dashboard/conditions.mdx +0 -42
- package/dist/docs/reference/dashboard/content/asset-library.mdx +0 -63
- package/dist/docs/reference/dashboard/content/blocks.mdx +0 -57
- package/dist/docs/reference/dashboard/content/content-entries.mdx +0 -95
- package/dist/docs/reference/dashboard/content/models.mdx +0 -108
- package/dist/docs/reference/dashboard/content/pages.mdx +0 -61
- package/dist/docs/reference/dashboard/experiences.mdx +0 -51
- package/dist/docs/reference/dashboard/features.mdx +0 -154
- package/dist/docs/reference/dashboard/fields.mdx +0 -106
- package/dist/docs/reference/dashboard/flow-builder/canvas.mdx +0 -58
- package/dist/docs/reference/dashboard/flow-builder/condition-builder.md +0 -57
- package/dist/docs/reference/dashboard/flow-builder/keyboard-shortcuts.md +0 -72
- package/dist/docs/reference/dashboard/flow-builder/nodes.md +0 -63
- package/dist/docs/reference/dashboard/projects.mdx +0 -44
- package/dist/docs/reference/dashboard/reports.mdx +0 -43
- package/dist/docs/reference/dashboard/steps.mdx +0 -37
- package/dist/docs/reference/dashboard/team-management.md +0 -29
- package/dist/docs/reference/dashboard/workspace-versioning.mdx +0 -30
- package/dist/docs/reference/dashboard/workspaces.mdx +0 -76
- package/dist/docs/reference/delivery-api/experience-content.md +0 -152
- package/dist/docs/reference/delivery-api/index.md +0 -45
- package/dist/docs/reference/delivery-api/preview-caching-crawling.md +0 -79
- package/dist/docs/reference/delivery-api/project-config.md +0 -65
- package/dist/docs/reference/delivery-api/workspace-schema.md +0 -85
- package/dist/docs/reference/glossary.md +0 -181
- package/dist/docs/reference/management-api/authentication.md +0 -74
- package/dist/docs/reference/management-api/authorization-and-scopes.md +0 -285
- package/dist/docs/reference/management-api/error-handling.md +0 -233
- package/dist/docs/reference/management-api/pagination.md +0 -192
- package/dist/docs/reference/pickedql/data-sources.md +0 -174
- package/dist/docs/reference/pickedql/dimensions.md +0 -103
- package/dist/docs/reference/pickedql/filtering.md +0 -64
- package/dist/docs/reference/pickedql/index.md +0 -18
- package/dist/docs/reference/pickedql/schema.md +0 -172
- package/dist/docs/reference/pickedql/virtual-functions.md +0 -248
- package/dist/docs/reference/sdk/actions.md +0 -30
- package/dist/docs/reference/sdk/analytics-events.md +0 -445
- package/dist/docs/reference/sdk/conditions.md +0 -147
- package/dist/docs/reference/sdk/content-security-policy.md +0 -21
- package/dist/docs/reference/sdk/content.md +0 -213
- package/dist/docs/reference/sdk/experiences.md +0 -51
- package/dist/docs/reference/sdk/features.md +0 -256
- package/dist/docs/reference/sdk/fields.md +0 -255
- package/dist/docs/reference/sdk/index.md +0 -68
- package/dist/docs/reference/sdk/plugins/create-experience.md +0 -123
- package/dist/docs/reference/sdk/plugins/dynamic-experiences.md +0 -74
- package/dist/docs/reference/sdk/plugins/index.md +0 -29
- package/dist/docs/reference/sdk/plugins/window-object.md +0 -25
- package/dist/docs/reference/sdk/predicates.md +0 -43
- package/dist/docs/reference/sdk/ssr/index.md +0 -33
- package/dist/docs/reference/sdk/ssr/rendering-and-hydration.md +0 -103
- package/dist/docs/reference/sdk/ssr/serialize.md +0 -80
- package/dist/docs/reference/sdk/ssr/slots-and-placements.md +0 -59
- package/dist/docs/reference/sdk/steps.md +0 -86
- package/dist/docs/reference/sdk/type-generation.md +0 -196
- package/dist/docs/reference/tools/chrome-extension.md +0 -16
- package/dist/docs/reference/tools/cli.md +0 -146
- package/dist/docs/reference/tools/image-optimisation-service.md +0 -104
- package/dist/docs/reference/tools/mcp.md +0 -90
- package/dist/docs/reference/tools/vite-plugin.md +0 -163
- package/dist/docs/tutorials/first-api-call.md +0 -228
- package/dist/docs/tutorials/first-experience-in-the-dashboard.mdx +0 -143
- package/dist/docs/tutorials/first-experience.mdx +0 -254
- package/dist/docs/tutorials/first-server-rendered-page.mdx +0 -186
- package/dist/dom-DlLH3FxV.cjs +0 -1
- package/dist/experience-instance-DGk11d8a.js +0 -563
- package/dist/experience-instance-Dej3P1sE.cjs +0 -1
- package/dist/plugin-BcLaCLm1.cjs +0 -1
- package/dist/plugin-De_BJSwE.js +0 -194
- package/dist/preview-channel-Cx0e6fye.cjs +0 -1
- package/dist/provider-C_9u0yGJ.cjs +0 -1
- package/dist/provider-ovM-CBX_.js +0 -98
- package/dist/rules-logic-CGZIYgAI.cjs +0 -1
- package/dist/version-BvLZaTMC.cjs +0 -1
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
//#region src/logic-engine.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
return typeof e == "number" && !isNaN(e);
|
|
4
|
+
}
|
|
5
|
+
function t(e) {
|
|
6
|
+
return typeof e == "string";
|
|
7
|
+
}
|
|
8
|
+
function n(e) {
|
|
9
|
+
return Array.isArray(e);
|
|
10
|
+
}
|
|
11
|
+
function r(e) {
|
|
12
|
+
return e instanceof Promise;
|
|
13
|
+
}
|
|
14
|
+
function i(e) {
|
|
15
|
+
return typeof e == "object" && !!e && !Array.isArray(e) && Object.keys(e).length === 1;
|
|
16
|
+
}
|
|
17
|
+
function a(t) {
|
|
18
|
+
if (e(t)) return t;
|
|
19
|
+
let n = parseFloat(`${t}`);
|
|
20
|
+
return isNaN(n) ? 0 : n;
|
|
21
|
+
}
|
|
22
|
+
function o(e) {
|
|
23
|
+
return `${e}`;
|
|
24
|
+
}
|
|
25
|
+
var s = {
|
|
26
|
+
"==": (e, t) => e == t,
|
|
27
|
+
"===": (e, t) => e === t,
|
|
28
|
+
"!=": (e, t) => e != t,
|
|
29
|
+
"!==": (e, t) => e !== t,
|
|
30
|
+
">": (e, t) => a(e) > a(t),
|
|
31
|
+
">=": (e, t) => a(e) >= a(t),
|
|
32
|
+
"<": (e, t, n) => {
|
|
33
|
+
let r = a(e), i = a(t);
|
|
34
|
+
if (n === void 0) return r < i;
|
|
35
|
+
let o = a(n);
|
|
36
|
+
return r < i && i < o;
|
|
37
|
+
},
|
|
38
|
+
"<=": (e, t, n) => {
|
|
39
|
+
let r = a(e), i = a(t);
|
|
40
|
+
if (n === void 0) return r <= i;
|
|
41
|
+
let o = a(n);
|
|
42
|
+
return r <= i && i <= o;
|
|
43
|
+
},
|
|
44
|
+
"!!": async (e) => await u(e),
|
|
45
|
+
"!": async (e) => !await u(e),
|
|
46
|
+
"%": (e, t) => a(e) % a(t),
|
|
47
|
+
log: (e) => (console.log(e), e),
|
|
48
|
+
in: (e, r) => r ? t(r) ? r.indexOf(o(e)) !== -1 : n(r) ? r.includes(e) : !1 : !1,
|
|
49
|
+
cat: (...e) => e.map(o).join(""),
|
|
50
|
+
substr: (e, t, n) => {
|
|
51
|
+
let r = o(e), i = a(t);
|
|
52
|
+
if (n === void 0) return r.substr(i);
|
|
53
|
+
let s = a(n);
|
|
54
|
+
if (s < 0) {
|
|
55
|
+
let e = r.substr(i);
|
|
56
|
+
return e.substr(0, e.length + s);
|
|
57
|
+
}
|
|
58
|
+
return r.substr(i, s);
|
|
59
|
+
},
|
|
60
|
+
"+": (...e) => e.reduce((e, t) => a(e) + a(t), 0),
|
|
61
|
+
"*": (...e) => e.reduce((e, t) => a(e) * a(t), 1),
|
|
62
|
+
"-": (e, t) => {
|
|
63
|
+
let n = a(e);
|
|
64
|
+
return t === void 0 ? -n : n - a(t);
|
|
65
|
+
},
|
|
66
|
+
"/": (e, t) => a(e) / a(t),
|
|
67
|
+
min: (...e) => Math.min(...e.map(a)),
|
|
68
|
+
max: (...e) => Math.max(...e.map(a)),
|
|
69
|
+
merge: (...e) => e.reduce((e, t) => n(t) ? e.concat(t) : e.concat([t]), []),
|
|
70
|
+
var(e, t) {
|
|
71
|
+
let n = arguments.length > 1 ? t : null;
|
|
72
|
+
if (e === "" || e === "." || e == null) return this;
|
|
73
|
+
if (typeof e == "number" && Array.isArray(this)) return e >= 0 && e < this.length ? this[e] : n;
|
|
74
|
+
let r = o(e);
|
|
75
|
+
if (r === "" || r === ".") return this;
|
|
76
|
+
let i = r.split("."), a = this;
|
|
77
|
+
for (let e of i) {
|
|
78
|
+
if (a == null) return n;
|
|
79
|
+
if (Array.isArray(a)) {
|
|
80
|
+
let t = parseInt(e, 10);
|
|
81
|
+
a = isNaN(t) ? a[e] : a[t];
|
|
82
|
+
} else a = a[e];
|
|
83
|
+
}
|
|
84
|
+
return a === void 0 ? n : a;
|
|
85
|
+
},
|
|
86
|
+
async missing(...e) {
|
|
87
|
+
let t = n(e[0]) ? e[0] : e, r = [];
|
|
88
|
+
for (let e of t) {
|
|
89
|
+
let t = await l({ var: e }, this);
|
|
90
|
+
(t === null || t === "") && r.push(`${e}`);
|
|
91
|
+
}
|
|
92
|
+
return r;
|
|
93
|
+
},
|
|
94
|
+
async missing_some(e, r) {
|
|
95
|
+
let i = await l({ missing: r }, this);
|
|
96
|
+
if (!n(i) || !n(r)) return [];
|
|
97
|
+
let o = i.filter(t);
|
|
98
|
+
return r.filter(t).length - o.length >= a(e) ? [] : o;
|
|
99
|
+
},
|
|
100
|
+
invoke(...e) {
|
|
101
|
+
let [t, ...n] = e;
|
|
102
|
+
return typeof t == "function" ? Reflect.apply(t, null, n) : null;
|
|
103
|
+
},
|
|
104
|
+
startsWith: (e, n) => t(e) && t(n) && e.startsWith(n),
|
|
105
|
+
endsWith: (e, n) => t(e) && t(n) && e.endsWith(n),
|
|
106
|
+
regexp_matches(e, r) {
|
|
107
|
+
let i = e, a = "";
|
|
108
|
+
if (n(e)) {
|
|
109
|
+
let [t, n] = e;
|
|
110
|
+
i = t, a = n;
|
|
111
|
+
}
|
|
112
|
+
return !t(i) || !t(a) ? !1 : new RegExp(i, a).test(o(r));
|
|
113
|
+
},
|
|
114
|
+
throw(e) {
|
|
115
|
+
throw Error(o(e));
|
|
116
|
+
}
|
|
117
|
+
}, c = [
|
|
118
|
+
"?:",
|
|
119
|
+
"all",
|
|
120
|
+
"and",
|
|
121
|
+
"catch",
|
|
122
|
+
"filter",
|
|
123
|
+
"if",
|
|
124
|
+
"map",
|
|
125
|
+
"none",
|
|
126
|
+
"or",
|
|
127
|
+
"reduce",
|
|
128
|
+
"some",
|
|
129
|
+
...Object.keys(s)
|
|
130
|
+
];
|
|
131
|
+
async function l(e, t) {
|
|
132
|
+
if (!e) return e;
|
|
133
|
+
if (r(e)) return l(await e, t);
|
|
134
|
+
if (n(e)) return Promise.all(e.map((e) => l(e, t)));
|
|
135
|
+
if (!i(e)) return e;
|
|
136
|
+
let a = d(e), o = a ? e[a] ?? [] : [];
|
|
137
|
+
switch (n(o) || (o = [o]), a) {
|
|
138
|
+
case "if":
|
|
139
|
+
case "?:":
|
|
140
|
+
for (let e = 0; e < o.length - 1; e += 2) if (await u(await l(o[e], t))) return l(o[e + 1], t);
|
|
141
|
+
return o.length % 2 == 1 ? l(o[o.length - 1], t) : null;
|
|
142
|
+
case "and": {
|
|
143
|
+
let e = null;
|
|
144
|
+
for (let n of o) if (e = await l(n, t), !await u(e)) return e;
|
|
145
|
+
return e;
|
|
146
|
+
}
|
|
147
|
+
case "or": {
|
|
148
|
+
let e = null;
|
|
149
|
+
for (let n of o) if (e = await l(n, t), await u(e)) return e;
|
|
150
|
+
return e;
|
|
151
|
+
}
|
|
152
|
+
case "map": {
|
|
153
|
+
let e = await l(o[0], t);
|
|
154
|
+
return n(e) ? await Promise.all(e.map((e) => l(o[1], e))) : [];
|
|
155
|
+
}
|
|
156
|
+
case "filter": {
|
|
157
|
+
let e = await l(o[0], t);
|
|
158
|
+
return n(e) ? (await Promise.all(e.map(async (e) => ({
|
|
159
|
+
item: e,
|
|
160
|
+
shouldInclude: await u(await l(o[1], e))
|
|
161
|
+
})))).filter(({ shouldInclude: e }) => e).map(({ item: e }) => e) : [];
|
|
162
|
+
}
|
|
163
|
+
case "reduce": {
|
|
164
|
+
let e = await l(o[0], t);
|
|
165
|
+
if (!n(e)) return o.length > 2 ? await l(o[2], t) : null;
|
|
166
|
+
let r = o[1], i = o.length > 2 ? await l(o[2], t) : null;
|
|
167
|
+
for (let t of e) i = await l(r, {
|
|
168
|
+
current: t,
|
|
169
|
+
accumulator: i
|
|
170
|
+
});
|
|
171
|
+
return i;
|
|
172
|
+
}
|
|
173
|
+
case "all": {
|
|
174
|
+
let e = await l(o[0], t);
|
|
175
|
+
if (!n(e) || e.length === 0) return !1;
|
|
176
|
+
for (let t of e) if (!await u(await l(o[1], t))) return !1;
|
|
177
|
+
return !0;
|
|
178
|
+
}
|
|
179
|
+
case "some": {
|
|
180
|
+
let e = await l(o[0], t);
|
|
181
|
+
if (!n(e)) return !1;
|
|
182
|
+
for (let t of e) if (await u(await l(o[1], t))) return !0;
|
|
183
|
+
return !1;
|
|
184
|
+
}
|
|
185
|
+
case "none": {
|
|
186
|
+
let e = await l(o[0], t);
|
|
187
|
+
if (!n(e)) return !0;
|
|
188
|
+
for (let t of e) if (await u(await l(o[1], t))) return !1;
|
|
189
|
+
return !0;
|
|
190
|
+
}
|
|
191
|
+
case "catch": try {
|
|
192
|
+
return await l(o[0], t);
|
|
193
|
+
} catch (e) {
|
|
194
|
+
return i(e) ? await l(e, t) : o[1] ? await l(o[1], e) : e instanceof Error ? e.message : e;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
let c = await Promise.all(o.map((e) => l(e, t))), f = a ? s[a] : void 0;
|
|
198
|
+
if (!f) throw Error(`Unrecognized operation ${a}`);
|
|
199
|
+
return f.apply(t, c);
|
|
200
|
+
}
|
|
201
|
+
async function u(e) {
|
|
202
|
+
return r(e) ? u(await e) : !(Array.isArray(e) && e.length === 0) && !!e;
|
|
203
|
+
}
|
|
204
|
+
function d(e) {
|
|
205
|
+
return Object.keys(e)[0];
|
|
206
|
+
}
|
|
207
|
+
//#endregion
|
|
208
|
+
export { c as OPERATORS, l as apply };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "../../../logger-DMN6TxJJ.js";
|
|
2
2
|
import { f as e, i as t } from "../../../supports-CO9bJGNl.js";
|
|
3
|
-
import { r as n } from "../../../dom-
|
|
3
|
+
import { r as n } from "../../../dom-v6ulxr_z.js";
|
|
4
4
|
import { createEffect as r, createEvent as i, createStore as a, sample as o } from "effector";
|
|
5
5
|
//#region src/plugins/dom-observer/plugin.ts
|
|
6
6
|
var s = /* @__PURE__ */ new WeakSet(), c = () => ({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as e } from "../../../plugin-
|
|
2
|
-
import { n as t, t as n } from "../../../api-
|
|
1
|
+
import { t as e } from "../../../plugin-B1kexnbX.js";
|
|
2
|
+
import { n as t, t as n } from "../../../api-nJ3O-8r5.js";
|
|
3
3
|
import { n as r } from "../../../registry-CXZv0uLg.js";
|
|
4
|
-
import {
|
|
5
|
-
export { i as createClientHeaders, e as dynamicExperiencesPlugin, n as fetchExperienceContent, t as fetchProject,
|
|
4
|
+
import { ActionResponseTimeoutError as i, ActionRunFailedError as a, createClientHeaders as o, fetchSchema as s } from "@picked/delivery-api-client";
|
|
5
|
+
export { i as ActionResponseTimeoutError, a as ActionRunFailedError, o as createClientHeaders, e as dynamicExperiencesPlugin, n as fetchExperienceContent, t as fetchProject, s as fetchSchema, r as registerPickedBundle };
|
|
@@ -14,23 +14,25 @@ var o = ({ storage: o = "local" } = {}) => ({
|
|
|
14
14
|
});
|
|
15
15
|
a({
|
|
16
16
|
source: s.eventBus,
|
|
17
|
-
filter: (e) => e.type === "experience_initialize" &&
|
|
17
|
+
filter: (e) => e.type === "experience_initialize" && e.experience.target !== void 0,
|
|
18
18
|
fn: (e) => e.experience,
|
|
19
19
|
target: l
|
|
20
20
|
});
|
|
21
21
|
let u = i(async ({ experience: e, isOpen: t }) => {
|
|
22
22
|
let n = r("open-close", "experience", e);
|
|
23
23
|
c.set(n, t);
|
|
24
|
-
}), d = (e) =>
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
}), d = /* @__PURE__ */ new WeakSet(), f = (e) => {
|
|
25
|
+
e.target === void 0 || d.has(e) || (d.add(e), a({
|
|
26
|
+
source: e.isOpenStore,
|
|
27
|
+
fn: (t) => ({
|
|
28
|
+
experience: e,
|
|
29
|
+
isOpen: t
|
|
30
|
+
}),
|
|
31
|
+
target: u
|
|
32
|
+
}));
|
|
33
|
+
};
|
|
32
34
|
s.experienceInstances.listStore.watch((e) => {
|
|
33
|
-
e.forEach(
|
|
35
|
+
e.forEach(f);
|
|
34
36
|
});
|
|
35
37
|
}
|
|
36
38
|
});
|
|
@@ -28,11 +28,7 @@ var u = ({ storage: r = "local" } = {}) => ({
|
|
|
28
28
|
if (!e) return null;
|
|
29
29
|
u.responses.register(e);
|
|
30
30
|
}), p = (e) => {
|
|
31
|
-
|
|
32
|
-
d.remove(s);
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
d.set(s, e);
|
|
31
|
+
Object.keys(e).length === 0 ? d.remove(s) : d.set(s, e);
|
|
36
32
|
}, m = i({
|
|
37
33
|
source: {
|
|
38
34
|
responses: u.responses.getAllStore,
|
|
@@ -46,7 +42,7 @@ var u = ({ storage: r = "local" } = {}) => ({
|
|
|
46
42
|
d.remove(s);
|
|
47
43
|
}), g = a((e) => {
|
|
48
44
|
let t = d.get(s).json();
|
|
49
|
-
|
|
45
|
+
t && Object.hasOwn(t, e) && p(Object.fromEntries(Object.entries(t).filter(([t]) => t !== e)));
|
|
50
46
|
});
|
|
51
47
|
o({
|
|
52
48
|
source: u.eventBus,
|
|
@@ -31,17 +31,17 @@ function p(t) {
|
|
|
31
31
|
name: c,
|
|
32
32
|
setup: (o) => {
|
|
33
33
|
if (!e() || u() || !(Math.random() < (t?.sampleRate ?? 1))) return;
|
|
34
|
-
let s = t?.endpoint, c = r(), p = n(),
|
|
35
|
-
clearTimeout(
|
|
36
|
-
},
|
|
37
|
-
|
|
34
|
+
let s = t?.endpoint, c = r(), p = n(), g = [], y, b = () => {
|
|
35
|
+
clearTimeout(y), y = void 0, v(s, h(o), g);
|
|
36
|
+
}, x = () => {
|
|
37
|
+
y ??= setTimeout(b, l);
|
|
38
38
|
};
|
|
39
|
-
f(
|
|
39
|
+
f(b), 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, i) => {
|
|
44
|
-
|
|
43
|
+
onSettled: (n, i, o) => {
|
|
44
|
+
g.push({
|
|
45
45
|
name: `picked.delivery.${e}`,
|
|
46
46
|
traceId: c,
|
|
47
47
|
spanId: t,
|
|
@@ -50,10 +50,11 @@ function p(t) {
|
|
|
50
50
|
endTimeUnixNano: a(d()),
|
|
51
51
|
attributes: {
|
|
52
52
|
"picked.endpoint": e,
|
|
53
|
-
...i !== void 0 && { "http.response.status_code": i }
|
|
53
|
+
...i !== void 0 && { "http.response.status_code": i },
|
|
54
|
+
...o && m(o)
|
|
54
55
|
},
|
|
55
56
|
status: n ? "ok" : "error"
|
|
56
|
-
}),
|
|
57
|
+
}), g.length >= 50 ? b() : x();
|
|
57
58
|
}
|
|
58
59
|
};
|
|
59
60
|
} }), o.eventBus.watch((e) => {
|
|
@@ -61,34 +62,44 @@ function p(t) {
|
|
|
61
62
|
let t = o.performance.startMeasure;
|
|
62
63
|
if (t) {
|
|
63
64
|
let e = performance.timeOrigin + t.startTime;
|
|
64
|
-
|
|
65
|
+
g.push({
|
|
65
66
|
name: "picked.start",
|
|
66
67
|
traceId: c,
|
|
67
68
|
spanId: p,
|
|
68
69
|
startTimeUnixNano: a(e),
|
|
69
70
|
endTimeUnixNano: a(e + t.duration),
|
|
70
|
-
attributes:
|
|
71
|
+
attributes: _(o),
|
|
71
72
|
status: "ok"
|
|
72
73
|
});
|
|
73
74
|
}
|
|
74
|
-
|
|
75
|
+
b();
|
|
75
76
|
});
|
|
76
77
|
}
|
|
77
78
|
};
|
|
78
79
|
}
|
|
79
80
|
function m(e) {
|
|
81
|
+
return {
|
|
82
|
+
"picked.failure.stage": e.stage,
|
|
83
|
+
...e.errorName !== void 0 && { "error.type": e.errorName },
|
|
84
|
+
...e.errorMessage !== void 0 && { "error.message": e.errorMessage.slice(0, 200) }
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function h(e) {
|
|
80
88
|
return {
|
|
81
89
|
"service.name": "picked-sdk",
|
|
82
90
|
"picked.project_id": e.projectId
|
|
83
91
|
};
|
|
84
92
|
}
|
|
85
|
-
function
|
|
93
|
+
function g(e) {
|
|
94
|
+
return e.dataSource ? e.dataSource.mode === "snapshot" ? "snapshot" : "bundle" : "api";
|
|
95
|
+
}
|
|
96
|
+
function _(e) {
|
|
86
97
|
return {
|
|
87
|
-
"picked.data.mode": e
|
|
98
|
+
"picked.data.mode": g(e),
|
|
88
99
|
"picked.sdk.plugins": s(Object.keys(e.plugins)).join(",")
|
|
89
100
|
};
|
|
90
101
|
}
|
|
91
|
-
async function
|
|
102
|
+
async function v(e, t, n) {
|
|
92
103
|
if (n.length === 0) return;
|
|
93
104
|
let r = n.splice(0, n.length);
|
|
94
105
|
try {
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { s as PREVIEW_CONTENT_PATCH_MESSAGE, i as PREVIEW_INERT_SCRIPTS_MESSAGE, a as PREVIEW_PROTOCOL_VERSION, n as PREVIEW_READY_MESSAGE, e as PREVIEW_RESYNC_MESSAGE, o as applyContentOps, t as formatContentPath, r as parseContentPath };
|
|
1
|
+
export { t as PREVIEW_CONTENT_PATCH_MESSAGE, n as PREVIEW_INERT_SCRIPTS_MESSAGE, r as PREVIEW_PROTOCOL_VERSION, i as PREVIEW_READY_MESSAGE, a as PREVIEW_RESYNC_MESSAGE, s as applyContentOps, c as formatContentPath, l as parseContentPath } from "../../protocol-C5KkkiZc.js";
|
package/dist/esm/server/index.js
CHANGED
|
@@ -1,41 +1,45 @@
|
|
|
1
|
-
import { a as e, c as t,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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-4D6Yk-h0.js";
|
|
2
|
+
import { t as s } from "../../preview-unavailable-BaHYVZQD.js";
|
|
3
|
+
import { n as c } from "../../plugin-B1kexnbX.js";
|
|
4
|
+
import { attach as l, createEffect as u, createEvent as d, createStore as f, sample as p } from "effector";
|
|
4
5
|
//#region src/server/serialize.ts
|
|
5
|
-
var
|
|
6
|
-
function
|
|
6
|
+
var m = 1e4;
|
|
7
|
+
function h(e) {
|
|
7
8
|
if (e?.location !== void 0) return { location: e.location };
|
|
8
9
|
}
|
|
9
|
-
function
|
|
10
|
-
return e.nodes.filter(
|
|
10
|
+
function g(e, t) {
|
|
11
|
+
return e.nodes.filter(n).some((e) => t.get(e.stepId) === !0);
|
|
11
12
|
}
|
|
12
|
-
async function
|
|
13
|
-
let
|
|
14
|
-
|
|
13
|
+
async function _(e, n = {}) {
|
|
14
|
+
let r = n.previewToken === void 0 ? void 0 : { previewToken: n.previewToken }, a = await e.getProjectConfig(r).catch((t) => {
|
|
15
|
+
if (!(t instanceof s)) throw t;
|
|
16
|
+
return r = void 0, e.getProjectConfig();
|
|
17
|
+
}), o = e.session.store.getState().id;
|
|
18
|
+
e.conditionResults.reset(), c(e, a, {
|
|
15
19
|
isPreview: !1,
|
|
16
20
|
sessionId: o
|
|
17
21
|
});
|
|
18
|
-
let
|
|
22
|
+
let l = h(n.attributes), u = n.timeoutMs ?? m, d = new Map(a.steps.map((e) => [e.id, e.layoutContentId !== void 0 && e.layoutContentId !== null])), f = Object.fromEntries(a.conditions.map((e) => [e.key, e])), p = a.experiences.filter((e) => !t(e.condition, f)), _ = (await Promise.all(p.map(async (t) => ({
|
|
19
23
|
experience: t,
|
|
20
|
-
active: await
|
|
21
|
-
})))).filter((e) => e.active).map((e) => e.experience),
|
|
24
|
+
active: await i(e, { condition: t.condition }, { context: l })
|
|
25
|
+
})))).filter((e) => e.active).map((e) => e.experience), v = await Promise.all(_.filter((e) => g(e, d)).map((t) => e.getExperienceContent({
|
|
22
26
|
id: t.id,
|
|
23
27
|
key: t.key
|
|
24
28
|
}, {
|
|
25
|
-
...
|
|
26
|
-
signal: AbortSignal.timeout(
|
|
27
|
-
}))),
|
|
28
|
-
for (let e of
|
|
29
|
+
...r,
|
|
30
|
+
signal: AbortSignal.timeout(u)
|
|
31
|
+
}))), y = /* @__PURE__ */ new Map();
|
|
32
|
+
for (let e of v) if (e) for (let t of [...e.references ?? [], ...e.content]) y.set(t.id, t);
|
|
29
33
|
return {
|
|
30
34
|
versionId: a.versionId,
|
|
31
35
|
projectConfig: a,
|
|
32
|
-
content: Array.from(
|
|
36
|
+
content: Array.from(y.values()),
|
|
33
37
|
conditionResults: e.conditionResults.store.getState()
|
|
34
38
|
};
|
|
35
39
|
}
|
|
36
40
|
//#endregion
|
|
37
41
|
//#region src/server/index.ts
|
|
38
|
-
function
|
|
42
|
+
function v() {
|
|
39
43
|
let e, t;
|
|
40
44
|
return {
|
|
41
45
|
promise: new Promise((n, r) => {
|
|
@@ -45,16 +49,16 @@ function _() {
|
|
|
45
49
|
reject: (e) => t(e)
|
|
46
50
|
};
|
|
47
51
|
}
|
|
48
|
-
function
|
|
49
|
-
let { promise: n, resolve: r } =
|
|
52
|
+
function y(e, t) {
|
|
53
|
+
let { promise: n, resolve: r } = v(), i = d(), a = d(), s = d(), c = d(), m = d(), h = e.experiences.listStore.map((t) => t.map((t) => o({
|
|
50
54
|
client: e,
|
|
51
55
|
experience: t
|
|
52
|
-
}))), g =
|
|
56
|
+
}))), g = f({
|
|
53
57
|
currentExperienceIndex: 0,
|
|
54
58
|
renderedExperiences: [],
|
|
55
59
|
isComplete: !1
|
|
56
|
-
}),
|
|
57
|
-
let n =
|
|
60
|
+
}), _ = u(async (t) => {
|
|
61
|
+
let n = l({
|
|
58
62
|
source: t.experience.componentStore,
|
|
59
63
|
effect: async (n, r) => {
|
|
60
64
|
let i = t.availableRenderers[r];
|
|
@@ -69,7 +73,7 @@ function v(e, t) {
|
|
|
69
73
|
if (t) return t;
|
|
70
74
|
}
|
|
71
75
|
return null;
|
|
72
|
-
}), y =
|
|
76
|
+
}), y = u(async ({ experience: e, availableRenderers: t, startRendererIndex: n = 0 }) => e ? _({
|
|
73
77
|
experience: e,
|
|
74
78
|
availableRenderers: t,
|
|
75
79
|
startRendererIndex: n
|
|
@@ -81,14 +85,14 @@ function v(e, t) {
|
|
|
81
85
|
})).on(m, (e) => ({
|
|
82
86
|
...e,
|
|
83
87
|
currentExperienceIndex: e.currentExperienceIndex + 1
|
|
84
|
-
})).on(
|
|
88
|
+
})).on(c, (e) => ({
|
|
85
89
|
...e,
|
|
86
90
|
isComplete: !0
|
|
87
|
-
})).reset(i),
|
|
91
|
+
})).reset(i), p({
|
|
88
92
|
clock: i,
|
|
89
|
-
target:
|
|
90
|
-
}),
|
|
91
|
-
clock:
|
|
93
|
+
target: a
|
|
94
|
+
}), p({
|
|
95
|
+
clock: a,
|
|
92
96
|
source: {
|
|
93
97
|
experiences: h,
|
|
94
98
|
state: g
|
|
@@ -100,24 +104,24 @@ function v(e, t) {
|
|
|
100
104
|
startRendererIndex: 0
|
|
101
105
|
}),
|
|
102
106
|
target: y
|
|
103
|
-
}),
|
|
107
|
+
}), p({
|
|
104
108
|
clock: y.doneData,
|
|
105
109
|
filter: (e) => e !== null,
|
|
106
110
|
fn: (e) => e.rendered.body,
|
|
107
111
|
target: s
|
|
108
|
-
}),
|
|
112
|
+
}), p({
|
|
109
113
|
clock: s,
|
|
110
|
-
target:
|
|
111
|
-
}),
|
|
114
|
+
target: a
|
|
115
|
+
}), p({
|
|
112
116
|
clock: y.doneData,
|
|
113
117
|
filter: (e) => e === null,
|
|
114
118
|
target: m
|
|
115
|
-
}),
|
|
119
|
+
}), p({
|
|
116
120
|
clock: m,
|
|
117
|
-
target:
|
|
118
|
-
}),
|
|
121
|
+
target: a
|
|
122
|
+
}), p({
|
|
119
123
|
clock: [
|
|
120
|
-
|
|
124
|
+
a,
|
|
121
125
|
m,
|
|
122
126
|
s
|
|
123
127
|
],
|
|
@@ -126,18 +130,18 @@ function v(e, t) {
|
|
|
126
130
|
state: g
|
|
127
131
|
},
|
|
128
132
|
filter: ({ experiences: e, state: t }) => t.currentExperienceIndex >= e.length,
|
|
129
|
-
target:
|
|
133
|
+
target: c
|
|
130
134
|
});
|
|
131
|
-
let b =
|
|
135
|
+
let b = l({
|
|
132
136
|
source: g,
|
|
133
137
|
effect: (e) => {
|
|
134
138
|
e.isComplete && r(e.renderedExperiences);
|
|
135
139
|
}
|
|
136
140
|
});
|
|
137
|
-
return
|
|
138
|
-
clock:
|
|
141
|
+
return p({
|
|
142
|
+
clock: c,
|
|
139
143
|
target: b
|
|
140
144
|
}), i(), n;
|
|
141
145
|
}
|
|
142
146
|
//#endregion
|
|
143
|
-
export {
|
|
147
|
+
export { o as createExperienceInstance, r as evaluateConditionMemo, e as hashRule, i as isExperienceActive, c as registerProjectConfig, y as render, a as ruleReferencesAction, t as ruleReferencesActionDeep, _ as serialize };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { t as createStorageKey, n as localStore, r as sessionStore, i as subscribe } from "../storage-1MW3-_As.js";
|