@delmaredigital/payload-experiments 0.4.0-rc.1 → 0.4.0-rc.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +284 -772
- package/dist/admin/LayerUsage.js +1 -1
- package/dist/admin/MetricSourceSelect.js +2 -2
- package/dist/admin/PlacementStatus.js +1 -1
- package/dist/admin/TestsDashboardCards.d.ts +1 -0
- package/dist/admin/TestsDashboardCards.js +5 -9
- package/dist/admin/TestsNavLink.d.ts +1 -0
- package/dist/admin/TestsNavLink.js +5 -11
- package/dist/admin/blocks/BlockPanel.d.ts +1 -0
- package/dist/admin/blocks/BlockPanel.js +129 -37
- package/dist/admin/blocks/TestBlockField.js +3 -3
- package/dist/admin/blocks/formApi.d.ts +3 -0
- package/dist/admin/blocks/formApi.js +10 -4
- package/dist/admin/blocks/inject.js +1 -0
- package/dist/admin/blocks/model.d.ts +3 -2
- package/dist/admin/blocks/model.js +10 -6
- package/dist/admin/blocks/statusCache.d.ts +2 -0
- package/dist/admin/blocks/statusCache.js +12 -3
- package/dist/admin/components/RootViewMessage.js +1 -1
- package/dist/admin/copy/blocks.d.ts +21 -1
- package/dist/admin/copy/blocks.js +40 -6
- package/dist/admin/copy/goals.d.ts +6 -1
- package/dist/admin/copy/goals.js +10 -3
- package/dist/admin/copy/newTest.d.ts +6 -7
- package/dist/admin/copy/newTest.js +9 -7
- package/dist/admin/goals/XpGoalField.d.ts +2 -0
- package/dist/admin/goals/XpGoalField.js +156 -114
- package/dist/admin/goals/xpGoalField.css +47 -0
- package/dist/admin/pageCollections.d.ts +1 -0
- package/dist/admin/pageCollections.js +3 -0
- package/dist/admin/paths.d.ts +3 -0
- package/dist/admin/paths.js +3 -0
- package/dist/admin/placementStatus.model.js +1 -1
- package/dist/admin/status.model.js +1 -1
- package/dist/admin/surface/ResultsRoute.d.ts +2 -1
- package/dist/admin/surface/ResultsRoute.js +20 -24
- package/dist/admin/surface/SurfaceShell.js +5 -2
- package/dist/admin/surface/TestRowMenu.d.ts +6 -0
- package/dist/admin/surface/TestRowMenu.js +156 -0
- package/dist/admin/surface/TestsHome.d.ts +5 -3
- package/dist/admin/surface/TestsHome.js +266 -58
- package/dist/admin/surface/TestsSurface.js +8 -7
- package/dist/admin/surface/goals/GoalForm.d.ts +1 -1
- package/dist/admin/surface/goals/GoalForm.js +95 -54
- package/dist/admin/surface/goals/GoalsList.d.ts +1 -1
- package/dist/admin/surface/goals/GoalsList.js +5 -4
- package/dist/admin/surface/goals/data.js +2 -2
- package/dist/admin/surface/goals/goals.css +7 -0
- package/dist/admin/surface/goals/goals.model.d.ts +11 -1
- package/dist/admin/surface/goals/goals.model.js +43 -0
- package/dist/admin/surface/home.model.d.ts +9 -8
- package/dist/admin/surface/home.model.js +22 -21
- package/dist/admin/surface/newTest/NewTest.d.ts +4 -4
- package/dist/admin/surface/newTest/NewTest.js +98 -94
- package/dist/admin/surface/newTest/PageWizard.d.ts +2 -1
- package/dist/admin/surface/newTest/PageWizard.js +111 -76
- package/dist/admin/surface/newTest/newTest.css +28 -9
- package/dist/admin/surface/results/ResultsHeader.d.ts +2 -2
- package/dist/admin/surface/results/ResultsHeader.js +58 -54
- package/dist/admin/surface/surface.css +10 -0
- package/dist/admin/surface/test/TestPage.d.ts +1 -2
- package/dist/admin/surface/test/TestPage.js +42 -162
- package/dist/admin/theme.css +2 -0
- package/dist/admin/views/CollectionListRedirect.d.ts +1 -0
- package/dist/admin/views/CollectionListRedirect.js +1 -1
- package/dist/admin/views/ExperimentsRootView.js +18 -165
- package/dist/admin/views/GoalEditRedirect.d.ts +4 -0
- package/dist/admin/views/GoalEditRedirect.js +14 -0
- package/dist/admin/views/GoalsCollectionListView.d.ts +2 -0
- package/dist/admin/views/GoalsCollectionListView.js +4 -0
- package/dist/admin/views/TestsCollectionListView.d.ts +2 -0
- package/dist/admin/views/TestsCollectionListView.js +4 -0
- package/dist/admin/views/TestsNavLinkServer.d.ts +1 -0
- package/dist/admin/views/TestsNavLinkServer.js +2 -2
- package/dist/admin/views/TestsSurfaceClient.d.ts +3 -0
- package/dist/admin/views/TestsSurfaceClient.js +11 -0
- package/dist/admin/views/buildSurfaceProps.d.ts +8 -0
- package/dist/admin/views/buildSurfaceProps.js +102 -0
- package/dist/admin/views/renderCollectionList.d.ts +2 -0
- package/dist/admin/views/renderCollectionList.js +34 -0
- package/dist/admin/views/renderTestsSurface.d.ts +3 -0
- package/dist/admin/views/renderTestsSurface.js +34 -0
- package/dist/blocks/bindings.js +8 -14
- package/dist/blocks/formState.js +1 -1
- package/dist/blocks/placementLanguages.d.ts +7 -0
- package/dist/blocks/placementLanguages.js +27 -0
- package/dist/blocks/placementLocale.d.ts +37 -0
- package/dist/blocks/placementLocale.js +270 -0
- package/dist/collections/experiments/config.js +17 -8
- package/dist/collections/experiments/deleteGuard.js +2 -2
- package/dist/collections/experiments/lockHook.js +21 -2
- package/dist/collections/experiments/pickSlug.js +2 -0
- package/dist/collections/metrics.js +16 -4
- package/dist/collections/metricsGuards.js +2 -0
- package/dist/collections/serialize.js +5 -4
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/db/adapter.d.ts +9 -1
- package/dist/db/adapter.js +77 -1
- package/dist/db/appends.d.ts +13 -0
- package/dist/db/appends.js +49 -0
- package/dist/db/bulkPlacementRemoval.d.ts +30 -0
- package/dist/db/bulkPlacementRemoval.js +111 -0
- package/dist/db/delete.d.ts +1 -1
- package/dist/db/delete.js +2 -4
- package/dist/db/events.d.ts +9 -0
- package/dist/db/events.js +42 -8
- package/dist/db/executor.d.ts +7 -1
- package/dist/db/executor.js +7 -3
- package/dist/db/pageCopies.d.ts +5 -0
- package/dist/db/pageCopies.js +31 -0
- package/dist/db/placements.d.ts +2 -0
- package/dist/db/placements.js +8 -0
- package/dist/db/results.d.ts +5 -1
- package/dist/db/results.js +21 -5
- package/dist/db/snapshots.d.ts +1 -0
- package/dist/endpoints/contentLocale.d.ts +6 -0
- package/dist/endpoints/contentLocale.js +15 -0
- package/dist/endpoints/deleteImpact.d.ts +6 -0
- package/dist/endpoints/deleteImpact.js +207 -0
- package/dist/endpoints/duplicateOriginal.d.ts +38 -0
- package/dist/endpoints/duplicateOriginal.js +407 -0
- package/dist/endpoints/editorSurface.d.ts +3 -0
- package/dist/endpoints/editorSurface.js +31 -0
- package/dist/endpoints/events.js +103 -39
- package/dist/endpoints/index.js +57 -9
- package/dist/endpoints/pages.js +247 -64
- package/dist/endpoints/placementStatus.js +13 -5
- package/dist/endpoints/preflight.d.ts +1 -1
- package/dist/endpoints/preflight.js +17 -2
- package/dist/endpoints/results.d.ts +1 -1
- package/dist/endpoints/results.js +6 -2
- package/dist/endpoints/routeId.d.ts +2 -2
- package/dist/endpoints/routeId.js +11 -5
- package/dist/endpoints/summary.js +46 -12
- package/dist/endpoints/testVersion.d.ts +2 -0
- package/dist/endpoints/testVersion.js +38 -0
- package/dist/endpoints/transitions.js +41 -29
- package/dist/errors.d.ts +5 -0
- package/dist/errors.js +8 -0
- package/dist/events/request.d.ts +6 -2
- package/dist/events/request.js +35 -8
- package/dist/events/rows.d.ts +1 -1
- package/dist/events/rows.js +24 -8
- package/dist/events/writable.d.ts +9 -0
- package/dist/events/writable.js +13 -0
- package/dist/exports/adminClient.d.ts +1 -1
- package/dist/exports/adminClient.js +1 -1
- package/dist/exports/adminRsc.d.ts +3 -0
- package/dist/exports/adminRsc.js +3 -0
- package/dist/exports/index.d.ts +1 -1
- package/dist/exports/rsc.d.ts +1 -0
- package/dist/exports/rsc.js +1 -0
- package/dist/fields/xpGoal.js +3 -15
- package/dist/goals/fairness.d.ts +1 -1
- package/dist/goals/fairness.js +44 -35
- package/dist/goals/picker/clickGoalPicker.model.d.ts +8 -1
- package/dist/goals/picker/clickGoalPicker.model.js +20 -2
- package/dist/goals/picker/copy.d.ts +6 -2
- package/dist/goals/picker/copy.js +11 -2
- package/dist/goals/picker/useClickGoalPicker.d.ts +1 -1
- package/dist/goals/picker/useClickGoalPicker.js +4 -2
- package/dist/goals/validate.d.ts +3 -0
- package/dist/goals/validate.js +15 -0
- package/dist/hooks/blockRemovalRule.d.ts +30 -0
- package/dist/hooks/blockRemovalRule.js +165 -0
- package/dist/hooks/hostHook.js +6 -2
- package/dist/hooks/pageGuard.d.ts +27 -2
- package/dist/hooks/pageGuard.js +213 -45
- package/dist/hooks/puckGoals.d.ts +5 -0
- package/dist/hooks/puckGoals.js +62 -0
- package/dist/hooks/puckNestedTests.d.ts +8 -0
- package/dist/hooks/puckNestedTests.js +36 -0
- package/dist/hooks/trackPageCopies.d.ts +11 -0
- package/dist/hooks/trackPageCopies.js +7 -0
- package/dist/lib/fetchAllDocs.d.ts +1 -1
- package/dist/lib/placementPages.d.ts +10 -0
- package/dist/{admin/previewLinks.model.js → lib/placementPages.js} +10 -5
- package/dist/manifest/compile.d.ts +2 -1
- package/dist/manifest/compile.js +13 -6
- package/dist/onInit.js +36 -0
- package/dist/options.d.ts +2 -0
- package/dist/options.js +23 -2
- package/dist/plugin.js +19 -20
- package/dist/proxy/pageNavigation.d.ts +4 -0
- package/dist/proxy/pageNavigation.js +28 -0
- package/dist/proxy/resolve.js +52 -25
- package/dist/puck/ExperimentPicker.d.ts +2 -1
- package/dist/puck/ExperimentPicker.js +62 -40
- package/dist/puck/ExperimentSlot.js +3 -1
- package/dist/puck/copy.d.ts +5 -1
- package/dist/puck/copy.js +5 -1
- package/dist/puck/editor/ConfigureTestDrawer.d.ts +25 -0
- package/dist/puck/editor/ConfigureTestDrawer.js +150 -0
- package/dist/puck/editor/CreateExperimentDrawer.d.ts +12 -2
- package/dist/puck/editor/CreateExperimentDrawer.js +89 -21
- package/dist/puck/editor/EditorControls.d.ts +14 -0
- package/dist/puck/editor/EditorControls.js +99 -0
- package/dist/puck/editor/ExperimentSlotEditor.js +951 -179
- package/dist/puck/editor/LeftoverVersions.d.ts +15 -0
- package/dist/puck/editor/LeftoverVersions.js +79 -0
- package/dist/puck/editor/PlacementNotice.d.ts +8 -0
- package/dist/puck/editor/PlacementNotice.js +22 -0
- package/dist/puck/editor/QuickTestActions.d.ts +6 -0
- package/dist/puck/editor/QuickTestActions.js +57 -0
- package/dist/puck/editor/ResultsReadout.d.ts +2 -1
- package/dist/puck/editor/ResultsReadout.js +10 -6
- package/dist/puck/editor/VersionBuilder.d.ts +66 -12
- package/dist/puck/editor/VersionBuilder.js +554 -231
- package/dist/puck/editor/armWrites.d.ts +11 -2
- package/dist/puck/editor/armWrites.js +43 -4
- package/dist/puck/editor/armsCache.d.ts +3 -1
- package/dist/puck/editor/armsCache.js +20 -4
- package/dist/puck/editor/blockClipboard.d.ts +16 -0
- package/dist/puck/editor/blockClipboard.js +20 -0
- package/dist/puck/editor/cloneSlot.d.ts +2 -0
- package/dist/puck/editor/cloneSlot.js +7 -0
- package/dist/puck/editor/copy.d.ts +64 -19
- package/dist/puck/editor/copy.js +72 -20
- package/dist/puck/editor/createTest.d.ts +3 -0
- package/dist/puck/editor/createTest.js +33 -0
- package/dist/puck/editor/editor.chrome.css +191 -19
- package/dist/puck/editor/editor.css +328 -24
- package/dist/puck/editor/editor.model.d.ts +17 -1
- package/dist/puck/editor/editor.model.js +61 -4
- package/dist/puck/editor/editorSurface.d.ts +10 -0
- package/dist/puck/editor/editorSurface.js +65 -0
- package/dist/puck/editor/experimentOutlinePlugin.js +96 -28
- package/dist/puck/editor/localPlacements.d.ts +5 -0
- package/dist/puck/editor/localPlacements.js +43 -0
- package/dist/puck/editor/outlineVersion.d.ts +5 -0
- package/dist/puck/editor/outlineVersion.js +36 -0
- package/dist/puck/editor/placementsCache.d.ts +60 -0
- package/dist/puck/editor/placementsCache.js +263 -0
- package/dist/puck/editor/sidebar.d.ts +8 -0
- package/dist/puck/editor/sidebar.js +74 -0
- package/dist/puck/editor/usePageSaveReadiness.d.ts +6 -0
- package/dist/puck/editor/usePageSaveReadiness.js +31 -0
- package/dist/puck/editor/usePlacementNotice.d.ts +3 -0
- package/dist/puck/editor/usePlacementNotice.js +15 -0
- package/dist/puck/editor/xpGoalPuckEditorField.js +105 -86
- package/dist/puck/experimentSlotField.d.ts +3 -0
- package/dist/puck/experimentSlotField.js +15 -4
- package/dist/puck/experimentSlug.d.ts +2 -0
- package/dist/puck/experimentSlug.js +3 -0
- package/dist/puck/nestedTestCopy.d.ts +8 -0
- package/dist/puck/nestedTestCopy.js +22 -0
- package/dist/puck/nestedTests.d.ts +17 -0
- package/dist/puck/nestedTests.js +30 -0
- package/dist/puck/slotConfig.d.ts +1 -1
- package/dist/puck/slotConfig.js +17 -4
- package/dist/puck/visibility.d.ts +20 -0
- package/dist/puck/visibility.js +81 -0
- package/dist/results/aggregate.d.ts +6 -3
- package/dist/results/aggregate.js +9 -9
- package/dist/results/health.d.ts +8 -0
- package/dist/results/health.js +28 -0
- package/dist/results/identityCredit.d.ts +1 -0
- package/dist/results/identityCredit.js +4 -1
- package/dist/results/verdict.js +2 -1
- package/dist/runtime/cookie.d.ts +10 -2
- package/dist/runtime/cookie.js +38 -6
- package/dist/runtime/cookieOptions.d.ts +6 -0
- package/dist/runtime/cookieOptions.js +14 -0
- package/dist/runtime/proxyRuntime.d.ts +1 -0
- package/dist/runtime/proxyRuntime.js +18 -8
- package/dist/runtime/signing.d.ts +1 -0
- package/dist/runtime/signing.js +5 -0
- package/dist/sanitizeReadinessDetail.d.ts +2 -2
- package/dist/sanitizeReadinessDetail.js +22 -2
- package/dist/server/getAssignments.js +11 -10
- package/dist/server/recordContentChange.d.ts +1 -1
- package/dist/server/recordContentChange.js +48 -22
- package/dist/server/resolveExperimentBlocks.js +2 -4
- package/dist/server/resolveExperimentData.js +8 -8
- package/dist/server/runResults.js +52 -14
- package/dist/server/startExperiment.d.ts +20 -0
- package/dist/server/startExperiment.js +70 -0
- package/dist/server/trackConversion.js +10 -13
- package/dist/{admin → testSurface}/PreviewLinks.js +6 -2
- package/dist/testSurface/actions/DecideDialog.d.ts +16 -0
- package/dist/{admin → testSurface}/actions/DecideDialog.js +78 -55
- package/dist/testSurface/actions/LifecycleAction.d.ts +16 -0
- package/dist/testSurface/actions/LifecycleAction.js +105 -0
- package/dist/{admin → testSurface}/actions/MakeContentResult.d.ts +4 -3
- package/dist/{admin → testSurface}/actions/MakeContentResult.js +10 -2
- package/dist/{admin → testSurface}/actions/actions.model.d.ts +13 -5
- package/dist/testSurface/actions/actions.model.js +122 -0
- package/dist/{admin → testSurface}/api.d.ts +20 -7
- package/dist/{admin → testSurface}/api.js +72 -22
- package/dist/testSurface/contentLocaleURL.d.ts +2 -0
- package/dist/testSurface/contentLocaleURL.js +3 -0
- package/dist/{admin → testSurface}/copy/actions.d.ts +28 -8
- package/dist/{admin → testSurface}/copy/actions.js +31 -11
- package/dist/{admin → testSurface}/copy/common.d.ts +13 -4
- package/dist/{admin → testSurface}/copy/common.js +18 -8
- package/dist/testSurface/copy/languages.d.ts +12 -0
- package/dist/testSurface/copy/languages.js +8 -0
- package/dist/{admin → testSurface}/copy/metrics.d.ts +1 -0
- package/dist/{admin → testSurface}/copy/metrics.js +1 -0
- package/dist/testSurface/copy/pages.d.ts +84 -0
- package/dist/testSurface/copy/pages.js +90 -0
- package/dist/{admin → testSurface}/copy/readiness.d.ts +38 -4
- package/dist/{admin → testSurface}/copy/readiness.js +52 -7
- package/dist/{admin → testSurface}/copy/results.d.ts +6 -3
- package/dist/{admin → testSurface}/copy/results.js +6 -3
- package/dist/{admin → testSurface}/copy/review.d.ts +1 -1
- package/dist/{admin → testSurface}/copy/review.js +1 -1
- package/dist/{admin → testSurface}/copy/surface.d.ts +11 -2
- package/dist/{admin → testSurface}/copy/surface.js +13 -10
- package/dist/{admin → testSurface}/copy/testPage.d.ts +53 -8
- package/dist/testSurface/copy/testPage.js +165 -0
- package/dist/testSurface/format/adminURL.d.ts +7 -0
- package/dist/testSurface/format/adminURL.js +9 -0
- package/dist/testSurface/placementLabel.d.ts +8 -0
- package/dist/testSurface/placementLabel.js +24 -0
- package/dist/{admin → testSurface}/placements/placementLabels.d.ts +2 -0
- package/dist/{admin → testSurface}/placements/placementLabels.js +3 -2
- package/dist/{admin → testSurface}/previewLinks.model.d.ts +1 -6
- package/dist/testSurface/previewLinks.model.js +4 -0
- package/dist/testSurface/readPreflight.d.ts +13 -0
- package/dist/testSurface/readPreflight.js +44 -0
- package/dist/testSurface/readinessRead.d.ts +53 -0
- package/dist/testSurface/readinessRead.js +50 -0
- package/dist/{admin → testSurface}/results/VerdictHero.d.ts +2 -1
- package/dist/{admin → testSurface}/results/VerdictHero.js +5 -1
- package/dist/testSurface/results/results.css +64 -0
- package/dist/{admin → testSurface}/results/results.model.js +6 -2
- package/dist/{admin → testSurface}/surface/contracts.d.ts +17 -3
- package/dist/testSurface/surface/editorPlacement.d.ts +26 -0
- package/dist/testSurface/surface/editorPlacement.js +78 -0
- package/dist/testSurface/surface/pageBlock/pageBlock.model.js +9 -0
- package/dist/{admin → testSurface}/surface/pageBlock/parts.js +39 -11
- package/dist/testSurface/surface/pagePicker/CopyRoute.d.ts +13 -0
- package/dist/testSurface/surface/pagePicker/CopyRoute.js +273 -0
- package/dist/testSurface/surface/pagePicker/PageCombobox.d.ts +21 -0
- package/dist/testSurface/surface/pagePicker/PageCombobox.js +503 -0
- package/dist/testSurface/surface/pagePicker/pagePicker.css +73 -0
- package/dist/{admin → testSurface}/surface/pagePicker/pagePicker.model.d.ts +7 -3
- package/dist/{admin → testSurface}/surface/pagePicker/pagePicker.model.js +17 -2
- package/dist/{admin → testSurface}/surface/readiness/ActionDialogs.d.ts +8 -4
- package/dist/testSurface/surface/readiness/ActionDialogs.js +351 -0
- package/dist/{admin → testSurface}/surface/readiness/Banner.d.ts +2 -3
- package/dist/testSurface/surface/readiness/Banner.js +187 -0
- package/dist/testSurface/surface/readiness/BlockerList.d.ts +11 -0
- package/dist/testSurface/surface/readiness/BlockerList.js +31 -0
- package/dist/testSurface/surface/readiness/SaveStatus.d.ts +10 -0
- package/dist/testSurface/surface/readiness/SaveStatus.js +66 -0
- package/dist/{admin → testSurface}/surface/readiness/parts.js +0 -2
- package/dist/{admin → testSurface}/surface/readiness/readiness.model.d.ts +28 -2
- package/dist/testSurface/surface/readiness/readiness.model.js +377 -0
- package/dist/testSurface/surface/readiness/useTransition.d.ts +16 -0
- package/dist/testSurface/surface/readiness/useTransition.js +141 -0
- package/dist/{admin → testSurface}/surface/results/ReleasePages.d.ts +6 -3
- package/dist/{admin → testSurface}/surface/results/ReleasePages.js +40 -40
- package/dist/{admin → testSurface}/surface/results/ResultsBody.d.ts +7 -3
- package/dist/{admin → testSurface}/surface/results/ResultsBody.js +108 -44
- package/dist/{admin → testSurface}/surface/results/useResults.d.ts +26 -8
- package/dist/{admin → testSurface}/surface/results/useResults.js +3 -2
- package/dist/{admin → testSurface}/surface/setting/parts.js +58 -18
- package/dist/testSurface/surface/setting/setting.css +17 -0
- package/dist/{admin → testSurface}/surface/test/AdvancedSection.js +2 -0
- package/dist/testSurface/surface/test/DeleteTest.d.ts +23 -0
- package/dist/testSurface/surface/test/DeleteTest.js +270 -0
- package/dist/testSurface/surface/test/GoalSection.d.ts +4 -0
- package/dist/{admin → testSurface}/surface/test/GoalSection.js +116 -86
- package/dist/testSurface/surface/test/LengthSection.d.ts +2 -0
- package/dist/{admin → testSurface}/surface/test/LengthSection.js +5 -1
- package/dist/{admin → testSurface}/surface/test/PageHoldout.js +4 -1
- package/dist/{admin → testSurface}/surface/test/Rail.js +7 -4
- package/dist/{admin → testSurface}/surface/test/ReadinessBar.d.ts +1 -0
- package/dist/{admin → testSurface}/surface/test/ReadinessBar.js +2 -3
- package/dist/{admin → testSurface}/surface/test/Section.d.ts +3 -1
- package/dist/testSurface/surface/test/Section.js +80 -0
- package/dist/{admin → testSurface}/surface/test/TargetingSection.js +82 -12
- package/dist/testSurface/surface/test/TestSurface.d.ts +19 -0
- package/dist/testSurface/surface/test/TestSurface.js +265 -0
- package/dist/testSurface/surface/test/VersionsSection.d.ts +5 -0
- package/dist/{admin → testSurface}/surface/test/VersionsSection.js +69 -35
- package/dist/{admin → testSurface}/surface/test/fields.d.ts +30 -7
- package/dist/testSurface/surface/test/fields.js +306 -0
- package/dist/{admin → testSurface}/surface/test/pageParts.js +27 -43
- package/dist/testSurface/surface/test/testPage.css +103 -0
- package/dist/{admin → testSurface}/surface/test/testPage.model.d.ts +1 -0
- package/dist/{admin → testSurface}/surface/test/testPage.model.js +6 -0
- package/dist/{admin → testSurface}/surface/testDocument.model.d.ts +3 -0
- package/dist/{admin → testSurface}/surface/testDocument.model.js +4 -1
- package/dist/testSurface/surface/useTestDocument.d.ts +60 -0
- package/dist/testSurface/surface/useTestDocument.js +782 -0
- package/dist/testSurface/surface/watchTestDocument.d.ts +15 -0
- package/dist/testSurface/surface/watchTestDocument.js +181 -0
- package/dist/testSurface/surfaceUrls.d.ts +7 -0
- package/dist/testSurface/surfaceUrls.js +19 -0
- package/dist/{admin → testSurface}/useApi.d.ts +21 -5
- package/dist/testSurface/useOnTestReturn.d.ts +2 -0
- package/dist/testSurface/useOnTestReturn.js +27 -0
- package/dist/testSurface/useReadinessPolling.d.ts +3 -0
- package/dist/testSurface/useReadinessPolling.js +26 -0
- package/dist/transitions/addMetric.d.ts +2 -5
- package/dist/transitions/addMetric.js +5 -1
- package/dist/transitions/allocate.d.ts +2 -2
- package/dist/transitions/allocate.js +3 -1
- package/dist/transitions/archive.d.ts +1 -1
- package/dist/transitions/archive.js +3 -2
- package/dist/transitions/checkStart.d.ts +6 -1
- package/dist/transitions/checkStart.js +133 -17
- package/dist/transitions/contentFields.js +9 -5
- package/dist/transitions/decide.d.ts +1 -1
- package/dist/transitions/decide.js +6 -3
- package/dist/transitions/deleteExperiment.d.ts +2 -2
- package/dist/transitions/deleteExperiment.js +17 -7
- package/dist/transitions/kernel.d.ts +4 -0
- package/dist/transitions/kernel.js +9 -4
- package/dist/transitions/makeContent.d.ts +2 -1
- package/dist/transitions/makeContent.js +41 -17
- package/dist/transitions/nestedPlacementNames.d.ts +5 -0
- package/dist/transitions/nestedPlacementNames.js +32 -0
- package/dist/transitions/pageAddress.d.ts +6 -0
- package/dist/transitions/pageAddress.js +71 -0
- package/dist/transitions/pageVersions.js +3 -1
- package/dist/transitions/phaseRecord.d.ts +2 -0
- package/dist/transitions/phaseRecord.js +5 -0
- package/dist/transitions/placementInteractions.d.ts +3 -3
- package/dist/transitions/placementInteractions.js +16 -12
- package/dist/transitions/placements.d.ts +54 -8
- package/dist/transitions/placements.js +304 -81
- package/dist/transitions/preflightData.d.ts +5 -3
- package/dist/transitions/preflightData.js +137 -40
- package/dist/transitions/releaseHoldout.d.ts +2 -1
- package/dist/transitions/releaseHoldout.js +3 -1
- package/dist/transitions/releasePages.d.ts +2 -1
- package/dist/transitions/releasePages.js +3 -1
- package/dist/transitions/resolveCaps.d.ts +2 -4
- package/dist/transitions/start.d.ts +6 -8
- package/dist/transitions/start.js +72 -35
- package/dist/transitions/startReads.d.ts +7 -0
- package/dist/transitions/startReads.js +28 -0
- package/dist/transitions/stop.d.ts +2 -1
- package/dist/transitions/stop.js +3 -2
- package/dist/types/contracts.d.ts +15 -3
- package/dist/types/endpoints.d.ts +121 -17
- package/dist/types/puck.d.ts +1 -0
- package/dist/types/runtime.d.ts +15 -9
- package/dist/types/snapshot.d.ts +2 -0
- package/dist/types/surface.d.ts +9 -9
- package/dist/ui/Button.js +2 -2
- package/dist/ui/Card.d.ts +2 -1
- package/dist/ui/Card.js +4 -4
- package/dist/ui/ChipsInput.d.ts +8 -1
- package/dist/ui/ChipsInput.js +17 -4
- package/dist/ui/Dialog.d.ts +24 -2
- package/dist/ui/Dialog.js +116 -6
- package/dist/ui/Drawer.d.ts +10 -0
- package/dist/ui/Drawer.js +29 -0
- package/dist/ui/Inputs.d.ts +4 -3
- package/dist/ui/Inputs.js +7 -4
- package/dist/ui/SelectControl.d.ts +33 -0
- package/dist/ui/SelectControl.js +504 -0
- package/dist/ui/Tabs.d.ts +4 -4
- package/dist/ui/Tabs.js +35 -32
- package/dist/ui/ui.css +49 -5
- package/package.json +3 -2
- package/dist/admin/actions/ConfirmDialog.d.ts +0 -19
- package/dist/admin/actions/ConfirmDialog.js +0 -149
- package/dist/admin/actions/DecideDialog.d.ts +0 -10
- package/dist/admin/actions/actions.model.js +0 -70
- package/dist/admin/copy/pages.d.ts +0 -26
- package/dist/admin/copy/pages.js +0 -26
- package/dist/admin/copy/testPage.js +0 -104
- package/dist/admin/results/results.css +0 -64
- package/dist/admin/styles.css +0 -10
- package/dist/admin/styles.d.ts +0 -2
- package/dist/admin/styles.js +0 -3
- package/dist/admin/surface/pageBlock/pageBlock.model.js +0 -8
- package/dist/admin/surface/pagePicker/CopyRoute.d.ts +0 -6
- package/dist/admin/surface/pagePicker/CopyRoute.js +0 -53
- package/dist/admin/surface/pagePicker/PagePicker.d.ts +0 -10
- package/dist/admin/surface/pagePicker/PagePicker.js +0 -172
- package/dist/admin/surface/readiness/ActionDialogs.js +0 -337
- package/dist/admin/surface/readiness/Banner.js +0 -190
- package/dist/admin/surface/readiness/SaveStatus.d.ts +0 -5
- package/dist/admin/surface/readiness/SaveStatus.js +0 -53
- package/dist/admin/surface/readiness/readiness.model.js +0 -205
- package/dist/admin/surface/readiness/useTransition.d.ts +0 -11
- package/dist/admin/surface/readiness/useTransition.js +0 -35
- package/dist/admin/surface/setting/setting.css +0 -17
- package/dist/admin/surface/test/GoalSection.d.ts +0 -2
- package/dist/admin/surface/test/LengthSection.d.ts +0 -2
- package/dist/admin/surface/test/Section.js +0 -47
- package/dist/admin/surface/test/VersionsSection.d.ts +0 -4
- package/dist/admin/surface/test/fields.js +0 -216
- package/dist/admin/surface/test/testPage.css +0 -97
- package/dist/admin/surface/useTestDocument.d.ts +0 -32
- package/dist/admin/surface/useTestDocument.js +0 -415
- /package/dist/{admin → testSurface}/PreviewLinks.d.ts +0 -0
- /package/dist/{admin → testSurface}/actions/decide.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/actions/decide.model.js +0 -0
- /package/dist/{admin → testSurface}/allocation.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/allocation.model.js +0 -0
- /package/dist/{admin → testSurface}/arms/arms.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/arms/arms.model.js +0 -0
- /package/dist/{admin → testSurface}/arms/pageTarget.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/arms/pageTarget.model.js +0 -0
- /package/dist/{admin → testSurface}/arms/params.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/arms/params.model.js +0 -0
- /package/dist/{admin → testSurface}/copy/advanced.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/advanced.js +0 -0
- /package/dist/{admin → testSurface}/copy/arms.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/arms.js +0 -0
- /package/dist/{admin → testSurface}/copy/audience.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/audience.js +0 -0
- /package/dist/{admin → testSurface}/copy/recommendation.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/recommendation.js +0 -0
- /package/dist/{admin → testSurface}/copy/setting.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/setting.js +0 -0
- /package/dist/{admin → testSurface}/format/date.d.ts +0 -0
- /package/dist/{admin → testSurface}/format/date.js +0 -0
- /package/dist/{admin → testSurface}/labels.d.ts +0 -0
- /package/dist/{admin → testSurface}/labels.js +0 -0
- /package/dist/{admin → testSurface}/lockedNotice.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/lockedNotice.model.js +0 -0
- /package/dist/{admin → testSurface}/metricSource.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/metricSource.model.js +0 -0
- /package/dist/{admin → testSurface}/placements/placementLabels.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/placements/placementLabels.model.js +0 -0
- /package/dist/{admin → testSurface}/placements/usePlacementLabels.d.ts +0 -0
- /package/dist/{admin → testSurface}/placements/usePlacementLabels.js +0 -0
- /package/dist/{admin → testSurface}/reload.d.ts +0 -0
- /package/dist/{admin → testSurface}/reload.js +0 -0
- /package/dist/{admin → testSurface}/results/CappedCell.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/CappedCell.js +0 -0
- /package/dist/{admin → testSurface}/results/CiChart.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/CiChart.js +0 -0
- /package/dist/{admin → testSurface}/results/DataQualityPanel.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/DataQualityPanel.js +0 -0
- /package/dist/{admin → testSurface}/results/DataTable.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/DataTable.js +0 -0
- /package/dist/{admin → testSurface}/results/StatTile.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/StatTile.js +0 -0
- /package/dist/{admin → testSurface}/results/chart.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/chart.model.js +0 -0
- /package/dist/{admin → testSurface}/results/format.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/format.js +0 -0
- /package/dist/{admin → testSurface}/results/legacy.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/legacy.js +0 -0
- /package/dist/{admin → testSurface}/results/releasePages.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/releasePages.model.js +0 -0
- /package/dist/{admin → testSurface}/results/results.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/snapshot.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/snapshot.js +0 -0
- /package/dist/{admin → testSurface}/review/review.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/review/review.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/contracts.js +0 -0
- /package/dist/{admin → testSurface}/surface/pageBlock/pageBlock.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/pageBlock/parts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/parts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/results/recommendation.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/results/recommendation.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/setting/parts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/setting/setting.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/setting/setting.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/AdvancedSection.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/PageHoldout.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/Rail.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/TargetingSection.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/jumpToSection.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/jumpToSection.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/pageParts.d.ts +0 -0
- /package/dist/{admin → testSurface}/targeting/targeting.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/targeting/targeting.model.js +0 -0
- /package/dist/{admin → testSurface}/theme.d.ts +0 -0
- /package/dist/{admin → testSurface}/theme.js +0 -0
- /package/dist/{admin → testSurface}/useApi.js +0 -0
|
@@ -1,7 +1,16 @@
|
|
|
1
|
-
import type { Arm } from '../../types/contracts.js';
|
|
1
|
+
import type { Arm, ArmKey } from '../../types/contracts.js';
|
|
2
|
+
import type { ArmSlot } from '../../types/puck.js';
|
|
2
3
|
import type { EditorExperiment } from './editor.model.js';
|
|
3
4
|
export declare class ArmWriteError extends Error {
|
|
4
5
|
}
|
|
6
|
+
/** Refuse obsolete intents before a no-op can become a successful PATCH. */
|
|
7
|
+
export declare function removeVersionArms(arms: Arm[], key: ArmKey): Arm[];
|
|
8
|
+
export declare function addVersionArms(arms: Arm[]): Arm[];
|
|
9
|
+
export declare function setVersionTraffic(arms: Arm[], key: ArmKey, weight: number): Arm[];
|
|
10
|
+
export declare function renameVersionArms(arms: Arm[], key: ArmKey, label: string): Arm[];
|
|
11
|
+
export declare function addLeftoverArms(arms: Arm[], slot: ArmSlot): Arm[];
|
|
5
12
|
export declare function readExperiment(url: string, signal?: AbortSignal): Promise<EditorExperiment>;
|
|
6
13
|
/** Each intent is applied to a fresh document, guarded by the collection's compare-and-set header. */
|
|
7
|
-
export declare function writeArms(url: string, transform: (arms: Arm[]) => Arm[], publish: (doc: EditorExperiment) => void
|
|
14
|
+
export declare function writeArms(url: string, transform: (arms: Arm[]) => Arm[], publish: (doc: EditorExperiment) => EditorExperiment | void, { draftOnly }?: {
|
|
15
|
+
draftOnly?: boolean;
|
|
16
|
+
}): Promise<Arm[]>;
|
|
@@ -1,10 +1,46 @@
|
|
|
1
1
|
import { checkArms } from '../../collections/experiments/armInvariants.js';
|
|
2
2
|
import { issueMessage } from '../../arms/copy.js';
|
|
3
|
-
import { totalWeight, withSlotsFor } from '../../arms/model.js';
|
|
3
|
+
import { addVariant, balanceWeight, removeArm, splitEvenly, totalWeight, withSlotsFor } from '../../arms/model.js';
|
|
4
4
|
import { XP_IF_UPDATED_AT_HEADER } from '../../constants.js';
|
|
5
|
+
import { slotLabels } from '../copy.js';
|
|
5
6
|
import { editorCopy, writeRefusal } from './copy.js';
|
|
6
7
|
export class ArmWriteError extends Error {
|
|
7
8
|
}
|
|
9
|
+
/** Refuse obsolete intents before a no-op can become a successful PATCH. */ export function removeVersionArms(arms, key) {
|
|
10
|
+
if (!arms.some((arm)=>arm.key === key && arm.kind !== 'control')) throw new ArmWriteError(editorCopy.staleEdit);
|
|
11
|
+
return splitEvenly(removeArm(arms, key));
|
|
12
|
+
}
|
|
13
|
+
export function addVersionArms(arms) {
|
|
14
|
+
const next = addVariant(arms, 'block');
|
|
15
|
+
if (next.length === arms.length) throw new ArmWriteError(editorCopy.staleEdit);
|
|
16
|
+
return next;
|
|
17
|
+
}
|
|
18
|
+
export function setVersionTraffic(arms, key, weight) {
|
|
19
|
+
if (!arms.some((arm)=>arm.key === key) || arms.length < 2) throw new ArmWriteError(editorCopy.staleEdit);
|
|
20
|
+
return balanceWeight(arms, key, weight);
|
|
21
|
+
}
|
|
22
|
+
export function renameVersionArms(arms, key, label) {
|
|
23
|
+
if (!arms.some((arm)=>arm.key === key)) throw new ArmWriteError(editorCopy.staleEdit);
|
|
24
|
+
return arms.map((arm)=>arm.key === key ? {
|
|
25
|
+
...arm,
|
|
26
|
+
label
|
|
27
|
+
} : arm);
|
|
28
|
+
}
|
|
29
|
+
export function addLeftoverArms(arms, slot) {
|
|
30
|
+
if (slot === 'control' || arms.some((arm)=>arm.key === slot) || !arms.some((arm)=>arm.kind === 'control') || arms.filter((arm)=>arm.kind === 'variant').length >= 3) throw new ArmWriteError(editorCopy.staleEdit);
|
|
31
|
+
const next = [
|
|
32
|
+
...arms
|
|
33
|
+
];
|
|
34
|
+
const holdout = next.findIndex((arm)=>arm.kind === 'holdout');
|
|
35
|
+
next.splice(holdout < 0 ? next.length : holdout, 0, {
|
|
36
|
+
key: slot,
|
|
37
|
+
slot,
|
|
38
|
+
kind: 'variant',
|
|
39
|
+
label: slotLabels[slot],
|
|
40
|
+
weight: 0
|
|
41
|
+
});
|
|
42
|
+
return next;
|
|
43
|
+
}
|
|
8
44
|
export async function readExperiment(url, signal) {
|
|
9
45
|
const response = await fetch(url, {
|
|
10
46
|
credentials: 'include',
|
|
@@ -31,9 +67,12 @@ export async function readExperiment(url, signal) {
|
|
|
31
67
|
].includes(value.status)) throw new ArmWriteError(editorCopy.lockedGeneric);
|
|
32
68
|
return value;
|
|
33
69
|
}
|
|
34
|
-
/** Each intent is applied to a fresh document, guarded by the collection's compare-and-set header. */ export async function writeArms(url, transform, publish) {
|
|
70
|
+
/** Each intent is applied to a fresh document, guarded by the collection's compare-and-set header. */ export async function writeArms(url, transform, publish, { draftOnly = false } = {}) {
|
|
35
71
|
const fresh = await readExperiment(`${url}?depth=0`);
|
|
36
|
-
publish(fresh);
|
|
72
|
+
const accepted = publish(fresh) ?? fresh;
|
|
73
|
+
// A later cache read can supersede this baseline before this GET finishes.
|
|
74
|
+
if (accepted.updatedAt !== fresh.updatedAt) throw new ArmWriteError(editorCopy.staleEdit);
|
|
75
|
+
if (draftOnly && fresh.status !== 'draft') throw new ArmWriteError(editorCopy.draftOnly);
|
|
37
76
|
if (fresh.status !== 'draft' && fresh.status !== 'stopped') throw new ArmWriteError(editorCopy.locked[fresh.status]);
|
|
38
77
|
if (!fresh.updatedAt || !Array.isArray(fresh.arms)) throw new ArmWriteError(editorCopy.writeUnreadable);
|
|
39
78
|
const arms = withSlotsFor(transform(fresh.arms), 'block');
|
|
@@ -55,7 +94,7 @@ export async function readExperiment(url, signal) {
|
|
|
55
94
|
if (!response.ok) {
|
|
56
95
|
const codes = Array.isArray(body?.errors) ? body.errors : [];
|
|
57
96
|
const stale = response.status === 409 && codes.some((error)=>error?.code === 'stale-edit');
|
|
58
|
-
if (
|
|
97
|
+
if (response.status === 409 || response.status === 403) {
|
|
59
98
|
try {
|
|
60
99
|
publish(await readExperiment(`${url}?depth=0`));
|
|
61
100
|
} catch {}
|
|
@@ -2,13 +2,15 @@ import type { DocId } from '../../types/contracts.js';
|
|
|
2
2
|
import type { EditorExperiment } from './editor.model.js';
|
|
3
3
|
type Arms = {
|
|
4
4
|
arms: string[];
|
|
5
|
+
doc?: EditorExperiment;
|
|
5
6
|
};
|
|
6
7
|
/** Only the first mounted block discards a document left by an earlier editor. */
|
|
7
8
|
export declare function acquireArms(testId: DocId): () => void;
|
|
8
9
|
/** Share the request, but abort it only after its last mounted consumer leaves. */
|
|
9
10
|
export declare function loadArms(testId: DocId, load: (signal: AbortSignal) => Promise<EditorExperiment>, signal: AbortSignal): Promise<EditorExperiment>;
|
|
10
11
|
export declare function subscribe(listener: () => void): () => void;
|
|
11
|
-
|
|
12
|
+
export declare function publishExperiment(testId: DocId, doc: EditorExperiment): EditorExperiment;
|
|
13
|
+
/** undefined means unknown. */
|
|
12
14
|
export declare function setArms(testId: DocId, arms: string[] | undefined): void;
|
|
13
15
|
export declare function useArms(testId: DocId | undefined): Arms | undefined;
|
|
14
16
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useSyncExternalStore } from 'react';
|
|
3
3
|
const cache = new Map();
|
|
4
|
+
const revisions = new Map();
|
|
4
5
|
const listeners = new Set();
|
|
5
6
|
const pending = new Map();
|
|
6
7
|
const mounted = new Map();
|
|
@@ -29,11 +30,12 @@ const mounted = new Map();
|
|
|
29
30
|
promise: undefined
|
|
30
31
|
};
|
|
31
32
|
const entry = request;
|
|
33
|
+
const revision = revisions.get(key) ?? 0;
|
|
32
34
|
entry.promise = load(controller.signal).then((doc)=>{
|
|
33
|
-
if (
|
|
34
|
-
return doc;
|
|
35
|
+
if ((revisions.get(key) ?? 0) !== revision) return cache.get(key)?.doc ?? doc;
|
|
36
|
+
return controller.signal.aborted ? doc : publishExperiment(testId, doc);
|
|
35
37
|
}, (error)=>{
|
|
36
|
-
if (
|
|
38
|
+
if ((revisions.get(key) ?? 0) !== revision && cache.get(key)?.doc) return cache.get(key).doc;
|
|
37
39
|
throw error;
|
|
38
40
|
}).finally(()=>{
|
|
39
41
|
if (pending.get(key) === entry) pending.delete(key);
|
|
@@ -63,7 +65,21 @@ export function subscribe(listener) {
|
|
|
63
65
|
listeners.delete(listener);
|
|
64
66
|
};
|
|
65
67
|
}
|
|
66
|
-
|
|
68
|
+
export function publishExperiment(testId, doc) {
|
|
69
|
+
const previous = cache.get(String(testId))?.doc;
|
|
70
|
+
// Surface reads and chrome writes share this producer too. A GET that began
|
|
71
|
+
// before a save cannot overwrite its newer server timestamp when it finishes.
|
|
72
|
+
if (previous?.updatedAt && doc.updatedAt && Date.parse(previous.updatedAt) > Date.parse(doc.updatedAt)) return previous;
|
|
73
|
+
revisions.set(String(testId), (revisions.get(String(testId)) ?? 0) + 1);
|
|
74
|
+
cache.set(String(testId), {
|
|
75
|
+
arms: doc.arms.map((arm)=>arm.key),
|
|
76
|
+
doc
|
|
77
|
+
});
|
|
78
|
+
for (const listener of listeners)listener();
|
|
79
|
+
return doc;
|
|
80
|
+
}
|
|
81
|
+
/** undefined means unknown. */ export function setArms(testId, arms) {
|
|
82
|
+
revisions.set(String(testId), (revisions.get(String(testId)) ?? 0) + 1);
|
|
67
83
|
if (arms) cache.set(String(testId), {
|
|
68
84
|
arms: [
|
|
69
85
|
...arms
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ComponentData } from '@puckeditor/core';
|
|
2
|
+
type PasteArgs = {
|
|
3
|
+
block: ComponentData;
|
|
4
|
+
destination: {
|
|
5
|
+
ancestors: readonly {
|
|
6
|
+
type: string;
|
|
7
|
+
}[];
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export declare function canPasteExperiment({ block, destination }: PasteArgs): true | string;
|
|
11
|
+
export declare const experimentClipboard: {
|
|
12
|
+
blockClipboard: {
|
|
13
|
+
canPaste: typeof canPasteExperiment;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { nestedTests } from '../nestedTests.js';
|
|
2
|
+
import { editorCopy } from './copy.js';
|
|
3
|
+
export function canPasteExperiment({ block, destination }) {
|
|
4
|
+
const ancestors = destination.ancestors.map((ancestor)=>({
|
|
5
|
+
type: ancestor.type,
|
|
6
|
+
props: {}
|
|
7
|
+
}));
|
|
8
|
+
if (nestedTests(block, {
|
|
9
|
+
includeHidden: true,
|
|
10
|
+
ancestors
|
|
11
|
+
}).length) return editorCopy.nestedPaste;
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
// Spread into the component config so older Puck typings and hosts accept the
|
|
15
|
+
// extra key. payload-puck 0.12.1 invokes it; 0.12.0 simply ignores it.
|
|
16
|
+
export const experimentClipboard = {
|
|
17
|
+
blockClipboard: {
|
|
18
|
+
canPaste: canPasteExperiment
|
|
19
|
+
}
|
|
20
|
+
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { Slot } from '../../types/puck.js';
|
|
2
2
|
/** Clone JSON Puck slot data, refreshing component ids even inside nested slots. */
|
|
3
3
|
export declare function cloneSlot(slot: Slot): Slot;
|
|
4
|
+
/** Count the Puck blocks that will be removed, including nested version content. */
|
|
5
|
+
export declare function countSlotBlocks(value: unknown): number;
|
|
@@ -39,3 +39,10 @@ function freshId(type, used) {
|
|
|
39
39
|
}
|
|
40
40
|
return clone(slot);
|
|
41
41
|
}
|
|
42
|
+
/** Count the Puck blocks that will be removed, including nested version content. */ export function countSlotBlocks(value) {
|
|
43
|
+
if (!value || typeof value !== 'object') return 0;
|
|
44
|
+
if (Array.isArray(value)) return value.reduce((total, item)=>total + countSlotBlocks(item), 0);
|
|
45
|
+
const node = value;
|
|
46
|
+
const own = typeof node.type === 'string' && node.props && typeof node.props === 'object' ? 1 : 0;
|
|
47
|
+
return own + Object.values(node).reduce((total, item)=>total + countSlotBlocks(item), 0);
|
|
48
|
+
}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
export declare const editorCopy: {
|
|
2
|
+
readonly nested: (outer?: string, inner?: string) => string;
|
|
3
|
+
readonly nestedHidden: (outer?: string) => string;
|
|
4
|
+
readonly nestedPaste: "A test can't go inside another test's version.";
|
|
5
|
+
readonly hidden: "This block is hidden, so visitors won't see this test here.";
|
|
6
|
+
readonly hiddenOn: (sizes: string) => string;
|
|
7
|
+
readonly retrySetup: "Retry";
|
|
8
|
+
readonly controlsUnavailable: "Test controls couldn't load.";
|
|
9
|
+
readonly setupForbidden: "You don't have access to set up tests.";
|
|
10
|
+
readonly setupUnavailable: "Setup isn't available right now.";
|
|
2
11
|
readonly labels: {
|
|
3
12
|
readonly control: "Original";
|
|
4
13
|
readonly variantA: "Variant A";
|
|
@@ -6,39 +15,72 @@ export declare const editorCopy: {
|
|
|
6
15
|
readonly variantC: "Variant C";
|
|
7
16
|
readonly holdout: "Holdout";
|
|
8
17
|
};
|
|
9
|
-
readonly
|
|
10
|
-
readonly
|
|
11
|
-
readonly
|
|
18
|
+
readonly configure: "Configure test";
|
|
19
|
+
readonly openInTab: "Open in a new tab";
|
|
20
|
+
readonly closeConfigure: "Close";
|
|
21
|
+
readonly selectBlock: "Select this test block";
|
|
22
|
+
readonly deleted: "The test for this block was deleted.";
|
|
23
|
+
readonly unbound: "This Experiment block has no test yet.";
|
|
24
|
+
readonly draft: (label: string) => string;
|
|
12
25
|
readonly running: "Changing this content mid-test mixes two versions in one result";
|
|
13
26
|
readonly decided: (winner: string) => string;
|
|
14
|
-
readonly archived:
|
|
15
|
-
readonly
|
|
16
|
-
readonly
|
|
17
|
-
readonly
|
|
27
|
+
readonly archived: (winner: string) => string;
|
|
28
|
+
readonly archivedOriginal: (original: string, discarded: boolean) => string;
|
|
29
|
+
readonly copy: (label?: string) => string;
|
|
30
|
+
readonly copyEmpty: (label?: string) => string;
|
|
31
|
+
readonly enterName: "Enter a name to create the test.";
|
|
32
|
+
readonly dropZone: (label: string) => string;
|
|
33
|
+
readonly replaceConfirm: (label: string, original?: string) => string;
|
|
34
|
+
readonly replaceTitle: (label: string, test?: string) => string;
|
|
18
35
|
readonly replace: "Replace";
|
|
19
|
-
readonly
|
|
36
|
+
readonly pageFallback: "Page";
|
|
37
|
+
readonly createLabel: "Set up test";
|
|
38
|
+
readonly existingTest: "Use an existing test";
|
|
39
|
+
readonly sharedTest: "This test is also used in another place. Changes here affect that test.";
|
|
40
|
+
readonly createdUnbound: "The test was created, but this block changed or was removed. Open the test to continue.";
|
|
20
41
|
readonly creating: "Creating…";
|
|
21
42
|
readonly cancel: "Cancel";
|
|
22
43
|
readonly name: "Name";
|
|
23
|
-
readonly
|
|
24
|
-
readonly viewResults: "View results";
|
|
44
|
+
readonly openTest: "Open the test";
|
|
25
45
|
readonly nameExists: "This name is too close to an existing test. Choose a different name.";
|
|
26
46
|
readonly createError: "Couldn't create the test. Try again.";
|
|
47
|
+
readonly savingVersions: "Saving version changes…";
|
|
48
|
+
readonly refreshing: "Refreshing results…";
|
|
27
49
|
readonly loading: "Loading test…";
|
|
28
50
|
readonly loadError: "Couldn't load this test. Try selecting it again.";
|
|
29
|
-
readonly orphan: (label: string) => string;
|
|
51
|
+
readonly orphan: (label: string, versions: string) => string;
|
|
52
|
+
readonly addLeftover: "Add to the test";
|
|
53
|
+
readonly deleteContent: "Delete its content";
|
|
54
|
+
readonly deleteContentTitle: (label: string, test?: string) => string;
|
|
55
|
+
readonly deleteContentHelp: (label: string, count: number) => string;
|
|
56
|
+
readonly draftOnly: "Only draft tests can add this version. Use a different test to include it.";
|
|
57
|
+
readonly outsideTest: (label: string) => string;
|
|
58
|
+
readonly showVersion: (label: string) => string;
|
|
30
59
|
readonly tabs: "Test versions";
|
|
31
60
|
readonly add: "Add variant";
|
|
32
|
-
readonly
|
|
33
|
-
readonly
|
|
34
|
-
readonly
|
|
61
|
+
readonly testGroup: "Test";
|
|
62
|
+
readonly versionsGroup: "Versions";
|
|
63
|
+
readonly moreGroup: "More";
|
|
64
|
+
readonly differentTest: "Use a different test";
|
|
65
|
+
readonly createAnother: "Create a test";
|
|
66
|
+
readonly readOnlyVersions: "You don't have permission to change this test's versions.";
|
|
67
|
+
readonly traffic: "Traffic (%)";
|
|
68
|
+
readonly percent: "%";
|
|
69
|
+
readonly saved: "Saved";
|
|
70
|
+
readonly removeVersion: "Remove version";
|
|
35
71
|
readonly emptyLabel: "Enter a name for this version.";
|
|
36
72
|
readonly remove: "Remove";
|
|
37
|
-
readonly removeTitle: (label: string) => string;
|
|
38
|
-
readonly removeHelp:
|
|
73
|
+
readonly removeTitle: (label: string, test?: string) => string;
|
|
74
|
+
readonly removeHelp: (count: number) => string;
|
|
75
|
+
readonly removeShared: "This test is also used in another place. The version is removed from the test there too.";
|
|
76
|
+
readonly removeScopeUnknown: "If this test is used on other pages, the version is removed from the test there too.";
|
|
39
77
|
readonly removed: "Save the page to finish removing this version's content.";
|
|
40
|
-
readonly
|
|
78
|
+
readonly removeUnclearedSteps: readonly ["Delete the leftover content from the outline.", "Save the page."];
|
|
79
|
+
readonly archivedStepsWhy: "To keep this content on the page without the test, move it into regular blocks.";
|
|
80
|
+
readonly archivedSteps: readonly ["Move the content out of the Experiment block on the canvas.", "Remove the Experiment block."];
|
|
81
|
+
readonly removeUncleared: "The version was removed from the test. Its content still needs to be removed from the page.";
|
|
41
82
|
readonly lockedGeneric: "This test's versions can't change. View the test page for details.";
|
|
83
|
+
readonly holdoutContent: "Holdout visitors see the Original.";
|
|
42
84
|
readonly holdoutPeople: (label: string, count: string) => string;
|
|
43
85
|
readonly weight: (label: string) => string;
|
|
44
86
|
readonly invalidShare: "Use a whole number from 0 to 100.";
|
|
@@ -48,12 +90,15 @@ export declare const editorCopy: {
|
|
|
48
90
|
readonly decided: "This test has a decision, so its versions can't change. View the results on the test page.";
|
|
49
91
|
readonly archived: "This test is archived, so its versions can't change. View the results on the test page.";
|
|
50
92
|
};
|
|
51
|
-
readonly staleEdit: "
|
|
93
|
+
readonly staleEdit: "This test changed. Check the saved settings and try again.";
|
|
94
|
+
readonly nameChanged: "This version name changed while you were editing.";
|
|
95
|
+
readonly versionName: (label: string) => string;
|
|
96
|
+
readonly shareChanged: "The saved shares changed while you were editing.";
|
|
52
97
|
readonly writeError: "Couldn't complete this change. Try again.";
|
|
53
98
|
readonly writeNetwork: "Couldn't reach the server. Check your connection and try again.";
|
|
54
99
|
readonly writeUnreadable: "Couldn't read the server's response. Reload and try again.";
|
|
55
100
|
readonly collecting: "Collecting";
|
|
56
|
-
readonly resultsUnavailable: "Results aren't available here.";
|
|
101
|
+
readonly resultsUnavailable: "Results aren't available here. Try Refresh.";
|
|
57
102
|
readonly refresh: "Refresh";
|
|
58
103
|
readonly people: (label: string, count: string) => string;
|
|
59
104
|
};
|
package/dist/puck/editor/copy.js
CHANGED
|
@@ -1,39 +1,88 @@
|
|
|
1
|
+
import { nestedTestCopy } from '../nestedTestCopy.js';
|
|
1
2
|
import { ARM_LABELS } from '../../labels/arms.js';
|
|
2
3
|
export const editorCopy = {
|
|
4
|
+
nested: nestedTestCopy.editor,
|
|
5
|
+
nestedHidden: nestedTestCopy.hidden,
|
|
6
|
+
nestedPaste: "A test can't go inside another test's version.",
|
|
7
|
+
hidden: "This block is hidden, so visitors won't see this test here.",
|
|
8
|
+
hiddenOn: (sizes)=>`This block is hidden on ${sizes}. Visitors on ${sizes} are still counted in this test.`,
|
|
9
|
+
retrySetup: 'Retry',
|
|
10
|
+
controlsUnavailable: "Test controls couldn't load.",
|
|
11
|
+
setupForbidden: "You don't have access to set up tests.",
|
|
12
|
+
setupUnavailable: "Setup isn't available right now.",
|
|
3
13
|
labels: ARM_LABELS,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
14
|
+
configure: 'Configure test',
|
|
15
|
+
openInTab: 'Open in a new tab',
|
|
16
|
+
closeConfigure: 'Close',
|
|
17
|
+
selectBlock: 'Select this test block',
|
|
18
|
+
deleted: 'The test for this block was deleted.',
|
|
19
|
+
unbound: 'This Experiment block has no test yet.',
|
|
20
|
+
draft: (label)=>`This block shows the ${label} to everyone until the test starts.`,
|
|
7
21
|
running: 'Changing this content mid-test mixes two versions in one result',
|
|
8
22
|
decided: (winner)=>`Decided: ${winner}. Use 'Make it the content' on the test to finish.`,
|
|
9
|
-
archived:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
23
|
+
archived: (winner)=>`Archived: this block serves ${winner}, or nothing if that version is empty.`,
|
|
24
|
+
archivedOriginal: (original, discarded)=>`${discarded ? 'Winner discarded' : 'Archived without a winner'}: this block shows ${original}, or nothing if it is empty.`,
|
|
25
|
+
copy: (label = ARM_LABELS.control)=>`Copy ${label} here`,
|
|
26
|
+
copyEmpty: (label = ARM_LABELS.control)=>`Add content to the ${label} before copying it.`,
|
|
27
|
+
enterName: 'Enter a name to create the test.',
|
|
28
|
+
dropZone: (label)=>`Drop ${label} content here`,
|
|
29
|
+
replaceConfirm: (label, original = ARM_LABELS.control)=>`This replaces the content in ${label} with a copy of ${original}. The original content stays in place.`,
|
|
30
|
+
replaceTitle: (label, test)=>test ? `Replace ${label} in “${test}”?` : `Replace ${label}?`,
|
|
13
31
|
replace: 'Replace',
|
|
14
|
-
|
|
32
|
+
pageFallback: 'Page',
|
|
33
|
+
createLabel: 'Set up test',
|
|
34
|
+
existingTest: 'Use an existing test',
|
|
35
|
+
sharedTest: 'This test is also used in another place. Changes here affect that test.',
|
|
36
|
+
createdUnbound: 'The test was created, but this block changed or was removed. Open the test to continue.',
|
|
15
37
|
creating: 'Creating…',
|
|
16
38
|
cancel: 'Cancel',
|
|
17
39
|
name: 'Name',
|
|
18
|
-
|
|
19
|
-
viewResults: 'View results',
|
|
40
|
+
openTest: 'Open the test',
|
|
20
41
|
nameExists: "This name is too close to an existing test. Choose a different name.",
|
|
21
42
|
createError: "Couldn't create the test. Try again.",
|
|
43
|
+
savingVersions: 'Saving version changes…',
|
|
44
|
+
refreshing: 'Refreshing results…',
|
|
22
45
|
loading: 'Loading test…',
|
|
23
46
|
loadError: "Couldn't load this test. Try selecting it again.",
|
|
24
|
-
orphan: (label)=>`${label} has content
|
|
47
|
+
orphan: (label, versions)=>`${label} has content on this page, but the test only has ${versions}. Visitors never see it.`,
|
|
48
|
+
addLeftover: 'Add to the test',
|
|
49
|
+
deleteContent: 'Delete its content',
|
|
50
|
+
deleteContentTitle: (label, test)=>test ? `Delete ${label} content from “${test}”?` : `Delete ${label} content?`,
|
|
51
|
+
deleteContentHelp: (label, count)=>`This deletes the ${count} ${count === 1 ? 'block' : 'blocks'} in ${label} from this page. Save the page to keep this change.`,
|
|
52
|
+
draftOnly: 'Only draft tests can add this version. Use a different test to include it.',
|
|
53
|
+
outsideTest: (label)=>`${label} · not in this test`,
|
|
54
|
+
showVersion: (label)=>`Show ${label} on the page`,
|
|
25
55
|
tabs: 'Test versions',
|
|
26
56
|
add: 'Add variant',
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
57
|
+
testGroup: 'Test',
|
|
58
|
+
versionsGroup: 'Versions',
|
|
59
|
+
moreGroup: 'More',
|
|
60
|
+
differentTest: 'Use a different test',
|
|
61
|
+
createAnother: 'Create a test',
|
|
62
|
+
readOnlyVersions: "You don't have permission to change this test's versions.",
|
|
63
|
+
traffic: 'Traffic (%)',
|
|
64
|
+
percent: '%',
|
|
65
|
+
saved: 'Saved',
|
|
66
|
+
removeVersion: 'Remove version',
|
|
30
67
|
emptyLabel: 'Enter a name for this version.',
|
|
31
68
|
remove: 'Remove',
|
|
32
|
-
removeTitle: (label)
|
|
33
|
-
removeHelp: 'This removes the version from the test and
|
|
69
|
+
removeTitle: (label, test)=>test ? `Remove ${label} from “${test}”?` : `Remove ${label}?`,
|
|
70
|
+
removeHelp: (count)=>count === 0 ? 'This removes the version from the test.' : `This removes the version from the test and deletes its ${count} ${count === 1 ? 'block' : 'blocks'} from this page. Save the page to keep this change.`,
|
|
71
|
+
removeShared: 'This test is also used in another place. The version is removed from the test there too.',
|
|
72
|
+
removeScopeUnknown: 'If this test is used on other pages, the version is removed from the test there too.',
|
|
34
73
|
removed: "Save the page to finish removing this version's content.",
|
|
35
|
-
|
|
74
|
+
removeUnclearedSteps: [
|
|
75
|
+
'Delete the leftover content from the outline.',
|
|
76
|
+
'Save the page.'
|
|
77
|
+
],
|
|
78
|
+
archivedStepsWhy: 'To keep this content on the page without the test, move it into regular blocks.',
|
|
79
|
+
archivedSteps: [
|
|
80
|
+
'Move the content out of the Experiment block on the canvas.',
|
|
81
|
+
'Remove the Experiment block.'
|
|
82
|
+
],
|
|
83
|
+
removeUncleared: "The version was removed from the test. Its content still needs to be removed from the page.",
|
|
36
84
|
lockedGeneric: "This test's versions can't change. View the test page for details.",
|
|
85
|
+
holdoutContent: 'Holdout visitors see the Original.',
|
|
37
86
|
holdoutPeople: (label, count)=>`${label}: ${count} people (not compared)`,
|
|
38
87
|
weight: (label)=>`${label} traffic (%)`,
|
|
39
88
|
invalidShare: 'Use a whole number from 0 to 100.',
|
|
@@ -43,16 +92,19 @@ export const editorCopy = {
|
|
|
43
92
|
decided: "This test has a decision, so its versions can't change. View the results on the test page.",
|
|
44
93
|
archived: "This test is archived, so its versions can't change. View the results on the test page."
|
|
45
94
|
},
|
|
46
|
-
staleEdit: '
|
|
95
|
+
staleEdit: 'This test changed. Check the saved settings and try again.',
|
|
96
|
+
nameChanged: 'This version name changed while you were editing.',
|
|
97
|
+
versionName: (label)=>`${label} version name`,
|
|
98
|
+
shareChanged: 'The saved shares changed while you were editing.',
|
|
47
99
|
writeError: "Couldn't complete this change. Try again.",
|
|
48
100
|
writeNetwork: "Couldn't reach the server. Check your connection and try again.",
|
|
49
101
|
writeUnreadable: "Couldn't read the server's response. Reload and try again.",
|
|
50
102
|
collecting: 'Collecting',
|
|
51
|
-
resultsUnavailable: "Results aren't available here.",
|
|
103
|
+
resultsUnavailable: "Results aren't available here. Try Refresh.",
|
|
52
104
|
refresh: 'Refresh',
|
|
53
105
|
people: (label, count)=>`${label}: ${count} people`
|
|
54
106
|
};
|
|
55
|
-
// Minimal editor-side equivalent of
|
|
107
|
+
// Minimal editor-side equivalent of testSurface/copy/common.ts: kept local to the editor creation flow.
|
|
56
108
|
// Never accept server text as a fallback.
|
|
57
109
|
export function writeRefusal(code, status) {
|
|
58
110
|
if (code === 'stale-edit') return editorCopy.staleEdit;
|
|
@@ -5,3 +5,6 @@ export declare class CreateRefused extends Error {
|
|
|
5
5
|
}
|
|
6
6
|
/** Shared lookup, complete draft creation and one retry for a racing slug collision. */
|
|
7
7
|
export declare function createTest(api: string, input: Omit<Parameters<typeof newTestBody>[0], 'slug'>): Promise<ExperimentRef>;
|
|
8
|
+
/** Choose a free display name before the existing slug/creation path. Called only by Set up test.
|
|
9
|
+
* Names are not unique: two editors may choose the same display name. Slugs are guarded separately. */
|
|
10
|
+
export declare function createBlockTest(api: string, pageTitle: string, arms: Parameters<typeof newTestBody>[0]['arms']): Promise<ExperimentRef>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { fetchAllDocs } from '../../lib/fetchAllDocs.js';
|
|
1
2
|
import { editorCopy } from './copy.js';
|
|
2
3
|
import { isSlugCollision, newTestBody, slugify, slugCandidate } from './editor.model.js';
|
|
3
4
|
/** Only a server refusal may supply editor-facing error text. */ export class CreateRefused extends Error {
|
|
@@ -59,3 +60,35 @@ function refusalMessage(body) {
|
|
|
59
60
|
};
|
|
60
61
|
}
|
|
61
62
|
}
|
|
63
|
+
// Keep generated names readable and bounded, including the numbered suffix.
|
|
64
|
+
const NAME_MAX_LENGTH = 200;
|
|
65
|
+
function blockTestName(title, index) {
|
|
66
|
+
const suffix = index === 1 ? ' test' : ` test ${index}`;
|
|
67
|
+
// Do not leave half a surrogate pair at the title boundary.
|
|
68
|
+
return title.slice(0, NAME_MAX_LENGTH - suffix.length).replace(/[\uD800-\uDBFF]$/, '').trimEnd() + suffix;
|
|
69
|
+
}
|
|
70
|
+
/** Choose a free display name before the existing slug/creation path. Called only by Set up test.
|
|
71
|
+
* Names are not unique: two editors may choose the same display name. Slugs are guarded separately. */ export async function createBlockTest(api, pageTitle, arms) {
|
|
72
|
+
const title = pageTitle.trim() || editorCopy.pageFallback;
|
|
73
|
+
const base = blockTestName(title, 1);
|
|
74
|
+
// A short common prefix also matches candidates whose title is trimmed for a number.
|
|
75
|
+
const query = new URLSearchParams({
|
|
76
|
+
depth: '0',
|
|
77
|
+
'select[name]': 'true',
|
|
78
|
+
'where[name][like]': base.slice(0, 64).replace(/[\uD800-\uDBFF]$/, '')
|
|
79
|
+
});
|
|
80
|
+
const response = await fetchAllDocs(`${api}/xp-experiments?${query}`, {
|
|
81
|
+
credentials: 'include'
|
|
82
|
+
});
|
|
83
|
+
if (!response.ok) throw new CreateRefused(refusalMessage(response.body));
|
|
84
|
+
const taken = new Set(response.docs.map((doc)=>doc.name));
|
|
85
|
+
for(let index = 1;; index++){
|
|
86
|
+
const name = blockTestName(title, index);
|
|
87
|
+
if (!taken.has(name)) return createTest(api, {
|
|
88
|
+
name,
|
|
89
|
+
kind: 'block',
|
|
90
|
+
unitType: 'visitor',
|
|
91
|
+
arms
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|