@delmaredigital/payload-experiments 0.4.0-rc.7 → 0.4.0
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 +9 -15
- 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 +7 -6
- 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 +12 -10
- 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 +224 -52
- 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 +99 -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 +98 -66
- 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 +2 -2
- package/dist/collections/experiments/armInvariants.js +8 -5
- package/dist/collections/experiments/config.js +8 -3
- package/dist/collections/experiments/deleteGuard.js +2 -2
- package/dist/collections/experiments/lockHook.js +21 -2
- package/dist/collections/experiments/pickSlug.js +2 -0
- package/dist/collections/metrics.js +12 -5
- package/dist/collections/metricsGuards.js +2 -0
- package/dist/collections/serialize.js +8 -6
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/db/adapter.d.ts +9 -1
- package/dist/db/adapter.js +77 -1
- package/dist/db/delete.d.ts +1 -1
- package/dist/db/delete.js +2 -4
- package/dist/db/events.d.ts +9 -0
- package/dist/db/events.js +42 -8
- package/dist/db/executor.d.ts +7 -1
- package/dist/db/executor.js +7 -3
- package/dist/db/pageCopies.d.ts +5 -0
- package/dist/db/pageCopies.js +31 -0
- package/dist/db/results.d.ts +5 -1
- package/dist/db/results.js +21 -5
- package/dist/db/snapshots.d.ts +2 -0
- package/dist/endpoints/deleteImpact.js +2 -1
- 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/events.js +103 -39
- package/dist/endpoints/index.js +22 -8
- package/dist/endpoints/pages.js +245 -66
- package/dist/endpoints/placementStatus.js +8 -4
- package/dist/endpoints/results.d.ts +1 -1
- package/dist/endpoints/results.js +9 -2
- package/dist/endpoints/routeId.d.ts +2 -2
- package/dist/endpoints/routeId.js +11 -5
- package/dist/endpoints/summary.js +46 -12
- package/dist/endpoints/testVersion.d.ts +2 -0
- package/dist/endpoints/testVersion.js +38 -0
- package/dist/endpoints/transitions.js +41 -29
- package/dist/errors.d.ts +4 -0
- package/dist/errors.js +6 -0
- package/dist/events/request.d.ts +6 -2
- package/dist/events/request.js +35 -8
- package/dist/events/rows.d.ts +1 -1
- package/dist/events/rows.js +24 -8
- package/dist/events/writable.d.ts +9 -0
- package/dist/events/writable.js +13 -0
- package/dist/exports/index.d.ts +1 -1
- package/dist/exports/rsc.d.ts +1 -0
- package/dist/exports/rsc.js +1 -0
- package/dist/goals/fairness.js +2 -2
- 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/hostHook.js +6 -2
- package/dist/hooks/pageGuard.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/lib/fetchAllDocs.d.ts +1 -1
- package/dist/manifest/compile.js +8 -5
- package/dist/onInit.js +14 -0
- package/dist/options.d.ts +2 -0
- package/dist/options.js +23 -2
- package/dist/plugin.js +56 -2
- package/dist/proxy/pageNavigation.d.ts +4 -0
- package/dist/proxy/pageNavigation.js +28 -0
- package/dist/proxy/resolve.js +52 -25
- package/dist/puck/editor/ConfigureTestDrawer.d.ts +7 -7
- package/dist/puck/editor/ConfigureTestDrawer.js +40 -29
- package/dist/puck/editor/ExperimentSlotEditor.d.ts +2 -1
- package/dist/puck/editor/ExperimentSlotEditor.js +376 -139
- package/dist/puck/editor/LeftoverVersions.js +17 -32
- package/dist/puck/editor/QuickTestActions.d.ts +6 -3
- package/dist/puck/editor/QuickTestActions.js +55 -33
- package/dist/puck/editor/ResultsReadout.d.ts +4 -1
- package/dist/puck/editor/ResultsReadout.js +28 -15
- package/dist/puck/editor/VersionBuilder.d.ts +17 -4
- package/dist/puck/editor/VersionBuilder.js +175 -112
- package/dist/puck/editor/armWrites.js +2 -2
- package/dist/puck/editor/armsCache.js +1 -3
- package/dist/puck/editor/copy.d.ts +14 -7
- package/dist/puck/editor/copy.js +26 -13
- package/dist/puck/editor/editor.chrome.css +10 -8
- package/dist/puck/editor/editor.css +15 -9
- package/dist/puck/editor/editor.model.d.ts +1 -0
- package/dist/puck/editor/placementsCache.d.ts +4 -0
- package/dist/puck/editor/usePageSaveReadiness.d.ts +6 -0
- package/dist/puck/editor/usePageSaveReadiness.js +31 -0
- 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/aggregate.d.ts +6 -3
- package/dist/results/aggregate.js +9 -9
- package/dist/results/analyse.d.ts +2 -0
- package/dist/results/analyse.js +2 -2
- package/dist/results/health.d.ts +8 -0
- package/dist/results/health.js +28 -0
- package/dist/results/identityCredit.d.ts +1 -0
- package/dist/results/identityCredit.js +4 -1
- package/dist/results/verdict.d.ts +4 -4
- package/dist/results/verdict.js +15 -11
- package/dist/runtime/cookie.d.ts +10 -2
- package/dist/runtime/cookie.js +38 -6
- package/dist/runtime/cookieOptions.d.ts +6 -0
- package/dist/runtime/cookieOptions.js +14 -0
- package/dist/runtime/proxyRuntime.d.ts +1 -0
- package/dist/runtime/proxyRuntime.js +18 -8
- package/dist/runtime/signing.d.ts +1 -0
- package/dist/runtime/signing.js +5 -0
- package/dist/sanitizeReadinessDetail.d.ts +2 -2
- package/dist/sanitizeReadinessDetail.js +20 -2
- package/dist/server/getAssignments.js +11 -10
- package/dist/server/recordContentChange.d.ts +1 -1
- package/dist/server/recordContentChange.js +11 -2
- package/dist/server/resolveExperimentBlocks.js +2 -4
- package/dist/server/resolveExperimentData.js +2 -5
- package/dist/server/runResults.js +54 -15
- package/dist/server/startExperiment.d.ts +20 -0
- package/dist/server/startExperiment.js +70 -0
- package/dist/server/trackConversion.js +10 -13
- package/dist/testSurface/PreviewLinks.d.ts +2 -1
- package/dist/testSurface/PreviewLinks.js +3 -3
- package/dist/testSurface/actions/DecideDialog.d.ts +10 -4
- package/dist/testSurface/actions/DecideDialog.js +93 -63
- package/dist/testSurface/actions/LifecycleAction.d.ts +17 -0
- package/dist/testSurface/actions/LifecycleAction.js +107 -0
- package/dist/testSurface/actions/MakeContentResult.d.ts +4 -3
- package/dist/testSurface/actions/MakeContentResult.js +10 -2
- 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 +9 -6
- package/dist/testSurface/api.js +43 -23
- package/dist/testSurface/copy/actions.d.ts +37 -14
- package/dist/testSurface/copy/actions.js +40 -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 +8 -6
- package/dist/testSurface/copy/common.js +8 -6
- package/dist/testSurface/copy/languages.d.ts +1 -0
- package/dist/testSurface/copy/languages.js +1 -0
- package/dist/testSurface/copy/metrics.d.ts +7 -0
- package/dist/testSurface/copy/metrics.js +9 -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 +20 -7
- package/dist/testSurface/copy/readiness.js +36 -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 +21 -12
- package/dist/testSurface/copy/results.js +24 -13
- 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 +36 -12
- package/dist/testSurface/copy/testPage.js +53 -16
- 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 +4 -0
- package/dist/testSurface/readPreflight.js +6 -0
- package/dist/testSurface/readinessRead.d.ts +3 -0
- package/dist/testSurface/readinessRead.js +4 -0
- 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 +3 -2
- package/dist/testSurface/results/VerdictHero.js +5 -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 +9 -4
- package/dist/testSurface/results/results.model.js +31 -23
- package/dist/testSurface/results/snapshot.d.ts +2 -0
- package/dist/testSurface/results/snapshot.js +3 -0
- package/dist/testSurface/surface/contracts.d.ts +13 -1
- package/dist/testSurface/surface/editorPlacement.d.ts +3 -3
- package/dist/testSurface/surface/editorPlacement.js +2 -2
- package/dist/testSurface/surface/pageBlock/pageBlock.model.js +3 -3
- 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 +300 -197
- 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 +9 -5
- package/dist/testSurface/surface/readiness/ActionDialogs.js +241 -230
- package/dist/testSurface/surface/readiness/Banner.d.ts +5 -1
- package/dist/testSurface/surface/readiness/Banner.js +113 -141
- package/dist/testSurface/surface/readiness/SaveStatus.d.ts +8 -4
- package/dist/testSurface/surface/readiness/SaveStatus.js +23 -22
- package/dist/testSurface/surface/readiness/readiness.model.d.ts +20 -6
- package/dist/testSurface/surface/readiness/readiness.model.js +168 -21
- package/dist/testSurface/surface/readiness/useTransition.d.ts +6 -4
- package/dist/testSurface/surface/readiness/useTransition.js +57 -14
- package/dist/testSurface/surface/results/ReleasePages.d.ts +6 -3
- package/dist/testSurface/surface/results/ReleasePages.js +42 -41
- package/dist/testSurface/surface/results/ResultsBody.d.ts +11 -4
- package/dist/testSurface/surface/results/ResultsBody.js +221 -118
- 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 +13 -8
- package/dist/testSurface/surface/results/useResults.js +3 -2
- package/dist/testSurface/surface/setting/parts.js +89 -46
- package/dist/testSurface/surface/setting/setting.css +2 -1
- package/dist/testSurface/surface/test/AdvancedSection.js +11 -4
- package/dist/testSurface/surface/test/DeleteTest.d.ts +10 -2
- package/dist/testSurface/surface/test/DeleteTest.js +173 -74
- package/dist/testSurface/surface/test/GoalSection.js +18 -14
- package/dist/testSurface/surface/test/LengthSection.js +24 -13
- package/dist/testSurface/surface/test/PageHoldout.d.ts +1 -1
- package/dist/testSurface/surface/test/PageHoldout.js +11 -8
- 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 +82 -12
- package/dist/testSurface/surface/test/TestSurface.js +73 -37
- package/dist/testSurface/surface/test/VersionsSection.js +141 -91
- package/dist/testSurface/surface/test/fields.d.ts +32 -6
- package/dist/testSurface/surface/test/fields.js +166 -52
- package/dist/testSurface/surface/test/pageParts.js +27 -12
- package/dist/testSurface/surface/test/testPage.css +9 -2
- package/dist/testSurface/surface/test/testPage.model.d.ts +1 -0
- package/dist/testSurface/surface/test/testPage.model.js +6 -0
- package/dist/testSurface/surface/testDocument.model.d.ts +3 -0
- package/dist/testSurface/surface/testDocument.model.js +4 -1
- package/dist/testSurface/surface/useTestDocument.d.ts +21 -5
- package/dist/testSurface/surface/useTestDocument.js +472 -167
- 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 +8 -5
- package/dist/testSurface/useOnTestReturn.d.ts +2 -0
- package/dist/testSurface/useOnTestReturn.js +27 -0
- package/dist/testSurface/useReadinessPolling.js +3 -1
- package/dist/transitions/addMetric.d.ts +2 -5
- package/dist/transitions/addMetric.js +5 -1
- package/dist/transitions/allocate.d.ts +2 -2
- package/dist/transitions/allocate.js +3 -1
- package/dist/transitions/archive.d.ts +1 -1
- package/dist/transitions/archive.js +3 -2
- package/dist/transitions/checkStart.d.ts +1 -0
- package/dist/transitions/checkStart.js +17 -6
- package/dist/transitions/decide.d.ts +1 -1
- package/dist/transitions/decide.js +5 -3
- package/dist/transitions/deleteExperiment.d.ts +2 -2
- package/dist/transitions/deleteExperiment.js +17 -7
- package/dist/transitions/kernel.d.ts +4 -0
- package/dist/transitions/kernel.js +9 -4
- package/dist/transitions/makeContent.d.ts +2 -1
- package/dist/transitions/makeContent.js +12 -8
- package/dist/transitions/nestedPlacementNames.d.ts +2 -2
- package/dist/transitions/nestedPlacementNames.js +4 -5
- 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/phaseRecord.d.ts +2 -0
- package/dist/transitions/phaseRecord.js +5 -0
- package/dist/transitions/placementInteractions.d.ts +3 -3
- package/dist/transitions/placementInteractions.js +8 -7
- package/dist/transitions/placements.d.ts +2 -0
- package/dist/transitions/placements.js +5 -5
- package/dist/transitions/preflightData.d.ts +3 -2
- package/dist/transitions/preflightData.js +77 -43
- package/dist/transitions/releaseHoldout.d.ts +2 -1
- package/dist/transitions/releaseHoldout.js +3 -1
- package/dist/transitions/releasePages.d.ts +2 -1
- package/dist/transitions/releasePages.js +3 -1
- package/dist/transitions/resolveCaps.d.ts +2 -4
- package/dist/transitions/start.d.ts +7 -9
- package/dist/transitions/start.js +75 -39
- package/dist/transitions/startReads.d.ts +7 -0
- package/dist/transitions/startReads.js +28 -0
- package/dist/transitions/stop.d.ts +2 -1
- package/dist/transitions/stop.js +3 -2
- package/dist/types/armKey.d.ts +2 -0
- package/dist/types/armKey.js +1 -0
- package/dist/types/contracts.d.ts +17 -4
- package/dist/types/endpoints.d.ts +89 -17
- package/dist/types/endpoints.js +1 -1
- package/dist/types/runtime.d.ts +15 -9
- package/dist/types/snapshot.d.ts +2 -0
- package/dist/types/surface.d.ts +7 -9
- package/dist/ui/ChipsInput.d.ts +8 -1
- package/dist/ui/ChipsInput.js +17 -4
- 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
|
-
/*#__PURE__*/ _jsx(StatusChip, {
|
|
36
|
-
status: doc.status
|
|
37
|
-
})
|
|
38
|
-
]
|
|
39
|
-
}) : undefined,
|
|
40
|
-
actions: doc && 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,
|
|
@@ -86,7 +86,7 @@ function copySlotBlocks(block, slot, field, config) {
|
|
|
86
86
|
], field, config)[0], slot);
|
|
87
87
|
}
|
|
88
88
|
export function syncExperimentSlots(block, arms, field, config = {}) {
|
|
89
|
-
const wanted = arms.filter((a)=>a.kind !== 'holdout' && a.key !== 'holdout').map((a)=>a.
|
|
89
|
+
const wanted = arms.filter((a)=>a.kind !== 'holdout' && a.key !== 'holdout').map((a)=>a.key).filter((slot)=>BLOCK_SLOTS.includes(slot));
|
|
90
90
|
const slots = [
|
|
91
91
|
...new Set(wanted)
|
|
92
92
|
].map((slot)=>block.slots.find((row)=>row.slot === slot) ?? {
|
|
@@ -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
|
}
|
|
@@ -44,16 +44,21 @@ export function experimentsCollection(options) {
|
|
|
44
44
|
},
|
|
45
45
|
access: {
|
|
46
46
|
...managedAccess(options),
|
|
47
|
-
delete: async ({ req })=>
|
|
47
|
+
delete: async ({ req, id })=>{
|
|
48
|
+
if (await options.access.manage({
|
|
48
49
|
req
|
|
49
|
-
})
|
|
50
|
+
}) !== true) return false;
|
|
51
|
+
// Single deletes report status through the locked beforeDelete guard.
|
|
52
|
+
// Payload catches per-document hook failures in bulk deletes, so keep their status filter in access.
|
|
53
|
+
return id != null ? true : {
|
|
50
54
|
status: {
|
|
51
55
|
in: [
|
|
52
56
|
'draft',
|
|
53
57
|
'archived'
|
|
54
58
|
]
|
|
55
59
|
}
|
|
56
|
-
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
57
62
|
},
|
|
58
63
|
admin: {
|
|
59
64
|
group: SURFACE_COPY.title,
|
|
@@ -3,8 +3,8 @@ import { xpOptionsFromReq } from '../../options/fromReq.js';
|
|
|
3
3
|
export const deleteGuard = async ({ req, id })=>{
|
|
4
4
|
await deleteExperiment(req, id);
|
|
5
5
|
};
|
|
6
|
-
export const deleteGuardAfter = async ({ req,
|
|
7
|
-
await deleteExperimentAfter(req
|
|
6
|
+
export const deleteGuardAfter = async ({ req, doc })=>{
|
|
7
|
+
await deleteExperimentAfter(req);
|
|
8
8
|
return doc;
|
|
9
9
|
};
|
|
10
10
|
export const deleteGuardBeforeOperation = async ({ operation, args, req })=>{
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { withSlotsFor } from '../../arms/model.js';
|
|
1
2
|
import { XpLockedFieldError, XpRefusal } from '../../errors.js';
|
|
2
3
|
import { XP_IF_UPDATED_AT_HEADER } from '../../constants.js';
|
|
3
4
|
import { txExecutor } from '../../db/executor.js';
|
|
@@ -64,6 +65,24 @@ const dates = new Set([
|
|
|
64
65
|
}
|
|
65
66
|
const same = (a, b, path)=>JSON.stringify(normalize(a, path)) === JSON.stringify(normalize(b, path));
|
|
66
67
|
export const lockHook = async ({ data, originalDoc, operation, req })=>{
|
|
68
|
+
const kind = operation === 'create' ? data.kind : originalDoc.kind;
|
|
69
|
+
const storedArms = operation === 'update' ? originalDoc.arms : undefined;
|
|
70
|
+
const canonicalSlots = (value)=>{
|
|
71
|
+
if (kind !== 'block' || !Array.isArray(value) || value.some((row)=>!isObject(row))) return value;
|
|
72
|
+
return withSlotsFor(value, 'block');
|
|
73
|
+
};
|
|
74
|
+
const canonicalArms = canonicalSlots(storedArms);
|
|
75
|
+
// Payload runs collection beforeChange before field validation on Create,
|
|
76
|
+
// Update and Restore. Derive slots here so the arms validator sees them.
|
|
77
|
+
const arms = data.arms === undefined ? storedArms : data.arms;
|
|
78
|
+
const repaired = arms === storedArms ? canonicalArms : canonicalSlots(arms);
|
|
79
|
+
if (repaired !== arms) {
|
|
80
|
+
if (operation === 'create') data = {
|
|
81
|
+
...data,
|
|
82
|
+
arms: repaired
|
|
83
|
+
};
|
|
84
|
+
else data.arms = repaired;
|
|
85
|
+
}
|
|
67
86
|
if (req.context.xpTransition === true) return data;
|
|
68
87
|
const baseline = req.headers.get(XP_IF_UPDATED_AT_HEADER);
|
|
69
88
|
if (operation === 'update' && baseline !== null) {
|
|
@@ -71,7 +90,7 @@ export const lockHook = async ({ data, originalDoc, operation, req })=>{
|
|
|
71
90
|
// so a competing save observes the preceding save's committed timestamp.
|
|
72
91
|
const stored = await lockExperimentUpdatedAt(txExecutor(req), originalDoc.id);
|
|
73
92
|
if (stored === null || new Date(baseline).getTime() !== new Date(stored).getTime()) {
|
|
74
|
-
throw new XpRefusal('stale-edit', '
|
|
93
|
+
throw new XpRefusal('stale-edit', 'This test changed. Read the latest settings and try again.', undefined, 409);
|
|
75
94
|
}
|
|
76
95
|
}
|
|
77
96
|
const admin = async ()=>{
|
|
@@ -139,7 +158,7 @@ export const lockHook = async ({ data, originalDoc, operation, req })=>{
|
|
|
139
158
|
].includes(field) && isObject(value)) {
|
|
140
159
|
for (const [key, nested] of Object.entries(value))await check(`${field}.${key}`, nested, originalDoc[field]?.[key]);
|
|
141
160
|
} else {
|
|
142
|
-
await check(field, value, originalDoc[field]);
|
|
161
|
+
await check(field, value, field === 'arms' ? canonicalArms : originalDoc[field]);
|
|
143
162
|
// Replacing the group also changes its method, including clearing it.
|
|
144
163
|
if (field === 'analysis' && !same(value, originalDoc.analysis, field) && originalDoc.analysis?.method != null && !await admin()) throw new XpLockedFieldError('analysis.method', status);
|
|
145
164
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { assertReadCommitted } from '../../db/adapter.js';
|
|
1
2
|
import { pickSlug } from '../../db/slugs.js';
|
|
2
3
|
import { pooledExecutor, txExecutor } from '../../db/executor.js';
|
|
3
4
|
export const pickExperimentSlug = async ({ req, data, operation })=>{
|
|
4
5
|
if (operation !== 'create' || typeof data.slug !== 'string' || !data.slug) return data;
|
|
5
6
|
const transactional = await req.transactionID != null;
|
|
7
|
+
if (transactional) await assertReadCommitted(req);
|
|
6
8
|
data.slug = await pickSlug(transactional ? txExecutor(req) : pooledExecutor(req.payload), data.slug, transactional);
|
|
7
9
|
return data;
|
|
8
10
|
};
|
|
@@ -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,3 +1,4 @@
|
|
|
1
|
+
import { assertReadCommitted } from '../db/adapter.js';
|
|
1
2
|
import { pooledExecutor, txExecutor } from '../db/executor.js';
|
|
2
3
|
import { findMetricUsage, lockMetricRow } from '../db/metricUsage.js';
|
|
3
4
|
/** Payload's REST formatter preserves public plugin errors and their 4xx status. */ export class XpGoalInUseError extends Error {
|
|
@@ -8,6 +9,7 @@ import { findMetricUsage, lockMetricRow } from '../db/metricUsage.js';
|
|
|
8
9
|
async function executor(req, id, mode) {
|
|
9
10
|
const transactionID = await req.transactionID;
|
|
10
11
|
if (transactionID != null) {
|
|
12
|
+
await assertReadCommitted(req);
|
|
11
13
|
const exec = txExecutor(req);
|
|
12
14
|
await lockMetricRow(exec, id, mode);
|
|
13
15
|
return exec;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { browserWritableMetric } from '../events/writable.js';
|
|
2
|
+
import { goalSourceLabel } from '../goals/sourceLabel.js';
|
|
1
3
|
export function serializeFlagPoints(options) {
|
|
2
4
|
return (options.flagPoints ?? []).map(({ id, label, description, params, defaultParams })=>({
|
|
3
5
|
id,
|
|
@@ -19,19 +21,19 @@ export function serializeMetricSources(options) {
|
|
|
19
21
|
keyedBy: 'visitor',
|
|
20
22
|
clientWritable: true
|
|
21
23
|
},
|
|
22
|
-
...(options.metricSources ?? []).map(({ id, label, kind, keyedBy
|
|
24
|
+
...(options.metricSources ?? []).map(({ id, label, kind, keyedBy })=>({
|
|
23
25
|
id,
|
|
24
|
-
label,
|
|
26
|
+
label: label?.trim() || goalSourceLabel(id),
|
|
25
27
|
kind,
|
|
26
28
|
keyedBy,
|
|
27
|
-
clientWritable:
|
|
29
|
+
clientWritable: browserWritableMetric(id, options)
|
|
28
30
|
})),
|
|
29
|
-
...(options.eventSources ?? []).map(({ name
|
|
31
|
+
...(options.eventSources ?? []).map(({ name })=>({
|
|
30
32
|
id: `events:${name}`,
|
|
31
|
-
label: name,
|
|
33
|
+
label: goalSourceLabel(name),
|
|
32
34
|
kind: 'binomial',
|
|
33
35
|
keyedBy: 'visitor',
|
|
34
|
-
clientWritable
|
|
36
|
+
clientWritable: browserWritableMetric(`events:${name}`, options)
|
|
35
37
|
}))
|
|
36
38
|
];
|
|
37
39
|
}
|
package/dist/constants.d.ts
CHANGED
|
@@ -7,3 +7,4 @@ export declare const XP_PREVIEW_PARAM = "xp_preview";
|
|
|
7
7
|
export declare const XP_MANIFEST_KEY_HEADER = "x-xp-manifest-key";
|
|
8
8
|
export declare const XP_REQUEST_HEADER = "x-xp-request";
|
|
9
9
|
export declare const XP_IF_UPDATED_AT_HEADER = "x-xp-if-updated-at";
|
|
10
|
+
export declare const USER_BROWSER_CONVERSION_PREFIX = "conversion:cu:";
|
package/dist/constants.js
CHANGED
|
@@ -7,3 +7,4 @@ export const XP_PREVIEW_PARAM = 'xp_preview';
|
|
|
7
7
|
export const XP_MANIFEST_KEY_HEADER = 'x-xp-manifest-key';
|
|
8
8
|
export const XP_REQUEST_HEADER = 'x-xp-request';
|
|
9
9
|
export const XP_IF_UPDATED_AT_HEADER = 'x-xp-if-updated-at';
|
|
10
|
+
export const USER_BROWSER_CONVERSION_PREFIX = 'conversion:cu:';
|
package/dist/db/adapter.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { APIError, type Payload, type PayloadRequest } from 'payload';
|
|
2
|
+
export declare class XpTransactionIsolationError extends APIError {
|
|
3
|
+
constructor();
|
|
4
|
+
}
|
|
5
|
+
/** Payload's initTransaction cannot pass options to the adapter. Like that
|
|
6
|
+
* helper, publish the pending transaction on the request before awaiting it.
|
|
7
|
+
*/
|
|
8
|
+
export declare function initTransitionTransaction(req: PayloadRequest): Promise<boolean>;
|
|
9
|
+
export declare function assertReadCommitted(req: PayloadRequest): Promise<void>;
|
|
2
10
|
export declare function assertPostgresAdapter(payload: Payload): void;
|
|
3
11
|
export declare function probeTransactions(payload: Payload): Promise<void>;
|