@delmaredigital/payload-experiments 0.4.0-rc.9 → 0.4.1
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/README.md +3 -7
- package/dist/admin/MetricSourceSelect.js +10 -3
- package/dist/admin/armSelect/armSelect.model.d.ts +1 -1
- package/dist/admin/blocks/BlockPanel.d.ts +1 -0
- package/dist/admin/blocks/BlockPanel.js +75 -29
- package/dist/admin/blocks/model.js +5 -4
- package/dist/admin/copy/blocks.d.ts +14 -11
- package/dist/admin/copy/blocks.js +33 -22
- package/dist/admin/copy/goals.d.ts +15 -8
- package/dist/admin/copy/goals.js +18 -8
- package/dist/admin/copy/newTest.d.ts +10 -7
- package/dist/admin/copy/newTest.js +14 -7
- package/dist/admin/copy/status.d.ts +1 -1
- package/dist/admin/copy/status.js +2 -1
- package/dist/admin/pageCollections.d.ts +1 -0
- package/dist/admin/pageCollections.js +3 -0
- package/dist/admin/placementStatus.model.js +5 -3
- package/dist/admin/status.model.d.ts +1 -0
- package/dist/admin/status.model.js +2 -1
- package/dist/admin/surface/ResultsRoute.js +4 -8
- package/dist/admin/surface/SurfaceShell.d.ts +4 -2
- package/dist/admin/surface/SurfaceShell.js +28 -3
- package/dist/admin/surface/TestRowMenu.d.ts +13 -0
- package/dist/admin/surface/TestRowMenu.js +163 -0
- package/dist/admin/surface/TestsHome.d.ts +4 -3
- package/dist/admin/surface/TestsHome.js +186 -47
- package/dist/admin/surface/TestsSurface.js +2 -1
- package/dist/admin/surface/goals/DeleteGoalDialog.d.ts +7 -0
- package/dist/admin/surface/goals/DeleteGoalDialog.js +42 -0
- package/dist/admin/surface/goals/GoalForm.d.ts +1 -0
- package/dist/admin/surface/goals/GoalForm.js +280 -198
- package/dist/admin/surface/goals/GoalsList.js +102 -33
- package/dist/admin/surface/goals/data.d.ts +2 -0
- package/dist/admin/surface/goals/data.js +9 -0
- package/dist/admin/surface/goals/goals.css +3 -2
- package/dist/admin/surface/goals/goals.model.d.ts +2 -2
- package/dist/admin/surface/goals/goals.model.js +7 -12
- package/dist/admin/surface/home.model.d.ts +15 -8
- package/dist/admin/surface/home.model.js +22 -18
- package/dist/admin/surface/newTest/NewTest.d.ts +3 -3
- package/dist/admin/surface/newTest/NewTest.js +156 -96
- package/dist/admin/surface/newTest/PageWizard.d.ts +4 -1
- package/dist/admin/surface/newTest/PageWizard.js +93 -68
- package/dist/admin/surface/newTest/newTest.css +28 -11
- package/dist/admin/surface/results/ResultsHeader.d.ts +1 -1
- package/dist/admin/surface/results/ResultsHeader.js +90 -63
- package/dist/admin/surface/surface.css +29 -0
- package/dist/admin/surface/test/TestPage.js +46 -38
- package/dist/admin/surface/useXpStepNav.d.ts +11 -0
- package/dist/admin/surface/useXpStepNav.js +14 -0
- package/dist/admin/views/TestsSurfaceClient.js +27 -3
- package/dist/admin/views/buildSurfaceProps.js +18 -66
- package/dist/arms/copy.d.ts +13 -3
- package/dist/arms/copy.js +5 -4
- package/dist/blocks/createExperimentBlock.js +1 -1
- package/dist/blocks/formState.js +1 -1
- package/dist/collections/experiments/armInvariants.js +8 -5
- package/dist/collections/metrics.js +12 -5
- package/dist/collections/serialize.js +3 -2
- package/dist/db/pageCopies.d.ts +5 -0
- package/dist/db/pageCopies.js +31 -0
- package/dist/db/snapshots.d.ts +1 -0
- package/dist/endpoints/duplicateOriginal.d.ts +38 -0
- package/dist/endpoints/duplicateOriginal.js +414 -0
- package/dist/endpoints/editorSurface.js +1 -1
- package/dist/endpoints/index.js +20 -0
- package/dist/endpoints/pages.js +245 -66
- package/dist/endpoints/placementStatus.js +1 -0
- package/dist/endpoints/results.js +3 -0
- package/dist/endpoints/testVersion.d.ts +2 -0
- package/dist/endpoints/testVersion.js +38 -0
- package/dist/endpoints/transitions.js +4 -5
- package/dist/exports/index.d.ts +1 -1
- package/dist/goals/picker/copy.js +1 -1
- package/dist/goals/sourceLabel.d.ts +2 -0
- package/dist/goals/sourceLabel.js +4 -0
- package/dist/hooks/trackPageCopies.d.ts +11 -0
- package/dist/hooks/trackPageCopies.js +7 -0
- package/dist/labels/arms.d.ts +3 -0
- package/dist/labels/arms.js +8 -0
- package/dist/options.d.ts +2 -0
- package/dist/options.js +18 -2
- package/dist/plugin.js +56 -2
- package/dist/puck/editor/ConfigureTestDrawer.d.ts +7 -7
- package/dist/puck/editor/ConfigureTestDrawer.js +36 -26
- package/dist/puck/editor/ExperimentSlotEditor.d.ts +2 -1
- package/dist/puck/editor/ExperimentSlotEditor.js +219 -106
- package/dist/puck/editor/LeftoverVersions.js +17 -32
- package/dist/puck/editor/QuickTestActions.d.ts +2 -2
- package/dist/puck/editor/QuickTestActions.js +44 -34
- package/dist/puck/editor/ResultsReadout.d.ts +3 -1
- package/dist/puck/editor/ResultsReadout.js +28 -16
- package/dist/puck/editor/VersionBuilder.d.ts +4 -2
- package/dist/puck/editor/VersionBuilder.js +42 -63
- package/dist/puck/editor/armWrites.js +1 -1
- package/dist/puck/editor/copy.d.ts +10 -6
- package/dist/puck/editor/copy.js +22 -12
- package/dist/puck/editor/editor.chrome.css +9 -8
- package/dist/puck/editor/editor.css +14 -9
- package/dist/puck/editor/placementsCache.d.ts +1 -1
- package/dist/puck/editor/placementsCache.js +9 -17
- package/dist/puck/editor/usePageSaveReadiness.d.ts +1 -4
- package/dist/puck/editor/usePageSaveReadiness.js +18 -21
- package/dist/puck/editor/usePlacementNotice.d.ts +2 -2
- package/dist/puck/editor/usePlacementNotice.js +4 -5
- package/dist/puck/nestedTestCopy.js +2 -2
- package/dist/puck/slotConfig.d.ts +1 -1
- package/dist/puck/slotConfig.js +1 -1
- package/dist/results/analyse.d.ts +2 -0
- package/dist/results/analyse.js +2 -2
- package/dist/results/verdict.d.ts +4 -4
- package/dist/results/verdict.js +13 -10
- package/dist/server/runResults.js +2 -1
- package/dist/testSurface/PreviewLinks.d.ts +2 -1
- package/dist/testSurface/PreviewLinks.js +3 -3
- package/dist/testSurface/actions/DecideDialog.d.ts +7 -4
- package/dist/testSurface/actions/DecideDialog.js +71 -59
- package/dist/testSurface/actions/LifecycleAction.d.ts +17 -0
- package/dist/testSurface/actions/LifecycleAction.js +107 -0
- package/dist/testSurface/actions/MakeContentResult.js +1 -1
- package/dist/testSurface/actions/actions.model.d.ts +13 -5
- package/dist/testSurface/actions/actions.model.js +75 -22
- package/dist/testSurface/actions/decide.model.d.ts +1 -0
- package/dist/testSurface/actions/decide.model.js +1 -0
- package/dist/testSurface/allocation.model.js +6 -3
- package/dist/testSurface/api.d.ts +4 -1
- package/dist/testSurface/api.js +22 -14
- package/dist/testSurface/copy/actions.d.ts +36 -14
- package/dist/testSurface/copy/actions.js +39 -17
- package/dist/testSurface/copy/advanced.d.ts +10 -0
- package/dist/testSurface/copy/advanced.js +10 -0
- package/dist/testSurface/copy/arms.d.ts +1 -1
- package/dist/testSurface/copy/arms.js +1 -1
- package/dist/testSurface/copy/audience.d.ts +4 -3
- package/dist/testSurface/copy/audience.js +5 -4
- package/dist/testSurface/copy/common.d.ts +6 -6
- package/dist/testSurface/copy/common.js +6 -6
- package/dist/testSurface/copy/metrics.d.ts +6 -0
- package/dist/testSurface/copy/metrics.js +8 -0
- package/dist/testSurface/copy/pages.d.ts +67 -7
- package/dist/testSurface/copy/pages.js +74 -7
- package/dist/testSurface/copy/readiness.d.ts +8 -6
- package/dist/testSurface/copy/readiness.js +19 -10
- package/dist/testSurface/copy/recommendation.d.ts +1 -22
- package/dist/testSurface/copy/recommendation.js +2 -22
- package/dist/testSurface/copy/results.d.ts +16 -10
- package/dist/testSurface/copy/results.js +19 -11
- package/dist/testSurface/copy/review.d.ts +13 -10
- package/dist/testSurface/copy/review.js +14 -10
- package/dist/testSurface/copy/setting.d.ts +1 -2
- package/dist/testSurface/copy/setting.js +1 -2
- package/dist/testSurface/copy/surface.d.ts +11 -2
- package/dist/testSurface/copy/surface.js +14 -11
- package/dist/testSurface/copy/testPage.d.ts +16 -10
- package/dist/testSurface/copy/testPage.js +24 -18
- package/dist/testSurface/format/date.d.ts +5 -2
- package/dist/testSurface/format/date.js +24 -8
- package/dist/testSurface/format/roundProgress.d.ts +6 -0
- package/dist/testSurface/format/roundProgress.js +15 -0
- package/dist/testSurface/format/useDateFormatter.d.ts +3 -0
- package/dist/testSurface/format/useDateFormatter.js +8 -0
- package/dist/testSurface/labels.d.ts +1 -2
- package/dist/testSurface/labels.js +2 -3
- package/dist/testSurface/lockedNotice.model.d.ts +2 -0
- package/dist/testSurface/lockedNotice.model.js +31 -0
- package/dist/testSurface/readPreflight.d.ts +0 -1
- package/dist/testSurface/readPreflight.js +0 -1
- package/dist/testSurface/results/CiChart.js +2 -1
- package/dist/testSurface/results/DataTable.d.ts +1 -1
- package/dist/testSurface/results/DataTable.js +4 -3
- package/dist/testSurface/results/VerdictHero.d.ts +1 -1
- package/dist/testSurface/results/legacy.d.ts +0 -5
- package/dist/testSurface/results/legacy.js +0 -14
- package/dist/testSurface/results/results.css +2 -2
- package/dist/testSurface/results/results.model.d.ts +8 -3
- package/dist/testSurface/results/results.model.js +25 -21
- package/dist/testSurface/results/snapshot.d.ts +2 -0
- package/dist/testSurface/results/snapshot.js +3 -0
- package/dist/testSurface/surface/contracts.d.ts +6 -1
- package/dist/testSurface/surface/editorPlacement.d.ts +1 -1
- package/dist/testSurface/surface/editorPlacement.js +1 -1
- package/dist/testSurface/surface/pageBlock/pageBlock.model.js +1 -1
- package/dist/testSurface/surface/pageBlock/parts.js +25 -12
- package/dist/testSurface/surface/pagePicker/CopyRoute.d.ts +8 -1
- package/dist/testSurface/surface/pagePicker/CopyRoute.js +243 -22
- package/dist/testSurface/surface/pagePicker/PageCombobox.d.ts +15 -4
- package/dist/testSurface/surface/pagePicker/PageCombobox.js +298 -209
- package/dist/testSurface/surface/pagePicker/pagePicker.css +73 -10
- package/dist/testSurface/surface/pagePicker/pagePicker.model.d.ts +5 -3
- package/dist/testSurface/surface/pagePicker/pagePicker.model.js +17 -2
- package/dist/testSurface/surface/readiness/ActionDialogs.d.ts +5 -3
- package/dist/testSurface/surface/readiness/ActionDialogs.js +213 -207
- package/dist/testSurface/surface/readiness/Banner.d.ts +5 -1
- package/dist/testSurface/surface/readiness/Banner.js +109 -148
- package/dist/testSurface/surface/readiness/SaveStatus.d.ts +5 -2
- package/dist/testSurface/surface/readiness/SaveStatus.js +8 -7
- package/dist/testSurface/surface/readiness/readiness.model.d.ts +14 -5
- package/dist/testSurface/surface/readiness/readiness.model.js +62 -12
- package/dist/testSurface/surface/readiness/useTransition.d.ts +3 -1
- package/dist/testSurface/surface/readiness/useTransition.js +49 -8
- package/dist/testSurface/surface/results/ReleasePages.d.ts +4 -3
- package/dist/testSurface/surface/results/ReleasePages.js +41 -41
- package/dist/testSurface/surface/results/ResultsBody.d.ts +7 -2
- package/dist/testSurface/surface/results/ResultsBody.js +170 -110
- package/dist/testSurface/surface/results/recommendation.model.d.ts +6 -9
- package/dist/testSurface/surface/results/recommendation.model.js +15 -59
- package/dist/testSurface/surface/results/useResults.d.ts +6 -2
- package/dist/testSurface/surface/setting/parts.js +31 -28
- package/dist/testSurface/surface/setting/setting.css +2 -1
- package/dist/testSurface/surface/test/AdvancedSection.js +10 -4
- package/dist/testSurface/surface/test/DeleteTest.d.ts +5 -1
- package/dist/testSurface/surface/test/DeleteTest.js +63 -55
- package/dist/testSurface/surface/test/GoalSection.js +11 -11
- package/dist/testSurface/surface/test/LengthSection.js +21 -13
- package/dist/testSurface/surface/test/PageHoldout.d.ts +1 -1
- package/dist/testSurface/surface/test/PageHoldout.js +7 -7
- package/dist/testSurface/surface/test/ReadinessBar.d.ts +2 -1
- package/dist/testSurface/surface/test/ReadinessBar.js +4 -10
- package/dist/testSurface/surface/test/Section.js +8 -0
- package/dist/testSurface/surface/test/TargetingSection.js +7 -2
- package/dist/testSurface/surface/test/TestSurface.js +17 -43
- package/dist/testSurface/surface/test/VersionsSection.js +93 -70
- package/dist/testSurface/surface/test/fields.d.ts +4 -3
- package/dist/testSurface/surface/test/fields.js +10 -16
- package/dist/testSurface/surface/test/pageParts.js +13 -7
- package/dist/testSurface/surface/test/testPage.css +9 -2
- package/dist/testSurface/surface/useTestDocument.d.ts +1 -3
- package/dist/testSurface/surface/useTestDocument.js +110 -52
- package/dist/testSurface/surface/watchTestDocument.d.ts +15 -0
- package/dist/testSurface/surface/watchTestDocument.js +181 -0
- package/dist/testSurface/surfaceUrls.d.ts +1 -0
- package/dist/testSurface/surfaceUrls.js +4 -0
- package/dist/testSurface/useApi.d.ts +3 -0
- package/dist/transitions/addMetric.d.ts +1 -1
- package/dist/transitions/addMetric.js +5 -1
- package/dist/transitions/kernel.d.ts +2 -0
- package/dist/transitions/kernel.js +1 -1
- package/dist/transitions/pageAddress.d.ts +6 -0
- package/dist/transitions/pageAddress.js +71 -0
- package/dist/transitions/pageVersions.d.ts +1 -1
- package/dist/transitions/preflightData.js +10 -2
- package/dist/transitions/start.d.ts +1 -1
- package/dist/transitions/start.js +8 -5
- package/dist/types/armKey.d.ts +2 -0
- package/dist/types/armKey.js +1 -0
- package/dist/types/contracts.d.ts +11 -1
- package/dist/types/endpoints.d.ts +38 -9
- package/dist/types/endpoints.js +1 -1
- package/dist/types/surface.d.ts +7 -9
- package/dist/ui/Dialog.d.ts +21 -2
- package/dist/ui/Dialog.js +101 -4
- package/dist/ui/Inputs.js +0 -1
- package/dist/ui/ui.css +5 -1
- package/package.json +2 -2
|
@@ -6,51 +6,59 @@ import { formatAdminURL } from '../../../testSurface/format/adminURL.js';
|
|
|
6
6
|
import { surfaceUrls } from '../../../testSurface/surfaceUrls.js';
|
|
7
7
|
import { Button } from '../../../ui/Button.js';
|
|
8
8
|
import { StatusChip } from '../../../ui/StatusChip.js';
|
|
9
|
+
import { useXpStepNav } from '../useXpStepNav.js';
|
|
9
10
|
import { SurfaceShell } from '../SurfaceShell.js';
|
|
10
11
|
export function TestPage({ id, surface, onTitleChange }) {
|
|
11
12
|
return /*#__PURE__*/ _jsx(TestSurface, {
|
|
12
13
|
id: id,
|
|
13
14
|
surface: surface,
|
|
14
15
|
onTitleChange: onTitleChange,
|
|
15
|
-
renderFrame: ({ test, children })
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
adminRoute: surface.adminRoute,
|
|
19
|
-
title: doc?.name ?? C.test,
|
|
20
|
-
crumbs: [
|
|
21
|
-
{
|
|
22
|
-
label: C.tests,
|
|
23
|
-
href: surfaceUrls.home(surface.adminRoute)
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
label: doc?.name ?? C.test
|
|
27
|
-
}
|
|
28
|
-
],
|
|
29
|
-
status: doc ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
30
|
-
children: [
|
|
31
|
-
/*#__PURE__*/ _jsx("span", {
|
|
32
|
-
className: "xp-tests-kind",
|
|
33
|
-
children: C.kinds[doc.kind]
|
|
34
|
-
}),
|
|
35
|
-
!test.statusReadPending ? /*#__PURE__*/ _jsx(StatusChip, {
|
|
36
|
-
status: doc.status
|
|
37
|
-
}) : null
|
|
38
|
-
]
|
|
39
|
-
}) : undefined,
|
|
40
|
-
actions: doc && !test.statusReadPending && surface.canReadResults && [
|
|
41
|
-
'running',
|
|
42
|
-
'stopped',
|
|
43
|
-
'decided'
|
|
44
|
-
].includes(doc.status) ? /*#__PURE__*/ _jsx(Button, {
|
|
45
|
-
variant: "secondary",
|
|
46
|
-
href: formatAdminURL({
|
|
47
|
-
adminRoute: surface.adminRoute,
|
|
48
|
-
path: `/experiments/${encodeURIComponent(String(doc.id))}/results`
|
|
49
|
-
}),
|
|
50
|
-
children: C.results
|
|
51
|
-
}) : undefined,
|
|
16
|
+
renderFrame: ({ test, children })=>/*#__PURE__*/ _jsx(TestPageFrame, {
|
|
17
|
+
test: test,
|
|
18
|
+
surface: surface,
|
|
52
19
|
children: children
|
|
53
|
-
})
|
|
20
|
+
})
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function TestPageFrame({ test, surface, children }) {
|
|
24
|
+
const doc = test.doc;
|
|
25
|
+
const crumbs = [
|
|
26
|
+
{
|
|
27
|
+
label: C.tests,
|
|
28
|
+
url: surfaceUrls.home(surface.adminRoute)
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
label: doc?.name ?? C.test
|
|
54
32
|
}
|
|
33
|
+
];
|
|
34
|
+
useXpStepNav(crumbs);
|
|
35
|
+
return /*#__PURE__*/ _jsx(SurfaceShell, {
|
|
36
|
+
adminRoute: surface.adminRoute,
|
|
37
|
+
title: doc?.name ?? C.test,
|
|
38
|
+
dynamicTitle: Boolean(doc?.name),
|
|
39
|
+
crumbs: crumbs.map(({ label, url })=>({
|
|
40
|
+
label,
|
|
41
|
+
href: url
|
|
42
|
+
})),
|
|
43
|
+
status: doc ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
44
|
+
children: [
|
|
45
|
+
/*#__PURE__*/ _jsx("span", {
|
|
46
|
+
className: "xp-tests-kind",
|
|
47
|
+
children: C.kinds[doc.kind]
|
|
48
|
+
}),
|
|
49
|
+
!test.statusReadPending ? /*#__PURE__*/ _jsx(StatusChip, {
|
|
50
|
+
status: doc.status
|
|
51
|
+
}) : null
|
|
52
|
+
]
|
|
53
|
+
}) : undefined,
|
|
54
|
+
actions: doc && !test.statusReadPending && surface.canReadResults && doc.status !== 'draft' ? /*#__PURE__*/ _jsx(Button, {
|
|
55
|
+
variant: "secondary",
|
|
56
|
+
href: formatAdminURL({
|
|
57
|
+
adminRoute: surface.adminRoute,
|
|
58
|
+
path: `/experiments/${encodeURIComponent(String(doc.id))}/results`
|
|
59
|
+
}),
|
|
60
|
+
children: C.results
|
|
61
|
+
}) : undefined,
|
|
62
|
+
children: children
|
|
55
63
|
});
|
|
56
64
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TestsRoute } from '../../types/surface.js';
|
|
2
|
+
export type StepNavItem = {
|
|
3
|
+
label: string;
|
|
4
|
+
url?: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const XpStepNavContext: import("react").Context<{
|
|
7
|
+
route: TestsRoute;
|
|
8
|
+
items: StepNavItem[];
|
|
9
|
+
setStepNav: (items: StepNavItem[]) => void;
|
|
10
|
+
} | undefined>;
|
|
11
|
+
export declare function useXpStepNav(items: StepNavItem[]): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { createContext, useContext, useEffect } from 'react';
|
|
3
|
+
export const XpStepNavContext = createContext(undefined);
|
|
4
|
+
export function useXpStepNav(items) {
|
|
5
|
+
const setStepNav = useContext(XpStepNavContext)?.setStepNav;
|
|
6
|
+
// Callers can pass inline crumbs without resetting Payload's provider on every render.
|
|
7
|
+
const crumbs = JSON.stringify(items);
|
|
8
|
+
useEffect(()=>{
|
|
9
|
+
setStepNav?.(JSON.parse(crumbs));
|
|
10
|
+
}, [
|
|
11
|
+
crumbs,
|
|
12
|
+
setStepNav
|
|
13
|
+
]);
|
|
14
|
+
}
|
|
@@ -1,11 +1,35 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useLocale } from '@payloadcms/ui';
|
|
3
|
+
import { useLocale, useStepNav } from '@payloadcms/ui';
|
|
4
|
+
import { useCallback, useState } from 'react';
|
|
4
5
|
import { TestsSurface as Surface } from '../surface/TestsSurface.js';
|
|
6
|
+
import { XpStepNavContext } from '../surface/useXpStepNav.js';
|
|
5
7
|
/** Payload context stays at the admin entry; the mountable surface stays neutral. */ export function TestsSurface(props) {
|
|
6
8
|
const locale = useLocale();
|
|
7
|
-
|
|
9
|
+
const { setStepNav } = useStepNav();
|
|
10
|
+
// Each screen starts with its own shell crumbs until it publishes step nav.
|
|
11
|
+
return /*#__PURE__*/ _jsx(ScreenStepNav, {
|
|
8
12
|
...props,
|
|
9
|
-
contentLocale: locale?.code
|
|
13
|
+
contentLocale: locale?.code,
|
|
14
|
+
publishToPayload: setStepNav
|
|
15
|
+
}, `${props.route}/${props.id ?? ''}`);
|
|
16
|
+
}
|
|
17
|
+
function ScreenStepNav({ publishToPayload, ...props }) {
|
|
18
|
+
const [items, setItems] = useState([]);
|
|
19
|
+
const setStepNav = useCallback((next)=>{
|
|
20
|
+
setItems(next);
|
|
21
|
+
publishToPayload(next);
|
|
22
|
+
}, [
|
|
23
|
+
publishToPayload
|
|
24
|
+
]);
|
|
25
|
+
return /*#__PURE__*/ _jsx(XpStepNavContext, {
|
|
26
|
+
value: {
|
|
27
|
+
route: props.route,
|
|
28
|
+
items,
|
|
29
|
+
setStepNav
|
|
30
|
+
},
|
|
31
|
+
children: /*#__PURE__*/ _jsx(Surface, {
|
|
32
|
+
...props
|
|
33
|
+
})
|
|
10
34
|
});
|
|
11
35
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { placementLanguageNames } from '../../blocks/placementLanguages.js';
|
|
2
|
-
import { placementReader } from '../../blocks/placementLocale.js';
|
|
3
|
-
import { flattenTopLevelFields, formatAdminURL } from 'payload/shared';
|
|
4
2
|
import { serializeAttributeKeys, serializeFlagPoints, serializeMetricSources } from '../../collections/serialize.js';
|
|
5
3
|
import { serializePageCollections } from '../pageCollections.js';
|
|
6
4
|
import { collectionLabel as resolveLabel } from '../../collections/labels.js';
|
|
7
|
-
import { puckCollections } from '../../options.js';
|
|
5
|
+
import { blockPageSlugs, puckCollections } from '../../options.js';
|
|
8
6
|
import { xpOptionsFromReq } from '../../options/fromReq.js';
|
|
9
7
|
import { routeAccess } from './access.model.js';
|
|
10
8
|
export async function buildSurfaceProps({ req, route, id, searchParams }) {
|
|
@@ -43,66 +41,20 @@ export async function buildSurfaceProps({ req, route, id, searchParams }) {
|
|
|
43
41
|
const defaults = state.flagDefaults;
|
|
44
42
|
for (const point of flagPoints)point.effectiveDefaults = defaults?.[point.id]?.params ?? point.defaultParams;
|
|
45
43
|
}
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
true
|
|
61
|
-
])) : {};
|
|
62
|
-
const result = await req.payload.find({
|
|
63
|
-
collection,
|
|
64
|
-
req,
|
|
65
|
-
overrideAccess: false,
|
|
66
|
-
depth: 0,
|
|
67
|
-
limit: 50,
|
|
68
|
-
sort: '-updatedAt',
|
|
69
|
-
draft: true,
|
|
70
|
-
select: {
|
|
71
|
-
[useAsTitle]: true,
|
|
72
|
-
...predicateFields
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
// The new-test list uses the latest draft's editing intent, as the "Test a block" field condition does (§4.1).
|
|
76
|
-
return result.docs.map((row)=>{
|
|
77
|
-
const placement = placementReader(req, collection, options).read(row, req.locale === 'all' ? 'all-locales' : 'localized');
|
|
78
|
-
const doc = placement.doc;
|
|
79
|
-
const editor = placement.editor;
|
|
80
|
-
if (editor !== 'puck' && editor !== 'blocks') return null;
|
|
81
|
-
const id = doc.id;
|
|
82
|
-
const customUrl = options.admin?.editorUrl?.({
|
|
83
|
-
collection,
|
|
84
|
-
id,
|
|
85
|
-
draft: true,
|
|
86
|
-
editor,
|
|
87
|
-
doc
|
|
88
|
-
});
|
|
89
|
-
const title = doc[useAsTitle];
|
|
90
|
-
return {
|
|
91
|
-
collection,
|
|
92
|
-
collectionLabel,
|
|
93
|
-
id,
|
|
94
|
-
editor,
|
|
95
|
-
title: typeof title === 'string' || typeof title === 'number' ? String(title) : String(id),
|
|
96
|
-
editorUrl: typeof customUrl === 'string' ? customUrl : formatAdminURL({
|
|
97
|
-
adminRoute,
|
|
98
|
-
path: `/collections/${collection}/${encodeURIComponent(String(id))}`
|
|
99
|
-
})
|
|
100
|
-
};
|
|
101
|
-
}).filter((page)=>page !== null);
|
|
102
|
-
} catch {
|
|
103
|
-
return [];
|
|
104
|
-
}
|
|
105
|
-
}))).flat() : undefined;
|
|
44
|
+
const blockPageCollections = route === 'new' && canManage ? blockPageSlugs(options).map((slug)=>{
|
|
45
|
+
const config = req.payload.config.collections.find((item)=>item.slug === slug);
|
|
46
|
+
const block = options.blocks?.collections.find((entry)=>entry.slug === slug);
|
|
47
|
+
const puck = options.puck?.enabled && puckCollections(options).some((entry)=>entry.slug === slug);
|
|
48
|
+
const editors = block ? [
|
|
49
|
+
'blocks'
|
|
50
|
+
] : [];
|
|
51
|
+
if (puck && (!block || block.appliesTo)) editors.push('puck');
|
|
52
|
+
return {
|
|
53
|
+
slug,
|
|
54
|
+
label: resolveLabel(config?.labels.plural, slug, req),
|
|
55
|
+
editors
|
|
56
|
+
};
|
|
57
|
+
}) : [];
|
|
106
58
|
const descriptions = options.admin?.descriptions;
|
|
107
59
|
const returnToTest = (await searchParams)?.return;
|
|
108
60
|
return {
|
|
@@ -122,9 +74,9 @@ export async function buildSurfaceProps({ req, route, id, searchParams }) {
|
|
|
122
74
|
canReadResults,
|
|
123
75
|
isAdmin,
|
|
124
76
|
flagPoints,
|
|
125
|
-
...
|
|
126
|
-
|
|
127
|
-
},
|
|
77
|
+
...blockPageCollections.length ? {
|
|
78
|
+
blockPageCollections
|
|
79
|
+
} : {},
|
|
128
80
|
pageCollections: serializePageCollections(options.pages?.collections ?? [], req),
|
|
129
81
|
collectionTitles: Object.fromEntries(req.payload.config.collections.flatMap((collection)=>{
|
|
130
82
|
const title = collection.admin.useAsTitle;
|
package/dist/arms/copy.d.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export declare const ISSUE_COPY: {
|
|
2
|
+
'weights-total': string;
|
|
3
|
+
'control-count': string;
|
|
4
|
+
'control-first': (label?: string) => string;
|
|
5
|
+
'holdout-last': string;
|
|
6
|
+
'holdout-count': string;
|
|
7
|
+
'variant-count': string;
|
|
8
|
+
'duplicate-key': string;
|
|
9
|
+
'duplicate-slot': string;
|
|
10
|
+
'slot-required': string;
|
|
11
|
+
'invalid-key': string;
|
|
12
|
+
};
|
|
3
13
|
export declare function issueMessage(issue: {
|
|
4
14
|
code: string;
|
|
5
15
|
message: string;
|
|
6
|
-
}, total: number): string;
|
|
16
|
+
}, total: number, controlLabel?: string): string;
|
package/dist/arms/copy.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { controlVersionName } from '../labels/arms.js';
|
|
1
2
|
export const ISSUE_COPY = {
|
|
2
3
|
'weights-total': 'Weights must add up to 100%. They add up to {total}% now.',
|
|
3
|
-
'control-count': 'Include exactly one
|
|
4
|
-
'control-first':
|
|
4
|
+
'control-count': 'Include exactly one version that visitors see today.',
|
|
5
|
+
'control-first': (label)=>`Put ${controlVersionName(label)} first.`,
|
|
5
6
|
'holdout-last': 'Put the holdout last.',
|
|
6
7
|
'holdout-count': 'Include only one holdout.',
|
|
7
8
|
'variant-count': 'Include up to three variants.',
|
|
@@ -10,7 +11,7 @@ export const ISSUE_COPY = {
|
|
|
10
11
|
'slot-required': 'Choose the matching content slot for this group.',
|
|
11
12
|
'invalid-key': 'Use the standard group names: Original, Variant A–C, Holdout.'
|
|
12
13
|
};
|
|
13
|
-
export function issueMessage(issue, total) {
|
|
14
|
+
export function issueMessage(issue, total, controlLabel) {
|
|
14
15
|
const copy = Object.hasOwn(ISSUE_COPY, issue.code) ? ISSUE_COPY[issue.code] : issue.message;
|
|
15
|
-
return copy.replace('{total}', String(total));
|
|
16
|
+
return typeof copy === 'function' ? copy(controlLabel) : copy.replace('{total}', String(total));
|
|
16
17
|
}
|
|
@@ -6,7 +6,7 @@ export function validateExperimentSlots(value) {
|
|
|
6
6
|
return new Set(slots).size === slots.length ? true : 'Each version appears once';
|
|
7
7
|
}
|
|
8
8
|
export function createExperimentBlock({ blocks, slug = EXPERIMENT_BLOCK_SLUG }) {
|
|
9
|
-
if (blocks.some((block)=>block.slug === slug)) throw new Error(
|
|
9
|
+
if (blocks.some((block)=>block.slug === slug)) throw new Error("Test blocks can't be placed inside another Test block.");
|
|
10
10
|
return {
|
|
11
11
|
slug,
|
|
12
12
|
labels: {
|
package/dist/blocks/formState.js
CHANGED
|
@@ -55,7 +55,7 @@ import { BLOCK_SLOTS, EXPERIMENT_BLOCK_SLUG, isObject, slotBlocks } from './mode
|
|
|
55
55
|
return copyRows(value, field);
|
|
56
56
|
}
|
|
57
57
|
export function wrapExperimentBlock(block, experiment, field, config = {}, blockSlug = EXPERIMENT_BLOCK_SLUG) {
|
|
58
|
-
if (block.blockType === blockSlug) throw new Error(
|
|
58
|
+
if (block.blockType === blockSlug) throw new Error("Test blocks can't be placed inside another Test block.");
|
|
59
59
|
return {
|
|
60
60
|
id: globalThis.crypto.randomUUID(),
|
|
61
61
|
blockType: blockSlug,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ARM_LABELS, controlVersionName } from '../../labels/arms.js';
|
|
1
2
|
/** The groups a new experiment starts with: Original 50 / Variant A 50, no holdout (spec §5.1, O4). Block slots equal the key. */ export function defaultArms(kind) {
|
|
2
3
|
const slot = (key)=>kind === 'block' ? {
|
|
3
4
|
slot: key
|
|
@@ -6,7 +7,7 @@
|
|
|
6
7
|
{
|
|
7
8
|
key: 'control',
|
|
8
9
|
kind: 'control',
|
|
9
|
-
label:
|
|
10
|
+
label: ARM_LABELS.control,
|
|
10
11
|
weight: 50,
|
|
11
12
|
...slot('control')
|
|
12
13
|
},
|
|
@@ -34,8 +35,10 @@ export function checkArms(arms, kind) {
|
|
|
34
35
|
if (arms.some((arm)=>!Number.isInteger(arm.weight) || arm.weight < 0) || arms.reduce((total, arm)=>total + arm.weight, 0) !== 100) {
|
|
35
36
|
issue('weights-total', 'Group shares must be whole numbers that add up to exactly 100.');
|
|
36
37
|
}
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
const controls = arms.filter((arm)=>arm.kind === 'control');
|
|
39
|
+
const controlLabel = controls[0]?.label;
|
|
40
|
+
if (controls.length !== 1) issue('control-count', 'Exactly one version must be the one visitors see today.');
|
|
41
|
+
if (arms.some((arm, index)=>arm.kind === 'control' && index !== 0)) issue('control-first', `${controlVersionName(controlLabel, true)} must be first.`);
|
|
39
42
|
if (arms.filter((arm)=>arm.kind === 'holdout').length > 1) issue('holdout-count', 'Only one Holdout is allowed.');
|
|
40
43
|
if (arms.some((arm, index)=>arm.kind === 'holdout' && index !== arms.length - 1)) issue('holdout-last', 'The Holdout must be the last group.');
|
|
41
44
|
if (arms.filter((arm)=>arm.kind === 'variant').length > 3) issue('variant-count', 'At most three variants are allowed.');
|
|
@@ -53,9 +56,9 @@ export function checkArms(arms, kind) {
|
|
|
53
56
|
keys.add(arm.key);
|
|
54
57
|
if (kind === 'block') {
|
|
55
58
|
if (arm.kind === 'holdout') {
|
|
56
|
-
if (arm.slot != null) issue('invalid-key',
|
|
59
|
+
if (arm.slot != null) issue('invalid-key', `The Holdout has no content of its own; it sees ${controlVersionName(controlLabel)}.`, index);
|
|
57
60
|
} else {
|
|
58
|
-
if (!arm.slot || arm.slot !== arm.key) issue('slot-required', 'Each
|
|
61
|
+
if (!arm.slot || arm.slot !== arm.key) issue('slot-required', 'Each version needs its own content area.', index);
|
|
59
62
|
if (arm.slot && slots.has(arm.slot)) issue('duplicate-slot', 'Two groups cannot share the same content area.', index);
|
|
60
63
|
if (arm.slot) slots.add(arm.slot);
|
|
61
64
|
}
|
|
@@ -19,6 +19,12 @@ export function metricsCollection(options) {
|
|
|
19
19
|
admin: {
|
|
20
20
|
group: SURFACE_COPY.title,
|
|
21
21
|
useAsTitle: 'name',
|
|
22
|
+
meta: {
|
|
23
|
+
title: {
|
|
24
|
+
absolute: 'Goals · Tests'
|
|
25
|
+
},
|
|
26
|
+
titleSuffix: ''
|
|
27
|
+
},
|
|
22
28
|
components: {
|
|
23
29
|
views: {
|
|
24
30
|
list: {
|
|
@@ -54,11 +60,12 @@ export function metricsCollection(options) {
|
|
|
54
60
|
const source = sources.find((source)=>source.id === (data.source ?? originalDoc?.source));
|
|
55
61
|
const capping = data.capping === undefined ? originalDoc?.capping : data.capping;
|
|
56
62
|
// Payload may submit an empty optional group as { type: null, value: null }.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
63
|
+
if (source?.kind === 'revenue' && capping?.type == null && capping?.value == null) {
|
|
64
|
+
data.capping = {
|
|
65
|
+
type: 'percentile',
|
|
66
|
+
value: 0.99
|
|
67
|
+
};
|
|
68
|
+
}
|
|
62
69
|
return data;
|
|
63
70
|
}
|
|
64
71
|
]
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { browserWritableMetric } from '../events/writable.js';
|
|
2
|
+
import { goalSourceLabel } from '../goals/sourceLabel.js';
|
|
2
3
|
export function serializeFlagPoints(options) {
|
|
3
4
|
return (options.flagPoints ?? []).map(({ id, label, description, params, defaultParams })=>({
|
|
4
5
|
id,
|
|
@@ -22,14 +23,14 @@ export function serializeMetricSources(options) {
|
|
|
22
23
|
},
|
|
23
24
|
...(options.metricSources ?? []).map(({ id, label, kind, keyedBy })=>({
|
|
24
25
|
id,
|
|
25
|
-
label,
|
|
26
|
+
label: label?.trim() || goalSourceLabel(id),
|
|
26
27
|
kind,
|
|
27
28
|
keyedBy,
|
|
28
29
|
clientWritable: browserWritableMetric(id, options)
|
|
29
30
|
})),
|
|
30
31
|
...(options.eventSources ?? []).map(({ name })=>({
|
|
31
32
|
id: `events:${name}`,
|
|
32
|
-
label: name,
|
|
33
|
+
label: goalSourceLabel(name),
|
|
33
34
|
kind: 'binomial',
|
|
34
35
|
keyedBy: 'visitor',
|
|
35
36
|
clientWritable: browserWritableMetric(`events:${name}`, options)
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Payload } from 'payload';
|
|
2
|
+
import type { DocId } from '../types/contracts.js';
|
|
3
|
+
/** Read only the tracked IDs. Omitting req puts this adapter read on the pool,
|
|
4
|
+
* so a row visible here survived the copy transaction. */
|
|
5
|
+
export declare function committedPageCopyIds(payload: Payload, collection: string, created: DocId[]): Promise<DocId[]>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** Read only the tracked IDs. Omitting req puts this adapter read on the pool,
|
|
2
|
+
* so a row visible here survived the copy transaction. */ export async function committedPageCopyIds(payload, collection, created) {
|
|
3
|
+
const ids = [
|
|
4
|
+
...new Set(created)
|
|
5
|
+
];
|
|
6
|
+
if (!ids.length) return [];
|
|
7
|
+
const adapter = payload.db;
|
|
8
|
+
// The original transaction may have died before the adapter marked its write.
|
|
9
|
+
// Always check the primary so replica lag can't hide a committed draft.
|
|
10
|
+
const primary = adapter.primaryDrizzle ? {
|
|
11
|
+
...adapter,
|
|
12
|
+
drizzle: adapter.primaryDrizzle
|
|
13
|
+
} : adapter;
|
|
14
|
+
const { docs } = await primary.find({
|
|
15
|
+
collection,
|
|
16
|
+
where: {
|
|
17
|
+
id: {
|
|
18
|
+
in: ids
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
select: {
|
|
22
|
+
id: true
|
|
23
|
+
},
|
|
24
|
+
sort: 'id',
|
|
25
|
+
limit: ids.length,
|
|
26
|
+
pagination: false,
|
|
27
|
+
// The adapter has no access layer. Only IDs from this write are checked here.
|
|
28
|
+
overrideAccess: false
|
|
29
|
+
});
|
|
30
|
+
return docs.map((doc)=>doc.id);
|
|
31
|
+
}
|
package/dist/db/snapshots.d.ts
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type PayloadRequest } from 'payload';
|
|
2
|
+
import type { Arm, DocId, ExperimentsPageCollection, ResolvedOptions } from '../types/contracts.js';
|
|
3
|
+
import type { CopyPagePlan, EndpointContext } from '../types/endpoints.js';
|
|
4
|
+
declare function readTest(req: PayloadRequest, id: DocId): Promise<import("payload").JsonObject & import("payload").TypeWithID>;
|
|
5
|
+
export declare function preparePageCopy<TUser extends {
|
|
6
|
+
id: DocId;
|
|
7
|
+
}>(req: PayloadRequest, options: ResolvedOptions<TUser>, test: Awaited<ReturnType<typeof readTest>>, key: string, confirmed?: CopyPagePlan): Promise<{
|
|
8
|
+
plan: {
|
|
9
|
+
title: string;
|
|
10
|
+
path: string;
|
|
11
|
+
phase: number;
|
|
12
|
+
updatedAt: string;
|
|
13
|
+
originalId: string | number;
|
|
14
|
+
originalUpdatedAt: string;
|
|
15
|
+
};
|
|
16
|
+
data: Record<string, unknown>;
|
|
17
|
+
entry: ExperimentsPageCollection;
|
|
18
|
+
titleField: string;
|
|
19
|
+
homeFlags: string[];
|
|
20
|
+
hasSlugHistory: boolean;
|
|
21
|
+
requiredUniqueFields: string[];
|
|
22
|
+
original: import("payload").JsonObject & import("payload").TypeWithID;
|
|
23
|
+
arms: Arm[];
|
|
24
|
+
reader: {
|
|
25
|
+
views: import("../blocks/placementLocale.js").PlacementLocaleView[];
|
|
26
|
+
documentViews: import("../blocks/placementLocale.js").PlacementLocaleView[];
|
|
27
|
+
read(doc: Record<string, unknown> | null | undefined, input: import("../blocks/placementLocale.js").PlacementInput, view?: import("../blocks/placementLocale.js").PlacementLocaleView): {
|
|
28
|
+
view: import("../blocks/placementLocale.js").PlacementLocaleView;
|
|
29
|
+
readonly doc: Record<string, unknown> | undefined;
|
|
30
|
+
readonly editor: "page" | "puck" | "blocks";
|
|
31
|
+
readonly slugs: string[];
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
}>;
|
|
35
|
+
export declare function handleDuplicateOriginal<TUser extends {
|
|
36
|
+
id: DocId;
|
|
37
|
+
}>(req: PayloadRequest, { options }: EndpointContext<TUser>): Promise<Response>;
|
|
38
|
+
export {};
|