@picked/client 0.0.1-dev.1787019239195 → 0.0.1-dev.1787537193674
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-4YpcWP-x.js +33 -0
- package/dist/api-DRTduQVm.cjs +1 -0
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/plugins/dynamic-experiences/index.js +1 -1
- package/dist/cjs/plugins/telemetry/index.js +1 -0
- package/dist/cjs/server/index.js +1 -1
- package/dist/docs/explanation/feature-flag-allocation.md +43 -1
- package/dist/docs/how-to/install-the-sdk.md +2 -2
- package/dist/docs/how-to/read-a-feature-flag.md +22 -10
- package/dist/docs/how-to/read-a-referenced-entry.md +4 -6
- package/dist/docs/how-to/render-a-step-form.md +3 -4
- package/dist/docs/how-to/switch-workspaces.md +1 -2
- package/dist/docs/reference/dashboard/features.mdx +45 -5
- package/dist/docs/reference/delivery-api/workspace-schema.md +12 -1
- package/dist/docs/reference/pickedql/dimensions.md +6 -0
- package/dist/docs/reference/pickedql/virtual-functions.md +16 -5
- package/dist/docs/reference/sdk/content.md +6 -9
- package/dist/docs/reference/sdk/features.md +17 -6
- package/dist/docs/reference/sdk/steps.md +3 -4
- package/dist/docs/reference/sdk/type-generation.md +18 -4
- package/dist/docs/reference/tools/cli.md +3 -5
- package/dist/docs/reference/tools/vite-plugin.md +1 -5
- package/dist/docs/tutorials/first-experience.mdx +4 -5
- package/dist/emit-D-tLiWL1.cjs +1 -0
- package/dist/emit-Ds2EG7CB.js +14 -0
- package/dist/esm/index.js +255 -232
- package/dist/esm/plugins/dynamic-experiences/index.js +2 -2
- package/dist/esm/plugins/telemetry/index.js +94 -0
- package/dist/esm/server/index.js +1 -1
- package/dist/plugin-BPZV7SJg.cjs +1 -0
- package/dist/{plugin-Bb2fJVFr.js → plugin-DTN7fsyp.js} +44 -29
- package/dist/{provider-DZEDUlIk.cjs → provider-BxhVIcsp.cjs} +1 -1
- package/dist/{provider-B8vTLrFT.js → provider-DLebj-AW.js} +1 -1
- package/dist/request-observer-BXDfOU0V.cjs +1 -0
- package/dist/request-observer-DtG0cRfz.js +19 -0
- package/dist/types/data-source/api.d.ts.map +1 -1
- package/dist/types/data-source/provider.d.ts +11 -1
- package/dist/types/data-source/provider.d.ts.map +1 -1
- package/dist/types/data-source/request-observer.d.ts +46 -0
- package/dist/types/data-source/request-observer.d.ts.map +1 -0
- package/dist/types/entities/feature/feature.d.ts +10 -3
- package/dist/types/entities/feature/feature.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lifecycle/lifecycle.d.ts.map +1 -1
- package/dist/types/picked.d.ts +12 -2
- package/dist/types/picked.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/hash.d.ts +53 -1
- package/dist/types/plugins/dynamic-experiences/hash.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 +1 -1
- package/dist/types/plugins/dynamic-experiences/plugin.d.ts.map +1 -1
- package/dist/types/plugins/dynamic-experiences/types.d.ts +3 -4
- package/dist/types/plugins/dynamic-experiences/types.d.ts.map +1 -1
- package/dist/types/plugins/telemetry/emit.d.ts +18 -0
- package/dist/types/plugins/telemetry/emit.d.ts.map +1 -0
- package/dist/types/plugins/telemetry/index.d.ts +4 -0
- package/dist/types/plugins/telemetry/index.d.ts.map +1 -0
- package/dist/types/plugins/telemetry/plugin-summary.d.ts +10 -0
- package/dist/types/plugins/telemetry/plugin-summary.d.ts.map +1 -0
- package/dist/types/plugins/telemetry/plugin.d.ts +29 -0
- package/dist/types/plugins/telemetry/plugin.d.ts.map +1 -0
- package/dist/types/schema-registry.d.ts +16 -0
- package/dist/types/schema-registry.d.ts.map +1 -1
- package/dist/types/utils/user-timing.d.ts +18 -0
- package/dist/types/utils/user-timing.d.ts.map +1 -0
- package/dist/version-BlahSDlG.cjs +1 -0
- package/dist/{version-DjCWhJD5.js → version-BmBn0dXR.js} +1 -1
- package/package.json +16 -4
- package/dist/api-TWnRLh3X.cjs +0 -1
- package/dist/api-uttjU_Tg.js +0 -22
- package/dist/plugin-hFQIiHOB.cjs +0 -1
- package/dist/version-CfTz7TK0.cjs +0 -1
|
@@ -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-DTN7fsyp.js";
|
|
2
|
+
import { n as t, t as n } from "../../../api-4YpcWP-x.js";
|
|
3
3
|
import { n as r } from "../../../registry-CXZv0uLg.js";
|
|
4
4
|
import { createClientHeaders as i, fetchSchema as a } from "@picked/delivery-api-client";
|
|
5
5
|
export { i as createClientHeaders, e as dynamicExperiencesPlugin, n as fetchExperienceContent, t as fetchProject, a as fetchSchema, r as registerPickedBundle };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { f as e, p as t } from "../../../supports-CO9bJGNl.js";
|
|
2
|
+
import { n } from "../../../request-observer-DtG0cRfz.js";
|
|
3
|
+
import { createSpanId as r, createTraceId as i, formatTraceparent as a, toUnixNano as o } from "@picked/telemetry";
|
|
4
|
+
//#region src/plugins/telemetry/plugin-summary.ts
|
|
5
|
+
var s = 100;
|
|
6
|
+
function c(e) {
|
|
7
|
+
return [...e].sort((e, t) => e.localeCompare(t)).slice(0, s);
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/plugins/telemetry/plugin.ts
|
|
11
|
+
var l = "telemetry", u = "https://production.otel.picked.app/v1/traces", d = "picked:start";
|
|
12
|
+
function f() {
|
|
13
|
+
try {
|
|
14
|
+
let e = t.navigator;
|
|
15
|
+
return "globalPrivacyControl" in e && e.globalPrivacyControl === !0 || e.doNotTrack === "1";
|
|
16
|
+
} catch {
|
|
17
|
+
return !1;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function p() {
|
|
21
|
+
try {
|
|
22
|
+
return performance.getEntriesByName(d, "measure").at(-1);
|
|
23
|
+
} catch {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function m() {
|
|
28
|
+
return performance.timeOrigin + performance.now();
|
|
29
|
+
}
|
|
30
|
+
function h(t) {
|
|
31
|
+
return {
|
|
32
|
+
name: l,
|
|
33
|
+
setup: (s) => {
|
|
34
|
+
if (!e() || f() || !(Math.random() < (t?.sampleRate ?? 1))) return;
|
|
35
|
+
let c = t?.endpoint ?? u, l = i(), d = r(), h = [];
|
|
36
|
+
n({ onRequest: (e) => {
|
|
37
|
+
let t = r(), n = m();
|
|
38
|
+
return {
|
|
39
|
+
headers: { traceparent: a(l, t, !0) },
|
|
40
|
+
onSettled: (r) => {
|
|
41
|
+
h.push({
|
|
42
|
+
name: `picked.delivery.${e}`,
|
|
43
|
+
traceId: l,
|
|
44
|
+
spanId: t,
|
|
45
|
+
parentSpanId: d,
|
|
46
|
+
startTimeUnixNano: o(n),
|
|
47
|
+
endTimeUnixNano: o(m()),
|
|
48
|
+
attributes: { "picked.endpoint": e },
|
|
49
|
+
status: r ? "ok" : "error"
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
} }), s.eventBus.watch((e) => {
|
|
54
|
+
if (e.type !== "ready") return;
|
|
55
|
+
let t = p();
|
|
56
|
+
if (t) {
|
|
57
|
+
let e = performance.timeOrigin + t.startTime;
|
|
58
|
+
h.push({
|
|
59
|
+
name: "picked.start",
|
|
60
|
+
traceId: l,
|
|
61
|
+
spanId: d,
|
|
62
|
+
startTimeUnixNano: o(e),
|
|
63
|
+
endTimeUnixNano: o(e + t.duration),
|
|
64
|
+
attributes: _(s),
|
|
65
|
+
status: "ok"
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
v(c, g(s), h);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function g(e) {
|
|
74
|
+
return {
|
|
75
|
+
"service.name": "picked-sdk",
|
|
76
|
+
"picked.project_id": e.projectId
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function _(e) {
|
|
80
|
+
return {
|
|
81
|
+
"picked.data.mode": e.dataSource ? "bundle" : "api",
|
|
82
|
+
"picked.sdk.plugins": c(e.pluginNames).join(",")
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
async function v(e, t, n) {
|
|
86
|
+
if (n.length === 0) return;
|
|
87
|
+
let r = n.splice(0, n.length);
|
|
88
|
+
try {
|
|
89
|
+
let { flushSpans: n } = await import("../../../emit-Ds2EG7CB.js");
|
|
90
|
+
await n(e, t, r);
|
|
91
|
+
} catch {}
|
|
92
|
+
}
|
|
93
|
+
//#endregion
|
|
94
|
+
export { l as TELEMETRY_PLUGIN_NAME, h as telemetryPlugin };
|
package/dist/esm/server/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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 { n as s } from "../../plugin-
|
|
2
|
+
import { n as s } from "../../plugin-DTN7fsyp.js";
|
|
3
3
|
import { attach as c, createEffect as l, createEvent as u, createStore as d, sample as f } from "effector";
|
|
4
4
|
//#region src/server/serialize.ts
|
|
5
5
|
var p = 1e4;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require("./logger-CSTvAyyB.cjs"),require("./api-DRTduQVm.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}var a=4294967296;function o(e,r,i){return(n(t(`${e}:${r}:${i}`))+.5)/a}function s(e,t,n){return n.weight<=0?0:n.weight/-Math.log(o(e,t,n.key))}function c(e,t,n){let r=null,i=0;for(let a of n){let n=s(e,t,a);n<=0||(n>i||n===i&&r!==null&&a.key<r.key)&&(i=n,r=a)}return r}function l(e,t){if(Array.isArray(t.conditions))for(let n of t.conditions)e.registerCondition(n)}function u(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 d(e){return typeof e!=`object`||!e?!1:`id`in e&&`key`in e&&`type`in e&&`name`in e}function f(e,t){if(Array.isArray(t.fields))for(let n of t.fields)d(n)&&e.registerField(n)}function p(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 m(e,t){if(Array.isArray(t.experiences))for(let n of t.experiences)u(e,n)}function h(e,t,n){v(e,t,n.isPreview,n.sessionId),l(e,t),f(e,t),p(e,t),m(e,t)}function g(e){let t=e.searchParams[`preview-token`];if(t&&t.length>0)return t[0]}function _(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 v(e,t,n,r){let i=_(e);for(let a of t.features)i.has(a.id)||y(e,a,n,r)}function y(e,t,n,a){let o=t.id,s=t.variants;e.registerFeature(o,{key:`v${t.version}`,name:t.name,enabled:t.enabled,weight:t.weight,storage:n?`session`:`local`,decide:()=>t.valueType===`text`?!s||s.length===0?(`${o}`,!1):c(a,o,s)?.value??!1:i(r(a,o),t.weight)})}function b(e,t){for(let n of[...t.references??[],...t.content])e.registerContent({id:n.id,contentModelKey:n.contentModelKey,data:n.data})}function x(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&&b(e,n),n}finally{n.delete(r.id)}})();return n.set(r.id,o),o}}function S(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 C(){return{name:`dynamic-experiences`,setup:t=>({onStart:(0,e.attach)({source:t.session.store.map(e=>e.id),effect:async e=>{let n=g(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=x(t,S(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,h(t,a,{isPreview:r,sessionId:e})}})})}}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return C}});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "./logger-DMN6TxJJ.js";
|
|
2
|
-
import "./api-
|
|
2
|
+
import "./api-4YpcWP-x.js";
|
|
3
3
|
import { attach as e } from "effector";
|
|
4
4
|
//#region src/plugins/dynamic-experiences/hash.ts
|
|
5
5
|
function t(e) {
|
|
@@ -17,12 +17,27 @@ function r(e, r) {
|
|
|
17
17
|
function i(e, t) {
|
|
18
18
|
return t <= 0 ? !1 : t >= 100 || e < t;
|
|
19
19
|
}
|
|
20
|
+
var a = 4294967296;
|
|
21
|
+
function o(e, r, i) {
|
|
22
|
+
return (n(t(`${e}:${r}:${i}`)) + .5) / a;
|
|
23
|
+
}
|
|
24
|
+
function s(e, t, n) {
|
|
25
|
+
return n.weight <= 0 ? 0 : n.weight / -Math.log(o(e, t, n.key));
|
|
26
|
+
}
|
|
27
|
+
function c(e, t, n) {
|
|
28
|
+
let r = null, i = 0;
|
|
29
|
+
for (let a of n) {
|
|
30
|
+
let n = s(e, t, a);
|
|
31
|
+
n <= 0 || (n > i || n === i && r !== null && a.key < r.key) && (i = n, r = a);
|
|
32
|
+
}
|
|
33
|
+
return r;
|
|
34
|
+
}
|
|
20
35
|
//#endregion
|
|
21
36
|
//#region src/plugins/dynamic-experiences/plugin.ts
|
|
22
|
-
function
|
|
37
|
+
function l(e, t) {
|
|
23
38
|
if (Array.isArray(t.conditions)) for (let n of t.conditions) e.registerCondition(n);
|
|
24
39
|
}
|
|
25
|
-
function
|
|
40
|
+
function u(e, t) {
|
|
26
41
|
e.registerExperience({
|
|
27
42
|
id: t.id,
|
|
28
43
|
key: t.key,
|
|
@@ -35,13 +50,13 @@ function o(e, t) {
|
|
|
35
50
|
componentName: t.componentName
|
|
36
51
|
});
|
|
37
52
|
}
|
|
38
|
-
function
|
|
53
|
+
function d(e) {
|
|
39
54
|
return typeof e != "object" || !e ? !1 : "id" in e && "key" in e && "type" in e && "name" in e;
|
|
40
55
|
}
|
|
41
|
-
function
|
|
42
|
-
if (Array.isArray(t.fields)) for (let n of t.fields)
|
|
56
|
+
function f(e, t) {
|
|
57
|
+
if (Array.isArray(t.fields)) for (let n of t.fields) d(n) && e.registerField(n);
|
|
43
58
|
}
|
|
44
|
-
function
|
|
59
|
+
function p(e, t) {
|
|
45
60
|
if (!Array.isArray(t.steps)) return;
|
|
46
61
|
let n = new Map(t.fields.map((e) => [e.id, e.key]));
|
|
47
62
|
for (let r of t.steps) {
|
|
@@ -68,17 +83,17 @@ function l(e, t) {
|
|
|
68
83
|
});
|
|
69
84
|
}
|
|
70
85
|
}
|
|
71
|
-
function
|
|
72
|
-
if (Array.isArray(t.experiences)) for (let n of t.experiences)
|
|
86
|
+
function m(e, t) {
|
|
87
|
+
if (Array.isArray(t.experiences)) for (let n of t.experiences) u(e, n);
|
|
73
88
|
}
|
|
74
|
-
function
|
|
75
|
-
|
|
89
|
+
function h(e, t, n) {
|
|
90
|
+
v(e, t, n.isPreview, n.sessionId), l(e, t), f(e, t), p(e, t), m(e, t);
|
|
76
91
|
}
|
|
77
|
-
function
|
|
92
|
+
function g(e) {
|
|
78
93
|
let t = e.searchParams["preview-token"];
|
|
79
94
|
if (t && t.length > 0) return t[0];
|
|
80
95
|
}
|
|
81
|
-
function
|
|
96
|
+
function _(e) {
|
|
82
97
|
let t = /* @__PURE__ */ new Set(), n = e.searchParams.feature;
|
|
83
98
|
if (!n) return t;
|
|
84
99
|
for (let e of n) {
|
|
@@ -87,29 +102,29 @@ function p(e) {
|
|
|
87
102
|
}
|
|
88
103
|
return t;
|
|
89
104
|
}
|
|
90
|
-
function
|
|
91
|
-
let i =
|
|
92
|
-
for (let a of t.features) i.has(a.id) ||
|
|
105
|
+
function v(e, t, n, r) {
|
|
106
|
+
let i = _(e);
|
|
107
|
+
for (let a of t.features) i.has(a.id) || y(e, a, n, r);
|
|
93
108
|
}
|
|
94
|
-
function
|
|
95
|
-
let o =
|
|
96
|
-
e.registerFeature(
|
|
109
|
+
function y(e, t, n, a) {
|
|
110
|
+
let o = t.id, s = t.variants;
|
|
111
|
+
e.registerFeature(o, {
|
|
97
112
|
key: `v${t.version}`,
|
|
98
113
|
name: t.name,
|
|
99
114
|
enabled: t.enabled,
|
|
100
115
|
weight: t.weight,
|
|
101
116
|
storage: n ? "session" : "local",
|
|
102
|
-
decide: () => i(o, t.weight)
|
|
117
|
+
decide: () => t.valueType === "text" ? !s || s.length === 0 ? (`${o}`, !1) : c(a, o, s)?.value ?? !1 : i(r(a, o), t.weight)
|
|
103
118
|
});
|
|
104
119
|
}
|
|
105
|
-
function
|
|
120
|
+
function b(e, t) {
|
|
106
121
|
for (let n of [...t.references ?? [], ...t.content]) e.registerContent({
|
|
107
122
|
id: n.id,
|
|
108
123
|
contentModelKey: n.contentModelKey,
|
|
109
124
|
data: n.data
|
|
110
125
|
});
|
|
111
126
|
}
|
|
112
|
-
function
|
|
127
|
+
function x(e, t) {
|
|
113
128
|
let n = /* @__PURE__ */ new Map();
|
|
114
129
|
return (r, i) => {
|
|
115
130
|
let a = n.get(r.id);
|
|
@@ -117,7 +132,7 @@ function _(e, t) {
|
|
|
117
132
|
let o = (async () => {
|
|
118
133
|
try {
|
|
119
134
|
let n = await t(r, i);
|
|
120
|
-
return n &&
|
|
135
|
+
return n && b(e, n), n;
|
|
121
136
|
} finally {
|
|
122
137
|
n.delete(r.id);
|
|
123
138
|
}
|
|
@@ -125,18 +140,18 @@ function _(e, t) {
|
|
|
125
140
|
return n.set(r.id, o), o;
|
|
126
141
|
};
|
|
127
142
|
}
|
|
128
|
-
function
|
|
143
|
+
function S(e, t) {
|
|
129
144
|
let n = new Set(t && Array.isArray(t.experiences) ? t.experiences.map((e) => e.id) : []);
|
|
130
145
|
return (t, r) => n.has(t.id) ? e(t, r) : Promise.resolve(null);
|
|
131
146
|
}
|
|
132
|
-
function
|
|
147
|
+
function C() {
|
|
133
148
|
return {
|
|
134
149
|
name: "dynamic-experiences",
|
|
135
150
|
setup: (t) => ({ onStart: e({
|
|
136
151
|
source: t.session.store.map((e) => e.id),
|
|
137
152
|
effect: async (e) => {
|
|
138
|
-
let n =
|
|
139
|
-
if (t.contentLoader =
|
|
153
|
+
let n = g(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);
|
|
154
|
+
if (t.contentLoader = x(t, S((e) => t.getExperienceContent(e, i), a)), !a) return;
|
|
140
155
|
let o = t.seededVersionId;
|
|
141
156
|
if (o !== null && o !== a.versionId) {
|
|
142
157
|
t.versionSkew = {
|
|
@@ -145,7 +160,7 @@ function y() {
|
|
|
145
160
|
}, `${a.versionId}${o}`;
|
|
146
161
|
return;
|
|
147
162
|
}
|
|
148
|
-
t.previewEmbedderOrigins = a.previewEmbedderOrigins ?? null,
|
|
163
|
+
t.previewEmbedderOrigins = a.previewEmbedderOrigins ?? null, h(t, a, {
|
|
149
164
|
isPreview: r,
|
|
150
165
|
sessionId: e
|
|
151
166
|
});
|
|
@@ -154,4 +169,4 @@ function y() {
|
|
|
154
169
|
};
|
|
155
170
|
}
|
|
156
171
|
//#endregion
|
|
157
|
-
export {
|
|
172
|
+
export { h as n, C as t };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require("./logger-CSTvAyyB.cjs");const e=require("./api-
|
|
1
|
+
require("./logger-CSTvAyyB.cjs");const e=require("./api-DRTduQVm.cjs"),t=require("./registry-C1t8l3t9.cjs");var n=`bundle`,r=`api`;async function i(){try{let e=await import(`virtual:picked/data`);return t.r(e)?e:null}catch{return null}}function a(e){if(e===void 0||t.r(e))return e}function o(o){let{apiUrl:s,projectId:c,previewToken:l,signal:u}=o,d=!!l,f=d?r:o.mode,p=a(d?void 0:o.bundle),m=d?void 0:o.projectConfig,h=o.getContent,g={mode:f??r,manifest:null},_,v,y=new Map;function b(){if(f===r)return Promise.resolve(null);if(p)return Promise.resolve(p);let e=t.t();return e?Promise.resolve(e):(_??=i(),_)}function x(e){g.mode=e?n:r,g.manifest=e?e.manifestMetadata:null}async function S(){if(m)return x(await b()),m;let t=await b();return x(t),t?t.projectConfig:f===n?null:e.n(s,c,{...l!==void 0&&{previewToken:l},...u!==void 0&&{signal:u}})}async function C(t,r){let i=l===void 0?void 0:{previewToken:l};if(h)return h(t,i);let a=await b();if(x(a),a)try{return await a.experienceContent(t,i)}catch{return`${t.id}`,null}if(f===n)return null;let o=r??u;return e.t(s,c,t.id,{...l!==void 0&&{previewToken:l},...o!==void 0&&{signal:o}})}return{meta:g,getProjectConfig:()=>(v??=S(),v),getContent:(e,t)=>{let n=y.get(e.id);if(n)return n;let r=C(e,t?.signal).finally(()=>{y.delete(e.id)});return y.set(e.id,r),r}}}exports.createPickedDataProvider=o;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=null;function t(t){e=t}function n(t){try{return e?.onRequest(t)??{}}catch{return{}}}function r(e,t){try{e.onSettled?.(t)}catch{}}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return n}});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/data-source/request-observer.ts
|
|
2
|
+
var e = null;
|
|
3
|
+
function t(t) {
|
|
4
|
+
e = t;
|
|
5
|
+
}
|
|
6
|
+
function n(t) {
|
|
7
|
+
try {
|
|
8
|
+
return e?.onRequest(t) ?? {};
|
|
9
|
+
} catch {
|
|
10
|
+
return {};
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function r(e, t) {
|
|
14
|
+
try {
|
|
15
|
+
e.onSettled?.(t);
|
|
16
|
+
} catch {}
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { t as n, r, n as t };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/data-source/api.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EACV,yBAAyB,EACzB,mBAAmB,EACnB,aAAa,EACd,MAAM,6BAA6B,CAAA;
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/data-source/api.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EACV,yBAAyB,EACzB,mBAAmB,EACnB,aAAa,EACd,MAAM,6BAA6B,CAAA;AA0FpC;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,aAAa,CAEpE;AAED;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,IAAI,yBAAyB,CAM5F;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CAI/B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE,mBAAmB,GAC5B,OAAO,CAAC,yBAAyB,GAAG,IAAI,CAAC,CAI3C"}
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @file The shared Picked data provider.
|
|
3
|
+
*
|
|
4
|
+
* One object answers "where does this session's project config and CMS content come from". A
|
|
5
|
+
* client builds one per preview token and reaches it through `getProjectConfig` and
|
|
6
|
+
* `getExperienceContent`; nothing outside the SDK constructs one. The mode is decided once, at
|
|
7
|
+
* construction, and the provider stays atomic: config and content come from the source the mode
|
|
8
|
+
* names.
|
|
9
|
+
*/
|
|
10
|
+
import type { ExperienceContentResponse, ProjectConfig } from '@picked/delivery-api-client';
|
|
11
|
+
import type { ContentLoader, PickedManifestMetadata, VirtualPickedData } from '../plugins/dynamic-experiences/types';
|
|
2
12
|
import { isVirtualPickedData } from './virtual-data';
|
|
3
13
|
/** Where a data provider reads project config and CMS content from. */
|
|
4
14
|
export type PickedDataMode = 'bundle' | 'api';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/data-source/provider.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/data-source/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAE3F,OAAO,KAAK,EACV,aAAa,EACb,sBAAsB,EACtB,iBAAiB,EAClB,MAAM,sCAAsC,CAAA;AAG7C,OAAO,EAAE,mBAAmB,E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AAO,EAAE,mBAAmB,EAAE,CAAA;AAyB9B;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,yBAAyB,GAAG,kBAAkB,CAuK/F"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file The hook the telemetry plugin uses to observe delivery API requests.
|
|
3
|
+
*
|
|
4
|
+
* The observer hands back a per-request handle, so each completion correlates
|
|
5
|
+
* to its own request through the closure that created it.
|
|
6
|
+
*/
|
|
7
|
+
/** Which delivery endpoint a request is for. */
|
|
8
|
+
export type DeliveryEndpoint = 'project-config' | 'experience-content';
|
|
9
|
+
/** A request in flight, from the observer's point of view. */
|
|
10
|
+
export interface ObservedRequest {
|
|
11
|
+
/** Headers to merge into this request, such as `traceparent`. */
|
|
12
|
+
headers?: Record<string, string>;
|
|
13
|
+
/** Called once the request has settled. */
|
|
14
|
+
onSettled?: (ok: boolean) => void;
|
|
15
|
+
}
|
|
16
|
+
/** Receives delivery requests as they are made. */
|
|
17
|
+
export interface DeliveryRequestObserver {
|
|
18
|
+
/** Called as a request begins; returns headers to add and a completion callback. */
|
|
19
|
+
onRequest: (endpoint: DeliveryEndpoint) => ObservedRequest;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Registers the observer, or clears it when passed `null`.
|
|
23
|
+
*
|
|
24
|
+
* @param {DeliveryRequestObserver | null} next - The observer to install, or `null` to remove it.
|
|
25
|
+
* @returns {void}
|
|
26
|
+
* @example setDeliveryRequestObserver({ onRequest: () => ({ headers: { traceparent } }) })
|
|
27
|
+
*/
|
|
28
|
+
export declare function setDeliveryRequestObserver(next: DeliveryRequestObserver | null): void;
|
|
29
|
+
/**
|
|
30
|
+
* Notifies the observer that a request is starting.
|
|
31
|
+
*
|
|
32
|
+
* @param {DeliveryEndpoint} endpoint - Which endpoint is being called.
|
|
33
|
+
* @returns {ObservedRequest} Headers to merge and a completion callback, both possibly absent.
|
|
34
|
+
* @example const observed = beginObservedRequest('project-config')
|
|
35
|
+
*/
|
|
36
|
+
export declare function beginObservedRequest(endpoint: DeliveryEndpoint): ObservedRequest;
|
|
37
|
+
/**
|
|
38
|
+
* Notifies the observer that a request has settled.
|
|
39
|
+
*
|
|
40
|
+
* @param {ObservedRequest} observed - The handle returned when the request began.
|
|
41
|
+
* @param {boolean} ok - Whether the request produced a usable result.
|
|
42
|
+
* @returns {void}
|
|
43
|
+
* @example settleObservedRequest(observed, true)
|
|
44
|
+
*/
|
|
45
|
+
export declare function settleObservedRequest(observed: ObservedRequest, ok: boolean): void;
|
|
46
|
+
//# sourceMappingURL=request-observer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-observer.d.ts","sourceRoot":"","sources":["../../../src/data-source/request-observer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,gDAAgD;AAChD,MAAM,MAAM,gBAAgB,GAAG,gBAAgB,GAAG,oBAAoB,CAAA;AAEtE,8DAA8D;AAC9D,MAAM,WAAW,eAAe;IAC9B,iEAAiE;IACjE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,2CAA2C;IAC3C,SAAS,CAAC,EAAE,CAAC,EAAE,EAAE,OAAO,KAAK,IAAI,CAAA;CAClC;AAED,mDAAmD;AACnD,MAAM,WAAW,uBAAuB;IACtC,oFAAoF;IACpF,SAAS,EAAE,CAAC,QAAQ,EAAE,gBAAgB,KAAK,eAAe,CAAA;CAC3D;AAID;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE,uBAAuB,GAAG,IAAI,GAAG,IAAI,CAErF;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,eAAe,CAOhF;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,eAAe,EAAE,EAAE,EAAE,OAAO,GAAG,IAAI,CAMlF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/** @file Feature entity — Effector stores and registry for A/B test features with persistent bucketing. */
|
|
2
2
|
import { type EventCallable, type Store } from 'effector';
|
|
3
3
|
import type { Picked } from '../../picked';
|
|
4
|
+
import type { FeatureValueFor } from '../../schema-registry';
|
|
4
5
|
export interface Feature {
|
|
5
6
|
key: string;
|
|
6
7
|
name: string;
|
|
@@ -48,9 +49,15 @@ export interface ResolvedFeatureBucket extends FeatureBaseBucket {
|
|
|
48
49
|
};
|
|
49
50
|
}
|
|
50
51
|
export type FeatureBucket = UnresolvedFeatureBucket | ResolvedFeatureBucket;
|
|
51
|
-
|
|
52
|
+
/**
|
|
53
|
+
* A feature's resolved bucket. `TValue` narrows to a text feature's declared arms when
|
|
54
|
+
* the schema registry is augmented, and stays `string | boolean` otherwise.
|
|
55
|
+
*
|
|
56
|
+
* @param {string | boolean} TValue - The value the feature resolves to.
|
|
57
|
+
*/
|
|
58
|
+
export interface FeatureResult<TValue extends string | boolean = string | boolean> {
|
|
52
59
|
id: string;
|
|
53
|
-
bucket:
|
|
60
|
+
bucket: TValue;
|
|
54
61
|
}
|
|
55
62
|
/** The bucket an evokable feature answers with, or undefined while its feature is unregistered. */
|
|
56
63
|
export type FeatureBucketValue = boolean | string | undefined;
|
|
@@ -81,7 +88,7 @@ declare const createFeatureIndexFactory: ({ client }: {
|
|
|
81
88
|
getByName: (name: string) => Store<FeatureIndexItem | undefined>;
|
|
82
89
|
listStore: Store<FeatureBucket[]>;
|
|
83
90
|
getEvokableFeature: (featureName: string) => Store<() => Promise<FeatureBucketValue>>;
|
|
84
|
-
getFeatureResult: (featureName:
|
|
91
|
+
getFeatureResult: <K extends string>(featureName: K) => Store<FeatureResult<FeatureValueFor<K>> | undefined>;
|
|
85
92
|
};
|
|
86
93
|
/**
|
|
87
94
|
* Creates a feature index with lifecycle stores and registration logic.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature.d.ts","sourceRoot":"","sources":["../../../../src/entities/feature/feature.ts"],"names":[],"mappings":"AAAA,2GAA2G;AAC3G,OAAO,EAQL,KAAK,aAAa,EAElB,KAAK,KAAK,EACX,MAAM,UAAU,CAAA;AAEjB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"feature.d.ts","sourceRoot":"","sources":["../../../../src/entities/feature/feature.ts"],"names":[],"mappings":"AAAA,2GAA2G;AAC3G,OAAO,EAQL,KAAK,aAAa,EAElB,KAAK,KAAK,EACX,MAAM,UAAU,CAAA;AAEjB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAI5D,MAAM,WAAW,OAAO;IACtB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IACnE,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;IAC7B,oGAAoG;IACpG,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,wHAAwH;IACxH,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAA;AAExE,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,OAAO,GAAG;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAA;CAClC;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,OAAO,GAAG,MAAM,CAAA;IACxB,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAC9B;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAA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,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;CAqBvD,CAAA;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC,CAAC,CAAC,EAC1F,MAAM,EAAE,CAAC,GACR,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAE9C;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,YAAY,SAAU,MAAM,WAAW,OAAO,YAAY,aAAa,SAEnF,CAAA"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -21,6 +21,6 @@ export type * from './utils/events';
|
|
|
21
21
|
export type * from './utils/search-params';
|
|
22
22
|
export type * from './entities/response/response';
|
|
23
23
|
export { Picked } from './picked';
|
|
24
|
-
export type { ActionKeys, ContentForStep, ExperienceKeys, FeatureKeys, FieldKeys, FieldKeysForStep, FieldValueFor, KnownActionKeys, KnownExperienceKeys, KnownFeatureKeys, KnownFieldKeys, KnownStepKeys, PickedSchemaRegistry, ReferencedContent, StepContentModelsMap, StepKeys, StepLayoutContent, TypedContent, } from './schema-registry';
|
|
24
|
+
export type { ActionKeys, ContentForStep, ExperienceKeys, FeatureKeys, FeatureValueFor, FieldKeys, FieldKeysForStep, FieldValueFor, KnownActionKeys, KnownExperienceKeys, KnownFeatureKeys, KnownFieldKeys, KnownStepKeys, PickedSchemaRegistry, ReferencedContent, StepContentModelsMap, StepKeys, StepLayoutContent, TypedContent, } from './schema-registry';
|
|
25
25
|
export { toTypedContentStore } from './typed-content';
|
|
26
26
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G,cAAc,WAAW,CAAA;AACzB,mBAAmB,UAAU,CAAA;AAC7B,mBAAmB,0BAA0B,CAAA;AAC7C,mBAAmB,gCAA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kCAAkC,CAAA;AACrD,mBAAmB,sBAAsB,CAAA;AACzC,mBAAmB,4BAA4B,CAAA;AAC/C,mBAAmB,wBAAwB,CAAA;AAC3C,mBAAmB,gCAAgC,CAAA;AACnD,mBAAmB,4BAA4B,CAAA;AAC/C,mBAAmB,0BAA0B,CAAA;AAC7C,mBAAmB,gCAAgC,CAAA;AACnD,mBAAmB,4BAA4B,CAAA;AAC/C,mBAAmB,gBAAgB,CAAA;AACnC,mBAAmB,uBAAuB,CAAA;AAC1C,mBAAmB,8BAA8B,CAAA;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,YAAY,EACV,UAAU,EACV,cAAc,EACd,cAAc,EACd,WAAW,EACX,eAAe,EACf,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,oBAAoB,EACpB,iBAAiB,EACjB,oBAAoB,EACpB,QAAQ,EACR,iBAAiB,EACjB,YAAY,GACb,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../../src/lifecycle/lifecycle.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,OAAO,EAOL,KAAK,MAAM,EACX,KAAK,aAAa,EAElB,KAAK,aAAa,EACnB,MAAM,UAAU,CAAA;AAEjB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../../src/lifecycle/lifecycle.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,OAAO,EAOL,KAAK,MAAM,EACX,KAAK,aAAa,EAElB,KAAK,aAAa,EACnB,MAAM,UAAU,CAAA;AAEjB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAQhD,4CAA4C;AAC5C,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,UAAU,GAAG,OAAO,GAAG,QAAQ,CAAA;AAErE,8GAA8G;AAC9G,KAAK,UAAU,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAA;AAEjD,6DAA6D;AAC7D,UAAU,SAAS;IACjB,8HAA8H;IAC9H,KAAK,EAAE,aAAa,CAAC,IAAI,CAAC,CAAA;IAE1B,4CAA4C;IAC5C,UAAU,EAAE,aAAa,CAAC,OAAO,CAAC,CAAA;IAClC,2FAA2F;IAC3F,uBAAuB,EAAE,aAAa,CAAC,OAAO,GAAG,SAAS,CAAC,CAAA;IAC3D,wFAAwF;IACxF,oBAAoB,EAAE,aAAa,CAAC,OAAO,GAAG,SAAS,CAAC,CAAA;IACxD,qDAAqD;IACrD,mBAAmB,EAAE,aAAa,CAAC,cAAc,CAAC,CAAA;IAElD,sDAAsD;IACtD,uBAAuB,EAAE,aAAa,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,CAAA;IAEjE,iFAAiF;IACjF,eAAe,EAAE,aAAa,CAAC,UAAU,CAAC,CAAA;IAC1C,8EAA8E;IAC9E,YAAY,EAAE,aAAa,CAAC,UAAU,CAAC,CAAA;CACxC;AA+OD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAErE"}
|
package/dist/types/picked.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/** @file Picked client — the main entry point for the Picked SDK. */
|
|
2
2
|
import { type Effect, type EventCallable, type Store, type StoreWritable } from 'effector';
|
|
3
|
+
import type { ExperienceContentResponse, ProjectConfig } from '@picked/delivery-api-client';
|
|
3
4
|
import { type Experience, type LaunchExperienceOptions } from './entities/experience/experience';
|
|
4
5
|
import { type Plugin, type PluginConfigIndex } from './entities/plugin/plugin';
|
|
5
6
|
import { type CreateClientOptions } from './client';
|
|
@@ -16,7 +17,7 @@ import { type EventBusPayload, type EventHistoryStore } from './utils/events';
|
|
|
16
17
|
import type { Field } from './entities/field/field';
|
|
17
18
|
import type { ExperienceStep } from './entities/step/step';
|
|
18
19
|
import type { Content, ContentDataPatch } from './entities/content/content';
|
|
19
|
-
import type { ContentLoader
|
|
20
|
+
import type { ContentLoader } from './plugins/dynamic-experiences/types';
|
|
20
21
|
import type { Action } from './entities/action/action';
|
|
21
22
|
import { type Condition } from './entities/condition/condition';
|
|
22
23
|
import type { SessionEntity } from './entities/session/session';
|
|
@@ -74,6 +75,15 @@ export declare class Picked {
|
|
|
74
75
|
*/
|
|
75
76
|
previewEmbedderOrigins: string[] | null;
|
|
76
77
|
private readonly plugins;
|
|
78
|
+
/**
|
|
79
|
+
* Names of the plugins registered on this client.
|
|
80
|
+
*
|
|
81
|
+
* Complete once the start chain has run, since plugins register one at a time.
|
|
82
|
+
*
|
|
83
|
+
* @returns {string[]} The registered plugin names.
|
|
84
|
+
* @example client.pluginNames // ['dynamic-experiences', 'single-page-app']
|
|
85
|
+
*/
|
|
86
|
+
get pluginNames(): string[];
|
|
77
87
|
private readonly dataProviders;
|
|
78
88
|
readonly eventBus: EventCallable<EventBusPayload>;
|
|
79
89
|
readonly events: EventHistoryStore;
|
|
@@ -172,7 +182,7 @@ export declare class Picked {
|
|
|
172
182
|
getByName: (name: string) => Store<import(".").FeatureIndexItem | undefined>;
|
|
173
183
|
listStore: Store<import(".").FeatureBucket[]>;
|
|
174
184
|
getEvokableFeature: (featureName: string) => Store<() => Promise<import(".").FeatureBucketValue>>;
|
|
175
|
-
getFeatureResult: (featureName:
|
|
185
|
+
getFeatureResult: <K extends string>(featureName: K) => Store<import(".").FeatureResult<import("./schema-registry").FeatureValueFor<K>> | undefined>;
|
|
176
186
|
};
|
|
177
187
|
readonly conditions: {
|
|
178
188
|
register: (condition: Condition) => void;
|
|
@@ -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,EAAE,MAAM,wBAAwB,CAAA;AAEnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAE1D,OA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|
|
24
24
|
* publishing a new version re-runs `decide` against the current weight and an
|
|
25
25
|
* unchanged weight keeps the same audience.
|
|
26
26
|
*
|
|
27
|
+
* This is the boolean path's input. A multi-variant feature does not roll once
|
|
28
|
+
* and look the result up; {@link allocateVariant} scores each arm on its own
|
|
29
|
+
* seed. One roll per feature is still what keeps features independent of one
|
|
30
|
+
* another, per ADR-0018.
|
|
31
|
+
*
|
|
27
32
|
* @param {string} sessionId - Current session id, stable across page loads.
|
|
28
33
|
* @param {string} featureId - Feature the roll is for.
|
|
29
|
-
* @returns {number} A value in the range 0
|
|
34
|
+
* @returns {number} A value in the range 0 to 99.
|
|
30
35
|
* @example
|
|
31
36
|
* ```typescript
|
|
32
37
|
* const diceRoll = featureDiceRoll('sess_1', 'winter-sale')
|
|
@@ -50,4 +55,51 @@ export declare function featureDiceRoll(sessionId: string, featureId: string): n
|
|
|
50
55
|
* ```
|
|
51
56
|
*/
|
|
52
57
|
export declare function isAllocated(diceRoll: number, weight: number): boolean;
|
|
58
|
+
/** The fields {@link allocateVariant} needs from an arm. */
|
|
59
|
+
export interface AllocatableVariant {
|
|
60
|
+
key: string;
|
|
61
|
+
weight: number;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Picks the arm a session lands in, scoring each arm independently.
|
|
65
|
+
*
|
|
66
|
+
* Each arm is hashed on its own key and scored against its own weight, and the
|
|
67
|
+
* highest score wins. An arm's score therefore depends on nothing but the
|
|
68
|
+
* session, the feature and that arm's own weight, which is what gives the two
|
|
69
|
+
* properties an author is entitled to assume:
|
|
70
|
+
*
|
|
71
|
+
* - Editing one arm's weight moves sessions only into or out of that arm. Two
|
|
72
|
+
* arms the author did not touch never trade sessions with each other.
|
|
73
|
+
* - Widening an arm only admits sessions and never evicts one already inside,
|
|
74
|
+
* the same ratchet {@link isAllocated} gives the boolean path. Narrowing is
|
|
75
|
+
* its mirror.
|
|
76
|
+
*
|
|
77
|
+
* Neither holds for cumulative ranges, where an arm's interval depends on every
|
|
78
|
+
* arm ordered before it, so a boundary shift upstream drags unrelated arms
|
|
79
|
+
* across it.
|
|
80
|
+
*
|
|
81
|
+
* Scores are compared, never summed, so the result is invariant under scaling
|
|
82
|
+
* every weight by the same factor: `1:1:2` and `10:10:20` allocate identically.
|
|
83
|
+
* Ties break on the key so that the arms' arrival order cannot matter — nothing
|
|
84
|
+
* in the delivery pipeline promises one.
|
|
85
|
+
*
|
|
86
|
+
* The chosen arm is returned whole rather than by key, so a caller reading its
|
|
87
|
+
* value needs no second lookup — and cannot resolve a duplicate key to a
|
|
88
|
+
* different arm than the one scored.
|
|
89
|
+
*
|
|
90
|
+
* @template T
|
|
91
|
+
* @param {string} sessionId - Current session id, stable across page loads.
|
|
92
|
+
* @param {string} featureKey - Feature being allocated.
|
|
93
|
+
* @param {readonly T[]} variants - The feature's arms, in any order.
|
|
94
|
+
* @returns {T | null} The chosen arm, or null when the set decides nobody.
|
|
95
|
+
* @example
|
|
96
|
+
* ```typescript
|
|
97
|
+
* // 'hero-b' takes three sessions in four; 'false' takes the fourth.
|
|
98
|
+
* allocateVariant('sess_1', 'hero', [
|
|
99
|
+
* { key: 'hero-b', weight: 3 },
|
|
100
|
+
* { key: 'false', weight: 1 },
|
|
101
|
+
* ])
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
export declare function allocateVariant<T extends AllocatableVariant>(sessionId: string, featureKey: string, variants: readonly T[]): T | null;
|
|
53
105
|
//# sourceMappingURL=hash.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dynamic-experiences/hash.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAY7C;AA8BD
|
|
1
|
+
{"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../../../src/plugins/dynamic-experiences/hash.ts"],"names":[],"mappings":"AAAA,sFAAsF;AAEtF;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAY7C;AA8BD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAE5E;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAUrE;AAED,4DAA4D;AAC5D,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,MAAM,CAAA;CACf;AA4CD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,kBAAkB,EAC1D,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,SAAS,CAAC,EAAE,GACrB,CAAC,GAAG,IAAI,CAmBV"}
|
|
@@ -3,4 +3,5 @@ export { dynamicExperiencesPlugin, fetchExperienceContent, fetchProject } from '
|
|
|
3
3
|
export { createClientHeaders, fetchSchema } from '@picked/delivery-api-client';
|
|
4
4
|
export { registerPickedBundle } from '../../data-source/registry';
|
|
5
5
|
export type * from './types';
|
|
6
|
+
export type { ApiExperienceStep, ContentBlob, ExperienceContentResponse, FetchProjectOptions, ProjectConfig, ProjectConfigExperience, ProjectConfigFeature, ProjectConfigNode, } from '@picked/delivery-api-client';
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|