@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,15 @@
|
|
|
1
|
+
import type { DocId } from '../../types/contracts.js';
|
|
2
|
+
/** Broadcast a completed mutation when its caller has no mounted document watcher. */
|
|
3
|
+
export declare function notifyTestDocument(apiRoute: string, id: DocId): void;
|
|
4
|
+
type Check = (reasons: {
|
|
5
|
+
broadcast: boolean;
|
|
6
|
+
returned: boolean;
|
|
7
|
+
}) => Promise<'ok' | 'retry' | 'stop'>;
|
|
8
|
+
type CheckResult = Awaited<ReturnType<Check>>;
|
|
9
|
+
/** Owns the single background read and its timer for one mounted test. */
|
|
10
|
+
export declare function watchTestDocument(apiRoute: string, id: DocId, check: Check): {
|
|
11
|
+
start(initial: CheckResult): void;
|
|
12
|
+
notify(): void;
|
|
13
|
+
close(): void;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
const POLL_MS = 5_000;
|
|
2
|
+
const IDLE_MS = 10 * 60_000;
|
|
3
|
+
const WINDOW_AWAY_MS = 250;
|
|
4
|
+
const RETRY_MS = [
|
|
5
|
+
4_000,
|
|
6
|
+
8_000,
|
|
7
|
+
16_000,
|
|
8
|
+
30_000
|
|
9
|
+
];
|
|
10
|
+
function openChannel(apiRoute, id) {
|
|
11
|
+
const key = JSON.stringify([
|
|
12
|
+
apiRoute.replace(/\/$/, ''),
|
|
13
|
+
String(id)
|
|
14
|
+
]);
|
|
15
|
+
try {
|
|
16
|
+
return new BroadcastChannel(`xp-test:${key}`);
|
|
17
|
+
} catch {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/** Broadcast a completed mutation when its caller has no mounted document watcher. */ export function notifyTestDocument(apiRoute, id) {
|
|
22
|
+
const sender = openChannel(apiRoute, id);
|
|
23
|
+
sender?.postMessage(null);
|
|
24
|
+
sender?.close();
|
|
25
|
+
}
|
|
26
|
+
/** Owns the single background read and its timer for one mounted test. */ export function watchTestDocument(apiRoute, id, check) {
|
|
27
|
+
const channel = openChannel(apiRoute, id);
|
|
28
|
+
const inputEvents = [
|
|
29
|
+
'pointerdown',
|
|
30
|
+
'pointermove',
|
|
31
|
+
'keydown',
|
|
32
|
+
'scroll'
|
|
33
|
+
];
|
|
34
|
+
let timer;
|
|
35
|
+
let lastInput = Date.now();
|
|
36
|
+
let retryAt = 0;
|
|
37
|
+
let failures = 0;
|
|
38
|
+
let started = false;
|
|
39
|
+
let closed = false;
|
|
40
|
+
let inFlight = false;
|
|
41
|
+
let requested = false;
|
|
42
|
+
let broadcast = false;
|
|
43
|
+
let returned = false;
|
|
44
|
+
let polling = true;
|
|
45
|
+
const visible = ()=>document.visibilityState === 'visible';
|
|
46
|
+
const active = ()=>Date.now() - lastInput < IDLE_MS;
|
|
47
|
+
let wasVisible = visible();
|
|
48
|
+
let awaitingPageShow = false;
|
|
49
|
+
let blurredAt;
|
|
50
|
+
let focusCheck;
|
|
51
|
+
function record(result) {
|
|
52
|
+
polling = result !== 'stop';
|
|
53
|
+
failures = result === 'retry' ? failures + 1 : 0;
|
|
54
|
+
retryAt = failures ? Date.now() + RETRY_MS[Math.min(failures - 1, RETRY_MS.length - 1)] : 0;
|
|
55
|
+
}
|
|
56
|
+
function schedule() {
|
|
57
|
+
clearTimeout(timer);
|
|
58
|
+
if (!started || closed || inFlight) return;
|
|
59
|
+
if (!broadcast && (!visible() || !requested && (!polling || !active()))) return;
|
|
60
|
+
const delay = requested || broadcast ? 0 : failures ? retryAt - Date.now() : POLL_MS;
|
|
61
|
+
const wait = Math.max(delay, retryAt - Date.now(), 0);
|
|
62
|
+
if (wait === 0) void run();
|
|
63
|
+
else timer = setTimeout(()=>{
|
|
64
|
+
void run();
|
|
65
|
+
}, wait);
|
|
66
|
+
}
|
|
67
|
+
async function run() {
|
|
68
|
+
if (closed || inFlight || !broadcast && (!visible() || !requested && !active())) return;
|
|
69
|
+
inFlight = true;
|
|
70
|
+
const reasons = {
|
|
71
|
+
broadcast,
|
|
72
|
+
returned
|
|
73
|
+
};
|
|
74
|
+
requested = false;
|
|
75
|
+
broadcast = false;
|
|
76
|
+
returned = false;
|
|
77
|
+
try {
|
|
78
|
+
record(await check(reasons));
|
|
79
|
+
} catch {
|
|
80
|
+
record('retry');
|
|
81
|
+
} finally{
|
|
82
|
+
inFlight = false;
|
|
83
|
+
schedule();
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function onInput() {
|
|
87
|
+
const wasIdle = !active();
|
|
88
|
+
lastInput = Date.now();
|
|
89
|
+
if (wasIdle && visible() && polling) {
|
|
90
|
+
requested = true;
|
|
91
|
+
schedule();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function requestReturn() {
|
|
95
|
+
requested = true;
|
|
96
|
+
returned = true;
|
|
97
|
+
schedule();
|
|
98
|
+
}
|
|
99
|
+
function onVisibility() {
|
|
100
|
+
const nowVisible = visible();
|
|
101
|
+
const becameVisible = nowVisible && !wasVisible;
|
|
102
|
+
wasVisible = nowVisible;
|
|
103
|
+
if (becameVisible && !awaitingPageShow) {
|
|
104
|
+
requestReturn();
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (!nowVisible) {
|
|
108
|
+
requested = false;
|
|
109
|
+
returned = false;
|
|
110
|
+
blurredAt = undefined;
|
|
111
|
+
}
|
|
112
|
+
schedule();
|
|
113
|
+
}
|
|
114
|
+
function onBlur() {
|
|
115
|
+
clearTimeout(focusCheck);
|
|
116
|
+
if (!visible()) return;
|
|
117
|
+
blurredAt = Date.now();
|
|
118
|
+
// Let focus settle. The document still has focus when it moves into
|
|
119
|
+
// a child frame, including the Puck canvas.
|
|
120
|
+
focusCheck = setTimeout(()=>{
|
|
121
|
+
if (document.hasFocus()) blurredAt = undefined;
|
|
122
|
+
}, 0);
|
|
123
|
+
}
|
|
124
|
+
function onFocus() {
|
|
125
|
+
// Switching windows can leave the document visible the whole time.
|
|
126
|
+
clearTimeout(focusCheck);
|
|
127
|
+
const returnedToWindow = blurredAt !== undefined && Date.now() - blurredAt >= WINDOW_AWAY_MS && wasVisible && visible() && !awaitingPageShow;
|
|
128
|
+
blurredAt = undefined;
|
|
129
|
+
if (returnedToWindow) requestReturn();
|
|
130
|
+
}
|
|
131
|
+
function onPageHide(event) {
|
|
132
|
+
// A restored page can become visible before pageshow. Count it as one return.
|
|
133
|
+
awaitingPageShow = event.persisted;
|
|
134
|
+
blurredAt = undefined;
|
|
135
|
+
}
|
|
136
|
+
function onPageShow(event) {
|
|
137
|
+
if (!event.persisted) return;
|
|
138
|
+
awaitingPageShow = false;
|
|
139
|
+
wasVisible = visible();
|
|
140
|
+
if (wasVisible) requestReturn();
|
|
141
|
+
}
|
|
142
|
+
channel?.addEventListener('message', ()=>{
|
|
143
|
+
broadcast = true;
|
|
144
|
+
schedule();
|
|
145
|
+
});
|
|
146
|
+
for (const event of inputEvents)document.addEventListener(event, onInput, {
|
|
147
|
+
capture: true,
|
|
148
|
+
passive: true
|
|
149
|
+
});
|
|
150
|
+
document.addEventListener('visibilitychange', onVisibility);
|
|
151
|
+
window.addEventListener('blur', onBlur);
|
|
152
|
+
window.addEventListener('focus', onFocus);
|
|
153
|
+
window.addEventListener('pagehide', onPageHide);
|
|
154
|
+
window.addEventListener('pageshow', onPageShow);
|
|
155
|
+
return {
|
|
156
|
+
start (initial) {
|
|
157
|
+
record(initial);
|
|
158
|
+
started = true;
|
|
159
|
+
schedule();
|
|
160
|
+
},
|
|
161
|
+
notify () {
|
|
162
|
+
if (!closed) channel?.postMessage(null);
|
|
163
|
+
else {
|
|
164
|
+
// A submitted save can finish after its reader has unmounted.
|
|
165
|
+
notifyTestDocument(apiRoute, id);
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
close () {
|
|
169
|
+
closed = true;
|
|
170
|
+
clearTimeout(timer);
|
|
171
|
+
clearTimeout(focusCheck);
|
|
172
|
+
channel?.close();
|
|
173
|
+
for (const event of inputEvents)document.removeEventListener(event, onInput, true);
|
|
174
|
+
document.removeEventListener('visibilitychange', onVisibility);
|
|
175
|
+
window.removeEventListener('blur', onBlur);
|
|
176
|
+
window.removeEventListener('focus', onFocus);
|
|
177
|
+
window.removeEventListener('pagehide', onPageHide);
|
|
178
|
+
window.removeEventListener('pageshow', onPageShow);
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
type SurfaceQuery = Record<string, string | string[] | undefined>;
|
|
2
|
+
export declare function surfaceQuery(query?: SurfaceQuery): string;
|
|
3
|
+
export declare const surfaceUrls: {
|
|
4
|
+
home: (adminRoute: string, query?: SurfaceQuery) => string;
|
|
5
|
+
goals: (adminRoute: string, query?: SurfaceQuery) => string;
|
|
6
|
+
};
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { formatAdminURL } from './format/adminURL.js';
|
|
2
|
+
export function surfaceQuery(query = {}) {
|
|
3
|
+
const params = new URLSearchParams();
|
|
4
|
+
for (const [key, value] of Object.entries(query)){
|
|
5
|
+
if (Array.isArray(value)) value.forEach((item)=>params.append(key, item));
|
|
6
|
+
else if (value !== undefined) params.set(key, value);
|
|
7
|
+
}
|
|
8
|
+
return params.size ? `?${params}` : '';
|
|
9
|
+
}
|
|
10
|
+
export const surfaceUrls = {
|
|
11
|
+
home: (adminRoute, query)=>formatAdminURL({
|
|
12
|
+
adminRoute,
|
|
13
|
+
path: `/collections/xp-experiments${surfaceQuery(query)}`
|
|
14
|
+
}),
|
|
15
|
+
goals: (adminRoute, query)=>formatAdminURL({
|
|
16
|
+
adminRoute,
|
|
17
|
+
path: `/collections/xp-metrics${surfaceQuery(query)}`
|
|
18
|
+
})
|
|
19
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export declare function useApi(apiRoute: string): {
|
|
2
|
+
findTestIdBySlug: (slug: string) => Promise<Extract<import("./api.js").ApiResult<import("../types/contracts.js").DocId>, {
|
|
3
|
+
ok: false;
|
|
4
|
+
}> | {
|
|
5
|
+
ok: true;
|
|
6
|
+
data: import("../types/contracts.js").DocId;
|
|
7
|
+
}>;
|
|
8
|
+
deleteTest: (id: import("../types/contracts.js").DocId, { draft }?: {
|
|
9
|
+
draft?: boolean;
|
|
10
|
+
}) => Promise<import("./api.js").ApiResult<unknown>>;
|
|
11
|
+
wrapBlock: (body: import("../types/endpoints.js").WrapBlockBody) => Promise<import("./api.js").ApiResult<Record<string, unknown>>>;
|
|
12
|
+
pages: (query: {
|
|
13
|
+
collection: string;
|
|
14
|
+
q?: string;
|
|
15
|
+
path?: string;
|
|
16
|
+
page?: number;
|
|
17
|
+
mode?: "block";
|
|
18
|
+
}, signal?: AbortSignal) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").PagesResult>>;
|
|
19
|
+
previewPageCopy: (id: import("../types/contracts.js").DocId, arm: string, signal?: AbortSignal) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").CopyPagePlan>>;
|
|
20
|
+
makePageCopy: (id: import("../types/contracts.js").DocId, arm: string, plan: import("../types/endpoints.js").CopyPagePlan) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").CopyPageResult>>;
|
|
21
|
+
placementStatus: (body: import("../types/endpoints.js").PlacementStatusBody) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").PlacementStatusResult>>;
|
|
22
|
+
start: (id: import("../types/contracts.js").DocId, phase?: number) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").TransitionSuccess>>;
|
|
23
|
+
allocate: (id: import("../types/contracts.js").DocId, body: import("../types/endpoints.js").AllocateBody, options?: {
|
|
24
|
+
notFound?: string;
|
|
25
|
+
forbidden?: string;
|
|
26
|
+
codes?: Readonly<Record<string, string>>;
|
|
27
|
+
fallback?: string;
|
|
28
|
+
}) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").TransitionSuccess>>;
|
|
29
|
+
addMetric: (id: import("../types/contracts.js").DocId, body: import("../types/endpoints.js").AddMetricBody, options?: {
|
|
30
|
+
notFound?: string;
|
|
31
|
+
forbidden?: string;
|
|
32
|
+
codes?: Readonly<Record<string, string>>;
|
|
33
|
+
fallback?: string;
|
|
34
|
+
}) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").AddMetricResult>>;
|
|
35
|
+
stop: (id: import("../types/contracts.js").DocId, phase?: number) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").TransitionSuccess>>;
|
|
36
|
+
decide: (id: import("../types/contracts.js").DocId, body: import("../types/endpoints.js").DecideBody) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").TransitionSuccess>>;
|
|
37
|
+
releaseHoldout: (id: import("../types/contracts.js").DocId, phase?: number) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").TransitionSuccess>>;
|
|
38
|
+
releasePages: (id: import("../types/contracts.js").DocId, phase?: number) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").TransitionSuccess>>;
|
|
39
|
+
makeContent: (id: import("../types/contracts.js").DocId, phase?: number) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").MakeContentResult>>;
|
|
40
|
+
dismissContentEntry: (id: import("../types/contracts.js").DocId, body: import("../types/endpoints.js").DismissContentEntryBody) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").DismissContentEntryResult>>;
|
|
41
|
+
restoreContentEntry: (id: import("../types/contracts.js").DocId, body: import("../types/endpoints.js").RestoreContentEntryBody) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").RestoreContentEntryResult>>;
|
|
42
|
+
archive: (id: import("../types/contracts.js").DocId, body: import("../types/endpoints.js").ArchiveBody) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").TransitionSuccess>>;
|
|
43
|
+
clickKeys: (id: import("../types/contracts.js").DocId) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").ClickKeysResult>>;
|
|
44
|
+
deleteImpact: (id: import("../types/contracts.js").DocId, signal?: AbortSignal) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").DeleteImpactResult>>;
|
|
45
|
+
preflight: (id: import("../types/contracts.js").DocId) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").PreflightResult>>;
|
|
46
|
+
previewToken: (id: import("../types/contracts.js").DocId, arm: string) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").PreviewTokenResult>>;
|
|
47
|
+
results: (id: import("../types/contracts.js").DocId, options?: {
|
|
48
|
+
phase?: number;
|
|
49
|
+
series?: boolean;
|
|
50
|
+
} & {
|
|
51
|
+
notFound?: string;
|
|
52
|
+
forbidden?: string;
|
|
53
|
+
codes?: Readonly<Record<string, string>>;
|
|
54
|
+
fallback?: string;
|
|
55
|
+
}) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").ResultsResponse>>;
|
|
56
|
+
recompute: (id: import("../types/contracts.js").DocId) => Promise<import("./api.js").ApiResult<{
|
|
57
|
+
snapshotId: string;
|
|
58
|
+
}>>;
|
|
59
|
+
summary: (ids: readonly import("../types/contracts.js").DocId[]) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").SummaryResponse>>;
|
|
60
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
/** Focus and visibility can both fire when returning to a tab. */ export function useOnTestReturn(onReturn, enabled = true) {
|
|
4
|
+
useEffect(()=>{
|
|
5
|
+
if (!enabled) return;
|
|
6
|
+
let lastReturn = -Infinity;
|
|
7
|
+
const refresh = ()=>{
|
|
8
|
+
if (document.visibilityState !== 'visible' || Date.now() - lastReturn < 100) return;
|
|
9
|
+
lastReturn = Date.now();
|
|
10
|
+
onReturn();
|
|
11
|
+
};
|
|
12
|
+
const restored = (event)=>{
|
|
13
|
+
if (event.persisted) refresh();
|
|
14
|
+
};
|
|
15
|
+
window.addEventListener('focus', refresh);
|
|
16
|
+
window.addEventListener('pageshow', restored);
|
|
17
|
+
document.addEventListener('visibilitychange', refresh);
|
|
18
|
+
return ()=>{
|
|
19
|
+
window.removeEventListener('focus', refresh);
|
|
20
|
+
window.removeEventListener('pageshow', restored);
|
|
21
|
+
document.removeEventListener('visibilitychange', refresh);
|
|
22
|
+
};
|
|
23
|
+
}, [
|
|
24
|
+
enabled,
|
|
25
|
+
onReturn
|
|
26
|
+
]);
|
|
27
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ReadinessRead } from './readinessRead.js';
|
|
2
|
+
/** Non-shared reads use the same visible-only delay policy as editor cache reads. */
|
|
3
|
+
export declare function useReadinessPolling(read: ReadinessRead | undefined, refresh: () => void, enabled?: boolean, pending?: boolean): void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef } from 'react';
|
|
3
|
+
/** Non-shared reads use the same visible-only delay policy as editor cache reads. */ export function useReadinessPolling(read, refresh, enabled = true, pending = false) {
|
|
4
|
+
const action = useRef(refresh);
|
|
5
|
+
action.current = refresh;
|
|
6
|
+
useEffect(()=>{
|
|
7
|
+
if (!enabled || pending || !read?.pollDelay) return;
|
|
8
|
+
let timer;
|
|
9
|
+
const schedule = ()=>{
|
|
10
|
+
clearTimeout(timer);
|
|
11
|
+
if (document.visibilityState === 'visible') timer = setTimeout(()=>{
|
|
12
|
+
if (document.visibilityState === 'visible') action.current();
|
|
13
|
+
}, read.pollDelay);
|
|
14
|
+
};
|
|
15
|
+
schedule();
|
|
16
|
+
document.addEventListener('visibilitychange', schedule);
|
|
17
|
+
return ()=>{
|
|
18
|
+
clearTimeout(timer);
|
|
19
|
+
document.removeEventListener('visibilitychange', schedule);
|
|
20
|
+
};
|
|
21
|
+
}, [
|
|
22
|
+
read,
|
|
23
|
+
enabled,
|
|
24
|
+
pending
|
|
25
|
+
]);
|
|
26
|
+
}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import type { PayloadRequest } from 'payload';
|
|
2
2
|
import type { DocId, ResolvedOptions } from '../types/contracts.js';
|
|
3
|
-
import type { AddMetricBody } from '../types/endpoints.js';
|
|
3
|
+
import type { AddMetricBody, AddMetricWarning } from '../types/endpoints.js';
|
|
4
4
|
export declare function addMetric<TUser extends {
|
|
5
5
|
id: DocId;
|
|
6
|
-
}>(req: PayloadRequest, { experimentId, metric, role, options }: AddMetricBody & {
|
|
6
|
+
}>(req: PayloadRequest, { experimentId, metric, role, phase: expectedPhase, options }: AddMetricBody & {
|
|
7
7
|
experimentId: DocId;
|
|
8
8
|
options: ResolvedOptions<TUser>;
|
|
9
9
|
}): Promise<{
|
|
10
|
-
detail?:
|
|
11
|
-
|
|
12
|
-
message: string;
|
|
13
|
-
}[] | undefined;
|
|
10
|
+
detail?: import("../types/endpoints.js").StartExperimentWarning[] | undefined;
|
|
11
|
+
warnings: AddMetricWarning[];
|
|
14
12
|
doc: import("payload").JsonObject & import("payload").TypeWithID;
|
|
15
13
|
revision: number;
|
|
16
14
|
}>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { asymmetricGoal, goalContent, goalPlacementDetail } from '../goals/fairness.js';
|
|
1
2
|
import { lockMetricsForFreeze } from '../db/metricUsage.js';
|
|
2
3
|
import { readState } from '../db/state.js';
|
|
3
4
|
import { XpRefusal } from '../errors.js';
|
|
@@ -5,9 +6,12 @@ import { relationshipId } from './checkStart.js';
|
|
|
5
6
|
import { withTransition } from './kernel.js';
|
|
6
7
|
import { readExperiment, refuse, updateExperiment } from './start.js';
|
|
7
8
|
import { resolveCaps } from './resolveCaps.js';
|
|
8
|
-
|
|
9
|
+
import { requireCurrentRound } from './phaseRecord.js';
|
|
10
|
+
export async function addMetric(req, { experimentId, metric, role, phase: expectedPhase, options }) {
|
|
9
11
|
if (role !== 'secondary' && role !== 'guardrail') refuse('invalid-body');
|
|
10
12
|
const before = await readExperiment(req, experimentId);
|
|
13
|
+
const openedPhase = before.phase;
|
|
14
|
+
requireCurrentRound(expectedPhase, openedPhase);
|
|
11
15
|
if (before.status !== 'running') refuse('invalid-status');
|
|
12
16
|
const found = await req.payload.find({
|
|
13
17
|
collection: 'xp-metrics',
|
|
@@ -23,6 +27,31 @@ export async function addMetric(req, { experimentId, metric, role, options }) {
|
|
|
23
27
|
});
|
|
24
28
|
if (!found.docs[0]) throw new XpRefusal('not-found', 'Metric not found', undefined, 404);
|
|
25
29
|
const metricId = found.docs[0].id;
|
|
30
|
+
const warnings = [];
|
|
31
|
+
if (String(found.docs[0].source).startsWith('click:')) {
|
|
32
|
+
const content = await goalContent(req, options, before);
|
|
33
|
+
if (asymmetricGoal(content, String(found.docs[0].source), before.arms)) {
|
|
34
|
+
const detail = {
|
|
35
|
+
metricId,
|
|
36
|
+
name: found.docs[0].name
|
|
37
|
+
};
|
|
38
|
+
if (role === 'guardrail') refuse('goal-in-some-versions', detail);
|
|
39
|
+
warnings.push({
|
|
40
|
+
code: 'goal-in-some-versions',
|
|
41
|
+
detail
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
warnings.push(...content.unchecked.map((placement)=>({
|
|
45
|
+
code: 'placement-unchecked',
|
|
46
|
+
detail: goalPlacementDetail(placement)
|
|
47
|
+
})));
|
|
48
|
+
warnings.push({
|
|
49
|
+
code: 'goal-added-mid-test',
|
|
50
|
+
detail: {
|
|
51
|
+
metricId
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
26
55
|
const at = new Date();
|
|
27
56
|
// §5.4: cap history ends at the phase start, never inside the running phase.
|
|
28
57
|
const started = before.startedAt;
|
|
@@ -36,6 +65,7 @@ export async function addMetric(req, { experimentId, metric, role, options }) {
|
|
|
36
65
|
bump: false
|
|
37
66
|
}, async ({ req, exec })=>{
|
|
38
67
|
const current = await readExperiment(req, experimentId);
|
|
68
|
+
requireCurrentRound(expectedPhase ?? openedPhase, current.phase);
|
|
39
69
|
if (current.status !== 'running') refuse('invalid-status');
|
|
40
70
|
const ids = [
|
|
41
71
|
current.metrics?.primary,
|
|
@@ -53,7 +83,7 @@ export async function addMetric(req, { experimentId, metric, role, options }) {
|
|
|
53
83
|
if (lockedMetrics[0].slug !== definition.slug || lockedMetrics[0].source !== definition.source) {
|
|
54
84
|
throw new XpRefusal('stale-draft', 'This goal changed. Review it again before adding it.', undefined, 409);
|
|
55
85
|
}
|
|
56
|
-
if (current.unitType === 'user' && definition.keyedBy === 'visitor' && !definition.source.startsWith('events:')) refuse('unit-source-mismatch');
|
|
86
|
+
if (current.unitType === 'user' && definition.keyedBy === 'visitor' && !definition.source.startsWith('events:') && !definition.source.startsWith('click:')) refuse('unit-source-mismatch');
|
|
57
87
|
// §7.8: phase lookup serves the access-authorised transition write.
|
|
58
88
|
const phases = await req.payload.find({
|
|
59
89
|
collection: 'xp-phases',
|
|
@@ -127,6 +157,7 @@ export async function addMetric(req, { experimentId, metric, role, options }) {
|
|
|
127
157
|
});
|
|
128
158
|
return {
|
|
129
159
|
...result,
|
|
160
|
+
warnings,
|
|
130
161
|
...caps.detail.length ? {
|
|
131
162
|
detail: caps.detail
|
|
132
163
|
} : {}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { PayloadRequest } from 'payload';
|
|
2
2
|
import type { DocId } from '../types/contracts.js';
|
|
3
|
-
|
|
3
|
+
import type { AllocateBody } from '../types/endpoints.js';
|
|
4
|
+
export declare function allocate(req: PayloadRequest, { experimentId, allocation, phase: expectedPhase }: AllocateBody & {
|
|
4
5
|
experimentId: DocId;
|
|
5
|
-
allocation: number;
|
|
6
6
|
}): Promise<{
|
|
7
7
|
doc: import("payload").JsonObject & import("payload").TypeWithID;
|
|
8
8
|
revision: number;
|
|
@@ -3,8 +3,9 @@ import { appendAllocationChange } from '../db/appends.js';
|
|
|
3
3
|
import { claimSlices } from '../db/slices.js';
|
|
4
4
|
import { relationshipId } from './checkStart.js';
|
|
5
5
|
import { withTransition } from './kernel.js';
|
|
6
|
+
import { requireCurrentRound } from './phaseRecord.js';
|
|
6
7
|
import { readExperiment, refuse, updateExperiment } from './start.js';
|
|
7
|
-
export async function allocate(req, { experimentId, allocation }) {
|
|
8
|
+
export async function allocate(req, { experimentId, allocation, phase: expectedPhase }) {
|
|
8
9
|
if (!Number.isInteger(allocation) || allocation < 1 || allocation > 100) refuse('invalid-body');
|
|
9
10
|
const before = await readExperiment(req, experimentId);
|
|
10
11
|
const { result: doc, revision } = await withTransition(req, {
|
|
@@ -12,6 +13,7 @@ export async function allocate(req, { experimentId, allocation }) {
|
|
|
12
13
|
layerId: relationshipId(before.layer)
|
|
13
14
|
}, async ({ req, exec })=>{
|
|
14
15
|
const current = await readExperiment(req, experimentId);
|
|
16
|
+
requireCurrentRound(expectedPhase, current.phase);
|
|
15
17
|
if (current.status !== 'running') refuse('invalid-status');
|
|
16
18
|
if (allocation <= current.allocation) refuse('allocation-lower');
|
|
17
19
|
const layerId = relationshipId(current.layer);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PayloadRequest } from 'payload';
|
|
2
2
|
import type { DocId } from '../types/contracts.js';
|
|
3
3
|
import type { ArchiveBody } from '../types/endpoints.js';
|
|
4
|
-
export declare function archive(req: PayloadRequest, { experimentId, mode, confirmation }: ArchiveBody & {
|
|
4
|
+
export declare function archive(req: PayloadRequest, { experimentId, mode, confirmation, phase: expectedPhase }: ArchiveBody & {
|
|
5
5
|
experimentId: DocId;
|
|
6
6
|
}): Promise<{
|
|
7
7
|
doc: import("payload").JsonObject & import("payload").TypeWithID;
|
|
@@ -2,15 +2,16 @@ import { contentDone } from '../contentDone.js';
|
|
|
2
2
|
import { relationshipId } from './checkStart.js';
|
|
3
3
|
import { expectedConfirm, matchesConfirm, storedWinnerLabel } from './confirmPhrases.js';
|
|
4
4
|
import { withTransition } from './kernel.js';
|
|
5
|
-
import { setPhaseEndedAt } from './phaseRecord.js';
|
|
5
|
+
import { requireCurrentRound, setPhaseEndedAt } from './phaseRecord.js';
|
|
6
6
|
import { readExperiment, refuse, updateExperiment } from './start.js';
|
|
7
|
-
export async function archive(req, { experimentId, mode, confirmation }) {
|
|
7
|
+
export async function archive(req, { experimentId, mode, confirmation, phase: expectedPhase }) {
|
|
8
8
|
const before = await readExperiment(req, experimentId);
|
|
9
9
|
const { result: doc, revision } = await withTransition(req, {
|
|
10
10
|
experimentId,
|
|
11
11
|
layerId: relationshipId(before.layer)
|
|
12
12
|
}, async ({ req })=>{
|
|
13
13
|
const current = await readExperiment(req, experimentId);
|
|
14
|
+
requireCurrentRound(expectedPhase, current.phase);
|
|
14
15
|
const decision = current.decision;
|
|
15
16
|
if (mode === 'stopped' ? current.status !== 'stopped' : current.status !== 'decided') refuse('invalid-status');
|
|
16
17
|
if (mode === 'hard-coded' && current.kind !== 'code') refuse('invalid-status');
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
+
import { type GoalContent } from '../goals/fairness.js';
|
|
1
2
|
import type { Arm, DocId, ExperimentKind, ExposurePolicy, FlagPoint, MetricSource, ResolvedOptions, Status, TargetingRule, UnitType } from '../types/contracts.js';
|
|
2
3
|
import type { ArmIssueCode, PreflightResult } from '../types/endpoints.js';
|
|
3
4
|
import type { BlockPlacement, FlagPlacement } from './placements.js';
|
|
4
|
-
export type ReadinessCode = ArmIssueCode | 'invalid-status' | 'no-planned-duration' | 'no-primary-metric' | 'no-reach-per-day' | 'page-no-targets' | 'page-in-use' | 'page-target-unpublished' | 'page-targets-unchecked' | 'version-page-unavailable' | 'version-page-unchecked' | 'page-user-unit' | 'flag-no-point' | 'flag-params-invalid' | 'flag-point-busy' | 'flag-placement-missing' | 'no-placements' | 'empty-slot' | 'make-content-unsupported' | 'layer-unit-mismatch' | 'layer-full' | 'unknown-metric-source' | 'unit-source-mismatch' | 'block-path-rule' | 'undeclared-targeting-key' | 'invalid-targeting-rule';
|
|
5
|
+
export type ReadinessCode = ArmIssueCode | 'nested-tests' | 'goal-in-some-versions' | 'placement-unchecked' | 'invalid-status' | 'no-planned-duration' | 'no-primary-metric' | 'no-reach-per-day' | 'placement-unpublished' | 'duplicate-version-row' | 'interacting-tests' | 'version-identical' | 'version-same-address' | 'unknown-collection' | 'page-no-targets' | 'page-in-use' | 'page-target-unpublished' | 'page-targets-unchecked' | 'version-page-unavailable' | 'version-page-unchecked' | 'page-user-unit' | 'flag-no-point' | 'flag-params-invalid' | 'flag-point-busy' | 'flag-placement-missing' | 'no-placements' | 'placement-removed' | 'empty-slot' | 'make-content-unsupported' | 'layer-unit-mismatch' | 'layer-full' | 'unknown-metric-source' | 'unit-source-mismatch' | 'block-path-rule' | 'undeclared-targeting-key' | 'invalid-targeting-rule';
|
|
5
6
|
export interface StartExperiment {
|
|
6
7
|
id: DocId;
|
|
7
8
|
slug: string;
|
|
8
9
|
status: Status;
|
|
9
10
|
kind: ExperimentKind;
|
|
10
11
|
unitType: UnitType;
|
|
12
|
+
phase?: number;
|
|
13
|
+
updatedAt?: string;
|
|
14
|
+
pageCollection?: string | null;
|
|
11
15
|
arms: Arm[];
|
|
12
16
|
allocation: number;
|
|
13
17
|
exposurePolicy: ExposurePolicy;
|
|
@@ -37,6 +41,7 @@ export interface StartExperiment {
|
|
|
37
41
|
export interface StartMetric {
|
|
38
42
|
id: DocId;
|
|
39
43
|
source: string;
|
|
44
|
+
name?: string;
|
|
40
45
|
}
|
|
41
46
|
export type PlacementFailure = 'placements-failed' | 'forbidden' | 'not-found';
|
|
42
47
|
export interface CheckStartInput {
|
|
@@ -46,9 +51,21 @@ export interface CheckStartInput {
|
|
|
46
51
|
flagPoints?: FlagPoint[];
|
|
47
52
|
placements?: BlockPlacement[];
|
|
48
53
|
flagPlacements?: FlagPlacement[];
|
|
54
|
+
placementLocaleCodes?: readonly string[];
|
|
55
|
+
placementLocale?: string;
|
|
56
|
+
placementDefaultLocale?: string;
|
|
49
57
|
placementError?: PlacementFailure;
|
|
50
58
|
flagPlacementError?: PlacementFailure;
|
|
51
59
|
flagPointBusy?: boolean;
|
|
60
|
+
goalContent?: GoalContent;
|
|
61
|
+
interactions?: import('./placementInteractions.js').InteractionDetail[];
|
|
62
|
+
unknownPageCollection?: boolean;
|
|
63
|
+
identicalVersions?: Array<{
|
|
64
|
+
arm: string;
|
|
65
|
+
path: string;
|
|
66
|
+
collection: string;
|
|
67
|
+
id: DocId;
|
|
68
|
+
}>;
|
|
52
69
|
unpublishedPageTargets?: string[];
|
|
53
70
|
pageTargetsUnchecked?: boolean;
|
|
54
71
|
pageTestsInUse?: Pick<StartExperiment, 'id' | 'arms'>[];
|