@delmaredigital/payload-experiments 0.4.0-rc.1 → 0.4.0-rc.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +284 -772
- package/dist/admin/LayerUsage.js +1 -1
- package/dist/admin/MetricSourceSelect.js +12 -5
- package/dist/admin/PlacementStatus.js +1 -1
- package/dist/admin/TestsDashboardCards.d.ts +1 -0
- package/dist/admin/TestsDashboardCards.js +5 -9
- package/dist/admin/TestsNavLink.d.ts +1 -0
- package/dist/admin/TestsNavLink.js +5 -11
- package/dist/admin/blocks/BlockPanel.d.ts +1 -0
- package/dist/admin/blocks/BlockPanel.js +129 -37
- package/dist/admin/blocks/TestBlockField.js +3 -3
- package/dist/admin/blocks/formApi.d.ts +3 -0
- package/dist/admin/blocks/formApi.js +10 -4
- package/dist/admin/blocks/inject.js +1 -0
- package/dist/admin/blocks/model.d.ts +3 -2
- package/dist/admin/blocks/model.js +10 -6
- package/dist/admin/blocks/statusCache.d.ts +2 -0
- package/dist/admin/blocks/statusCache.js +12 -3
- package/dist/admin/components/RootViewMessage.js +1 -1
- package/dist/admin/copy/blocks.d.ts +21 -1
- package/dist/admin/copy/blocks.js +40 -6
- package/dist/admin/copy/goals.d.ts +21 -9
- package/dist/admin/copy/goals.js +28 -11
- package/dist/admin/copy/newTest.d.ts +7 -7
- package/dist/admin/copy/newTest.js +10 -7
- package/dist/admin/goals/XpGoalField.d.ts +2 -0
- package/dist/admin/goals/XpGoalField.js +156 -114
- package/dist/admin/goals/xpGoalField.css +47 -0
- package/dist/admin/pageCollections.d.ts +1 -0
- package/dist/admin/pageCollections.js +3 -0
- package/dist/admin/paths.d.ts +3 -0
- package/dist/admin/paths.js +3 -0
- package/dist/admin/placementStatus.model.js +1 -1
- package/dist/admin/status.model.js +1 -1
- package/dist/admin/surface/ResultsRoute.d.ts +2 -1
- package/dist/admin/surface/ResultsRoute.js +20 -24
- package/dist/admin/surface/SurfaceShell.d.ts +4 -2
- package/dist/admin/surface/SurfaceShell.js +29 -4
- package/dist/admin/surface/TestRowMenu.d.ts +13 -0
- package/dist/admin/surface/TestRowMenu.js +163 -0
- package/dist/admin/surface/TestsHome.d.ts +5 -3
- package/dist/admin/surface/TestsHome.js +273 -58
- package/dist/admin/surface/TestsSurface.js +8 -7
- package/dist/admin/surface/goals/DeleteGoalDialog.d.ts +7 -0
- package/dist/admin/surface/goals/DeleteGoalDialog.js +42 -0
- package/dist/admin/surface/goals/GoalForm.d.ts +2 -1
- package/dist/admin/surface/goals/GoalForm.js +342 -212
- package/dist/admin/surface/goals/GoalsList.d.ts +1 -1
- package/dist/admin/surface/goals/GoalsList.js +107 -37
- package/dist/admin/surface/goals/data.d.ts +2 -0
- package/dist/admin/surface/goals/data.js +11 -2
- package/dist/admin/surface/goals/goals.css +9 -1
- package/dist/admin/surface/goals/goals.model.d.ts +12 -2
- package/dist/admin/surface/goals/goals.model.js +39 -1
- package/dist/admin/surface/home.model.d.ts +10 -8
- package/dist/admin/surface/home.model.js +27 -22
- package/dist/admin/surface/newTest/NewTest.d.ts +4 -4
- package/dist/admin/surface/newTest/NewTest.js +149 -118
- package/dist/admin/surface/newTest/PageWizard.d.ts +5 -2
- package/dist/admin/surface/newTest/PageWizard.js +115 -80
- package/dist/admin/surface/newTest/newTest.css +28 -9
- package/dist/admin/surface/results/ResultsHeader.d.ts +3 -3
- package/dist/admin/surface/results/ResultsHeader.js +115 -83
- package/dist/admin/surface/surface.css +29 -0
- package/dist/admin/surface/test/TestPage.d.ts +1 -2
- package/dist/admin/surface/test/TestPage.js +44 -152
- package/dist/admin/surface/useXpStepNav.d.ts +11 -0
- package/dist/admin/surface/useXpStepNav.js +14 -0
- package/dist/admin/theme.css +2 -0
- package/dist/admin/views/CollectionListRedirect.d.ts +1 -0
- package/dist/admin/views/CollectionListRedirect.js +1 -1
- package/dist/admin/views/ExperimentsRootView.js +18 -165
- package/dist/admin/views/GoalEditRedirect.d.ts +4 -0
- package/dist/admin/views/GoalEditRedirect.js +14 -0
- package/dist/admin/views/GoalsCollectionListView.d.ts +2 -0
- package/dist/admin/views/GoalsCollectionListView.js +4 -0
- package/dist/admin/views/TestsCollectionListView.d.ts +2 -0
- package/dist/admin/views/TestsCollectionListView.js +4 -0
- package/dist/admin/views/TestsNavLinkServer.d.ts +1 -0
- package/dist/admin/views/TestsNavLinkServer.js +2 -2
- package/dist/admin/views/TestsSurfaceClient.d.ts +3 -0
- package/dist/admin/views/TestsSurfaceClient.js +35 -0
- package/dist/admin/views/buildSurfaceProps.d.ts +8 -0
- package/dist/admin/views/buildSurfaceProps.js +102 -0
- package/dist/admin/views/renderCollectionList.d.ts +2 -0
- package/dist/admin/views/renderCollectionList.js +34 -0
- package/dist/admin/views/renderTestsSurface.d.ts +3 -0
- package/dist/admin/views/renderTestsSurface.js +34 -0
- package/dist/blocks/bindings.js +8 -14
- package/dist/blocks/createExperimentBlock.js +1 -1
- package/dist/blocks/formState.js +2 -2
- package/dist/blocks/placementLanguages.d.ts +7 -0
- package/dist/blocks/placementLanguages.js +27 -0
- package/dist/blocks/placementLocale.d.ts +37 -0
- package/dist/blocks/placementLocale.js +270 -0
- package/dist/collections/experiments/config.js +17 -8
- package/dist/collections/experiments/deleteGuard.js +2 -2
- package/dist/collections/experiments/lockHook.js +21 -2
- package/dist/collections/experiments/pickSlug.js +2 -0
- package/dist/collections/metrics.js +28 -9
- package/dist/collections/metricsGuards.js +2 -0
- package/dist/collections/serialize.js +8 -6
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/db/adapter.d.ts +9 -1
- package/dist/db/adapter.js +77 -1
- package/dist/db/appends.d.ts +13 -0
- package/dist/db/appends.js +49 -0
- package/dist/db/bulkPlacementRemoval.d.ts +30 -0
- package/dist/db/bulkPlacementRemoval.js +111 -0
- package/dist/db/delete.d.ts +1 -1
- package/dist/db/delete.js +2 -4
- package/dist/db/events.d.ts +9 -0
- package/dist/db/events.js +42 -8
- package/dist/db/executor.d.ts +7 -1
- package/dist/db/executor.js +7 -3
- package/dist/db/pageCopies.d.ts +5 -0
- package/dist/db/pageCopies.js +31 -0
- package/dist/db/placements.d.ts +2 -0
- package/dist/db/placements.js +8 -0
- package/dist/db/results.d.ts +5 -1
- package/dist/db/results.js +21 -5
- package/dist/db/snapshots.d.ts +2 -0
- package/dist/endpoints/contentLocale.d.ts +6 -0
- package/dist/endpoints/contentLocale.js +15 -0
- package/dist/endpoints/deleteImpact.d.ts +6 -0
- package/dist/endpoints/deleteImpact.js +207 -0
- package/dist/endpoints/duplicateOriginal.d.ts +38 -0
- package/dist/endpoints/duplicateOriginal.js +407 -0
- package/dist/endpoints/editorSurface.d.ts +3 -0
- package/dist/endpoints/editorSurface.js +31 -0
- package/dist/endpoints/events.js +103 -39
- package/dist/endpoints/index.js +57 -9
- package/dist/endpoints/pages.js +247 -64
- package/dist/endpoints/placementStatus.js +13 -5
- package/dist/endpoints/preflight.d.ts +1 -1
- package/dist/endpoints/preflight.js +17 -2
- package/dist/endpoints/results.d.ts +1 -1
- package/dist/endpoints/results.js +6 -2
- package/dist/endpoints/routeId.d.ts +2 -2
- package/dist/endpoints/routeId.js +11 -5
- package/dist/endpoints/summary.js +46 -12
- package/dist/endpoints/testVersion.d.ts +2 -0
- package/dist/endpoints/testVersion.js +38 -0
- package/dist/endpoints/transitions.js +41 -29
- package/dist/errors.d.ts +5 -0
- package/dist/errors.js +8 -0
- package/dist/events/request.d.ts +6 -2
- package/dist/events/request.js +35 -8
- package/dist/events/rows.d.ts +1 -1
- package/dist/events/rows.js +24 -8
- package/dist/events/writable.d.ts +9 -0
- package/dist/events/writable.js +13 -0
- package/dist/exports/adminClient.d.ts +1 -1
- package/dist/exports/adminClient.js +1 -1
- package/dist/exports/adminRsc.d.ts +3 -0
- package/dist/exports/adminRsc.js +3 -0
- package/dist/exports/index.d.ts +1 -1
- package/dist/exports/rsc.d.ts +1 -0
- package/dist/exports/rsc.js +1 -0
- package/dist/fields/xpGoal.js +3 -15
- package/dist/goals/fairness.d.ts +1 -1
- package/dist/goals/fairness.js +44 -35
- package/dist/goals/picker/clickGoalPicker.model.d.ts +8 -1
- package/dist/goals/picker/clickGoalPicker.model.js +20 -2
- package/dist/goals/picker/copy.d.ts +6 -2
- package/dist/goals/picker/copy.js +11 -2
- package/dist/goals/picker/useClickGoalPicker.d.ts +1 -1
- package/dist/goals/picker/useClickGoalPicker.js +4 -2
- package/dist/goals/sourceLabel.d.ts +2 -0
- package/dist/goals/sourceLabel.js +4 -0
- package/dist/goals/validate.d.ts +3 -0
- package/dist/goals/validate.js +15 -0
- package/dist/hooks/blockRemovalRule.d.ts +30 -0
- package/dist/hooks/blockRemovalRule.js +165 -0
- package/dist/hooks/hostHook.js +6 -2
- package/dist/hooks/pageGuard.d.ts +27 -2
- package/dist/hooks/pageGuard.js +213 -45
- package/dist/hooks/puckGoals.d.ts +5 -0
- package/dist/hooks/puckGoals.js +62 -0
- package/dist/hooks/puckNestedTests.d.ts +8 -0
- package/dist/hooks/puckNestedTests.js +36 -0
- package/dist/hooks/trackPageCopies.d.ts +11 -0
- package/dist/hooks/trackPageCopies.js +7 -0
- package/dist/lib/fetchAllDocs.d.ts +1 -1
- package/dist/lib/placementPages.d.ts +10 -0
- package/dist/{admin/previewLinks.model.js → lib/placementPages.js} +10 -5
- package/dist/manifest/compile.d.ts +2 -1
- package/dist/manifest/compile.js +13 -6
- package/dist/onInit.js +36 -0
- package/dist/options.d.ts +2 -0
- package/dist/options.js +23 -2
- package/dist/plugin.js +70 -21
- package/dist/proxy/pageNavigation.d.ts +4 -0
- package/dist/proxy/pageNavigation.js +28 -0
- package/dist/proxy/resolve.js +52 -25
- package/dist/puck/ExperimentPicker.d.ts +2 -1
- package/dist/puck/ExperimentPicker.js +62 -40
- package/dist/puck/ExperimentSlot.js +3 -1
- package/dist/puck/copy.d.ts +5 -1
- package/dist/puck/copy.js +5 -1
- package/dist/puck/editor/ConfigureTestDrawer.d.ts +25 -0
- package/dist/puck/editor/ConfigureTestDrawer.js +150 -0
- package/dist/puck/editor/CreateExperimentDrawer.d.ts +12 -2
- package/dist/puck/editor/CreateExperimentDrawer.js +89 -21
- package/dist/puck/editor/EditorControls.d.ts +14 -0
- package/dist/puck/editor/EditorControls.js +99 -0
- package/dist/puck/editor/ExperimentSlotEditor.d.ts +2 -1
- package/dist/puck/editor/ExperimentSlotEditor.js +1007 -182
- package/dist/puck/editor/LeftoverVersions.d.ts +15 -0
- package/dist/puck/editor/LeftoverVersions.js +79 -0
- package/dist/puck/editor/PlacementNotice.d.ts +8 -0
- package/dist/puck/editor/PlacementNotice.js +22 -0
- package/dist/puck/editor/QuickTestActions.d.ts +6 -0
- package/dist/puck/editor/QuickTestActions.js +72 -0
- package/dist/puck/editor/ResultsReadout.d.ts +4 -1
- package/dist/puck/editor/ResultsReadout.js +35 -19
- package/dist/puck/editor/VersionBuilder.d.ts +67 -12
- package/dist/puck/editor/VersionBuilder.js +560 -231
- package/dist/puck/editor/armWrites.d.ts +11 -2
- package/dist/puck/editor/armWrites.js +43 -4
- package/dist/puck/editor/armsCache.d.ts +3 -1
- package/dist/puck/editor/armsCache.js +20 -4
- package/dist/puck/editor/blockClipboard.d.ts +16 -0
- package/dist/puck/editor/blockClipboard.js +20 -0
- package/dist/puck/editor/cloneSlot.d.ts +2 -0
- package/dist/puck/editor/cloneSlot.js +7 -0
- package/dist/puck/editor/copy.d.ts +65 -20
- package/dist/puck/editor/copy.js +73 -21
- package/dist/puck/editor/createTest.d.ts +3 -0
- package/dist/puck/editor/createTest.js +33 -0
- package/dist/puck/editor/editor.chrome.css +200 -20
- package/dist/puck/editor/editor.css +338 -25
- package/dist/puck/editor/editor.model.d.ts +17 -1
- package/dist/puck/editor/editor.model.js +61 -4
- package/dist/puck/editor/editorSurface.d.ts +10 -0
- package/dist/puck/editor/editorSurface.js +65 -0
- package/dist/puck/editor/experimentOutlinePlugin.js +96 -28
- package/dist/puck/editor/localPlacements.d.ts +5 -0
- package/dist/puck/editor/localPlacements.js +43 -0
- package/dist/puck/editor/outlineVersion.d.ts +5 -0
- package/dist/puck/editor/outlineVersion.js +36 -0
- package/dist/puck/editor/placementsCache.d.ts +60 -0
- package/dist/puck/editor/placementsCache.js +263 -0
- package/dist/puck/editor/sidebar.d.ts +8 -0
- package/dist/puck/editor/sidebar.js +74 -0
- package/dist/puck/editor/usePageSaveReadiness.d.ts +6 -0
- package/dist/puck/editor/usePageSaveReadiness.js +31 -0
- package/dist/puck/editor/usePlacementNotice.d.ts +3 -0
- package/dist/puck/editor/usePlacementNotice.js +15 -0
- package/dist/puck/editor/xpGoalPuckEditorField.js +105 -86
- package/dist/puck/experimentSlotField.d.ts +3 -0
- package/dist/puck/experimentSlotField.js +15 -4
- package/dist/puck/experimentSlug.d.ts +2 -0
- package/dist/puck/experimentSlug.js +3 -0
- package/dist/puck/nestedTestCopy.d.ts +8 -0
- package/dist/puck/nestedTestCopy.js +22 -0
- package/dist/puck/nestedTests.d.ts +17 -0
- package/dist/puck/nestedTests.js +30 -0
- package/dist/puck/slotConfig.d.ts +2 -2
- package/dist/puck/slotConfig.js +18 -5
- package/dist/puck/visibility.d.ts +20 -0
- package/dist/puck/visibility.js +81 -0
- package/dist/results/aggregate.d.ts +6 -3
- package/dist/results/aggregate.js +9 -9
- package/dist/results/analyse.d.ts +2 -0
- package/dist/results/analyse.js +2 -2
- package/dist/results/health.d.ts +8 -0
- package/dist/results/health.js +28 -0
- package/dist/results/identityCredit.d.ts +1 -0
- package/dist/results/identityCredit.js +4 -1
- package/dist/results/verdict.d.ts +1 -1
- package/dist/results/verdict.js +9 -7
- package/dist/runtime/cookie.d.ts +10 -2
- package/dist/runtime/cookie.js +38 -6
- package/dist/runtime/cookieOptions.d.ts +6 -0
- package/dist/runtime/cookieOptions.js +14 -0
- package/dist/runtime/proxyRuntime.d.ts +1 -0
- package/dist/runtime/proxyRuntime.js +18 -8
- package/dist/runtime/signing.d.ts +1 -0
- package/dist/runtime/signing.js +5 -0
- package/dist/sanitizeReadinessDetail.d.ts +2 -2
- package/dist/sanitizeReadinessDetail.js +22 -2
- package/dist/server/getAssignments.js +11 -10
- package/dist/server/recordContentChange.d.ts +1 -1
- package/dist/server/recordContentChange.js +48 -22
- package/dist/server/resolveExperimentBlocks.js +2 -4
- package/dist/server/resolveExperimentData.js +8 -8
- package/dist/server/runResults.js +54 -15
- package/dist/server/startExperiment.d.ts +20 -0
- package/dist/server/startExperiment.js +70 -0
- package/dist/server/trackConversion.js +10 -13
- package/dist/{admin → testSurface}/PreviewLinks.d.ts +2 -1
- package/dist/{admin → testSurface}/PreviewLinks.js +9 -5
- package/dist/testSurface/actions/DecideDialog.d.ts +17 -0
- package/dist/testSurface/actions/DecideDialog.js +222 -0
- package/dist/testSurface/actions/LifecycleAction.d.ts +17 -0
- package/dist/testSurface/actions/LifecycleAction.js +107 -0
- package/dist/{admin → testSurface}/actions/MakeContentResult.d.ts +4 -3
- package/dist/{admin → testSurface}/actions/MakeContentResult.js +10 -2
- package/dist/{admin → testSurface}/actions/actions.model.d.ts +13 -5
- package/dist/testSurface/actions/actions.model.js +123 -0
- package/dist/{admin → testSurface}/actions/decide.model.d.ts +1 -0
- package/dist/{admin → testSurface}/actions/decide.model.js +1 -0
- package/dist/{admin → testSurface}/allocation.model.js +6 -3
- package/dist/{admin → testSurface}/api.d.ts +20 -7
- package/dist/{admin → testSurface}/api.js +72 -22
- package/dist/testSurface/contentLocaleURL.d.ts +2 -0
- package/dist/testSurface/contentLocaleURL.js +3 -0
- package/dist/{admin → testSurface}/copy/actions.d.ts +37 -14
- package/dist/{admin → testSurface}/copy/actions.js +40 -17
- package/dist/{admin → testSurface}/copy/advanced.d.ts +10 -0
- package/dist/{admin → testSurface}/copy/advanced.js +10 -0
- package/dist/{admin → testSurface}/copy/arms.d.ts +1 -1
- package/dist/{admin → testSurface}/copy/arms.js +1 -1
- package/dist/{admin → testSurface}/copy/audience.d.ts +4 -3
- package/dist/{admin → testSurface}/copy/audience.js +5 -4
- package/dist/{admin → testSurface}/copy/common.d.ts +15 -6
- package/dist/{admin → testSurface}/copy/common.js +20 -10
- package/dist/testSurface/copy/languages.d.ts +12 -0
- package/dist/testSurface/copy/languages.js +8 -0
- package/dist/{admin → testSurface}/copy/metrics.d.ts +7 -0
- package/dist/testSurface/copy/metrics.js +18 -0
- package/dist/testSurface/copy/pages.d.ts +84 -0
- package/dist/testSurface/copy/pages.js +90 -0
- package/dist/{admin → testSurface}/copy/readiness.d.ts +40 -6
- package/dist/{admin → testSurface}/copy/readiness.js +54 -9
- package/dist/{admin → testSurface}/copy/recommendation.d.ts +4 -4
- package/dist/{admin → testSurface}/copy/recommendation.js +4 -4
- package/dist/{admin → testSurface}/copy/results.d.ts +19 -12
- package/dist/{admin → testSurface}/copy/results.js +21 -12
- package/dist/testSurface/copy/review.d.ts +20 -0
- package/dist/testSurface/copy/review.js +21 -0
- package/dist/{admin → testSurface}/copy/setting.d.ts +1 -2
- package/dist/{admin → testSurface}/copy/setting.js +1 -2
- package/dist/{admin → testSurface}/copy/surface.d.ts +11 -2
- package/dist/{admin → testSurface}/copy/surface.js +14 -11
- package/dist/{admin → testSurface}/copy/testPage.d.ts +61 -12
- package/dist/testSurface/copy/testPage.js +168 -0
- package/dist/testSurface/format/adminURL.d.ts +7 -0
- package/dist/testSurface/format/adminURL.js +9 -0
- package/dist/{admin → testSurface}/format/date.d.ts +1 -0
- package/dist/testSurface/format/date.js +21 -0
- package/dist/{admin → testSurface}/labels.d.ts +1 -2
- package/dist/{admin → testSurface}/labels.js +2 -3
- package/dist/{admin → testSurface}/lockedNotice.model.d.ts +2 -0
- package/dist/{admin → testSurface}/lockedNotice.model.js +31 -0
- package/dist/testSurface/placementLabel.d.ts +8 -0
- package/dist/testSurface/placementLabel.js +24 -0
- package/dist/{admin → testSurface}/placements/placementLabels.d.ts +2 -0
- package/dist/{admin → testSurface}/placements/placementLabels.js +3 -2
- package/dist/{admin → testSurface}/previewLinks.model.d.ts +1 -6
- package/dist/testSurface/previewLinks.model.js +4 -0
- package/dist/testSurface/readPreflight.d.ts +13 -0
- package/dist/testSurface/readPreflight.js +44 -0
- package/dist/testSurface/readinessRead.d.ts +53 -0
- package/dist/testSurface/readinessRead.js +50 -0
- package/dist/{admin → testSurface}/results/VerdictHero.d.ts +2 -1
- package/dist/{admin → testSurface}/results/VerdictHero.js +5 -1
- package/dist/testSurface/results/results.css +64 -0
- package/dist/{admin → testSurface}/results/results.model.d.ts +3 -2
- package/dist/{admin → testSurface}/results/results.model.js +16 -11
- package/dist/{admin → testSurface}/surface/contracts.d.ts +17 -3
- package/dist/testSurface/surface/editorPlacement.d.ts +26 -0
- package/dist/testSurface/surface/editorPlacement.js +78 -0
- package/dist/testSurface/surface/pageBlock/pageBlock.model.js +9 -0
- package/dist/testSurface/surface/pageBlock/parts.js +107 -0
- package/dist/testSurface/surface/pagePicker/CopyRoute.d.ts +13 -0
- package/dist/testSurface/surface/pagePicker/CopyRoute.js +273 -0
- package/dist/testSurface/surface/pagePicker/PageCombobox.d.ts +21 -0
- package/dist/testSurface/surface/pagePicker/PageCombobox.js +498 -0
- package/dist/testSurface/surface/pagePicker/pagePicker.css +73 -0
- package/dist/{admin → testSurface}/surface/pagePicker/pagePicker.model.d.ts +7 -3
- package/dist/{admin → testSurface}/surface/pagePicker/pagePicker.model.js +17 -2
- package/dist/{admin → testSurface}/surface/readiness/ActionDialogs.d.ts +9 -5
- package/dist/testSurface/surface/readiness/ActionDialogs.js +372 -0
- package/dist/{admin → testSurface}/surface/readiness/Banner.d.ts +4 -3
- package/dist/testSurface/surface/readiness/Banner.js +198 -0
- package/dist/testSurface/surface/readiness/BlockerList.d.ts +11 -0
- package/dist/testSurface/surface/readiness/BlockerList.js +31 -0
- package/dist/testSurface/surface/readiness/SaveStatus.d.ts +13 -0
- package/dist/testSurface/surface/readiness/SaveStatus.js +67 -0
- package/dist/{admin → testSurface}/surface/readiness/parts.js +0 -2
- package/dist/{admin → testSurface}/surface/readiness/readiness.model.d.ts +28 -2
- package/dist/testSurface/surface/readiness/readiness.model.js +377 -0
- package/dist/testSurface/surface/readiness/useTransition.d.ts +16 -0
- package/dist/testSurface/surface/readiness/useTransition.js +141 -0
- package/dist/{admin → testSurface}/surface/results/ReleasePages.d.ts +6 -3
- package/dist/{admin → testSurface}/surface/results/ReleasePages.js +40 -40
- package/dist/{admin → testSurface}/surface/results/ResultsBody.d.ts +11 -4
- package/dist/{admin → testSurface}/surface/results/ResultsBody.js +207 -104
- package/dist/{admin → testSurface}/surface/results/recommendation.model.js +3 -3
- package/dist/{admin → testSurface}/surface/results/useResults.d.ts +26 -8
- package/dist/{admin → testSurface}/surface/results/useResults.js +3 -2
- package/dist/{admin → testSurface}/surface/setting/parts.js +89 -46
- package/dist/testSurface/surface/setting/setting.css +18 -0
- package/dist/{admin → testSurface}/surface/test/AdvancedSection.js +12 -4
- package/dist/testSurface/surface/test/DeleteTest.d.ts +23 -0
- package/dist/testSurface/surface/test/DeleteTest.js +270 -0
- package/dist/testSurface/surface/test/GoalSection.d.ts +4 -0
- package/dist/{admin → testSurface}/surface/test/GoalSection.js +119 -89
- package/dist/testSurface/surface/test/LengthSection.d.ts +2 -0
- package/dist/{admin → testSurface}/surface/test/LengthSection.js +25 -14
- package/dist/{admin → testSurface}/surface/test/PageHoldout.d.ts +1 -1
- package/dist/{admin → testSurface}/surface/test/PageHoldout.js +11 -8
- package/dist/{admin → testSurface}/surface/test/Rail.js +7 -4
- package/dist/{admin → testSurface}/surface/test/ReadinessBar.d.ts +2 -1
- package/dist/{admin → testSurface}/surface/test/ReadinessBar.js +4 -11
- package/dist/{admin → testSurface}/surface/test/Section.d.ts +3 -1
- package/dist/testSurface/surface/test/Section.js +88 -0
- package/dist/{admin → testSurface}/surface/test/TargetingSection.js +87 -12
- package/dist/testSurface/surface/test/TestSurface.d.ts +19 -0
- package/dist/testSurface/surface/test/TestSurface.js +265 -0
- package/dist/testSurface/surface/test/VersionsSection.d.ts +5 -0
- package/dist/testSurface/surface/test/VersionsSection.js +301 -0
- package/dist/{admin → testSurface}/surface/test/fields.d.ts +33 -9
- package/dist/testSurface/surface/test/fields.js +300 -0
- package/dist/{admin → testSurface}/surface/test/pageParts.js +30 -44
- package/dist/testSurface/surface/test/testPage.css +111 -0
- package/dist/{admin → testSurface}/surface/test/testPage.model.d.ts +1 -0
- package/dist/{admin → testSurface}/surface/test/testPage.model.js +6 -0
- package/dist/{admin → testSurface}/surface/testDocument.model.d.ts +3 -0
- package/dist/{admin → testSurface}/surface/testDocument.model.js +4 -1
- package/dist/testSurface/surface/useTestDocument.d.ts +60 -0
- package/dist/testSurface/surface/useTestDocument.js +782 -0
- package/dist/testSurface/surface/watchTestDocument.d.ts +15 -0
- package/dist/testSurface/surface/watchTestDocument.js +181 -0
- package/dist/testSurface/surfaceUrls.d.ts +8 -0
- package/dist/testSurface/surfaceUrls.js +23 -0
- package/dist/{admin → testSurface}/useApi.d.ts +21 -5
- package/dist/testSurface/useOnTestReturn.d.ts +2 -0
- package/dist/testSurface/useOnTestReturn.js +27 -0
- package/dist/testSurface/useReadinessPolling.d.ts +3 -0
- package/dist/testSurface/useReadinessPolling.js +26 -0
- package/dist/transitions/addMetric.d.ts +2 -5
- package/dist/transitions/addMetric.js +5 -1
- package/dist/transitions/allocate.d.ts +2 -2
- package/dist/transitions/allocate.js +3 -1
- package/dist/transitions/archive.d.ts +1 -1
- package/dist/transitions/archive.js +3 -2
- package/dist/transitions/checkStart.d.ts +6 -1
- package/dist/transitions/checkStart.js +133 -17
- package/dist/transitions/contentFields.js +9 -5
- package/dist/transitions/decide.d.ts +1 -1
- package/dist/transitions/decide.js +6 -3
- package/dist/transitions/deleteExperiment.d.ts +2 -2
- package/dist/transitions/deleteExperiment.js +17 -7
- package/dist/transitions/kernel.d.ts +4 -0
- package/dist/transitions/kernel.js +9 -4
- package/dist/transitions/makeContent.d.ts +2 -1
- package/dist/transitions/makeContent.js +41 -17
- package/dist/transitions/nestedPlacementNames.d.ts +5 -0
- package/dist/transitions/nestedPlacementNames.js +32 -0
- package/dist/transitions/pageAddress.d.ts +6 -0
- package/dist/transitions/pageAddress.js +71 -0
- package/dist/transitions/pageVersions.js +3 -1
- package/dist/transitions/phaseRecord.d.ts +2 -0
- package/dist/transitions/phaseRecord.js +5 -0
- package/dist/transitions/placementInteractions.d.ts +3 -3
- package/dist/transitions/placementInteractions.js +16 -12
- package/dist/transitions/placements.d.ts +54 -8
- package/dist/transitions/placements.js +304 -81
- package/dist/transitions/preflightData.d.ts +5 -3
- package/dist/transitions/preflightData.js +137 -40
- package/dist/transitions/releaseHoldout.d.ts +2 -1
- package/dist/transitions/releaseHoldout.js +3 -1
- package/dist/transitions/releasePages.d.ts +2 -1
- package/dist/transitions/releasePages.js +3 -1
- package/dist/transitions/resolveCaps.d.ts +2 -4
- package/dist/transitions/start.d.ts +6 -8
- package/dist/transitions/start.js +72 -35
- package/dist/transitions/startReads.d.ts +7 -0
- package/dist/transitions/startReads.js +28 -0
- package/dist/transitions/stop.d.ts +2 -1
- package/dist/transitions/stop.js +3 -2
- package/dist/types/contracts.d.ts +15 -3
- package/dist/types/endpoints.d.ts +121 -17
- package/dist/types/puck.d.ts +1 -0
- package/dist/types/runtime.d.ts +15 -9
- package/dist/types/snapshot.d.ts +2 -0
- package/dist/types/surface.d.ts +9 -9
- package/dist/ui/Button.js +2 -2
- package/dist/ui/Card.d.ts +2 -1
- package/dist/ui/Card.js +4 -4
- package/dist/ui/ChipsInput.d.ts +8 -1
- package/dist/ui/ChipsInput.js +17 -4
- package/dist/ui/Dialog.d.ts +24 -2
- package/dist/ui/Dialog.js +141 -6
- package/dist/ui/Drawer.d.ts +10 -0
- package/dist/ui/Drawer.js +29 -0
- package/dist/ui/Inputs.d.ts +4 -3
- package/dist/ui/Inputs.js +6 -4
- package/dist/ui/SelectControl.d.ts +33 -0
- package/dist/ui/SelectControl.js +504 -0
- package/dist/ui/Tabs.d.ts +4 -4
- package/dist/ui/Tabs.js +35 -32
- package/dist/ui/ui.css +50 -5
- package/package.json +3 -2
- package/dist/admin/actions/ConfirmDialog.d.ts +0 -19
- package/dist/admin/actions/ConfirmDialog.js +0 -149
- package/dist/admin/actions/DecideDialog.d.ts +0 -10
- package/dist/admin/actions/DecideDialog.js +0 -190
- package/dist/admin/actions/actions.model.js +0 -70
- package/dist/admin/copy/metrics.js +0 -9
- package/dist/admin/copy/pages.d.ts +0 -26
- package/dist/admin/copy/pages.js +0 -26
- package/dist/admin/copy/review.d.ts +0 -17
- package/dist/admin/copy/review.js +0 -17
- package/dist/admin/copy/testPage.js +0 -104
- package/dist/admin/format/date.js +0 -10
- package/dist/admin/results/results.css +0 -64
- package/dist/admin/styles.css +0 -10
- package/dist/admin/styles.d.ts +0 -2
- package/dist/admin/styles.js +0 -3
- package/dist/admin/surface/pageBlock/pageBlock.model.js +0 -8
- package/dist/admin/surface/pageBlock/parts.js +0 -69
- package/dist/admin/surface/pagePicker/CopyRoute.d.ts +0 -6
- package/dist/admin/surface/pagePicker/CopyRoute.js +0 -53
- package/dist/admin/surface/pagePicker/PagePicker.d.ts +0 -10
- package/dist/admin/surface/pagePicker/PagePicker.js +0 -172
- package/dist/admin/surface/readiness/ActionDialogs.js +0 -337
- package/dist/admin/surface/readiness/Banner.js +0 -190
- package/dist/admin/surface/readiness/SaveStatus.d.ts +0 -5
- package/dist/admin/surface/readiness/SaveStatus.js +0 -53
- package/dist/admin/surface/readiness/readiness.model.js +0 -205
- package/dist/admin/surface/readiness/useTransition.d.ts +0 -11
- package/dist/admin/surface/readiness/useTransition.js +0 -35
- package/dist/admin/surface/setting/setting.css +0 -17
- package/dist/admin/surface/test/GoalSection.d.ts +0 -2
- package/dist/admin/surface/test/LengthSection.d.ts +0 -2
- package/dist/admin/surface/test/Section.js +0 -47
- package/dist/admin/surface/test/VersionsSection.d.ts +0 -4
- package/dist/admin/surface/test/VersionsSection.js +0 -247
- package/dist/admin/surface/test/fields.js +0 -216
- package/dist/admin/surface/test/testPage.css +0 -97
- package/dist/admin/surface/useTestDocument.d.ts +0 -32
- package/dist/admin/surface/useTestDocument.js +0 -415
- /package/dist/{admin → testSurface}/allocation.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/arms/arms.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/arms/arms.model.js +0 -0
- /package/dist/{admin → testSurface}/arms/pageTarget.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/arms/pageTarget.model.js +0 -0
- /package/dist/{admin → testSurface}/arms/params.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/arms/params.model.js +0 -0
- /package/dist/{admin → testSurface}/metricSource.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/metricSource.model.js +0 -0
- /package/dist/{admin → testSurface}/placements/placementLabels.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/placements/placementLabels.model.js +0 -0
- /package/dist/{admin → testSurface}/placements/usePlacementLabels.d.ts +0 -0
- /package/dist/{admin → testSurface}/placements/usePlacementLabels.js +0 -0
- /package/dist/{admin → testSurface}/reload.d.ts +0 -0
- /package/dist/{admin → testSurface}/reload.js +0 -0
- /package/dist/{admin → testSurface}/results/CappedCell.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/CappedCell.js +0 -0
- /package/dist/{admin → testSurface}/results/CiChart.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/CiChart.js +0 -0
- /package/dist/{admin → testSurface}/results/DataQualityPanel.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/DataQualityPanel.js +0 -0
- /package/dist/{admin → testSurface}/results/DataTable.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/DataTable.js +0 -0
- /package/dist/{admin → testSurface}/results/StatTile.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/StatTile.js +0 -0
- /package/dist/{admin → testSurface}/results/chart.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/chart.model.js +0 -0
- /package/dist/{admin → testSurface}/results/format.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/format.js +0 -0
- /package/dist/{admin → testSurface}/results/legacy.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/legacy.js +0 -0
- /package/dist/{admin → testSurface}/results/releasePages.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/releasePages.model.js +0 -0
- /package/dist/{admin → testSurface}/results/snapshot.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/snapshot.js +0 -0
- /package/dist/{admin → testSurface}/review/review.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/review/review.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/contracts.js +0 -0
- /package/dist/{admin → testSurface}/surface/pageBlock/pageBlock.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/pageBlock/parts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/parts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/results/recommendation.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/setting/parts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/setting/setting.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/setting/setting.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/AdvancedSection.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/Rail.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/TargetingSection.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/jumpToSection.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/jumpToSection.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/pageParts.d.ts +0 -0
- /package/dist/{admin → testSurface}/targeting/targeting.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/targeting/targeting.model.js +0 -0
- /package/dist/{admin → testSurface}/theme.d.ts +0 -0
- /package/dist/{admin → testSurface}/theme.js +0 -0
- /package/dist/{admin → testSurface}/useApi.js +0 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { placementLanguageNames } from '../../blocks/placementLanguages.js';
|
|
2
|
+
import { serializeAttributeKeys, serializeFlagPoints, serializeMetricSources } from '../../collections/serialize.js';
|
|
3
|
+
import { serializePageCollections } from '../pageCollections.js';
|
|
4
|
+
import { collectionLabel as resolveLabel } from '../../collections/labels.js';
|
|
5
|
+
import { blockPageSlugs, puckCollections } from '../../options.js';
|
|
6
|
+
import { xpOptionsFromReq } from '../../options/fromReq.js';
|
|
7
|
+
import { routeAccess } from './access.model.js';
|
|
8
|
+
export async function buildSurfaceProps({ req, route, id, searchParams }) {
|
|
9
|
+
if (!req.user) return null;
|
|
10
|
+
const adminRoute = req.payload.config.routes.admin;
|
|
11
|
+
const options = xpOptionsFromReq(req);
|
|
12
|
+
async function permits(access) {
|
|
13
|
+
try {
|
|
14
|
+
return await access({
|
|
15
|
+
req
|
|
16
|
+
}) === true;
|
|
17
|
+
} catch {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const canManage = await permits(options.access.manage);
|
|
22
|
+
const isAdmin = options.access.admin ? await permits(options.access.admin) : false;
|
|
23
|
+
const canReadResults = options.access.readResults ? await permits(options.access.readResults) : canManage;
|
|
24
|
+
if (routeAccess({
|
|
25
|
+
route,
|
|
26
|
+
hasUser: true,
|
|
27
|
+
canManage,
|
|
28
|
+
canReadResults
|
|
29
|
+
}) !== 'ok') {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
const flagPoints = serializeFlagPoints(options);
|
|
33
|
+
// xp-state is manager-readable only. Results-only readers do not edit settings.
|
|
34
|
+
if (canManage && flagPoints.length) {
|
|
35
|
+
const state = await req.payload.findGlobal({
|
|
36
|
+
slug: 'xp-state',
|
|
37
|
+
req,
|
|
38
|
+
overrideAccess: false,
|
|
39
|
+
depth: 0
|
|
40
|
+
});
|
|
41
|
+
const defaults = state.flagDefaults;
|
|
42
|
+
for (const point of flagPoints)point.effectiveDefaults = defaults?.[point.id]?.params ?? point.defaultParams;
|
|
43
|
+
}
|
|
44
|
+
const blockPageCollections = route === 'new' && canManage ? blockPageSlugs(options).map((slug)=>{
|
|
45
|
+
const config = req.payload.config.collections.find((item)=>item.slug === slug);
|
|
46
|
+
const block = options.blocks?.collections.find((entry)=>entry.slug === slug);
|
|
47
|
+
const puck = options.puck?.enabled && puckCollections(options).some((entry)=>entry.slug === slug);
|
|
48
|
+
const editors = block ? [
|
|
49
|
+
'blocks'
|
|
50
|
+
] : [];
|
|
51
|
+
if (puck && (!block || block.appliesTo)) editors.push('puck');
|
|
52
|
+
return {
|
|
53
|
+
slug,
|
|
54
|
+
label: resolveLabel(config?.labels.plural, slug, req),
|
|
55
|
+
editors
|
|
56
|
+
};
|
|
57
|
+
}) : [];
|
|
58
|
+
const descriptions = options.admin?.descriptions;
|
|
59
|
+
const returnToTest = (await searchParams)?.return;
|
|
60
|
+
return {
|
|
61
|
+
...typeof returnToTest === 'string' && /^[\w-]+$/.test(returnToTest) ? {
|
|
62
|
+
returnToTest
|
|
63
|
+
} : {},
|
|
64
|
+
route,
|
|
65
|
+
...id === undefined ? {} : {
|
|
66
|
+
id
|
|
67
|
+
},
|
|
68
|
+
adminRoute,
|
|
69
|
+
apiRoute: req.payload.config.routes.api,
|
|
70
|
+
...req.payload.config.localization ? {
|
|
71
|
+
contentLanguageLabels: placementLanguageNames(req, req.payload.config.localization.localeCodes)
|
|
72
|
+
} : {},
|
|
73
|
+
canManage,
|
|
74
|
+
canReadResults,
|
|
75
|
+
isAdmin,
|
|
76
|
+
flagPoints,
|
|
77
|
+
...blockPageCollections.length ? {
|
|
78
|
+
blockPageCollections
|
|
79
|
+
} : {},
|
|
80
|
+
pageCollections: serializePageCollections(options.pages?.collections ?? [], req),
|
|
81
|
+
collectionTitles: Object.fromEntries(req.payload.config.collections.flatMap((collection)=>{
|
|
82
|
+
const title = collection.admin.useAsTitle;
|
|
83
|
+
return title && title !== 'id' ? [
|
|
84
|
+
[
|
|
85
|
+
collection.slug,
|
|
86
|
+
title
|
|
87
|
+
]
|
|
88
|
+
] : [];
|
|
89
|
+
})),
|
|
90
|
+
userId: req.user.id,
|
|
91
|
+
userCollection: req.payload.config.admin.user,
|
|
92
|
+
attributeKeys: serializeAttributeKeys(options),
|
|
93
|
+
metricSources: serializeMetricSources(options),
|
|
94
|
+
...descriptions ? {
|
|
95
|
+
admin: {
|
|
96
|
+
descriptions: {
|
|
97
|
+
...descriptions
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
} : {}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { ListViewServerProps } from 'payload';
|
|
2
|
+
export declare function renderCollectionList({ payload, searchParams }: ListViewServerProps, route: 'home' | 'goals'): Promise<string | number | bigint | boolean | Iterable<import("react").ReactNode> | import("react").JSX.Element | null | undefined>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createLocalReq } from 'payload';
|
|
2
|
+
import { formatAdminURL } from 'payload/shared';
|
|
3
|
+
import { headers } from 'next/headers.js';
|
|
4
|
+
import { redirect } from 'next/navigation.js';
|
|
5
|
+
import { surfaceUrls } from '../../testSurface/surfaceUrls.js';
|
|
6
|
+
import { buildSurfaceProps } from './buildSurfaceProps.js';
|
|
7
|
+
import { renderTestsSurface } from './renderTestsSurface.js';
|
|
8
|
+
export async function renderCollectionList({ payload, searchParams }, route) {
|
|
9
|
+
const requestHeaders = await headers();
|
|
10
|
+
// Authentication, not an access-checked operation; host access callbacks need the full session user.
|
|
11
|
+
const { user } = await payload.auth({
|
|
12
|
+
headers: requestHeaders
|
|
13
|
+
});
|
|
14
|
+
const adminRoute = payload.config.routes.admin;
|
|
15
|
+
if (!user) {
|
|
16
|
+
const { login } = payload.config.admin.routes;
|
|
17
|
+
const currentPath = route === 'home' ? surfaceUrls.home(adminRoute, await searchParams) : surfaceUrls.goals(adminRoute, await searchParams);
|
|
18
|
+
return redirect(formatAdminURL({
|
|
19
|
+
adminRoute,
|
|
20
|
+
path: `${login}?redirect=${encodeURIComponent(currentPath)}`
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
const req = await createLocalReq({
|
|
24
|
+
user,
|
|
25
|
+
req: {
|
|
26
|
+
headers: requestHeaders
|
|
27
|
+
}
|
|
28
|
+
}, payload);
|
|
29
|
+
return renderTestsSurface(req, await buildSurfaceProps({
|
|
30
|
+
req,
|
|
31
|
+
route,
|
|
32
|
+
searchParams
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { PayloadRequest } from 'payload';
|
|
2
|
+
import type { TestsSurfaceProps } from '../../types/surface.js';
|
|
3
|
+
export declare function renderTestsSurface(req: PayloadRequest, clientProps: TestsSurfaceProps | null): Promise<string | number | bigint | boolean | Iterable<import("react").ReactNode> | import("react").JSX.Element | null | undefined>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent';
|
|
3
|
+
import { accentStyles } from '../../ui/accent.js';
|
|
4
|
+
import { xpOptionsFromReq } from '../../options/fromReq.js';
|
|
5
|
+
import { XP_TESTS_SURFACE } from '../paths.js';
|
|
6
|
+
import { SURFACE_COPY } from '../../testSurface/copy/surface.js';
|
|
7
|
+
export async function renderTestsSurface(req, clientProps) {
|
|
8
|
+
// Keep the server export importable in plain Node; Next loads the CSS-bearing client boundary on render.
|
|
9
|
+
const { RootViewMessage } = await import('../components/RootViewMessage.js');
|
|
10
|
+
if (!clientProps) return /*#__PURE__*/ _jsx(RootViewMessage, {
|
|
11
|
+
children: SURFACE_COPY.noAccess
|
|
12
|
+
});
|
|
13
|
+
function TestsSurfaceFallback() {
|
|
14
|
+
return /*#__PURE__*/ _jsx(RootViewMessage, {
|
|
15
|
+
alert: true,
|
|
16
|
+
children: SURFACE_COPY.notInstalled
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
const css = accentStyles(xpOptionsFromReq(req).theme?.accent);
|
|
20
|
+
const surface = RenderServerComponent({
|
|
21
|
+
Component: XP_TESTS_SURFACE,
|
|
22
|
+
Fallback: TestsSurfaceFallback,
|
|
23
|
+
importMap: req.payload.importMap,
|
|
24
|
+
clientProps
|
|
25
|
+
});
|
|
26
|
+
return css ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
27
|
+
children: [
|
|
28
|
+
/*#__PURE__*/ _jsx("style", {
|
|
29
|
+
children: css
|
|
30
|
+
}),
|
|
31
|
+
surface
|
|
32
|
+
]
|
|
33
|
+
}) : surface;
|
|
34
|
+
}
|
package/dist/blocks/bindings.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { puckExperimentSlug } from '../puck/experimentSlug.js';
|
|
2
|
+
import { walkVisiblePuck } from '../puck/visibility.js';
|
|
1
3
|
import { documentEditor, puckCollections } from '../options.js';
|
|
2
|
-
import { EXPERIMENT_BLOCK_SLUG, hostBlocks
|
|
4
|
+
import { EXPERIMENT_BLOCK_SLUG, hostBlocks } from './model.js';
|
|
3
5
|
/** Same document-kind rule as the scan; Payload blocks are top level, Puck is recursive. */ export function placementSlugs(options, collection, doc) {
|
|
4
6
|
if (!doc) return [];
|
|
5
7
|
const editor = documentEditor(options, collection, doc);
|
|
@@ -15,19 +17,11 @@ import { EXPERIMENT_BLOCK_SLUG, hostBlocks, isObject } from './model.js';
|
|
|
15
17
|
if (editor !== 'puck') return [];
|
|
16
18
|
const registration = puckCollections(options).find((r)=>r.slug === collection);
|
|
17
19
|
const found = new Set();
|
|
18
|
-
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (!isObject(v)) return;
|
|
24
|
-
if (v.type === 'ExperimentSlot' && isObject(v.props)) {
|
|
25
|
-
const ref = v.props.experiment, slug = typeof ref === 'string' ? ref : isObject(ref) ? ref.slug : undefined;
|
|
26
|
-
if (typeof slug === 'string') found.add(slug);
|
|
27
|
-
}
|
|
28
|
-
Object.values(v).forEach(walk);
|
|
29
|
-
}
|
|
30
|
-
if (registration) walk(doc[registration.field]);
|
|
20
|
+
if (registration) walkVisiblePuck(doc[registration.field], (node, visibility)=>{
|
|
21
|
+
if (visibility.hidden || node.type !== 'ExperimentSlot') return;
|
|
22
|
+
const slug = puckExperimentSlug(node.props.experiment);
|
|
23
|
+
if (typeof slug === 'string') found.add(slug);
|
|
24
|
+
});
|
|
31
25
|
return [
|
|
32
26
|
...found
|
|
33
27
|
];
|
|
@@ -6,7 +6,7 @@ export function validateExperimentSlots(value) {
|
|
|
6
6
|
return new Set(slots).size === slots.length ? true : 'Each version appears once';
|
|
7
7
|
}
|
|
8
8
|
export function createExperimentBlock({ blocks, slug = EXPERIMENT_BLOCK_SLUG }) {
|
|
9
|
-
if (blocks.some((block)=>block.slug === slug)) throw new Error(
|
|
9
|
+
if (blocks.some((block)=>block.slug === slug)) throw new Error("Test blocks can't be placed inside another Test block.");
|
|
10
10
|
return {
|
|
11
11
|
slug,
|
|
12
12
|
labels: {
|
package/dist/blocks/formState.js
CHANGED
|
@@ -55,7 +55,7 @@ import { BLOCK_SLOTS, EXPERIMENT_BLOCK_SLUG, isObject, slotBlocks } from './mode
|
|
|
55
55
|
return copyRows(value, field);
|
|
56
56
|
}
|
|
57
57
|
export function wrapExperimentBlock(block, experiment, field, config = {}, blockSlug = EXPERIMENT_BLOCK_SLUG) {
|
|
58
|
-
if (block.blockType === blockSlug) throw new Error(
|
|
58
|
+
if (block.blockType === blockSlug) throw new Error("Test blocks can't be placed inside another Test block.");
|
|
59
59
|
return {
|
|
60
60
|
id: globalThis.crypto.randomUUID(),
|
|
61
61
|
blockType: blockSlug,
|
|
@@ -86,7 +86,7 @@ function copySlotBlocks(block, slot, field, config) {
|
|
|
86
86
|
], field, config)[0], slot);
|
|
87
87
|
}
|
|
88
88
|
export function syncExperimentSlots(block, arms, field, config = {}) {
|
|
89
|
-
const wanted = arms.filter((a)=>a.kind !== 'holdout' && a.key !== 'holdout').map((a)=>a.
|
|
89
|
+
const wanted = arms.filter((a)=>a.kind !== 'holdout' && a.key !== 'holdout').map((a)=>a.key).filter((slot)=>BLOCK_SLOTS.includes(slot));
|
|
90
90
|
const slots = [
|
|
91
91
|
...new Set(wanted)
|
|
92
92
|
].map((slot)=>block.slots.find((row)=>row.slot === slot) ?? {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PayloadRequest } from 'payload';
|
|
2
|
+
/** One language naming rule for placement lists and visitor-impact details. */
|
|
3
|
+
export declare function placementLanguages(req: PayloadRequest, codes: readonly string[]): {
|
|
4
|
+
locales?: string[];
|
|
5
|
+
allLocales?: true;
|
|
6
|
+
};
|
|
7
|
+
export declare function placementLanguageNames(req: PayloadRequest, codes: readonly string[]): string[];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { getTranslation } from '@payloadcms/translations';
|
|
2
|
+
/** One language naming rule for placement lists and visitor-impact details. */ export function placementLanguages(req, codes) {
|
|
3
|
+
const localization = req.payload.config.localization;
|
|
4
|
+
const unique = [
|
|
5
|
+
...new Set(codes.filter(Boolean))
|
|
6
|
+
];
|
|
7
|
+
if (localization && unique.length === localization.localeCodes.length) return {
|
|
8
|
+
allLocales: true
|
|
9
|
+
};
|
|
10
|
+
const locales = placementLanguageNames(req, unique);
|
|
11
|
+
return locales.length ? {
|
|
12
|
+
locales
|
|
13
|
+
} : {};
|
|
14
|
+
}
|
|
15
|
+
export function placementLanguageNames(req, codes) {
|
|
16
|
+
const localization = req.payload.config.localization;
|
|
17
|
+
const unique = [
|
|
18
|
+
...new Set(codes.filter(Boolean))
|
|
19
|
+
];
|
|
20
|
+
return unique.map((code)=>{
|
|
21
|
+
const label = localization && localization.locales.find((entry)=>entry.code === code)?.label;
|
|
22
|
+
return label ? getTranslation(label, req.i18n ?? {
|
|
23
|
+
language: 'en',
|
|
24
|
+
fallbackLanguage: 'en'
|
|
25
|
+
}) || code : code;
|
|
26
|
+
});
|
|
27
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type PayloadRequest } from 'payload';
|
|
2
|
+
import type { DocId, ResolvedOptions } from '../types/contracts.js';
|
|
3
|
+
export type PlacementInput = 'all-locales' | 'localized';
|
|
4
|
+
export declare function placementLocaleContent(req: PayloadRequest, collection: string, doc: Record<string, unknown> | undefined, input: PlacementInput): Record<string, unknown> | undefined;
|
|
5
|
+
/** The single document → locale view → editor/placements boundary. Compiled schemas are shared per sanitized config.
|
|
6
|
+
* Local API and form documents explicitly bypass all-locale projection.
|
|
7
|
+
*/
|
|
8
|
+
export declare function placementReader(req: PayloadRequest, collection: string, options?: Pick<ResolvedOptions, "puck" | "blocks">): {
|
|
9
|
+
views: PlacementLocaleView[];
|
|
10
|
+
documentViews: PlacementLocaleView[];
|
|
11
|
+
read(doc: Record<string, unknown> | null | undefined, input: PlacementInput, view?: PlacementLocaleView): {
|
|
12
|
+
view: PlacementLocaleView;
|
|
13
|
+
readonly doc: Record<string, unknown> | undefined;
|
|
14
|
+
readonly editor: "page" | "puck" | "blocks";
|
|
15
|
+
readonly slugs: string[];
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export declare function allPlacementSlugs(req: PayloadRequest, collection: string, doc: Record<string, unknown> | undefined, input: PlacementInput): string[];
|
|
19
|
+
export interface PlacementLocaleView {
|
|
20
|
+
locale: string;
|
|
21
|
+
fallbackLocale: import('payload').TypedFallbackLocale;
|
|
22
|
+
}
|
|
23
|
+
export declare const placementDocumentKey: (collection: string, id: DocId, view: PlacementLocaleView) => string;
|
|
24
|
+
export type RemovedPlacementViews = Map<string, PlacementLocaleView[]>;
|
|
25
|
+
export declare function localeRequest(req: PayloadRequest, view: PlacementLocaleView): PayloadRequest;
|
|
26
|
+
/** Canonical views of registered content, without multiplying nonlocalized rows. */
|
|
27
|
+
export declare function placementLocaleViews(req: PayloadRequest, collection: string, options?: Pick<ResolvedOptions, "puck" | "blocks">): PlacementLocaleView[];
|
|
28
|
+
/** Compare every locale view: a localized edit can also change fallback
|
|
29
|
+
* content in another locale. Whole-row removals replace every view with absence.
|
|
30
|
+
* The incoming hook document is already flattened to the writing locale.
|
|
31
|
+
*/
|
|
32
|
+
export declare function removedPlacementViews(req: PayloadRequest, collection: string, before: Record<string, unknown> | undefined, after: Record<string, unknown>, removingPage: boolean, input?: PlacementInput): RemovedPlacementViews;
|
|
33
|
+
/** Rebuild unchanged locale maps around a flattened hook write before reading each view. */
|
|
34
|
+
export declare function mergedPlacementLocales(req: PayloadRequest, collection: string, before: Record<string, unknown> | undefined, after: Record<string, unknown>): Record<string, unknown>;
|
|
35
|
+
/** Project host document adapters before they run. Callers own path normalization
|
|
36
|
+
* and use sortLockKeys for the existing experiment → page-path lock ordering. */
|
|
37
|
+
export declare function placementDocumentPaths(req: PayloadRequest, collection: string, docs: Array<Record<string, unknown> | undefined>, input: PlacementInput, pathOf: (doc: Record<string, unknown>) => string | null): string[];
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { sanitizeFallbackLocale } from 'payload';
|
|
2
|
+
import { fieldShouldBeLocalized, flattenTopLevelFields } from 'payload/shared';
|
|
3
|
+
import { documentEditor, puckCollections } from '../options.js';
|
|
4
|
+
import { placementSlugs } from './bindings.js';
|
|
5
|
+
import { contentBlocks, hasLocalizedFields } from '../transitions/contentFields.js';
|
|
6
|
+
import { isObject } from './model.js';
|
|
7
|
+
const identity = (data)=>data;
|
|
8
|
+
// Sanitized schemas are immutable. Weak ownership keeps separate Payload configs
|
|
9
|
+
// (and test harnesses) isolated; locale transforms survive individual readers/saves.
|
|
10
|
+
const localeTransforms = new WeakMap();
|
|
11
|
+
/** Compile only schema-marked localized branches. Opaque field values are never traversed.
|
|
12
|
+
* Copy ancestors only when a localized descendant changes; ordinary branches retain identity.
|
|
13
|
+
*/ function localeTransform(payloadConfig, collection, locale, fallback) {
|
|
14
|
+
const config = payloadConfig.collections?.find((entry)=>entry.slug === collection);
|
|
15
|
+
if (!payloadConfig.localization || !config) return identity;
|
|
16
|
+
let collections = localeTransforms.get(payloadConfig);
|
|
17
|
+
if (!collections) localeTransforms.set(payloadConfig, collections = new WeakMap());
|
|
18
|
+
let cached = collections.get(config);
|
|
19
|
+
if (!cached || cached.fields !== config.fields) collections.set(config, cached = {
|
|
20
|
+
fields: config.fields,
|
|
21
|
+
transforms: new Map()
|
|
22
|
+
});
|
|
23
|
+
const key = JSON.stringify([
|
|
24
|
+
locale,
|
|
25
|
+
fallback
|
|
26
|
+
]);
|
|
27
|
+
const existing = cached.transforms.get(key);
|
|
28
|
+
if (existing) return existing;
|
|
29
|
+
const blocks = payloadConfig.blocks ?? [];
|
|
30
|
+
const compiled = new Map();
|
|
31
|
+
function compile(fields, parentIsLocalized = false) {
|
|
32
|
+
if (parentIsLocalized) return (data)=>data;
|
|
33
|
+
const cached = compiled.get(fields);
|
|
34
|
+
if (cached) return cached;
|
|
35
|
+
let project;
|
|
36
|
+
const transform = (data, write, previous)=>project(data, write, previous);
|
|
37
|
+
compiled.set(fields, transform);
|
|
38
|
+
const steps = flattenTopLevelFields(fields).flatMap((field)=>{
|
|
39
|
+
if (!('name' in field) || !field.name) return [];
|
|
40
|
+
const name = field.name;
|
|
41
|
+
const localized = fieldShouldBeLocalized({
|
|
42
|
+
field,
|
|
43
|
+
parentIsLocalized
|
|
44
|
+
});
|
|
45
|
+
const parent = parentIsLocalized || localized;
|
|
46
|
+
const children = 'fields' in field && hasLocalizedFields(field.fields, payloadConfig) && [
|
|
47
|
+
'group',
|
|
48
|
+
'array',
|
|
49
|
+
'tab'
|
|
50
|
+
].includes(field.type) ? compile(field.fields, parent) : undefined;
|
|
51
|
+
const variants = field.type === 'blocks' ? new Map([
|
|
52
|
+
...field.blocks ?? [],
|
|
53
|
+
...field.blockReferences ?? []
|
|
54
|
+
].flatMap((ref)=>{
|
|
55
|
+
const block = typeof ref === 'string' ? blocks.find((block)=>block.slug === ref) : ref;
|
|
56
|
+
return block && hasLocalizedFields(block.fields, payloadConfig) ? [
|
|
57
|
+
[
|
|
58
|
+
block.slug,
|
|
59
|
+
compile(block.fields, parent)
|
|
60
|
+
]
|
|
61
|
+
] : [];
|
|
62
|
+
})) : undefined;
|
|
63
|
+
if (!localized && !children && !variants) return [];
|
|
64
|
+
return [
|
|
65
|
+
(data, write, previous)=>{
|
|
66
|
+
if (!(name in data)) return data;
|
|
67
|
+
let value = data[name];
|
|
68
|
+
const prior = previous?.[name];
|
|
69
|
+
if (localized && write) value = {
|
|
70
|
+
...isObject(prior) ? prior : {},
|
|
71
|
+
[locale]: value
|
|
72
|
+
};
|
|
73
|
+
else {
|
|
74
|
+
if (localized) {
|
|
75
|
+
const values = isObject(value) ? value : {};
|
|
76
|
+
value = values[locale];
|
|
77
|
+
if (fallback && fallback !== locale && (value == null || (field.type === 'text' || field.type === 'textarea') && value === '')) {
|
|
78
|
+
for (const code of Array.isArray(fallback) ? fallback : [
|
|
79
|
+
fallback
|
|
80
|
+
]){
|
|
81
|
+
const candidate = values[code];
|
|
82
|
+
if (candidate != null && candidate !== '') {
|
|
83
|
+
value = candidate;
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const visit = (row, old)=>{
|
|
90
|
+
if (!isObject(row)) return row;
|
|
91
|
+
const transform = children ?? (variants && typeof row.blockType === 'string' ? variants.get(row.blockType) : undefined);
|
|
92
|
+
return transform ? transform(row, write, isObject(old) ? old : undefined) : row;
|
|
93
|
+
};
|
|
94
|
+
if (children || variants) {
|
|
95
|
+
if (Array.isArray(value)) {
|
|
96
|
+
const rows = value.map((row, index)=>visit(row, Array.isArray(prior) ? isObject(row) && row.id != null ? prior.find((old)=>isObject(old) && old.id === row.id) : prior[index] : undefined));
|
|
97
|
+
if (rows.some((row, index)=>row !== value[index])) value = rows;
|
|
98
|
+
} else value = visit(value, prior);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return value === data[name] ? data : {
|
|
102
|
+
...data,
|
|
103
|
+
[name]: value
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
];
|
|
107
|
+
});
|
|
108
|
+
project = (data, write = false, previous)=>steps.reduce((result, step)=>step(result, write, previous), data);
|
|
109
|
+
return transform;
|
|
110
|
+
}
|
|
111
|
+
const transform = hasLocalizedFields(config.fields ?? [], payloadConfig) ? compile(config.fields ?? []) : identity;
|
|
112
|
+
cached.transforms.set(key, transform);
|
|
113
|
+
return transform;
|
|
114
|
+
}
|
|
115
|
+
export function placementLocaleContent(req, collection, doc, input) {
|
|
116
|
+
return placementReader(req, collection).read(doc, input).doc;
|
|
117
|
+
}
|
|
118
|
+
/** The single document → locale view → editor/placements boundary. Compiled schemas are shared per sanitized config.
|
|
119
|
+
* Local API and form documents explicitly bypass all-locale projection.
|
|
120
|
+
*/ export function placementReader(req, collection, options = req.payload.config.custom?.xp) {
|
|
121
|
+
const views = placementLocaleViews(req, collection, options);
|
|
122
|
+
const transforms = new Map();
|
|
123
|
+
return {
|
|
124
|
+
views,
|
|
125
|
+
documentViews: schemaLocaleViews(req, collection),
|
|
126
|
+
read (doc, input, view) {
|
|
127
|
+
const requested = view ?? {
|
|
128
|
+
locale: req.locale ?? '',
|
|
129
|
+
fallbackLocale: req.fallbackLocale ?? false
|
|
130
|
+
};
|
|
131
|
+
const selected = requested.locale === 'all' ? {
|
|
132
|
+
...requested,
|
|
133
|
+
locale: req.payload.config.localization ? req.payload.config.localization.defaultLocale : ''
|
|
134
|
+
} : requested;
|
|
135
|
+
let content, resolved = false;
|
|
136
|
+
const resolve = ()=>{
|
|
137
|
+
if (resolved) return content;
|
|
138
|
+
resolved = true;
|
|
139
|
+
content = doc ?? undefined;
|
|
140
|
+
if (doc && input === 'all-locales' && req.payload.config.localization && selected.locale !== 'all') {
|
|
141
|
+
const locale = selected.locale || req.payload.config.localization.defaultLocale;
|
|
142
|
+
const key = JSON.stringify([
|
|
143
|
+
locale,
|
|
144
|
+
selected.fallbackLocale
|
|
145
|
+
]);
|
|
146
|
+
let transform = transforms.get(key);
|
|
147
|
+
if (!transform) {
|
|
148
|
+
transform = localeTransform(req.payload.config, collection, locale, sanitizeFallbackLocale({
|
|
149
|
+
fallbackLocale: selected.fallbackLocale,
|
|
150
|
+
locale,
|
|
151
|
+
localization: req.payload.config.localization
|
|
152
|
+
}));
|
|
153
|
+
transforms.set(key, transform);
|
|
154
|
+
}
|
|
155
|
+
content = transform(doc);
|
|
156
|
+
}
|
|
157
|
+
return content;
|
|
158
|
+
};
|
|
159
|
+
let editor, slugs;
|
|
160
|
+
return {
|
|
161
|
+
view: selected,
|
|
162
|
+
get doc () {
|
|
163
|
+
return resolve();
|
|
164
|
+
},
|
|
165
|
+
get editor () {
|
|
166
|
+
return editor ??= doc ? documentEditor(options ?? {}, collection, resolve()) : 'page';
|
|
167
|
+
},
|
|
168
|
+
get slugs () {
|
|
169
|
+
return slugs ??= placementSlugs(options ?? {}, collection, resolve());
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
export function allPlacementSlugs(req, collection, doc, input) {
|
|
176
|
+
const reader = placementReader(req, collection);
|
|
177
|
+
return [
|
|
178
|
+
...new Set(reader.views.flatMap((view)=>reader.read(doc, input, view).slugs))
|
|
179
|
+
];
|
|
180
|
+
}
|
|
181
|
+
export const placementDocumentKey = (collection, id, view)=>JSON.stringify([
|
|
182
|
+
collection,
|
|
183
|
+
String(id),
|
|
184
|
+
view
|
|
185
|
+
]);
|
|
186
|
+
export function localeRequest(req, view) {
|
|
187
|
+
// Fetch Request properties are prototype getters and disappear in a spread.
|
|
188
|
+
// Local API setup needs headers/url; hooks also retain method and cancellation.
|
|
189
|
+
return {
|
|
190
|
+
...req,
|
|
191
|
+
headers: req.headers,
|
|
192
|
+
url: req.url,
|
|
193
|
+
method: req.method,
|
|
194
|
+
signal: req.signal,
|
|
195
|
+
...view
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
/** Audits may contain localized arm-select tags outside registered editors. */ function schemaLocaleViews(req, collection) {
|
|
199
|
+
const localization = req.payload.config.localization;
|
|
200
|
+
const config = req.payload.config.collections?.find((entry)=>entry.slug === collection);
|
|
201
|
+
return localization && hasLocalizedFields(config?.fields ?? [], req.payload.config) ? (localization.localeCodes ?? localization.locales.map((entry)=>typeof entry === 'string' ? entry : entry.code)).map((locale)=>({
|
|
202
|
+
locale,
|
|
203
|
+
fallbackLocale: sanitizeFallbackLocale({
|
|
204
|
+
fallbackLocale: null,
|
|
205
|
+
locale,
|
|
206
|
+
localization
|
|
207
|
+
})
|
|
208
|
+
})) : [
|
|
209
|
+
{
|
|
210
|
+
locale: '',
|
|
211
|
+
fallbackLocale: false
|
|
212
|
+
}
|
|
213
|
+
];
|
|
214
|
+
}
|
|
215
|
+
/** Canonical views of registered content, without multiplying nonlocalized rows. */ export function placementLocaleViews(req, collection, options = req.payload.config.custom?.xp ?? {}) {
|
|
216
|
+
const localization = req.payload.config.localization;
|
|
217
|
+
const config = req.payload.config.collections?.find((entry)=>entry.slug === collection);
|
|
218
|
+
const names = new Set([
|
|
219
|
+
...puckCollections(options).filter((entry)=>entry.slug === collection).map((entry)=>entry.field),
|
|
220
|
+
...(options.blocks?.collections ?? []).filter((entry)=>entry.slug === collection).map((entry)=>entry.field)
|
|
221
|
+
]);
|
|
222
|
+
const localized = config && hasLocalizedFields(config.fields ?? [], req.payload.config) && (Boolean(options.blocks?.collections.some((entry)=>entry.slug === collection && entry.appliesTo)) || flattenTopLevelFields(config.fields ?? []).some((field)=>'name' in field && names.has(field.name) && ('localized' in field && field.localized || 'fields' in field && hasLocalizedFields(field.fields, req.payload.config) || field.type === 'blocks' && hasLocalizedFields(contentBlocks(field, req.payload.config.blocks).flatMap((block)=>block.fields), req.payload.config))));
|
|
223
|
+
return localization && localized ? (localization.localeCodes ?? localization.locales.map((entry)=>typeof entry === 'string' ? entry : entry.code)).map((locale)=>({
|
|
224
|
+
locale,
|
|
225
|
+
fallbackLocale: sanitizeFallbackLocale({
|
|
226
|
+
fallbackLocale: null,
|
|
227
|
+
locale,
|
|
228
|
+
localization
|
|
229
|
+
})
|
|
230
|
+
})) : [
|
|
231
|
+
{
|
|
232
|
+
locale: '',
|
|
233
|
+
fallbackLocale: false
|
|
234
|
+
}
|
|
235
|
+
];
|
|
236
|
+
}
|
|
237
|
+
/** Compare every locale view: a localized edit can also change fallback
|
|
238
|
+
* content in another locale. Whole-row removals replace every view with absence.
|
|
239
|
+
* The incoming hook document is already flattened to the writing locale.
|
|
240
|
+
*/ export function removedPlacementViews(req, collection, before, after, removingPage, input = 'localized') {
|
|
241
|
+
const result = new Map();
|
|
242
|
+
if (!before) return result;
|
|
243
|
+
const reader = placementReader(req, collection);
|
|
244
|
+
const rawAfter = input === 'all-locales' ? after : mergedPlacementLocales(req, collection, before, after);
|
|
245
|
+
for (const view of reader.views){
|
|
246
|
+
const previous = reader.read(before, 'all-locales', view).slugs;
|
|
247
|
+
const next = removingPage ? [] : reader.read(rawAfter, 'all-locales', view).slugs;
|
|
248
|
+
for (const slug of previous.filter((slug)=>!next.includes(slug)))result.set(slug, [
|
|
249
|
+
...result.get(slug) ?? [],
|
|
250
|
+
view
|
|
251
|
+
]);
|
|
252
|
+
}
|
|
253
|
+
return result;
|
|
254
|
+
}
|
|
255
|
+
/** Rebuild unchanged locale maps around a flattened hook write before reading each view. */ export function mergedPlacementLocales(req, collection, before, after) {
|
|
256
|
+
const localization = req.payload.config.localization;
|
|
257
|
+
if (!localization || req.locale === 'all') return after;
|
|
258
|
+
return localeTransform(req.payload.config, collection, req.locale || localization.defaultLocale, false)(after, true, before);
|
|
259
|
+
}
|
|
260
|
+
/** Project host document adapters before they run. Callers own path normalization
|
|
261
|
+
* and use sortLockKeys for the existing experiment → page-path lock ordering. */ export function placementDocumentPaths(req, collection, docs, input, pathOf) {
|
|
262
|
+
const reader = placementReader(req, collection);
|
|
263
|
+
return docs.flatMap((raw)=>reader.documentViews.flatMap((view)=>{
|
|
264
|
+
const doc = reader.read(raw, input, view).doc;
|
|
265
|
+
const path = doc ? pathOf(doc) : null;
|
|
266
|
+
return path === null ? [] : [
|
|
267
|
+
path
|
|
268
|
+
];
|
|
269
|
+
}));
|
|
270
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SURFACE_COPY } from '../../testSurface/copy/surface.js';
|
|
1
2
|
import * as paths from '../../admin/paths.js';
|
|
2
3
|
import { managedAccess } from '../access.js';
|
|
3
4
|
import { serializeAttributeKeys, serializeFlagPoints } from '../serialize.js';
|
|
@@ -37,22 +38,30 @@ export function experimentsCollection(options) {
|
|
|
37
38
|
drafts: false,
|
|
38
39
|
maxPerDoc: 50
|
|
39
40
|
},
|
|
41
|
+
labels: {
|
|
42
|
+
singular: SURFACE_COPY.test,
|
|
43
|
+
plural: SURFACE_COPY.navAllTests
|
|
44
|
+
},
|
|
40
45
|
access: {
|
|
41
46
|
...managedAccess(options),
|
|
42
|
-
delete: async ({ req })=>
|
|
47
|
+
delete: async ({ req, id })=>{
|
|
48
|
+
if (await options.access.manage({
|
|
43
49
|
req
|
|
44
|
-
})
|
|
50
|
+
}) !== true) return false;
|
|
51
|
+
// Single deletes report status through the locked beforeDelete guard.
|
|
52
|
+
// Payload catches per-document hook failures in bulk deletes, so keep their status filter in access.
|
|
53
|
+
return id != null ? true : {
|
|
45
54
|
status: {
|
|
46
55
|
in: [
|
|
47
56
|
'draft',
|
|
48
57
|
'archived'
|
|
49
58
|
]
|
|
50
59
|
}
|
|
51
|
-
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
52
62
|
},
|
|
53
63
|
admin: {
|
|
54
|
-
|
|
55
|
-
group: false,
|
|
64
|
+
group: SURFACE_COPY.title,
|
|
56
65
|
useAsTitle: 'name',
|
|
57
66
|
defaultColumns: [
|
|
58
67
|
'name',
|
|
@@ -63,7 +72,7 @@ export function experimentsCollection(options) {
|
|
|
63
72
|
components: {
|
|
64
73
|
views: {
|
|
65
74
|
list: {
|
|
66
|
-
Component: paths.
|
|
75
|
+
Component: paths.XP_TESTS_COLLECTION_LIST
|
|
67
76
|
},
|
|
68
77
|
edit: {
|
|
69
78
|
default: {
|
|
@@ -101,8 +110,8 @@ export function experimentsCollection(options) {
|
|
|
101
110
|
],
|
|
102
111
|
afterError: [
|
|
103
112
|
({ error })=>{
|
|
104
|
-
// Payload preserves public Error status/message, but omits custom codes.
|
|
105
|
-
if (error instanceof XpRefusal
|
|
113
|
+
// Payload preserves public Error status/message, but omits custom codes; the admin maps refusals by code.
|
|
114
|
+
if (error instanceof XpRefusal) {
|
|
106
115
|
return {
|
|
107
116
|
status: error.status,
|
|
108
117
|
response: {
|
|
@@ -3,8 +3,8 @@ import { xpOptionsFromReq } from '../../options/fromReq.js';
|
|
|
3
3
|
export const deleteGuard = async ({ req, id })=>{
|
|
4
4
|
await deleteExperiment(req, id);
|
|
5
5
|
};
|
|
6
|
-
export const deleteGuardAfter = async ({ req,
|
|
7
|
-
await deleteExperimentAfter(req
|
|
6
|
+
export const deleteGuardAfter = async ({ req, doc })=>{
|
|
7
|
+
await deleteExperimentAfter(req);
|
|
8
8
|
return doc;
|
|
9
9
|
};
|
|
10
10
|
export const deleteGuardBeforeOperation = async ({ operation, args, req })=>{
|