@picked/client 0.0.1-dev.1785826066660 → 0.0.1-dev.1785972867484
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/.tsbuildinfo +1 -1
- package/dist/{api-d0qKmzPH.js → api-BWJPDrlt.js} +1 -1
- package/dist/{api-Djuh2gfe.cjs → api-DPsVVMiu.cjs} +1 -1
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
- package/dist/cjs/server/index.js +1 -1
- package/dist/docs/explanation/conditions-and-the-logic-engine.md +94 -0
- package/dist/docs/explanation/feature-flag-allocation.md +176 -0
- package/dist/docs/explanation/how-picked-works.md +124 -0
- package/dist/docs/explanation/how-pickedql-works.md +76 -0
- package/dist/docs/explanation/pages-and-flows.md +64 -0
- package/dist/docs/explanation/the-content-model.md +77 -0
- package/dist/docs/explanation/the-two-apis.md +68 -0
- package/dist/docs/explanation/why-server-side-rendering.md +76 -0
- package/dist/docs/explanation/workspaces-and-versions.md +71 -0
- package/dist/docs/how-to/add-a-step-field-or-action.md +43 -0
- package/dist/docs/{pickedql/examples.md → how-to/analytics/index.md} +19 -6
- package/dist/docs/how-to/archive-or-delete-a-workspace.md +46 -0
- package/dist/docs/how-to/authenticate-with-a-magic-link.md +40 -0
- package/dist/docs/how-to/authenticate-with-a-password.md +51 -0
- package/dist/docs/how-to/authenticate-with-an-api-key.md +51 -0
- package/dist/docs/how-to/authenticate-with-oauth.md +40 -0
- package/dist/docs/{flow-builder/building-flows.md → how-to/build-a-flow.md} +13 -9
- package/dist/docs/how-to/connect-the-mcp-server.md +38 -0
- package/dist/docs/how-to/create-a-project.md +29 -0
- package/dist/docs/how-to/create-an-experience.md +42 -0
- package/dist/docs/how-to/create-and-revoke-an-api-key.md +37 -0
- package/dist/docs/how-to/debug-with-the-chrome-extension.md +57 -0
- package/dist/docs/how-to/define-a-page-layout.md +39 -0
- package/dist/docs/how-to/fill-and-publish-a-page.md +50 -0
- package/dist/docs/{gtm-template.md → how-to/install-the-gtm-template.md} +9 -3
- package/dist/docs/how-to/install-the-sdk.md +68 -0
- package/dist/docs/how-to/install-the-vite-plugin.md +56 -0
- package/dist/docs/how-to/invite-and-remove-members.md +34 -0
- package/dist/docs/how-to/preview-a-workspace.md +28 -0
- package/dist/docs/how-to/publish-a-workspace.md +30 -0
- package/dist/docs/how-to/read-a-feature-flag.md +101 -0
- package/dist/docs/how-to/register-a-component.md +55 -0
- package/dist/docs/how-to/register-an-action-handler.md +67 -0
- package/dist/docs/how-to/render-a-step-form.md +132 -0
- package/dist/docs/how-to/render-an-unpublished-preview.md +41 -0
- package/dist/docs/how-to/reuse-a-section.md +37 -0
- package/dist/docs/how-to/reuse-a-step-field-or-action.md +28 -0
- package/dist/docs/how-to/roll-back-a-published-version.md +26 -0
- package/dist/docs/how-to/run-an-ab-test.md +49 -0
- package/dist/docs/how-to/run-code-on-a-form-submission.md +125 -0
- package/dist/docs/how-to/server-render-a-page.md +81 -0
- package/dist/docs/how-to/set-a-content-security-policy.md +32 -0
- package/dist/docs/how-to/set-up-mfa.md +69 -0
- package/dist/docs/how-to/upload-and-use-an-asset.mdx +73 -0
- package/dist/docs/how-to/validate-a-field.md +52 -0
- package/dist/docs/how-to/write-a-condition.md +45 -0
- package/dist/docs/how-to/write-a-predicate.md +60 -0
- package/dist/docs/index.md +41 -70
- package/dist/docs/reference/dashboard/actions.mdx +53 -0
- package/dist/docs/{api-keys.mdx → reference/dashboard/api-keys.mdx} +7 -15
- package/dist/docs/reference/dashboard/conditions.mdx +42 -0
- package/dist/docs/reference/dashboard/content/asset-library.mdx +63 -0
- package/dist/docs/{content → reference/dashboard/content}/content-entries.mdx +11 -3
- package/dist/docs/{content → reference/dashboard/content}/layouts.mdx +11 -35
- package/dist/docs/reference/dashboard/content/pages.mdx +35 -0
- package/dist/docs/reference/dashboard/content/sections.mdx +28 -0
- package/dist/docs/{experiences.mdx → reference/dashboard/experiences.mdx} +9 -16
- package/dist/docs/{features.mdx → reference/dashboard/features.mdx} +26 -41
- package/dist/docs/{fields.mdx → reference/dashboard/fields.mdx} +26 -20
- package/dist/docs/{flow-builder/overview.mdx → reference/dashboard/flow-builder/canvas.mdx} +8 -13
- package/dist/docs/{flow-builder → reference/dashboard/flow-builder}/condition-builder.md +5 -13
- package/dist/docs/{flow-builder → reference/dashboard/flow-builder}/keyboard-shortcuts.md +7 -1
- package/dist/docs/{flow-builder → reference/dashboard/flow-builder}/nodes.md +10 -3
- package/dist/docs/reference/dashboard/projects.mdx +44 -0
- package/dist/docs/reference/dashboard/reports.mdx +43 -0
- package/dist/docs/reference/dashboard/steps.mdx +37 -0
- package/dist/docs/{team-management.md → reference/dashboard/team-management.md} +5 -22
- package/dist/docs/{workspace-versioning.mdx → reference/dashboard/workspace-versioning.mdx} +6 -10
- package/dist/docs/reference/dashboard/workspaces.mdx +76 -0
- package/dist/docs/{delivery-api → reference/delivery-api}/experience-content.md +11 -4
- package/dist/docs/reference/delivery-api/index.md +45 -0
- package/dist/docs/{delivery-api → reference/delivery-api}/preview-caching-crawling.md +12 -5
- package/dist/docs/{delivery-api → reference/delivery-api}/project-config.md +11 -4
- package/dist/docs/reference/glossary.md +173 -0
- package/dist/docs/reference/management-api/authentication.md +74 -0
- package/dist/docs/{api → reference/management-api}/authorization-and-scopes.md +10 -3
- package/dist/docs/{api → reference/management-api}/error-handling.md +9 -3
- package/dist/docs/{api → reference/management-api}/pagination.md +6 -0
- package/dist/docs/{pickedql → reference/pickedql}/data-sources.md +16 -9
- package/dist/docs/{pickedql → reference/pickedql}/dimensions.md +7 -0
- package/dist/docs/{pickedql → reference/pickedql}/filtering.md +7 -0
- package/dist/docs/reference/pickedql/index.md +18 -0
- package/dist/docs/{pickedql → reference/pickedql}/schema.md +13 -6
- package/dist/docs/{pickedql → reference/pickedql}/virtual-functions.md +7 -0
- package/dist/docs/reference/sdk/actions.md +30 -0
- package/dist/docs/{sdk → reference/sdk}/conditions.md +8 -1
- package/dist/docs/reference/sdk/content-security-policy.md +21 -0
- package/dist/docs/reference/sdk/experiences.md +51 -0
- package/dist/docs/{sdk → reference/sdk}/features.md +30 -117
- package/dist/docs/{sdk → reference/sdk}/fields.md +10 -88
- package/dist/docs/reference/sdk/index.md +68 -0
- package/dist/docs/{sdk → reference/sdk}/plugins/create-experience.md +10 -22
- package/dist/docs/reference/sdk/plugins/dynamic-experiences.md +74 -0
- package/dist/docs/reference/sdk/plugins/index.md +29 -0
- package/dist/docs/{sdk → reference/sdk}/plugins/window-object.md +6 -0
- package/dist/docs/reference/sdk/predicates.md +43 -0
- package/dist/docs/reference/sdk/ssr/index.md +33 -0
- package/dist/docs/{sdk → reference/sdk}/ssr/rendering-and-hydration.md +4 -63
- package/dist/docs/{sdk → reference/sdk}/ssr/serialize.md +6 -33
- package/dist/docs/{sdk → reference/sdk}/ssr/slots-and-placements.md +7 -1
- package/dist/docs/reference/sdk/steps.md +87 -0
- package/dist/docs/reference/tools/chrome-extension.md +16 -0
- package/dist/docs/{image-optimisation-service.md → reference/tools/image-optimisation-service.md} +8 -0
- package/dist/docs/{mcp.md → reference/tools/mcp.md} +5 -45
- package/dist/docs/{vite-plugin.md → reference/tools/vite-plugin.md} +34 -35
- package/dist/docs/{api/index.md → tutorials/first-api-call.md} +27 -15
- package/dist/docs/tutorials/first-experience-in-the-dashboard.mdx +143 -0
- package/dist/docs/tutorials/first-experience.mdx +255 -0
- package/dist/docs/tutorials/first-server-rendered-page.mdx +186 -0
- package/dist/esm/index.js +290 -319
- package/dist/esm/plugins/dynamic-experiences/index.js +3 -3
- package/dist/esm/server/index.js +22 -22
- package/dist/plugin-BcDuXGos.cjs +1 -0
- package/dist/plugin-Csb2irFa.js +287 -0
- package/dist/types/data-source/api.d.ts +60 -0
- package/dist/types/data-source/api.d.ts.map +1 -0
- package/dist/types/data-source/provider.d.ts +97 -0
- package/dist/types/data-source/provider.d.ts.map +1 -0
- package/dist/types/entities/feature/feature.d.ts +16 -0
- package/dist/types/entities/feature/feature.d.ts.map +1 -1
- package/dist/types/exports.d.ts +0 -2
- package/dist/types/exports.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/picked.d.ts +15 -0
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/index.d.ts +2 -0
- package/dist/types/plugins/dynamic-experiences/index.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts +2 -34
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts +34 -16
- package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
- package/dist/types/server/serialize.d.ts +7 -6
- package/dist/types/server/serialize.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/docs/actions.mdx +0 -98
- package/dist/docs/api/authentication.md +0 -403
- package/dist/docs/chrome-extension.md +0 -68
- package/dist/docs/conditions.mdx +0 -72
- package/dist/docs/content/asset-library.mdx +0 -124
- package/dist/docs/content/pages.mdx +0 -82
- package/dist/docs/content/sections.mdx +0 -44
- package/dist/docs/delivery-api/index.md +0 -53
- package/dist/docs/guides/build-a-personalized-page.mdx +0 -161
- package/dist/docs/pickedql/index.md +0 -54
- package/dist/docs/projects.mdx +0 -44
- package/dist/docs/reports.mdx +0 -20
- package/dist/docs/sdk/actions.md +0 -82
- package/dist/docs/sdk/content-security-policy.md +0 -33
- package/dist/docs/sdk/experiences.md +0 -64
- package/dist/docs/sdk/feature-allocation.md +0 -161
- package/dist/docs/sdk/index.md +0 -98
- package/dist/docs/sdk/plugins/dynamic-experiences.md +0 -84
- package/dist/docs/sdk/plugins/index.md +0 -9
- package/dist/docs/sdk/predicates.md +0 -128
- package/dist/docs/sdk/ssr/index.md +0 -79
- package/dist/docs/sdk/steps.md +0 -479
- package/dist/docs/steps.mdx +0 -53
- package/dist/docs/workspaces.mdx +0 -133
- package/dist/plugin-BVAFWjpT.js +0 -252
- package/dist/plugin-BcCn2llk.cjs +0 -1
- package/dist/types/entities/content/reference.d.ts +0 -101
- package/dist/types/entities/content/reference.d.ts.map +0 -1
package/dist/plugin-BVAFWjpT.js
DELETED
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
import "./logger-DMN6TxJJ.js";
|
|
2
|
-
import { t as e } from "./api-d0qKmzPH.js";
|
|
3
|
-
import { attach as t } from "effector";
|
|
4
|
-
//#region src/plugins/dynamic-experiences/hash.ts
|
|
5
|
-
function n(e) {
|
|
6
|
-
let t = 2166136261;
|
|
7
|
-
for (let n of e) t ^= n.codePointAt(0) ?? 0, t = Math.imul(t, 16777619);
|
|
8
|
-
return t >>> 0;
|
|
9
|
-
}
|
|
10
|
-
function r(e) {
|
|
11
|
-
let t = e;
|
|
12
|
-
return t ^= t >>> 16, t = Math.imul(t, 2246822507), t ^= t >>> 13, t = Math.imul(t, 3266489909), t ^= t >>> 16, t >>> 0;
|
|
13
|
-
}
|
|
14
|
-
function i(e, t) {
|
|
15
|
-
return r(n(`${e}:${t}`)) % 100;
|
|
16
|
-
}
|
|
17
|
-
function a(e, t) {
|
|
18
|
-
return t <= 0 ? !1 : t >= 100 || e < t;
|
|
19
|
-
}
|
|
20
|
-
//#endregion
|
|
21
|
-
//#region src/plugins/dynamic-experiences/plugin.ts
|
|
22
|
-
function o(e) {
|
|
23
|
-
return typeof e == "object" && !!e && "features" in e && Array.isArray(e.features);
|
|
24
|
-
}
|
|
25
|
-
function s(e, t) {
|
|
26
|
-
if (Array.isArray(t.conditions)) for (let n of t.conditions) e.registerCondition(n);
|
|
27
|
-
}
|
|
28
|
-
function c(e, t) {
|
|
29
|
-
e.registerExperience({
|
|
30
|
-
id: t.id,
|
|
31
|
-
key: t.key,
|
|
32
|
-
name: t.name,
|
|
33
|
-
targets: t.targets,
|
|
34
|
-
nodes: t.nodes,
|
|
35
|
-
edges: t.edges,
|
|
36
|
-
condition: t.condition,
|
|
37
|
-
initializeOpen: t.initializeOpen,
|
|
38
|
-
componentName: t.componentName
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
function l(e, t) {
|
|
42
|
-
if (Array.isArray(t.fields)) for (let n of t.fields) e.registerField(n);
|
|
43
|
-
}
|
|
44
|
-
function u(e, t) {
|
|
45
|
-
if (!Array.isArray(t.steps)) return;
|
|
46
|
-
let n = new Map(t.fields.map((e) => [e.id, e.key]));
|
|
47
|
-
for (let r of t.steps) {
|
|
48
|
-
let t = [];
|
|
49
|
-
for (let e of r.fieldIds ?? []) {
|
|
50
|
-
let i = n.get(e);
|
|
51
|
-
if (i === void 0) {
|
|
52
|
-
`${r.key}${e}`;
|
|
53
|
-
continue;
|
|
54
|
-
}
|
|
55
|
-
t.push(i);
|
|
56
|
-
}
|
|
57
|
-
let i = r.layoutContentId ? e.contents.getById(r.layoutContentId) : null;
|
|
58
|
-
e.registerStep({
|
|
59
|
-
id: r.id,
|
|
60
|
-
key: r.key,
|
|
61
|
-
name: r.name,
|
|
62
|
-
fieldKeys: t,
|
|
63
|
-
layoutName: r.layoutName,
|
|
64
|
-
...r.layoutContentId !== void 0 && {
|
|
65
|
-
layoutContentId: r.layoutContentId,
|
|
66
|
-
layoutContentStore: i
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
function d(e, t) {
|
|
72
|
-
if (Array.isArray(t.experiences)) for (let n of t.experiences) c(e, n);
|
|
73
|
-
}
|
|
74
|
-
function f(e, t, n) {
|
|
75
|
-
h(e, t, n.isPreview, n.sessionId), s(e, t), l(e, t), u(e, t), d(e, t);
|
|
76
|
-
}
|
|
77
|
-
function p(e) {
|
|
78
|
-
let t = e.searchParams["preview-token"];
|
|
79
|
-
if (t && t.length > 0) return t[0];
|
|
80
|
-
}
|
|
81
|
-
function m(e) {
|
|
82
|
-
let t = /* @__PURE__ */ new Set(), n = e.searchParams.feature;
|
|
83
|
-
if (!n) return t;
|
|
84
|
-
for (let e of n) {
|
|
85
|
-
let n = e.indexOf(":");
|
|
86
|
-
n > 0 && t.add(e.substring(0, n));
|
|
87
|
-
}
|
|
88
|
-
return t;
|
|
89
|
-
}
|
|
90
|
-
function h(e, t, n, r) {
|
|
91
|
-
let i = m(e);
|
|
92
|
-
for (let a of t.features) i.has(a.id) || g(e, a, n, r);
|
|
93
|
-
}
|
|
94
|
-
function g(e, t, n, r) {
|
|
95
|
-
let o = i(r, t.id);
|
|
96
|
-
e.registerFeature(t.id, {
|
|
97
|
-
key: `v${t.version}`,
|
|
98
|
-
name: t.name,
|
|
99
|
-
enabled: t.enabled,
|
|
100
|
-
weight: t.weight,
|
|
101
|
-
storage: n ? "session" : "local",
|
|
102
|
-
decide: () => a(o, t.weight)
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
function _(e) {
|
|
106
|
-
try {
|
|
107
|
-
let t = new URL(e).hostname;
|
|
108
|
-
return t === "localhost" || t === "127.0.0.1" || t === "::1";
|
|
109
|
-
} catch {
|
|
110
|
-
return !1;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
function v(e) {
|
|
114
|
-
if (typeof e != "object" || !e || !("cause" in e)) return !1;
|
|
115
|
-
let { cause: t } = e;
|
|
116
|
-
return typeof t != "object" || !t || !("code" in t) ? !1 : t.code === "ECONNREFUSED";
|
|
117
|
-
}
|
|
118
|
-
async function y(t, n, r) {
|
|
119
|
-
let i = r?.previewToken ? `projects/${n}?preview_token=${encodeURIComponent(r.previewToken)}` : `projects/${n}`, a;
|
|
120
|
-
try {
|
|
121
|
-
a = await e(t, i, r?.headers);
|
|
122
|
-
} catch (e) {
|
|
123
|
-
return _(t) && v(e), null;
|
|
124
|
-
}
|
|
125
|
-
if (!a.ok) return `${a.status.toString()}`, null;
|
|
126
|
-
let s;
|
|
127
|
-
try {
|
|
128
|
-
s = await a.json();
|
|
129
|
-
} catch {
|
|
130
|
-
return null;
|
|
131
|
-
}
|
|
132
|
-
return o(s) ? s : null;
|
|
133
|
-
}
|
|
134
|
-
function b(e) {
|
|
135
|
-
return typeof e != "object" || !e || !("experienceId" in e) || !("content" in e) ? !1 : Array.isArray(e.content);
|
|
136
|
-
}
|
|
137
|
-
async function x(t, n, r, i) {
|
|
138
|
-
let a = i?.previewToken ? `projects/${n}/experiences/${r}/content?preview_token=${encodeURIComponent(i.previewToken)}` : `projects/${n}/experiences/${r}/content`, o;
|
|
139
|
-
try {
|
|
140
|
-
o = await e(t, a, i?.headers, i?.signal);
|
|
141
|
-
} catch (e) {
|
|
142
|
-
return _(t) && v(e) || `${r}`, null;
|
|
143
|
-
}
|
|
144
|
-
if (!o.ok) return `${r}${o.status.toString()}`, null;
|
|
145
|
-
let s;
|
|
146
|
-
try {
|
|
147
|
-
s = await o.json();
|
|
148
|
-
} catch {
|
|
149
|
-
return `${r}`, null;
|
|
150
|
-
}
|
|
151
|
-
return b(s) ? s : (`${r}`, null);
|
|
152
|
-
}
|
|
153
|
-
function S(e, t) {
|
|
154
|
-
for (let n of [...t.references ?? [], ...t.content]) e.registerContent({
|
|
155
|
-
id: n.id,
|
|
156
|
-
contentModelKey: n.contentModelKey,
|
|
157
|
-
data: n.data
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
function C(e) {
|
|
161
|
-
if (typeof e != "object" || !e || !("projectConfig" in e) || !("experienceContent" in e) || !("manifestMetadata" in e)) return !1;
|
|
162
|
-
let { experienceContent: t } = e;
|
|
163
|
-
return typeof t == "function";
|
|
164
|
-
}
|
|
165
|
-
async function w() {
|
|
166
|
-
try {
|
|
167
|
-
let e = await import("virtual:picked/data");
|
|
168
|
-
return C(e) ? e : null;
|
|
169
|
-
} catch {
|
|
170
|
-
return null;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
function T(e, t, n) {
|
|
174
|
-
return (r) => x(e, t, r.id, n ? { previewToken: n } : void 0);
|
|
175
|
-
}
|
|
176
|
-
function E(e, t) {
|
|
177
|
-
return (n) => e(n, t ? { previewToken: t } : void 0);
|
|
178
|
-
}
|
|
179
|
-
function D(e) {
|
|
180
|
-
return (t, n) => e.experienceContent(t, n);
|
|
181
|
-
}
|
|
182
|
-
function O(e, t) {
|
|
183
|
-
let n = /* @__PURE__ */ new Map();
|
|
184
|
-
return (r, i) => {
|
|
185
|
-
let a = n.get(r.id);
|
|
186
|
-
if (a) return a;
|
|
187
|
-
let o = (async () => {
|
|
188
|
-
try {
|
|
189
|
-
let n = await t(r, i);
|
|
190
|
-
return n && S(e, n), n;
|
|
191
|
-
} finally {
|
|
192
|
-
n.delete(r.id);
|
|
193
|
-
}
|
|
194
|
-
})();
|
|
195
|
-
return n.set(r.id, o), o;
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
function k(e, t) {
|
|
199
|
-
let n = new Set(t && Array.isArray(t.experiences) ? t.experiences.map((e) => e.id) : []);
|
|
200
|
-
return (t, r) => n.has(t.id) ? e(t, r) : Promise.resolve(null);
|
|
201
|
-
}
|
|
202
|
-
async function A(e) {
|
|
203
|
-
let { client: t, apiUrl: n, options: r } = e, i = p(t), a = !!i, o = r?.projectConfig ?? null, s = r?.getContent ? E(r.getContent, i) : null, c = null;
|
|
204
|
-
if (i) return o ??= await y(n, t.projectId, { previewToken: i }), s ??= T(n, t.projectId, i), {
|
|
205
|
-
config: o,
|
|
206
|
-
contentLoader: s,
|
|
207
|
-
dataSource: c,
|
|
208
|
-
isPreview: a
|
|
209
|
-
};
|
|
210
|
-
if (o && s) return {
|
|
211
|
-
config: o,
|
|
212
|
-
contentLoader: s,
|
|
213
|
-
dataSource: c,
|
|
214
|
-
isPreview: a
|
|
215
|
-
};
|
|
216
|
-
let l = await w();
|
|
217
|
-
return l ? (o ??= l.projectConfig, s ??= D(l), c = l.manifestMetadata, {
|
|
218
|
-
config: o,
|
|
219
|
-
contentLoader: s,
|
|
220
|
-
dataSource: c,
|
|
221
|
-
isPreview: a
|
|
222
|
-
}) : (o ??= await y(n, t.projectId), s ??= T(n, t.projectId), {
|
|
223
|
-
config: o,
|
|
224
|
-
contentLoader: s,
|
|
225
|
-
dataSource: c,
|
|
226
|
-
isPreview: a
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
function j(e) {
|
|
230
|
-
return {
|
|
231
|
-
name: "dynamic-experiences",
|
|
232
|
-
setup: (n) => {
|
|
233
|
-
let r = e?.apiUrl ?? n.apiUrl;
|
|
234
|
-
return { onStart: t({
|
|
235
|
-
source: n.session.store.map((e) => e.id),
|
|
236
|
-
effect: async (t) => {
|
|
237
|
-
let { config: i, contentLoader: a, dataSource: o, isPreview: s } = await A({
|
|
238
|
-
client: n,
|
|
239
|
-
apiUrl: r,
|
|
240
|
-
options: e
|
|
241
|
-
});
|
|
242
|
-
a && (n.contentLoader = O(n, k(a, i))), n.dataSource = o, i && (n.previewEmbedderOrigins = i.previewEmbedderOrigins ?? null, f(n, i, {
|
|
243
|
-
isPreview: s,
|
|
244
|
-
sessionId: t
|
|
245
|
-
}));
|
|
246
|
-
}
|
|
247
|
-
}) };
|
|
248
|
-
}
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
//#endregion
|
|
252
|
-
export { f as i, x as n, y as r, j as t };
|
package/dist/plugin-BcCn2llk.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require("./logger-CSTvAyyB.cjs");const e=require("./api-Djuh2gfe.cjs");let t=require("effector");function n(e){let t=2166136261;for(let n of e)t^=n.codePointAt(0)??0,t=Math.imul(t,16777619);return t>>>0}function r(e){let t=e;return t^=t>>>16,t=Math.imul(t,2246822507),t^=t>>>13,t=Math.imul(t,3266489909),t^=t>>>16,t>>>0}function i(e,t){return r(n(`${e}:${t}`))%100}function a(e,t){return t<=0?!1:t>=100||e<t}function o(e){return typeof e==`object`&&!!e&&`features`in e&&Array.isArray(e.features)}function s(e,t){if(Array.isArray(t.conditions))for(let n of t.conditions)e.registerCondition(n)}function c(e,t){e.registerExperience({id:t.id,key:t.key,name:t.name,targets:t.targets,nodes:t.nodes,edges:t.edges,condition:t.condition,initializeOpen:t.initializeOpen,componentName:t.componentName})}function l(e,t){if(Array.isArray(t.fields))for(let n of t.fields)e.registerField(n)}function u(e,t){if(!Array.isArray(t.steps))return;let n=new Map(t.fields.map(e=>[e.id,e.key]));for(let r of t.steps){let t=[];for(let e of r.fieldIds??[]){let i=n.get(e);if(i===void 0){`${r.key}${e}`;continue}t.push(i)}let i=r.layoutContentId?e.contents.getById(r.layoutContentId):null;e.registerStep({id:r.id,key:r.key,name:r.name,fieldKeys:t,layoutName:r.layoutName,...r.layoutContentId!==void 0&&{layoutContentId:r.layoutContentId,layoutContentStore:i}})}}function d(e,t){if(Array.isArray(t.experiences))for(let n of t.experiences)c(e,n)}function f(e,t,n){h(e,t,n.isPreview,n.sessionId),s(e,t),l(e,t),u(e,t),d(e,t)}function p(e){let t=e.searchParams[`preview-token`];if(t&&t.length>0)return t[0]}function m(e){let t=new Set,n=e.searchParams.feature;if(!n)return t;for(let e of n){let n=e.indexOf(`:`);n>0&&t.add(e.substring(0,n))}return t}function h(e,t,n,r){let i=m(e);for(let a of t.features)i.has(a.id)||g(e,a,n,r)}function g(e,t,n,r){let o=i(r,t.id);e.registerFeature(t.id,{key:`v${t.version}`,name:t.name,enabled:t.enabled,weight:t.weight,storage:n?`session`:`local`,decide:()=>a(o,t.weight)})}function _(e){try{let t=new URL(e).hostname;return t===`localhost`||t===`127.0.0.1`||t===`::1`}catch{return!1}}function v(e){if(typeof e!=`object`||!e||!(`cause`in e))return!1;let{cause:t}=e;return typeof t!=`object`||!t||!(`code`in t)?!1:t.code===`ECONNREFUSED`}async function y(t,n,r){let i=r?.previewToken?`projects/${n}?preview_token=${encodeURIComponent(r.previewToken)}`:`projects/${n}`,a;try{a=await e.t(t,i,r?.headers)}catch(e){return _(t)&&v(e),null}if(!a.ok)return`${a.status.toString()}`,null;let s;try{s=await a.json()}catch{return null}return o(s)?s:null}function b(e){return typeof e!=`object`||!e||!(`experienceId`in e)||!(`content`in e)?!1:Array.isArray(e.content)}async function x(t,n,r,i){let a=i?.previewToken?`projects/${n}/experiences/${r}/content?preview_token=${encodeURIComponent(i.previewToken)}`:`projects/${n}/experiences/${r}/content`,o;try{o=await e.t(t,a,i?.headers,i?.signal)}catch(e){return _(t)&&v(e)||`${r}`,null}if(!o.ok)return`${r}${o.status.toString()}`,null;let s;try{s=await o.json()}catch{return`${r}`,null}return b(s)?s:(`${r}`,null)}function S(e,t){for(let n of[...t.references??[],...t.content])e.registerContent({id:n.id,contentModelKey:n.contentModelKey,data:n.data})}function C(e){if(typeof e!=`object`||!e||!(`projectConfig`in e)||!(`experienceContent`in e)||!(`manifestMetadata`in e))return!1;let{experienceContent:t}=e;return typeof t==`function`}async function w(){try{let e=await import(`virtual:picked/data`);return C(e)?e:null}catch{return null}}function T(e,t,n){return r=>x(e,t,r.id,n?{previewToken:n}:void 0)}function E(e,t){return n=>e(n,t?{previewToken:t}:void 0)}function D(e){return(t,n)=>e.experienceContent(t,n)}function O(e,t){let n=new Map;return(r,i)=>{let a=n.get(r.id);if(a)return a;let o=(async()=>{try{let n=await t(r,i);return n&&S(e,n),n}finally{n.delete(r.id)}})();return n.set(r.id,o),o}}function k(e,t){let n=new Set(t&&Array.isArray(t.experiences)?t.experiences.map(e=>e.id):[]);return(t,r)=>n.has(t.id)?e(t,r):Promise.resolve(null)}async function A(e){let{client:t,apiUrl:n,options:r}=e,i=p(t),a=!!i,o=r?.projectConfig??null,s=r?.getContent?E(r.getContent,i):null,c=null;if(i)return o??=await y(n,t.projectId,{previewToken:i}),s??=T(n,t.projectId,i),{config:o,contentLoader:s,dataSource:c,isPreview:a};if(o&&s)return{config:o,contentLoader:s,dataSource:c,isPreview:a};let l=await w();return l?(o??=l.projectConfig,s??=D(l),c=l.manifestMetadata,{config:o,contentLoader:s,dataSource:c,isPreview:a}):(o??=await y(n,t.projectId),s??=T(n,t.projectId),{config:o,contentLoader:s,dataSource:c,isPreview:a})}function j(e){return{name:`dynamic-experiences`,setup:n=>{let r=e?.apiUrl??n.apiUrl;return{onStart:(0,t.attach)({source:n.session.store.map(e=>e.id),effect:async t=>{let{config:i,contentLoader:a,dataSource:o,isPreview:s}=await A({client:n,apiUrl:r,options:e});a&&(n.contentLoader=O(n,k(a,i))),n.dataSource=o,i&&(n.previewEmbedderOrigins=i.previewEmbedderOrigins??null,f(n,i,{isPreview:s,sessionId:t}))}})}}}}Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return j}});
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Reading `reference` field values out of a delivered content blob.
|
|
3
|
-
*
|
|
4
|
-
* A `reference` field arrives as a pointer at another Content record rather than
|
|
5
|
-
* as the record itself. The referenced record travels separately and is
|
|
6
|
-
* registered into the content index under its own id, so resolving a pointer is
|
|
7
|
-
* a registry lookup — see `useReference` (`@picked/react`) and `getReference`
|
|
8
|
-
* (`@picked/svelte`), which is what most consumers should reach for.
|
|
9
|
-
*
|
|
10
|
-
* This module is the framework-agnostic half: readers that turn a raw field
|
|
11
|
-
* value into the id (or ids) to look up, tolerating both a single value and the
|
|
12
|
-
* array a repeatable field delivers, plus the store derivations the framework
|
|
13
|
-
* bindings wrap.
|
|
14
|
-
*/
|
|
15
|
-
import { type Store } from 'effector';
|
|
16
|
-
import type { Content, ContentsStore } from './content';
|
|
17
|
-
/** A pointer at another Content record, as delivered inside a `reference` field. */
|
|
18
|
-
export interface ContentReference {
|
|
19
|
-
/** Id of the referenced Content record, to look up in the content index. */
|
|
20
|
-
contentEntryId: string;
|
|
21
|
-
/** The `key` of the Content Model the target belongs to, or `null` when unresolved. */
|
|
22
|
-
contentModelKey?: string | null;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Narrows an arbitrary field value to a {@link ContentReference}.
|
|
26
|
-
*
|
|
27
|
-
* A pointer that still carries inline `data` matches: the delivery surface emits
|
|
28
|
-
* inline data alongside the separate record while that format is retired, and
|
|
29
|
-
* both shapes address the same record.
|
|
30
|
-
*
|
|
31
|
-
* @param {unknown} value - The raw value read from a content blob's `data`.
|
|
32
|
-
* @returns {boolean} Whether `value` is a reference pointer.
|
|
33
|
-
* @example
|
|
34
|
-
* ```typescript
|
|
35
|
-
* if (isContentReference(content.author)) { content.author.contentEntryId }
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
export declare function isContentReference(value: unknown): value is ContentReference;
|
|
39
|
-
/**
|
|
40
|
-
* Reads the referenced Content record id from a single `reference` field value.
|
|
41
|
-
*
|
|
42
|
-
* @param {unknown} value - The raw value read from a content blob's `data`.
|
|
43
|
-
* @returns {string | null} The referenced id, or `null` when the field is unset or not a reference.
|
|
44
|
-
* @example
|
|
45
|
-
* ```typescript
|
|
46
|
-
* const authorId = readReferenceId(content.author)
|
|
47
|
-
* ```
|
|
48
|
-
*/
|
|
49
|
-
export declare function readReferenceId(value: unknown): string | null;
|
|
50
|
-
/**
|
|
51
|
-
* Reads every referenced Content record id from a `reference` field, whether it
|
|
52
|
-
* was authored as repeatable or not. Values that are not references are dropped,
|
|
53
|
-
* so the result is always a list of ids that can be looked up.
|
|
54
|
-
*
|
|
55
|
-
* @param {unknown} value - The raw value read from a content blob's `data`.
|
|
56
|
-
* @returns {string[]} The referenced ids, in field order.
|
|
57
|
-
* @example
|
|
58
|
-
* ```typescript
|
|
59
|
-
* const authorIds = readReferenceIds(content.authors)
|
|
60
|
-
* ```
|
|
61
|
-
*/
|
|
62
|
-
export declare function readReferenceIds(value: unknown): string[];
|
|
63
|
-
/**
|
|
64
|
-
* Derives a store resolving a single `reference` field value against the content
|
|
65
|
-
* registry.
|
|
66
|
-
*
|
|
67
|
-
* Reads the registry index rather than a per-id store so an unset field, an
|
|
68
|
-
* unregistered target, and a target registered after first paint all flow
|
|
69
|
-
* through one reactive path. The framework bindings (`useReference`,
|
|
70
|
-
* `getReference`) wrap this; call it directly only outside React and Svelte.
|
|
71
|
-
*
|
|
72
|
-
* @param {ContentsStore} contents - The client's content registry.
|
|
73
|
-
* @param {unknown} value - The raw `reference` value, or an Effector store carrying one. A
|
|
74
|
-
* store keeps the lookup live when the field arrives after this call.
|
|
75
|
-
* @returns {Store<Content | null>} The referenced record, or `null` when the field is unset or its target is not registered.
|
|
76
|
-
* @example
|
|
77
|
-
* ```typescript
|
|
78
|
-
* const author = deriveReference(client.contents, content.author)
|
|
79
|
-
* ```
|
|
80
|
-
*/
|
|
81
|
-
export declare function deriveReference(contents: ContentsStore, value: unknown): Store<Content | null>;
|
|
82
|
-
/**
|
|
83
|
-
* Derives a store resolving a repeatable `reference` field against the content
|
|
84
|
-
* registry, in field order. A single (non-repeatable) value resolves to a
|
|
85
|
-
* one-element list.
|
|
86
|
-
*
|
|
87
|
-
* The list is dense: a pointer whose target is not registered — deleted, cut off
|
|
88
|
-
* by the reference depth cap, or belonging to another workspace — is skipped
|
|
89
|
-
* rather than held as a hole, so consumers can iterate without a null check.
|
|
90
|
-
*
|
|
91
|
-
* @param {ContentsStore} contents - The client's content registry.
|
|
92
|
-
* @param {unknown} value - The raw `reference` value, or an Effector store carrying one. A
|
|
93
|
-
* store keeps the lookup live when the field arrives after this call.
|
|
94
|
-
* @returns {Store<Content[]>} The referenced records that resolved.
|
|
95
|
-
* @example
|
|
96
|
-
* ```typescript
|
|
97
|
-
* const authors = deriveReferences(client.contents, content.authors)
|
|
98
|
-
* ```
|
|
99
|
-
*/
|
|
100
|
-
export declare function deriveReferences(contents: ContentsStore, value: unknown): Store<Content[]>;
|
|
101
|
-
//# sourceMappingURL=reference.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"reference.d.ts","sourceRoot":"","sources":["../../../../src/entities/content/reference.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAe,KAAK,KAAK,EAAE,MAAM,UAAU,CAAA;AAClD,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAA;AAEvD,oFAAoF;AACpF,MAAM,WAAW,gBAAgB;IAC/B,4EAA4E;IAC5E,cAAc,EAAE,MAAM,CAAA;IACtB,uFAAuF;IACvF,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAChC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,gBAAgB,CAQ5E;AAED;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAE7D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,EAAE,CAUzD;AAiCD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,CAS9F;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,OAAO,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC,CAS1F"}
|