@delmaredigital/payload-experiments 0.3.0-rc.4 → 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 +293 -688
- package/dist/admin/LayerUsage.js +1 -1
- package/dist/admin/MetricSourceSelect.js +4 -4
- package/dist/admin/PlacementStatus.d.ts +3 -0
- package/dist/admin/PlacementStatus.js +54 -0
- 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 +5 -0
- package/dist/admin/blocks/BlockPanel.js +245 -0
- package/dist/admin/blocks/TestBlockField.d.ts +5 -0
- package/dist/admin/blocks/TestBlockField.js +163 -0
- package/dist/admin/blocks/formApi.d.ts +46 -0
- package/dist/admin/blocks/formApi.js +159 -0
- package/dist/admin/blocks/inject.d.ts +7 -0
- package/dist/admin/blocks/inject.js +42 -0
- package/dist/admin/blocks/model.d.ts +18 -0
- package/dist/admin/blocks/model.js +49 -0
- package/dist/admin/blocks/statusCache.d.ts +9 -0
- package/dist/admin/blocks/statusCache.js +92 -0
- package/dist/admin/blocks/useBlockForm.d.ts +17 -0
- package/dist/admin/blocks/useBlockForm.js +46 -0
- package/dist/admin/components/RootViewMessage.js +1 -1
- package/dist/admin/copy/blocks.d.ts +47 -0
- package/dist/admin/copy/blocks.js +72 -0
- package/dist/admin/copy/goals.d.ts +8 -1
- package/dist/admin/copy/goals.js +14 -4
- package/dist/admin/copy/newTest.d.ts +13 -4
- package/dist/admin/copy/newTest.js +16 -4
- package/dist/admin/goals/XpGoalField.d.ts +4 -0
- package/dist/admin/goals/XpGoalField.js +194 -0
- package/dist/admin/goals/xpGoalField.css +47 -0
- package/dist/admin/pageCollections.d.ts +11 -0
- package/dist/admin/pageCollections.js +23 -0
- package/dist/admin/paths.d.ts +9 -0
- package/dist/admin/paths.js +9 -0
- package/dist/admin/placementStatus.model.d.ts +2 -0
- package/dist/admin/placementStatus.model.js +19 -0
- 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 +298 -59
- package/dist/admin/surface/TestsSurface.js +13 -8
- package/dist/admin/surface/goals/GoalForm.d.ts +1 -1
- package/dist/admin/surface/goals/GoalForm.js +159 -85
- package/dist/admin/surface/goals/GoalsList.d.ts +1 -1
- package/dist/admin/surface/goals/GoalsList.js +7 -6
- package/dist/admin/surface/goals/data.js +6 -3
- package/dist/admin/surface/goals/goals.css +7 -0
- package/dist/admin/surface/goals/goals.model.d.ts +12 -3
- package/dist/admin/surface/goals/goals.model.js +43 -2
- package/dist/admin/surface/home.model.d.ts +9 -8
- package/dist/admin/surface/home.model.js +28 -23
- package/dist/admin/surface/newTest/NewTest.d.ts +4 -4
- package/dist/admin/surface/newTest/NewTest.js +146 -101
- package/dist/admin/surface/newTest/PageWizard.d.ts +8 -0
- package/dist/admin/surface/newTest/PageWizard.js +244 -0
- 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 -57
- 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 -161
- 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 +28 -133
- 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.d.ts +3 -0
- package/dist/blocks/bindings.js +28 -0
- package/dist/blocks/createExperimentBlock.d.ts +6 -0
- package/dist/blocks/createExperimentBlock.js +77 -0
- package/dist/blocks/formState.d.ts +31 -0
- package/dist/blocks/formState.js +146 -0
- package/dist/blocks/model.d.ts +41 -0
- package/dist/blocks/model.js +34 -0
- 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/client/ExperimentGroup.d.ts +6 -0
- package/dist/client/ExperimentGroup.js +9 -0
- package/dist/client/ExperimentsProvider.js +20 -4
- package/dist/client/clickGoals.d.ts +4 -0
- package/dist/client/clickGoals.js +43 -0
- package/dist/collections/experiments/config.js +29 -10
- package/dist/collections/experiments/deleteGuard.d.ts +2 -1
- package/dist/collections/experiments/deleteGuard.js +14 -3
- package/dist/collections/experiments/editability.js +4 -2
- package/dist/collections/experiments/lockHook.js +21 -2
- package/dist/collections/experiments/pickSlug.d.ts +2 -0
- package/dist/collections/experiments/pickSlug.js +10 -0
- package/dist/collections/labels.d.ts +3 -0
- package/dist/collections/labels.js +20 -0
- package/dist/collections/metrics.js +28 -6
- package/dist/collections/metricsGuards.js +2 -0
- package/dist/collections/phases.js +1 -0
- package/dist/collections/serialize.js +12 -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/clickGoals.d.ts +9 -0
- package/dist/db/clickGoals.js +22 -0
- package/dist/db/delete.d.ts +2 -1
- package/dist/db/delete.js +3 -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/locks.d.ts +8 -0
- package/dist/db/locks.js +27 -4
- package/dist/db/names.d.ts +4 -0
- package/dist/db/names.js +4 -0
- package/dist/db/pageBindings.d.ts +4 -0
- package/dist/db/pageBindings.js +17 -0
- package/dist/db/pageBusy.d.ts +2 -0
- package/dist/db/pageBusy.js +10 -0
- package/dist/db/pageContent.d.ts +10 -0
- package/dist/db/pageContent.js +79 -0
- package/dist/db/pageCopies.d.ts +5 -0
- package/dist/db/pageCopies.js +31 -0
- package/dist/db/placements.d.ts +35 -0
- package/dist/db/placements.js +62 -0
- package/dist/db/results.d.ts +5 -1
- package/dist/db/results.js +21 -5
- package/dist/db/slugs.d.ts +8 -0
- package/dist/db/slugs.js +40 -0
- package/dist/db/snapshots.d.ts +7 -0
- package/dist/db/snapshots.js +8 -5
- package/dist/endpoints/clickKeys.d.ts +5 -0
- package/dist/endpoints/clickKeys.js +17 -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 +106 -39
- package/dist/endpoints/index.js +85 -9
- package/dist/endpoints/pages.d.ts +5 -0
- package/dist/endpoints/pages.js +303 -0
- package/dist/endpoints/placementStatus.d.ts +6 -0
- package/dist/endpoints/placementStatus.js +246 -0
- package/dist/endpoints/preflight.d.ts +1 -1
- package/dist/endpoints/preflight.js +17 -2
- package/dist/endpoints/readBody.d.ts +2 -0
- package/dist/endpoints/readBody.js +24 -0
- package/dist/endpoints/results.d.ts +1 -1
- package/dist/endpoints/results.js +10 -2
- package/dist/endpoints/routeId.d.ts +2 -2
- package/dist/endpoints/routeId.js +11 -5
- package/dist/endpoints/summary.js +46 -5
- package/dist/endpoints/testVersion.d.ts +2 -0
- package/dist/endpoints/testVersion.js +38 -0
- package/dist/endpoints/transitions.js +41 -29
- package/dist/endpoints/wrapBlock.d.ts +6 -0
- package/dist/endpoints/wrapBlock.js +76 -0
- package/dist/errors.d.ts +7 -2
- package/dist/errors.js +11 -3
- 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 +25 -7
- package/dist/events/writable.d.ts +9 -0
- package/dist/events/writable.js +13 -0
- package/dist/exports/adminClient.d.ts +6 -1
- package/dist/exports/adminClient.js +6 -1
- package/dist/exports/adminRsc.d.ts +3 -0
- package/dist/exports/adminRsc.js +3 -0
- package/dist/exports/blocks.d.ts +2 -0
- package/dist/exports/blocks.js +1 -0
- package/dist/exports/client.d.ts +1 -0
- package/dist/exports/client.js +1 -0
- package/dist/exports/index.d.ts +6 -1
- package/dist/exports/index.js +3 -0
- package/dist/exports/puck.d.ts +3 -1
- package/dist/exports/puck.js +2 -0
- package/dist/exports/puckEditor.d.ts +3 -0
- package/dist/exports/puckEditor.js +2 -0
- package/dist/exports/rsc.d.ts +4 -0
- package/dist/exports/rsc.js +3 -0
- package/dist/fields/xpGoal.d.ts +3 -0
- package/dist/fields/xpGoal.js +16 -0
- package/dist/globals/state.js +10 -0
- package/dist/goals/cache.d.ts +3 -0
- package/dist/goals/cache.js +35 -0
- package/dist/goals/fairness.d.ts +40 -0
- package/dist/goals/fairness.js +209 -0
- package/dist/goals/key.d.ts +4 -0
- package/dist/goals/key.js +3 -0
- package/dist/goals/picker/clickGoalPicker.model.d.ts +36 -0
- package/dist/goals/picker/clickGoalPicker.model.js +63 -0
- package/dist/goals/picker/copy.d.ts +20 -0
- package/dist/goals/picker/copy.js +24 -0
- package/dist/goals/picker/useClickGoalPicker.d.ts +30 -0
- package/dist/goals/picker/useClickGoalPicker.js +222 -0
- package/dist/goals/validate.d.ts +3 -0
- package/dist/goals/validate.js +15 -0
- package/dist/hooks/blockRemovalRule.d.ts +30 -0
- package/dist/hooks/blockRemovalRule.js +165 -0
- package/dist/hooks/hostHook.js +6 -2
- package/dist/hooks/pageGuard.d.ts +30 -1
- package/dist/hooks/pageGuard.js +337 -107
- 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 +65 -0
- package/dist/options.d.ts +4 -0
- package/dist/options.js +62 -1
- package/dist/plugin.js +56 -44
- 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 +6 -1
- package/dist/puck/copy.js +6 -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 +192 -19
- package/dist/puck/editor/editor.css +329 -24
- package/dist/puck/editor/editor.model.d.ts +21 -3
- package/dist/puck/editor/editor.model.js +67 -7
- 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/integration.d.ts +10 -0
- package/dist/puck/editor/integration.js +30 -0
- 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.d.ts +7 -0
- package/dist/puck/editor/xpGoalPuckEditorField.js +153 -0
- 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/integration.d.ts +6 -0
- package/dist/puck/integration.js +21 -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/puck/xpGoalField.d.ts +3 -0
- package/dist/puck/xpGoalField.js +6 -0
- package/dist/results/aggregate.d.ts +6 -3
- package/dist/results/aggregate.js +9 -9
- package/dist/results/health.d.ts +12 -0
- package/dist/results/health.js +55 -0
- package/dist/results/identityCredit.d.ts +1 -0
- package/dist/results/identityCredit.js +4 -1
- package/dist/results/snapshot.js +15 -2
- 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 +63 -2
- package/dist/server/getAssignments.js +11 -10
- package/dist/server/pageKindSeoContract.d.ts +27 -0
- package/dist/server/pageKindSeoContract.js +80 -0
- package/dist/server/recordContentChange.d.ts +1 -1
- package/dist/server/recordContentChange.js +88 -12
- package/dist/server/resolveExperimentBlocks.d.ts +5 -0
- package/dist/server/resolveExperimentBlocks.js +52 -0
- package/dist/server/resolveExperimentData.js +8 -8
- package/dist/server/runResults.js +104 -25
- package/dist/server/startExperiment.d.ts +20 -0
- package/dist/server/startExperiment.js +70 -0
- package/dist/server/toClientAssignments.js +2 -1
- package/dist/server/trackConversion.js +10 -13
- package/dist/{admin → testSurface}/PreviewLinks.d.ts +2 -1
- package/dist/{admin → testSurface}/PreviewLinks.js +8 -4
- package/dist/testSurface/actions/DecideDialog.d.ts +16 -0
- package/dist/{admin → testSurface}/actions/DecideDialog.js +79 -56
- 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/testSurface/api.d.ts +60 -0
- package/dist/testSurface/api.js +167 -0
- package/dist/testSurface/contentLocaleURL.d.ts +2 -0
- package/dist/testSurface/contentLocaleURL.js +3 -0
- package/dist/{admin → testSurface}/copy/actions.d.ts +30 -8
- package/dist/{admin → testSurface}/copy/actions.js +40 -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 +59 -6
- package/dist/testSurface/copy/readiness.js +136 -0
- package/dist/{admin → testSurface}/copy/results.d.ts +7 -3
- package/dist/{admin → testSurface}/copy/results.js +7 -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 +56 -7
- 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/{admin → testSurface}/metricSource.model.d.ts +2 -0
- package/dist/{admin → testSurface}/metricSource.model.js +4 -0
- package/dist/testSurface/placementLabel.d.ts +8 -0
- package/dist/testSurface/placementLabel.js +24 -0
- package/dist/testSurface/placements/placementLabels.d.ts +13 -0
- package/dist/testSurface/placements/placementLabels.js +22 -0
- package/dist/testSurface/placements/placementLabels.model.d.ts +13 -0
- package/dist/testSurface/placements/placementLabels.model.js +12 -0
- package/dist/testSurface/placements/usePlacementLabels.d.ts +12 -0
- package/dist/testSurface/placements/usePlacementLabels.js +102 -0
- 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/DataQualityPanel.js +4 -1
- package/dist/{admin → testSurface}/results/VerdictHero.d.ts +2 -1
- package/dist/{admin → testSurface}/results/VerdictHero.js +5 -1
- package/dist/testSurface/results/results.css +64 -0
- package/dist/{admin → testSurface}/results/results.model.d.ts +3 -0
- package/dist/{admin → testSurface}/results/results.model.js +14 -6
- package/dist/{admin → testSurface}/surface/contracts.d.ts +23 -8
- 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/testSurface/surface/pagePicker/pagePicker.model.d.ts +29 -0
- package/dist/testSurface/surface/pagePicker/pagePicker.model.js +40 -0
- 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/testSurface/surface/readiness/readiness.model.d.ts +57 -0
- 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/testSurface/surface/results/ReleasePages.d.ts +19 -0
- package/dist/{admin → testSurface}/surface/results/ReleasePages.js +43 -47
- package/dist/{admin → testSurface}/surface/results/ResultsBody.d.ts +7 -3
- package/dist/{admin → testSurface}/surface/results/ResultsBody.js +129 -46
- package/dist/{admin → testSurface}/surface/results/useResults.d.ts +36 -9
- 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/testSurface/surface/test/AdvancedSection.js +169 -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/testSurface/surface/test/GoalSection.js +341 -0
- package/dist/testSurface/surface/test/LengthSection.d.ts +2 -0
- package/dist/{admin → testSurface}/surface/test/LengthSection.js +6 -2
- package/dist/testSurface/surface/test/PageHoldout.d.ts +3 -0
- package/dist/testSurface/surface/test/PageHoldout.js +70 -0
- 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 +81 -40
- package/dist/{admin → testSurface}/surface/test/fields.d.ts +40 -8
- package/dist/testSurface/surface/test/fields.js +306 -0
- package/dist/{admin → testSurface}/surface/test/jumpToSection.d.ts +1 -1
- package/dist/{admin → testSurface}/surface/test/jumpToSection.js +4 -3
- package/dist/testSurface/surface/test/pageParts.d.ts +5 -0
- package/dist/testSurface/surface/test/pageParts.js +106 -0
- 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 +4 -0
- package/dist/{admin → testSurface}/surface/testDocument.model.js +6 -2
- 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/testSurface/useApi.d.ts +60 -0
- package/dist/testSurface/useApi.js +8 -0
- 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 +4 -6
- package/dist/transitions/addMetric.js +33 -2
- 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 +18 -1
- package/dist/transitions/checkStart.js +207 -9
- package/dist/transitions/contentFields.js +9 -5
- package/dist/transitions/decide.d.ts +1 -1
- package/dist/transitions/decide.js +30 -3
- package/dist/transitions/deleteExperiment.d.ts +5 -3
- package/dist/transitions/deleteExperiment.js +43 -7
- package/dist/transitions/kernel.d.ts +4 -0
- package/dist/transitions/kernel.js +13 -4
- package/dist/transitions/makeContent.d.ts +7 -1
- package/dist/transitions/makeContent.js +74 -22
- 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/pageCollection.d.ts +10 -0
- package/dist/transitions/pageCollection.js +20 -0
- package/dist/transitions/pageVersions.d.ts +10 -0
- package/dist/transitions/pageVersions.js +46 -0
- package/dist/transitions/phaseRecord.d.ts +3 -0
- package/dist/transitions/phaseRecord.js +5 -0
- package/dist/transitions/placementInteractions.d.ts +40 -0
- package/dist/transitions/placementInteractions.js +98 -0
- package/dist/transitions/placements.d.ts +58 -4
- package/dist/transitions/placements.js +391 -21
- package/dist/transitions/preflightData.d.ts +7 -5
- package/dist/transitions/preflightData.js +269 -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 +3 -4
- package/dist/transitions/resolveCaps.js +6 -2
- package/dist/transitions/start.d.ts +6 -8
- package/dist/transitions/start.js +112 -31
- 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/admin.d.ts +1 -1
- package/dist/types/assignments.d.ts +1 -0
- package/dist/types/contracts.d.ts +30 -3
- package/dist/types/endpoints.d.ts +204 -13
- package/dist/types/index.d.ts +3 -0
- package/dist/types/puck.d.ts +8 -1
- package/dist/types/runtime.d.ts +15 -9
- package/dist/types/snapshot.d.ts +19 -4
- package/dist/types/surface.d.ts +20 -7
- 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 +9 -1
- package/dist/admin/actions/ConfirmDialog.d.ts +0 -18
- package/dist/admin/actions/ConfirmDialog.js +0 -149
- package/dist/admin/actions/DecideDialog.d.ts +0 -9
- package/dist/admin/actions/actions.model.js +0 -70
- package/dist/admin/api.d.ts +0 -38
- package/dist/admin/api.js +0 -99
- package/dist/admin/copy/readiness.js +0 -71
- package/dist/admin/copy/testPage.js +0 -100
- 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/readiness/ActionDialogs.js +0 -302
- package/dist/admin/surface/readiness/Banner.js +0 -166
- 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.d.ts +0 -24
- package/dist/admin/surface/readiness/readiness.model.js +0 -123
- package/dist/admin/surface/readiness/useTransition.d.ts +0 -11
- package/dist/admin/surface/readiness/useTransition.js +0 -35
- package/dist/admin/surface/results/ReleasePages.d.ts +0 -14
- package/dist/admin/surface/setting/setting.css +0 -17
- package/dist/admin/surface/test/AdvancedSection.js +0 -160
- package/dist/admin/surface/test/GoalSection.d.ts +0 -2
- package/dist/admin/surface/test/GoalSection.js +0 -228
- 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 -184
- package/dist/admin/surface/test/pageParts.d.ts +0 -2
- package/dist/admin/surface/test/pageParts.js +0 -45
- package/dist/admin/surface/test/testPage.css +0 -90
- package/dist/admin/surface/useTestDocument.d.ts +0 -23
- package/dist/admin/surface/useTestDocument.js +0 -377
- package/dist/admin/useApi.d.ts +0 -35
- package/dist/admin/useApi.js +0 -10
- /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}/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/DataTable.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/DataTable.js +0 -0
- /package/dist/{admin → testSurface}/results/StatTile.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/StatTile.js +0 -0
- /package/dist/{admin → testSurface}/results/chart.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/chart.model.js +0 -0
- /package/dist/{admin → testSurface}/results/format.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/format.js +0 -0
- /package/dist/{admin → testSurface}/results/legacy.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/legacy.js +0 -0
- /package/dist/{admin → testSurface}/results/releasePages.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/releasePages.model.js +0 -0
- /package/dist/{admin → testSurface}/results/snapshot.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/snapshot.js +0 -0
- /package/dist/{admin → testSurface}/review/review.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/review/review.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/contracts.js +0 -0
- /package/dist/{admin → testSurface}/surface/pageBlock/pageBlock.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/pageBlock/parts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/parts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/results/recommendation.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/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/Rail.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/TargetingSection.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
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** Localized responses are already grouped by the server. Legacy single-language
|
|
2
|
+
* responses contain occurrences; preserve their page grouping and version counts. */ export function placementPages(placements, flagPoint) {
|
|
3
|
+
if (placements.some((placement)=>placement.allLocales || placement.locales?.length)) {
|
|
4
|
+
return placements.map((placement, index)=>({
|
|
5
|
+
...placement,
|
|
6
|
+
key: String(index),
|
|
7
|
+
slotCount: placement.slotCount ?? 1
|
|
8
|
+
}));
|
|
9
|
+
}
|
|
2
10
|
const pages = new Map();
|
|
3
11
|
for (const [index, placement] of placements.entries()){
|
|
4
12
|
const key = `${placement.collection}\u0000${String(placement.id)}${placement.collection === flagPoint ? `\u0000${index}` : ''}`;
|
|
@@ -15,7 +23,7 @@
|
|
|
15
23
|
page: {
|
|
16
24
|
...placement,
|
|
17
25
|
key,
|
|
18
|
-
slotCount: 1
|
|
26
|
+
slotCount: placement.slotCount ?? 1
|
|
19
27
|
},
|
|
20
28
|
versions: new Map([
|
|
21
29
|
[
|
|
@@ -30,6 +38,3 @@
|
|
|
30
38
|
...pages.values()
|
|
31
39
|
].map(({ page })=>page);
|
|
32
40
|
}
|
|
33
|
-
/** Pages that offer something to do: a preview or an editor link. The section is hidden when none do. */ export function actionablePreviewPages(placements, flagPoint) {
|
|
34
|
-
return previewPages(placements, flagPoint).filter((page)=>page.url || page.editorUrl);
|
|
35
|
-
}
|
|
@@ -46,9 +46,10 @@ export interface ManifestInputs {
|
|
|
46
46
|
excludeIds?: DocId[];
|
|
47
47
|
pruneFlagDefaultIds?: DocId[];
|
|
48
48
|
}
|
|
49
|
-
export declare function loadManifestInputs(req: PayloadRequest, { excludeIds, pruneFlagDefaultIds }?: {
|
|
49
|
+
export declare function loadManifestInputs(req: PayloadRequest, { excludeIds, pruneFlagDefaultIds, signal }?: {
|
|
50
50
|
excludeIds?: DocId[];
|
|
51
51
|
pruneFlagDefaultIds?: DocId[];
|
|
52
|
+
signal?: AbortSignal;
|
|
52
53
|
}): Promise<ManifestInputs>;
|
|
53
54
|
/** Pure compiler. Assignment config comes exclusively from the frozen phase. */
|
|
54
55
|
/**
|
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,13 +1,78 @@
|
|
|
1
|
+
import { puckCollections } from './options.js';
|
|
2
|
+
import { pageGuardEnterOperation } from './hooks/pageGuard.js';
|
|
3
|
+
import { findRegisteredBlocksField } from './blocks/formState.js';
|
|
4
|
+
import { EXPERIMENT_BLOCK_SLUG } from './blocks/model.js';
|
|
5
|
+
import { contentBlocks } from './transitions/contentFields.js';
|
|
1
6
|
import { validateDimensions } from './events/dimensions.js';
|
|
2
7
|
import { assertPostgresAdapter, probeTransactions } from './db/adapter.js';
|
|
3
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';
|
|
13
|
+
// Diagnostic only: named containers are never accepted by the top-level readers.
|
|
14
|
+
function registeredPaths(fields, name, parent = []) {
|
|
15
|
+
return fields.flatMap((field)=>{
|
|
16
|
+
const path = 'name' in field && field.name ? [
|
|
17
|
+
...parent,
|
|
18
|
+
field.name
|
|
19
|
+
] : parent;
|
|
20
|
+
if (field.type === 'blocks' && field.name === name) return [
|
|
21
|
+
path.join('.')
|
|
22
|
+
];
|
|
23
|
+
if (field.type === 'tabs') return field.tabs.flatMap((tab)=>registeredPaths(tab.fields, name, 'name' in tab && tab.name ? [
|
|
24
|
+
...path,
|
|
25
|
+
tab.name
|
|
26
|
+
] : path));
|
|
27
|
+
return 'fields' in field ? registeredPaths(field.fields, name, path) : [];
|
|
28
|
+
});
|
|
29
|
+
}
|
|
4
30
|
export function createOnInit(options) {
|
|
5
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
|
+
}
|
|
59
|
+
for (const registration of options.blocks?.collections ?? []){
|
|
60
|
+
const config = payload.config.collections.find((c)=>c.slug === registration.slug);
|
|
61
|
+
const found = findRegisteredBlocksField(config?.fields ?? [], registration.field);
|
|
62
|
+
if (!found) throw new Error(`Experiments blocks field ${registration.slug}.${registeredPaths(config?.fields ?? [], registration.field)[0] ?? registration.field} must be a top-level blocks field and must contain ${registration.blockSlug ?? EXPERIMENT_BLOCK_SLUG}`);
|
|
63
|
+
if (!contentBlocks(found.field, payload.config.blocks).some((b)=>b.slug === (registration.blockSlug ?? EXPERIMENT_BLOCK_SLUG))) {
|
|
64
|
+
throw new Error(`Experiments blocks field ${registration.slug}.${registration.field} must contain ${registration.blockSlug ?? EXPERIMENT_BLOCK_SLUG}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (options.metricSources?.some((source)=>source.id.startsWith('click:'))) throw new Error('metricSources ids starting with click: are reserved for click goals');
|
|
6
68
|
validateDimensions(options.events?.dimensions);
|
|
7
69
|
assertPostgresAdapter(payload);
|
|
8
70
|
await probeTransactions(payload);
|
|
9
71
|
if (Object.hasOwn(options.attributeKeys ?? {}, 'staff') && !hasHostAttributesOf(options.runtime)) {
|
|
10
72
|
throw new Error('`staff` is declared in attributeKeys, so pass an `attributesOf` that identifies staff to defineExperimentsServerRuntime');
|
|
11
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
|
+
}
|
|
12
77
|
};
|
|
13
78
|
}
|
package/dist/options.d.ts
CHANGED
|
@@ -7,3 +7,7 @@ export declare function puckCollections(options: Pick<ExperimentsPluginOptions,
|
|
|
7
7
|
export declare function resolveOptions<TUser extends {
|
|
8
8
|
id: string | number;
|
|
9
9
|
}>(input: ExperimentsPluginOptions<TUser>): ResolvedOptions<TUser>;
|
|
10
|
+
/** One published-row rule shared by scans, bindings, writes and editor links. */
|
|
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,
|
|
@@ -49,7 +55,8 @@ export function resolveOptions(input) {
|
|
|
49
55
|
if (![
|
|
50
56
|
'block',
|
|
51
57
|
'document',
|
|
52
|
-
'setting'
|
|
58
|
+
'setting',
|
|
59
|
+
'page'
|
|
53
60
|
].includes(key)) throw new Error(`Unknown experiments admin.descriptions option: ${key}`);
|
|
54
61
|
if (value !== undefined && typeof value !== 'string') throw new Error(`Experiments admin.descriptions.${key} must be a string`);
|
|
55
62
|
}
|
|
@@ -62,6 +69,34 @@ export function resolveOptions(input) {
|
|
|
62
69
|
if (!entry || typeof entry.slug !== 'string' || !entry.slug.trim() || slugs.has(entry.slug) || typeof entry.pathOf !== 'function' || typeof entry.findByPath !== 'function') {
|
|
63
70
|
throw new Error('Experiments pages.collections requires unique slugs, pathOf and findByPath functions');
|
|
64
71
|
}
|
|
72
|
+
if (entry.contentOf !== undefined && typeof entry.contentOf !== 'function') throw new Error('Experiments contentOf must be a function');
|
|
73
|
+
for (const [key, max] of [
|
|
74
|
+
[
|
|
75
|
+
'copyHint',
|
|
76
|
+
200
|
|
77
|
+
],
|
|
78
|
+
[
|
|
79
|
+
'copyLabel',
|
|
80
|
+
40
|
|
81
|
+
]
|
|
82
|
+
]){
|
|
83
|
+
const value = entry[key];
|
|
84
|
+
if (value !== undefined && (typeof value !== 'string' || !value.trim() || value.length > max)) throw new Error(`Experiments ${key} must be a non-empty string of at most ${max} characters`);
|
|
85
|
+
}
|
|
86
|
+
if (entry.copyUrl !== undefined && !validCopyUrl(entry.copyUrl)) throw new Error('Experiments copyUrl must be a root-relative path');
|
|
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
|
+
}
|
|
91
|
+
slugs.add(entry.slug);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (input.blocks !== undefined) {
|
|
95
|
+
if (!input.blocks || !Array.isArray(input.blocks.collections) || !input.blocks.collections.length) throw new Error('Experiments blocks.collections must be a non-empty array');
|
|
96
|
+
const slugs = new Set();
|
|
97
|
+
for (const entry of input.blocks.collections){
|
|
98
|
+
if (!entry || typeof entry.slug !== 'string' || !entry.slug.trim() || slugs.has(entry.slug) || typeof entry.field !== 'string' || !entry.field.trim() || entry.blockSlug !== undefined && (typeof entry.blockSlug !== 'string' || !entry.blockSlug.trim()) || entry.appliesTo !== undefined && typeof entry.appliesTo !== 'function') throw new Error('Invalid experiments blocks collection');
|
|
99
|
+
if (puckCollections(input).some((puck)=>puck.slug === entry.slug) && !entry.appliesTo) throw new Error('A collection registered in puck and blocks requires appliesTo');
|
|
65
100
|
slugs.add(entry.slug);
|
|
66
101
|
}
|
|
67
102
|
}
|
|
@@ -137,6 +172,8 @@ export function resolveOptions(input) {
|
|
|
137
172
|
])),
|
|
138
173
|
events: {
|
|
139
174
|
...input.events,
|
|
175
|
+
origin,
|
|
176
|
+
rateLimit: input.events?.rateLimit,
|
|
140
177
|
retentionDays,
|
|
141
178
|
maxBodyBytes,
|
|
142
179
|
dimensions: Array.isArray(dimensions) ? [
|
|
@@ -150,3 +187,27 @@ export function resolveOptions(input) {
|
|
|
150
187
|
}
|
|
151
188
|
};
|
|
152
189
|
}
|
|
190
|
+
function validCopyUrl(value) {
|
|
191
|
+
if (typeof value !== 'string' || !/^\/(?![/\\])/.test(value) || /[\s\x00-\x1f\x7f]/.test(value)) return false;
|
|
192
|
+
try {
|
|
193
|
+
return new URL(value, 'http://x').origin === 'http://x';
|
|
194
|
+
} catch {
|
|
195
|
+
return false;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
/** One published-row rule shared by scans, bindings, writes and editor links. */ export function documentEditor(options, collection, doc) {
|
|
199
|
+
const block = options.blocks?.collections.find((entry)=>entry.slug === collection);
|
|
200
|
+
if (block && (block.appliesTo ? block.appliesTo(doc) : true)) return 'blocks';
|
|
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
|
+
];
|
|
213
|
+
}
|
package/dist/plugin.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
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';
|
|
9
|
+
import { injectTestBlock } from './admin/blocks/inject.js';
|
|
7
10
|
import * as paths from './admin/paths.js';
|
|
8
11
|
export function createExperimentsPlugin(input) {
|
|
9
12
|
const options = resolveOptions(input);
|
|
@@ -15,12 +18,13 @@ export function createExperimentsPlugin(input) {
|
|
|
15
18
|
for (const { slug } of options.pages?.collections ?? []){
|
|
16
19
|
if (!config.collections?.some((collection)=>collection.slug === slug)) throw new Error(`Unknown experiments page collection: ${slug}`);
|
|
17
20
|
}
|
|
21
|
+
for (const { slug } of options.blocks?.collections ?? []){
|
|
22
|
+
if (!config.collections?.some((collection)=>collection.slug === slug)) throw new Error(`Unknown experiments blocks collection: ${slug}`);
|
|
23
|
+
}
|
|
18
24
|
// The frozen factories consume registration/access metadata, never TUser callbacks.
|
|
19
25
|
// Erase the user subtype only at this non-generic factory boundary.
|
|
20
26
|
const { collections, globals } = buildCollections(options);
|
|
21
27
|
const onInit = createOnInit(options);
|
|
22
|
-
const beforeDashboard = config.admin?.components?.beforeDashboard ?? [];
|
|
23
|
-
const beforeNavLinks = config.admin?.components?.beforeNavLinks ?? [];
|
|
24
28
|
return {
|
|
25
29
|
...config,
|
|
26
30
|
admin: {
|
|
@@ -30,10 +34,6 @@ export function createExperimentsPlugin(input) {
|
|
|
30
34
|
xpTestsSurface: {
|
|
31
35
|
path: paths.XP_TESTS_SURFACE,
|
|
32
36
|
type: 'component'
|
|
33
|
-
},
|
|
34
|
-
xpTestsNav: {
|
|
35
|
-
path: paths.XP_TESTS_NAV_CLIENT,
|
|
36
|
-
type: 'component'
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
components: {
|
|
@@ -44,59 +44,71 @@ export function createExperimentsPlugin(input) {
|
|
|
44
44
|
Component: paths.XP_TESTS_VIEW,
|
|
45
45
|
path: '/experiments/:segments*'
|
|
46
46
|
}
|
|
47
|
-
}
|
|
48
|
-
beforeDashboard: beforeDashboard.includes(paths.XP_TESTS_DASHBOARD_CARDS) ? beforeDashboard : [
|
|
49
|
-
...beforeDashboard,
|
|
50
|
-
paths.XP_TESTS_DASHBOARD_CARDS
|
|
51
|
-
],
|
|
52
|
-
beforeNavLinks: beforeNavLinks.includes(paths.XP_TESTS_NAV_LINK) ? beforeNavLinks : [
|
|
53
|
-
...beforeNavLinks,
|
|
54
|
-
paths.XP_TESTS_NAV_LINK
|
|
55
|
-
]
|
|
47
|
+
}
|
|
56
48
|
}
|
|
57
49
|
},
|
|
58
50
|
collections: [
|
|
51
|
+
...[
|
|
52
|
+
'xp-experiments',
|
|
53
|
+
'xp-metrics'
|
|
54
|
+
].map((slug)=>collections.find((collection)=>collection.slug === slug)),
|
|
59
55
|
...(config.collections ?? []).map((collection)=>{
|
|
60
|
-
const puck = options.puck?.enabled && registrations.
|
|
61
|
-
const page = options.pages?.collections.
|
|
62
|
-
|
|
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);
|
|
58
|
+
const blocks = options.blocks?.collections.find((entry)=>entry.slug === collection.slug);
|
|
59
|
+
if (!puck && !page && !blocks) return collection;
|
|
63
60
|
return {
|
|
64
61
|
...collection,
|
|
62
|
+
fields: [
|
|
63
|
+
...page ? [
|
|
64
|
+
{
|
|
65
|
+
name: 'xpPlacementStatus',
|
|
66
|
+
type: 'ui',
|
|
67
|
+
admin: {
|
|
68
|
+
position: 'sidebar',
|
|
69
|
+
components: {
|
|
70
|
+
Field: paths.XP_PLACEMENT_STATUS
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
] : [],
|
|
75
|
+
...blocks ? injectTestBlock(collection.fields, blocks) : collection.fields
|
|
76
|
+
],
|
|
65
77
|
hooks: {
|
|
66
78
|
...collection.hooks,
|
|
67
79
|
beforeChange: [
|
|
68
80
|
...collection.hooks?.beforeChange ?? [],
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
] : [],
|
|
81
|
+
pageGuardBeforeChange,
|
|
82
|
+
contentChangesBeforeHook,
|
|
72
83
|
...puck ? [
|
|
73
|
-
|
|
84
|
+
puckGoalsBeforeChange(puck.field)
|
|
74
85
|
] : []
|
|
75
86
|
],
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
87
|
+
beforeOperation: [
|
|
88
|
+
pageGuardEnterOperation,
|
|
89
|
+
...collection.hooks?.beforeOperation ?? [],
|
|
90
|
+
pageGuardBeforeOperation
|
|
91
|
+
],
|
|
92
|
+
beforeDelete: [
|
|
93
|
+
...collection.hooks?.beforeDelete ?? [],
|
|
94
|
+
pageGuardBeforeDelete
|
|
95
|
+
],
|
|
96
|
+
afterOperation: [
|
|
97
|
+
pageGuardAfterOperation,
|
|
98
|
+
...collection.hooks?.afterOperation ?? []
|
|
99
|
+
],
|
|
100
|
+
afterChange: [
|
|
101
|
+
...page?.copy ? [
|
|
102
|
+
trackPageCopies
|
|
103
|
+
] : [],
|
|
104
|
+
...collection.hooks?.afterChange ?? [],
|
|
105
|
+
pageGuardAfterChange,
|
|
106
|
+
contentChangesHook
|
|
107
|
+
]
|
|
96
108
|
}
|
|
97
109
|
};
|
|
98
110
|
}),
|
|
99
|
-
...collections
|
|
111
|
+
...collections.filter((collection)=>collection.slug !== 'xp-experiments' && collection.slug !== 'xp-metrics')
|
|
100
112
|
],
|
|
101
113
|
globals: [
|
|
102
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;
|