@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
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
:where(.xp-test-surface) .xp-test-page { color: var(--xp-text); background: var(--xp-bg); max-width: 90rem; margin: 0 auto; padding: 1.5rem; }
|
|
2
|
+
:where(.xp-test-surface) .xp-test-page--setup { min-width: 0; padding: 0 0 160px; }
|
|
3
|
+
:where(.xp-test-surface) .xp-test-header { position: sticky; top: 0; z-index: 10; background: var(--xp-bg); padding: 1rem 0; border-bottom: 1px solid var(--xp-border); }
|
|
4
|
+
:where(.xp-test-surface) .xp-header-meta, :where(.xp-test-surface) .xp-section-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; margin-block: 1rem; }
|
|
5
|
+
:where(.xp-test-surface) .xp-kind-chip, :where(.xp-test-surface) .xp-status-pill { border: 1px solid var(--xp-border-strong); border-radius: 1rem; padding: .25rem .75rem; }
|
|
6
|
+
:where(.xp-test-surface) .xp-status-pill--success, :where(.xp-test-surface) .xp-content-ready, :where(.xp-test-surface) .xp-section-check--done { color: var(--xp-success-text); }
|
|
7
|
+
:where(.xp-test-surface) .xp-content-empty, :where(.xp-test-surface) .xp-status-pill--warning { color: var(--xp-warning-text); }
|
|
8
|
+
:where(.xp-test-surface) .xp-test-section, :where(.xp-test-surface) .xp-test-advanced { scroll-margin-top: var(--xp-space-6); }
|
|
9
|
+
:where(.xp-test-surface) .xp-version-rows { display: grid; grid-template-columns: minmax(0, 1.3fr) var(--xp-version-share-width) minmax(var(--xp-version-state-width), 1fr) var(--xp-version-remove-width); gap: var(--xp-space-3); align-items: center; }
|
|
10
|
+
:where(.xp-test-surface) .xp-version-row, :where(.xp-test-surface) .xp-version-grid-head { display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; gap: var(--xp-space-3); align-items: center; }
|
|
11
|
+
:where(.xp-test-surface) .xp-version-grid-head { margin-bottom: var(--xp-space-2); font: var(--xp-text-small); color: var(--xp-text-2); }
|
|
12
|
+
:where(.xp-test-surface) .xp-version-row > .xp-field-error, :where(.xp-test-surface) .xp-version-row > [role=alert] { grid-column: 1 / -1; }
|
|
13
|
+
:where(.xp-test-surface) .xp-version-remove { grid-column: 4; }
|
|
14
|
+
:where(.xp-test-surface) .xp-grid-field .xp-ui-field { margin: 0; }
|
|
15
|
+
:where(.xp-test-surface) .xp-grid-field .xp-ui-field > label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
|
|
16
|
+
:where(.xp-test-surface) .xp-version-content { display: flex; flex-wrap: nowrap; gap: var(--xp-space-2); align-items: center; min-width: 0; }
|
|
17
|
+
:where(.xp-test-surface) .xp-version-content .xp-ui-button { white-space: nowrap; }
|
|
18
|
+
:where(.xp-test-surface) .xp-version-content--page { flex-direction: column; align-items: stretch; gap: var(--xp-space-3); }
|
|
19
|
+
:where(.xp-test-surface) .xp-copy-route ol { list-style: decimal; padding-inline-start: var(--xp-space-6); }
|
|
20
|
+
:where(.xp-test-surface) .xp-content-chip { flex-shrink: 0; display: inline-flex; width: fit-content; border-radius: var(--xp-radius-chip); padding: var(--xp-space-half) var(--xp-space-2); font: var(--xp-text-small); background: var(--xp-surface-2); color: var(--xp-text-2); }
|
|
21
|
+
:where(.xp-test-surface) .xp-content-chip.xp-content-ready { background: var(--xp-success-bg); color: var(--xp-success); }
|
|
22
|
+
:where(.xp-test-surface) .xp-content-chip.xp-content-empty { background: var(--xp-warning-bg); color: var(--xp-warning); }
|
|
23
|
+
:where(.xp-test-surface) .xp-traffic-bar { display: flex; height: var(--xp-space-2); gap: var(--xp-space-half); margin-block: var(--xp-space-5) var(--xp-space-3); overflow: hidden; border-radius: var(--xp-space-1); }
|
|
24
|
+
:where(.xp-test-surface) .xp-traffic-bar > span { display: block; }
|
|
25
|
+
:where(.xp-test-surface) .xp-split-legend { display: flex; flex-wrap: wrap; gap: var(--xp-space-4); font: var(--xp-text-small); color: var(--xp-text-2); }
|
|
26
|
+
:where(.xp-test-surface) .xp-split-legend i { display: inline-block; width: var(--xp-legend-key-size); height: var(--xp-legend-key-size); border-radius: var(--xp-legend-key-radius); margin-right: var(--xp-space-one-half); }
|
|
27
|
+
:where(.xp-test-surface) .xp-field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--xp-space-4); }
|
|
28
|
+
:where(.xp-test-surface) .xp-test-advanced .xp-field-grid { padding-top: var(--xp-space-4); }
|
|
29
|
+
:where(.xp-test-surface) .xp-field-grid > div { min-width: 0; }
|
|
30
|
+
:where(.xp-test-surface) .xp-field-grid p, :where(.xp-test-surface) .xp-page-binding p { color: var(--xp-text-2); font: var(--xp-text-small); }
|
|
31
|
+
:where(.xp-test-surface) .xp-read-only code { font-family: var(--xp-mono); overflow-wrap: anywhere; }
|
|
32
|
+
:where(.xp-test-surface) .xp-ui-checkbox-list { display: flex; flex-wrap: wrap; gap: var(--xp-space-2) var(--xp-space-4); }
|
|
33
|
+
:where(.xp-test-surface) .xp-duration-suggestion { align-items: center; margin-top: var(--xp-space-4); }
|
|
34
|
+
:where(.xp-test-surface) .xp-read-only { padding-block: .5rem; }
|
|
35
|
+
:where(.xp-test-surface) .xp-read-only p { margin-block: .5rem; }
|
|
36
|
+
:where(.xp-test-surface) .xp-field-error { color: var(--xp-error-text); }
|
|
37
|
+
|
|
38
|
+
:where(.xp-test-surface) .xp-targeting-row { display: grid; grid-template-columns: var(--xp-targeting-attribute-width) var(--xp-targeting-comparison-width) minmax(0, 1fr); align-items: start; gap: var(--xp-space-3); border: 1px solid var(--xp-border); border-radius: var(--xp-radius-control); padding: var(--xp-space-4); margin-bottom: var(--xp-space-4); }
|
|
39
|
+
:where(.xp-test-surface) .xp-targeting-row > .xp-ui-button-group, :where(.xp-test-surface) .xp-targeting-row > p { grid-column: 1 / -1; }
|
|
40
|
+
@media (max-width: 720px) {
|
|
41
|
+
:where(.xp-test-surface) .xp-version-rows { grid-template-columns: minmax(0, 1fr) var(--xp-version-share-width-mobile); }
|
|
42
|
+
:where(.xp-test-surface) .xp-version-content { flex-wrap: wrap; }
|
|
43
|
+
:where(.xp-test-surface) .xp-version-remove:empty { display: none; }
|
|
44
|
+
:where(.xp-test-surface) .xp-version-content, :where(.xp-test-surface) .xp-setting-values, :where(.xp-test-surface) .xp-version-remove { grid-column: 1 / -1; }
|
|
45
|
+
:where(.xp-test-surface) .xp-version-grid-head > :nth-child(n+3) { display: none; }
|
|
46
|
+
:where(.xp-test-surface) .xp-targeting-row, :where(.xp-test-surface) .xp-field-grid { grid-template-columns: 1fr; }
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
:where(.xp-test-surface) .xp-test-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); align-items: start; gap: var(--xp-space-8); }
|
|
50
|
+
:where(.xp-test-surface) .xp-test-content { display: grid; gap: var(--xp-space-8); min-width: 0; max-width: 760px; }
|
|
51
|
+
:where(.xp-test-surface) .xp-test-rail { position: sticky; top: var(--xp-space-6); min-width: 0; }
|
|
52
|
+
:where(.xp-test-surface) .xp-test-rail-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--xp-space-1); }
|
|
53
|
+
:where(.xp-test-surface) .xp-test-rail-item { display: flex; align-items: center; gap: var(--xp-space-2); padding: var(--xp-space-2); border-radius: var(--xp-radius-control); color: var(--xp-text-2); text-decoration: none; font: var(--xp-text-small); }
|
|
54
|
+
:where(.xp-test-surface) .xp-test-rail-item:hover, :where(.xp-test-surface) .xp-test-rail-item.is-active { background: var(--xp-surface-2); color: var(--xp-text); }
|
|
55
|
+
:where(.xp-test-surface) .xp-test-rail-item.is-active { font-weight: 600; }
|
|
56
|
+
:where(.xp-test-surface) .xp-test-rail-item--advanced { margin-top: var(--xp-space-3); color: var(--xp-text-3); }
|
|
57
|
+
:where(.xp-test-surface) .xp-test-rail-mark { flex: none; color: var(--xp-text-3); }
|
|
58
|
+
:where(.xp-test-surface) .xp-test-rail-mark--done { color: var(--xp-success); }
|
|
59
|
+
:where(.xp-test-surface) .xp-test-sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
|
|
60
|
+
:where(.xp-test-surface) .xp-test-rail-item:focus-visible, :where(.xp-test-surface) .xp-test-advanced > summary:focus-visible, :where(.xp-test-surface) .xp-test-content h2:focus { outline: 2px solid var(--xp-focus); outline-offset: 2px; }
|
|
61
|
+
:where(.xp-test-surface) .xp-test-advanced { border: 1px solid var(--xp-border); border-radius: var(--xp-radius-card); background: var(--xp-surface); }
|
|
62
|
+
:where(.xp-test-surface) .xp-test-advanced > summary { cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: var(--xp-space-3); padding: var(--xp-space-4) var(--xp-space-5); color: var(--xp-text-2); }
|
|
63
|
+
:where(.xp-test-surface) .xp-test-advanced > summary h2 { margin: 0; font: var(--xp-text-body); }
|
|
64
|
+
:where(.xp-test-surface) .xp-test-advanced[open] > summary { border-bottom: 1px solid var(--xp-border); }
|
|
65
|
+
:where(.xp-test-surface) .xp-test-readiness-bar { position: fixed; bottom: 0; inset-inline: 0; z-index: 20; background: var(--xp-surface); border-top: 1px solid var(--xp-border); }
|
|
66
|
+
:where(.xp-test-surface) .xp-readiness { color: var(--xp-text); background: var(--xp-surface); padding: var(--xp-space-4); border: 1px solid var(--xp-border-strong); border-radius: var(--xp-radius-control); }
|
|
67
|
+
:where(.xp-test-surface) .xp-readiness--ready:not(.xp-readiness--bar) { background: var(--xp-success-bg); }
|
|
68
|
+
:where(.xp-test-surface) .xp-readiness--bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--xp-space-2) var(--xp-space-4); padding-block: var(--xp-space-3); min-height: 64px; border: 0; border-radius: 0; }
|
|
69
|
+
:where(.xp-test-surface) .xp-readiness__state { display: flex; align-items: center; flex-wrap: wrap; gap: var(--xp-space-2); min-width: 0; }
|
|
70
|
+
:where(.xp-test-surface) .xp-readiness__state p, :where(.xp-test-surface) .xp-readiness--bar > p { margin: 0; }
|
|
71
|
+
:where(.xp-test-surface) .xp-readiness__state > p { font-weight: 500; white-space: pre-line; }
|
|
72
|
+
:where(.xp-test-surface) .xp-readiness--bar .xp-save-status, :where(.xp-test-surface) .xp-readiness__separator { color: var(--xp-text-3); font: var(--xp-text-small); }
|
|
73
|
+
:where(.xp-test-surface) .xp-readiness__actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--xp-space-2); }
|
|
74
|
+
:where(.xp-test-surface) .xp-readiness--bar > .xp-readiness__actions { grid-column: 2; grid-row: 1 / span 3; justify-content: flex-end; }
|
|
75
|
+
@media (max-width: 960px) {
|
|
76
|
+
:where(.xp-test-surface) .xp-test-layout { grid-template-columns: minmax(0, 1fr); gap: var(--xp-space-5); }
|
|
77
|
+
:where(.xp-test-surface) .xp-test-rail { top: 0; z-index: 2; background: var(--xp-bg); padding-block: var(--xp-space-2); border-bottom: 1px solid var(--xp-border); }
|
|
78
|
+
:where(.xp-test-surface) .xp-test-rail-list { flex-direction: row; overflow-x: auto; }
|
|
79
|
+
:where(.xp-test-surface) .xp-test-rail-item { white-space: nowrap; }
|
|
80
|
+
:where(.xp-test-surface) .xp-test-rail-item--advanced { margin-top: 0; }
|
|
81
|
+
:where(.xp-test-surface) .xp-test-content { max-width: none; }
|
|
82
|
+
:where(.xp-test-surface) .xp-test-section, :where(.xp-test-surface) .xp-test-advanced { scroll-margin-top: 64px; }
|
|
83
|
+
}
|
|
84
|
+
@media (max-width: 720px) {
|
|
85
|
+
:where(.xp-test-surface) .xp-readiness--bar { grid-template-columns: minmax(0, 1fr); }
|
|
86
|
+
/* The sentence wraps under the save state here, so a trailing separator would dangle. */
|
|
87
|
+
:where(.xp-test-surface) .xp-readiness--bar .xp-readiness__separator { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
|
|
88
|
+
:where(.xp-test-surface) .xp-readiness--bar > .xp-readiness__actions { grid-column: 1; grid-row: auto; justify-content: flex-start; }
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
:where(.xp-test-surface) .xp-ui-checkbox-list > .xp-ui-field:has(input[type="search"]) { flex-basis: 100%; }
|
|
92
|
+
:where(.xp-test-surface) .xp-targeting-row .xp-ui-chips { margin-block: 0; }
|
|
93
|
+
|
|
94
|
+
:where(.xp-test-surface) .xp-test-rail-mark--blocked { color: var(--xp-error); }
|
|
95
|
+
:where(.xp-test-surface) .xp-test-rail-item.is-blocked { border-color: var(--xp-error-border); }
|
|
96
|
+
:where(.xp-test-surface) .xp-ui-section--blocked h2:focus, :where(.xp-test-surface) .xp-test-rail-item.is-blocked:focus-visible { outline-color: var(--xp-error); }
|
|
97
|
+
:where(.xp-test-surface) .xp-readiness__warning { color: var(--xp-warning); border-inline-start: 3px solid var(--xp-warning-border); padding-inline-start: var(--xp-space-2); }
|
|
98
|
+
|
|
99
|
+
:where(.xp-test-surface) .xp-readiness--bar { grid-template-columns: minmax(0, 1fr); }
|
|
100
|
+
:where(.xp-test-surface) .xp-readiness--bar > .xp-readiness__actions { grid-column: 1; grid-row: auto; justify-content: flex-start; }
|
|
101
|
+
:where(.xp-test-surface) .xp-readiness-action-reason { display: block; }
|
|
102
|
+
|
|
103
|
+
:where(.xp-test-surface) .xp-test-advanced.xp-ui-section--blocked { border-color: var(--xp-error-border); }
|
|
104
|
+
:where(.xp-test-surface) .xp-test-rail-mark--blocked { display: grid; place-items: center; width: 20px; height: 20px; border: 1px solid var(--xp-error-border); border-radius: 50%; }
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import type { Arm, DocId } from '../../types/contracts.js';
|
|
2
2
|
import type { PreflightResult } from '../../types/endpoints.js';
|
|
3
|
+
import { type ReadinessRead } from '../readinessRead.js';
|
|
3
4
|
import type { TestDocument, TestDocumentPatch } from './testDocument.model.js';
|
|
4
5
|
/** Section data only: staging never saves. Call commit on blur or a section action. */
|
|
5
|
-
export declare function useTestDocument(id: DocId, { apiRoute, refetchPreflightOnFocus }: {
|
|
6
|
+
export declare function useTestDocument(id: DocId, { apiRoute, refetchPreflightOnFocus, enabled, onDocument, onPreflight, requestPreflight }: {
|
|
6
7
|
apiRoute: string;
|
|
7
8
|
refetchPreflightOnFocus?: boolean;
|
|
9
|
+
enabled?: boolean;
|
|
10
|
+
onDocument?: (doc: TestDocument) => void;
|
|
11
|
+
onPreflight?: (preflight: PreflightResult) => void;
|
|
12
|
+
requestPreflight?: (signal: AbortSignal, supersede?: boolean) => Promise<Response>;
|
|
8
13
|
}): {
|
|
9
14
|
stage: (partial: TestDocumentPatch) => void;
|
|
10
15
|
commit: () => Promise<void>;
|
|
11
16
|
reload: () => Promise<void>;
|
|
12
|
-
refreshPreflight: () => Promise<void>;
|
|
17
|
+
refreshPreflight: (supersede?: boolean) => Promise<void>;
|
|
13
18
|
choosePage: (arm: Arm["key"], page: {
|
|
14
19
|
id: DocId;
|
|
15
20
|
path: string;
|
|
@@ -24,6 +29,7 @@ export declare function useTestDocument(id: DocId, { apiRoute, refetchPreflightO
|
|
|
24
29
|
}>>;
|
|
25
30
|
doc: TestDocument | null;
|
|
26
31
|
preflight: PreflightResult | null;
|
|
32
|
+
preflightRead?: ReadinessRead;
|
|
27
33
|
preflightError: string | null;
|
|
28
34
|
preflightPending: boolean;
|
|
29
35
|
/** Includes staged edits and all queued or in-flight PATCHes. */
|
|
@@ -33,4 +39,5 @@ export declare function useTestDocument(id: DocId, { apiRoute, refetchPreflightO
|
|
|
33
39
|
stale: boolean;
|
|
34
40
|
/** Path-specific validation errors; _section is the fallback for a section-wide refusal. */
|
|
35
41
|
errors: Record<string, string>;
|
|
42
|
+
acceptTransition?: (result: unknown) => void;
|
|
36
43
|
};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
|
-
import { API_MESSAGES
|
|
3
|
+
import { API_MESSAGES } from '../copy/common.js';
|
|
4
|
+
import { readPreflight } from '../readPreflight.js';
|
|
4
5
|
import { XP_IF_UPDATED_AT_HEADER } from '../../constants.js';
|
|
6
|
+
import { useReadinessPolling } from '../useReadinessPolling.js';
|
|
7
|
+
import { classifyReadinessRead } from '../readinessRead.js';
|
|
5
8
|
import { TEST_PAGE } from '../copy/testPage.js';
|
|
6
9
|
import { changedPatch, editablePatch, payloadFieldErrors } from './testDocument.model.js';
|
|
7
10
|
// Saves outlive their mounted reader. Reopening the same document must wait for its queue.
|
|
@@ -65,7 +68,17 @@ function stage(session, partial) {
|
|
|
65
68
|
if (!session.queue.length) session.view.saving = 'idle';
|
|
66
69
|
session.publish();
|
|
67
70
|
}
|
|
68
|
-
/** Section data only: staging never saves. Call commit on blur or a section action. */ export function useTestDocument(id, { apiRoute, refetchPreflightOnFocus = false }) {
|
|
71
|
+
/** Section data only: staging never saves. Call commit on blur or a section action. */ export function useTestDocument(id, { apiRoute, refetchPreflightOnFocus = false, enabled = true, onDocument, onPreflight, requestPreflight }) {
|
|
72
|
+
const observers = useRef({
|
|
73
|
+
onDocument,
|
|
74
|
+
onPreflight,
|
|
75
|
+
requestPreflight
|
|
76
|
+
});
|
|
77
|
+
observers.current = {
|
|
78
|
+
onDocument,
|
|
79
|
+
onPreflight,
|
|
80
|
+
requestPreflight
|
|
81
|
+
};
|
|
69
82
|
const base = apiRoute.replace(/\/$/, '');
|
|
70
83
|
const documentId = String(id);
|
|
71
84
|
const key = JSON.stringify([
|
|
@@ -81,18 +94,22 @@ function stage(session, partial) {
|
|
|
81
94
|
}));
|
|
82
95
|
const [reloadCount, setReloadCount] = useState(0);
|
|
83
96
|
useEffect(()=>{
|
|
97
|
+
if (!enabled) return;
|
|
84
98
|
const controller = new AbortController();
|
|
85
99
|
const session = {
|
|
86
100
|
key,
|
|
87
|
-
saved: null,
|
|
101
|
+
saved: current.current?.key === key ? current.current.saved : null,
|
|
88
102
|
pending: {},
|
|
89
103
|
queue: [],
|
|
90
104
|
tail: Promise.resolve(),
|
|
91
|
-
view:
|
|
105
|
+
view: reloadCount && current.current?.key === key ? {
|
|
106
|
+
...current.current.view
|
|
107
|
+
} : initialView(),
|
|
92
108
|
controller,
|
|
93
109
|
reloading: false,
|
|
94
110
|
preflightReads: 0,
|
|
95
|
-
preflightLoading:
|
|
111
|
+
preflightLoading: true,
|
|
112
|
+
preflightFailures: current.current?.key === key ? current.current.preflightFailures : 0,
|
|
96
113
|
publish () {
|
|
97
114
|
if (controller.signal.aborted) return;
|
|
98
115
|
session.view.doc = session.view.loadState === 'ready' ? optimistic(session) : null;
|
|
@@ -109,49 +126,39 @@ function stage(session, partial) {
|
|
|
109
126
|
current.current = session;
|
|
110
127
|
const url = `${base}/xp-experiments/${encodeURIComponent(documentId)}?depth=0`;
|
|
111
128
|
let preflightRevision = 0;
|
|
112
|
-
async function refreshPreflight(initial = false) {
|
|
129
|
+
async function refreshPreflight(initial = false, supersede = false) {
|
|
113
130
|
if (controller.signal.aborted) return;
|
|
114
131
|
const revision = ++preflightRevision;
|
|
115
132
|
session.preflightLoading = true;
|
|
116
133
|
session.publish();
|
|
117
134
|
// createApi has no signal option; this read must abort without cancelling submitted PATCHes.
|
|
118
|
-
let
|
|
135
|
+
let body;
|
|
119
136
|
let status = 0;
|
|
120
|
-
let message = API_MESSAGES.network;
|
|
121
137
|
try {
|
|
122
|
-
const response = await fetch(`${base}/xp/experiments/${encodeURIComponent(documentId)}/preflight`, {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
138
|
+
const { response, body: answerBody } = await readPreflight((signal)=>observers.current.requestPreflight?.(signal, supersede || initial && reloadCount > 0) ?? fetch(`${base}/xp/experiments/${encodeURIComponent(documentId)}/preflight`, {
|
|
139
|
+
method: 'GET',
|
|
140
|
+
credentials: 'include',
|
|
141
|
+
cache: 'no-store',
|
|
142
|
+
signal
|
|
143
|
+
}), controller.signal);
|
|
127
144
|
status = response.status;
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
data = body;
|
|
131
|
-
message = API_MESSAGES.unreadable;
|
|
132
|
-
} else {
|
|
133
|
-
const envelope = body;
|
|
134
|
-
const error = Array.isArray(envelope?.errors) ? envelope.errors[0] : undefined;
|
|
135
|
-
message = refusalMessage(status === 501 ? 'not-implemented' : error?.code, status, typeof error?.message === 'string' ? error.message : undefined);
|
|
136
|
-
}
|
|
137
|
-
} catch {
|
|
138
|
-
message = API_MESSAGES.network;
|
|
139
|
-
}
|
|
145
|
+
body = answerBody;
|
|
146
|
+
} catch {}
|
|
140
147
|
if (controller.signal.aborted) return;
|
|
141
148
|
if (revision !== preflightRevision) return;
|
|
142
149
|
session.preflightLoading = false;
|
|
150
|
+
session.view.preflightRead = classifyReadinessRead(status, body, session.preflightFailures + 1);
|
|
151
|
+
session.preflightFailures = session.view.preflightRead.failed ? session.preflightFailures + 1 : 0;
|
|
152
|
+
const data = session.view.preflightRead.answer;
|
|
143
153
|
if (data) {
|
|
154
|
+
observers.current.onPreflight?.(data);
|
|
144
155
|
session.view.preflight = data;
|
|
145
156
|
session.view.preflightError = null;
|
|
146
157
|
if (initial) session.view.loadState = 'ready';
|
|
147
158
|
} else {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
...session.view.errors,
|
|
152
|
-
_section: message
|
|
153
|
-
};
|
|
154
|
-
} else session.view.preflightError = message;
|
|
159
|
+
session.view.preflight = null;
|
|
160
|
+
session.view.preflightError = session.view.preflightRead.message ?? null;
|
|
161
|
+
if (initial) session.view.loadState = session.view.preflightRead.loadState === 'error' ? 'ready' : session.view.preflightRead.loadState;
|
|
155
162
|
}
|
|
156
163
|
session.publish();
|
|
157
164
|
}
|
|
@@ -235,13 +242,17 @@ function stage(session, partial) {
|
|
|
235
242
|
...patch,
|
|
236
243
|
updatedAt: undefined
|
|
237
244
|
};
|
|
245
|
+
if (readable) observers.current.onDocument?.(doc);
|
|
238
246
|
saved = true;
|
|
239
247
|
// Keep readiness pending even while recovering an unreadable successful PATCH body.
|
|
240
248
|
session.preflightReads++;
|
|
241
249
|
session.publish();
|
|
242
250
|
session.view.errors = clearErrors(session.view.errors, patch);
|
|
243
251
|
delete session.view.errors._section;
|
|
244
|
-
if (!readable && !controller.signal.aborted)
|
|
252
|
+
if (!readable && !controller.signal.aborted) {
|
|
253
|
+
session.saved = await readDocument();
|
|
254
|
+
observers.current.onDocument?.(session.saved);
|
|
255
|
+
}
|
|
245
256
|
}
|
|
246
257
|
}
|
|
247
258
|
} catch (error) {
|
|
@@ -259,7 +270,7 @@ function stage(session, partial) {
|
|
|
259
270
|
if (saved) {
|
|
260
271
|
// Recovery is complete; readiness now belongs to the latest preflight read.
|
|
261
272
|
session.preflightReads--;
|
|
262
|
-
await refreshPreflight();
|
|
273
|
+
await refreshPreflight(false, true);
|
|
263
274
|
}
|
|
264
275
|
};
|
|
265
276
|
// Recover both the preceding tail and this step: unexpected throws must not strand later saves.
|
|
@@ -277,28 +288,38 @@ function stage(session, partial) {
|
|
|
277
288
|
commitRef.current = {
|
|
278
289
|
session,
|
|
279
290
|
commit,
|
|
280
|
-
refreshPreflight: ()=>refreshPreflight()
|
|
291
|
+
refreshPreflight: (supersede)=>refreshPreflight(false, supersede)
|
|
281
292
|
};
|
|
282
293
|
session.publish();
|
|
283
294
|
void (async ()=>{
|
|
284
295
|
try {
|
|
285
296
|
await waitForDrain(drainingSaves.get(key), controller.signal);
|
|
286
297
|
if (controller.signal.aborted) return;
|
|
287
|
-
const response = await fetch(url, {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
298
|
+
const { response, body } = await readPreflight((signal)=>fetch(url, {
|
|
299
|
+
method: 'GET',
|
|
300
|
+
credentials: 'include',
|
|
301
|
+
signal
|
|
302
|
+
}), controller.signal);
|
|
292
303
|
if (controller.signal.aborted) return;
|
|
293
304
|
if (!response.ok) {
|
|
294
|
-
session.
|
|
305
|
+
session.preflightLoading = false;
|
|
306
|
+
session.view.preflightRead = classifyReadinessRead(response.status, undefined, session.preflightFailures + 1, {
|
|
307
|
+
kind: 'document'
|
|
308
|
+
});
|
|
309
|
+
session.preflightFailures = session.view.preflightRead.failed ? session.preflightFailures + 1 : 0;
|
|
310
|
+
session.view.loadState = session.view.preflightRead.loadState;
|
|
295
311
|
session.publish();
|
|
296
312
|
return;
|
|
297
313
|
}
|
|
298
|
-
const doc =
|
|
314
|
+
const doc = body;
|
|
299
315
|
if (controller.signal.aborted) return;
|
|
300
|
-
if (doc.id == null || !doc.status) throw new Error(API_MESSAGES.unreadable);
|
|
316
|
+
if (!doc || doc.id == null || !doc.status) throw new Error(API_MESSAGES.unreadable);
|
|
301
317
|
session.saved = doc;
|
|
318
|
+
session.view.errors = {};
|
|
319
|
+
session.view.chosenPages = {};
|
|
320
|
+
session.view.stale = false;
|
|
321
|
+
session.view.saving = 'idle';
|
|
322
|
+
observers.current.onDocument?.(doc);
|
|
302
323
|
await refreshPreflight(true);
|
|
303
324
|
if (controller.signal.aborted) return;
|
|
304
325
|
session.publish();
|
|
@@ -314,6 +335,10 @@ function stage(session, partial) {
|
|
|
314
335
|
}
|
|
315
336
|
} catch {
|
|
316
337
|
if (controller.signal.aborted) return;
|
|
338
|
+
session.preflightLoading = false;
|
|
339
|
+
session.view.preflightRead = classifyReadinessRead(0, undefined, ++session.preflightFailures, {
|
|
340
|
+
kind: 'document'
|
|
341
|
+
});
|
|
317
342
|
session.view.loadState = 'error';
|
|
318
343
|
session.view.errors = {
|
|
319
344
|
_section: API_MESSAGES.unreadable
|
|
@@ -334,7 +359,8 @@ function stage(session, partial) {
|
|
|
334
359
|
key,
|
|
335
360
|
base,
|
|
336
361
|
documentId,
|
|
337
|
-
reloadCount
|
|
362
|
+
reloadCount,
|
|
363
|
+
enabled
|
|
338
364
|
]);
|
|
339
365
|
const stagePartial = useCallback((partial)=>{
|
|
340
366
|
const session = current.current;
|
|
@@ -358,12 +384,17 @@ function stage(session, partial) {
|
|
|
358
384
|
}, [
|
|
359
385
|
key
|
|
360
386
|
]);
|
|
361
|
-
const refreshPreflight = useCallback(()=>{
|
|
387
|
+
const refreshPreflight = useCallback((supersede = false)=>{
|
|
362
388
|
const entry = commitRef.current;
|
|
363
|
-
return entry?.session.key === key && entry.session.view.loadState === 'ready' && !entry.session.reloading ? entry.refreshPreflight() : Promise.resolve();
|
|
389
|
+
return entry?.session.key === key && entry.session.view.loadState === 'ready' && !entry.session.reloading ? entry.refreshPreflight(supersede) : Promise.resolve();
|
|
364
390
|
}, [
|
|
365
391
|
key
|
|
366
392
|
]);
|
|
393
|
+
const settledRead = state.key === key ? state.view.preflightRead : undefined;
|
|
394
|
+
useReadinessPolling(settledRead, ()=>{
|
|
395
|
+
if (state.view.loadState === 'ready') void refreshPreflight();
|
|
396
|
+
else void reload();
|
|
397
|
+
}, !requestPreflight || state.view.loadState === 'error', state.view.preflightPending);
|
|
367
398
|
useEffect(()=>{
|
|
368
399
|
if (!refetchPreflightOnFocus) return;
|
|
369
400
|
let lastReturn = -Infinity;
|
|
@@ -404,7 +435,22 @@ function stage(session, partial) {
|
|
|
404
435
|
key,
|
|
405
436
|
commit
|
|
406
437
|
]);
|
|
438
|
+
// Transition responses outlive this mount just like submitted PATCHes. Publish
|
|
439
|
+
// their authoritative document before attempting a mount-dependent reload.
|
|
440
|
+
const transitionActions = {
|
|
441
|
+
acceptTransition (result) {
|
|
442
|
+
const doc = result?.doc;
|
|
443
|
+
if (!doc || doc.id == null || !doc.status || !Array.isArray(doc.arms) || String(doc.id) !== documentId) return;
|
|
444
|
+
observers.current.onDocument?.(doc);
|
|
445
|
+
const session = current.current;
|
|
446
|
+
if (session?.key === key && !session.controller.signal.aborted) {
|
|
447
|
+
session.saved = doc;
|
|
448
|
+
session.publish();
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
};
|
|
407
452
|
return {
|
|
453
|
+
...transitionActions,
|
|
408
454
|
...state.key === key ? state.view : initialView(),
|
|
409
455
|
stage: stagePartial,
|
|
410
456
|
commit,
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ReadinessRead } from './readinessRead.js';
|
|
2
|
+
/** Non-shared reads use the same visible-only delay policy as editor cache reads. */
|
|
3
|
+
export declare function useReadinessPolling(read: ReadinessRead | undefined, refresh: () => void, enabled?: boolean, pending?: boolean): void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef } from 'react';
|
|
3
|
+
/** Non-shared reads use the same visible-only delay policy as editor cache reads. */ export function useReadinessPolling(read, refresh, enabled = true, pending = false) {
|
|
4
|
+
const action = useRef(refresh);
|
|
5
|
+
action.current = refresh;
|
|
6
|
+
useEffect(()=>{
|
|
7
|
+
if (!enabled || pending || !read?.pollDelay) return;
|
|
8
|
+
let timer;
|
|
9
|
+
const schedule = ()=>{
|
|
10
|
+
clearTimeout(timer);
|
|
11
|
+
if (document.visibilityState === 'visible') timer = setTimeout(()=>action.current(), read.pollDelay);
|
|
12
|
+
};
|
|
13
|
+
schedule();
|
|
14
|
+
document.addEventListener('visibilitychange', schedule);
|
|
15
|
+
return ()=>{
|
|
16
|
+
clearTimeout(timer);
|
|
17
|
+
document.removeEventListener('visibilitychange', schedule);
|
|
18
|
+
};
|
|
19
|
+
}, [
|
|
20
|
+
read,
|
|
21
|
+
enabled,
|
|
22
|
+
pending
|
|
23
|
+
]);
|
|
24
|
+
}
|
|
@@ -2,7 +2,7 @@ import { placementPathContent, placementTests } from '../db/placements.js';
|
|
|
2
2
|
import { lockPagePaths } from '../db/locks.js';
|
|
3
3
|
import { normalisePath } from '../runtime/normalisePath.js';
|
|
4
4
|
import { scanBlockPlacements } from './placements.js';
|
|
5
|
-
import { interactingTestsCopy } from '../
|
|
5
|
+
import { interactingTestsCopy } from '../testSurface/copy/readiness.js';
|
|
6
6
|
import { XpRefusal } from '../errors.js';
|
|
7
7
|
import { pageTargetPaths } from './checkStart.js';
|
|
8
8
|
export async function detached(req, fn) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PayloadRequest } from 'payload';
|
|
2
2
|
import type { Arm, DocId, FlagPoint, PreviewPlacement, ResolvedOptions } from '../types/contracts.js';
|
|
3
3
|
import type { ArmSlot } from '../types/puck.js';
|
|
4
|
+
import { type PlacementLocaleView } from '../blocks/placementLocale.js';
|
|
4
5
|
export interface BlockPlacement extends PreviewPlacement {
|
|
5
6
|
editor?: 'puck' | 'blocks' | 'page';
|
|
6
7
|
doc?: Record<string, unknown>;
|
|
@@ -11,20 +12,37 @@ export interface BlockPlacement extends PreviewPlacement {
|
|
|
11
12
|
localized?: boolean;
|
|
12
13
|
}
|
|
13
14
|
export type FlagPlacement = Awaited<ReturnType<NonNullable<FlagPoint['placements']>>>[number];
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
15
|
+
/** Internal page-guard overlay: simulate the pending write using the same scan as Start.
|
|
16
|
+
* Draft-only writes retain the published view. Publish/unpublish replace both views.
|
|
16
17
|
*/
|
|
17
|
-
export
|
|
18
|
-
|
|
18
|
+
export interface PlacementChange {
|
|
19
|
+
collection: string;
|
|
20
|
+
id: DocId;
|
|
21
|
+
draftOnly?: boolean;
|
|
22
|
+
doc?: Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
interface ScanOptions {
|
|
19
25
|
puckCollections: NonNullable<ResolvedOptions['puck']>['collections'];
|
|
20
26
|
blocksCollections: NonNullable<ResolvedOptions['blocks']>['collections'];
|
|
21
27
|
compareVersions?: boolean;
|
|
28
|
+
/** Hook reads must see every placement and must never invoke nested access checks (CORE-21). */
|
|
29
|
+
pageGuard?: true;
|
|
30
|
+
change?: PlacementChange;
|
|
31
|
+
}
|
|
32
|
+
/** Published rows only, one pass per collection across both editor registrations.
|
|
33
|
+
* The exclusion predicate reads live transaction claims after each awaited page.
|
|
34
|
+
*/
|
|
35
|
+
export declare function hasOtherPublishedBlockPlacement(req: PayloadRequest, options: ResolvedOptions, slug: string, excluded: (collection: string, id: DocId, view: PlacementLocaleView, doc: Record<string, unknown> & {
|
|
36
|
+
id: DocId;
|
|
37
|
+
}) => boolean): Promise<boolean>;
|
|
38
|
+
/** Each matching ExperimentSlot is checked separately, including multiple slots
|
|
39
|
+
* in one document: content elsewhere in the document cannot hide an empty slot.
|
|
40
|
+
*/
|
|
41
|
+
export declare function scanBlockPlacements(req: PayloadRequest, args: ScanOptions & {
|
|
42
|
+
slug: string;
|
|
22
43
|
}): Promise<BlockPlacement[]>;
|
|
23
|
-
export declare function scanBlockPlacements(req: PayloadRequest, args: {
|
|
44
|
+
export declare function scanBlockPlacements(req: PayloadRequest, args: ScanOptions & {
|
|
24
45
|
slugs: ReadonlySet<string>;
|
|
25
|
-
puckCollections: NonNullable<ResolvedOptions['puck']>['collections'];
|
|
26
|
-
blocksCollections: NonNullable<ResolvedOptions['blocks']>['collections'];
|
|
27
|
-
compareVersions?: boolean;
|
|
28
46
|
}): Promise<Map<string, BlockPlacement[]>>;
|
|
29
47
|
export declare function flagPlacements<TUser extends {
|
|
30
48
|
id: DocId;
|
|
@@ -33,3 +51,4 @@ export declare function flagPlacements<TUser extends {
|
|
|
33
51
|
flagPoint?: string | null;
|
|
34
52
|
arms: Arm[];
|
|
35
53
|
}, req: PayloadRequest): Promise<FlagPlacement[]>;
|
|
54
|
+
export {};
|
|
@@ -4,6 +4,8 @@ import { pageVersionContent } from '../db/pageContent.js';
|
|
|
4
4
|
import { comparableContent } from './pageVersions.js';
|
|
5
5
|
import { isDeepStrictEqual } from 'node:util';
|
|
6
6
|
import { hasLocalizedFields } from './contentFields.js';
|
|
7
|
+
import { localeRequest, placementLocaleContent, placementLocaleViews } from '../blocks/placementLocale.js';
|
|
8
|
+
import { placementSlugs } from '../blocks/bindings.js';
|
|
7
9
|
import { documentEditor, puckCollections as normalisePuckCollections } from '../options.js';
|
|
8
10
|
const slots = [
|
|
9
11
|
'control',
|
|
@@ -11,6 +13,75 @@ const slots = [
|
|
|
11
13
|
'variantB',
|
|
12
14
|
'variantC'
|
|
13
15
|
];
|
|
16
|
+
async function placementDocuments(req, query, guard) {
|
|
17
|
+
// §7.8 page guard: the hook must see test placements regardless of the editor's access.
|
|
18
|
+
if (guard) return req.payload.find({
|
|
19
|
+
...query,
|
|
20
|
+
req,
|
|
21
|
+
overrideAccess: true
|
|
22
|
+
});
|
|
23
|
+
return req.payload.find({
|
|
24
|
+
...query,
|
|
25
|
+
req,
|
|
26
|
+
overrideAccess: false
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function changedDocuments(docs, change, collection, draft, page, draftsEnabled) {
|
|
30
|
+
if (!change || change.collection !== collection || change.draftOnly && !draft) return docs;
|
|
31
|
+
const kept = docs.filter((doc)=>String(doc.id) !== String(change.id));
|
|
32
|
+
const doc = change.doc;
|
|
33
|
+
if (page === 1 && doc && (draft ? change.draftOnly || doc._status === 'draft' : !draftsEnabled || doc._status === 'published')) {
|
|
34
|
+
kept.push({
|
|
35
|
+
...doc,
|
|
36
|
+
id: change.id,
|
|
37
|
+
...change.draftOnly ? {
|
|
38
|
+
_status: 'draft'
|
|
39
|
+
} : {}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return kept;
|
|
43
|
+
}
|
|
44
|
+
/** Published rows only, one pass per collection across both editor registrations.
|
|
45
|
+
* The exclusion predicate reads live transaction claims after each awaited page.
|
|
46
|
+
*/ export async function hasOtherPublishedBlockPlacement(req, options, slug, excluded) {
|
|
47
|
+
const scanReq = req.payload.config.localization ? {
|
|
48
|
+
...req,
|
|
49
|
+
locale: 'all'
|
|
50
|
+
} : req;
|
|
51
|
+
const collections = new Set([
|
|
52
|
+
...normalisePuckCollections(options).map((entry)=>entry.slug),
|
|
53
|
+
...(options.blocks?.collections ?? []).map((entry)=>entry.slug)
|
|
54
|
+
]);
|
|
55
|
+
for (const collection of collections){
|
|
56
|
+
const drafts = req.payload.config.collections?.some((c)=>c.slug === collection && c.versions && c.versions.drafts);
|
|
57
|
+
let page = 1;
|
|
58
|
+
while(true){
|
|
59
|
+
const result = await placementDocuments(scanReq, {
|
|
60
|
+
collection,
|
|
61
|
+
overrideAccess: false,
|
|
62
|
+
limit: 100,
|
|
63
|
+
page,
|
|
64
|
+
depth: 0,
|
|
65
|
+
draft: false,
|
|
66
|
+
...req.payload.config.localization ? {
|
|
67
|
+
locale: 'all',
|
|
68
|
+
fallbackLocale: false
|
|
69
|
+
} : {},
|
|
70
|
+
...drafts ? {
|
|
71
|
+
where: {
|
|
72
|
+
_status: {
|
|
73
|
+
equals: 'published'
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
} : {}
|
|
77
|
+
}, true);
|
|
78
|
+
if (result.docs.some((doc)=>doc._status !== 'draft' && doc.deletedAt == null && placementLocaleViews(req, collection).some((view)=>placementSlugs(options, collection, placementLocaleContent(localeRequest(req, view), collection, doc)).includes(slug) && !excluded(collection, doc.id, view, doc)))) return true;
|
|
79
|
+
if (!result.hasNextPage) break;
|
|
80
|
+
page++;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
14
85
|
export async function scanBlockPlacements(req, args) {
|
|
15
86
|
const { puckCollections } = args;
|
|
16
87
|
const slugs = args.slugs ?? new Set([
|
|
@@ -38,7 +109,7 @@ export async function scanBlockPlacements(req, args) {
|
|
|
38
109
|
]){
|
|
39
110
|
let page = 1;
|
|
40
111
|
while(true){
|
|
41
|
-
const result = await req
|
|
112
|
+
const result = await placementDocuments(req, {
|
|
42
113
|
collection,
|
|
43
114
|
req,
|
|
44
115
|
overrideAccess: false,
|
|
@@ -54,8 +125,8 @@ export async function scanBlockPlacements(req, args) {
|
|
|
54
125
|
}
|
|
55
126
|
}
|
|
56
127
|
} : {}
|
|
57
|
-
});
|
|
58
|
-
for (const doc of result.docs){
|
|
128
|
+
}, args.pageGuard);
|
|
129
|
+
for (const doc of changedDocuments(result.docs, args.change, collection, draft, page, Boolean(draftsEnabled))){
|
|
59
130
|
if (!draft && doc._status === 'draft') continue;
|
|
60
131
|
if (draft && doc._status !== 'draft' && publishedIds.has(String(doc.id))) continue;
|
|
61
132
|
if (!draft) {
|
|
@@ -164,7 +235,7 @@ export async function scanBlockPlacements(req, args) {
|
|
|
164
235
|
]){
|
|
165
236
|
let page = 1;
|
|
166
237
|
while(true){
|
|
167
|
-
const result = await req
|
|
238
|
+
const result = await placementDocuments(req, {
|
|
168
239
|
collection,
|
|
169
240
|
req,
|
|
170
241
|
overrideAccess: false,
|
|
@@ -180,8 +251,8 @@ export async function scanBlockPlacements(req, args) {
|
|
|
180
251
|
}
|
|
181
252
|
}
|
|
182
253
|
} : {}
|
|
183
|
-
});
|
|
184
|
-
for (const doc of result.docs){
|
|
254
|
+
}, args.pageGuard);
|
|
255
|
+
for (const doc of changedDocuments(result.docs, args.change, collection, draft, page, Boolean(draftsEnabled))){
|
|
185
256
|
if (!draft && doc._status === 'draft') continue;
|
|
186
257
|
if (!draft) published.set(String(doc.id), doc);
|
|
187
258
|
else if (doc._status !== 'draft' && published.has(String(doc.id))) continue;
|
|
@@ -604,7 +604,7 @@ export async function preflightData(req, { experimentId, options }, { now = new
|
|
|
604
604
|
...input.goalContent ? {
|
|
605
605
|
goalNotes: input.metrics.filter((m)=>m.source.startsWith('click:') && input.goalContent && !input.goalContent.skipped && !input.goalContent.unchecked.length && !input.goalContent.keys.some((k)=>`click:${k.key}` === m.source)).map((m)=>({
|
|
606
606
|
metricId: m.id,
|
|
607
|
-
message: OUTSIDE_GOAL
|
|
607
|
+
message: OUTSIDE_GOAL(m.name, e.kind)
|
|
608
608
|
}))
|
|
609
609
|
} : {},
|
|
610
610
|
placements,
|