@delmaredigital/payload-experiments 0.3.0-rc.4 → 0.4.0-rc.10
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 +293 -688
- package/dist/admin/LayerUsage.js +1 -1
- package/dist/admin/MetricSourceSelect.js +4 -4
- package/dist/admin/PlacementStatus.d.ts +3 -0
- package/dist/admin/PlacementStatus.js +54 -0
- package/dist/admin/TestsDashboardCards.d.ts +1 -0
- package/dist/admin/TestsDashboardCards.js +5 -9
- package/dist/admin/TestsNavLink.d.ts +1 -0
- package/dist/admin/TestsNavLink.js +5 -11
- package/dist/admin/blocks/BlockPanel.d.ts +5 -0
- package/dist/admin/blocks/BlockPanel.js +245 -0
- package/dist/admin/blocks/TestBlockField.d.ts +5 -0
- package/dist/admin/blocks/TestBlockField.js +163 -0
- package/dist/admin/blocks/formApi.d.ts +46 -0
- package/dist/admin/blocks/formApi.js +159 -0
- package/dist/admin/blocks/inject.d.ts +7 -0
- package/dist/admin/blocks/inject.js +42 -0
- package/dist/admin/blocks/model.d.ts +18 -0
- package/dist/admin/blocks/model.js +49 -0
- package/dist/admin/blocks/statusCache.d.ts +9 -0
- package/dist/admin/blocks/statusCache.js +92 -0
- package/dist/admin/blocks/useBlockForm.d.ts +17 -0
- package/dist/admin/blocks/useBlockForm.js +46 -0
- package/dist/admin/components/RootViewMessage.js +1 -1
- package/dist/admin/copy/blocks.d.ts +47 -0
- package/dist/admin/copy/blocks.js +72 -0
- package/dist/admin/copy/goals.d.ts +8 -1
- package/dist/admin/copy/goals.js +14 -4
- package/dist/admin/copy/newTest.d.ts +13 -4
- package/dist/admin/copy/newTest.js +16 -4
- package/dist/admin/goals/XpGoalField.d.ts +4 -0
- package/dist/admin/goals/XpGoalField.js +194 -0
- package/dist/admin/goals/xpGoalField.css +47 -0
- package/dist/admin/pageCollections.d.ts +11 -0
- package/dist/admin/pageCollections.js +23 -0
- package/dist/admin/paths.d.ts +9 -0
- package/dist/admin/paths.js +9 -0
- package/dist/admin/placementStatus.model.d.ts +2 -0
- package/dist/admin/placementStatus.model.js +19 -0
- package/dist/admin/status.model.js +1 -1
- package/dist/admin/surface/ResultsRoute.d.ts +2 -1
- package/dist/admin/surface/ResultsRoute.js +20 -24
- package/dist/admin/surface/SurfaceShell.js +5 -2
- package/dist/admin/surface/TestRowMenu.d.ts +6 -0
- package/dist/admin/surface/TestRowMenu.js +156 -0
- package/dist/admin/surface/TestsHome.d.ts +5 -3
- package/dist/admin/surface/TestsHome.js +298 -59
- package/dist/admin/surface/TestsSurface.js +13 -8
- package/dist/admin/surface/goals/GoalForm.d.ts +1 -1
- package/dist/admin/surface/goals/GoalForm.js +159 -85
- package/dist/admin/surface/goals/GoalsList.d.ts +1 -1
- package/dist/admin/surface/goals/GoalsList.js +7 -6
- package/dist/admin/surface/goals/data.js +6 -3
- package/dist/admin/surface/goals/goals.css +7 -0
- package/dist/admin/surface/goals/goals.model.d.ts +12 -3
- package/dist/admin/surface/goals/goals.model.js +43 -2
- package/dist/admin/surface/home.model.d.ts +9 -8
- package/dist/admin/surface/home.model.js +28 -23
- package/dist/admin/surface/newTest/NewTest.d.ts +4 -4
- package/dist/admin/surface/newTest/NewTest.js +146 -101
- package/dist/admin/surface/newTest/PageWizard.d.ts +8 -0
- package/dist/admin/surface/newTest/PageWizard.js +244 -0
- package/dist/admin/surface/newTest/newTest.css +28 -9
- package/dist/admin/surface/results/ResultsHeader.d.ts +2 -2
- package/dist/admin/surface/results/ResultsHeader.js +58 -57
- package/dist/admin/surface/surface.css +10 -0
- package/dist/admin/surface/test/TestPage.d.ts +1 -2
- package/dist/admin/surface/test/TestPage.js +42 -161
- package/dist/admin/theme.css +2 -0
- package/dist/admin/views/CollectionListRedirect.d.ts +1 -0
- package/dist/admin/views/CollectionListRedirect.js +1 -1
- package/dist/admin/views/ExperimentsRootView.js +28 -133
- package/dist/admin/views/GoalEditRedirect.d.ts +4 -0
- package/dist/admin/views/GoalEditRedirect.js +14 -0
- package/dist/admin/views/GoalsCollectionListView.d.ts +2 -0
- package/dist/admin/views/GoalsCollectionListView.js +4 -0
- package/dist/admin/views/TestsCollectionListView.d.ts +2 -0
- package/dist/admin/views/TestsCollectionListView.js +4 -0
- package/dist/admin/views/TestsNavLinkServer.d.ts +1 -0
- package/dist/admin/views/TestsNavLinkServer.js +2 -2
- package/dist/admin/views/TestsSurfaceClient.d.ts +3 -0
- package/dist/admin/views/TestsSurfaceClient.js +11 -0
- package/dist/admin/views/buildSurfaceProps.d.ts +8 -0
- package/dist/admin/views/buildSurfaceProps.js +102 -0
- package/dist/admin/views/renderCollectionList.d.ts +2 -0
- package/dist/admin/views/renderCollectionList.js +34 -0
- package/dist/admin/views/renderTestsSurface.d.ts +3 -0
- package/dist/admin/views/renderTestsSurface.js +34 -0
- package/dist/blocks/bindings.d.ts +3 -0
- package/dist/blocks/bindings.js +28 -0
- package/dist/blocks/createExperimentBlock.d.ts +6 -0
- package/dist/blocks/createExperimentBlock.js +77 -0
- package/dist/blocks/formState.d.ts +31 -0
- package/dist/blocks/formState.js +146 -0
- package/dist/blocks/model.d.ts +41 -0
- package/dist/blocks/model.js +34 -0
- package/dist/blocks/placementLanguages.d.ts +7 -0
- package/dist/blocks/placementLanguages.js +27 -0
- package/dist/blocks/placementLocale.d.ts +37 -0
- package/dist/blocks/placementLocale.js +270 -0
- package/dist/client/ExperimentGroup.d.ts +6 -0
- package/dist/client/ExperimentGroup.js +9 -0
- package/dist/client/ExperimentsProvider.js +20 -4
- package/dist/client/clickGoals.d.ts +4 -0
- package/dist/client/clickGoals.js +43 -0
- package/dist/collections/experiments/config.js +29 -10
- package/dist/collections/experiments/deleteGuard.d.ts +2 -1
- package/dist/collections/experiments/deleteGuard.js +14 -3
- package/dist/collections/experiments/editability.js +4 -2
- package/dist/collections/experiments/lockHook.js +21 -2
- package/dist/collections/experiments/pickSlug.d.ts +2 -0
- package/dist/collections/experiments/pickSlug.js +10 -0
- package/dist/collections/labels.d.ts +3 -0
- package/dist/collections/labels.js +20 -0
- package/dist/collections/metrics.js +28 -6
- package/dist/collections/metricsGuards.js +2 -0
- package/dist/collections/phases.js +1 -0
- package/dist/collections/serialize.js +12 -4
- 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/appends.d.ts +13 -0
- package/dist/db/appends.js +49 -0
- package/dist/db/bulkPlacementRemoval.d.ts +30 -0
- package/dist/db/bulkPlacementRemoval.js +111 -0
- package/dist/db/clickGoals.d.ts +9 -0
- package/dist/db/clickGoals.js +22 -0
- package/dist/db/delete.d.ts +2 -1
- package/dist/db/delete.js +3 -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/locks.d.ts +8 -0
- package/dist/db/locks.js +27 -4
- package/dist/db/names.d.ts +4 -0
- package/dist/db/names.js +4 -0
- package/dist/db/pageBindings.d.ts +4 -0
- package/dist/db/pageBindings.js +17 -0
- package/dist/db/pageBusy.d.ts +2 -0
- package/dist/db/pageBusy.js +10 -0
- package/dist/db/pageContent.d.ts +10 -0
- package/dist/db/pageContent.js +79 -0
- package/dist/db/pageCopies.d.ts +5 -0
- package/dist/db/pageCopies.js +31 -0
- package/dist/db/placements.d.ts +35 -0
- package/dist/db/placements.js +62 -0
- package/dist/db/results.d.ts +5 -1
- package/dist/db/results.js +21 -5
- package/dist/db/slugs.d.ts +8 -0
- package/dist/db/slugs.js +40 -0
- package/dist/db/snapshots.d.ts +7 -0
- package/dist/db/snapshots.js +8 -5
- package/dist/endpoints/clickKeys.d.ts +5 -0
- package/dist/endpoints/clickKeys.js +17 -0
- package/dist/endpoints/contentLocale.d.ts +6 -0
- package/dist/endpoints/contentLocale.js +15 -0
- package/dist/endpoints/deleteImpact.d.ts +6 -0
- package/dist/endpoints/deleteImpact.js +207 -0
- package/dist/endpoints/duplicateOriginal.d.ts +38 -0
- package/dist/endpoints/duplicateOriginal.js +407 -0
- package/dist/endpoints/editorSurface.d.ts +3 -0
- package/dist/endpoints/editorSurface.js +31 -0
- package/dist/endpoints/events.js +106 -39
- package/dist/endpoints/index.js +85 -9
- package/dist/endpoints/pages.d.ts +5 -0
- package/dist/endpoints/pages.js +303 -0
- package/dist/endpoints/placementStatus.d.ts +6 -0
- package/dist/endpoints/placementStatus.js +246 -0
- package/dist/endpoints/preflight.d.ts +1 -1
- package/dist/endpoints/preflight.js +17 -2
- package/dist/endpoints/readBody.d.ts +2 -0
- package/dist/endpoints/readBody.js +24 -0
- package/dist/endpoints/results.d.ts +1 -1
- package/dist/endpoints/results.js +10 -2
- package/dist/endpoints/routeId.d.ts +2 -2
- package/dist/endpoints/routeId.js +11 -5
- package/dist/endpoints/summary.js +46 -5
- package/dist/endpoints/testVersion.d.ts +2 -0
- package/dist/endpoints/testVersion.js +38 -0
- package/dist/endpoints/transitions.js +41 -29
- package/dist/endpoints/wrapBlock.d.ts +6 -0
- package/dist/endpoints/wrapBlock.js +76 -0
- package/dist/errors.d.ts +7 -2
- package/dist/errors.js +11 -3
- 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 +25 -7
- package/dist/events/writable.d.ts +9 -0
- package/dist/events/writable.js +13 -0
- package/dist/exports/adminClient.d.ts +6 -1
- package/dist/exports/adminClient.js +6 -1
- package/dist/exports/adminRsc.d.ts +3 -0
- package/dist/exports/adminRsc.js +3 -0
- package/dist/exports/blocks.d.ts +2 -0
- package/dist/exports/blocks.js +1 -0
- package/dist/exports/client.d.ts +1 -0
- package/dist/exports/client.js +1 -0
- package/dist/exports/index.d.ts +6 -1
- package/dist/exports/index.js +3 -0
- package/dist/exports/puck.d.ts +3 -1
- package/dist/exports/puck.js +2 -0
- package/dist/exports/puckEditor.d.ts +3 -0
- package/dist/exports/puckEditor.js +2 -0
- package/dist/exports/rsc.d.ts +4 -0
- package/dist/exports/rsc.js +3 -0
- package/dist/fields/xpGoal.d.ts +3 -0
- package/dist/fields/xpGoal.js +16 -0
- package/dist/globals/state.js +10 -0
- package/dist/goals/cache.d.ts +3 -0
- package/dist/goals/cache.js +35 -0
- package/dist/goals/fairness.d.ts +40 -0
- package/dist/goals/fairness.js +209 -0
- package/dist/goals/key.d.ts +4 -0
- package/dist/goals/key.js +3 -0
- package/dist/goals/picker/clickGoalPicker.model.d.ts +36 -0
- package/dist/goals/picker/clickGoalPicker.model.js +63 -0
- package/dist/goals/picker/copy.d.ts +20 -0
- package/dist/goals/picker/copy.js +24 -0
- package/dist/goals/picker/useClickGoalPicker.d.ts +30 -0
- package/dist/goals/picker/useClickGoalPicker.js +222 -0
- package/dist/goals/validate.d.ts +3 -0
- package/dist/goals/validate.js +15 -0
- package/dist/hooks/blockRemovalRule.d.ts +30 -0
- package/dist/hooks/blockRemovalRule.js +165 -0
- package/dist/hooks/hostHook.js +6 -2
- package/dist/hooks/pageGuard.d.ts +30 -1
- package/dist/hooks/pageGuard.js +337 -107
- package/dist/hooks/puckGoals.d.ts +5 -0
- package/dist/hooks/puckGoals.js +62 -0
- package/dist/hooks/puckNestedTests.d.ts +8 -0
- package/dist/hooks/puckNestedTests.js +36 -0
- package/dist/hooks/trackPageCopies.d.ts +11 -0
- package/dist/hooks/trackPageCopies.js +7 -0
- package/dist/lib/fetchAllDocs.d.ts +1 -1
- package/dist/lib/placementPages.d.ts +10 -0
- package/dist/{admin/previewLinks.model.js → lib/placementPages.js} +10 -5
- package/dist/manifest/compile.d.ts +2 -1
- package/dist/manifest/compile.js +13 -6
- package/dist/onInit.js +65 -0
- package/dist/options.d.ts +4 -0
- package/dist/options.js +62 -1
- package/dist/plugin.js +56 -44
- 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/ExperimentPicker.d.ts +2 -1
- package/dist/puck/ExperimentPicker.js +62 -40
- package/dist/puck/ExperimentSlot.js +3 -1
- package/dist/puck/copy.d.ts +6 -1
- package/dist/puck/copy.js +6 -1
- package/dist/puck/editor/ConfigureTestDrawer.d.ts +25 -0
- package/dist/puck/editor/ConfigureTestDrawer.js +150 -0
- package/dist/puck/editor/CreateExperimentDrawer.d.ts +12 -2
- package/dist/puck/editor/CreateExperimentDrawer.js +89 -21
- package/dist/puck/editor/EditorControls.d.ts +14 -0
- package/dist/puck/editor/EditorControls.js +99 -0
- package/dist/puck/editor/ExperimentSlotEditor.js +951 -179
- package/dist/puck/editor/LeftoverVersions.d.ts +15 -0
- package/dist/puck/editor/LeftoverVersions.js +79 -0
- package/dist/puck/editor/PlacementNotice.d.ts +8 -0
- package/dist/puck/editor/PlacementNotice.js +22 -0
- package/dist/puck/editor/QuickTestActions.d.ts +6 -0
- package/dist/puck/editor/QuickTestActions.js +57 -0
- package/dist/puck/editor/ResultsReadout.d.ts +2 -1
- package/dist/puck/editor/ResultsReadout.js +10 -6
- package/dist/puck/editor/VersionBuilder.d.ts +66 -12
- package/dist/puck/editor/VersionBuilder.js +554 -231
- package/dist/puck/editor/armWrites.d.ts +11 -2
- package/dist/puck/editor/armWrites.js +43 -4
- package/dist/puck/editor/armsCache.d.ts +3 -1
- package/dist/puck/editor/armsCache.js +20 -4
- package/dist/puck/editor/blockClipboard.d.ts +16 -0
- package/dist/puck/editor/blockClipboard.js +20 -0
- package/dist/puck/editor/cloneSlot.d.ts +2 -0
- package/dist/puck/editor/cloneSlot.js +7 -0
- package/dist/puck/editor/copy.d.ts +64 -19
- package/dist/puck/editor/copy.js +72 -20
- package/dist/puck/editor/createTest.d.ts +3 -0
- package/dist/puck/editor/createTest.js +33 -0
- package/dist/puck/editor/editor.chrome.css +192 -19
- package/dist/puck/editor/editor.css +329 -24
- package/dist/puck/editor/editor.model.d.ts +21 -3
- package/dist/puck/editor/editor.model.js +67 -7
- package/dist/puck/editor/editorSurface.d.ts +10 -0
- package/dist/puck/editor/editorSurface.js +65 -0
- package/dist/puck/editor/experimentOutlinePlugin.js +96 -28
- package/dist/puck/editor/integration.d.ts +10 -0
- package/dist/puck/editor/integration.js +30 -0
- package/dist/puck/editor/localPlacements.d.ts +5 -0
- package/dist/puck/editor/localPlacements.js +43 -0
- package/dist/puck/editor/outlineVersion.d.ts +5 -0
- package/dist/puck/editor/outlineVersion.js +36 -0
- package/dist/puck/editor/placementsCache.d.ts +60 -0
- package/dist/puck/editor/placementsCache.js +263 -0
- package/dist/puck/editor/sidebar.d.ts +8 -0
- package/dist/puck/editor/sidebar.js +74 -0
- package/dist/puck/editor/usePageSaveReadiness.d.ts +6 -0
- package/dist/puck/editor/usePageSaveReadiness.js +31 -0
- package/dist/puck/editor/usePlacementNotice.d.ts +3 -0
- package/dist/puck/editor/usePlacementNotice.js +15 -0
- package/dist/puck/editor/xpGoalPuckEditorField.d.ts +7 -0
- package/dist/puck/editor/xpGoalPuckEditorField.js +153 -0
- package/dist/puck/experimentSlotField.d.ts +3 -0
- package/dist/puck/experimentSlotField.js +15 -4
- package/dist/puck/experimentSlug.d.ts +2 -0
- package/dist/puck/experimentSlug.js +3 -0
- package/dist/puck/integration.d.ts +6 -0
- package/dist/puck/integration.js +21 -0
- package/dist/puck/nestedTestCopy.d.ts +8 -0
- package/dist/puck/nestedTestCopy.js +22 -0
- package/dist/puck/nestedTests.d.ts +17 -0
- package/dist/puck/nestedTests.js +30 -0
- package/dist/puck/slotConfig.d.ts +1 -1
- package/dist/puck/slotConfig.js +17 -4
- package/dist/puck/visibility.d.ts +20 -0
- package/dist/puck/visibility.js +81 -0
- package/dist/puck/xpGoalField.d.ts +3 -0
- package/dist/puck/xpGoalField.js +6 -0
- package/dist/results/aggregate.d.ts +6 -3
- package/dist/results/aggregate.js +9 -9
- package/dist/results/health.d.ts +12 -0
- package/dist/results/health.js +55 -0
- package/dist/results/identityCredit.d.ts +1 -0
- package/dist/results/identityCredit.js +4 -1
- package/dist/results/snapshot.js +15 -2
- package/dist/results/verdict.js +2 -1
- 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 +63 -2
- package/dist/server/getAssignments.js +11 -10
- package/dist/server/pageKindSeoContract.d.ts +27 -0
- package/dist/server/pageKindSeoContract.js +80 -0
- package/dist/server/recordContentChange.d.ts +1 -1
- package/dist/server/recordContentChange.js +88 -12
- package/dist/server/resolveExperimentBlocks.d.ts +5 -0
- package/dist/server/resolveExperimentBlocks.js +52 -0
- package/dist/server/resolveExperimentData.js +8 -8
- package/dist/server/runResults.js +104 -25
- package/dist/server/startExperiment.d.ts +20 -0
- package/dist/server/startExperiment.js +70 -0
- package/dist/server/toClientAssignments.js +2 -1
- package/dist/server/trackConversion.js +10 -13
- package/dist/{admin → testSurface}/PreviewLinks.d.ts +2 -1
- package/dist/{admin → testSurface}/PreviewLinks.js +8 -4
- package/dist/testSurface/actions/DecideDialog.d.ts +16 -0
- package/dist/{admin → testSurface}/actions/DecideDialog.js +79 -56
- package/dist/testSurface/actions/LifecycleAction.d.ts +16 -0
- package/dist/testSurface/actions/LifecycleAction.js +105 -0
- package/dist/{admin → testSurface}/actions/MakeContentResult.d.ts +4 -3
- package/dist/{admin → testSurface}/actions/MakeContentResult.js +10 -2
- package/dist/{admin → testSurface}/actions/actions.model.d.ts +13 -5
- package/dist/testSurface/actions/actions.model.js +122 -0
- package/dist/testSurface/api.d.ts +60 -0
- package/dist/testSurface/api.js +167 -0
- package/dist/testSurface/contentLocaleURL.d.ts +2 -0
- package/dist/testSurface/contentLocaleURL.js +3 -0
- package/dist/{admin → testSurface}/copy/actions.d.ts +30 -8
- package/dist/{admin → testSurface}/copy/actions.js +40 -11
- package/dist/{admin → testSurface}/copy/common.d.ts +13 -4
- package/dist/{admin → testSurface}/copy/common.js +18 -8
- package/dist/testSurface/copy/languages.d.ts +12 -0
- package/dist/testSurface/copy/languages.js +8 -0
- package/dist/{admin → testSurface}/copy/metrics.d.ts +1 -0
- package/dist/{admin → testSurface}/copy/metrics.js +1 -0
- package/dist/testSurface/copy/pages.d.ts +84 -0
- package/dist/testSurface/copy/pages.js +90 -0
- package/dist/{admin → testSurface}/copy/readiness.d.ts +59 -6
- package/dist/testSurface/copy/readiness.js +136 -0
- package/dist/{admin → testSurface}/copy/results.d.ts +7 -3
- package/dist/{admin → testSurface}/copy/results.js +7 -3
- package/dist/{admin → testSurface}/copy/review.d.ts +1 -1
- package/dist/{admin → testSurface}/copy/review.js +1 -1
- package/dist/{admin → testSurface}/copy/surface.d.ts +11 -2
- package/dist/{admin → testSurface}/copy/surface.js +13 -10
- package/dist/{admin → testSurface}/copy/testPage.d.ts +56 -7
- package/dist/testSurface/copy/testPage.js +165 -0
- package/dist/testSurface/format/adminURL.d.ts +7 -0
- package/dist/testSurface/format/adminURL.js +9 -0
- package/dist/{admin → testSurface}/metricSource.model.d.ts +2 -0
- package/dist/{admin → testSurface}/metricSource.model.js +4 -0
- package/dist/testSurface/placementLabel.d.ts +8 -0
- package/dist/testSurface/placementLabel.js +24 -0
- package/dist/testSurface/placements/placementLabels.d.ts +13 -0
- package/dist/testSurface/placements/placementLabels.js +22 -0
- package/dist/testSurface/placements/placementLabels.model.d.ts +13 -0
- package/dist/testSurface/placements/placementLabels.model.js +12 -0
- package/dist/testSurface/placements/usePlacementLabels.d.ts +12 -0
- package/dist/testSurface/placements/usePlacementLabels.js +102 -0
- package/dist/{admin → testSurface}/previewLinks.model.d.ts +1 -6
- package/dist/testSurface/previewLinks.model.js +4 -0
- package/dist/testSurface/readPreflight.d.ts +13 -0
- package/dist/testSurface/readPreflight.js +44 -0
- package/dist/testSurface/readinessRead.d.ts +53 -0
- package/dist/testSurface/readinessRead.js +50 -0
- package/dist/{admin → testSurface}/results/DataQualityPanel.js +4 -1
- package/dist/{admin → testSurface}/results/VerdictHero.d.ts +2 -1
- package/dist/{admin → testSurface}/results/VerdictHero.js +5 -1
- package/dist/testSurface/results/results.css +64 -0
- package/dist/{admin → testSurface}/results/results.model.d.ts +3 -0
- package/dist/{admin → testSurface}/results/results.model.js +14 -6
- package/dist/{admin → testSurface}/surface/contracts.d.ts +23 -8
- package/dist/testSurface/surface/editorPlacement.d.ts +26 -0
- package/dist/testSurface/surface/editorPlacement.js +78 -0
- package/dist/testSurface/surface/pageBlock/pageBlock.model.js +9 -0
- package/dist/{admin → testSurface}/surface/pageBlock/parts.js +39 -11
- package/dist/testSurface/surface/pagePicker/CopyRoute.d.ts +13 -0
- package/dist/testSurface/surface/pagePicker/CopyRoute.js +273 -0
- package/dist/testSurface/surface/pagePicker/PageCombobox.d.ts +21 -0
- package/dist/testSurface/surface/pagePicker/PageCombobox.js +503 -0
- package/dist/testSurface/surface/pagePicker/pagePicker.css +73 -0
- package/dist/testSurface/surface/pagePicker/pagePicker.model.d.ts +29 -0
- package/dist/testSurface/surface/pagePicker/pagePicker.model.js +40 -0
- package/dist/{admin → testSurface}/surface/readiness/ActionDialogs.d.ts +8 -4
- package/dist/testSurface/surface/readiness/ActionDialogs.js +351 -0
- package/dist/{admin → testSurface}/surface/readiness/Banner.d.ts +2 -3
- package/dist/testSurface/surface/readiness/Banner.js +187 -0
- package/dist/testSurface/surface/readiness/BlockerList.d.ts +11 -0
- package/dist/testSurface/surface/readiness/BlockerList.js +31 -0
- package/dist/testSurface/surface/readiness/SaveStatus.d.ts +10 -0
- package/dist/testSurface/surface/readiness/SaveStatus.js +66 -0
- package/dist/{admin → testSurface}/surface/readiness/parts.js +0 -2
- package/dist/testSurface/surface/readiness/readiness.model.d.ts +57 -0
- package/dist/testSurface/surface/readiness/readiness.model.js +377 -0
- package/dist/testSurface/surface/readiness/useTransition.d.ts +16 -0
- package/dist/testSurface/surface/readiness/useTransition.js +141 -0
- package/dist/testSurface/surface/results/ReleasePages.d.ts +19 -0
- package/dist/{admin → testSurface}/surface/results/ReleasePages.js +43 -47
- package/dist/{admin → testSurface}/surface/results/ResultsBody.d.ts +7 -3
- package/dist/{admin → testSurface}/surface/results/ResultsBody.js +129 -46
- package/dist/{admin → testSurface}/surface/results/useResults.d.ts +36 -9
- package/dist/{admin → testSurface}/surface/results/useResults.js +3 -2
- package/dist/{admin → testSurface}/surface/setting/parts.js +58 -18
- package/dist/testSurface/surface/setting/setting.css +17 -0
- package/dist/testSurface/surface/test/AdvancedSection.js +169 -0
- package/dist/testSurface/surface/test/DeleteTest.d.ts +23 -0
- package/dist/testSurface/surface/test/DeleteTest.js +270 -0
- package/dist/testSurface/surface/test/GoalSection.d.ts +4 -0
- package/dist/testSurface/surface/test/GoalSection.js +341 -0
- package/dist/testSurface/surface/test/LengthSection.d.ts +2 -0
- package/dist/{admin → testSurface}/surface/test/LengthSection.js +6 -2
- package/dist/testSurface/surface/test/PageHoldout.d.ts +3 -0
- package/dist/testSurface/surface/test/PageHoldout.js +70 -0
- package/dist/{admin → testSurface}/surface/test/Rail.js +7 -4
- package/dist/{admin → testSurface}/surface/test/ReadinessBar.d.ts +1 -0
- package/dist/{admin → testSurface}/surface/test/ReadinessBar.js +2 -3
- package/dist/{admin → testSurface}/surface/test/Section.d.ts +3 -1
- package/dist/testSurface/surface/test/Section.js +80 -0
- package/dist/{admin → testSurface}/surface/test/TargetingSection.js +82 -12
- package/dist/testSurface/surface/test/TestSurface.d.ts +19 -0
- package/dist/testSurface/surface/test/TestSurface.js +265 -0
- package/dist/testSurface/surface/test/VersionsSection.d.ts +5 -0
- package/dist/{admin → testSurface}/surface/test/VersionsSection.js +81 -40
- package/dist/{admin → testSurface}/surface/test/fields.d.ts +40 -8
- package/dist/testSurface/surface/test/fields.js +306 -0
- package/dist/{admin → testSurface}/surface/test/jumpToSection.d.ts +1 -1
- package/dist/{admin → testSurface}/surface/test/jumpToSection.js +4 -3
- package/dist/testSurface/surface/test/pageParts.d.ts +5 -0
- package/dist/testSurface/surface/test/pageParts.js +106 -0
- package/dist/testSurface/surface/test/testPage.css +103 -0
- package/dist/{admin → testSurface}/surface/test/testPage.model.d.ts +1 -0
- package/dist/{admin → testSurface}/surface/test/testPage.model.js +6 -0
- package/dist/{admin → testSurface}/surface/testDocument.model.d.ts +4 -0
- package/dist/{admin → testSurface}/surface/testDocument.model.js +6 -2
- package/dist/testSurface/surface/useTestDocument.d.ts +60 -0
- package/dist/testSurface/surface/useTestDocument.js +782 -0
- package/dist/testSurface/surface/watchTestDocument.d.ts +15 -0
- package/dist/testSurface/surface/watchTestDocument.js +181 -0
- package/dist/testSurface/surfaceUrls.d.ts +7 -0
- package/dist/testSurface/surfaceUrls.js +19 -0
- package/dist/testSurface/useApi.d.ts +60 -0
- package/dist/testSurface/useApi.js +8 -0
- package/dist/testSurface/useOnTestReturn.d.ts +2 -0
- package/dist/testSurface/useOnTestReturn.js +27 -0
- package/dist/testSurface/useReadinessPolling.d.ts +3 -0
- package/dist/testSurface/useReadinessPolling.js +26 -0
- package/dist/transitions/addMetric.d.ts +4 -6
- package/dist/transitions/addMetric.js +33 -2
- 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 +18 -1
- package/dist/transitions/checkStart.js +207 -9
- package/dist/transitions/contentFields.js +9 -5
- package/dist/transitions/decide.d.ts +1 -1
- package/dist/transitions/decide.js +30 -3
- package/dist/transitions/deleteExperiment.d.ts +5 -3
- package/dist/transitions/deleteExperiment.js +43 -7
- package/dist/transitions/kernel.d.ts +4 -0
- package/dist/transitions/kernel.js +13 -4
- package/dist/transitions/makeContent.d.ts +7 -1
- package/dist/transitions/makeContent.js +74 -22
- package/dist/transitions/nestedPlacementNames.d.ts +5 -0
- package/dist/transitions/nestedPlacementNames.js +32 -0
- package/dist/transitions/pageAddress.d.ts +6 -0
- package/dist/transitions/pageAddress.js +71 -0
- package/dist/transitions/pageCollection.d.ts +10 -0
- package/dist/transitions/pageCollection.js +20 -0
- package/dist/transitions/pageVersions.d.ts +10 -0
- package/dist/transitions/pageVersions.js +46 -0
- package/dist/transitions/phaseRecord.d.ts +3 -0
- package/dist/transitions/phaseRecord.js +5 -0
- package/dist/transitions/placementInteractions.d.ts +40 -0
- package/dist/transitions/placementInteractions.js +98 -0
- package/dist/transitions/placements.d.ts +58 -4
- package/dist/transitions/placements.js +391 -21
- package/dist/transitions/preflightData.d.ts +7 -5
- package/dist/transitions/preflightData.js +269 -40
- 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 +3 -4
- package/dist/transitions/resolveCaps.js +6 -2
- package/dist/transitions/start.d.ts +6 -8
- package/dist/transitions/start.js +112 -31
- 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/admin.d.ts +1 -1
- package/dist/types/assignments.d.ts +1 -0
- package/dist/types/contracts.d.ts +30 -3
- package/dist/types/endpoints.d.ts +204 -13
- package/dist/types/index.d.ts +3 -0
- package/dist/types/puck.d.ts +8 -1
- package/dist/types/runtime.d.ts +15 -9
- package/dist/types/snapshot.d.ts +19 -4
- package/dist/types/surface.d.ts +20 -7
- package/dist/ui/Button.js +2 -2
- package/dist/ui/Card.d.ts +2 -1
- package/dist/ui/Card.js +4 -4
- package/dist/ui/ChipsInput.d.ts +8 -1
- package/dist/ui/ChipsInput.js +17 -4
- package/dist/ui/Dialog.d.ts +24 -2
- package/dist/ui/Dialog.js +116 -6
- package/dist/ui/Drawer.d.ts +10 -0
- package/dist/ui/Drawer.js +29 -0
- package/dist/ui/Inputs.d.ts +4 -3
- package/dist/ui/Inputs.js +7 -4
- package/dist/ui/SelectControl.d.ts +33 -0
- package/dist/ui/SelectControl.js +504 -0
- package/dist/ui/Tabs.d.ts +4 -4
- package/dist/ui/Tabs.js +35 -32
- package/dist/ui/ui.css +49 -5
- package/package.json +9 -1
- package/dist/admin/actions/ConfirmDialog.d.ts +0 -18
- package/dist/admin/actions/ConfirmDialog.js +0 -149
- package/dist/admin/actions/DecideDialog.d.ts +0 -9
- package/dist/admin/actions/actions.model.js +0 -70
- package/dist/admin/api.d.ts +0 -38
- package/dist/admin/api.js +0 -99
- package/dist/admin/copy/readiness.js +0 -71
- package/dist/admin/copy/testPage.js +0 -100
- package/dist/admin/results/results.css +0 -64
- package/dist/admin/styles.css +0 -10
- package/dist/admin/styles.d.ts +0 -2
- package/dist/admin/styles.js +0 -3
- package/dist/admin/surface/pageBlock/pageBlock.model.js +0 -8
- package/dist/admin/surface/readiness/ActionDialogs.js +0 -302
- package/dist/admin/surface/readiness/Banner.js +0 -166
- package/dist/admin/surface/readiness/SaveStatus.d.ts +0 -5
- package/dist/admin/surface/readiness/SaveStatus.js +0 -53
- package/dist/admin/surface/readiness/readiness.model.d.ts +0 -24
- package/dist/admin/surface/readiness/readiness.model.js +0 -123
- package/dist/admin/surface/readiness/useTransition.d.ts +0 -11
- package/dist/admin/surface/readiness/useTransition.js +0 -35
- package/dist/admin/surface/results/ReleasePages.d.ts +0 -14
- package/dist/admin/surface/setting/setting.css +0 -17
- package/dist/admin/surface/test/AdvancedSection.js +0 -160
- package/dist/admin/surface/test/GoalSection.d.ts +0 -2
- package/dist/admin/surface/test/GoalSection.js +0 -228
- package/dist/admin/surface/test/LengthSection.d.ts +0 -2
- package/dist/admin/surface/test/Section.js +0 -47
- package/dist/admin/surface/test/VersionsSection.d.ts +0 -4
- package/dist/admin/surface/test/fields.js +0 -184
- package/dist/admin/surface/test/pageParts.d.ts +0 -2
- package/dist/admin/surface/test/pageParts.js +0 -45
- package/dist/admin/surface/test/testPage.css +0 -90
- package/dist/admin/surface/useTestDocument.d.ts +0 -23
- package/dist/admin/surface/useTestDocument.js +0 -377
- package/dist/admin/useApi.d.ts +0 -35
- package/dist/admin/useApi.js +0 -10
- /package/dist/{admin → testSurface}/actions/decide.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/actions/decide.model.js +0 -0
- /package/dist/{admin → testSurface}/allocation.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/allocation.model.js +0 -0
- /package/dist/{admin → testSurface}/arms/arms.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/arms/arms.model.js +0 -0
- /package/dist/{admin → testSurface}/arms/pageTarget.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/arms/pageTarget.model.js +0 -0
- /package/dist/{admin → testSurface}/arms/params.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/arms/params.model.js +0 -0
- /package/dist/{admin → testSurface}/copy/advanced.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/advanced.js +0 -0
- /package/dist/{admin → testSurface}/copy/arms.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/arms.js +0 -0
- /package/dist/{admin → testSurface}/copy/audience.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/audience.js +0 -0
- /package/dist/{admin → testSurface}/copy/recommendation.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/recommendation.js +0 -0
- /package/dist/{admin → testSurface}/copy/setting.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/setting.js +0 -0
- /package/dist/{admin → testSurface}/format/date.d.ts +0 -0
- /package/dist/{admin → testSurface}/format/date.js +0 -0
- /package/dist/{admin → testSurface}/labels.d.ts +0 -0
- /package/dist/{admin → testSurface}/labels.js +0 -0
- /package/dist/{admin → testSurface}/lockedNotice.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/lockedNotice.model.js +0 -0
- /package/dist/{admin → testSurface}/reload.d.ts +0 -0
- /package/dist/{admin → testSurface}/reload.js +0 -0
- /package/dist/{admin → testSurface}/results/CappedCell.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/CappedCell.js +0 -0
- /package/dist/{admin → testSurface}/results/CiChart.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/CiChart.js +0 -0
- /package/dist/{admin → testSurface}/results/DataQualityPanel.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/DataTable.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/DataTable.js +0 -0
- /package/dist/{admin → testSurface}/results/StatTile.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/StatTile.js +0 -0
- /package/dist/{admin → testSurface}/results/chart.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/chart.model.js +0 -0
- /package/dist/{admin → testSurface}/results/format.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/format.js +0 -0
- /package/dist/{admin → testSurface}/results/legacy.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/legacy.js +0 -0
- /package/dist/{admin → testSurface}/results/releasePages.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/releasePages.model.js +0 -0
- /package/dist/{admin → testSurface}/results/snapshot.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/snapshot.js +0 -0
- /package/dist/{admin → testSurface}/review/review.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/review/review.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/contracts.js +0 -0
- /package/dist/{admin → testSurface}/surface/pageBlock/pageBlock.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/pageBlock/parts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/parts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/results/recommendation.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/results/recommendation.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/setting/parts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/setting/setting.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/setting/setting.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/AdvancedSection.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/Rail.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/TargetingSection.d.ts +0 -0
- /package/dist/{admin → testSurface}/targeting/targeting.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/targeting/targeting.model.js +0 -0
- /package/dist/{admin → testSurface}/theme.d.ts +0 -0
- /package/dist/{admin → testSurface}/theme.js +0 -0
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { placementReader } from '../blocks/placementLocale.js';
|
|
2
|
+
import { readBody } from './readBody.js';
|
|
3
|
+
import { safeError } from '../log.js';
|
|
4
|
+
import { statusPageContent } from '../db/pageContent.js';
|
|
5
|
+
import { normalisePath } from '../runtime/normalisePath.js';
|
|
6
|
+
import { puckCollections } from '../options.js';
|
|
7
|
+
import { resolvePageCollection } from '../transitions/pageCollection.js';
|
|
8
|
+
const error = (status, code, message)=>Response.json({
|
|
9
|
+
errors: [
|
|
10
|
+
{
|
|
11
|
+
code,
|
|
12
|
+
message
|
|
13
|
+
}
|
|
14
|
+
]
|
|
15
|
+
}, {
|
|
16
|
+
status
|
|
17
|
+
});
|
|
18
|
+
const object = (v)=>!!v && typeof v === 'object' && !Array.isArray(v);
|
|
19
|
+
const id = (v)=>typeof v === 'string' && !!v.trim() || typeof v === 'number' && Number.isSafeInteger(v);
|
|
20
|
+
export async function handlePlacementStatus(req, { options }) {
|
|
21
|
+
let value;
|
|
22
|
+
try {
|
|
23
|
+
value = await readBody(req);
|
|
24
|
+
} catch (cause) {
|
|
25
|
+
return error(cause instanceof RangeError ? 413 : 422, cause instanceof RangeError ? 'body-too-large' : 'invalid-body', 'Enter a valid request body.');
|
|
26
|
+
}
|
|
27
|
+
if (!object(value) || Object.keys(value).some((key)=>key !== 'docs' && key !== 'slugs') || value.docs !== undefined && !Array.isArray(value.docs) || value.slugs !== undefined && !Array.isArray(value.slugs)) return error(422, 'invalid-body', 'Enter a valid request body.');
|
|
28
|
+
if ((value.docs?.length ?? 0) > 100 || (value.slugs?.length ?? 0) > 100) return error(422, 'too-many-ids', 'Choose at most 100 documents and slugs.');
|
|
29
|
+
if (value.docs?.some((doc)=>!object(doc) || typeof doc.collection !== 'string' || !id(doc.id)) || value.slugs?.some((slug)=>typeof slug !== 'string' || !slug || slug.length > 64)) return error(422, 'invalid-body', 'Enter valid documents and slugs.');
|
|
30
|
+
const body = value;
|
|
31
|
+
const registered = new Set([
|
|
32
|
+
...options.pages?.collections.map((entry)=>entry.slug) ?? [],
|
|
33
|
+
...options.blocks?.collections.map((entry)=>entry.slug) ?? [],
|
|
34
|
+
...puckCollections(options).map((entry)=>entry.slug)
|
|
35
|
+
]);
|
|
36
|
+
if (body.docs?.some((doc)=>!registered.has(doc.collection))) return error(422, 'unknown-collection', "That page type isn't set up for tests.");
|
|
37
|
+
const result = {
|
|
38
|
+
docs: Object.create(null),
|
|
39
|
+
slugs: Object.create(null)
|
|
40
|
+
};
|
|
41
|
+
const wanted = body.slugs ?? [];
|
|
42
|
+
const { docs } = await req.payload.find({
|
|
43
|
+
collection: 'xp-experiments',
|
|
44
|
+
req,
|
|
45
|
+
overrideAccess: false,
|
|
46
|
+
depth: 0,
|
|
47
|
+
pagination: false,
|
|
48
|
+
limit: 0,
|
|
49
|
+
where: !body.docs?.length ? {
|
|
50
|
+
slug: {
|
|
51
|
+
in: wanted
|
|
52
|
+
}
|
|
53
|
+
} : !wanted.length ? {
|
|
54
|
+
kind: {
|
|
55
|
+
equals: 'page'
|
|
56
|
+
}
|
|
57
|
+
} : undefined
|
|
58
|
+
});
|
|
59
|
+
const tests = docs;
|
|
60
|
+
const state = wanted.length ? await req.payload.findGlobal({
|
|
61
|
+
slug: 'xp-state',
|
|
62
|
+
req,
|
|
63
|
+
overrideAccess: false,
|
|
64
|
+
depth: 0
|
|
65
|
+
}) : null;
|
|
66
|
+
const retired = Array.isArray(state?.retiredSlugs) ? state.retiredSlugs : [];
|
|
67
|
+
const rounds = new Map();
|
|
68
|
+
for (const test of tests){
|
|
69
|
+
let arms = test.arms, rollout = false;
|
|
70
|
+
if ([
|
|
71
|
+
'running',
|
|
72
|
+
'decided',
|
|
73
|
+
'archived'
|
|
74
|
+
].includes(test.status)) {
|
|
75
|
+
const phases = await req.payload.find({
|
|
76
|
+
collection: 'xp-phases',
|
|
77
|
+
req,
|
|
78
|
+
overrideAccess: false,
|
|
79
|
+
depth: 0,
|
|
80
|
+
limit: 1,
|
|
81
|
+
sort: '-phase',
|
|
82
|
+
where: {
|
|
83
|
+
experiment: {
|
|
84
|
+
equals: test.id
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
const latest = phases.docs[0];
|
|
89
|
+
rollout = test.status === 'decided' && latest?.phaseKind === 'rollout' && !latest.endedAt && !test.decision?.holdoutReleasedAt;
|
|
90
|
+
if (latest?.phaseKind === 'test') arms = latest.arms;
|
|
91
|
+
else if (latest) {
|
|
92
|
+
const frozen = await req.payload.find({
|
|
93
|
+
collection: 'xp-phases',
|
|
94
|
+
req,
|
|
95
|
+
overrideAccess: false,
|
|
96
|
+
depth: 0,
|
|
97
|
+
limit: 1,
|
|
98
|
+
sort: '-phase',
|
|
99
|
+
where: {
|
|
100
|
+
and: [
|
|
101
|
+
{
|
|
102
|
+
experiment: {
|
|
103
|
+
equals: test.id
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
phaseKind: {
|
|
108
|
+
equals: 'test'
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
]
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
arms = frozen.docs[0]?.arms ?? arms;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
rounds.set(test.slug, {
|
|
118
|
+
arms,
|
|
119
|
+
rollout
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
for (const slug of wanted){
|
|
123
|
+
const test = tests.find((test)=>test.slug === slug);
|
|
124
|
+
if (!test) {
|
|
125
|
+
result.slugs[slug] = retired.includes(slug) ? {
|
|
126
|
+
deleted: true
|
|
127
|
+
} : {
|
|
128
|
+
missing: true
|
|
129
|
+
};
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
const round = rounds.get(slug);
|
|
133
|
+
result.slugs[slug] = {
|
|
134
|
+
name: test.name,
|
|
135
|
+
status: test.status,
|
|
136
|
+
kind: test.kind,
|
|
137
|
+
arms: round.arms.map(({ key, kind, label, slot })=>{
|
|
138
|
+
const contentSlot = test.kind === 'block' ? kind !== 'holdout' && key !== 'holdout' ? key : undefined : slot;
|
|
139
|
+
return {
|
|
140
|
+
key,
|
|
141
|
+
label,
|
|
142
|
+
...contentSlot ? {
|
|
143
|
+
slot: contentSlot
|
|
144
|
+
} : {}
|
|
145
|
+
};
|
|
146
|
+
}),
|
|
147
|
+
...test.decision?.winnerArm ? {
|
|
148
|
+
winnerArm: test.decision.winnerArm
|
|
149
|
+
} : {},
|
|
150
|
+
...test.decision?.discardedAt ? {
|
|
151
|
+
discarded: true
|
|
152
|
+
} : {},
|
|
153
|
+
rollout: round.rollout
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
const collections = new Map();
|
|
157
|
+
const winnerTitles = new Map();
|
|
158
|
+
for (const { collection, id } of body.docs ?? []){
|
|
159
|
+
// Check document access before the raw path read. A refused read propagates.
|
|
160
|
+
await req.payload.findByID({
|
|
161
|
+
collection,
|
|
162
|
+
id,
|
|
163
|
+
req,
|
|
164
|
+
overrideAccess: false,
|
|
165
|
+
depth: 0,
|
|
166
|
+
draft: false
|
|
167
|
+
});
|
|
168
|
+
const registration = options.pages?.collections.find((entry)=>entry.slug === collection);
|
|
169
|
+
const raw = registration ? await statusPageContent(req, collection, id) : null;
|
|
170
|
+
const doc = placementReader(req, collection, options).read(raw, 'all-locales').doc;
|
|
171
|
+
const rawPath = doc && registration ? registration.pathOf(doc) : null;
|
|
172
|
+
const path = rawPath;
|
|
173
|
+
const pathKey = path === null ? null : normalisePath(path);
|
|
174
|
+
const status = {
|
|
175
|
+
path,
|
|
176
|
+
tests: []
|
|
177
|
+
};
|
|
178
|
+
for (const test of tests){
|
|
179
|
+
if (test.kind !== 'page' || path === null || test.decision?.pagesReleasedAt || test.decision?.discardedAt || test.status === 'archived' && !test.decision?.winnerArm) continue;
|
|
180
|
+
const round = rounds.get(test.slug);
|
|
181
|
+
if (!collections.has(test.slug)) collections.set(test.slug, await resolvePageCollection(req, options, {
|
|
182
|
+
...test,
|
|
183
|
+
arms: round.arms
|
|
184
|
+
}));
|
|
185
|
+
const testCollection = collections.get(test.slug);
|
|
186
|
+
if (testCollection?.slug !== collection) continue;
|
|
187
|
+
const arm = round.arms.find((arm)=>arm.kind !== 'holdout' && arm.pageTarget && normalisePath(arm.pageTarget) === pathKey);
|
|
188
|
+
if (!arm) continue;
|
|
189
|
+
const winner = round.arms.find((arm)=>arm.key === test.decision?.winnerArm);
|
|
190
|
+
const original = round.arms.find((arm)=>arm.kind === 'control');
|
|
191
|
+
if (!winnerTitles.has(test.slug)) {
|
|
192
|
+
let title;
|
|
193
|
+
try {
|
|
194
|
+
const winnerPage = winner?.pageTarget && registration ? await registration.findByPath(winner.pageTarget, req) : null;
|
|
195
|
+
const winnerDoc = winnerPage ? await req.payload.findByID({
|
|
196
|
+
collection,
|
|
197
|
+
id: winnerPage.id,
|
|
198
|
+
req,
|
|
199
|
+
overrideAccess: false,
|
|
200
|
+
depth: 0,
|
|
201
|
+
draft: false,
|
|
202
|
+
disableErrors: true
|
|
203
|
+
}) : null;
|
|
204
|
+
const titleField = req.payload.config.collections.find((entry)=>entry.slug === collection)?.admin.useAsTitle ?? 'title';
|
|
205
|
+
if (winnerDoc) title = String(winnerDoc[titleField] ?? winnerDoc.id);
|
|
206
|
+
} catch (cause) {
|
|
207
|
+
req.payload.logger.error({
|
|
208
|
+
err: safeError(cause),
|
|
209
|
+
experimentId: test.id
|
|
210
|
+
}, 'Experiment winner title lookup failed');
|
|
211
|
+
}
|
|
212
|
+
winnerTitles.set(test.slug, title);
|
|
213
|
+
}
|
|
214
|
+
const winnerTitle = winnerTitles.get(test.slug);
|
|
215
|
+
status.tests.push({
|
|
216
|
+
slug: test.slug,
|
|
217
|
+
name: test.name,
|
|
218
|
+
status: test.status,
|
|
219
|
+
role: arm.kind === 'control' ? 'original' : 'version',
|
|
220
|
+
armLabel: arm.label,
|
|
221
|
+
winner: [
|
|
222
|
+
'decided',
|
|
223
|
+
'archived'
|
|
224
|
+
].includes(test.status) && winner?.key === arm.key,
|
|
225
|
+
...winner ? {
|
|
226
|
+
winnerLabel: winner.label,
|
|
227
|
+
winnerPath: winner.pageTarget
|
|
228
|
+
} : {},
|
|
229
|
+
...winnerTitle ? {
|
|
230
|
+
winnerTitle
|
|
231
|
+
} : {},
|
|
232
|
+
...original?.pageTarget ? {
|
|
233
|
+
originalPath: normalisePath(original.pageTarget)
|
|
234
|
+
} : {},
|
|
235
|
+
rollout: round.rollout,
|
|
236
|
+
pagesReleased: false
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
result.docs[`${collection}:${id}`] = status;
|
|
240
|
+
}
|
|
241
|
+
return Response.json(result, {
|
|
242
|
+
headers: {
|
|
243
|
+
'Cache-Control': 'no-store'
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type PayloadRequest } from 'payload';
|
|
2
2
|
import type { EndpointContext } from '../types/endpoints.js';
|
|
3
3
|
import type { PreflightDependencies } from '../transitions/preflightData.js';
|
|
4
4
|
export declare function handlePreflight<TUser extends {
|
|
@@ -1,10 +1,25 @@
|
|
|
1
|
+
import { contentLocale } from './contentLocale.js';
|
|
2
|
+
import { sanitizeFallbackLocale } from 'payload';
|
|
3
|
+
import { localeRequest } from '../blocks/placementLocale.js';
|
|
1
4
|
import { preflightData } from '../transitions/preflightData.js';
|
|
2
5
|
import { routeId } from './routeId.js';
|
|
3
6
|
export async function handlePreflight(req, ctx, dependencies) {
|
|
4
7
|
const id = routeId(req);
|
|
5
|
-
const
|
|
8
|
+
const placementLocale = contentLocale(req).locale ?? undefined;
|
|
9
|
+
const localization = req.payload.config.localization;
|
|
10
|
+
// The query selects readiness labels only. Host reads must match Start's default request.
|
|
11
|
+
const readinessReq = localization ? localeRequest(req, {
|
|
12
|
+
locale: localization.defaultLocale,
|
|
13
|
+
fallbackLocale: sanitizeFallbackLocale({
|
|
14
|
+
fallbackLocale: null,
|
|
15
|
+
locale: localization.defaultLocale,
|
|
16
|
+
localization
|
|
17
|
+
})
|
|
18
|
+
}) : req;
|
|
19
|
+
const result = id !== undefined ? await preflightData(readinessReq, {
|
|
6
20
|
experimentId: id,
|
|
7
|
-
options: ctx.options
|
|
21
|
+
options: ctx.options,
|
|
22
|
+
placementLocale
|
|
8
23
|
}, dependencies) : null;
|
|
9
24
|
const headers = {
|
|
10
25
|
'Cache-Control': 'no-store'
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export async function readBody(req) {
|
|
2
|
+
if (req.data !== undefined) {
|
|
3
|
+
if (Buffer.byteLength(JSON.stringify(req.data)) > 16 * 1024) throw new RangeError();
|
|
4
|
+
return req.data;
|
|
5
|
+
}
|
|
6
|
+
if (!req.body) return {};
|
|
7
|
+
const reader = req.body.getReader(), chunks = [];
|
|
8
|
+
let size = 0;
|
|
9
|
+
try {
|
|
10
|
+
while(true){
|
|
11
|
+
const { done, value } = await reader.read();
|
|
12
|
+
if (done) break;
|
|
13
|
+
size += value.byteLength;
|
|
14
|
+
if (size > 16 * 1024) {
|
|
15
|
+
void reader.cancel().catch(()=>{});
|
|
16
|
+
throw new RangeError();
|
|
17
|
+
}
|
|
18
|
+
chunks.push(value);
|
|
19
|
+
}
|
|
20
|
+
return JSON.parse(Buffer.concat(chunks).toString('utf8'));
|
|
21
|
+
} finally{
|
|
22
|
+
reader.releaseLock();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -21,4 +21,4 @@ export declare function handleResults<TUser extends {
|
|
|
21
21
|
id: string | number;
|
|
22
22
|
} = {
|
|
23
23
|
id: string | number;
|
|
24
|
-
}>(req: PayloadRequest,
|
|
24
|
+
}>(req: PayloadRequest, { options }: EndpointContext<TUser>): Promise<Response>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { resultsMetadata, newestSnapshotIds } from '../db/snapshots.js';
|
|
2
2
|
import { pooledExecutor } from '../db/executor.js';
|
|
3
3
|
import { routeId } from './routeId.js';
|
|
4
|
+
import { isClickSource } from '../goals/key.js';
|
|
5
|
+
import { browserWritableMetric } from '../events/writable.js';
|
|
4
6
|
const headers = {
|
|
5
7
|
'Cache-Control': 'no-store'
|
|
6
8
|
};
|
|
@@ -52,7 +54,7 @@ export async function readSnapshots(req, ids, { per = 'phase', decisionId, serie
|
|
|
52
54
|
numeric: true
|
|
53
55
|
}));
|
|
54
56
|
}
|
|
55
|
-
export async function handleResults(req,
|
|
57
|
+
export async function handleResults(req, { options }) {
|
|
56
58
|
const id = routeId(req);
|
|
57
59
|
if (id === undefined) return resultsError(404, 'not-found', 'Experiment not found');
|
|
58
60
|
const params = new URL(req.url ?? 'http://localhost').searchParams;
|
|
@@ -85,11 +87,17 @@ export async function handleResults(req, _ctx) {
|
|
|
85
87
|
label,
|
|
86
88
|
kind
|
|
87
89
|
})),
|
|
88
|
-
metrics: record.metricDefinitions.map(({ metricId, name, kind, role, resolvedCap, historyUnits, capNotice })=>({
|
|
90
|
+
metrics: record.metricDefinitions.map(({ metricId, name, kind, role, source, browserWritable, resolvedCap, historyUnits, capNotice })=>({
|
|
89
91
|
metricId,
|
|
90
92
|
name,
|
|
91
93
|
kind,
|
|
92
94
|
role,
|
|
95
|
+
...isClickSource(source) ? {
|
|
96
|
+
clickGoal: true
|
|
97
|
+
} : {},
|
|
98
|
+
...browserWritable === true || browserWritableMetric(source, options) ? {
|
|
99
|
+
browserWritable: true
|
|
100
|
+
} : {},
|
|
93
101
|
...resolvedCap === undefined ? {} : {
|
|
94
102
|
resolvedCap
|
|
95
103
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PayloadRequest } from 'payload';
|
|
2
2
|
import type { DocId } from '../types/contracts.js';
|
|
3
|
-
/**
|
|
4
|
-
export declare function experimentId(req: PayloadRequest, value: unknown): DocId | undefined;
|
|
3
|
+
/** Use the stored spelling for PostgreSQL IDs before any lock or comparison. */
|
|
4
|
+
export declare function experimentId(req: PayloadRequest, value: unknown, source?: 'route' | 'payload'): DocId | undefined;
|
|
5
5
|
export declare function routeId(req: PayloadRequest): DocId | undefined;
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** Use the stored spelling for PostgreSQL IDs before any lock or comparison. */ export function experimentId(req, value, source = 'route') {
|
|
2
2
|
if (typeof value !== 'string' && typeof value !== 'number') return undefined;
|
|
3
3
|
const id = String(value);
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
if (
|
|
4
|
+
const customIDType = req.payload.collections?.['xp-experiments']?.customIDType;
|
|
5
|
+
const idType = customIDType ?? req.payload.db.defaultIDType;
|
|
6
|
+
if (idType !== 'number') {
|
|
7
|
+
// The Postgres adapter reports a native UUID as text. Custom text IDs are opaque.
|
|
8
|
+
const uuid = /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i;
|
|
9
|
+
return customIDType !== 'text' && uuid.test(id) ? id.toLowerCase() : id;
|
|
10
|
+
}
|
|
11
|
+
// Native Payload deletes already use Number() for their ID lookup.
|
|
12
|
+
if (source === 'route' && !/^\d+$/.test(id)) return undefined;
|
|
7
13
|
const number = Number(id);
|
|
8
14
|
// Payload's Postgres serial ids are int4; larger values would reach SQL and fail with 22003.
|
|
9
|
-
return Number.
|
|
15
|
+
return Number.isInteger(number) && number >= -2_147_483_648 && number <= 2_147_483_647 ? number : undefined;
|
|
10
16
|
}
|
|
11
17
|
export function routeId(req) {
|
|
12
18
|
return experimentId(req, req.routeParams?.id);
|
|
@@ -1,8 +1,28 @@
|
|
|
1
|
+
import { BLOCK_SLOTS } from '../blocks/model.js';
|
|
1
2
|
import { checkStart } from '../transitions/checkStart.js';
|
|
2
3
|
import { loadStartInputsBatch } from '../transitions/preflightData.js';
|
|
3
4
|
import { readSnapshots, resultsError } from './results.js';
|
|
4
5
|
import { experimentId } from './routeId.js';
|
|
5
6
|
import { sanitizeReadinessDetail } from './sanitizeReadinessDetail.js';
|
|
7
|
+
/** Use the batch scan's saved drafts. As in preflight, every matching block on
|
|
8
|
+
* a page in the affected language needs content before suggesting publication. */ function draftReadySlots(placements) {
|
|
9
|
+
const location = (row)=>JSON.stringify([
|
|
10
|
+
row.collection,
|
|
11
|
+
String(row.id),
|
|
12
|
+
row.locale
|
|
13
|
+
]);
|
|
14
|
+
const filledInDraft = new Map();
|
|
15
|
+
for (const row of placements){
|
|
16
|
+
if (row.published) continue;
|
|
17
|
+
const id = location(row);
|
|
18
|
+
const filled = filledInDraft.get(id) ?? BLOCK_SLOTS;
|
|
19
|
+
filledInDraft.set(id, filled.filter((slot)=>row.slots[slot] > 0));
|
|
20
|
+
}
|
|
21
|
+
return BLOCK_SLOTS.filter((slot)=>{
|
|
22
|
+
const affected = placements.filter((row)=>row.published && !(row.slots[slot] > 0));
|
|
23
|
+
return affected.length > 0 && affected.every((row)=>filledInDraft.get(location(row))?.includes(slot));
|
|
24
|
+
});
|
|
25
|
+
}
|
|
6
26
|
export async function handleSummary(req, { options }) {
|
|
7
27
|
let ids;
|
|
8
28
|
try {
|
|
@@ -43,10 +63,30 @@ export async function handleSummary(req, { options }) {
|
|
|
43
63
|
headline: snapshot.verdict.headline
|
|
44
64
|
},
|
|
45
65
|
...snapshot.health ? {
|
|
46
|
-
health: snapshot.health.slice(0, 100).map((
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
66
|
+
health: snapshot.health.slice(0, 100).map((item)=>{
|
|
67
|
+
switch(item.code){
|
|
68
|
+
case 'placement-unchecked':
|
|
69
|
+
return {
|
|
70
|
+
code: item.code,
|
|
71
|
+
detail: sanitizeReadinessDetail(item.code, item.detail)
|
|
72
|
+
};
|
|
73
|
+
case 'goal-in-some-versions':
|
|
74
|
+
return {
|
|
75
|
+
code: item.code,
|
|
76
|
+
metricId: item.metricId,
|
|
77
|
+
name: item.name.slice(0, 128)
|
|
78
|
+
};
|
|
79
|
+
case 'rapid-browser-events':
|
|
80
|
+
return {
|
|
81
|
+
code: item.code
|
|
82
|
+
};
|
|
83
|
+
default:
|
|
84
|
+
return {
|
|
85
|
+
code: item.code,
|
|
86
|
+
path: item.path.slice(0, 128)
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
})
|
|
50
90
|
} : {}
|
|
51
91
|
} : {
|
|
52
92
|
exposures: 0,
|
|
@@ -83,7 +123,8 @@ export async function handleSummary(req, { options }) {
|
|
|
83
123
|
response[key].ready = !!input && checks.every((check)=>check.ok);
|
|
84
124
|
const next = checks.find((check)=>!check.ok && !check.warning);
|
|
85
125
|
if (next) {
|
|
86
|
-
const
|
|
126
|
+
const draftReady = next.code === 'empty-slot' && input?.placements ? draftReadySlots(input.placements) : undefined;
|
|
127
|
+
const detail = sanitizeReadinessDetail(next.code, next.detail, draftReady);
|
|
87
128
|
response[key].next = {
|
|
88
129
|
code: next.code,
|
|
89
130
|
...detail === undefined ? {} : {
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { routeId } from './routeId.js';
|
|
2
|
+
export async function handleTestVersion(req) {
|
|
3
|
+
const id = routeId(req);
|
|
4
|
+
const headers = {
|
|
5
|
+
'Cache-Control': 'private, no-store'
|
|
6
|
+
};
|
|
7
|
+
const doc = id === undefined ? null : await req.payload.findByID({
|
|
8
|
+
collection: 'xp-experiments',
|
|
9
|
+
id,
|
|
10
|
+
req,
|
|
11
|
+
overrideAccess: false,
|
|
12
|
+
depth: 0,
|
|
13
|
+
disableErrors: true,
|
|
14
|
+
select: {
|
|
15
|
+
updatedAt: true,
|
|
16
|
+
status: true,
|
|
17
|
+
phase: true
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
if (!doc) return Response.json({
|
|
21
|
+
errors: [
|
|
22
|
+
{
|
|
23
|
+
code: 'not-found',
|
|
24
|
+
message: 'Experiment not found'
|
|
25
|
+
}
|
|
26
|
+
]
|
|
27
|
+
}, {
|
|
28
|
+
status: 404,
|
|
29
|
+
headers
|
|
30
|
+
});
|
|
31
|
+
return Response.json({
|
|
32
|
+
updatedAt: doc.updatedAt,
|
|
33
|
+
status: doc.status,
|
|
34
|
+
phase: doc.phase ?? 0
|
|
35
|
+
}, {
|
|
36
|
+
headers
|
|
37
|
+
});
|
|
38
|
+
}
|
|
@@ -33,6 +33,7 @@ async function body(req) {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
const only = (value, keys)=>Object.keys(value).every((key)=>keys.includes(key));
|
|
36
|
+
const validPhase = (phase)=>phase === undefined || typeof phase === 'number' && Number.isSafeInteger(phase) && phase >= 0;
|
|
36
37
|
async function respond(req, action) {
|
|
37
38
|
const id = routeId(req);
|
|
38
39
|
if (id === undefined) return Response.json({
|
|
@@ -63,15 +64,18 @@ async function respond(req, action) {
|
|
|
63
64
|
}
|
|
64
65
|
]
|
|
65
66
|
}, {
|
|
66
|
-
status: cause.status === 409 ? 422 : cause.status
|
|
67
|
+
status: cause.status === 409 && cause.code !== 'round-changed' ? 422 : cause.status
|
|
67
68
|
});
|
|
68
69
|
throw cause;
|
|
69
70
|
}
|
|
70
71
|
}
|
|
71
72
|
export async function handleStart(req, ctx) {
|
|
72
73
|
const value = await body(req);
|
|
73
|
-
if (!value || !only(value, [
|
|
74
|
+
if (!value || !only(value, [
|
|
75
|
+
'phase'
|
|
76
|
+
]) || !validPhase(value.phase)) return invalidBody();
|
|
74
77
|
return respond(req, (id)=>start(req, {
|
|
78
|
+
...value,
|
|
75
79
|
experimentId: id,
|
|
76
80
|
options: ctx.options
|
|
77
81
|
}));
|
|
@@ -79,32 +83,34 @@ export async function handleStart(req, ctx) {
|
|
|
79
83
|
export async function handleAllocate(req, _ctx) {
|
|
80
84
|
const value = await body(req);
|
|
81
85
|
if (!value || !only(value, [
|
|
82
|
-
'allocation'
|
|
83
|
-
|
|
84
|
-
|
|
86
|
+
'allocation',
|
|
87
|
+
'phase'
|
|
88
|
+
]) || !validPhase(value.phase) || typeof value.allocation !== 'number' || !Number.isInteger(value.allocation) || value.allocation < 1 || value.allocation > 100) return invalidBody();
|
|
85
89
|
return respond(req, (id)=>allocate(req, {
|
|
86
|
-
|
|
87
|
-
|
|
90
|
+
...value,
|
|
91
|
+
experimentId: id
|
|
88
92
|
}));
|
|
89
93
|
}
|
|
90
94
|
export async function handleAddMetric(req, ctx) {
|
|
91
95
|
const value = await body(req);
|
|
92
96
|
if (!value || !only(value, [
|
|
93
97
|
'metric',
|
|
94
|
-
'role'
|
|
95
|
-
|
|
96
|
-
|
|
98
|
+
'role',
|
|
99
|
+
'phase'
|
|
100
|
+
]) || !validPhase(value.phase) || !(typeof value.metric === 'string' && value.metric.trim() || typeof value.metric === 'number' && Number.isSafeInteger(value.metric)) || value.role !== 'secondary' && value.role !== 'guardrail') return invalidBody();
|
|
97
101
|
return respond(req, (id)=>addMetric(req, {
|
|
102
|
+
...value,
|
|
98
103
|
experimentId: id,
|
|
99
|
-
metric,
|
|
100
|
-
role,
|
|
101
104
|
options: ctx.options
|
|
102
105
|
}));
|
|
103
106
|
}
|
|
104
107
|
export async function handleStop(req, _ctx) {
|
|
105
108
|
const value = await body(req);
|
|
106
|
-
if (!value || !only(value, [
|
|
109
|
+
if (!value || !only(value, [
|
|
110
|
+
'phase'
|
|
111
|
+
]) || !validPhase(value.phase)) return invalidBody();
|
|
107
112
|
return respond(req, (id)=>stop(req, {
|
|
113
|
+
...value,
|
|
108
114
|
experimentId: id
|
|
109
115
|
}));
|
|
110
116
|
}
|
|
@@ -113,35 +119,42 @@ export async function handleDecide(req, _ctx) {
|
|
|
113
119
|
if (!value || !only(value, [
|
|
114
120
|
'winnerArm',
|
|
115
121
|
'note',
|
|
116
|
-
'confirmation'
|
|
117
|
-
|
|
118
|
-
|
|
122
|
+
'confirmation',
|
|
123
|
+
'phase'
|
|
124
|
+
]) || !validPhase(value.phase) || typeof value.winnerArm !== 'string' || value.note !== undefined && typeof value.note !== 'string' || value.confirmation !== undefined && typeof value.confirmation !== 'string') return invalidBody();
|
|
119
125
|
return respond(req, (id)=>decide(req, {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
note,
|
|
123
|
-
confirmation
|
|
126
|
+
...value,
|
|
127
|
+
experimentId: id
|
|
124
128
|
}));
|
|
125
129
|
}
|
|
126
130
|
export async function handleReleaseHoldout(req, _ctx) {
|
|
127
131
|
const value = await body(req);
|
|
128
|
-
if (!value || !only(value, [
|
|
132
|
+
if (!value || !only(value, [
|
|
133
|
+
'phase'
|
|
134
|
+
]) || !validPhase(value.phase)) return invalidBody();
|
|
129
135
|
return respond(req, (id)=>releaseHoldout(req, {
|
|
136
|
+
...value,
|
|
130
137
|
experimentId: id
|
|
131
138
|
}));
|
|
132
139
|
}
|
|
133
140
|
export async function handleMakeContent(req, ctx) {
|
|
134
141
|
const value = await body(req);
|
|
135
|
-
if (!value || !only(value, [
|
|
142
|
+
if (!value || !only(value, [
|
|
143
|
+
'phase'
|
|
144
|
+
]) || !validPhase(value.phase)) return invalidBody();
|
|
136
145
|
return respond(req, (id)=>makeContent(req, {
|
|
146
|
+
...value,
|
|
137
147
|
experimentId: id,
|
|
138
148
|
options: ctx.options
|
|
139
149
|
}));
|
|
140
150
|
}
|
|
141
151
|
export async function handleReleasePages(req, _ctx) {
|
|
142
152
|
const value = await body(req);
|
|
143
|
-
if (!value || !only(value, [
|
|
153
|
+
if (!value || !only(value, [
|
|
154
|
+
'phase'
|
|
155
|
+
]) || !validPhase(value.phase)) return invalidBody();
|
|
144
156
|
return respond(req, (id)=>releasePages(req, {
|
|
157
|
+
...value,
|
|
145
158
|
experimentId: id
|
|
146
159
|
}));
|
|
147
160
|
}
|
|
@@ -175,17 +188,16 @@ export async function handleArchive(req, _ctx) {
|
|
|
175
188
|
const value = await body(req);
|
|
176
189
|
if (!value || !only(value, [
|
|
177
190
|
'mode',
|
|
178
|
-
'confirmation'
|
|
179
|
-
|
|
191
|
+
'confirmation',
|
|
192
|
+
'phase'
|
|
193
|
+
]) || !validPhase(value.phase) || ![
|
|
180
194
|
'stopped',
|
|
181
195
|
'after-content',
|
|
182
196
|
'discard',
|
|
183
197
|
'hard-coded'
|
|
184
198
|
].includes(value.mode) || value.confirmation !== undefined && typeof value.confirmation !== 'string') return invalidBody();
|
|
185
|
-
const { mode, confirmation } = value;
|
|
186
199
|
return respond(req, (id)=>archive(req, {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
confirmation
|
|
200
|
+
...value,
|
|
201
|
+
experimentId: id
|
|
190
202
|
}));
|
|
191
203
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type PayloadRequest } from 'payload';
|
|
2
|
+
import type { EndpointContext } from '../types/endpoints.js';
|
|
3
|
+
import type { DocId } from '../types/contracts.js';
|
|
4
|
+
export declare function handleWrapBlock<TUser extends {
|
|
5
|
+
id: DocId;
|
|
6
|
+
}>(req: PayloadRequest, { options }: EndpointContext<TUser>): Promise<Response>;
|