@picked/client 0.0.1-dev.1786004500650 → 0.0.1-dev.1786065500148
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/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/esm/index.js +354 -270
- package/dist/esm/plugins/dynamic-experiences/index.js +3 -3
- package/dist/esm/server/index.js +36 -39
- package/dist/plugin-EFn9ALEF.cjs +1 -0
- package/dist/plugin-YytfMG0n.js +153 -0
- package/dist/registry-BYtEBdL1.js +111 -0
- package/dist/registry-DtmKJre-.cjs +1 -0
- package/dist/types/data-source/provider.d.ts +2 -0
- package/dist/types/data-source/provider.d.ts.map +1 -1
- package/dist/types/picked.d.ts +50 -1
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/index.d.ts +1 -3
- package/dist/types/plugins/dynamic-experiences/index.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts +8 -7
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts +0 -24
- package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
- package/dist/types/server/index.d.ts +1 -1
- package/dist/types/server/index.d.ts.map +1 -1
- package/dist/types/server/serialize.d.ts +7 -25
- package/dist/types/server/serialize.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/api-BLYaNoaa.cjs +0 -1
- package/dist/api-fPB4ZBjC.js +0 -38
- package/dist/plugin-Bg-jjHsL.cjs +0 -1
- package/dist/plugin-CfO5xaRm.js +0 -302
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
1
|
+
import { a as e, c as t, i as n, n as r } from "../../../registry-BYtEBdL1.js";
|
|
2
|
+
import { t as i } from "../../../plugin-YytfMG0n.js";
|
|
3
|
+
export { t as createClientHeaders, i as dynamicExperiencesPlugin, n as fetchExperienceContent, e as fetchProject, r as registerPickedBundle };
|
package/dist/esm/server/index.js
CHANGED
|
@@ -1,44 +1,41 @@
|
|
|
1
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 {
|
|
3
|
-
import { attach as
|
|
2
|
+
import { n as s } from "../../plugin-YytfMG0n.js";
|
|
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
|
-
var
|
|
6
|
-
function
|
|
5
|
+
var p = 1e4;
|
|
6
|
+
function m(e) {
|
|
7
7
|
if (e?.location !== void 0) return { location: e.location };
|
|
8
8
|
}
|
|
9
|
-
function
|
|
9
|
+
function h(e, t) {
|
|
10
10
|
return e.nodes.filter(o).some((e) => t.get(e.stepId) === !0);
|
|
11
11
|
}
|
|
12
|
-
async function
|
|
13
|
-
let {
|
|
14
|
-
e.conditionResults.reset(),
|
|
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;
|
|
14
|
+
e.conditionResults.reset(), s(e, a, {
|
|
15
15
|
isPreview: !1,
|
|
16
|
-
sessionId:
|
|
16
|
+
sessionId: o
|
|
17
17
|
});
|
|
18
|
-
let
|
|
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:
|
|
21
|
-
})))).filter((e) => e.active).map((e) => e.experience), _ = await Promise.all(
|
|
20
|
+
active: await r(e, { condition: t.condition }, { context: c })
|
|
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
|
-
}
|
|
25
|
-
|
|
26
|
-
key: t.key
|
|
27
|
-
}, { previewToken: n.previewToken }) : s(e.apiUrl, e.projectId, t.id, {
|
|
28
|
-
previewToken: n.previewToken,
|
|
24
|
+
}, {
|
|
25
|
+
...i,
|
|
29
26
|
signal: AbortSignal.timeout(l)
|
|
30
27
|
}))), v = /* @__PURE__ */ new Map();
|
|
31
28
|
for (let e of _) if (e) for (let t of e.content) v.set(t.id, t);
|
|
32
29
|
return {
|
|
33
|
-
versionId:
|
|
34
|
-
projectConfig:
|
|
30
|
+
versionId: a.versionId,
|
|
31
|
+
projectConfig: a,
|
|
35
32
|
content: Array.from(v.values()),
|
|
36
33
|
conditionResults: e.conditionResults.store.getState()
|
|
37
34
|
};
|
|
38
35
|
}
|
|
39
36
|
//#endregion
|
|
40
37
|
//#region src/server/index.ts
|
|
41
|
-
function
|
|
38
|
+
function _() {
|
|
42
39
|
let e, t;
|
|
43
40
|
return {
|
|
44
41
|
promise: new Promise((n, r) => {
|
|
@@ -48,16 +45,16 @@ function v() {
|
|
|
48
45
|
reject: (e) => t(e)
|
|
49
46
|
};
|
|
50
47
|
}
|
|
51
|
-
function
|
|
52
|
-
let { promise: n, resolve: r } =
|
|
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({
|
|
53
50
|
client: e,
|
|
54
51
|
experience: t
|
|
55
|
-
}))), g =
|
|
52
|
+
}))), g = d({
|
|
56
53
|
currentExperienceIndex: 0,
|
|
57
54
|
renderedExperiences: [],
|
|
58
55
|
isComplete: !1
|
|
59
|
-
}),
|
|
60
|
-
let n =
|
|
56
|
+
}), v = l(async (t) => {
|
|
57
|
+
let n = c({
|
|
61
58
|
source: t.experience.componentStore,
|
|
62
59
|
effect: async (n, r) => {
|
|
63
60
|
let i = t.availableRenderers[r];
|
|
@@ -72,7 +69,7 @@ function y(e, t) {
|
|
|
72
69
|
if (t) return t;
|
|
73
70
|
}
|
|
74
71
|
return null;
|
|
75
|
-
}), y =
|
|
72
|
+
}), y = l(async ({ experience: e, availableRenderers: t, startRendererIndex: n = 0 }) => e ? v({
|
|
76
73
|
experience: e,
|
|
77
74
|
availableRenderers: t,
|
|
78
75
|
startRendererIndex: n
|
|
@@ -84,13 +81,13 @@ function y(e, t) {
|
|
|
84
81
|
})).on(m, (e) => ({
|
|
85
82
|
...e,
|
|
86
83
|
currentExperienceIndex: e.currentExperienceIndex + 1
|
|
87
|
-
})).on(
|
|
84
|
+
})).on(p, (e) => ({
|
|
88
85
|
...e,
|
|
89
86
|
isComplete: !0
|
|
90
|
-
})).reset(i),
|
|
87
|
+
})).reset(i), f({
|
|
91
88
|
clock: i,
|
|
92
89
|
target: o
|
|
93
|
-
}),
|
|
90
|
+
}), f({
|
|
94
91
|
clock: o,
|
|
95
92
|
source: {
|
|
96
93
|
experiences: h,
|
|
@@ -103,22 +100,22 @@ function y(e, t) {
|
|
|
103
100
|
startRendererIndex: 0
|
|
104
101
|
}),
|
|
105
102
|
target: y
|
|
106
|
-
}),
|
|
103
|
+
}), f({
|
|
107
104
|
clock: y.doneData,
|
|
108
105
|
filter: (e) => e !== null,
|
|
109
106
|
fn: (e) => e.rendered.body,
|
|
110
107
|
target: s
|
|
111
|
-
}),
|
|
108
|
+
}), f({
|
|
112
109
|
clock: s,
|
|
113
110
|
target: o
|
|
114
|
-
}),
|
|
111
|
+
}), f({
|
|
115
112
|
clock: y.doneData,
|
|
116
113
|
filter: (e) => e === null,
|
|
117
114
|
target: m
|
|
118
|
-
}),
|
|
115
|
+
}), f({
|
|
119
116
|
clock: m,
|
|
120
117
|
target: o
|
|
121
|
-
}),
|
|
118
|
+
}), f({
|
|
122
119
|
clock: [
|
|
123
120
|
o,
|
|
124
121
|
m,
|
|
@@ -129,18 +126,18 @@ function y(e, t) {
|
|
|
129
126
|
state: g
|
|
130
127
|
},
|
|
131
128
|
filter: ({ experiences: e, state: t }) => t.currentExperienceIndex >= e.length,
|
|
132
|
-
target:
|
|
129
|
+
target: p
|
|
133
130
|
});
|
|
134
|
-
let b =
|
|
131
|
+
let b = c({
|
|
135
132
|
source: g,
|
|
136
133
|
effect: (e) => {
|
|
137
134
|
e.isComplete && r(e.renderedExperiences);
|
|
138
135
|
}
|
|
139
136
|
});
|
|
140
|
-
return
|
|
141
|
-
clock:
|
|
137
|
+
return f({
|
|
138
|
+
clock: p,
|
|
142
139
|
target: b
|
|
143
140
|
}), i(), n;
|
|
144
141
|
}
|
|
145
142
|
//#endregion
|
|
146
|
-
export { a as createExperienceInstance, n as evaluateConditionMemo, e as hashRule, r as isExperienceActive,
|
|
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 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require("./logger-CSTvAyyB.cjs");let e=require("effector");function t(e){let t=2166136261;for(let n of e)t^=n.codePointAt(0)??0,t=Math.imul(t,16777619);return t>>>0}function n(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 r(e,r){return n(t(`${e}:${r}`))%100}function i(e,t){return t<=0?!1:t>=100||e<t}function a(e,t){if(Array.isArray(t.conditions))for(let n of t.conditions)e.registerCondition(n)}function o(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 s(e,t){if(Array.isArray(t.fields))for(let n of t.fields)e.registerField(n)}function c(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 l(e,t){if(Array.isArray(t.experiences))for(let n of t.experiences)o(e,n)}function u(e,t,n){p(e,t,n.isPreview,n.sessionId),a(e,t),s(e,t),c(e,t),l(e,t)}function d(e){let t=e.searchParams[`preview-token`];if(t&&t.length>0)return t[0]}function f(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 p(e,t,n,r){let i=f(e);for(let a of t.features)i.has(a.id)||m(e,a,n,r)}function m(e,t,n,a){let o=r(a,t.id);e.registerFeature(t.id,{key:`v${t.version}`,name:t.name,enabled:t.enabled,weight:t.weight,storage:n?`session`:`local`,decide:()=>i(o,t.weight)})}function h(e,t){for(let n of t.content)e.registerContent({id:n.id,contentModelKey:n.contentModelKey,data:n.data})}function g(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&&h(e,n),n}finally{n.delete(r.id)}})();return n.set(r.id,o),o}}function _(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)}function v(){return{name:`dynamic-experiences`,setup:t=>({onStart:(0,e.attach)({source:t.session.store.map(e=>e.id),effect:async e=>{let n=d(t),r=n!==void 0,i=n===void 0?void 0:{previewToken:n},a=await t.getProjectConfig(n===void 0?void 0:{previewToken:n}).catch(e=>null);if(t.contentLoader=g(t,_(e=>t.getExperienceContent(e,i),a)),!a)return;let o=t.seededVersionId;if(o!==null&&o!==a.versionId){t.versionSkew={seeded:o,resolved:a.versionId},`${a.versionId}${o}`;return}t.previewEmbedderOrigins=a.previewEmbedderOrigins??null,u(t,a,{isPreview:r,sessionId:e})}})})}}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return v}});
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import "./logger-DMN6TxJJ.js";
|
|
2
|
+
import { attach as e } from "effector";
|
|
3
|
+
//#region src/plugins/dynamic-experiences/hash.ts
|
|
4
|
+
function t(e) {
|
|
5
|
+
let t = 2166136261;
|
|
6
|
+
for (let n of e) t ^= n.codePointAt(0) ?? 0, t = Math.imul(t, 16777619);
|
|
7
|
+
return t >>> 0;
|
|
8
|
+
}
|
|
9
|
+
function n(e) {
|
|
10
|
+
let t = e;
|
|
11
|
+
return t ^= t >>> 16, t = Math.imul(t, 2246822507), t ^= t >>> 13, t = Math.imul(t, 3266489909), t ^= t >>> 16, t >>> 0;
|
|
12
|
+
}
|
|
13
|
+
function r(e, r) {
|
|
14
|
+
return n(t(`${e}:${r}`)) % 100;
|
|
15
|
+
}
|
|
16
|
+
function i(e, t) {
|
|
17
|
+
return t <= 0 ? !1 : t >= 100 || e < t;
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/plugins/dynamic-experiences/plugin.ts
|
|
21
|
+
function a(e, t) {
|
|
22
|
+
if (Array.isArray(t.conditions)) for (let n of t.conditions) e.registerCondition(n);
|
|
23
|
+
}
|
|
24
|
+
function o(e, t) {
|
|
25
|
+
e.registerExperience({
|
|
26
|
+
id: t.id,
|
|
27
|
+
key: t.key,
|
|
28
|
+
name: t.name,
|
|
29
|
+
targets: t.targets,
|
|
30
|
+
nodes: t.nodes,
|
|
31
|
+
edges: t.edges,
|
|
32
|
+
condition: t.condition,
|
|
33
|
+
initializeOpen: t.initializeOpen,
|
|
34
|
+
componentName: t.componentName
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
function s(e, t) {
|
|
38
|
+
if (Array.isArray(t.fields)) for (let n of t.fields) e.registerField(n);
|
|
39
|
+
}
|
|
40
|
+
function c(e, t) {
|
|
41
|
+
if (!Array.isArray(t.steps)) return;
|
|
42
|
+
let n = new Map(t.fields.map((e) => [e.id, e.key]));
|
|
43
|
+
for (let r of t.steps) {
|
|
44
|
+
let t = [];
|
|
45
|
+
for (let e of r.fieldIds ?? []) {
|
|
46
|
+
let i = n.get(e);
|
|
47
|
+
if (i === void 0) {
|
|
48
|
+
`${r.key}${e}`;
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
t.push(i);
|
|
52
|
+
}
|
|
53
|
+
let i = r.layoutContentId ? e.contents.getById(r.layoutContentId) : null;
|
|
54
|
+
e.registerStep({
|
|
55
|
+
id: r.id,
|
|
56
|
+
key: r.key,
|
|
57
|
+
name: r.name,
|
|
58
|
+
fieldKeys: t,
|
|
59
|
+
layoutName: r.layoutName,
|
|
60
|
+
...r.layoutContentId !== void 0 && {
|
|
61
|
+
layoutContentId: r.layoutContentId,
|
|
62
|
+
layoutContentStore: i
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function l(e, t) {
|
|
68
|
+
if (Array.isArray(t.experiences)) for (let n of t.experiences) o(e, n);
|
|
69
|
+
}
|
|
70
|
+
function u(e, t, n) {
|
|
71
|
+
p(e, t, n.isPreview, n.sessionId), a(e, t), s(e, t), c(e, t), l(e, t);
|
|
72
|
+
}
|
|
73
|
+
function d(e) {
|
|
74
|
+
let t = e.searchParams["preview-token"];
|
|
75
|
+
if (t && t.length > 0) return t[0];
|
|
76
|
+
}
|
|
77
|
+
function f(e) {
|
|
78
|
+
let t = /* @__PURE__ */ new Set(), n = e.searchParams.feature;
|
|
79
|
+
if (!n) return t;
|
|
80
|
+
for (let e of n) {
|
|
81
|
+
let n = e.indexOf(":");
|
|
82
|
+
n > 0 && t.add(e.substring(0, n));
|
|
83
|
+
}
|
|
84
|
+
return t;
|
|
85
|
+
}
|
|
86
|
+
function p(e, t, n, r) {
|
|
87
|
+
let i = f(e);
|
|
88
|
+
for (let a of t.features) i.has(a.id) || m(e, a, n, r);
|
|
89
|
+
}
|
|
90
|
+
function m(e, t, n, a) {
|
|
91
|
+
let o = r(a, t.id);
|
|
92
|
+
e.registerFeature(t.id, {
|
|
93
|
+
key: `v${t.version}`,
|
|
94
|
+
name: t.name,
|
|
95
|
+
enabled: t.enabled,
|
|
96
|
+
weight: t.weight,
|
|
97
|
+
storage: n ? "session" : "local",
|
|
98
|
+
decide: () => i(o, t.weight)
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
function h(e, t) {
|
|
102
|
+
for (let n of t.content) e.registerContent({
|
|
103
|
+
id: n.id,
|
|
104
|
+
contentModelKey: n.contentModelKey,
|
|
105
|
+
data: n.data
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function g(e, t) {
|
|
109
|
+
let n = /* @__PURE__ */ new Map();
|
|
110
|
+
return (r, i) => {
|
|
111
|
+
let a = n.get(r.id);
|
|
112
|
+
if (a) return a;
|
|
113
|
+
let o = (async () => {
|
|
114
|
+
try {
|
|
115
|
+
let n = await t(r, i);
|
|
116
|
+
return n && h(e, n), n;
|
|
117
|
+
} finally {
|
|
118
|
+
n.delete(r.id);
|
|
119
|
+
}
|
|
120
|
+
})();
|
|
121
|
+
return n.set(r.id, o), o;
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
function _(e, t) {
|
|
125
|
+
let n = new Set(t && Array.isArray(t.experiences) ? t.experiences.map((e) => e.id) : []);
|
|
126
|
+
return (t, r) => n.has(t.id) ? e(t, r) : Promise.resolve(null);
|
|
127
|
+
}
|
|
128
|
+
function v() {
|
|
129
|
+
return {
|
|
130
|
+
name: "dynamic-experiences",
|
|
131
|
+
setup: (t) => ({ onStart: e({
|
|
132
|
+
source: t.session.store.map((e) => e.id),
|
|
133
|
+
effect: async (e) => {
|
|
134
|
+
let n = d(t), r = n !== void 0, i = n === void 0 ? void 0 : { previewToken: n }, a = await t.getProjectConfig(n === void 0 ? void 0 : { previewToken: n }).catch((e) => null);
|
|
135
|
+
if (t.contentLoader = g(t, _((e) => t.getExperienceContent(e, i), a)), !a) return;
|
|
136
|
+
let o = t.seededVersionId;
|
|
137
|
+
if (o !== null && o !== a.versionId) {
|
|
138
|
+
t.versionSkew = {
|
|
139
|
+
seeded: o,
|
|
140
|
+
resolved: a.versionId
|
|
141
|
+
}, `${a.versionId}${o}`;
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
t.previewEmbedderOrigins = a.previewEmbedderOrigins ?? null, u(t, a, {
|
|
145
|
+
isPreview: r,
|
|
146
|
+
sessionId: e
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
}) })
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
//#endregion
|
|
153
|
+
export { u as n, v as t };
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import "./logger-DMN6TxJJ.js";
|
|
2
|
+
//#region src/utils/client-headers.ts
|
|
3
|
+
var e = "Picked-Client", t = "Picked-Version";
|
|
4
|
+
function n(n, r) {
|
|
5
|
+
return {
|
|
6
|
+
[e]: n,
|
|
7
|
+
[t]: r
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region src/utils/version.ts
|
|
12
|
+
var r = () => "0.0.1-dev.1786065500148", i = "v1";
|
|
13
|
+
function a(e, t) {
|
|
14
|
+
return new URL(`/api/${i}/${t}`, e).toString();
|
|
15
|
+
}
|
|
16
|
+
function o(e) {
|
|
17
|
+
return {
|
|
18
|
+
...n("sdk", r()),
|
|
19
|
+
...e
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
async function s(e, t, n, r) {
|
|
23
|
+
let i = a(e, t);
|
|
24
|
+
return fetch(i, {
|
|
25
|
+
headers: o(n),
|
|
26
|
+
signal: r
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
async function c(e, t, n, r) {
|
|
30
|
+
let i = a(e, t);
|
|
31
|
+
return fetch(i, {
|
|
32
|
+
method: "POST",
|
|
33
|
+
headers: {
|
|
34
|
+
"Content-Type": "application/json",
|
|
35
|
+
...o(r)
|
|
36
|
+
},
|
|
37
|
+
body: JSON.stringify(n)
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function l(e) {
|
|
41
|
+
return typeof e == "object" && !!e;
|
|
42
|
+
}
|
|
43
|
+
function u(e) {
|
|
44
|
+
return l(e) && "features" in e && Array.isArray(e.features);
|
|
45
|
+
}
|
|
46
|
+
function d(e) {
|
|
47
|
+
return !l(e) || !("experienceId" in e) || !("content" in e) ? !1 : Array.isArray(e.content);
|
|
48
|
+
}
|
|
49
|
+
function f(e) {
|
|
50
|
+
try {
|
|
51
|
+
let t = new URL(e).hostname;
|
|
52
|
+
return t === "localhost" || t === "127.0.0.1" || t === "::1";
|
|
53
|
+
} catch {
|
|
54
|
+
return !1;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function p(e) {
|
|
58
|
+
if (!l(e) || !("cause" in e)) return !1;
|
|
59
|
+
let { cause: t } = e;
|
|
60
|
+
return !l(t) || !("code" in t) ? !1 : t.code === "ECONNREFUSED";
|
|
61
|
+
}
|
|
62
|
+
async function m(e, t, n) {
|
|
63
|
+
let r = n?.previewToken ? `projects/${t}?preview_token=${encodeURIComponent(n.previewToken)}` : `projects/${t}`, i;
|
|
64
|
+
try {
|
|
65
|
+
i = await s(e, r, n?.headers, n?.signal);
|
|
66
|
+
} catch (t) {
|
|
67
|
+
return f(e) && p(t), null;
|
|
68
|
+
}
|
|
69
|
+
if (!i.ok) return `${i.status.toString()}`, null;
|
|
70
|
+
let a;
|
|
71
|
+
try {
|
|
72
|
+
a = await i.json();
|
|
73
|
+
} catch {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
return u(a) ? a : null;
|
|
77
|
+
}
|
|
78
|
+
async function h(e, t, n, r) {
|
|
79
|
+
let i = r?.previewToken ? `projects/${t}/experiences/${n}/content?preview_token=${encodeURIComponent(r.previewToken)}` : `projects/${t}/experiences/${n}/content`, a;
|
|
80
|
+
try {
|
|
81
|
+
a = await s(e, i, r?.headers, r?.signal);
|
|
82
|
+
} catch (t) {
|
|
83
|
+
return f(e) && p(t) || `${n}`, null;
|
|
84
|
+
}
|
|
85
|
+
if (!a.ok) return `${n}${a.status.toString()}`, null;
|
|
86
|
+
let o;
|
|
87
|
+
try {
|
|
88
|
+
o = await a.json();
|
|
89
|
+
} catch {
|
|
90
|
+
return `${n}`, null;
|
|
91
|
+
}
|
|
92
|
+
return d(o) ? o : (`${n}`, null);
|
|
93
|
+
}
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/data-source/virtual-data.ts
|
|
96
|
+
function g(e) {
|
|
97
|
+
if (typeof e != "object" || !e || !("projectConfig" in e) || !("experienceContent" in e) || !("manifestMetadata" in e)) return !1;
|
|
98
|
+
let { experienceContent: t } = e;
|
|
99
|
+
return typeof t == "function";
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
//#region src/data-source/registry.ts
|
|
103
|
+
var _ = null;
|
|
104
|
+
function v(e) {
|
|
105
|
+
g(e) && (_ = e);
|
|
106
|
+
}
|
|
107
|
+
function y() {
|
|
108
|
+
return _;
|
|
109
|
+
}
|
|
110
|
+
//#endregion
|
|
111
|
+
export { m as a, n as c, h as i, v as n, c as o, g as r, r as s, y as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require("./logger-CSTvAyyB.cjs");var e=`Picked-Client`,t=`Picked-Version`;function n(n,r){return{[e]:n,[t]:r}}var r=()=>`0.0.1-dev.1786065500148`,i=`v1`;function a(e,t){return new URL(`/api/${i}/${t}`,e).toString()}function o(e){return{...n(`sdk`,r()),...e}}async function s(e,t,n,r){let i=a(e,t);return fetch(i,{headers:o(n),signal:r})}async function c(e,t,n,r){let i=a(e,t);return fetch(i,{method:`POST`,headers:{"Content-Type":`application/json`,...o(r)},body:JSON.stringify(n)})}function l(e){return typeof e==`object`&&!!e}function u(e){return l(e)&&`features`in e&&Array.isArray(e.features)}function d(e){return!l(e)||!(`experienceId`in e)||!(`content`in e)?!1:Array.isArray(e.content)}function f(e){try{let t=new URL(e).hostname;return t===`localhost`||t===`127.0.0.1`||t===`::1`}catch{return!1}}function p(e){if(!l(e)||!(`cause`in e))return!1;let{cause:t}=e;return!l(t)||!(`code`in t)?!1:t.code===`ECONNREFUSED`}async function m(e,t,n){let r=n?.previewToken?`projects/${t}?preview_token=${encodeURIComponent(n.previewToken)}`:`projects/${t}`,i;try{i=await s(e,r,n?.headers,n?.signal)}catch(t){return f(e)&&p(t),null}if(!i.ok)return`${i.status.toString()}`,null;let a;try{a=await i.json()}catch{return null}return u(a)?a:null}async function h(e,t,n,r){let i=r?.previewToken?`projects/${t}/experiences/${n}/content?preview_token=${encodeURIComponent(r.previewToken)}`:`projects/${t}/experiences/${n}/content`,a;try{a=await s(e,i,r?.headers,r?.signal)}catch(t){return f(e)&&p(t)||`${n}`,null}if(!a.ok)return`${n}${a.status.toString()}`,null;let o;try{o=await a.json()}catch{return`${n}`,null}return d(o)?o:(`${n}`,null)}function g(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`}var _=null;function v(e){g(e)&&(_=e)}function y(){return _}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return y}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/data-source/provider.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EACV,aAAa,EACb,yBAAyB,EACzB,sBAAsB,EACtB,aAAa,EACb,iBAAiB,EAClB,MAAM,sCAAsC,CAAA;AAG7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAEpD,uEAAuE;AACvE,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,KAAK,CAAA;AAQ7C,oDAAoD;AACpD,MAAM,WAAW,yBAAyB;IACxC,sFAAsF;IACtF,MAAM,EAAE,MAAM,CAAA;IACd,sCAAsC;IACtC,SAAS,EAAE,MAAM,CAAA;IACjB;;;OAGG;IACH,IAAI,CAAC,EAAE,cAAc,CAAA;IACrB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,iBAAiB,CAAA;IAC1B,sFAAsF;IACtF,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B,sFAAsF;IACtF,UAAU,CAAC,EAAE,aAAa,CAAA;IAC1B,sFAAsF;IACtF,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB;AAED,4DAA4D;AAC5D,MAAM,WAAW,sBAAsB;IACrC,yDAAyD;IACzD,IAAI,EAAE,cAAc,CAAA;IACpB,gFAAgF;IAChF,QAAQ,EAAE,sBAAsB,GAAG,IAAI,CAAA;CACxC;AAED,6EAA6E;AAC7E,MAAM,WAAW,kBAAkB;IACjC,wFAAwF;IACxF,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAA;IACrC,4FAA4F;IAC5F,gBAAgB,EAAE,MAAM,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAAA;IACrD,oGAAoG;IACpG,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/data-source/provider.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,E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AC/C;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAYlF;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAA;AA0B9B;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,kBAAkB,CAwK/F"}
|
package/dist/types/picked.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ import { type EventBusPayload, type EventHistoryStore } from './utils/events';
|
|
|
16
16
|
import type { Field } from './entities/field/field';
|
|
17
17
|
import type { ExperienceStep } from './entities/step/step';
|
|
18
18
|
import type { Content, ContentDataPatch } from './entities/content/content';
|
|
19
|
-
import type { ContentLoader } from './plugins/dynamic-experiences/types';
|
|
19
|
+
import type { ContentLoader, ExperienceContentResponse, ProjectConfig } from './plugins/dynamic-experiences/types';
|
|
20
20
|
import type { Action } from './entities/action/action';
|
|
21
21
|
import { type Condition } from './entities/condition/condition';
|
|
22
22
|
import type { SessionEntity } from './entities/session/session';
|
|
@@ -74,6 +74,7 @@ export declare class Picked {
|
|
|
74
74
|
*/
|
|
75
75
|
previewEmbedderOrigins: string[] | null;
|
|
76
76
|
private readonly plugins;
|
|
77
|
+
private readonly dataProviders;
|
|
77
78
|
readonly eventBus: EventCallable<EventBusPayload>;
|
|
78
79
|
readonly events: EventHistoryStore;
|
|
79
80
|
readonly projectId: string;
|
|
@@ -276,6 +277,54 @@ export declare class Picked {
|
|
|
276
277
|
context?: Record<string, unknown>;
|
|
277
278
|
}, string, Error>;
|
|
278
279
|
constructor(options: CreateClientOptions);
|
|
280
|
+
/**
|
|
281
|
+
* Resolves the data provider backing a given preview token, building it once per token.
|
|
282
|
+
*
|
|
283
|
+
* @param {string | undefined} previewToken - Preview token for the caller, when there is one.
|
|
284
|
+
* @returns {PickedDataProvider} The provider for that token.
|
|
285
|
+
* @example
|
|
286
|
+
* const provider = client.dataProviderFor(undefined)
|
|
287
|
+
*/
|
|
288
|
+
private dataProviderFor;
|
|
289
|
+
/**
|
|
290
|
+
* Resolves this project's configuration.
|
|
291
|
+
*
|
|
292
|
+
* Reads the build-time bundle when one registered itself, and the Picked API otherwise. A
|
|
293
|
+
* preview token forces the API, because preview renders unpublished data no bundle can hold.
|
|
294
|
+
* Deduplicated per token, so several callers in one request cost one resolution.
|
|
295
|
+
*
|
|
296
|
+
* @param {object} [options] - Per-call resolution inputs.
|
|
297
|
+
* @param {string} [options.previewToken] - Preview token, forcing a live read.
|
|
298
|
+
* @param {AbortSignal} [options.signal] - Signal applied to an API read.
|
|
299
|
+
* @returns {Promise<ProjectConfig>} The project configuration.
|
|
300
|
+
* @throws {Error} When the configuration cannot be resolved from any source.
|
|
301
|
+
* @example
|
|
302
|
+
* const config = await client.getProjectConfig()
|
|
303
|
+
*/
|
|
304
|
+
getProjectConfig(options?: {
|
|
305
|
+
previewToken?: string;
|
|
306
|
+
signal?: AbortSignal;
|
|
307
|
+
}): Promise<ProjectConfig>;
|
|
308
|
+
/**
|
|
309
|
+
* Resolves one experience's CMS content, from the same source as the configuration.
|
|
310
|
+
*
|
|
311
|
+
* @param {{ id: string; key: string }} experience - The experience to resolve content for.
|
|
312
|
+
* @param {string} experience.id - Experience id, which keys bundled content.
|
|
313
|
+
* @param {string} experience.key - Experience key, for a content loader that prefers it.
|
|
314
|
+
* @param {object} [options] - Per-call resolution inputs.
|
|
315
|
+
* @param {string} [options.previewToken] - Preview token, forcing a live read.
|
|
316
|
+
* @param {AbortSignal} [options.signal] - Deadline for this call's API read, if it makes one.
|
|
317
|
+
* @returns {Promise<ExperienceContentResponse | null>} The content, or `null` when it has none.
|
|
318
|
+
* @example
|
|
319
|
+
* const content = await client.getExperienceContent({ id: 'exp_1', key: 'promo' })
|
|
320
|
+
*/
|
|
321
|
+
getExperienceContent(experience: {
|
|
322
|
+
id: string;
|
|
323
|
+
key: string;
|
|
324
|
+
}, options?: {
|
|
325
|
+
previewToken?: string;
|
|
326
|
+
signal?: AbortSignal;
|
|
327
|
+
}): Promise<ExperienceContentResponse | null>;
|
|
279
328
|
/**
|
|
280
329
|
* Lazily starts the preview channel when this frame is a live-preview session: the outbound
|
|
281
330
|
* bridge, which reports the frame's URL to the dashboard, and the inbound receiver, which applies
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"picked.d.ts","sourceRoot":"","sources":["../../src/picked.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,OAAO,EAGL,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,KAAK,EACV,KAAK,aAAa,EACnB,MAAM,UAAU,CAAA;AACjB,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,uBAAuB,EAC7B,MAAM,kCAAkC,CAAA;AACzC,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,iBAAiB,EAAe,MAAM,0BAA0B,CAAA;AAC3F,OAAO,EAAE,KAAK,mBAAmB,EAAE,MAAM,UAAU,CAAA;AACnD,OAAO,EACL,KAAK,gBAAgB,EAGtB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAEL,KAAK,SAAS,EAEf,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAA4B,KAAK,aAAa,EAAE,MAAM,4BAA4B,CAAA;AACzF,OAAO,EAA6B,KAAK,uBAAuB,EAAE,MAAM,yBAAyB,CAAA;AACjG,OAAO,EAAE,KAAK,gBAAgB,EAA0B,MAAM,iCAAiC,CAAA;AAC/F,OAAO,EAAmB,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC5E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAA;AAE/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAIzD,OAAO,EAAsB,KAAK,eAAe,EAAE,KAAK,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AACjG,OAAO,KAAK,EAAE,KAAK,EAA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-experience content resolution). */
|
|
2
2
|
export { dynamicExperiencesPlugin, fetchExperienceContent, fetchProject } from './plugin';
|
|
3
3
|
export { createClientHeaders } from '../../utils/client-headers';
|
|
4
|
-
export {
|
|
5
|
-
export { registerPickedBundle, readRegisteredBundle } from '../../data-source/registry';
|
|
6
|
-
export type { PickedDataMode, PickedDataProvider, PickedDataProviderMeta, PickedDataProviderOptions, } from '../../data-source/provider';
|
|
4
|
+
export { registerPickedBundle } from '../../data-source/registry';
|
|
7
5
|
export type * from './types';
|
|
8
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dynamic-experiences/index.ts"],"names":[],"mappings":"AAAA,oHAAoH;AACpH,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACzF,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dynamic-experiences/index.ts"],"names":[],"mappings":"AAAA,oHAAoH;AACpH,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AACzF,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAIhE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA;AACjE,mBAAmB,SAAS,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Plugin } from '../../entities/plugin/plugin';
|
|
2
2
|
import type { Picked } from '../../picked';
|
|
3
|
-
import type {
|
|
3
|
+
import type { ProjectConfig } from './types';
|
|
4
4
|
export { fetchProject, fetchExperienceContent } from '../../data-source/api';
|
|
5
5
|
/**
|
|
6
6
|
* Synchronously registers a complete project config with the client: features, conditions,
|
|
@@ -25,13 +25,14 @@ export declare function registerProjectConfig(client: Picked, config: ProjectCon
|
|
|
25
25
|
sessionId: string;
|
|
26
26
|
}): void;
|
|
27
27
|
/**
|
|
28
|
-
* Plugin that
|
|
29
|
-
*
|
|
28
|
+
* Plugin that resolves project configuration through the client and registers features,
|
|
29
|
+
* steps, fields, and experiences with it.
|
|
30
30
|
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
31
|
+
* Resolution runs during the `onStart` hook, before experience initialisation, and reads
|
|
32
|
+
* whichever source the client resolves to — the build-time bundle when one registered itself,
|
|
33
|
+
* the Picked API otherwise. Search param feature overrides take precedence over resolved
|
|
34
|
+
* values.
|
|
33
35
|
*
|
|
34
|
-
* @param {DynamicExperiencesPluginOptions} [options] - Optional plugin configuration.
|
|
35
36
|
* @returns {Plugin} A configured Picked plugin.
|
|
36
37
|
* @example
|
|
37
38
|
* ```typescript
|
|
@@ -44,5 +45,5 @@ export declare function registerProjectConfig(client: Picked, config: ProjectCon
|
|
|
44
45
|
* })
|
|
45
46
|
* ```
|
|
46
47
|
*/
|
|
47
|
-
export declare function dynamicExperiencesPlugin(
|
|
48
|
+
export declare function dynamicExperiencesPlugin(): Plugin;
|
|
48
49
|
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dynamic-experiences/plugin.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dynamic-experiences/plugin.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAG1C,OAAO,KAAK,EAGV,aAAa,EAGd,MAAM,SAAS,CAAA;AAEhB,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAA;AAyI5E;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,aAAa,EACrB,OAAO,EAAE;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACjD,IAAI,CAMN;AAoMD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,CA4DjD"}
|
|
@@ -5,7 +5,6 @@ import type { ExperienceStep } from '../../entities/step/step';
|
|
|
5
5
|
import type { Field } from '../../entities/field/field';
|
|
6
6
|
import type { ExperienceEdge, ExperienceNode, ExperienceTarget } from '../../entities/experience/experience';
|
|
7
7
|
import type { Condition } from '../../entities/condition/condition';
|
|
8
|
-
import type { PickedDataProvider } from '../../data-source/provider';
|
|
9
8
|
import type { LogicRule, LogicValue } from '../../logic-engine';
|
|
10
9
|
/**
|
|
11
10
|
* Wire-format step as returned by the Picked API. Matches {@link ExperienceStep}
|
|
@@ -79,29 +78,6 @@ export interface ProjectConfig {
|
|
|
79
78
|
*/
|
|
80
79
|
previewEmbedderOrigins?: string[];
|
|
81
80
|
}
|
|
82
|
-
export interface DynamicExperiencesPluginOptions {
|
|
83
|
-
apiUrl?: string;
|
|
84
|
-
/**
|
|
85
|
-
* A pre-built data provider, used verbatim. Supply this to share one provider between the
|
|
86
|
-
* browser plugin and a server-side `serialize()` call, or to inject a stub in tests.
|
|
87
|
-
* Supersedes `projectConfig` and `getContent`.
|
|
88
|
-
*/
|
|
89
|
-
dataProvider?: PickedDataProvider;
|
|
90
|
-
projectConfig?: ProjectConfig;
|
|
91
|
-
/**
|
|
92
|
-
* Customer-supplied content fetcher. When provided, supersedes both the virtual
|
|
93
|
-
* data module and the runtime API for per-experience content resolution.
|
|
94
|
-
* Customers using this override are responsible for project ↔ content version
|
|
95
|
-
* consistency. Receives the resolved experience and the current preview token
|
|
96
|
-
* (when present) so the customer can decide preview semantics themselves.
|
|
97
|
-
*/
|
|
98
|
-
getContent?: (experience: {
|
|
99
|
-
id: string;
|
|
100
|
-
key: string;
|
|
101
|
-
}, options?: {
|
|
102
|
-
previewToken?: string;
|
|
103
|
-
}) => Promise<ExperienceContentResponse | null>;
|
|
104
|
-
}
|
|
105
81
|
export interface FetchProjectOptions {
|
|
106
82
|
previewToken?: string;
|
|
107
83
|
headers?: Record<string, string>;
|