@delmaredigital/payload-experiments 0.4.0-rc.3 → 0.4.0-rc.5
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/dist/admin/LayerUsage.js +1 -1
- package/dist/admin/MetricSourceSelect.js +2 -2
- package/dist/admin/PlacementStatus.js +1 -1
- package/dist/admin/TestsDashboardCards.js +2 -2
- package/dist/admin/TestsNavLink.js +2 -2
- package/dist/admin/blocks/BlockPanel.js +3 -3
- package/dist/admin/blocks/TestBlockField.js +3 -3
- package/dist/admin/blocks/formApi.js +1 -1
- package/dist/admin/blocks/model.js +1 -1
- package/dist/admin/blocks/statusCache.js +1 -1
- package/dist/admin/components/RootViewMessage.js +1 -1
- package/dist/admin/copy/blocks.d.ts +2 -2
- package/dist/admin/copy/blocks.js +3 -2
- package/dist/admin/copy/goals.d.ts +5 -1
- package/dist/admin/copy/goals.js +9 -3
- package/dist/admin/goals/XpGoalField.js +155 -129
- package/dist/admin/goals/xpGoalField.css +2 -3
- package/dist/admin/status.model.js +1 -1
- package/dist/admin/surface/ResultsRoute.d.ts +2 -1
- package/dist/admin/surface/ResultsRoute.js +6 -13
- package/dist/admin/surface/SurfaceShell.js +2 -2
- package/dist/admin/surface/TestsHome.d.ts +1 -1
- package/dist/admin/surface/TestsHome.js +3 -3
- package/dist/admin/surface/TestsSurface.js +2 -2
- package/dist/admin/surface/goals/GoalForm.d.ts +1 -1
- package/dist/admin/surface/goals/GoalForm.js +55 -7
- package/dist/admin/surface/goals/GoalsList.d.ts +1 -1
- package/dist/admin/surface/goals/GoalsList.js +4 -4
- package/dist/admin/surface/goals/data.js +2 -2
- package/dist/admin/surface/goals/goals.css +7 -0
- package/dist/admin/surface/goals/goals.model.d.ts +11 -1
- package/dist/admin/surface/goals/goals.model.js +43 -0
- package/dist/admin/surface/home.model.d.ts +1 -1
- package/dist/admin/surface/home.model.js +5 -5
- package/dist/admin/surface/newTest/NewTest.d.ts +1 -1
- package/dist/admin/surface/newTest/NewTest.js +1 -1
- package/dist/admin/surface/newTest/PageWizard.d.ts +1 -1
- package/dist/admin/surface/newTest/PageWizard.js +23 -25
- package/dist/admin/surface/results/ResultsHeader.d.ts +2 -2
- package/dist/admin/surface/results/ResultsHeader.js +22 -15
- package/dist/admin/surface/test/TestPage.d.ts +1 -2
- package/dist/admin/surface/test/TestPage.js +45 -156
- package/dist/admin/views/ExperimentsRootView.js +1 -1
- package/dist/admin/views/TestsNavLinkServer.js +1 -1
- package/dist/admin/views/renderCollectionList.js +1 -1
- package/dist/admin/views/renderTestsSurface.js +1 -1
- package/dist/blocks/placementLocale.d.ts +21 -0
- package/dist/blocks/placementLocale.js +115 -0
- package/dist/collections/experiments/config.js +1 -1
- package/dist/collections/metrics.js +1 -1
- package/dist/db/bulkPlacementRemoval.d.ts +30 -0
- package/dist/db/bulkPlacementRemoval.js +107 -0
- package/dist/db/placements.d.ts +2 -0
- package/dist/db/placements.js +8 -0
- package/dist/endpoints/editorSurface.d.ts +3 -0
- package/dist/endpoints/editorSurface.js +31 -0
- package/dist/endpoints/index.js +28 -1
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +2 -0
- package/dist/fields/xpGoal.js +1 -1
- package/dist/goals/fairness.d.ts +1 -1
- package/dist/goals/fairness.js +1 -1
- 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 +4 -2
- package/dist/goals/picker/copy.js +4 -2
- package/dist/goals/picker/useClickGoalPicker.d.ts +1 -1
- package/dist/goals/picker/useClickGoalPicker.js +4 -2
- package/dist/hooks/blockRemovalRule.d.ts +29 -0
- package/dist/hooks/blockRemovalRule.js +141 -0
- package/dist/hooks/pageGuard.d.ts +24 -2
- package/dist/hooks/pageGuard.js +178 -24
- package/dist/lib/placementPages.d.ts +9 -0
- package/dist/{admin/previewLinks.model.js → lib/placementPages.js} +1 -4
- package/dist/onInit.js +22 -0
- package/dist/plugin.js +2 -1
- package/dist/puck/ExperimentPicker.js +25 -10
- package/dist/puck/copy.d.ts +4 -1
- package/dist/puck/copy.js +4 -1
- package/dist/puck/editor/ConfigureTestDrawer.d.ts +21 -0
- package/dist/puck/editor/ConfigureTestDrawer.js +147 -0
- package/dist/puck/editor/CreateExperimentDrawer.d.ts +11 -2
- package/dist/puck/editor/CreateExperimentDrawer.js +73 -9
- package/dist/puck/editor/EditorControls.d.ts +14 -0
- package/dist/puck/editor/EditorControls.js +99 -0
- package/dist/puck/editor/ExperimentSlotEditor.js +690 -79
- package/dist/puck/editor/LeftoverVersions.d.ts +13 -0
- package/dist/puck/editor/LeftoverVersions.js +115 -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 +3 -0
- package/dist/puck/editor/QuickTestActions.js +50 -0
- package/dist/puck/editor/ResultsReadout.js +8 -5
- package/dist/puck/editor/VersionBuilder.d.ts +20 -6
- package/dist/puck/editor/VersionBuilder.js +80 -50
- package/dist/puck/editor/armWrites.d.ts +3 -1
- package/dist/puck/editor/armWrites.js +2 -1
- package/dist/puck/editor/armsCache.d.ts +3 -1
- package/dist/puck/editor/armsCache.js +20 -3
- package/dist/puck/editor/cloneSlot.d.ts +2 -0
- package/dist/puck/editor/cloneSlot.js +7 -0
- package/dist/puck/editor/copy.d.ts +42 -5
- package/dist/puck/editor/copy.js +43 -6
- package/dist/puck/editor/editor.chrome.css +44 -0
- package/dist/puck/editor/editor.css +68 -0
- package/dist/puck/editor/editor.model.d.ts +14 -0
- package/dist/puck/editor/editor.model.js +58 -1
- 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 +2 -0
- package/dist/puck/editor/localPlacements.js +29 -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 +50 -0
- package/dist/puck/editor/placementsCache.js +258 -0
- package/dist/puck/editor/sidebar.d.ts +12 -0
- package/dist/puck/editor/sidebar.js +77 -0
- package/dist/puck/editor/usePlacementNotice.d.ts +3 -0
- package/dist/puck/editor/usePlacementNotice.js +14 -0
- package/dist/puck/editor/xpGoalPuckEditorField.js +109 -98
- package/dist/puck/experimentSlotField.d.ts +3 -0
- package/dist/puck/experimentSlotField.js +15 -4
- package/dist/{admin → testSurface}/actions/DecideDialog.d.ts +2 -1
- package/dist/{admin → testSurface}/actions/DecideDialog.js +6 -4
- package/dist/{admin → testSurface}/api.js +5 -6
- package/dist/{admin → testSurface}/copy/common.d.ts +3 -1
- package/dist/{admin → testSurface}/copy/common.js +5 -1
- package/dist/{admin → testSurface}/copy/readiness.d.ts +20 -1
- package/dist/{admin → testSurface}/copy/readiness.js +25 -1
- package/dist/{admin → testSurface}/copy/testPage.d.ts +4 -0
- package/dist/{admin → testSurface}/copy/testPage.js +8 -2
- package/dist/testSurface/format/adminURL.d.ts +7 -0
- package/dist/testSurface/format/adminURL.js +9 -0
- package/dist/{admin → testSurface}/placements/placementLabels.js +1 -1
- package/dist/{admin → testSurface}/previewLinks.model.d.ts +1 -6
- package/dist/testSurface/previewLinks.model.js +4 -0
- package/dist/testSurface/readPreflight.d.ts +9 -0
- package/dist/testSurface/readPreflight.js +38 -0
- package/dist/testSurface/readinessRead.d.ts +50 -0
- package/dist/testSurface/readinessRead.js +46 -0
- package/dist/testSurface/results/results.css +64 -0
- package/dist/{admin → testSurface}/surface/contracts.d.ts +7 -2
- package/dist/testSurface/surface/editorPlacement.d.ts +21 -0
- package/dist/testSurface/surface/editorPlacement.js +60 -0
- package/dist/{admin → testSurface}/surface/pageBlock/parts.js +19 -9
- package/dist/testSurface/surface/pagePicker/pagePicker.css +10 -0
- package/dist/{admin → testSurface}/surface/readiness/ActionDialogs.js +37 -7
- package/dist/testSurface/surface/readiness/Banner.d.ts +2 -0
- package/dist/{admin → testSurface}/surface/readiness/Banner.js +106 -68
- 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 +9 -0
- package/dist/testSurface/surface/readiness/SaveStatus.js +66 -0
- package/dist/{admin → testSurface}/surface/readiness/parts.js +0 -2
- package/dist/{admin → testSurface}/surface/readiness/readiness.model.d.ts +13 -0
- package/dist/{admin → testSurface}/surface/readiness/readiness.model.js +51 -36
- package/dist/{admin → testSurface}/surface/readiness/useTransition.d.ts +5 -2
- package/dist/testSurface/surface/readiness/useTransition.js +98 -0
- package/dist/{admin → testSurface}/surface/results/ResultsBody.d.ts +2 -2
- package/dist/{admin → testSurface}/surface/results/ResultsBody.js +18 -11
- package/dist/testSurface/surface/setting/setting.css +17 -0
- package/dist/{admin → testSurface}/surface/test/AdvancedSection.js +1 -0
- package/dist/testSurface/surface/test/GoalSection.d.ts +4 -0
- package/dist/{admin → testSurface}/surface/test/GoalSection.js +4 -2
- package/dist/testSurface/surface/test/LengthSection.d.ts +2 -0
- package/dist/{admin → testSurface}/surface/test/LengthSection.js +2 -1
- package/dist/{admin → testSurface}/surface/test/Rail.js +7 -4
- package/dist/{admin → testSurface}/surface/test/ReadinessBar.js +1 -2
- 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 +5 -0
- package/dist/testSurface/surface/test/TestSurface.d.ts +19 -0
- package/dist/testSurface/surface/test/TestSurface.js +213 -0
- package/dist/testSurface/surface/test/VersionsSection.d.ts +5 -0
- package/dist/{admin → testSurface}/surface/test/VersionsSection.js +13 -6
- package/dist/testSurface/surface/test/testPage.css +104 -0
- package/dist/{admin → testSurface}/surface/useTestDocument.d.ts +9 -2
- package/dist/{admin → testSurface}/surface/useTestDocument.js +92 -46
- package/dist/{admin → testSurface}/surfaceUrls.js +1 -1
- package/dist/testSurface/useReadinessPolling.d.ts +3 -0
- package/dist/testSurface/useReadinessPolling.js +24 -0
- package/dist/transitions/placementInteractions.js +1 -1
- package/dist/transitions/placements.d.ts +27 -8
- package/dist/transitions/placements.js +77 -6
- package/dist/transitions/preflightData.js +1 -1
- package/dist/transitions/start.js +2 -2
- package/dist/types/endpoints.d.ts +1 -1
- package/dist/ui/Card.d.ts +2 -1
- package/dist/ui/Card.js +4 -4
- package/dist/ui/Dialog.d.ts +4 -1
- package/dist/ui/Dialog.js +41 -3
- package/dist/ui/Drawer.d.ts +10 -0
- package/dist/ui/Drawer.js +29 -0
- package/dist/ui/Tabs.d.ts +4 -3
- package/dist/ui/Tabs.js +47 -32
- package/dist/ui/ui.css +24 -0
- package/package.json +1 -1
- package/dist/admin/actions/ConfirmDialog.d.ts +0 -19
- package/dist/admin/actions/ConfirmDialog.js +0 -149
- 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/pagePicker/pagePicker.css +0 -10
- package/dist/admin/surface/readiness/Banner.d.ts +0 -5
- package/dist/admin/surface/readiness/SaveStatus.d.ts +0 -5
- package/dist/admin/surface/readiness/SaveStatus.js +0 -53
- 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 -48
- package/dist/admin/surface/test/VersionsSection.d.ts +0 -4
- package/dist/admin/surface/test/testPage.css +0 -92
- /package/dist/{admin → testSurface}/PreviewLinks.d.ts +0 -0
- /package/dist/{admin → testSurface}/PreviewLinks.js +0 -0
- /package/dist/{admin → testSurface}/actions/MakeContentResult.d.ts +0 -0
- /package/dist/{admin → testSurface}/actions/MakeContentResult.js +0 -0
- /package/dist/{admin → testSurface}/actions/actions.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/actions/actions.model.js +0 -0
- /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}/api.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}/copy/actions.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/actions.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/metrics.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/metrics.js +0 -0
- /package/dist/{admin → testSurface}/copy/pages.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/pages.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/results.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/results.js +0 -0
- /package/dist/{admin → testSurface}/copy/review.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/review.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}/copy/surface.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/surface.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}/metricSource.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/metricSource.model.js +0 -0
- /package/dist/{admin → testSurface}/placements/placementLabels.d.ts +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/VerdictHero.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/VerdictHero.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/results.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/results.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/pageBlock.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/pageBlock/parts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/pagePicker/CopyRoute.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/pagePicker/CopyRoute.js +0 -0
- /package/dist/{admin → testSurface}/surface/pagePicker/PageCombobox.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/pagePicker/PageCombobox.js +0 -0
- /package/dist/{admin → testSurface}/surface/pagePicker/pagePicker.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/pagePicker/pagePicker.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/ActionDialogs.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/parts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/results/ReleasePages.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/results/ReleasePages.js +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/results/useResults.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/results/useResults.js +0 -0
- /package/dist/{admin → testSurface}/surface/setting/parts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/setting/parts.js +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/PageHoldout.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/PageHoldout.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/Rail.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/ReadinessBar.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/TargetingSection.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/fields.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/fields.js +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}/surface/test/pageParts.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/testPage.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/testPage.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/testDocument.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/testDocument.model.js +0 -0
- /package/dist/{admin → testSurface}/surfaceUrls.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.d.ts +0 -0
- /package/dist/{admin → testSurface}/useApi.js +0 -0
|
@@ -1,167 +1,56 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { formatAdminURL } from '
|
|
6
|
-
import {
|
|
7
|
-
import { TEST_PAGE as C } from '../../copy/testPage.js';
|
|
8
|
-
import { pageBlockParts } from '../pageBlock/parts.js';
|
|
9
|
-
import { settingParts } from '../setting/parts.js';
|
|
10
|
-
import { pageParts } from './pageParts.js';
|
|
11
|
-
import { Section } from './Section.js';
|
|
12
|
-
import { Hypothesis, TestName } from './fields.js';
|
|
13
|
-
import { VersionsSection } from './VersionsSection.js';
|
|
14
|
-
import { GoalSection } from './GoalSection.js';
|
|
15
|
-
import { TargetingSection } from './TargetingSection.js';
|
|
16
|
-
import { LengthSection } from './LengthSection.js';
|
|
17
|
-
import { AdvancedSection } from './AdvancedSection.js';
|
|
18
|
-
import { SurfaceShell } from '../SurfaceShell.js';
|
|
3
|
+
import { TestSurface } from '../../../testSurface/surface/test/TestSurface.js';
|
|
4
|
+
import { TEST_PAGE as C } from '../../../testSurface/copy/testPage.js';
|
|
5
|
+
import { formatAdminURL } from '../../../testSurface/format/adminURL.js';
|
|
6
|
+
import { surfaceUrls } from '../../../testSurface/surfaceUrls.js';
|
|
19
7
|
import { Button } from '../../../ui/Button.js';
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import { ReadinessBar } from './ReadinessBar.js';
|
|
23
|
-
import './testPage.css';
|
|
8
|
+
import { StatusChip } from '../../../ui/StatusChip.js';
|
|
9
|
+
import { SurfaceShell } from '../SurfaceShell.js';
|
|
24
10
|
export function TestPage({ id, surface, onTitleChange }) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}, [
|
|
33
|
-
test.doc?.name,
|
|
34
|
-
onTitleChange
|
|
35
|
-
]);
|
|
36
|
-
if (test.loadState !== 'ready' || !test.doc) return /*#__PURE__*/ _jsx(SurfaceShell, {
|
|
37
|
-
adminRoute: surface.adminRoute,
|
|
38
|
-
title: C.test,
|
|
39
|
-
crumbs: [
|
|
40
|
-
{
|
|
41
|
-
label: C.tests,
|
|
42
|
-
href: surfaceUrls.home(surface.adminRoute)
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
label: C.test
|
|
46
|
-
}
|
|
47
|
-
],
|
|
48
|
-
children: /*#__PURE__*/ _jsxs("div", {
|
|
49
|
-
className: "xp-test-page",
|
|
50
|
-
role: test.loadState === 'error' ? 'alert' : 'status',
|
|
51
|
-
children: [
|
|
52
|
-
/*#__PURE__*/ _jsx("p", {
|
|
53
|
-
children: test.loadState === 'forbidden' ? C.forbidden : test.loadState === 'missing' ? C.missing : test.loadState === 'error' ? C.error : C.loading
|
|
54
|
-
}),
|
|
55
|
-
test.loadState === 'error' ? /*#__PURE__*/ _jsx(Button, {
|
|
56
|
-
onClick: ()=>void test.reload(),
|
|
57
|
-
children: C.retry
|
|
58
|
-
}) : null
|
|
59
|
-
]
|
|
60
|
-
})
|
|
61
|
-
});
|
|
62
|
-
const parts = test.doc.kind === 'block' ? pageBlockParts : test.doc.kind === 'page' ? pageParts : settingParts;
|
|
63
|
-
const props = {
|
|
64
|
-
test,
|
|
65
|
-
surface
|
|
66
|
-
};
|
|
67
|
-
return /*#__PURE__*/ _jsx(SurfaceShell, {
|
|
68
|
-
adminRoute: surface.adminRoute,
|
|
69
|
-
title: test.doc.name,
|
|
70
|
-
crumbs: [
|
|
71
|
-
{
|
|
72
|
-
label: C.tests,
|
|
73
|
-
href: surfaceUrls.home(surface.adminRoute)
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
label: test.doc.name
|
|
77
|
-
}
|
|
78
|
-
],
|
|
79
|
-
status: /*#__PURE__*/ _jsxs(_Fragment, {
|
|
80
|
-
children: [
|
|
81
|
-
/*#__PURE__*/ _jsx("span", {
|
|
82
|
-
className: "xp-tests-kind",
|
|
83
|
-
children: C.kinds[test.doc.kind]
|
|
84
|
-
}),
|
|
85
|
-
/*#__PURE__*/ _jsx(StatusChip, {
|
|
86
|
-
status: test.doc.status
|
|
87
|
-
})
|
|
88
|
-
]
|
|
89
|
-
}),
|
|
90
|
-
actions: surface.canReadResults && [
|
|
91
|
-
'running',
|
|
92
|
-
'stopped',
|
|
93
|
-
'decided'
|
|
94
|
-
].includes(test.doc.status) ? /*#__PURE__*/ _jsx(Button, {
|
|
95
|
-
variant: "secondary",
|
|
96
|
-
href: formatAdminURL({
|
|
11
|
+
return /*#__PURE__*/ _jsx(TestSurface, {
|
|
12
|
+
id: id,
|
|
13
|
+
surface: surface,
|
|
14
|
+
onTitleChange: onTitleChange,
|
|
15
|
+
renderFrame: ({ test, children })=>{
|
|
16
|
+
const doc = test.doc;
|
|
17
|
+
return /*#__PURE__*/ _jsx(SurfaceShell, {
|
|
97
18
|
adminRoute: surface.adminRoute,
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
/*#__PURE__*/ _jsxs(
|
|
109
|
-
className: "xp-test-layout",
|
|
19
|
+
title: doc?.name ?? C.test,
|
|
20
|
+
crumbs: [
|
|
21
|
+
{
|
|
22
|
+
label: C.tests,
|
|
23
|
+
href: surfaceUrls.home(surface.adminRoute)
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
label: doc?.name ?? C.test
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
status: doc ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
110
30
|
children: [
|
|
111
|
-
/*#__PURE__*/ _jsx(
|
|
112
|
-
|
|
31
|
+
/*#__PURE__*/ _jsx("span", {
|
|
32
|
+
className: "xp-tests-kind",
|
|
33
|
+
children: C.kinds[doc.kind]
|
|
113
34
|
}),
|
|
114
|
-
/*#__PURE__*/
|
|
115
|
-
|
|
116
|
-
children: [
|
|
117
|
-
test.errors._section ? /*#__PURE__*/ _jsx(Banner, {
|
|
118
|
-
tone: "error",
|
|
119
|
-
action: test.stale ? /*#__PURE__*/ _jsx(Button, {
|
|
120
|
-
onClick: ()=>void test.reload(),
|
|
121
|
-
children: C.reload
|
|
122
|
-
}) : undefined,
|
|
123
|
-
children: test.errors._section
|
|
124
|
-
}) : null,
|
|
125
|
-
/*#__PURE__*/ _jsxs(Section, {
|
|
126
|
-
test: test,
|
|
127
|
-
sectionId: "what",
|
|
128
|
-
children: [
|
|
129
|
-
/*#__PURE__*/ _jsx(TestName, {
|
|
130
|
-
...props
|
|
131
|
-
}),
|
|
132
|
-
/*#__PURE__*/ _jsx(parts.Binding, {
|
|
133
|
-
...props
|
|
134
|
-
}),
|
|
135
|
-
/*#__PURE__*/ _jsx(Hypothesis, {
|
|
136
|
-
...props
|
|
137
|
-
})
|
|
138
|
-
]
|
|
139
|
-
}),
|
|
140
|
-
/*#__PURE__*/ _jsx(VersionsSection, {
|
|
141
|
-
...props,
|
|
142
|
-
parts: parts
|
|
143
|
-
}),
|
|
144
|
-
/*#__PURE__*/ _jsx(GoalSection, {
|
|
145
|
-
...props
|
|
146
|
-
}),
|
|
147
|
-
/*#__PURE__*/ _jsx(TargetingSection, {
|
|
148
|
-
...props
|
|
149
|
-
}),
|
|
150
|
-
/*#__PURE__*/ _jsx(LengthSection, {
|
|
151
|
-
...props
|
|
152
|
-
}),
|
|
153
|
-
/*#__PURE__*/ _jsx(AdvancedSection, {
|
|
154
|
-
...props
|
|
155
|
-
})
|
|
156
|
-
]
|
|
35
|
+
/*#__PURE__*/ _jsx(StatusChip, {
|
|
36
|
+
status: doc.status
|
|
157
37
|
})
|
|
158
38
|
]
|
|
159
|
-
}),
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
39
|
+
}) : undefined,
|
|
40
|
+
actions: doc && surface.canReadResults && [
|
|
41
|
+
'running',
|
|
42
|
+
'stopped',
|
|
43
|
+
'decided'
|
|
44
|
+
].includes(doc.status) ? /*#__PURE__*/ _jsx(Button, {
|
|
45
|
+
variant: "secondary",
|
|
46
|
+
href: formatAdminURL({
|
|
47
|
+
adminRoute: surface.adminRoute,
|
|
48
|
+
path: `/experiments/${encodeURIComponent(String(doc.id))}/results`
|
|
49
|
+
}),
|
|
50
|
+
children: C.results
|
|
51
|
+
}) : undefined,
|
|
52
|
+
children: children
|
|
53
|
+
});
|
|
54
|
+
}
|
|
166
55
|
});
|
|
167
56
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { formatAdminURL } from 'payload/shared';
|
|
2
2
|
import { notFound, redirect } from 'next/navigation.js';
|
|
3
3
|
import { xpOptionsFromReq } from '../../options/fromReq.js';
|
|
4
|
-
import { surfaceUrls } from '
|
|
4
|
+
import { surfaceUrls } from '../../testSurface/surfaceUrls.js';
|
|
5
5
|
import { buildSurfaceProps } from './buildSurfaceProps.js';
|
|
6
6
|
import { renderTestsSurface } from './renderTestsSurface.js';
|
|
7
7
|
export async function ExperimentsRootView({ initPageResult, params, searchParams }) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent';
|
|
2
|
-
import { SURFACE_COPY } from '
|
|
2
|
+
import { SURFACE_COPY } from '../../testSurface/copy/surface.js';
|
|
3
3
|
import { XP_TESTS_NAV_CLIENT } from '../paths.js';
|
|
4
4
|
/** @deprecated Retained for existing import maps until 0.5.0. */ export async function TestsNavLinkServer({ payload, user, permissions }) {
|
|
5
5
|
const testPermissions = permissions?.collections?.['xp-experiments'];
|
|
@@ -2,7 +2,7 @@ import { createLocalReq } from 'payload';
|
|
|
2
2
|
import { formatAdminURL } from 'payload/shared';
|
|
3
3
|
import { headers } from 'next/headers.js';
|
|
4
4
|
import { redirect } from 'next/navigation.js';
|
|
5
|
-
import { surfaceUrls } from '
|
|
5
|
+
import { surfaceUrls } from '../../testSurface/surfaceUrls.js';
|
|
6
6
|
import { buildSurfaceProps } from './buildSurfaceProps.js';
|
|
7
7
|
import { renderTestsSurface } from './renderTestsSurface.js';
|
|
8
8
|
export async function renderCollectionList({ payload, searchParams }, route) {
|
|
@@ -3,7 +3,7 @@ import { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerCompo
|
|
|
3
3
|
import { accentStyles } from '../../ui/accent.js';
|
|
4
4
|
import { xpOptionsFromReq } from '../../options/fromReq.js';
|
|
5
5
|
import { XP_TESTS_SURFACE } from '../paths.js';
|
|
6
|
-
import { SURFACE_COPY } from '
|
|
6
|
+
import { SURFACE_COPY } from '../../testSurface/copy/surface.js';
|
|
7
7
|
export async function renderTestsSurface(req, clientProps) {
|
|
8
8
|
// Keep the server export importable in plain Node; Next loads the CSS-bearing client boundary on render.
|
|
9
9
|
const { RootViewMessage } = await import('../components/RootViewMessage.js');
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type PayloadRequest } from 'payload';
|
|
2
|
+
import type { DocId } from '../types/contracts.js';
|
|
3
|
+
/** Adapter rows retain locale maps; Start's Local API scan flattens these fields
|
|
4
|
+
* to req.locale (and req.fallbackLocale). Registrations name top-level fields.
|
|
5
|
+
* Match Payload afterRead/promise.js:50-89: [] is present, not a fallback.
|
|
6
|
+
*/
|
|
7
|
+
export declare function placementLocaleContent(req: PayloadRequest, collection: string, doc: Record<string, unknown> | undefined): Record<string, unknown> | undefined;
|
|
8
|
+
export interface PlacementLocaleView {
|
|
9
|
+
locale: string;
|
|
10
|
+
fallbackLocale: import('payload').TypedFallbackLocale;
|
|
11
|
+
}
|
|
12
|
+
export declare const placementDocumentKey: (collection: string, id: DocId, view: PlacementLocaleView) => string;
|
|
13
|
+
export type RemovedPlacementViews = Map<string, PlacementLocaleView[]>;
|
|
14
|
+
export declare function localeRequest(req: PayloadRequest, view: PlacementLocaleView): PayloadRequest;
|
|
15
|
+
/** Canonical views of registered content, without multiplying nonlocalized rows. */
|
|
16
|
+
export declare function placementLocaleViews(req: PayloadRequest, collection: string): PlacementLocaleView[];
|
|
17
|
+
/** Compare every locale view: a localized edit can also change fallback
|
|
18
|
+
* content in another locale. Whole-row removals replace every view with absence.
|
|
19
|
+
* The incoming hook document is already flattened to the writing locale.
|
|
20
|
+
*/
|
|
21
|
+
export declare function removedPlacementViews(req: PayloadRequest, collection: string, before: Record<string, unknown> | undefined, after: Record<string, unknown>, removingPage: boolean): RemovedPlacementViews;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { sanitizeFallbackLocale } from 'payload';
|
|
2
|
+
import { flattenTopLevelFields } from 'payload/shared';
|
|
3
|
+
import { puckCollections } from '../options.js';
|
|
4
|
+
import { placementSlugs } from './bindings.js';
|
|
5
|
+
import { isObject } from './model.js';
|
|
6
|
+
/** Adapter rows retain locale maps; Start's Local API scan flattens these fields
|
|
7
|
+
* to req.locale (and req.fallbackLocale). Registrations name top-level fields.
|
|
8
|
+
* Match Payload afterRead/promise.js:50-89: [] is present, not a fallback.
|
|
9
|
+
*/ export function placementLocaleContent(req, collection, doc) {
|
|
10
|
+
const localization = req.payload.config.localization;
|
|
11
|
+
if (!doc || !localization || req.locale === 'all') return doc;
|
|
12
|
+
const config = req.payload.config.collections?.find((entry)=>entry.slug === collection);
|
|
13
|
+
if (!config) return doc;
|
|
14
|
+
const options = req.payload.config.custom.xp;
|
|
15
|
+
const names = new Set([
|
|
16
|
+
...puckCollections(options).filter((entry)=>entry.slug === collection).map((entry)=>entry.field),
|
|
17
|
+
...(options.blocks?.collections ?? []).filter((entry)=>entry.slug === collection).map((entry)=>entry.field)
|
|
18
|
+
]);
|
|
19
|
+
const result = {
|
|
20
|
+
...doc
|
|
21
|
+
};
|
|
22
|
+
const locale = req.locale || localization.defaultLocale;
|
|
23
|
+
const fallback = sanitizeFallbackLocale({
|
|
24
|
+
fallbackLocale: req.fallbackLocale ?? null,
|
|
25
|
+
locale,
|
|
26
|
+
localization
|
|
27
|
+
});
|
|
28
|
+
for (const field of flattenTopLevelFields(config.fields)){
|
|
29
|
+
if (!('name' in field) || typeof field.name !== 'string' || !names.has(field.name) || !('localized' in field) || !field.localized) continue;
|
|
30
|
+
const values = doc[field.name];
|
|
31
|
+
if (!isObject(values)) continue;
|
|
32
|
+
let value = values[locale];
|
|
33
|
+
if (value == null && fallback && fallback !== locale) {
|
|
34
|
+
for (const code of Array.isArray(fallback) ? fallback : [
|
|
35
|
+
fallback
|
|
36
|
+
]){
|
|
37
|
+
if (values[code] != null && values[code] !== '') {
|
|
38
|
+
value = values[code];
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
result[field.name] = value;
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
export const placementDocumentKey = (collection, id, view)=>JSON.stringify([
|
|
48
|
+
collection,
|
|
49
|
+
String(id),
|
|
50
|
+
view
|
|
51
|
+
]);
|
|
52
|
+
export function localeRequest(req, view) {
|
|
53
|
+
return {
|
|
54
|
+
...req,
|
|
55
|
+
...view
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/** Canonical views of registered content, without multiplying nonlocalized rows. */ export function placementLocaleViews(req, collection) {
|
|
59
|
+
const localization = req.payload.config.localization;
|
|
60
|
+
const config = req.payload.config.collections?.find((entry)=>entry.slug === collection);
|
|
61
|
+
const options = req.payload.config.custom.xp;
|
|
62
|
+
const names = new Set([
|
|
63
|
+
...puckCollections(options).filter((entry)=>entry.slug === collection).map((entry)=>entry.field),
|
|
64
|
+
...(options.blocks?.collections ?? []).filter((entry)=>entry.slug === collection).map((entry)=>entry.field)
|
|
65
|
+
]);
|
|
66
|
+
const localized = config && flattenTopLevelFields(config.fields).some((field)=>'name' in field && names.has(field.name) && 'localized' in field && field.localized);
|
|
67
|
+
return localization && localized ? localization.localeCodes.map((locale)=>({
|
|
68
|
+
locale,
|
|
69
|
+
fallbackLocale: sanitizeFallbackLocale({
|
|
70
|
+
fallbackLocale: null,
|
|
71
|
+
locale,
|
|
72
|
+
localization
|
|
73
|
+
})
|
|
74
|
+
})) : [
|
|
75
|
+
{
|
|
76
|
+
locale: '',
|
|
77
|
+
fallbackLocale: false
|
|
78
|
+
}
|
|
79
|
+
];
|
|
80
|
+
}
|
|
81
|
+
/** Compare every locale view: a localized edit can also change fallback
|
|
82
|
+
* content in another locale. Whole-row removals replace every view with absence.
|
|
83
|
+
* The incoming hook document is already flattened to the writing locale.
|
|
84
|
+
*/ export function removedPlacementViews(req, collection, before, after, removingPage) {
|
|
85
|
+
const result = new Map();
|
|
86
|
+
if (!before) return result;
|
|
87
|
+
const localization = req.payload.config.localization;
|
|
88
|
+
const config = req.payload.config.collections?.find((entry)=>entry.slug === collection);
|
|
89
|
+
const options = req.payload.config.custom.xp;
|
|
90
|
+
const fields = config ? flattenTopLevelFields(config.fields) : [];
|
|
91
|
+
const localized = fields.filter((field)=>'name' in field && 'localized' in field && field.localized);
|
|
92
|
+
// Keep the raw locale maps for unchanged languages when merging a partial,
|
|
93
|
+
// flattened main-row write back into the adapter baseline.
|
|
94
|
+
const rawAfter = {
|
|
95
|
+
...after
|
|
96
|
+
};
|
|
97
|
+
if (localization && req.locale !== 'all') for (const field of localized){
|
|
98
|
+
if (!('name' in field) || typeof field.name !== 'string' || !(field.name in after)) continue;
|
|
99
|
+
const previousValue = before[field.name];
|
|
100
|
+
rawAfter[field.name] = {
|
|
101
|
+
...isObject(previousValue) ? previousValue : {},
|
|
102
|
+
[req.locale || localization.defaultLocale]: after[field.name]
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
for (const view of placementLocaleViews(req, collection)){
|
|
106
|
+
const viewReq = localeRequest(req, view);
|
|
107
|
+
const previous = placementSlugs(options, collection, placementLocaleContent(viewReq, collection, before));
|
|
108
|
+
const next = removingPage ? [] : placementSlugs(options, collection, placementLocaleContent(viewReq, collection, rawAfter));
|
|
109
|
+
for (const slug of previous.filter((slug)=>!next.includes(slug)))result.set(slug, [
|
|
110
|
+
...result.get(slug) ?? [],
|
|
111
|
+
view
|
|
112
|
+
]);
|
|
113
|
+
}
|
|
114
|
+
return result;
|
|
115
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SURFACE_COPY } from '../../
|
|
1
|
+
import { SURFACE_COPY } from '../../testSurface/copy/surface.js';
|
|
2
2
|
import * as paths from '../../admin/paths.js';
|
|
3
3
|
import { managedAccess } from '../access.js';
|
|
4
4
|
import { serializeAttributeKeys, serializeFlagPoints } from '../serialize.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SURFACE_COPY } from '../
|
|
1
|
+
import { SURFACE_COPY } from '../testSurface/copy/surface.js';
|
|
2
2
|
import { CLICK_KEY, isClickSource, validClickSource } from '../goals/key.js';
|
|
3
3
|
import { XP_METRIC_SOURCE_SELECT, XP_GOALS_COLLECTION_LIST, XP_GOAL_EDIT_REDIRECT } from '../admin/paths.js';
|
|
4
4
|
import { managedAccess } from './access.js';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { PayloadRequest, Where } from 'payload';
|
|
2
|
+
import { type PlacementLocaleView } from '../blocks/placementLocale.js';
|
|
3
|
+
import type { DocId } from '../types/contracts.js';
|
|
4
|
+
export interface BulkPlacementRemoval {
|
|
5
|
+
documents: Set<string>;
|
|
6
|
+
change?: {
|
|
7
|
+
collection: string;
|
|
8
|
+
data?: Record<string, unknown>;
|
|
9
|
+
draft: boolean;
|
|
10
|
+
deleting: boolean;
|
|
11
|
+
};
|
|
12
|
+
refusals: Map<string, string>;
|
|
13
|
+
}
|
|
14
|
+
export declare function usesBulkDocumentTransactions(req: PayloadRequest): boolean;
|
|
15
|
+
/** A distinct operation identity without copying the transaction/context. Native
|
|
16
|
+
* Request accessors and methods must use the original receiver.
|
|
17
|
+
*/
|
|
18
|
+
export declare function placementOperationRequest(req: PayloadRequest, fields: Map<PropertyKey, unknown>, failed?: () => void): PayloadRequest;
|
|
19
|
+
/** Observe Payload's actual, access-filtered bulk selection before it dispatches
|
|
20
|
+
* any document hooks. This request-only proxy adds no reads and never replaces
|
|
21
|
+
* the shared adapter. Matching the original Where node avoids capturing nested
|
|
22
|
+
* access-hook reads. queryDrafts prefixes keys but preserves condition objects.
|
|
23
|
+
* Payload 3's update/delete operations select the entire set before Promise.all.
|
|
24
|
+
*/
|
|
25
|
+
export declare function bulkPlacementRequest(req: PayloadRequest, collection: string, where: Where, data: Record<string, unknown> | undefined, draft: boolean, deleting: boolean, bulk: BulkPlacementRemoval): PayloadRequest;
|
|
26
|
+
/** Evaluate the common change against the published row seen under E, rather
|
|
27
|
+
* than a draft version or a selection snapshot from before the lock. */
|
|
28
|
+
export declare function bulkRemoves(bulk: BulkPlacementRemoval | undefined, req: PayloadRequest, collection: string, doc: Record<string, unknown> & {
|
|
29
|
+
id: DocId;
|
|
30
|
+
}, slug: string, view: PlacementLocaleView): boolean;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { removedPlacementViews, placementDocumentKey } from '../blocks/placementLocale.js';
|
|
2
|
+
// Payload starts/ends a transaction per bulk document with this adapter option.
|
|
3
|
+
export function usesBulkDocumentTransactions(req) {
|
|
4
|
+
return req.payload.db.bulkOperationsSingleTransaction === true;
|
|
5
|
+
}
|
|
6
|
+
const operationRequestState = Symbol('xpPlacementRequestState');
|
|
7
|
+
/** A distinct operation identity without copying the transaction/context. Native
|
|
8
|
+
* Request accessors and methods must use the original receiver.
|
|
9
|
+
*/ export function placementOperationRequest(req, fields, failed) {
|
|
10
|
+
const parent = req[operationRequestState];
|
|
11
|
+
const state = {
|
|
12
|
+
target: parent?.target ?? req,
|
|
13
|
+
failed: failed ?? parent?.failed
|
|
14
|
+
};
|
|
15
|
+
return new Proxy(req, {
|
|
16
|
+
deleteProperty (target, key) {
|
|
17
|
+
// Transaction deletion must reach the shared request without ending any
|
|
18
|
+
// ancestor operation. Extra wrappers of this operation inherit its cleanup.
|
|
19
|
+
if (key === 'transactionID') {
|
|
20
|
+
state.failed?.();
|
|
21
|
+
return Reflect.deleteProperty(state.target, key);
|
|
22
|
+
}
|
|
23
|
+
return Reflect.deleteProperty(target, key);
|
|
24
|
+
},
|
|
25
|
+
get (target, key) {
|
|
26
|
+
if (key === operationRequestState) return state;
|
|
27
|
+
if (fields.has(key)) return fields.get(key);
|
|
28
|
+
const value = Reflect.get(target, key, target);
|
|
29
|
+
return typeof Object.getOwnPropertyDescriptor(Request.prototype, key)?.value === 'function' ? value.bind(target) : value;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/** Observe Payload's actual, access-filtered bulk selection before it dispatches
|
|
34
|
+
* any document hooks. This request-only proxy adds no reads and never replaces
|
|
35
|
+
* the shared adapter. Matching the original Where node avoids capturing nested
|
|
36
|
+
* access-hook reads. queryDrafts prefixes keys but preserves condition objects.
|
|
37
|
+
* Payload 3's update/delete operations select the entire set before Promise.all.
|
|
38
|
+
*/ export function bulkPlacementRequest(req, collection, where, data, draft, deleting, bulk) {
|
|
39
|
+
const config = req.payload.config.collections.find((entry)=>entry.slug === collection);
|
|
40
|
+
const draftOnly = draft && Boolean(config?.versions && config.versions.drafts) && data?._status !== 'published';
|
|
41
|
+
bulk.change = {
|
|
42
|
+
collection,
|
|
43
|
+
data,
|
|
44
|
+
draft: draftOnly,
|
|
45
|
+
deleting
|
|
46
|
+
};
|
|
47
|
+
let captured = false;
|
|
48
|
+
const matches = (value, expected, versions)=>{
|
|
49
|
+
if (value === expected) return true;
|
|
50
|
+
if (!versions) return false;
|
|
51
|
+
if (!value || !expected || typeof value !== 'object' || typeof expected !== 'object') return false;
|
|
52
|
+
const actual = value;
|
|
53
|
+
return Object.entries(expected).every(([key, condition])=>{
|
|
54
|
+
if (key === 'and' || key === 'or') return Array.isArray(actual[key]) && Array.isArray(condition) && condition.length === actual[key].length && condition.every((entry, i)=>matches(actual[key][i], entry, versions));
|
|
55
|
+
return actual[versions ? key === 'id' ? 'parent' : `version.${key}` : key] === condition;
|
|
56
|
+
}) && Object.keys(actual).length === Object.keys(expected).length;
|
|
57
|
+
};
|
|
58
|
+
const contains = (value, versions)=>matches(value, where, versions) || !!value && typeof value === 'object' && [
|
|
59
|
+
'and',
|
|
60
|
+
'or'
|
|
61
|
+
].some((key)=>{
|
|
62
|
+
const children = value[key];
|
|
63
|
+
return Array.isArray(children) && children.some((child)=>contains(child, versions));
|
|
64
|
+
});
|
|
65
|
+
const database = new Proxy(req.payload.db, {
|
|
66
|
+
get (target, key, receiver) {
|
|
67
|
+
const method = Reflect.get(target, key, receiver);
|
|
68
|
+
if (key !== 'find' && key !== 'queryDrafts') return method;
|
|
69
|
+
return async (query)=>{
|
|
70
|
+
const selection = !captured && (key !== 'queryDrafts' || 'pagination' in query && query.pagination === false) && query.req === scoped && query.collection === collection && contains(query.where, key === 'queryDrafts');
|
|
71
|
+
const result = await method.call(target, query);
|
|
72
|
+
if (selection) {
|
|
73
|
+
captured = true;
|
|
74
|
+
for (const doc of result.docs)bulk.documents.add(JSON.stringify([
|
|
75
|
+
collection,
|
|
76
|
+
String(doc.id)
|
|
77
|
+
]));
|
|
78
|
+
}
|
|
79
|
+
return result;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
const payload = new Proxy(req.payload, {
|
|
84
|
+
get: (target, key, receiver)=>key === 'db' ? database : Reflect.get(target, key, receiver)
|
|
85
|
+
});
|
|
86
|
+
const scoped = placementOperationRequest(req, new Map([
|
|
87
|
+
[
|
|
88
|
+
'payload',
|
|
89
|
+
payload
|
|
90
|
+
]
|
|
91
|
+
]));
|
|
92
|
+
return scoped;
|
|
93
|
+
}
|
|
94
|
+
/** Evaluate the common change against the published row seen under E, rather
|
|
95
|
+
* than a draft version or a selection snapshot from before the lock. */ export function bulkRemoves(bulk, req, collection, doc, slug, view) {
|
|
96
|
+
const change = bulk?.change;
|
|
97
|
+
if (!change || change.draft || change.collection !== collection || !bulk.documents.has(JSON.stringify([
|
|
98
|
+
collection,
|
|
99
|
+
String(doc.id)
|
|
100
|
+
]))) return false;
|
|
101
|
+
const after = {
|
|
102
|
+
...doc,
|
|
103
|
+
...change.data
|
|
104
|
+
};
|
|
105
|
+
const views = removedPlacementViews(req, collection, doc, after, change.deleting || after.deletedAt != null || after._status === 'draft');
|
|
106
|
+
return (views.get(slug) ?? []).some((removed)=>placementDocumentKey(collection, doc.id, removed) === placementDocumentKey(collection, doc.id, view));
|
|
107
|
+
}
|
package/dist/db/placements.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export interface PlacementTest {
|
|
|
21
21
|
}
|
|
22
22
|
/** Raw reads only: guard discovery includes every status, interaction checks filter under the locks. */
|
|
23
23
|
export declare function placementTests(exec: Executor): Promise<PlacementTest[]>;
|
|
24
|
+
/** Indexed slug lookup for the removal guard; startable tests share E with Start before status is rechecked. */
|
|
25
|
+
export declare function removableBlockTests(exec: Executor, slugs: readonly string[]): Promise<Array<Pick<PlacementTest, 'id' | 'slug' | 'name' | 'status'>>>;
|
|
24
26
|
/** §7.8: interacting-tests computes placement paths from published rows. */
|
|
25
27
|
export declare function placementPathContent(req: PayloadRequest, collection: string, id: DocId): Promise<(Record<string, unknown> & {
|
|
26
28
|
id: DocId;
|
package/dist/db/placements.js
CHANGED
|
@@ -14,6 +14,14 @@ import { qualifiedTable, quoteIdentifier as q } from './sql.js';
|
|
|
14
14
|
placementDocs: row.placementDocs ?? null
|
|
15
15
|
}));
|
|
16
16
|
}
|
|
17
|
+
/** Indexed slug lookup for the removal guard; startable tests share E with Start before status is rechecked. */ export async function removableBlockTests(exec, slugs) {
|
|
18
|
+
const e = COLUMNS.experiments;
|
|
19
|
+
const { rows } = await exec.query(`SELECT ${q(e.id)} AS id, ${q(e.slug)} AS slug, ${q(e.name)} AS name, ${q(e.status)} AS status
|
|
20
|
+
FROM ${qualifiedTable(exec, TABLES.experiments)} WHERE ${q(e.slug)} = ANY($1::text[]) AND ${q(e.kind)} = 'block' AND ${q(e.status)} IN ('draft', 'stopped', 'running')`, [
|
|
21
|
+
slugs
|
|
22
|
+
]);
|
|
23
|
+
return rows;
|
|
24
|
+
}
|
|
17
25
|
/** §7.8: interacting-tests computes placement paths from published rows. */ export async function placementPathContent(req, collection, id) {
|
|
18
26
|
return req.payload.db.findOne({
|
|
19
27
|
collection,
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { buildSurfaceProps } from '../admin/views/buildSurfaceProps.js';
|
|
2
|
+
/** The same request-scoped configuration the admin view sends this user. */ export async function handleEditorSurface(req) {
|
|
3
|
+
const props = await buildSurfaceProps({
|
|
4
|
+
req,
|
|
5
|
+
route: 'test',
|
|
6
|
+
searchParams: {}
|
|
7
|
+
}) ?? await buildSurfaceProps({
|
|
8
|
+
req,
|
|
9
|
+
route: 'results',
|
|
10
|
+
searchParams: {}
|
|
11
|
+
});
|
|
12
|
+
if (!props) return Response.json({
|
|
13
|
+
errors: [
|
|
14
|
+
{
|
|
15
|
+
code: 'forbidden',
|
|
16
|
+
message: 'Access denied'
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
}, {
|
|
20
|
+
status: 403,
|
|
21
|
+
headers: {
|
|
22
|
+
'Cache-Control': 'private, no-store'
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
const { route: _route, id: _id, pages: _pages, returnToTest: _return, ...surface } = props;
|
|
26
|
+
return Response.json(surface, {
|
|
27
|
+
headers: {
|
|
28
|
+
'Cache-Control': 'private, no-store'
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|