@delmaredigital/payload-experiments 0.4.0-rc.1 → 0.4.0-rc.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +284 -772
- 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.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 +6 -1
- package/dist/admin/copy/goals.js +10 -3
- package/dist/admin/copy/newTest.d.ts +6 -7
- package/dist/admin/copy/newTest.js +9 -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.js +5 -2
- package/dist/admin/surface/TestRowMenu.d.ts +6 -0
- package/dist/admin/surface/TestRowMenu.js +156 -0
- package/dist/admin/surface/TestsHome.d.ts +5 -3
- package/dist/admin/surface/TestsHome.js +266 -58
- package/dist/admin/surface/TestsSurface.js +8 -7
- package/dist/admin/surface/goals/GoalForm.d.ts +1 -1
- package/dist/admin/surface/goals/GoalForm.js +95 -54
- package/dist/admin/surface/goals/GoalsList.d.ts +1 -1
- package/dist/admin/surface/goals/GoalsList.js +5 -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 +9 -8
- package/dist/admin/surface/home.model.js +22 -21
- package/dist/admin/surface/newTest/NewTest.d.ts +4 -4
- package/dist/admin/surface/newTest/NewTest.js +98 -94
- package/dist/admin/surface/newTest/PageWizard.d.ts +2 -1
- package/dist/admin/surface/newTest/PageWizard.js +111 -76
- package/dist/admin/surface/newTest/newTest.css +28 -9
- package/dist/admin/surface/results/ResultsHeader.d.ts +2 -2
- package/dist/admin/surface/results/ResultsHeader.js +58 -54
- package/dist/admin/surface/surface.css +10 -0
- package/dist/admin/surface/test/TestPage.d.ts +1 -2
- package/dist/admin/surface/test/TestPage.js +42 -162
- 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 +11 -0
- package/dist/admin/views/buildSurfaceProps.d.ts +8 -0
- package/dist/admin/views/buildSurfaceProps.js +102 -0
- package/dist/admin/views/renderCollectionList.d.ts +2 -0
- package/dist/admin/views/renderCollectionList.js +34 -0
- package/dist/admin/views/renderTestsSurface.d.ts +3 -0
- package/dist/admin/views/renderTestsSurface.js +34 -0
- package/dist/blocks/bindings.js +8 -14
- package/dist/blocks/formState.js +1 -1
- 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 +16 -4
- package/dist/collections/metricsGuards.js +2 -0
- package/dist/collections/serialize.js +5 -4
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/db/adapter.d.ts +9 -1
- package/dist/db/adapter.js +77 -1
- package/dist/db/appends.d.ts +13 -0
- package/dist/db/appends.js +49 -0
- package/dist/db/bulkPlacementRemoval.d.ts +30 -0
- package/dist/db/bulkPlacementRemoval.js +111 -0
- package/dist/db/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 +1 -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/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 +19 -20
- 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.js +951 -179
- package/dist/puck/editor/LeftoverVersions.d.ts +15 -0
- package/dist/puck/editor/LeftoverVersions.js +79 -0
- package/dist/puck/editor/PlacementNotice.d.ts +8 -0
- package/dist/puck/editor/PlacementNotice.js +22 -0
- package/dist/puck/editor/QuickTestActions.d.ts +6 -0
- package/dist/puck/editor/QuickTestActions.js +57 -0
- package/dist/puck/editor/ResultsReadout.d.ts +2 -1
- package/dist/puck/editor/ResultsReadout.js +10 -6
- package/dist/puck/editor/VersionBuilder.d.ts +66 -12
- package/dist/puck/editor/VersionBuilder.js +554 -231
- package/dist/puck/editor/armWrites.d.ts +11 -2
- package/dist/puck/editor/armWrites.js +43 -4
- package/dist/puck/editor/armsCache.d.ts +3 -1
- package/dist/puck/editor/armsCache.js +20 -4
- package/dist/puck/editor/blockClipboard.d.ts +16 -0
- package/dist/puck/editor/blockClipboard.js +20 -0
- package/dist/puck/editor/cloneSlot.d.ts +2 -0
- package/dist/puck/editor/cloneSlot.js +7 -0
- package/dist/puck/editor/copy.d.ts +64 -19
- package/dist/puck/editor/copy.js +72 -20
- package/dist/puck/editor/createTest.d.ts +3 -0
- package/dist/puck/editor/createTest.js +33 -0
- package/dist/puck/editor/editor.chrome.css +191 -19
- package/dist/puck/editor/editor.css +328 -24
- 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 +1 -1
- package/dist/puck/slotConfig.js +17 -4
- package/dist/puck/visibility.d.ts +20 -0
- package/dist/puck/visibility.js +81 -0
- package/dist/results/aggregate.d.ts +6 -3
- package/dist/results/aggregate.js +9 -9
- 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.js +2 -1
- package/dist/runtime/cookie.d.ts +10 -2
- package/dist/runtime/cookie.js +38 -6
- package/dist/runtime/cookieOptions.d.ts +6 -0
- package/dist/runtime/cookieOptions.js +14 -0
- package/dist/runtime/proxyRuntime.d.ts +1 -0
- package/dist/runtime/proxyRuntime.js +18 -8
- package/dist/runtime/signing.d.ts +1 -0
- package/dist/runtime/signing.js +5 -0
- package/dist/sanitizeReadinessDetail.d.ts +2 -2
- package/dist/sanitizeReadinessDetail.js +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 +52 -14
- 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.js +6 -2
- package/dist/testSurface/actions/DecideDialog.d.ts +16 -0
- package/dist/{admin → testSurface}/actions/DecideDialog.js +78 -55
- package/dist/testSurface/actions/LifecycleAction.d.ts +16 -0
- package/dist/testSurface/actions/LifecycleAction.js +105 -0
- package/dist/{admin → testSurface}/actions/MakeContentResult.d.ts +4 -3
- package/dist/{admin → testSurface}/actions/MakeContentResult.js +10 -2
- package/dist/{admin → testSurface}/actions/actions.model.d.ts +13 -5
- package/dist/testSurface/actions/actions.model.js +122 -0
- package/dist/{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 +28 -8
- package/dist/{admin → testSurface}/copy/actions.js +31 -11
- package/dist/{admin → testSurface}/copy/common.d.ts +13 -4
- package/dist/{admin → testSurface}/copy/common.js +18 -8
- package/dist/testSurface/copy/languages.d.ts +12 -0
- package/dist/testSurface/copy/languages.js +8 -0
- package/dist/{admin → testSurface}/copy/metrics.d.ts +1 -0
- package/dist/{admin → testSurface}/copy/metrics.js +1 -0
- package/dist/testSurface/copy/pages.d.ts +84 -0
- package/dist/testSurface/copy/pages.js +90 -0
- package/dist/{admin → testSurface}/copy/readiness.d.ts +38 -4
- package/dist/{admin → testSurface}/copy/readiness.js +52 -7
- package/dist/{admin → testSurface}/copy/results.d.ts +6 -3
- package/dist/{admin → testSurface}/copy/results.js +6 -3
- package/dist/{admin → testSurface}/copy/review.d.ts +1 -1
- package/dist/{admin → testSurface}/copy/review.js +1 -1
- package/dist/{admin → testSurface}/copy/surface.d.ts +11 -2
- package/dist/{admin → testSurface}/copy/surface.js +13 -10
- package/dist/{admin → testSurface}/copy/testPage.d.ts +53 -8
- package/dist/testSurface/copy/testPage.js +165 -0
- package/dist/testSurface/format/adminURL.d.ts +7 -0
- package/dist/testSurface/format/adminURL.js +9 -0
- package/dist/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.js +6 -2
- 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/{admin → testSurface}/surface/pageBlock/parts.js +39 -11
- package/dist/testSurface/surface/pagePicker/CopyRoute.d.ts +13 -0
- package/dist/testSurface/surface/pagePicker/CopyRoute.js +273 -0
- package/dist/testSurface/surface/pagePicker/PageCombobox.d.ts +21 -0
- package/dist/testSurface/surface/pagePicker/PageCombobox.js +503 -0
- package/dist/testSurface/surface/pagePicker/pagePicker.css +73 -0
- package/dist/{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 +8 -4
- package/dist/testSurface/surface/readiness/ActionDialogs.js +351 -0
- package/dist/{admin → testSurface}/surface/readiness/Banner.d.ts +2 -3
- package/dist/testSurface/surface/readiness/Banner.js +187 -0
- package/dist/testSurface/surface/readiness/BlockerList.d.ts +11 -0
- package/dist/testSurface/surface/readiness/BlockerList.js +31 -0
- package/dist/testSurface/surface/readiness/SaveStatus.d.ts +10 -0
- package/dist/testSurface/surface/readiness/SaveStatus.js +66 -0
- package/dist/{admin → testSurface}/surface/readiness/parts.js +0 -2
- package/dist/{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 +7 -3
- package/dist/{admin → testSurface}/surface/results/ResultsBody.js +108 -44
- 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 +58 -18
- package/dist/testSurface/surface/setting/setting.css +17 -0
- package/dist/{admin → testSurface}/surface/test/AdvancedSection.js +2 -0
- package/dist/testSurface/surface/test/DeleteTest.d.ts +23 -0
- package/dist/testSurface/surface/test/DeleteTest.js +270 -0
- package/dist/testSurface/surface/test/GoalSection.d.ts +4 -0
- package/dist/{admin → testSurface}/surface/test/GoalSection.js +116 -86
- package/dist/testSurface/surface/test/LengthSection.d.ts +2 -0
- package/dist/{admin → testSurface}/surface/test/LengthSection.js +5 -1
- package/dist/{admin → testSurface}/surface/test/PageHoldout.js +4 -1
- package/dist/{admin → testSurface}/surface/test/Rail.js +7 -4
- package/dist/{admin → testSurface}/surface/test/ReadinessBar.d.ts +1 -0
- package/dist/{admin → testSurface}/surface/test/ReadinessBar.js +2 -3
- package/dist/{admin → testSurface}/surface/test/Section.d.ts +3 -1
- package/dist/testSurface/surface/test/Section.js +80 -0
- package/dist/{admin → testSurface}/surface/test/TargetingSection.js +82 -12
- package/dist/testSurface/surface/test/TestSurface.d.ts +19 -0
- package/dist/testSurface/surface/test/TestSurface.js +265 -0
- package/dist/testSurface/surface/test/VersionsSection.d.ts +5 -0
- package/dist/{admin → testSurface}/surface/test/VersionsSection.js +69 -35
- package/dist/{admin → testSurface}/surface/test/fields.d.ts +30 -7
- package/dist/testSurface/surface/test/fields.js +306 -0
- package/dist/{admin → testSurface}/surface/test/pageParts.js +27 -43
- package/dist/testSurface/surface/test/testPage.css +103 -0
- package/dist/{admin → testSurface}/surface/test/testPage.model.d.ts +1 -0
- package/dist/{admin → testSurface}/surface/test/testPage.model.js +6 -0
- package/dist/{admin → testSurface}/surface/testDocument.model.d.ts +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 +7 -0
- package/dist/testSurface/surfaceUrls.js +19 -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 +116 -6
- package/dist/ui/Drawer.d.ts +10 -0
- package/dist/ui/Drawer.js +29 -0
- package/dist/ui/Inputs.d.ts +4 -3
- package/dist/ui/Inputs.js +7 -4
- package/dist/ui/SelectControl.d.ts +33 -0
- package/dist/ui/SelectControl.js +504 -0
- package/dist/ui/Tabs.d.ts +4 -4
- package/dist/ui/Tabs.js +35 -32
- package/dist/ui/ui.css +49 -5
- package/package.json +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/actions.model.js +0 -70
- package/dist/admin/copy/pages.d.ts +0 -26
- package/dist/admin/copy/pages.js +0 -26
- package/dist/admin/copy/testPage.js +0 -104
- 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/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/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}/PreviewLinks.d.ts +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}/arms/arms.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/arms/arms.model.js +0 -0
- /package/dist/{admin → testSurface}/arms/pageTarget.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/arms/pageTarget.model.js +0 -0
- /package/dist/{admin → testSurface}/arms/params.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/arms/params.model.js +0 -0
- /package/dist/{admin → testSurface}/copy/advanced.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/advanced.js +0 -0
- /package/dist/{admin → testSurface}/copy/arms.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/arms.js +0 -0
- /package/dist/{admin → testSurface}/copy/audience.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/audience.js +0 -0
- /package/dist/{admin → testSurface}/copy/recommendation.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/recommendation.js +0 -0
- /package/dist/{admin → testSurface}/copy/setting.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/setting.js +0 -0
- /package/dist/{admin → testSurface}/format/date.d.ts +0 -0
- /package/dist/{admin → testSurface}/format/date.js +0 -0
- /package/dist/{admin → testSurface}/labels.d.ts +0 -0
- /package/dist/{admin → testSurface}/labels.js +0 -0
- /package/dist/{admin → testSurface}/lockedNotice.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/lockedNotice.model.js +0 -0
- /package/dist/{admin → testSurface}/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/results.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/snapshot.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/snapshot.js +0 -0
- /package/dist/{admin → testSurface}/review/review.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/review/review.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/contracts.js +0 -0
- /package/dist/{admin → testSurface}/surface/pageBlock/pageBlock.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/pageBlock/parts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/parts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/results/recommendation.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/results/recommendation.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/setting/parts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/setting/setting.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/setting/setting.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/AdvancedSection.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/PageHoldout.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
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { accentStyles } from '../../ui/accent.js';
|
|
3
|
-
import { flattenTopLevelFields, formatAdminURL } from 'payload/shared';
|
|
1
|
+
import { formatAdminURL } from 'payload/shared';
|
|
4
2
|
import { notFound, redirect } from 'next/navigation.js';
|
|
5
|
-
import { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent';
|
|
6
|
-
import { serializeAttributeKeys, serializeFlagPoints, serializeMetricSources } from '../../collections/serialize.js';
|
|
7
|
-
import { serializePageCollections } from '../pageCollections.js';
|
|
8
|
-
import { collectionLabel as resolveLabel } from '../../collections/labels.js';
|
|
9
|
-
import { documentEditor, puckCollections } from '../../options.js';
|
|
10
3
|
import { xpOptionsFromReq } from '../../options/fromReq.js';
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
4
|
+
import { surfaceUrls } from '../../testSurface/surfaceUrls.js';
|
|
5
|
+
import { buildSurfaceProps } from './buildSurfaceProps.js';
|
|
6
|
+
import { renderTestsSurface } from './renderTestsSurface.js';
|
|
14
7
|
export async function ExperimentsRootView({ initPageResult, params, searchParams }) {
|
|
15
8
|
const { req } = initPageResult;
|
|
16
9
|
const adminRoute = req.payload.config.routes.admin;
|
|
@@ -51,32 +44,23 @@ export async function ExperimentsRootView({ initPageResult, params, searchParams
|
|
|
51
44
|
path: `${login}?redirect=${encodeURIComponent(currentPath)}`
|
|
52
45
|
}));
|
|
53
46
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const options = xpOptionsFromReq(req);
|
|
57
|
-
async function permits(access) {
|
|
47
|
+
if (route === 'home' || route === 'goals') {
|
|
48
|
+
let canManage = false;
|
|
58
49
|
try {
|
|
59
|
-
|
|
50
|
+
canManage = await xpOptionsFromReq(req).access.manage({
|
|
60
51
|
req
|
|
61
52
|
}) === true;
|
|
62
|
-
} catch {
|
|
63
|
-
|
|
64
|
-
|
|
53
|
+
} catch {}
|
|
54
|
+
if (!canManage) return renderTestsSurface(req, null);
|
|
55
|
+
return redirect(route === 'home' ? surfaceUrls.home(adminRoute, await searchParams) : surfaceUrls.goals(adminRoute, await searchParams));
|
|
65
56
|
}
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
const canReadResults = options.access.readResults ? await permits(options.access.readResults) : canManage;
|
|
69
|
-
if (routeAccess({
|
|
57
|
+
const clientProps = await buildSurfaceProps({
|
|
58
|
+
req,
|
|
70
59
|
route,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return /*#__PURE__*/ _jsx(RootViewMessage, {
|
|
76
|
-
children: SURFACE_COPY.noAccess
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
if (canManage && id && tail[0] === 'by-slug') {
|
|
60
|
+
id,
|
|
61
|
+
searchParams
|
|
62
|
+
});
|
|
63
|
+
if (clientProps?.canManage && id && tail[0] === 'by-slug') {
|
|
80
64
|
const result = await req.payload.find({
|
|
81
65
|
collection: 'xp-experiments',
|
|
82
66
|
req,
|
|
@@ -90,138 +74,7 @@ export async function ExperimentsRootView({ initPageResult, params, searchParams
|
|
|
90
74
|
}
|
|
91
75
|
});
|
|
92
76
|
if (!result.docs[0]) return notFound();
|
|
93
|
-
id = String(result.docs[0].id);
|
|
77
|
+
clientProps.id = String(result.docs[0].id);
|
|
94
78
|
}
|
|
95
|
-
|
|
96
|
-
// xp-state is manager-readable only. Results-only readers do not edit settings.
|
|
97
|
-
if (canManage && flagPoints.length) {
|
|
98
|
-
const state = await req.payload.findGlobal({
|
|
99
|
-
slug: 'xp-state',
|
|
100
|
-
req,
|
|
101
|
-
overrideAccess: false,
|
|
102
|
-
depth: 0
|
|
103
|
-
});
|
|
104
|
-
const defaults = state.flagDefaults;
|
|
105
|
-
for (const point of flagPoints)point.effectiveDefaults = defaults?.[point.id]?.params ?? point.defaultParams;
|
|
106
|
-
}
|
|
107
|
-
const registrations = [
|
|
108
|
-
...new Set([
|
|
109
|
-
...options.puck?.enabled ? puckCollections(options) : [],
|
|
110
|
-
...options.blocks?.collections ?? []
|
|
111
|
-
].map((entry)=>entry.slug))
|
|
112
|
-
];
|
|
113
|
-
const pages = route === 'new' && canManage && registrations.length ? (await Promise.all(registrations.map(async (collection)=>{
|
|
114
|
-
try {
|
|
115
|
-
const config = req.payload.config.collections.find((item)=>item.slug === collection);
|
|
116
|
-
const useAsTitle = config?.admin.useAsTitle ?? 'id';
|
|
117
|
-
const collectionLabel = resolveLabel(config?.labels.plural, collection, req);
|
|
118
|
-
// appliesTo may inspect any stored field; ordinary Puck lists keep their title-only projection.
|
|
119
|
-
const predicateFields = options.blocks?.collections.some((entry)=>entry.slug === collection) ? Object.fromEntries(flattenTopLevelFields(config?.fields ?? []).map((field)=>[
|
|
120
|
-
field.name,
|
|
121
|
-
true
|
|
122
|
-
])) : {};
|
|
123
|
-
const result = await req.payload.find({
|
|
124
|
-
collection,
|
|
125
|
-
req,
|
|
126
|
-
overrideAccess: false,
|
|
127
|
-
depth: 0,
|
|
128
|
-
limit: 50,
|
|
129
|
-
sort: '-updatedAt',
|
|
130
|
-
draft: true,
|
|
131
|
-
select: {
|
|
132
|
-
[useAsTitle]: true,
|
|
133
|
-
...predicateFields
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
// The new-test list uses the latest draft's editing intent, as the "Test a block" field condition does (§4.1).
|
|
137
|
-
return result.docs.map((doc)=>{
|
|
138
|
-
const editor = documentEditor(options, collection, doc);
|
|
139
|
-
if (editor !== 'puck' && editor !== 'blocks') return null;
|
|
140
|
-
const id = doc.id;
|
|
141
|
-
const customUrl = options.admin?.editorUrl?.({
|
|
142
|
-
collection,
|
|
143
|
-
id,
|
|
144
|
-
draft: true,
|
|
145
|
-
editor,
|
|
146
|
-
doc
|
|
147
|
-
});
|
|
148
|
-
const title = doc[useAsTitle];
|
|
149
|
-
return {
|
|
150
|
-
collection,
|
|
151
|
-
collectionLabel,
|
|
152
|
-
id,
|
|
153
|
-
editor,
|
|
154
|
-
title: typeof title === 'string' || typeof title === 'number' ? String(title) : String(id),
|
|
155
|
-
editorUrl: typeof customUrl === 'string' ? customUrl : formatAdminURL({
|
|
156
|
-
adminRoute,
|
|
157
|
-
path: `/collections/${collection}/${encodeURIComponent(String(id))}`
|
|
158
|
-
})
|
|
159
|
-
};
|
|
160
|
-
}).filter((page)=>page !== null);
|
|
161
|
-
} catch {
|
|
162
|
-
return [];
|
|
163
|
-
}
|
|
164
|
-
}))).flat() : undefined;
|
|
165
|
-
const descriptions = options.admin?.descriptions;
|
|
166
|
-
const returnToTest = (await searchParams)?.return;
|
|
167
|
-
const clientProps = {
|
|
168
|
-
...typeof returnToTest === 'string' && /^[\w-]+$/.test(returnToTest) ? {
|
|
169
|
-
returnToTest
|
|
170
|
-
} : {},
|
|
171
|
-
route,
|
|
172
|
-
...id === undefined ? {} : {
|
|
173
|
-
id
|
|
174
|
-
},
|
|
175
|
-
adminRoute,
|
|
176
|
-
apiRoute: req.payload.config.routes.api,
|
|
177
|
-
canManage,
|
|
178
|
-
canReadResults,
|
|
179
|
-
isAdmin,
|
|
180
|
-
flagPoints,
|
|
181
|
-
...pages === undefined ? {} : {
|
|
182
|
-
pages
|
|
183
|
-
},
|
|
184
|
-
pageCollections: serializePageCollections(options.pages?.collections ?? [], req),
|
|
185
|
-
collectionTitles: Object.fromEntries(req.payload.config.collections.flatMap((collection)=>{
|
|
186
|
-
const title = collection.admin.useAsTitle;
|
|
187
|
-
return title && title !== 'id' ? [
|
|
188
|
-
[
|
|
189
|
-
collection.slug,
|
|
190
|
-
title
|
|
191
|
-
]
|
|
192
|
-
] : [];
|
|
193
|
-
})),
|
|
194
|
-
userId: req.user.id,
|
|
195
|
-
userCollection: req.payload.config.admin.user,
|
|
196
|
-
attributeKeys: serializeAttributeKeys(options),
|
|
197
|
-
metricSources: serializeMetricSources(options),
|
|
198
|
-
...descriptions ? {
|
|
199
|
-
admin: {
|
|
200
|
-
descriptions: {
|
|
201
|
-
...descriptions
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
} : {}
|
|
205
|
-
};
|
|
206
|
-
function TestsSurfaceFallback() {
|
|
207
|
-
return /*#__PURE__*/ _jsx(RootViewMessage, {
|
|
208
|
-
alert: true,
|
|
209
|
-
children: SURFACE_COPY.notInstalled
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
const css = accentStyles(options.theme?.accent);
|
|
213
|
-
const surface = RenderServerComponent({
|
|
214
|
-
Component: XP_TESTS_SURFACE,
|
|
215
|
-
Fallback: TestsSurfaceFallback,
|
|
216
|
-
importMap: req.payload.importMap,
|
|
217
|
-
clientProps
|
|
218
|
-
});
|
|
219
|
-
return css ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
220
|
-
children: [
|
|
221
|
-
/*#__PURE__*/ _jsx("style", {
|
|
222
|
-
children: css
|
|
223
|
-
}),
|
|
224
|
-
surface
|
|
225
|
-
]
|
|
226
|
-
}) : surface;
|
|
79
|
+
return renderTestsSurface(req, clientProps);
|
|
227
80
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { formatAdminURL } from 'payload/shared';
|
|
2
|
+
import { redirect } from 'next/navigation.js';
|
|
3
|
+
export async function GoalEditRedirect({ initPageResult, params, routeSegments }) {
|
|
4
|
+
const resolved = await params;
|
|
5
|
+
const segments = routeSegments ?? (Array.isArray(resolved?.segments) ? resolved.segments : []);
|
|
6
|
+
const collectionIndex = segments.indexOf('xp-metrics');
|
|
7
|
+
const tail = collectionIndex >= 0 ? segments.slice(collectionIndex + 1) : segments;
|
|
8
|
+
const id = tail[0] ?? resolved?.id ?? initPageResult.docID;
|
|
9
|
+
const path = id === undefined || id === 'create' ? '/experiments/goals/new' : `/experiments/goals/${encodeURIComponent(String(id))}`;
|
|
10
|
+
return redirect(formatAdminURL({
|
|
11
|
+
adminRoute: initPageResult.req.payload.config.routes.admin,
|
|
12
|
+
path
|
|
13
|
+
}));
|
|
14
|
+
}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { ServerProps } from 'payload';
|
|
2
|
+
/** @deprecated Retained for existing import maps until 0.5.0. */
|
|
2
3
|
export declare function TestsNavLinkServer({ payload, user, permissions }: Pick<ServerProps, 'payload' | 'user' | 'permissions'>): Promise<string | number | bigint | boolean | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent';
|
|
2
|
-
import { SURFACE_COPY } from '
|
|
2
|
+
import { SURFACE_COPY } from '../../testSurface/copy/surface.js';
|
|
3
3
|
import { XP_TESTS_NAV_CLIENT } from '../paths.js';
|
|
4
|
-
export async function TestsNavLinkServer({ payload, user, permissions }) {
|
|
4
|
+
/** @deprecated Retained for existing import maps until 0.5.0. */ export async function TestsNavLinkServer({ payload, user, permissions }) {
|
|
5
5
|
const testPermissions = permissions?.collections?.['xp-experiments'];
|
|
6
6
|
if (!user?.collection || testPermissions?.update !== true) return null;
|
|
7
7
|
const result = await payload.find({
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useLocale } from '@payloadcms/ui';
|
|
4
|
+
import { TestsSurface as Surface } from '../surface/TestsSurface.js';
|
|
5
|
+
/** Payload context stays at the admin entry; the mountable surface stays neutral. */ export function TestsSurface(props) {
|
|
6
|
+
const locale = useLocale();
|
|
7
|
+
return /*#__PURE__*/ _jsx(Surface, {
|
|
8
|
+
...props,
|
|
9
|
+
contentLocale: locale?.code
|
|
10
|
+
});
|
|
11
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AdminViewServerProps, PayloadRequest } from 'payload';
|
|
2
|
+
import type { TestsRoute, TestsSurfaceProps } from '../../types/surface.js';
|
|
3
|
+
export declare function buildSurfaceProps({ req, route, id, searchParams }: {
|
|
4
|
+
req: PayloadRequest;
|
|
5
|
+
route: TestsRoute;
|
|
6
|
+
id?: string;
|
|
7
|
+
searchParams: AdminViewServerProps['searchParams'];
|
|
8
|
+
}): Promise<TestsSurfaceProps | null>;
|
|
@@ -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
|
];
|
package/dist/blocks/formState.js
CHANGED
|
@@ -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[];
|