@delmaredigital/payload-experiments 0.4.0-rc.1 → 0.4.0-rc.11
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 +284 -772
- package/dist/admin/LayerUsage.js +1 -1
- package/dist/admin/MetricSourceSelect.js +12 -5
- package/dist/admin/PlacementStatus.js +1 -1
- 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 +1 -0
- package/dist/admin/blocks/BlockPanel.js +129 -37
- package/dist/admin/blocks/TestBlockField.js +3 -3
- package/dist/admin/blocks/formApi.d.ts +3 -0
- package/dist/admin/blocks/formApi.js +10 -4
- package/dist/admin/blocks/inject.js +1 -0
- package/dist/admin/blocks/model.d.ts +3 -2
- package/dist/admin/blocks/model.js +10 -6
- package/dist/admin/blocks/statusCache.d.ts +2 -0
- package/dist/admin/blocks/statusCache.js +12 -3
- package/dist/admin/components/RootViewMessage.js +1 -1
- package/dist/admin/copy/blocks.d.ts +21 -1
- package/dist/admin/copy/blocks.js +40 -6
- package/dist/admin/copy/goals.d.ts +21 -9
- package/dist/admin/copy/goals.js +28 -11
- package/dist/admin/copy/newTest.d.ts +7 -7
- package/dist/admin/copy/newTest.js +10 -7
- package/dist/admin/goals/XpGoalField.d.ts +2 -0
- package/dist/admin/goals/XpGoalField.js +156 -114
- package/dist/admin/goals/xpGoalField.css +47 -0
- package/dist/admin/pageCollections.d.ts +1 -0
- package/dist/admin/pageCollections.js +3 -0
- package/dist/admin/paths.d.ts +3 -0
- package/dist/admin/paths.js +3 -0
- package/dist/admin/placementStatus.model.js +1 -1
- 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.d.ts +4 -2
- package/dist/admin/surface/SurfaceShell.js +29 -4
- package/dist/admin/surface/TestRowMenu.d.ts +13 -0
- package/dist/admin/surface/TestRowMenu.js +163 -0
- package/dist/admin/surface/TestsHome.d.ts +5 -3
- package/dist/admin/surface/TestsHome.js +273 -58
- package/dist/admin/surface/TestsSurface.js +8 -7
- package/dist/admin/surface/goals/DeleteGoalDialog.d.ts +7 -0
- package/dist/admin/surface/goals/DeleteGoalDialog.js +42 -0
- package/dist/admin/surface/goals/GoalForm.d.ts +2 -1
- package/dist/admin/surface/goals/GoalForm.js +342 -212
- package/dist/admin/surface/goals/GoalsList.d.ts +1 -1
- package/dist/admin/surface/goals/GoalsList.js +107 -37
- package/dist/admin/surface/goals/data.d.ts +2 -0
- package/dist/admin/surface/goals/data.js +11 -2
- package/dist/admin/surface/goals/goals.css +9 -1
- package/dist/admin/surface/goals/goals.model.d.ts +12 -2
- package/dist/admin/surface/goals/goals.model.js +39 -1
- package/dist/admin/surface/home.model.d.ts +10 -8
- package/dist/admin/surface/home.model.js +27 -22
- package/dist/admin/surface/newTest/NewTest.d.ts +4 -4
- package/dist/admin/surface/newTest/NewTest.js +149 -118
- package/dist/admin/surface/newTest/PageWizard.d.ts +5 -2
- package/dist/admin/surface/newTest/PageWizard.js +115 -80
- package/dist/admin/surface/newTest/newTest.css +28 -9
- package/dist/admin/surface/results/ResultsHeader.d.ts +3 -3
- package/dist/admin/surface/results/ResultsHeader.js +115 -83
- package/dist/admin/surface/surface.css +29 -0
- package/dist/admin/surface/test/TestPage.d.ts +1 -2
- package/dist/admin/surface/test/TestPage.js +44 -152
- package/dist/admin/surface/useXpStepNav.d.ts +11 -0
- package/dist/admin/surface/useXpStepNav.js +14 -0
- 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 +18 -165
- 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 +35 -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.js +8 -14
- package/dist/blocks/createExperimentBlock.js +1 -1
- package/dist/blocks/formState.js +2 -2
- 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/collections/experiments/config.js +17 -8
- package/dist/collections/experiments/deleteGuard.js +2 -2
- package/dist/collections/experiments/lockHook.js +21 -2
- package/dist/collections/experiments/pickSlug.js +2 -0
- package/dist/collections/metrics.js +28 -9
- package/dist/collections/metricsGuards.js +2 -0
- package/dist/collections/serialize.js +8 -6
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/db/adapter.d.ts +9 -1
- package/dist/db/adapter.js +77 -1
- package/dist/db/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/delete.d.ts +1 -1
- package/dist/db/delete.js +2 -4
- package/dist/db/events.d.ts +9 -0
- package/dist/db/events.js +42 -8
- package/dist/db/executor.d.ts +7 -1
- package/dist/db/executor.js +7 -3
- package/dist/db/pageCopies.d.ts +5 -0
- package/dist/db/pageCopies.js +31 -0
- package/dist/db/placements.d.ts +2 -0
- package/dist/db/placements.js +8 -0
- package/dist/db/results.d.ts +5 -1
- package/dist/db/results.js +21 -5
- package/dist/db/snapshots.d.ts +2 -0
- package/dist/endpoints/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 +103 -39
- package/dist/endpoints/index.js +57 -9
- package/dist/endpoints/pages.js +247 -64
- package/dist/endpoints/placementStatus.js +13 -5
- package/dist/endpoints/preflight.d.ts +1 -1
- package/dist/endpoints/preflight.js +17 -2
- package/dist/endpoints/results.d.ts +1 -1
- package/dist/endpoints/results.js +6 -2
- package/dist/endpoints/routeId.d.ts +2 -2
- package/dist/endpoints/routeId.js +11 -5
- package/dist/endpoints/summary.js +46 -12
- package/dist/endpoints/testVersion.d.ts +2 -0
- package/dist/endpoints/testVersion.js +38 -0
- package/dist/endpoints/transitions.js +41 -29
- package/dist/errors.d.ts +5 -0
- package/dist/errors.js +8 -0
- package/dist/events/request.d.ts +6 -2
- package/dist/events/request.js +35 -8
- package/dist/events/rows.d.ts +1 -1
- package/dist/events/rows.js +24 -8
- package/dist/events/writable.d.ts +9 -0
- package/dist/events/writable.js +13 -0
- package/dist/exports/adminClient.d.ts +1 -1
- package/dist/exports/adminClient.js +1 -1
- package/dist/exports/adminRsc.d.ts +3 -0
- package/dist/exports/adminRsc.js +3 -0
- package/dist/exports/index.d.ts +1 -1
- package/dist/exports/rsc.d.ts +1 -0
- package/dist/exports/rsc.js +1 -0
- package/dist/fields/xpGoal.js +3 -15
- package/dist/goals/fairness.d.ts +1 -1
- package/dist/goals/fairness.js +44 -35
- package/dist/goals/picker/clickGoalPicker.model.d.ts +8 -1
- package/dist/goals/picker/clickGoalPicker.model.js +20 -2
- package/dist/goals/picker/copy.d.ts +6 -2
- package/dist/goals/picker/copy.js +11 -2
- package/dist/goals/picker/useClickGoalPicker.d.ts +1 -1
- package/dist/goals/picker/useClickGoalPicker.js +4 -2
- package/dist/goals/sourceLabel.d.ts +2 -0
- package/dist/goals/sourceLabel.js +4 -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 +27 -2
- package/dist/hooks/pageGuard.js +213 -45
- 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 +36 -0
- package/dist/options.d.ts +2 -0
- package/dist/options.js +23 -2
- package/dist/plugin.js +70 -21
- 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 +5 -1
- package/dist/puck/copy.js +5 -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.d.ts +2 -1
- package/dist/puck/editor/ExperimentSlotEditor.js +1007 -182
- 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 +72 -0
- package/dist/puck/editor/ResultsReadout.d.ts +4 -1
- package/dist/puck/editor/ResultsReadout.js +35 -19
- package/dist/puck/editor/VersionBuilder.d.ts +67 -12
- package/dist/puck/editor/VersionBuilder.js +560 -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 +65 -20
- package/dist/puck/editor/copy.js +73 -21
- package/dist/puck/editor/createTest.d.ts +3 -0
- package/dist/puck/editor/createTest.js +33 -0
- package/dist/puck/editor/editor.chrome.css +200 -20
- package/dist/puck/editor/editor.css +338 -25
- package/dist/puck/editor/editor.model.d.ts +17 -1
- package/dist/puck/editor/editor.model.js +61 -4
- 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/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.js +105 -86
- 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/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 +2 -2
- package/dist/puck/slotConfig.js +18 -5
- package/dist/puck/visibility.d.ts +20 -0
- package/dist/puck/visibility.js +81 -0
- package/dist/results/aggregate.d.ts +6 -3
- package/dist/results/aggregate.js +9 -9
- package/dist/results/analyse.d.ts +2 -0
- package/dist/results/analyse.js +2 -2
- package/dist/results/health.d.ts +8 -0
- package/dist/results/health.js +28 -0
- package/dist/results/identityCredit.d.ts +1 -0
- package/dist/results/identityCredit.js +4 -1
- package/dist/results/verdict.d.ts +1 -1
- package/dist/results/verdict.js +9 -7
- 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 +22 -2
- package/dist/server/getAssignments.js +11 -10
- package/dist/server/recordContentChange.d.ts +1 -1
- package/dist/server/recordContentChange.js +48 -22
- package/dist/server/resolveExperimentBlocks.js +2 -4
- package/dist/server/resolveExperimentData.js +8 -8
- package/dist/server/runResults.js +54 -15
- package/dist/server/startExperiment.d.ts +20 -0
- package/dist/server/startExperiment.js +70 -0
- package/dist/server/trackConversion.js +10 -13
- package/dist/{admin → testSurface}/PreviewLinks.d.ts +2 -1
- package/dist/{admin → testSurface}/PreviewLinks.js +9 -5
- package/dist/testSurface/actions/DecideDialog.d.ts +17 -0
- package/dist/testSurface/actions/DecideDialog.js +222 -0
- package/dist/testSurface/actions/LifecycleAction.d.ts +17 -0
- package/dist/testSurface/actions/LifecycleAction.js +107 -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 +123 -0
- package/dist/{admin → testSurface}/actions/decide.model.d.ts +1 -0
- package/dist/{admin → testSurface}/actions/decide.model.js +1 -0
- package/dist/{admin → testSurface}/allocation.model.js +6 -3
- package/dist/{admin → testSurface}/api.d.ts +20 -7
- package/dist/{admin → testSurface}/api.js +72 -22
- package/dist/testSurface/contentLocaleURL.d.ts +2 -0
- package/dist/testSurface/contentLocaleURL.js +3 -0
- package/dist/{admin → testSurface}/copy/actions.d.ts +37 -14
- package/dist/{admin → testSurface}/copy/actions.js +40 -17
- package/dist/{admin → testSurface}/copy/advanced.d.ts +10 -0
- package/dist/{admin → testSurface}/copy/advanced.js +10 -0
- package/dist/{admin → testSurface}/copy/arms.d.ts +1 -1
- package/dist/{admin → testSurface}/copy/arms.js +1 -1
- package/dist/{admin → testSurface}/copy/audience.d.ts +4 -3
- package/dist/{admin → testSurface}/copy/audience.js +5 -4
- package/dist/{admin → testSurface}/copy/common.d.ts +15 -6
- package/dist/{admin → testSurface}/copy/common.js +20 -10
- 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 +7 -0
- package/dist/testSurface/copy/metrics.js +18 -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 +40 -6
- package/dist/{admin → testSurface}/copy/readiness.js +54 -9
- package/dist/{admin → testSurface}/copy/recommendation.d.ts +4 -4
- package/dist/{admin → testSurface}/copy/recommendation.js +4 -4
- package/dist/{admin → testSurface}/copy/results.d.ts +19 -12
- package/dist/{admin → testSurface}/copy/results.js +21 -12
- package/dist/testSurface/copy/review.d.ts +20 -0
- package/dist/testSurface/copy/review.js +21 -0
- package/dist/{admin → testSurface}/copy/setting.d.ts +1 -2
- package/dist/{admin → testSurface}/copy/setting.js +1 -2
- package/dist/{admin → testSurface}/copy/surface.d.ts +11 -2
- package/dist/{admin → testSurface}/copy/surface.js +14 -11
- package/dist/{admin → testSurface}/copy/testPage.d.ts +61 -12
- package/dist/testSurface/copy/testPage.js +168 -0
- package/dist/testSurface/format/adminURL.d.ts +7 -0
- package/dist/testSurface/format/adminURL.js +9 -0
- package/dist/{admin → testSurface}/format/date.d.ts +1 -0
- package/dist/testSurface/format/date.js +21 -0
- package/dist/{admin → testSurface}/labels.d.ts +1 -2
- package/dist/{admin → testSurface}/labels.js +2 -3
- package/dist/{admin → testSurface}/lockedNotice.model.d.ts +2 -0
- package/dist/{admin → testSurface}/lockedNotice.model.js +31 -0
- package/dist/testSurface/placementLabel.d.ts +8 -0
- package/dist/testSurface/placementLabel.js +24 -0
- package/dist/{admin → testSurface}/placements/placementLabels.d.ts +2 -0
- package/dist/{admin → testSurface}/placements/placementLabels.js +3 -2
- 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/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 -2
- package/dist/{admin → testSurface}/results/results.model.js +16 -11
- package/dist/{admin → testSurface}/surface/contracts.d.ts +17 -3
- 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/testSurface/surface/pageBlock/parts.js +107 -0
- 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 +498 -0
- package/dist/testSurface/surface/pagePicker/pagePicker.css +73 -0
- package/dist/{admin → testSurface}/surface/pagePicker/pagePicker.model.d.ts +7 -3
- package/dist/{admin → testSurface}/surface/pagePicker/pagePicker.model.js +17 -2
- package/dist/{admin → testSurface}/surface/readiness/ActionDialogs.d.ts +9 -5
- package/dist/testSurface/surface/readiness/ActionDialogs.js +372 -0
- package/dist/{admin → testSurface}/surface/readiness/Banner.d.ts +4 -3
- package/dist/testSurface/surface/readiness/Banner.js +198 -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 +13 -0
- package/dist/testSurface/surface/readiness/SaveStatus.js +67 -0
- package/dist/{admin → testSurface}/surface/readiness/parts.js +0 -2
- package/dist/{admin → testSurface}/surface/readiness/readiness.model.d.ts +28 -2
- 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/{admin → testSurface}/surface/results/ReleasePages.d.ts +6 -3
- package/dist/{admin → testSurface}/surface/results/ReleasePages.js +40 -40
- package/dist/{admin → testSurface}/surface/results/ResultsBody.d.ts +11 -4
- package/dist/{admin → testSurface}/surface/results/ResultsBody.js +207 -104
- package/dist/{admin → testSurface}/surface/results/recommendation.model.js +3 -3
- package/dist/{admin → testSurface}/surface/results/useResults.d.ts +26 -8
- package/dist/{admin → testSurface}/surface/results/useResults.js +3 -2
- package/dist/{admin → testSurface}/surface/setting/parts.js +89 -46
- package/dist/testSurface/surface/setting/setting.css +18 -0
- package/dist/{admin → testSurface}/surface/test/AdvancedSection.js +12 -4
- 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/{admin → testSurface}/surface/test/GoalSection.js +119 -89
- package/dist/testSurface/surface/test/LengthSection.d.ts +2 -0
- package/dist/{admin → testSurface}/surface/test/LengthSection.js +25 -14
- package/dist/{admin → testSurface}/surface/test/PageHoldout.d.ts +1 -1
- package/dist/{admin → testSurface}/surface/test/PageHoldout.js +11 -8
- package/dist/{admin → testSurface}/surface/test/Rail.js +7 -4
- package/dist/{admin → testSurface}/surface/test/ReadinessBar.d.ts +2 -1
- package/dist/{admin → testSurface}/surface/test/ReadinessBar.js +4 -11
- package/dist/{admin → testSurface}/surface/test/Section.d.ts +3 -1
- package/dist/testSurface/surface/test/Section.js +88 -0
- package/dist/{admin → testSurface}/surface/test/TargetingSection.js +87 -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/testSurface/surface/test/VersionsSection.js +301 -0
- package/dist/{admin → testSurface}/surface/test/fields.d.ts +33 -9
- package/dist/testSurface/surface/test/fields.js +300 -0
- package/dist/{admin → testSurface}/surface/test/pageParts.js +30 -44
- package/dist/testSurface/surface/test/testPage.css +111 -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 +3 -0
- package/dist/{admin → testSurface}/surface/testDocument.model.js +4 -1
- 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 +8 -0
- package/dist/testSurface/surfaceUrls.js +23 -0
- package/dist/{admin → testSurface}/useApi.d.ts +21 -5
- 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 +2 -5
- package/dist/transitions/addMetric.js +5 -1
- package/dist/transitions/allocate.d.ts +2 -2
- package/dist/transitions/allocate.js +3 -1
- package/dist/transitions/archive.d.ts +1 -1
- package/dist/transitions/archive.js +3 -2
- package/dist/transitions/checkStart.d.ts +6 -1
- package/dist/transitions/checkStart.js +133 -17
- package/dist/transitions/contentFields.js +9 -5
- package/dist/transitions/decide.d.ts +1 -1
- package/dist/transitions/decide.js +6 -3
- package/dist/transitions/deleteExperiment.d.ts +2 -2
- package/dist/transitions/deleteExperiment.js +17 -7
- package/dist/transitions/kernel.d.ts +4 -0
- package/dist/transitions/kernel.js +9 -4
- package/dist/transitions/makeContent.d.ts +2 -1
- package/dist/transitions/makeContent.js +41 -17
- 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/pageVersions.js +3 -1
- package/dist/transitions/phaseRecord.d.ts +2 -0
- package/dist/transitions/phaseRecord.js +5 -0
- package/dist/transitions/placementInteractions.d.ts +3 -3
- package/dist/transitions/placementInteractions.js +16 -12
- package/dist/transitions/placements.d.ts +54 -8
- package/dist/transitions/placements.js +304 -81
- package/dist/transitions/preflightData.d.ts +5 -3
- package/dist/transitions/preflightData.js +137 -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 +2 -4
- package/dist/transitions/start.d.ts +6 -8
- package/dist/transitions/start.js +72 -35
- 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/contracts.d.ts +15 -3
- package/dist/types/endpoints.d.ts +121 -17
- package/dist/types/puck.d.ts +1 -0
- package/dist/types/runtime.d.ts +15 -9
- package/dist/types/snapshot.d.ts +2 -0
- package/dist/types/surface.d.ts +9 -9
- 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 +141 -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 +6 -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 +50 -5
- package/package.json +3 -2
- package/dist/admin/actions/ConfirmDialog.d.ts +0 -19
- package/dist/admin/actions/ConfirmDialog.js +0 -149
- package/dist/admin/actions/DecideDialog.d.ts +0 -10
- package/dist/admin/actions/DecideDialog.js +0 -190
- package/dist/admin/actions/actions.model.js +0 -70
- package/dist/admin/copy/metrics.js +0 -9
- package/dist/admin/copy/pages.d.ts +0 -26
- package/dist/admin/copy/pages.js +0 -26
- package/dist/admin/copy/review.d.ts +0 -17
- package/dist/admin/copy/review.js +0 -17
- package/dist/admin/copy/testPage.js +0 -104
- package/dist/admin/format/date.js +0 -10
- 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/pageBlock/parts.js +0 -69
- package/dist/admin/surface/pagePicker/CopyRoute.d.ts +0 -6
- package/dist/admin/surface/pagePicker/CopyRoute.js +0 -53
- package/dist/admin/surface/pagePicker/PagePicker.d.ts +0 -10
- package/dist/admin/surface/pagePicker/PagePicker.js +0 -172
- package/dist/admin/surface/readiness/ActionDialogs.js +0 -337
- package/dist/admin/surface/readiness/Banner.js +0 -190
- 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.js +0 -205
- package/dist/admin/surface/readiness/useTransition.d.ts +0 -11
- package/dist/admin/surface/readiness/useTransition.js +0 -35
- package/dist/admin/surface/setting/setting.css +0 -17
- package/dist/admin/surface/test/GoalSection.d.ts +0 -2
- 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/VersionsSection.js +0 -247
- package/dist/admin/surface/test/fields.js +0 -216
- package/dist/admin/surface/test/testPage.css +0 -97
- package/dist/admin/surface/useTestDocument.d.ts +0 -32
- package/dist/admin/surface/useTestDocument.js +0 -415
- /package/dist/{admin → testSurface}/allocation.model.d.ts +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}/metricSource.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/metricSource.model.js +0 -0
- /package/dist/{admin → testSurface}/placements/placementLabels.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/placements/placementLabels.model.js +0 -0
- /package/dist/{admin → testSurface}/placements/usePlacementLabels.d.ts +0 -0
- /package/dist/{admin → testSurface}/placements/usePlacementLabels.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/DataQualityPanel.js +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/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}/surface/test/jumpToSection.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/jumpToSection.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/pageParts.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
- /package/dist/{admin → testSurface}/useApi.js +0 -0
package/dist/goals/fairness.js
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
|
+
import { placementReader } from '../blocks/placementLocale.js';
|
|
2
|
+
import { puckExperimentSlug } from '../puck/experimentSlug.js';
|
|
3
|
+
import { puckVisibility } from '../puck/visibility.js';
|
|
1
4
|
import { clickGoalContent } from '../db/clickGoals.js';
|
|
2
5
|
import { safeError } from '../log.js';
|
|
3
|
-
import {
|
|
6
|
+
import { puckCollections } from '../options.js';
|
|
4
7
|
import { EXPERIMENT_BLOCK_SLUG, hostBlocks, isObject, slotBlocks } from '../blocks/model.js';
|
|
5
8
|
import { resolvePageCollection } from '../transitions/pageCollection.js';
|
|
6
9
|
import { scanPlacements, uniquePlacementDocs } from '../transitions/placementInteractions.js';
|
|
7
10
|
import { CLICK_KEY } from './key.js';
|
|
8
|
-
export const OUTSIDE_GOAL =
|
|
11
|
+
export const OUTSIDE_GOAL = (name = 'Selected goal', kind = 'block')=>kind === 'block' ? `Heads up: the click goal “${name}” is outside this test's block, so every version shows the same button. The test can still start. To compare different buttons, move the goal inside each version.` : `Heads up: the click goal “${name}” isn't on any of this test's pages. The test can still start. Add the goal to every version's page to measure those clicks.`;
|
|
9
12
|
export const LEGACY_FAIRNESS = "Goal fairness isn't checked for tests started before this update.";
|
|
10
|
-
/** Inspect inline JSON only; depth-zero relationship ids never dereference another document. */ function collect(value, into, label = '', labels) {
|
|
13
|
+
/** Inspect inline JSON only; depth-zero relationship ids never dereference another document. */ function collect(value, into, label = '', labels, visibility) {
|
|
11
14
|
if (Array.isArray(value)) {
|
|
12
|
-
value.forEach((item)=>collect(item, into, label, labels));
|
|
15
|
+
value.forEach((item)=>collect(item, into, label, labels, visibility));
|
|
13
16
|
return;
|
|
14
17
|
}
|
|
15
|
-
if (!isObject(value)) return;
|
|
18
|
+
if (!isObject(value) || visibility?.get(value)?.hidden) return;
|
|
16
19
|
const blockType = typeof value.blockType === 'string' ? value.blockType : typeof value.type === 'string' ? value.type : '';
|
|
17
20
|
const containing = labels.get(blockType) ?? (blockType || label);
|
|
18
21
|
if (typeof value.xpGoal === 'string' && CLICK_KEY.test(value.xpGoal)) into.set(value.xpGoal, containing || value.xpGoal);
|
|
19
|
-
Object.values(value).forEach((item)=>collect(item, into, containing, labels));
|
|
22
|
+
Object.values(value).forEach((item)=>collect(item, into, containing, labels, visibility));
|
|
20
23
|
}
|
|
21
24
|
function blockLabels(req) {
|
|
22
25
|
const labels = new Map();
|
|
@@ -91,7 +94,8 @@ function blockLabels(req) {
|
|
|
91
94
|
unchecked.push(placement);
|
|
92
95
|
continue;
|
|
93
96
|
}
|
|
94
|
-
|
|
97
|
+
const reader = placementReader(req, collection.slug, options);
|
|
98
|
+
for (const view of reader.documentViews)collect(collection.contentOf(reader.read(doc, 'all-locales', view).doc), byArm.get(arm.key), '', labels);
|
|
95
99
|
readArms.add(arm.key);
|
|
96
100
|
} catch (error) {
|
|
97
101
|
failed(error, placement);
|
|
@@ -119,36 +123,41 @@ function blockLabels(req) {
|
|
|
119
123
|
}
|
|
120
124
|
for (const placement of docs){
|
|
121
125
|
try {
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
const
|
|
125
|
-
|
|
126
|
-
const
|
|
127
|
-
if (!
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
const walk = (value)=>{
|
|
136
|
-
if (Array.isArray(value)) {
|
|
137
|
-
value.forEach(walk);
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
if (!isObject(value)) return;
|
|
141
|
-
const props = isObject(value.props) ? value.props : undefined;
|
|
142
|
-
const ref = props?.experiment;
|
|
143
|
-
if (value.type === 'ExperimentSlot' && props && (typeof ref === 'string' ? ref : isObject(ref) ? ref.slug : undefined) === experiment.slug) {
|
|
144
|
-
for (const arm of experiment.arms.filter((a)=>a.kind !== 'holdout'))collect(props[arm.slot ?? arm.key], byArm.get(arm.key), '', labels);
|
|
145
|
-
return;
|
|
126
|
+
const raw = await clickGoalContent(req, placement.collection, placement.id);
|
|
127
|
+
const reader = placementReader(req, placement.collection, options);
|
|
128
|
+
for (const view of reader.views){
|
|
129
|
+
const localized = reader.read(raw, 'all-locales', view);
|
|
130
|
+
const doc = localized.doc;
|
|
131
|
+
if (!doc) continue;
|
|
132
|
+
const editor = localized.editor;
|
|
133
|
+
if (editor === 'blocks') {
|
|
134
|
+
const registration = options.blocks?.collections.find((c)=>c.slug === placement.collection);
|
|
135
|
+
if (!registration) continue;
|
|
136
|
+
for (const block of hostBlocks(doc[registration.field])){
|
|
137
|
+
if (block.blockType !== (registration.blockSlug ?? EXPERIMENT_BLOCK_SLUG) || block.experiment !== experiment.slug) continue;
|
|
138
|
+
for (const arm of experiment.arms.filter((a)=>a.kind !== 'holdout'))collect(slotBlocks(block, arm.key), byArm.get(arm.key), '', labels);
|
|
146
139
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
140
|
+
} else {
|
|
141
|
+
const registration = puckCollections(options).find((c)=>c.slug === placement.collection);
|
|
142
|
+
if (!registration) continue;
|
|
143
|
+
const visibility = puckVisibility(doc[registration.field]);
|
|
144
|
+
const walk = (value)=>{
|
|
145
|
+
if (Array.isArray(value)) {
|
|
146
|
+
value.forEach(walk);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
if (!isObject(value) || visibility.get(value)?.hidden) return;
|
|
150
|
+
const props = isObject(value.props) ? value.props : undefined;
|
|
151
|
+
if (value.type === 'ExperimentSlot' && props && puckExperimentSlug(props.experiment) === experiment.slug) {
|
|
152
|
+
for (const arm of experiment.arms.filter((a)=>a.kind !== 'holdout'))collect(props[arm.key], byArm.get(arm.key), '', labels, visibility);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
Object.values(value).forEach(walk);
|
|
156
|
+
};
|
|
157
|
+
walk(doc[registration.field]);
|
|
158
|
+
}
|
|
159
|
+
for (const arm of byArm.keys())readArms.add(arm);
|
|
150
160
|
}
|
|
151
|
-
for (const arm of byArm.keys())readArms.add(arm);
|
|
152
161
|
} catch (error) {
|
|
153
162
|
failed(error, placement);
|
|
154
163
|
}
|
|
@@ -8,7 +8,14 @@ export type PickerStatus = 'loading' | 'ready' | 'not-manager' | 'error';
|
|
|
8
8
|
export declare function goalSlug(name: string): string;
|
|
9
9
|
export declare function clickGoalSlug(name: string): string;
|
|
10
10
|
export declare function definedClickGoals(rows: readonly ClickGoal[]): ClickGoal[];
|
|
11
|
-
|
|
11
|
+
/** Keep legacy values visible without changing stored data during a read. */
|
|
12
|
+
export declare function clickGoalOptions(status: PickerStatus, goals: readonly ClickGoal[], value: string): {
|
|
13
|
+
options: {
|
|
14
|
+
value: string;
|
|
15
|
+
label: string;
|
|
16
|
+
}[];
|
|
17
|
+
missing: boolean;
|
|
18
|
+
};
|
|
12
19
|
export declare function clickGoalBody(name: string, slug: string): {
|
|
13
20
|
name: string;
|
|
14
21
|
slug: string;
|
|
@@ -9,8 +9,26 @@ export function clickGoalSlug(name) {
|
|
|
9
9
|
export function definedClickGoals(rows) {
|
|
10
10
|
return rows.filter((row)=>isClickSource(row.source));
|
|
11
11
|
}
|
|
12
|
-
export function
|
|
13
|
-
|
|
12
|
+
/** Keep legacy values visible without changing stored data during a read. */ export function clickGoalOptions(status, goals, value) {
|
|
13
|
+
const missing = status === 'ready' && Boolean(value) && !goals.some((goal)=>goal.slug === value);
|
|
14
|
+
const options = [
|
|
15
|
+
{
|
|
16
|
+
value: '',
|
|
17
|
+
label: C.none
|
|
18
|
+
},
|
|
19
|
+
...goals.map((goal)=>({
|
|
20
|
+
value: goal.slug,
|
|
21
|
+
label: goal.name
|
|
22
|
+
}))
|
|
23
|
+
];
|
|
24
|
+
if (value && !goals.some((goal)=>goal.slug === value)) options.push({
|
|
25
|
+
value,
|
|
26
|
+
label: missing ? `${value} (missing)` : value
|
|
27
|
+
});
|
|
28
|
+
return {
|
|
29
|
+
options,
|
|
30
|
+
missing
|
|
31
|
+
};
|
|
14
32
|
}
|
|
15
33
|
export function clickGoalBody(name, slug) {
|
|
16
34
|
return {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/** Shared by Payload's field and the Puck sidebar, without either UI dependency. */
|
|
2
2
|
export declare const CLICK_GOAL_COPY: {
|
|
3
3
|
readonly label: "Click goal";
|
|
4
|
-
readonly
|
|
4
|
+
readonly none: "No click goal";
|
|
5
|
+
readonly loadError: "Couldn't load goals. Try again.";
|
|
6
|
+
readonly retry: "Try again";
|
|
5
7
|
readonly newGoal: "+ New click goal";
|
|
6
8
|
readonly title: "New click goal";
|
|
7
9
|
readonly name: "Name";
|
|
@@ -9,8 +11,10 @@ export declare const CLICK_GOAL_COPY: {
|
|
|
9
11
|
readonly advanced: "Advanced";
|
|
10
12
|
readonly createGoal: "Create goal";
|
|
11
13
|
readonly cancel: "Cancel";
|
|
12
|
-
readonly undefinedKey: "
|
|
14
|
+
readonly undefinedKey: "This click goal is missing. Choose another goal or “No click goal”.";
|
|
15
|
+
readonly invalidKey: "Use a click goal short name.";
|
|
13
16
|
readonly slugRule: "Use 1–64 lowercase letters, numbers, underscores or hyphens, starting with a letter or number.";
|
|
14
17
|
readonly duplicateSlug: "Another goal already uses this short name. Change it under Advanced.";
|
|
15
18
|
readonly saveError: "Couldn't save the goal. Try again.";
|
|
16
19
|
};
|
|
20
|
+
export declare function puckGoalRefusal(rawKey: string, block: string, malformed: boolean, more?: number): string;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/** Shared by Payload's field and the Puck sidebar, without either UI dependency. */ export const CLICK_GOAL_COPY = {
|
|
2
2
|
label: 'Click goal',
|
|
3
|
-
|
|
3
|
+
none: 'No click goal',
|
|
4
|
+
loadError: "Couldn't load goals. Try again.",
|
|
5
|
+
retry: 'Try again',
|
|
4
6
|
newGoal: '+ New click goal',
|
|
5
7
|
title: 'New click goal',
|
|
6
8
|
name: 'Name',
|
|
@@ -8,8 +10,15 @@
|
|
|
8
10
|
advanced: 'Advanced',
|
|
9
11
|
createGoal: 'Create goal',
|
|
10
12
|
cancel: 'Cancel',
|
|
11
|
-
undefinedKey: '
|
|
13
|
+
undefinedKey: 'This click goal is missing. Choose another goal or “No click goal”.',
|
|
14
|
+
invalidKey: 'Use a click goal short name.',
|
|
12
15
|
slugRule: 'Use 1–64 lowercase letters, numbers, underscores or hyphens, starting with a letter or number.',
|
|
13
16
|
duplicateSlug: 'Another goal already uses this short name. Change it under Advanced.',
|
|
14
17
|
saveError: "Couldn't save the goal. Try again."
|
|
15
18
|
};
|
|
19
|
+
export function puckGoalRefusal(rawKey, block, malformed, more = 0) {
|
|
20
|
+
// A malformed key can be any length; keep the dialog readable.
|
|
21
|
+
const key = rawKey.length > 64 ? `${rawKey.slice(0, 64)}…` : rawKey;
|
|
22
|
+
const sentence = malformed ? `Click goal "${key}" on the ${block} block isn't a valid short name. Use lowercase letters, numbers, - and _.` : `Click goal "${key}" doesn't exist yet. Create it with "+ New click goal" on the ${block} block.`;
|
|
23
|
+
return sentence + (more > 0 ? ` (and ${more} more)` : '');
|
|
24
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { useEffect, useRef, useState } from 'react';
|
|
3
3
|
import { fetchAllDocs } from '../../lib/fetchAllDocs.js';
|
|
4
4
|
import { CLICK_KEY } from '../key.js';
|
|
5
|
-
import { clickGoalBody, clickGoalCreateError, clickGoalSlug, definedClickGoals
|
|
5
|
+
import { clickGoalBody, clickGoalCreateError, clickGoalSlug, definedClickGoals } from './clickGoalPicker.model.js';
|
|
6
6
|
const goalLists = new Map();
|
|
7
7
|
function publish(list, state) {
|
|
8
8
|
// A read may finish after its last row unmounts and a new list has started.
|
|
@@ -180,7 +180,9 @@ const emptyPanel = ()=>({
|
|
|
180
180
|
status,
|
|
181
181
|
goals,
|
|
182
182
|
canManage,
|
|
183
|
-
|
|
183
|
+
retry: ()=>{
|
|
184
|
+
loadGoals(api);
|
|
185
|
+
},
|
|
184
186
|
panel,
|
|
185
187
|
open: ()=>{
|
|
186
188
|
if (canManage) setPanel({
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { definedClickKeys } from '../db/clickGoals.js';
|
|
2
|
+
import { pooledExecutor } from '../db/executor.js';
|
|
3
|
+
import { clickKeys } from './cache.js';
|
|
4
|
+
import { CLICK_KEY } from './key.js';
|
|
5
|
+
import { CLICK_GOAL_COPY } from './picker/copy.js';
|
|
6
|
+
/** Shared publish validation for Payload fields and Puck JSON props. */ export async function validateClickGoal(value, req) {
|
|
7
|
+
if (!value) return true;
|
|
8
|
+
if (!CLICK_KEY.test(value)) return CLICK_GOAL_COPY.invalidKey;
|
|
9
|
+
const options = req.payload.config.custom?.xp;
|
|
10
|
+
if (!options || await options.access.manage({
|
|
11
|
+
req
|
|
12
|
+
}) !== true) return true;
|
|
13
|
+
const keys = await clickKeys(req.payload);
|
|
14
|
+
return !keys || keys.has(value) || (await definedClickKeys(pooledExecutor(req.payload))).has(value) || CLICK_GOAL_COPY.undefinedKey;
|
|
15
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { PayloadRequest } from 'payload';
|
|
2
|
+
import type { Executor } from '../db/executor.js';
|
|
3
|
+
import { type PlacementTest } from '../db/placements.js';
|
|
4
|
+
import { type BulkPlacementRemoval } from '../db/bulkPlacementRemoval.js';
|
|
5
|
+
import { type RemovedPlacementViews, type PlacementInput } from '../blocks/placementLocale.js';
|
|
6
|
+
import type { DocId } from '../types/contracts.js';
|
|
7
|
+
export type RemovalClaims = {
|
|
8
|
+
transaction: unknown;
|
|
9
|
+
tests: Map<string, Set<string>>;
|
|
10
|
+
counts?: Map<string, Map<string, number>>;
|
|
11
|
+
absent?: Set<string>;
|
|
12
|
+
};
|
|
13
|
+
export declare function releaseRemovalClaim(req: PayloadRequest, collection: string, id: DocId, ownKeys?: Map<string, Set<string>>): void;
|
|
14
|
+
/** A removal must have reached afterChange before a later write can restore it.
|
|
15
|
+
* A write merely retaining another locale cannot clear an in-flight removal.
|
|
16
|
+
*/
|
|
17
|
+
export declare function observeUnpublishedRemoval(req: PayloadRequest, collection: string, id: DocId): void;
|
|
18
|
+
export declare function releaseRestoredRemovalClaims(req: PayloadRequest, collection: string, doc: Record<string, unknown> & {
|
|
19
|
+
id: DocId;
|
|
20
|
+
}, test: PlacementTest): void;
|
|
21
|
+
export declare const blockRemovalRule: {
|
|
22
|
+
prepare(req: PayloadRequest, collection: string, before: Record<string, unknown> | undefined, after: Record<string, unknown>, removingPage: boolean, exec?: Executor, tests?: readonly PlacementTest[], input?: PlacementInput): Promise<{
|
|
23
|
+
views: RemovedPlacementViews;
|
|
24
|
+
affected: PlacementTest[];
|
|
25
|
+
hidden: Set<string>;
|
|
26
|
+
}>;
|
|
27
|
+
discover(exec: Executor, removed: string[], tests?: readonly PlacementTest[]): Promise<PlacementTest[]>;
|
|
28
|
+
claim(req: PayloadRequest, transaction: unknown, affected: readonly PlacementTest[], collection: string, id: DocId, views: RemovedPlacementViews): RemovalClaims;
|
|
29
|
+
check(req: PayloadRequest, current: readonly PlacementTest[], affected: readonly PlacementTest[], collection: string, id: DocId, removingPage: boolean, views: RemovedPlacementViews, bulk?: BulkPlacementRemoval, hidden?: ReadonlySet<string>): Promise<void>;
|
|
30
|
+
};
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { puckExperimentSlug } from '../puck/experimentSlug.js';
|
|
2
|
+
import { walkVisiblePuck } from '../puck/visibility.js';
|
|
3
|
+
import { puckCollections } from '../options.js';
|
|
4
|
+
import { removableBlockTests } from '../db/placements.js';
|
|
5
|
+
import { XpNoTransactionError, XpRefusal } from '../errors.js';
|
|
6
|
+
import { lastBlockPlacementCopy, hiddenBlockPlacementCopy, pendingBlockRemovalCopy, bulkBlockRemovalCopy } from '../testSurface/copy/readiness.js';
|
|
7
|
+
import { hasOtherPublishedBlockPlacement } from '../transitions/placements.js';
|
|
8
|
+
import { bulkRemoves } from '../db/bulkPlacementRemoval.js';
|
|
9
|
+
import { placementReader, removedPlacementViews, placementDocumentKey, mergedPlacementLocales } from '../blocks/placementLocale.js';
|
|
10
|
+
export function releaseRemovalClaim(req, collection, id, ownKeys) {
|
|
11
|
+
const claims = req.context.xpPlacementRemovals;
|
|
12
|
+
for (const [test, documents] of claims?.tests ?? [])for (const key of documents){
|
|
13
|
+
const [slug, docId] = JSON.parse(key);
|
|
14
|
+
if (slug !== collection || docId !== String(id) || ownKeys && !ownKeys.get(test)?.has(key)) continue;
|
|
15
|
+
const count = claims?.counts?.get(test)?.get(key) ?? 1;
|
|
16
|
+
if (ownKeys && count > 1) claims.counts.get(test).set(key, count - 1);
|
|
17
|
+
else {
|
|
18
|
+
documents.delete(`${key}`);
|
|
19
|
+
claims?.counts?.get(test)?.delete(`${key}`);
|
|
20
|
+
claims?.absent?.delete(`${test}:${key}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/** A removal must have reached afterChange before a later write can restore it.
|
|
25
|
+
* A write merely retaining another locale cannot clear an in-flight removal.
|
|
26
|
+
*/ export function observeUnpublishedRemoval(req, collection, id) {
|
|
27
|
+
const claims = req.context.xpPlacementRemovals;
|
|
28
|
+
if (!claims) return;
|
|
29
|
+
claims.absent ??= new Set();
|
|
30
|
+
for (const [test, documents] of claims.tests)for (const key of documents){
|
|
31
|
+
const [slug, docId] = JSON.parse(key);
|
|
32
|
+
if (slug === collection && docId === String(id)) claims.absent.add(`${test}:${key}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export function releaseRestoredRemovalClaims(req, collection, doc, test) {
|
|
36
|
+
const claims = req.context.xpPlacementRemovals;
|
|
37
|
+
if (!claims) return;
|
|
38
|
+
claims.absent ??= new Set();
|
|
39
|
+
for (const key of claims.tests.get(String(test.id)) ?? []){
|
|
40
|
+
const [slug, id, view] = JSON.parse(key);
|
|
41
|
+
if (slug !== collection || id !== String(doc.id)) continue;
|
|
42
|
+
const marker = `${test.id}:${key}`;
|
|
43
|
+
if (!placementReader(req, collection).read(doc, 'all-locales', view).slugs.includes(test.slug)) claims.absent.add(marker);
|
|
44
|
+
else if (claims.absent.has(marker) && (claims.counts?.get(String(test.id))?.get(key) ?? 1) === 1) {
|
|
45
|
+
claims.tests.get(String(test.id)).delete(`${key}`);
|
|
46
|
+
claims.counts?.get(String(test.id))?.delete(`${key}`);
|
|
47
|
+
claims.absent.delete(`${marker}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// Separate removal-rule entry points let tests observe its IO independently
|
|
52
|
+
// of the earlier page-path and publish guards.
|
|
53
|
+
export const blockRemovalRule = {
|
|
54
|
+
async prepare (req, collection, before, after, removingPage, exec, tests, input = 'localized') {
|
|
55
|
+
const views = removedPlacementViews(req, collection, before, after, removingPage, input);
|
|
56
|
+
const affected = views.size ? await blockRemovalRule.discover(exec, [
|
|
57
|
+
...views.keys()
|
|
58
|
+
], tests) : [];
|
|
59
|
+
const hidden = new Set();
|
|
60
|
+
const options = req.payload.config.custom.xp;
|
|
61
|
+
const registration = puckCollections(options).find((entry)=>entry.slug === collection);
|
|
62
|
+
const rawAfter = input === 'all-locales' ? after : mergedPlacementLocales(req, collection, before, after);
|
|
63
|
+
const reader = placementReader(req, collection);
|
|
64
|
+
if (views.size && !removingPage && registration) {
|
|
65
|
+
for (const view of reader.views){
|
|
66
|
+
const previous = reader.read(before, 'all-locales', view);
|
|
67
|
+
const next = reader.read(rawAfter, 'all-locales', view);
|
|
68
|
+
if (next.editor !== 'puck') continue;
|
|
69
|
+
const visibleBefore = new Set();
|
|
70
|
+
walkVisiblePuck(previous.doc?.[registration.field], (block, visibility)=>{
|
|
71
|
+
if (!visibility.hidden && block.type === 'ExperimentSlot') visibleBefore.add(String(block.props.id));
|
|
72
|
+
});
|
|
73
|
+
walkVisiblePuck(next.doc?.[registration.field], (block, visibility)=>{
|
|
74
|
+
if (!visibility.hidden || block.type !== 'ExperimentSlot' || !visibleBefore.has(String(block.props.id))) return;
|
|
75
|
+
const slug = puckExperimentSlug(block.props.experiment);
|
|
76
|
+
if (typeof slug === 'string') hidden.add(slug);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return {
|
|
81
|
+
views,
|
|
82
|
+
affected,
|
|
83
|
+
hidden
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
async discover (exec, removed, tests) {
|
|
87
|
+
if (tests) return tests.filter((test)=>test.kind === 'block' && [
|
|
88
|
+
'draft',
|
|
89
|
+
'stopped',
|
|
90
|
+
'running'
|
|
91
|
+
].includes(test.status) && removed.includes(test.slug));
|
|
92
|
+
return (await removableBlockTests(exec, removed)).map((test)=>({
|
|
93
|
+
...test,
|
|
94
|
+
kind: 'block',
|
|
95
|
+
pageCollection: null,
|
|
96
|
+
phase: 0,
|
|
97
|
+
arms: [],
|
|
98
|
+
placementDocs: null
|
|
99
|
+
}));
|
|
100
|
+
},
|
|
101
|
+
claim (req, transaction, affected, collection, id, views) {
|
|
102
|
+
let claims = req.context.xpPlacementRemovals;
|
|
103
|
+
if (!claims) req.context.xpPlacementRemovals = claims = {
|
|
104
|
+
transaction,
|
|
105
|
+
tests: new Map()
|
|
106
|
+
};
|
|
107
|
+
claims.counts ??= new Map();
|
|
108
|
+
claims.absent ??= new Set();
|
|
109
|
+
if (claims.transaction !== transaction) {
|
|
110
|
+
claims.transaction = transaction;
|
|
111
|
+
claims.tests.clear();
|
|
112
|
+
claims.counts.clear();
|
|
113
|
+
claims.absent.clear();
|
|
114
|
+
}
|
|
115
|
+
for (const test of affected){
|
|
116
|
+
const documents = claims.tests.get(String(test.id)) ?? new Set();
|
|
117
|
+
const counts = claims.counts.get(String(test.id)) ?? new Map();
|
|
118
|
+
for (const view of views.get(test.slug) ?? []){
|
|
119
|
+
const key = placementDocumentKey(collection, id, view);
|
|
120
|
+
documents.add(key);
|
|
121
|
+
counts.set(key, (counts.get(key) ?? 0) + 1);
|
|
122
|
+
}
|
|
123
|
+
claims.tests.set(String(test.id), documents);
|
|
124
|
+
claims.counts.set(String(test.id), counts);
|
|
125
|
+
}
|
|
126
|
+
return claims;
|
|
127
|
+
},
|
|
128
|
+
async check (req, current, affected, collection, id, removingPage, views, bulk, hidden) {
|
|
129
|
+
const transaction = await req.transactionID;
|
|
130
|
+
// Claim only after every earlier guard passed. These claims cover subsequent
|
|
131
|
+
// writes; the complete bulk selection covers siblings before any can decide.
|
|
132
|
+
const claims = transaction == null ? undefined : blockRemovalRule.claim(req, transaction, affected, collection, id, views);
|
|
133
|
+
const ownKeys = new Map(affected.map((test)=>[
|
|
134
|
+
String(test.id),
|
|
135
|
+
new Set((views.get(test.slug) ?? []).map((view)=>placementDocumentKey(collection, id, view)))
|
|
136
|
+
]));
|
|
137
|
+
try {
|
|
138
|
+
for (const test of affected){
|
|
139
|
+
if (!current.some((row)=>String(row.id) === String(test.id) && row.kind === 'block' && row.status === 'running')) continue;
|
|
140
|
+
const documents = claims?.tests.get(String(test.id));
|
|
141
|
+
let excludedSibling = false;
|
|
142
|
+
if (await hasOtherPublishedBlockPlacement(req, req.payload.config.custom.xp, test.slug, (slug, docId, view, doc)=>{
|
|
143
|
+
const key = placementDocumentKey(slug, docId, view);
|
|
144
|
+
if (ownKeys.get(String(test.id))?.has(key)) return true;
|
|
145
|
+
if (bulkRemoves(bulk, req, slug, doc, test.slug, view) || documents?.has(key)) {
|
|
146
|
+
excludedSibling = true;
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
return false;
|
|
150
|
+
})) continue;
|
|
151
|
+
if (transaction == null) throw new XpNoTransactionError('Save this page with transactions on.');
|
|
152
|
+
// Bulk selection is immutable through every sibling's decision, including
|
|
153
|
+
// earlier rule refusals. afterOperation explains unrelated failed writes.
|
|
154
|
+
const message = excludedSibling ? bulk ? bulkBlockRemovalCopy(test.name) : pendingBlockRemovalCopy(test.name) : hidden?.has(test.slug) ? hiddenBlockPlacementCopy(test.name) : lastBlockPlacementCopy(test.name, removingPage);
|
|
155
|
+
if (bulk && excludedSibling) bulk.refusals.set(message, pendingBlockRemovalCopy(test.name));
|
|
156
|
+
throw new XpRefusal('locked-placement', message, {
|
|
157
|
+
experimentId: test.id
|
|
158
|
+
}, 409);
|
|
159
|
+
}
|
|
160
|
+
} catch (error) {
|
|
161
|
+
releaseRemovalClaim(req, collection, id, ownKeys);
|
|
162
|
+
throw error;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
};
|
package/dist/hooks/hostHook.js
CHANGED
|
@@ -4,7 +4,9 @@ import { safeError } from '../log.js';
|
|
|
4
4
|
try {
|
|
5
5
|
return await hook(args);
|
|
6
6
|
} catch (error) {
|
|
7
|
-
|
|
7
|
+
try {
|
|
8
|
+
console.error(`[payload-experiments] ${name} failed; the document was saved without it`, safeError(error));
|
|
9
|
+
} catch {}
|
|
8
10
|
return args.doc;
|
|
9
11
|
}
|
|
10
12
|
};
|
|
@@ -14,7 +16,9 @@ import { safeError } from '../log.js';
|
|
|
14
16
|
try {
|
|
15
17
|
return await hook(args);
|
|
16
18
|
} catch (error) {
|
|
17
|
-
|
|
19
|
+
try {
|
|
20
|
+
console.error(`[payload-experiments] ${name} failed; the document was saved without it`, safeError(error));
|
|
21
|
+
} catch {}
|
|
18
22
|
return args.data;
|
|
19
23
|
}
|
|
20
24
|
};
|
|
@@ -1,9 +1,34 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
import type { CollectionAfterChangeHook, CollectionAfterOperationHook, CollectionBeforeChangeHook, CollectionBeforeDeleteHook, CollectionBeforeOperationHook, PayloadRequest } from 'payload';
|
|
3
|
+
import type { DocId } from '../types/contracts.js';
|
|
2
4
|
import { type PlacementTest } from '../db/placements.js';
|
|
5
|
+
import { type BulkPlacementRemoval } from '../db/bulkPlacementRemoval.js';
|
|
6
|
+
type OperationFrame = {
|
|
7
|
+
collection: string;
|
|
8
|
+
request?: PayloadRequest;
|
|
9
|
+
draft: boolean;
|
|
10
|
+
restore: boolean;
|
|
11
|
+
versionId?: DocId;
|
|
12
|
+
isBulk?: boolean;
|
|
13
|
+
publishSpecificLocale?: string;
|
|
14
|
+
pending?: boolean;
|
|
15
|
+
scoped?: boolean;
|
|
16
|
+
complete?: boolean;
|
|
17
|
+
detached?: boolean;
|
|
18
|
+
parent?: OperationFrame;
|
|
19
|
+
bulk?: BulkPlacementRemoval;
|
|
20
|
+
};
|
|
21
|
+
export declare const pageGuardOperationScope: AsyncLocalStorage<OperationFrame | undefined>;
|
|
22
|
+
/** Must be first: buildBeforeOperation invokes its first hook synchronously,
|
|
23
|
+
* before the operation registers its await continuation. Later host hooks may
|
|
24
|
+
* await nested operations; those keep separate async contexts. No IO here.
|
|
25
|
+
*/
|
|
26
|
+
export declare const pageGuardEnterOperation: CollectionBeforeOperationHook;
|
|
3
27
|
export declare const pageGuardBeforeOperation: CollectionBeforeOperationHook;
|
|
4
28
|
export declare const pageGuardAfterOperation: CollectionAfterOperationHook;
|
|
5
|
-
export declare function guardExperimentIds(tests: readonly PlacementTest[], slugs: readonly string[], collection: string, paths: readonly string[], held: unknown, tags?: Set<string
|
|
29
|
+
export declare function guardExperimentIds(tests: readonly PlacementTest[], slugs: readonly string[], collection: string, paths: readonly string[], held: unknown, tags?: Set<string>, discovered?: readonly DocId[]): string[];
|
|
6
30
|
export declare const pageGuardBeforeDelete: CollectionBeforeDeleteHook;
|
|
7
31
|
export declare const pageGuardBeforeChange: CollectionBeforeChangeHook;
|
|
8
32
|
/** Unwrapped: these writes must fail the publish closed, unlike the best-effort audit. */
|
|
9
33
|
export declare const pageGuardAfterChange: CollectionAfterChangeHook;
|
|
34
|
+
export {};
|