@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
package/dist/manifest/compile.js
CHANGED
|
@@ -2,7 +2,8 @@ import { txExecutor } from '../db/executor.js';
|
|
|
2
2
|
import { bumpRevision, writeManifest } from '../db/state.js';
|
|
3
3
|
import { XpRefusal } from '../errors.js';
|
|
4
4
|
import { xpOptionsFromReq } from '../options/fromReq.js';
|
|
5
|
-
export async function loadManifestInputs(req, { excludeIds = [], pruneFlagDefaultIds = [] } = {}) {
|
|
5
|
+
export async function loadManifestInputs(req, { excludeIds = [], pruneFlagDefaultIds = [], signal } = {}) {
|
|
6
|
+
signal?.throwIfAborted();
|
|
6
7
|
// §7.8 manifest reads: transitions compile all live/archived routing state.
|
|
7
8
|
const result = await req.payload.find({
|
|
8
9
|
collection: 'xp-experiments',
|
|
@@ -20,6 +21,7 @@ export async function loadManifestInputs(req, { excludeIds = [], pruneFlagDefaul
|
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
23
|
});
|
|
24
|
+
signal?.throwIfAborted();
|
|
23
25
|
const excluded = new Set(excludeIds.map(String));
|
|
24
26
|
const experiments = [];
|
|
25
27
|
for (const doc of result.docs){
|
|
@@ -44,6 +46,7 @@ export async function loadManifestInputs(req, { excludeIds = [], pruneFlagDefaul
|
|
|
44
46
|
},
|
|
45
47
|
sort: '-phase'
|
|
46
48
|
});
|
|
49
|
+
signal?.throwIfAborted();
|
|
47
50
|
const rollout = phases.docs[0]?.phaseKind === 'rollout';
|
|
48
51
|
// §7.8 manifest reads: runtime rollout ranges use the test's full weights (including their exact
|
|
49
52
|
// floating-point sum) and its control content. The rollout record has only
|
|
@@ -64,6 +67,7 @@ export async function loadManifestInputs(req, { excludeIds = [], pruneFlagDefaul
|
|
|
64
67
|
},
|
|
65
68
|
sort: '-phase'
|
|
66
69
|
}) : null;
|
|
70
|
+
signal?.throwIfAborted();
|
|
67
71
|
if (rollout && !test?.docs[0]) throw new Error('Missing test phase for rollout ' + doc.id);
|
|
68
72
|
experiments.push({
|
|
69
73
|
...doc,
|
|
@@ -133,7 +137,7 @@ export async function loadManifestInputs(req, { excludeIds = [], pruneFlagDefaul
|
|
|
133
137
|
const testPhase = experiment.lastTestPhase ?? (phase?.phaseKind === 'test' ? phase : null);
|
|
134
138
|
if (!testPhase) throw new XpRefusal('invalid-status', `Missing last test phase for experiment ${experiment.slug}`, undefined, 409);
|
|
135
139
|
const winner = testPhase.arms.find((arm)=>arm.key === decision.winnerArm);
|
|
136
|
-
if (experiment.kind === 'block' && winner
|
|
140
|
+
if (experiment.kind === 'block' && winner && winner.kind !== 'holdout' && winner.key !== 'holdout') manifest.archivedWinners[experiment.slug] = winner.key;
|
|
137
141
|
if (experiment.kind === 'page' && winner?.pageTarget) {
|
|
138
142
|
for (const arm of testPhase.arms){
|
|
139
143
|
if (arm.pageTarget && arm.pageTarget !== winner.pageTarget) {
|
|
@@ -185,12 +189,14 @@ export async function loadManifestInputs(req, { excludeIds = [], pruneFlagDefaul
|
|
|
185
189
|
phaseKind: rollout ? 'rollout' : 'test',
|
|
186
190
|
seed: phase.seed,
|
|
187
191
|
coverage: layer || experiment.status === 'decided' && !rollout ? 1 : phase.allocation / 100,
|
|
188
|
-
arms: (phase.phaseKind === 'rollout' ? experiment.lastTestPhase?.arms ?? phase.arms : phase.arms).map(({ key, kind, weight, slot, pageTarget, params })=>
|
|
192
|
+
arms: (phase.phaseKind === 'rollout' ? experiment.lastTestPhase?.arms ?? phase.arms : phase.arms).map(({ key, kind, weight, slot, pageTarget, params })=>{
|
|
193
|
+
const contentSlot = experiment.kind === 'block' ? kind !== 'holdout' && key !== 'holdout' ? key : undefined : slot;
|
|
194
|
+
return {
|
|
189
195
|
key,
|
|
190
196
|
kind,
|
|
191
197
|
weight,
|
|
192
|
-
...
|
|
193
|
-
slot
|
|
198
|
+
...contentSlot != null ? {
|
|
199
|
+
slot: contentSlot
|
|
194
200
|
} : {},
|
|
195
201
|
...pageTarget != null ? {
|
|
196
202
|
pageTarget
|
|
@@ -198,7 +204,8 @@ export async function loadManifestInputs(req, { excludeIds = [], pruneFlagDefaul
|
|
|
198
204
|
...params != null ? {
|
|
199
205
|
params
|
|
200
206
|
} : {}
|
|
201
|
-
}
|
|
207
|
+
};
|
|
208
|
+
}),
|
|
202
209
|
targeting,
|
|
203
210
|
exposurePolicy: experiment.exposurePolicy,
|
|
204
211
|
deferrable: targeting.some((rule)=>rule.attribute === 'loggedIn' || rule.attribute === 'staff'),
|
package/dist/onInit.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
import { puckCollections } from './options.js';
|
|
2
|
+
import { pageGuardEnterOperation } from './hooks/pageGuard.js';
|
|
1
3
|
import { findRegisteredBlocksField } from './blocks/formState.js';
|
|
2
4
|
import { EXPERIMENT_BLOCK_SLUG } from './blocks/model.js';
|
|
3
5
|
import { contentBlocks } from './transitions/contentFields.js';
|
|
4
6
|
import { validateDimensions } from './events/dimensions.js';
|
|
5
7
|
import { assertPostgresAdapter, probeTransactions } from './db/adapter.js';
|
|
6
8
|
import { hasHostAttributesOf } from './server/serverRuntime.js';
|
|
9
|
+
import { assertSigningSecrets } from './runtime/signing.js';
|
|
10
|
+
import { assertUnitRateLimit } from './runtime/proxyRuntime.js';
|
|
11
|
+
import { assertCookieOptions } from './runtime/cookieOptions.js';
|
|
12
|
+
import { publicEventOrigin } from './events/request.js';
|
|
7
13
|
// Diagnostic only: named containers are never accepted by the top-level readers.
|
|
8
14
|
function registeredPaths(fields, name, parent = []) {
|
|
9
15
|
return fields.flatMap((field)=>{
|
|
@@ -23,6 +29,33 @@ function registeredPaths(fields, name, parent = []) {
|
|
|
23
29
|
}
|
|
24
30
|
export function createOnInit(options) {
|
|
25
31
|
return async (payload)=>{
|
|
32
|
+
const rateLimit = options.events?.rateLimit;
|
|
33
|
+
if (rateLimit !== false && typeof rateLimit !== 'function') {
|
|
34
|
+
throw new Error('Experiments requires events.rateLimit to be a client-address rate limiter, or false if you rate-limit the events route upstream.');
|
|
35
|
+
}
|
|
36
|
+
assertSigningSecrets(options.runtime.proxyRuntime.secrets);
|
|
37
|
+
assertUnitRateLimit(options.runtime.proxyRuntime.rateLimitUnit);
|
|
38
|
+
assertCookieOptions(options.runtime.proxyRuntime.cookie);
|
|
39
|
+
const guarded = new Set([
|
|
40
|
+
...options.puck?.enabled ? puckCollections(options).map((c)=>c.slug) : [],
|
|
41
|
+
...(options.blocks?.collections ?? []).map((c)=>c.slug),
|
|
42
|
+
...(options.pages?.collections ?? []).map((c)=>c.slug)
|
|
43
|
+
]);
|
|
44
|
+
for (const collection of payload.config.collections ?? []){
|
|
45
|
+
if (!guarded.has(collection.slug)) continue;
|
|
46
|
+
// Page-only guards also read the raw main row's scalar _status when
|
|
47
|
+
// protecting unpublishes and restores; localized status breaks those too.
|
|
48
|
+
if (payload.config.localization && payload.config.experimental?.localizeStatus && collection.versions && collection.versions.drafts && collection.versions.drafts.localizeStatus) {
|
|
49
|
+
throw new Error(`Experiments collection ${collection.slug} does not support versions.drafts.localizeStatus. Use a shared publication status.`);
|
|
50
|
+
}
|
|
51
|
+
if (collection.hooks) {
|
|
52
|
+
const hooks = collection.hooks.beforeOperation ?? [];
|
|
53
|
+
collection.hooks.beforeOperation = [
|
|
54
|
+
pageGuardEnterOperation,
|
|
55
|
+
...hooks.filter((hook)=>hook !== pageGuardEnterOperation)
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
26
59
|
for (const registration of options.blocks?.collections ?? []){
|
|
27
60
|
const config = payload.config.collections.find((c)=>c.slug === registration.slug);
|
|
28
61
|
const found = findRegisteredBlocksField(config?.fields ?? [], registration.field);
|
|
@@ -38,5 +71,8 @@ export function createOnInit(options) {
|
|
|
38
71
|
if (Object.hasOwn(options.attributeKeys ?? {}, 'staff') && !hasHostAttributesOf(options.runtime)) {
|
|
39
72
|
throw new Error('`staff` is declared in attributeKeys, so pass an `attributesOf` that identifies staff to defineExperimentsServerRuntime');
|
|
40
73
|
}
|
|
74
|
+
if (!options.events.origin && !publicEventOrigin(payload.config.serverURL)) {
|
|
75
|
+
payload.logger.warn('Experiments: set events.origin or Payload serverURL to your public HTTP(S) origin without a path. Until then, browser events with Origin or Referer and without Fetch Metadata are dropped.');
|
|
76
|
+
}
|
|
41
77
|
};
|
|
42
78
|
}
|
package/dist/options.d.ts
CHANGED
|
@@ -9,3 +9,5 @@ export declare function resolveOptions<TUser extends {
|
|
|
9
9
|
}>(input: ExperimentsPluginOptions<TUser>): ResolvedOptions<TUser>;
|
|
10
10
|
/** One published-row rule shared by scans, bindings, writes and editor links. */
|
|
11
11
|
export declare function documentEditor(options: Pick<ExperimentsPluginOptions, 'puck' | 'blocks'>, collection: string, doc: Record<string, unknown>): 'puck' | 'blocks' | 'page';
|
|
12
|
+
export declare function hasPuckEditor(options: Pick<ExperimentsPluginOptions, 'puck'>, collection: string): boolean;
|
|
13
|
+
export declare function blockPageSlugs(options: Pick<ExperimentsPluginOptions, 'puck' | 'blocks'>): string[];
|
package/dist/options.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { validateAccent } from './ui/accent.js';
|
|
2
2
|
import { DEFAULT_MAX_BODY_BYTES } from './constants.js';
|
|
3
|
+
import { publicEventOrigin } from './events/request.js';
|
|
3
4
|
const normalisedCollections = new WeakMap();
|
|
4
5
|
/** Resolve once per registration list; every consumer shares the same field defaults. */ export function puckCollections(options) {
|
|
5
6
|
const entries = options.puck?.collections;
|
|
@@ -17,8 +18,13 @@ const normalisedCollections = new WeakMap();
|
|
|
17
18
|
normalisedCollections.set(resolved, resolved);
|
|
18
19
|
return resolved;
|
|
19
20
|
}
|
|
21
|
+
function enabledPuckCollections(options) {
|
|
22
|
+
return options.puck?.enabled === false ? [] : puckCollections(options);
|
|
23
|
+
}
|
|
20
24
|
export function resolveOptions(input) {
|
|
21
25
|
if (typeof input?.access?.manage !== 'function') throw new Error('Experiments access.manage must be a function');
|
|
26
|
+
const origin = publicEventOrigin(input.events?.origin);
|
|
27
|
+
if (input.events?.origin !== undefined && !origin) throw new Error('Experiments events.origin must be a public HTTP(S) origin with no path, query or credentials');
|
|
22
28
|
const { manage, admin = manage, readResults = manage, readIdentities = admin } = input.access;
|
|
23
29
|
for (const [name, access] of Object.entries({
|
|
24
30
|
admin,
|
|
@@ -79,6 +85,9 @@ export function resolveOptions(input) {
|
|
|
79
85
|
}
|
|
80
86
|
if (entry.copyUrl !== undefined && !validCopyUrl(entry.copyUrl)) throw new Error('Experiments copyUrl must be a root-relative path');
|
|
81
87
|
if (entry.copyLabel !== undefined && entry.copyUrl === undefined) throw new Error('Experiments copyLabel requires copyUrl');
|
|
88
|
+
if (entry.copy !== undefined && typeof entry.copy !== 'boolean' && (!entry.copy || typeof entry.copy !== 'object' || Array.isArray(entry.copy) || typeof entry.copy.overrides !== 'function')) {
|
|
89
|
+
throw new Error('Experiments pages.collections[].copy must be a boolean or an object with an overrides function');
|
|
90
|
+
}
|
|
82
91
|
slugs.add(entry.slug);
|
|
83
92
|
}
|
|
84
93
|
}
|
|
@@ -163,6 +172,8 @@ export function resolveOptions(input) {
|
|
|
163
172
|
])),
|
|
164
173
|
events: {
|
|
165
174
|
...input.events,
|
|
175
|
+
origin,
|
|
176
|
+
rateLimit: input.events?.rateLimit,
|
|
166
177
|
retentionDays,
|
|
167
178
|
maxBodyBytes,
|
|
168
179
|
dimensions: Array.isArray(dimensions) ? [
|
|
@@ -186,7 +197,17 @@ function validCopyUrl(value) {
|
|
|
186
197
|
}
|
|
187
198
|
/** One published-row rule shared by scans, bindings, writes and editor links. */ export function documentEditor(options, collection, doc) {
|
|
188
199
|
const block = options.blocks?.collections.find((entry)=>entry.slug === collection);
|
|
189
|
-
const puck = options.puck?.enabled !== false && puckCollections(options).some((entry)=>entry.slug === collection);
|
|
190
200
|
if (block && (block.appliesTo ? block.appliesTo(doc) : true)) return 'blocks';
|
|
191
|
-
return
|
|
201
|
+
return hasPuckEditor(options, collection) ? 'puck' : 'page';
|
|
202
|
+
}
|
|
203
|
+
export function hasPuckEditor(options, collection) {
|
|
204
|
+
return enabledPuckCollections(options).some((entry)=>entry.slug === collection);
|
|
205
|
+
}
|
|
206
|
+
export function blockPageSlugs(options) {
|
|
207
|
+
return [
|
|
208
|
+
...new Set([
|
|
209
|
+
...enabledPuckCollections(options),
|
|
210
|
+
...options.blocks?.collections ?? []
|
|
211
|
+
].map((entry)=>entry.slug))
|
|
212
|
+
];
|
|
192
213
|
}
|
package/dist/plugin.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { buildCollections } from './collections/index.js';
|
|
2
2
|
import { buildEndpoints } from './endpoints/index.js';
|
|
3
3
|
import { contentChangesBeforeHook, contentChangesHook } from './hooks/contentChanges.js';
|
|
4
|
-
import {
|
|
4
|
+
import { puckGoalsBeforeChange } from './hooks/puckGoals.js';
|
|
5
|
+
import { trackPageCopies } from './hooks/trackPageCopies.js';
|
|
6
|
+
import { pageGuardAfterChange, pageGuardAfterOperation, pageGuardEnterOperation, pageGuardBeforeChange, pageGuardBeforeDelete, pageGuardBeforeOperation } from './hooks/pageGuard.js';
|
|
5
7
|
import { createOnInit } from './onInit.js';
|
|
6
8
|
import { puckCollections, resolveOptions } from './options.js';
|
|
7
9
|
import { injectTestBlock } from './admin/blocks/inject.js';
|
|
@@ -23,8 +25,6 @@ export function createExperimentsPlugin(input) {
|
|
|
23
25
|
// Erase the user subtype only at this non-generic factory boundary.
|
|
24
26
|
const { collections, globals } = buildCollections(options);
|
|
25
27
|
const onInit = createOnInit(options);
|
|
26
|
-
const beforeDashboard = config.admin?.components?.beforeDashboard ?? [];
|
|
27
|
-
const beforeNavLinks = config.admin?.components?.beforeNavLinks ?? [];
|
|
28
28
|
return {
|
|
29
29
|
...config,
|
|
30
30
|
admin: {
|
|
@@ -34,10 +34,6 @@ export function createExperimentsPlugin(input) {
|
|
|
34
34
|
xpTestsSurface: {
|
|
35
35
|
path: paths.XP_TESTS_SURFACE,
|
|
36
36
|
type: 'component'
|
|
37
|
-
},
|
|
38
|
-
xpTestsNav: {
|
|
39
|
-
path: paths.XP_TESTS_NAV_CLIENT,
|
|
40
|
-
type: 'component'
|
|
41
37
|
}
|
|
42
38
|
},
|
|
43
39
|
components: {
|
|
@@ -48,21 +44,17 @@ export function createExperimentsPlugin(input) {
|
|
|
48
44
|
Component: paths.XP_TESTS_VIEW,
|
|
49
45
|
path: '/experiments/:segments*'
|
|
50
46
|
}
|
|
51
|
-
}
|
|
52
|
-
beforeDashboard: beforeDashboard.includes(paths.XP_TESTS_DASHBOARD_CARDS) ? beforeDashboard : [
|
|
53
|
-
...beforeDashboard,
|
|
54
|
-
paths.XP_TESTS_DASHBOARD_CARDS
|
|
55
|
-
],
|
|
56
|
-
beforeNavLinks: beforeNavLinks.includes(paths.XP_TESTS_NAV_LINK) ? beforeNavLinks : [
|
|
57
|
-
...beforeNavLinks,
|
|
58
|
-
paths.XP_TESTS_NAV_LINK
|
|
59
|
-
]
|
|
47
|
+
}
|
|
60
48
|
}
|
|
61
49
|
},
|
|
62
50
|
collections: [
|
|
51
|
+
...[
|
|
52
|
+
'xp-experiments',
|
|
53
|
+
'xp-metrics'
|
|
54
|
+
].map((slug)=>collections.find((collection)=>collection.slug === slug)),
|
|
63
55
|
...(config.collections ?? []).map((collection)=>{
|
|
64
|
-
const puck = options.puck?.enabled && registrations.
|
|
65
|
-
const page = options.pages?.collections.
|
|
56
|
+
const puck = options.puck?.enabled && registrations.find((entry)=>entry.slug === collection.slug);
|
|
57
|
+
const page = options.pages?.collections.find((entry)=>entry.slug === collection.slug);
|
|
66
58
|
const blocks = options.blocks?.collections.find((entry)=>entry.slug === collection.slug);
|
|
67
59
|
if (!puck && !page && !blocks) return collection;
|
|
68
60
|
return {
|
|
@@ -87,9 +79,13 @@ export function createExperimentsPlugin(input) {
|
|
|
87
79
|
beforeChange: [
|
|
88
80
|
...collection.hooks?.beforeChange ?? [],
|
|
89
81
|
pageGuardBeforeChange,
|
|
90
|
-
contentChangesBeforeHook
|
|
82
|
+
contentChangesBeforeHook,
|
|
83
|
+
...puck ? [
|
|
84
|
+
puckGoalsBeforeChange(puck.field)
|
|
85
|
+
] : []
|
|
91
86
|
],
|
|
92
87
|
beforeOperation: [
|
|
88
|
+
pageGuardEnterOperation,
|
|
93
89
|
...collection.hooks?.beforeOperation ?? [],
|
|
94
90
|
pageGuardBeforeOperation
|
|
95
91
|
],
|
|
@@ -102,6 +98,9 @@ export function createExperimentsPlugin(input) {
|
|
|
102
98
|
...collection.hooks?.afterOperation ?? []
|
|
103
99
|
],
|
|
104
100
|
afterChange: [
|
|
101
|
+
...page?.copy ? [
|
|
102
|
+
trackPageCopies
|
|
103
|
+
] : [],
|
|
105
104
|
...collection.hooks?.afterChange ?? [],
|
|
106
105
|
pageGuardAfterChange,
|
|
107
106
|
contentChangesHook
|
|
@@ -109,7 +108,7 @@ export function createExperimentsPlugin(input) {
|
|
|
109
108
|
}
|
|
110
109
|
};
|
|
111
110
|
}),
|
|
112
|
-
...collections
|
|
111
|
+
...collections.filter((collection)=>collection.slug !== 'xp-experiments' && collection.slug !== 'xp-metrics')
|
|
113
112
|
],
|
|
114
113
|
globals: [
|
|
115
114
|
...config.globals ?? [],
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { NextRequest } from 'next/server';
|
|
2
|
+
/** A document or an App Router navigation can mint the cookie for its own render. */
|
|
3
|
+
export declare function isPageNavigation({ method, headers }: NextRequest): boolean;
|
|
4
|
+
export declare function looksLikeNormalizedAppRouterRequest({ method, headers }: NextRequest): boolean;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** A document or an App Router navigation can mint the cookie for its own render. */ export function isPageNavigation({ method, headers }) {
|
|
2
|
+
if (method !== 'GET') return false;
|
|
3
|
+
if (headers.has('x-nextjs-data') || headers.has('next-router-prefetch') || headers.has('next-router-segment-prefetch') || headers.has('x-middleware-prefetch') || headers.has('next-hmr-refresh') || headers.get('next-test-fetch-priority') === 'low' || [
|
|
4
|
+
'purpose',
|
|
5
|
+
'sec-purpose',
|
|
6
|
+
'x-moz'
|
|
7
|
+
].some((name)=>/\b(?:prefetch|prerender)\b/i.test(headers.get(name) ?? ''))) return false;
|
|
8
|
+
const mode = headers.get('sec-fetch-mode');
|
|
9
|
+
const destination = headers.get('sec-fetch-dest');
|
|
10
|
+
if (headers.has('rsc')) {
|
|
11
|
+
// Next sends the router state on navigation and refresh. Explicit full prefetch can
|
|
12
|
+
// share this shape, so hosts must avoid full prefetch on routes covered by the proxy.
|
|
13
|
+
const site = headers.get('sec-fetch-site');
|
|
14
|
+
return headers.get('rsc') === '1' && Boolean(headers.get('next-router-state-tree')) && (mode === null || mode === 'cors' || mode === 'same-origin') && (destination === null || destination === 'empty') && (site === null || site === 'same-origin');
|
|
15
|
+
}
|
|
16
|
+
if (mode !== null && mode !== 'navigate') return false;
|
|
17
|
+
if (destination !== null) return destination === 'document';
|
|
18
|
+
// Older browsers still advertise HTML for a document navigation.
|
|
19
|
+
return (headers.get('accept') ?? '').split(',').some((value)=>{
|
|
20
|
+
const [type, ...params] = value.trim().toLowerCase().split(';');
|
|
21
|
+
return (type === 'text/html' || type === 'application/xhtml+xml') && !params.some((param)=>/^\s*q\s*=\s*0(?:\.0*)?\s*$/.test(param));
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
export function looksLikeNormalizedAppRouterRequest({ method, headers }) {
|
|
25
|
+
// Next-Url survives normalization when the App Router sends it for interception.
|
|
26
|
+
// Fetch Metadata and Accept alone also match ordinary same-origin fetches.
|
|
27
|
+
return method === 'GET' && !headers.has('rsc') && headers.get('next-url')?.startsWith('/') === true && headers.get('accept') === '*/*' && headers.get('sec-fetch-mode') === 'cors' && headers.get('sec-fetch-dest') === 'empty' && headers.get('sec-fetch-site') === 'same-origin';
|
|
28
|
+
}
|
package/dist/proxy/resolve.js
CHANGED
|
@@ -4,14 +4,17 @@ import { assign, fillFlagPoints } from '../runtime/assign.js';
|
|
|
4
4
|
import { sign } from '../runtime/signing.js';
|
|
5
5
|
import { requestAttributes } from '../runtime/normalisePath.js';
|
|
6
6
|
import { isBot } from '../runtime/bot.js';
|
|
7
|
-
import { cookieAttributes, encodeUnitCookie, mintUnitId,
|
|
7
|
+
import { cookieAttributes, encodeUnitCookie, mintUnitId, readSignedUnit, unitCookieMaxAgeMs } from '../runtime/cookie.js';
|
|
8
8
|
import { encodeAssignmentsHeader } from '../runtime/header.js';
|
|
9
9
|
import { verifyPreviewToken } from '../runtime/previewToken.js';
|
|
10
10
|
import { pageRewrite } from './pageRewrite.js';
|
|
11
11
|
import { skipPath } from './skip.js';
|
|
12
12
|
import { controlAssignments, emptyAssignments } from './control.js';
|
|
13
13
|
import { consentFallback } from './consentFallback.js';
|
|
14
|
+
import { isPageNavigation, looksLikeNormalizedAppRouterRequest } from './pageNavigation.js';
|
|
15
|
+
import { assertCookieOptions } from '../runtime/cookieOptions.js';
|
|
14
16
|
const caches = new WeakMap();
|
|
17
|
+
let warnedAboutUrlNormalization = false;
|
|
15
18
|
export async function resolveExperiments(request, proxyRuntime) {
|
|
16
19
|
const requestHeaders = new Headers(request.headers);
|
|
17
20
|
const result = {
|
|
@@ -23,38 +26,62 @@ export async function resolveExperiments(request, proxyRuntime) {
|
|
|
23
26
|
...requestHeaders.keys()
|
|
24
27
|
])if (name.startsWith('x-xp-')) requestHeaders.delete(name);
|
|
25
28
|
if (skipPath(request.nextUrl.pathname, proxyRuntime.apiRoute)) return result;
|
|
29
|
+
assertCookieOptions(proxyRuntime.cookie);
|
|
30
|
+
const name = proxyRuntime.cookie.name;
|
|
31
|
+
if (!warnedAboutUrlNormalization && !request.cookies.has(name) && looksLikeNormalizedAppRouterRequest(request)) {
|
|
32
|
+
warnedAboutUrlNormalization = true;
|
|
33
|
+
console.warn('[payload-experiments] Next.js may be stripping App Router headers. Set skipProxyUrlNormalize: true in your Next.js config. Without it, visitors who follow in-site links or continue after consent without a full page load wait until their next full page load to enroll in tests.');
|
|
34
|
+
}
|
|
35
|
+
const bot = isBot(request.headers.get('user-agent'));
|
|
26
36
|
let consent = false;
|
|
27
37
|
try {
|
|
28
38
|
consent = proxyRuntime.cookie.consent?.(request) !== false;
|
|
29
39
|
} catch {
|
|
30
40
|
console.error('[payload-experiments] consent failed; treating consent as false');
|
|
31
41
|
}
|
|
32
|
-
const
|
|
42
|
+
const nowMs = Date.now();
|
|
43
|
+
const signedUnit = consent ? readSignedUnit(request, proxyRuntime, nowMs) : null;
|
|
44
|
+
let visitorId = signedUnit?.unitId;
|
|
45
|
+
let cookieValue;
|
|
46
|
+
if (consent && !signedUnit && !bot && isPageNavigation(request)) {
|
|
47
|
+
try {
|
|
48
|
+
const limit = proxyRuntime.rateLimitUnit;
|
|
49
|
+
if (limit === false || await limit?.(request) === true) {
|
|
50
|
+
const id = mintUnitId();
|
|
51
|
+
cookieValue = encodeUnitCookie(id, proxyRuntime.secrets);
|
|
52
|
+
visitorId = id;
|
|
53
|
+
}
|
|
54
|
+
} catch {
|
|
55
|
+
console.error('[payload-experiments] visitor ID issuance failed');
|
|
56
|
+
}
|
|
57
|
+
} else if (signedUnit && (signedUnit.renewedAtMs === null || nowMs - signedUnit.renewedAtMs >= unitCookieMaxAgeMs(proxyRuntime) / 2)) {
|
|
58
|
+
cookieValue = encodeUnitCookie(signedUnit.unitId, proxyRuntime.secrets, signedUnit.issuedAtMs, nowMs);
|
|
59
|
+
}
|
|
60
|
+
// Consent applies to both unit types. Issuance only controls the visitor ID.
|
|
61
|
+
// Keep Next's Flight cache key out of the signed context and preserve the app's raw query.
|
|
62
|
+
const query = request.nextUrl.search.slice(1).split('&').filter((part)=>part !== '_rsc' && !part.startsWith('_rsc=')).join('&');
|
|
63
|
+
const requestPath = query ? `${request.nextUrl.pathname}?${query}` : request.nextUrl.pathname;
|
|
64
|
+
const requestContext = `${request.method}|${requestPath}|${consent ? 'c1' : 'c0'}`;
|
|
33
65
|
const signedContext = `${requestContext}|${sign(`xp:request:${requestContext}`, proxyRuntime.secrets)}`;
|
|
34
66
|
if (Buffer.byteLength(signedContext) <= 2048) requestHeaders.set(XP_REQUEST_HEADER, signedContext);
|
|
35
|
-
|
|
36
|
-
let visitorId = consent ? verifyUnitCookie(request.cookies.get(name)?.value, proxyRuntime.secrets) ?? undefined : undefined;
|
|
37
|
-
if (!consent) {
|
|
67
|
+
if (!visitorId || cookieValue) {
|
|
38
68
|
const cookies = (requestHeaders.get('cookie') ?? '').split(';').map((cookie)=>cookie.trim()).filter((cookie)=>cookie && cookie.split('=', 1)[0]?.trim() !== name);
|
|
69
|
+
if (cookieValue) {
|
|
70
|
+
result.requestCookies.push({
|
|
71
|
+
name,
|
|
72
|
+
value: cookieValue
|
|
73
|
+
});
|
|
74
|
+
result.setCookies.push({
|
|
75
|
+
name,
|
|
76
|
+
value: cookieValue,
|
|
77
|
+
...cookieAttributes(proxyRuntime, {
|
|
78
|
+
https: request.nextUrl.protocol === 'https:'
|
|
79
|
+
})
|
|
80
|
+
});
|
|
81
|
+
cookies.push(`${name}=${cookieValue}`);
|
|
82
|
+
}
|
|
39
83
|
if (cookies.length) requestHeaders.set('cookie', cookies.join('; '));
|
|
40
84
|
else requestHeaders.delete('cookie');
|
|
41
|
-
} else if (!visitorId) {
|
|
42
|
-
visitorId = mintUnitId();
|
|
43
|
-
const value = encodeUnitCookie(visitorId, proxyRuntime.secrets);
|
|
44
|
-
result.requestCookies.push({
|
|
45
|
-
name,
|
|
46
|
-
value
|
|
47
|
-
});
|
|
48
|
-
result.setCookies.push({
|
|
49
|
-
name,
|
|
50
|
-
value,
|
|
51
|
-
...cookieAttributes(proxyRuntime, {
|
|
52
|
-
https: request.nextUrl.protocol === 'https:'
|
|
53
|
-
})
|
|
54
|
-
});
|
|
55
|
-
const cookies = (request.headers.get('cookie') ?? '').split(';').map((cookie)=>cookie.trim()).filter((cookie)=>cookie && cookie.split('=', 1)[0] !== name);
|
|
56
|
-
cookies.push(`${name}=${value}`);
|
|
57
|
-
requestHeaders.set('cookie', cookies.join('; '));
|
|
58
85
|
}
|
|
59
86
|
let resolvedUnit = {
|
|
60
87
|
attributes: {}
|
|
@@ -92,7 +119,7 @@ export async function resolveExperiments(request, proxyRuntime) {
|
|
|
92
119
|
visitorId,
|
|
93
120
|
userId,
|
|
94
121
|
staff: attributes.staff === true,
|
|
95
|
-
bot
|
|
122
|
+
bot,
|
|
96
123
|
preview: Boolean(previewExperiment),
|
|
97
124
|
sessionUnknown: sessionUnknown ?? false,
|
|
98
125
|
method: request.method
|
|
@@ -103,7 +130,7 @@ export async function resolveExperiments(request, proxyRuntime) {
|
|
|
103
130
|
try {
|
|
104
131
|
assignments = consentFallback(currentManifest, attributes, context);
|
|
105
132
|
} catch {
|
|
106
|
-
console.error('[payload-experiments]
|
|
133
|
+
console.error('[payload-experiments] identity-free fallback failed; serving non-exposable control');
|
|
107
134
|
assignmentFailed = true;
|
|
108
135
|
try {
|
|
109
136
|
assignments = controlAssignments(currentManifest, context);
|
|
@@ -132,7 +159,7 @@ export async function resolveExperiments(request, proxyRuntime) {
|
|
|
132
159
|
}
|
|
133
160
|
}
|
|
134
161
|
if (previewExperiment && token) {
|
|
135
|
-
if (
|
|
162
|
+
if (visitorId && !assignmentFailed) {
|
|
136
163
|
assignments.deferred = assignments.deferred.filter((slug)=>slug !== previewExperiment.slug);
|
|
137
164
|
assignments.bySlug[previewExperiment.slug] = {
|
|
138
165
|
slug: previewExperiment.slug,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ExperimentRef } from '../types/puck.js';
|
|
2
|
-
export declare function ExperimentPicker({ value, onChange }: {
|
|
2
|
+
export declare function ExperimentPicker({ value, onChange, allowEmpty }: {
|
|
3
|
+
allowEmpty?: boolean;
|
|
3
4
|
value: ExperimentRef | null;
|
|
4
5
|
onChange: (value: ExperimentRef | null) => void;
|
|
5
6
|
}): import("react").JSX.Element;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { SelectControl } from '../ui/SelectControl.js';
|
|
3
4
|
import { useEffect, useId, useState } from 'react';
|
|
4
5
|
import { fetchAllDocs } from '../lib/fetchAllDocs.js';
|
|
5
6
|
import { usePuckRoutes } from './hostContext.js';
|
|
@@ -9,7 +10,7 @@ function isExperimentOption(value) {
|
|
|
9
10
|
const doc = value;
|
|
10
11
|
return (typeof doc.id === 'string' || typeof doc.id === 'number') && typeof doc.slug === 'string' && typeof doc.name === 'string' && typeof doc.status === 'string' && Object.hasOwn(pickerCopy.statuses, doc.status);
|
|
11
12
|
}
|
|
12
|
-
export function ExperimentPicker({ value, onChange }) {
|
|
13
|
+
export function ExperimentPicker({ value, onChange, allowEmpty = true }) {
|
|
13
14
|
const { api } = usePuckRoutes();
|
|
14
15
|
const id = useId();
|
|
15
16
|
const [experiments, setExperiments] = useState([]);
|
|
@@ -26,7 +27,7 @@ export function ExperimentPicker({ value, onChange }) {
|
|
|
26
27
|
});
|
|
27
28
|
if (!active) return;
|
|
28
29
|
if (!response.ok) {
|
|
29
|
-
setState(response.status === 403 ? 'forbidden' : 'error');
|
|
30
|
+
setState(response.status === 401 || response.status === 403 ? 'forbidden' : 'error');
|
|
30
31
|
return;
|
|
31
32
|
}
|
|
32
33
|
setExperiments(response.docs.filter(isExperimentOption).sort((a, b)=>(Date.parse(b.updatedAt ?? '') || 0) - (Date.parse(a.updatedAt ?? '') || 0)));
|
|
@@ -46,6 +47,29 @@ export function ExperimentPicker({ value, onChange }) {
|
|
|
46
47
|
const selected = value ? String(value.id) : '';
|
|
47
48
|
const query = search.trim().toLocaleLowerCase('en-US');
|
|
48
49
|
const visible = experiments.filter((doc)=>String(doc.id) === selected || doc.name.toLocaleLowerCase('en-US').includes(query) || doc.slug.toLocaleLowerCase('en-US').includes(query));
|
|
50
|
+
if (state === 'loading') return /*#__PURE__*/ _jsxs("div", {
|
|
51
|
+
className: "xp-ui-field",
|
|
52
|
+
children: [
|
|
53
|
+
/*#__PURE__*/ _jsx("span", {
|
|
54
|
+
children: pickerCopy.label
|
|
55
|
+
}),
|
|
56
|
+
/*#__PURE__*/ _jsx("p", {
|
|
57
|
+
role: "status",
|
|
58
|
+
children: pickerCopy.loading
|
|
59
|
+
})
|
|
60
|
+
]
|
|
61
|
+
});
|
|
62
|
+
if (state === 'forbidden') return /*#__PURE__*/ _jsxs("div", {
|
|
63
|
+
className: "xp-ui-field",
|
|
64
|
+
children: [
|
|
65
|
+
/*#__PURE__*/ _jsx("span", {
|
|
66
|
+
children: pickerCopy.label
|
|
67
|
+
}),
|
|
68
|
+
/*#__PURE__*/ _jsx("p", {
|
|
69
|
+
children: value ? pickerCopy.forbidden : pickerCopy.forbiddenUnbound
|
|
70
|
+
})
|
|
71
|
+
]
|
|
72
|
+
});
|
|
49
73
|
return /*#__PURE__*/ _jsxs("div", {
|
|
50
74
|
className: "xp-ui-field",
|
|
51
75
|
children: [
|
|
@@ -65,49 +89,47 @@ export function ExperimentPicker({ value, onChange }) {
|
|
|
65
89
|
})
|
|
66
90
|
]
|
|
67
91
|
}) : null,
|
|
68
|
-
/*#__PURE__*/
|
|
69
|
-
|
|
70
|
-
children: pickerCopy.label
|
|
71
|
-
}),
|
|
72
|
-
/*#__PURE__*/ _jsxs("select", {
|
|
73
|
-
id: id,
|
|
74
|
-
className: "xp-ui-input xp-ui-select",
|
|
75
|
-
value: selected,
|
|
76
|
-
disabled: state === 'loading',
|
|
77
|
-
onChange: (event)=>{
|
|
78
|
-
const experiment = experiments.find((doc)=>String(doc.id) === event.currentTarget.value);
|
|
79
|
-
onChange(experiment ? {
|
|
80
|
-
id: experiment.id,
|
|
81
|
-
slug: experiment.slug
|
|
82
|
-
} : null);
|
|
83
|
-
},
|
|
92
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
93
|
+
className: "xp-ui-field",
|
|
84
94
|
children: [
|
|
85
|
-
/*#__PURE__*/ _jsx("
|
|
86
|
-
|
|
87
|
-
|
|
95
|
+
/*#__PURE__*/ _jsx("label", {
|
|
96
|
+
id: `${id}-label`,
|
|
97
|
+
htmlFor: id,
|
|
98
|
+
children: pickerCopy.label
|
|
88
99
|
}),
|
|
89
|
-
|
|
100
|
+
/*#__PURE__*/ _jsxs(SelectControl, {
|
|
101
|
+
id: id,
|
|
90
102
|
value: selected,
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
103
|
+
onChange: (event)=>{
|
|
104
|
+
const experiment = experiments.find((doc)=>String(doc.id) === event.currentTarget.value);
|
|
105
|
+
if (experiment || allowEmpty) onChange(experiment ? {
|
|
106
|
+
id: experiment.id,
|
|
107
|
+
slug: experiment.slug
|
|
108
|
+
} : null);
|
|
109
|
+
},
|
|
110
|
+
children: [
|
|
111
|
+
/*#__PURE__*/ _jsx("option", {
|
|
112
|
+
value: "",
|
|
113
|
+
disabled: !allowEmpty,
|
|
114
|
+
children: allowEmpty ? pickerCopy.none : pickerCopy.choose
|
|
115
|
+
}),
|
|
116
|
+
value && !experiments.some((doc)=>String(doc.id) === selected) ? /*#__PURE__*/ _jsx("option", {
|
|
117
|
+
value: selected,
|
|
118
|
+
children: value.slug
|
|
119
|
+
}) : null,
|
|
120
|
+
visible.map((doc)=>/*#__PURE__*/ _jsxs("option", {
|
|
121
|
+
value: String(doc.id),
|
|
122
|
+
children: [
|
|
123
|
+
doc.name,
|
|
124
|
+
" · ",
|
|
125
|
+
pickerCopy.statuses[doc.status]
|
|
126
|
+
]
|
|
127
|
+
}, doc.id))
|
|
128
|
+
]
|
|
129
|
+
})
|
|
101
130
|
]
|
|
102
131
|
}),
|
|
103
|
-
state === '
|
|
104
|
-
className: "xp-ui-banner",
|
|
105
|
-
role: "status",
|
|
106
|
-
children: /*#__PURE__*/ _jsx("p", {
|
|
107
|
-
children: pickerCopy.loading
|
|
108
|
-
})
|
|
109
|
-
}) : null,
|
|
110
|
-
state === 'error' || state === 'forbidden' ? /*#__PURE__*/ _jsx("div", {
|
|
132
|
+
state === 'error' ? /*#__PURE__*/ _jsx("div", {
|
|
111
133
|
className: "xp-ui-banner xp-ui-banner--error",
|
|
112
134
|
role: "alert",
|
|
113
135
|
children: /*#__PURE__*/ _jsx("p", {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { fullyHidden } from './visibility.js';
|
|
2
3
|
import { ViewportExposure } from '../client/ViewportExposure.js';
|
|
3
4
|
import { experimentSlotDefaultProps, experimentSlotFields, experimentSlotLabel } from './slotConfig.js';
|
|
4
5
|
import { createExperimentSlotField } from './experimentSlotField.js';
|
|
@@ -16,6 +17,7 @@ export function createExperimentSlot({ routes: inputRoutes } = {}) {
|
|
|
16
17
|
},
|
|
17
18
|
defaultProps: experimentSlotDefaultProps,
|
|
18
19
|
render: (props)=>{
|
|
20
|
+
if (fullyHidden(props._visibility)) return /*#__PURE__*/ _jsx(_Fragment, {});
|
|
19
21
|
const Slot = props[slotToRender(props)];
|
|
20
22
|
return /*#__PURE__*/ _jsx(ViewportExposure, {
|
|
21
23
|
expose: props.xpExpose,
|
package/dist/puck/copy.d.ts
CHANGED
|
@@ -8,10 +8,14 @@ export declare const slotLabels: {
|
|
|
8
8
|
export declare const pickerCopy: {
|
|
9
9
|
readonly label: "Test";
|
|
10
10
|
readonly none: "No test";
|
|
11
|
+
readonly choose: "Choose a test";
|
|
11
12
|
readonly search: "Search tests";
|
|
12
13
|
readonly loading: "Loading tests…";
|
|
13
14
|
readonly error: "Couldn't load tests.";
|
|
14
|
-
readonly forbidden: "You
|
|
15
|
+
readonly forbidden: "You don't have access to this test. You can still edit its content.";
|
|
16
|
+
readonly forbiddenUnbound: "You don't have access to tests.";
|
|
17
|
+
readonly unavailable: "This test isn't available to you. You can still edit its content.";
|
|
18
|
+
readonly resultsOnly: "You can view this test's results.";
|
|
15
19
|
readonly statuses: {
|
|
16
20
|
readonly draft: "Draft";
|
|
17
21
|
readonly running: "Running";
|