@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
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { sanitizeFallbackLocale } from 'payload';
|
|
2
|
+
import { fieldShouldBeLocalized, flattenTopLevelFields } from 'payload/shared';
|
|
3
|
+
import { documentEditor, puckCollections } from '../options.js';
|
|
4
|
+
import { placementSlugs } from './bindings.js';
|
|
5
|
+
import { contentBlocks, hasLocalizedFields } from '../transitions/contentFields.js';
|
|
6
|
+
import { isObject } from './model.js';
|
|
7
|
+
const identity = (data)=>data;
|
|
8
|
+
// Sanitized schemas are immutable. Weak ownership keeps separate Payload configs
|
|
9
|
+
// (and test harnesses) isolated; locale transforms survive individual readers/saves.
|
|
10
|
+
const localeTransforms = new WeakMap();
|
|
11
|
+
/** Compile only schema-marked localized branches. Opaque field values are never traversed.
|
|
12
|
+
* Copy ancestors only when a localized descendant changes; ordinary branches retain identity.
|
|
13
|
+
*/ function localeTransform(payloadConfig, collection, locale, fallback) {
|
|
14
|
+
const config = payloadConfig.collections?.find((entry)=>entry.slug === collection);
|
|
15
|
+
if (!payloadConfig.localization || !config) return identity;
|
|
16
|
+
let collections = localeTransforms.get(payloadConfig);
|
|
17
|
+
if (!collections) localeTransforms.set(payloadConfig, collections = new WeakMap());
|
|
18
|
+
let cached = collections.get(config);
|
|
19
|
+
if (!cached || cached.fields !== config.fields) collections.set(config, cached = {
|
|
20
|
+
fields: config.fields,
|
|
21
|
+
transforms: new Map()
|
|
22
|
+
});
|
|
23
|
+
const key = JSON.stringify([
|
|
24
|
+
locale,
|
|
25
|
+
fallback
|
|
26
|
+
]);
|
|
27
|
+
const existing = cached.transforms.get(key);
|
|
28
|
+
if (existing) return existing;
|
|
29
|
+
const blocks = payloadConfig.blocks ?? [];
|
|
30
|
+
const compiled = new Map();
|
|
31
|
+
function compile(fields, parentIsLocalized = false) {
|
|
32
|
+
if (parentIsLocalized) return (data)=>data;
|
|
33
|
+
const cached = compiled.get(fields);
|
|
34
|
+
if (cached) return cached;
|
|
35
|
+
let project;
|
|
36
|
+
const transform = (data, write, previous)=>project(data, write, previous);
|
|
37
|
+
compiled.set(fields, transform);
|
|
38
|
+
const steps = flattenTopLevelFields(fields).flatMap((field)=>{
|
|
39
|
+
if (!('name' in field) || !field.name) return [];
|
|
40
|
+
const name = field.name;
|
|
41
|
+
const localized = fieldShouldBeLocalized({
|
|
42
|
+
field,
|
|
43
|
+
parentIsLocalized
|
|
44
|
+
});
|
|
45
|
+
const parent = parentIsLocalized || localized;
|
|
46
|
+
const children = 'fields' in field && hasLocalizedFields(field.fields, payloadConfig) && [
|
|
47
|
+
'group',
|
|
48
|
+
'array',
|
|
49
|
+
'tab'
|
|
50
|
+
].includes(field.type) ? compile(field.fields, parent) : undefined;
|
|
51
|
+
const variants = field.type === 'blocks' ? new Map([
|
|
52
|
+
...field.blocks ?? [],
|
|
53
|
+
...field.blockReferences ?? []
|
|
54
|
+
].flatMap((ref)=>{
|
|
55
|
+
const block = typeof ref === 'string' ? blocks.find((block)=>block.slug === ref) : ref;
|
|
56
|
+
return block && hasLocalizedFields(block.fields, payloadConfig) ? [
|
|
57
|
+
[
|
|
58
|
+
block.slug,
|
|
59
|
+
compile(block.fields, parent)
|
|
60
|
+
]
|
|
61
|
+
] : [];
|
|
62
|
+
})) : undefined;
|
|
63
|
+
if (!localized && !children && !variants) return [];
|
|
64
|
+
return [
|
|
65
|
+
(data, write, previous)=>{
|
|
66
|
+
if (!(name in data)) return data;
|
|
67
|
+
let value = data[name];
|
|
68
|
+
const prior = previous?.[name];
|
|
69
|
+
if (localized && write) value = {
|
|
70
|
+
...isObject(prior) ? prior : {},
|
|
71
|
+
[locale]: value
|
|
72
|
+
};
|
|
73
|
+
else {
|
|
74
|
+
if (localized) {
|
|
75
|
+
const values = isObject(value) ? value : {};
|
|
76
|
+
value = values[locale];
|
|
77
|
+
if (fallback && fallback !== locale && (value == null || (field.type === 'text' || field.type === 'textarea') && value === '')) {
|
|
78
|
+
for (const code of Array.isArray(fallback) ? fallback : [
|
|
79
|
+
fallback
|
|
80
|
+
]){
|
|
81
|
+
const candidate = values[code];
|
|
82
|
+
if (candidate != null && candidate !== '') {
|
|
83
|
+
value = candidate;
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const visit = (row, old)=>{
|
|
90
|
+
if (!isObject(row)) return row;
|
|
91
|
+
const transform = children ?? (variants && typeof row.blockType === 'string' ? variants.get(row.blockType) : undefined);
|
|
92
|
+
return transform ? transform(row, write, isObject(old) ? old : undefined) : row;
|
|
93
|
+
};
|
|
94
|
+
if (children || variants) {
|
|
95
|
+
if (Array.isArray(value)) {
|
|
96
|
+
const rows = value.map((row, index)=>visit(row, Array.isArray(prior) ? isObject(row) && row.id != null ? prior.find((old)=>isObject(old) && old.id === row.id) : prior[index] : undefined));
|
|
97
|
+
if (rows.some((row, index)=>row !== value[index])) value = rows;
|
|
98
|
+
} else value = visit(value, prior);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return value === data[name] ? data : {
|
|
102
|
+
...data,
|
|
103
|
+
[name]: value
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
];
|
|
107
|
+
});
|
|
108
|
+
project = (data, write = false, previous)=>steps.reduce((result, step)=>step(result, write, previous), data);
|
|
109
|
+
return transform;
|
|
110
|
+
}
|
|
111
|
+
const transform = hasLocalizedFields(config.fields ?? [], payloadConfig) ? compile(config.fields ?? []) : identity;
|
|
112
|
+
cached.transforms.set(key, transform);
|
|
113
|
+
return transform;
|
|
114
|
+
}
|
|
115
|
+
export function placementLocaleContent(req, collection, doc, input) {
|
|
116
|
+
return placementReader(req, collection).read(doc, input).doc;
|
|
117
|
+
}
|
|
118
|
+
/** The single document → locale view → editor/placements boundary. Compiled schemas are shared per sanitized config.
|
|
119
|
+
* Local API and form documents explicitly bypass all-locale projection.
|
|
120
|
+
*/ export function placementReader(req, collection, options = req.payload.config.custom?.xp) {
|
|
121
|
+
const views = placementLocaleViews(req, collection, options);
|
|
122
|
+
const transforms = new Map();
|
|
123
|
+
return {
|
|
124
|
+
views,
|
|
125
|
+
documentViews: schemaLocaleViews(req, collection),
|
|
126
|
+
read (doc, input, view) {
|
|
127
|
+
const requested = view ?? {
|
|
128
|
+
locale: req.locale ?? '',
|
|
129
|
+
fallbackLocale: req.fallbackLocale ?? false
|
|
130
|
+
};
|
|
131
|
+
const selected = requested.locale === 'all' ? {
|
|
132
|
+
...requested,
|
|
133
|
+
locale: req.payload.config.localization ? req.payload.config.localization.defaultLocale : ''
|
|
134
|
+
} : requested;
|
|
135
|
+
let content, resolved = false;
|
|
136
|
+
const resolve = ()=>{
|
|
137
|
+
if (resolved) return content;
|
|
138
|
+
resolved = true;
|
|
139
|
+
content = doc ?? undefined;
|
|
140
|
+
if (doc && input === 'all-locales' && req.payload.config.localization && selected.locale !== 'all') {
|
|
141
|
+
const locale = selected.locale || req.payload.config.localization.defaultLocale;
|
|
142
|
+
const key = JSON.stringify([
|
|
143
|
+
locale,
|
|
144
|
+
selected.fallbackLocale
|
|
145
|
+
]);
|
|
146
|
+
let transform = transforms.get(key);
|
|
147
|
+
if (!transform) {
|
|
148
|
+
transform = localeTransform(req.payload.config, collection, locale, sanitizeFallbackLocale({
|
|
149
|
+
fallbackLocale: selected.fallbackLocale,
|
|
150
|
+
locale,
|
|
151
|
+
localization: req.payload.config.localization
|
|
152
|
+
}));
|
|
153
|
+
transforms.set(key, transform);
|
|
154
|
+
}
|
|
155
|
+
content = transform(doc);
|
|
156
|
+
}
|
|
157
|
+
return content;
|
|
158
|
+
};
|
|
159
|
+
let editor, slugs;
|
|
160
|
+
return {
|
|
161
|
+
view: selected,
|
|
162
|
+
get doc () {
|
|
163
|
+
return resolve();
|
|
164
|
+
},
|
|
165
|
+
get editor () {
|
|
166
|
+
return editor ??= doc ? documentEditor(options ?? {}, collection, resolve()) : 'page';
|
|
167
|
+
},
|
|
168
|
+
get slugs () {
|
|
169
|
+
return slugs ??= placementSlugs(options ?? {}, collection, resolve());
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
export function allPlacementSlugs(req, collection, doc, input) {
|
|
176
|
+
const reader = placementReader(req, collection);
|
|
177
|
+
return [
|
|
178
|
+
...new Set(reader.views.flatMap((view)=>reader.read(doc, input, view).slugs))
|
|
179
|
+
];
|
|
180
|
+
}
|
|
181
|
+
export const placementDocumentKey = (collection, id, view)=>JSON.stringify([
|
|
182
|
+
collection,
|
|
183
|
+
String(id),
|
|
184
|
+
view
|
|
185
|
+
]);
|
|
186
|
+
export function localeRequest(req, view) {
|
|
187
|
+
// Fetch Request properties are prototype getters and disappear in a spread.
|
|
188
|
+
// Local API setup needs headers/url; hooks also retain method and cancellation.
|
|
189
|
+
return {
|
|
190
|
+
...req,
|
|
191
|
+
headers: req.headers,
|
|
192
|
+
url: req.url,
|
|
193
|
+
method: req.method,
|
|
194
|
+
signal: req.signal,
|
|
195
|
+
...view
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
/** Audits may contain localized arm-select tags outside registered editors. */ function schemaLocaleViews(req, collection) {
|
|
199
|
+
const localization = req.payload.config.localization;
|
|
200
|
+
const config = req.payload.config.collections?.find((entry)=>entry.slug === collection);
|
|
201
|
+
return localization && hasLocalizedFields(config?.fields ?? [], req.payload.config) ? (localization.localeCodes ?? localization.locales.map((entry)=>typeof entry === 'string' ? entry : entry.code)).map((locale)=>({
|
|
202
|
+
locale,
|
|
203
|
+
fallbackLocale: sanitizeFallbackLocale({
|
|
204
|
+
fallbackLocale: null,
|
|
205
|
+
locale,
|
|
206
|
+
localization
|
|
207
|
+
})
|
|
208
|
+
})) : [
|
|
209
|
+
{
|
|
210
|
+
locale: '',
|
|
211
|
+
fallbackLocale: false
|
|
212
|
+
}
|
|
213
|
+
];
|
|
214
|
+
}
|
|
215
|
+
/** Canonical views of registered content, without multiplying nonlocalized rows. */ export function placementLocaleViews(req, collection, options = req.payload.config.custom?.xp ?? {}) {
|
|
216
|
+
const localization = req.payload.config.localization;
|
|
217
|
+
const config = req.payload.config.collections?.find((entry)=>entry.slug === collection);
|
|
218
|
+
const names = new Set([
|
|
219
|
+
...puckCollections(options).filter((entry)=>entry.slug === collection).map((entry)=>entry.field),
|
|
220
|
+
...(options.blocks?.collections ?? []).filter((entry)=>entry.slug === collection).map((entry)=>entry.field)
|
|
221
|
+
]);
|
|
222
|
+
const localized = config && hasLocalizedFields(config.fields ?? [], req.payload.config) && (Boolean(options.blocks?.collections.some((entry)=>entry.slug === collection && entry.appliesTo)) || flattenTopLevelFields(config.fields ?? []).some((field)=>'name' in field && names.has(field.name) && ('localized' in field && field.localized || 'fields' in field && hasLocalizedFields(field.fields, req.payload.config) || field.type === 'blocks' && hasLocalizedFields(contentBlocks(field, req.payload.config.blocks).flatMap((block)=>block.fields), req.payload.config))));
|
|
223
|
+
return localization && localized ? (localization.localeCodes ?? localization.locales.map((entry)=>typeof entry === 'string' ? entry : entry.code)).map((locale)=>({
|
|
224
|
+
locale,
|
|
225
|
+
fallbackLocale: sanitizeFallbackLocale({
|
|
226
|
+
fallbackLocale: null,
|
|
227
|
+
locale,
|
|
228
|
+
localization
|
|
229
|
+
})
|
|
230
|
+
})) : [
|
|
231
|
+
{
|
|
232
|
+
locale: '',
|
|
233
|
+
fallbackLocale: false
|
|
234
|
+
}
|
|
235
|
+
];
|
|
236
|
+
}
|
|
237
|
+
/** Compare every locale view: a localized edit can also change fallback
|
|
238
|
+
* content in another locale. Whole-row removals replace every view with absence.
|
|
239
|
+
* The incoming hook document is already flattened to the writing locale.
|
|
240
|
+
*/ export function removedPlacementViews(req, collection, before, after, removingPage, input = 'localized') {
|
|
241
|
+
const result = new Map();
|
|
242
|
+
if (!before) return result;
|
|
243
|
+
const reader = placementReader(req, collection);
|
|
244
|
+
const rawAfter = input === 'all-locales' ? after : mergedPlacementLocales(req, collection, before, after);
|
|
245
|
+
for (const view of reader.views){
|
|
246
|
+
const previous = reader.read(before, 'all-locales', view).slugs;
|
|
247
|
+
const next = removingPage ? [] : reader.read(rawAfter, 'all-locales', view).slugs;
|
|
248
|
+
for (const slug of previous.filter((slug)=>!next.includes(slug)))result.set(slug, [
|
|
249
|
+
...result.get(slug) ?? [],
|
|
250
|
+
view
|
|
251
|
+
]);
|
|
252
|
+
}
|
|
253
|
+
return result;
|
|
254
|
+
}
|
|
255
|
+
/** Rebuild unchanged locale maps around a flattened hook write before reading each view. */ export function mergedPlacementLocales(req, collection, before, after) {
|
|
256
|
+
const localization = req.payload.config.localization;
|
|
257
|
+
if (!localization || req.locale === 'all') return after;
|
|
258
|
+
return localeTransform(req.payload.config, collection, req.locale || localization.defaultLocale, false)(after, true, before);
|
|
259
|
+
}
|
|
260
|
+
/** Project host document adapters before they run. Callers own path normalization
|
|
261
|
+
* and use sortLockKeys for the existing experiment → page-path lock ordering. */ export function placementDocumentPaths(req, collection, docs, input, pathOf) {
|
|
262
|
+
const reader = placementReader(req, collection);
|
|
263
|
+
return docs.flatMap((raw)=>reader.documentViews.flatMap((view)=>{
|
|
264
|
+
const doc = reader.read(raw, input, view).doc;
|
|
265
|
+
const path = doc ? pathOf(doc) : null;
|
|
266
|
+
return path === null ? [] : [
|
|
267
|
+
path
|
|
268
|
+
];
|
|
269
|
+
}));
|
|
270
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SURFACE_COPY } from '../../testSurface/copy/surface.js';
|
|
1
2
|
import * as paths from '../../admin/paths.js';
|
|
2
3
|
import { managedAccess } from '../access.js';
|
|
3
4
|
import { serializeAttributeKeys, serializeFlagPoints } from '../serialize.js';
|
|
@@ -37,22 +38,30 @@ export function experimentsCollection(options) {
|
|
|
37
38
|
drafts: false,
|
|
38
39
|
maxPerDoc: 50
|
|
39
40
|
},
|
|
41
|
+
labels: {
|
|
42
|
+
singular: SURFACE_COPY.test,
|
|
43
|
+
plural: SURFACE_COPY.navAllTests
|
|
44
|
+
},
|
|
40
45
|
access: {
|
|
41
46
|
...managedAccess(options),
|
|
42
|
-
delete: async ({ req })=>
|
|
47
|
+
delete: async ({ req, id })=>{
|
|
48
|
+
if (await options.access.manage({
|
|
43
49
|
req
|
|
44
|
-
})
|
|
50
|
+
}) !== true) return false;
|
|
51
|
+
// Single deletes report status through the locked beforeDelete guard.
|
|
52
|
+
// Payload catches per-document hook failures in bulk deletes, so keep their status filter in access.
|
|
53
|
+
return id != null ? true : {
|
|
45
54
|
status: {
|
|
46
55
|
in: [
|
|
47
56
|
'draft',
|
|
48
57
|
'archived'
|
|
49
58
|
]
|
|
50
59
|
}
|
|
51
|
-
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
52
62
|
},
|
|
53
63
|
admin: {
|
|
54
|
-
|
|
55
|
-
group: false,
|
|
64
|
+
group: SURFACE_COPY.title,
|
|
56
65
|
useAsTitle: 'name',
|
|
57
66
|
defaultColumns: [
|
|
58
67
|
'name',
|
|
@@ -63,7 +72,7 @@ export function experimentsCollection(options) {
|
|
|
63
72
|
components: {
|
|
64
73
|
views: {
|
|
65
74
|
list: {
|
|
66
|
-
Component: paths.
|
|
75
|
+
Component: paths.XP_TESTS_COLLECTION_LIST
|
|
67
76
|
},
|
|
68
77
|
edit: {
|
|
69
78
|
default: {
|
|
@@ -101,8 +110,8 @@ export function experimentsCollection(options) {
|
|
|
101
110
|
],
|
|
102
111
|
afterError: [
|
|
103
112
|
({ error })=>{
|
|
104
|
-
// Payload preserves public Error status/message, but omits custom codes.
|
|
105
|
-
if (error instanceof XpRefusal
|
|
113
|
+
// Payload preserves public Error status/message, but omits custom codes; the admin maps refusals by code.
|
|
114
|
+
if (error instanceof XpRefusal) {
|
|
106
115
|
return {
|
|
107
116
|
status: error.status,
|
|
108
117
|
response: {
|
|
@@ -3,8 +3,8 @@ import { xpOptionsFromReq } from '../../options/fromReq.js';
|
|
|
3
3
|
export const deleteGuard = async ({ req, id })=>{
|
|
4
4
|
await deleteExperiment(req, id);
|
|
5
5
|
};
|
|
6
|
-
export const deleteGuardAfter = async ({ req,
|
|
7
|
-
await deleteExperimentAfter(req
|
|
6
|
+
export const deleteGuardAfter = async ({ req, doc })=>{
|
|
7
|
+
await deleteExperimentAfter(req);
|
|
8
8
|
return doc;
|
|
9
9
|
};
|
|
10
10
|
export const deleteGuardBeforeOperation = async ({ operation, args, req })=>{
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { withSlotsFor } from '../../arms/model.js';
|
|
1
2
|
import { XpLockedFieldError, XpRefusal } from '../../errors.js';
|
|
2
3
|
import { XP_IF_UPDATED_AT_HEADER } from '../../constants.js';
|
|
3
4
|
import { txExecutor } from '../../db/executor.js';
|
|
@@ -64,6 +65,24 @@ const dates = new Set([
|
|
|
64
65
|
}
|
|
65
66
|
const same = (a, b, path)=>JSON.stringify(normalize(a, path)) === JSON.stringify(normalize(b, path));
|
|
66
67
|
export const lockHook = async ({ data, originalDoc, operation, req })=>{
|
|
68
|
+
const kind = operation === 'create' ? data.kind : originalDoc.kind;
|
|
69
|
+
const storedArms = operation === 'update' ? originalDoc.arms : undefined;
|
|
70
|
+
const canonicalSlots = (value)=>{
|
|
71
|
+
if (kind !== 'block' || !Array.isArray(value) || value.some((row)=>!isObject(row))) return value;
|
|
72
|
+
return withSlotsFor(value, 'block');
|
|
73
|
+
};
|
|
74
|
+
const canonicalArms = canonicalSlots(storedArms);
|
|
75
|
+
// Payload runs collection beforeChange before field validation on Create,
|
|
76
|
+
// Update and Restore. Derive slots here so the arms validator sees them.
|
|
77
|
+
const arms = data.arms === undefined ? storedArms : data.arms;
|
|
78
|
+
const repaired = arms === storedArms ? canonicalArms : canonicalSlots(arms);
|
|
79
|
+
if (repaired !== arms) {
|
|
80
|
+
if (operation === 'create') data = {
|
|
81
|
+
...data,
|
|
82
|
+
arms: repaired
|
|
83
|
+
};
|
|
84
|
+
else data.arms = repaired;
|
|
85
|
+
}
|
|
67
86
|
if (req.context.xpTransition === true) return data;
|
|
68
87
|
const baseline = req.headers.get(XP_IF_UPDATED_AT_HEADER);
|
|
69
88
|
if (operation === 'update' && baseline !== null) {
|
|
@@ -71,7 +90,7 @@ export const lockHook = async ({ data, originalDoc, operation, req })=>{
|
|
|
71
90
|
// so a competing save observes the preceding save's committed timestamp.
|
|
72
91
|
const stored = await lockExperimentUpdatedAt(txExecutor(req), originalDoc.id);
|
|
73
92
|
if (stored === null || new Date(baseline).getTime() !== new Date(stored).getTime()) {
|
|
74
|
-
throw new XpRefusal('stale-edit', '
|
|
93
|
+
throw new XpRefusal('stale-edit', 'This test changed. Read the latest settings and try again.', undefined, 409);
|
|
75
94
|
}
|
|
76
95
|
}
|
|
77
96
|
const admin = async ()=>{
|
|
@@ -139,7 +158,7 @@ export const lockHook = async ({ data, originalDoc, operation, req })=>{
|
|
|
139
158
|
].includes(field) && isObject(value)) {
|
|
140
159
|
for (const [key, nested] of Object.entries(value))await check(`${field}.${key}`, nested, originalDoc[field]?.[key]);
|
|
141
160
|
} else {
|
|
142
|
-
await check(field, value, originalDoc[field]);
|
|
161
|
+
await check(field, value, field === 'arms' ? canonicalArms : originalDoc[field]);
|
|
143
162
|
// Replacing the group also changes its method, including clearing it.
|
|
144
163
|
if (field === 'analysis' && !same(value, originalDoc.analysis, field) && originalDoc.analysis?.method != null && !await admin()) throw new XpLockedFieldError('analysis.method', status);
|
|
145
164
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { assertReadCommitted } from '../../db/adapter.js';
|
|
1
2
|
import { pickSlug } from '../../db/slugs.js';
|
|
2
3
|
import { pooledExecutor, txExecutor } from '../../db/executor.js';
|
|
3
4
|
export const pickExperimentSlug = async ({ req, data, operation })=>{
|
|
4
5
|
if (operation !== 'create' || typeof data.slug !== 'string' || !data.slug) return data;
|
|
5
6
|
const transactional = await req.transactionID != null;
|
|
7
|
+
if (transactional) await assertReadCommitted(req);
|
|
6
8
|
data.slug = await pickSlug(transactional ? txExecutor(req) : pooledExecutor(req.payload), data.slug, transactional);
|
|
7
9
|
return data;
|
|
8
10
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { SURFACE_COPY } from '../testSurface/copy/surface.js';
|
|
1
2
|
import { CLICK_KEY, isClickSource, validClickSource } from '../goals/key.js';
|
|
2
|
-
import { XP_METRIC_SOURCE_SELECT } from '../admin/paths.js';
|
|
3
|
+
import { XP_METRIC_SOURCE_SELECT, XP_GOALS_COLLECTION_LIST, XP_GOAL_EDIT_REDIRECT } from '../admin/paths.js';
|
|
3
4
|
import { managedAccess } from './access.js';
|
|
4
5
|
import { serializeMetricSources } from './serialize.js';
|
|
5
6
|
import { validateCappingType, validateCappingValue } from './metricValidation.js';
|
|
@@ -11,14 +12,25 @@ export function metricsCollection(options) {
|
|
|
11
12
|
graphQL: false,
|
|
12
13
|
disableDuplicate: true,
|
|
13
14
|
versions: false,
|
|
14
|
-
// group:false hides navigation while keeping collection routes reachable (hidden causes 404s).
|
|
15
15
|
labels: {
|
|
16
16
|
singular: 'Goal',
|
|
17
17
|
plural: 'Goals'
|
|
18
18
|
},
|
|
19
19
|
admin: {
|
|
20
|
-
group:
|
|
21
|
-
useAsTitle: 'name'
|
|
20
|
+
group: SURFACE_COPY.title,
|
|
21
|
+
useAsTitle: 'name',
|
|
22
|
+
components: {
|
|
23
|
+
views: {
|
|
24
|
+
list: {
|
|
25
|
+
Component: XP_GOALS_COLLECTION_LIST
|
|
26
|
+
},
|
|
27
|
+
edit: {
|
|
28
|
+
default: {
|
|
29
|
+
Component: XP_GOAL_EDIT_REDIRECT
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
22
34
|
},
|
|
23
35
|
access: managedAccess(options),
|
|
24
36
|
hooks: {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { assertReadCommitted } from '../db/adapter.js';
|
|
1
2
|
import { pooledExecutor, txExecutor } from '../db/executor.js';
|
|
2
3
|
import { findMetricUsage, lockMetricRow } from '../db/metricUsage.js';
|
|
3
4
|
/** Payload's REST formatter preserves public plugin errors and their 4xx status. */ export class XpGoalInUseError extends Error {
|
|
@@ -8,6 +9,7 @@ import { findMetricUsage, lockMetricRow } from '../db/metricUsage.js';
|
|
|
8
9
|
async function executor(req, id, mode) {
|
|
9
10
|
const transactionID = await req.transactionID;
|
|
10
11
|
if (transactionID != null) {
|
|
12
|
+
await assertReadCommitted(req);
|
|
11
13
|
const exec = txExecutor(req);
|
|
12
14
|
await lockMetricRow(exec, id, mode);
|
|
13
15
|
return exec;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { browserWritableMetric } from '../events/writable.js';
|
|
1
2
|
export function serializeFlagPoints(options) {
|
|
2
3
|
return (options.flagPoints ?? []).map(({ id, label, description, params, defaultParams })=>({
|
|
3
4
|
id,
|
|
@@ -19,19 +20,19 @@ export function serializeMetricSources(options) {
|
|
|
19
20
|
keyedBy: 'visitor',
|
|
20
21
|
clientWritable: true
|
|
21
22
|
},
|
|
22
|
-
...(options.metricSources ?? []).map(({ id, label, kind, keyedBy
|
|
23
|
+
...(options.metricSources ?? []).map(({ id, label, kind, keyedBy })=>({
|
|
23
24
|
id,
|
|
24
25
|
label,
|
|
25
26
|
kind,
|
|
26
27
|
keyedBy,
|
|
27
|
-
clientWritable:
|
|
28
|
+
clientWritable: browserWritableMetric(id, options)
|
|
28
29
|
})),
|
|
29
|
-
...(options.eventSources ?? []).map(({ name
|
|
30
|
+
...(options.eventSources ?? []).map(({ name })=>({
|
|
30
31
|
id: `events:${name}`,
|
|
31
32
|
label: name,
|
|
32
33
|
kind: 'binomial',
|
|
33
34
|
keyedBy: 'visitor',
|
|
34
|
-
clientWritable
|
|
35
|
+
clientWritable: browserWritableMetric(`events:${name}`, options)
|
|
35
36
|
}))
|
|
36
37
|
];
|
|
37
38
|
}
|
package/dist/constants.d.ts
CHANGED
|
@@ -7,3 +7,4 @@ export declare const XP_PREVIEW_PARAM = "xp_preview";
|
|
|
7
7
|
export declare const XP_MANIFEST_KEY_HEADER = "x-xp-manifest-key";
|
|
8
8
|
export declare const XP_REQUEST_HEADER = "x-xp-request";
|
|
9
9
|
export declare const XP_IF_UPDATED_AT_HEADER = "x-xp-if-updated-at";
|
|
10
|
+
export declare const USER_BROWSER_CONVERSION_PREFIX = "conversion:cu:";
|
package/dist/constants.js
CHANGED
|
@@ -7,3 +7,4 @@ export const XP_PREVIEW_PARAM = 'xp_preview';
|
|
|
7
7
|
export const XP_MANIFEST_KEY_HEADER = 'x-xp-manifest-key';
|
|
8
8
|
export const XP_REQUEST_HEADER = 'x-xp-request';
|
|
9
9
|
export const XP_IF_UPDATED_AT_HEADER = 'x-xp-if-updated-at';
|
|
10
|
+
export const USER_BROWSER_CONVERSION_PREFIX = 'conversion:cu:';
|
package/dist/db/adapter.d.ts
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { APIError, type Payload, type PayloadRequest } from 'payload';
|
|
2
|
+
export declare class XpTransactionIsolationError extends APIError {
|
|
3
|
+
constructor();
|
|
4
|
+
}
|
|
5
|
+
/** Payload's initTransaction cannot pass options to the adapter. Like that
|
|
6
|
+
* helper, publish the pending transaction on the request before awaiting it.
|
|
7
|
+
*/
|
|
8
|
+
export declare function initTransitionTransaction(req: PayloadRequest): Promise<boolean>;
|
|
9
|
+
export declare function assertReadCommitted(req: PayloadRequest): Promise<void>;
|
|
2
10
|
export declare function assertPostgresAdapter(payload: Payload): void;
|
|
3
11
|
export declare function probeTransactions(payload: Payload): Promise<void>;
|
package/dist/db/adapter.js
CHANGED
|
@@ -1,3 +1,72 @@
|
|
|
1
|
+
import { APIError } from 'payload';
|
|
2
|
+
import { XpNoTransactionError } from '../errors.js';
|
|
3
|
+
import { API_MESSAGES } from '../testSurface/copy/common.js';
|
|
4
|
+
import { transactionSession, txExecutor } from './executor.js';
|
|
5
|
+
const transitionIsolation = 'read committed';
|
|
6
|
+
const isolationMessage = 'Experiments requires PostgreSQL READ COMMITTED so it can see changes committed while waiting for locks. Set the Postgres adapter\'s transactionOptions.isolationLevel to "read committed" or remove the override.';
|
|
7
|
+
const checkedSessions = new WeakMap();
|
|
8
|
+
export class XpTransactionIsolationError extends APIError {
|
|
9
|
+
constructor(){
|
|
10
|
+
super(API_MESSAGES.transactionIsolation, 500, null, true);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/** Payload's initTransaction cannot pass options to the adapter. Like that
|
|
14
|
+
* helper, publish the pending transaction on the request before awaiting it.
|
|
15
|
+
*/ export async function initTransitionTransaction(req) {
|
|
16
|
+
if (req.transactionID != null) {
|
|
17
|
+
await req.transactionID;
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
const db = req.payload.db;
|
|
21
|
+
const pending = db.beginTransaction({
|
|
22
|
+
...db.transactionOptions || {},
|
|
23
|
+
isolationLevel: transitionIsolation
|
|
24
|
+
}).then((id)=>{
|
|
25
|
+
if (id == null) throw new XpNoTransactionError();
|
|
26
|
+
const session = db.sessions?.[id];
|
|
27
|
+
if (session) checkedSessions.set(session, Promise.resolve());
|
|
28
|
+
req.transactionID = id;
|
|
29
|
+
return id;
|
|
30
|
+
});
|
|
31
|
+
req.transactionID = pending;
|
|
32
|
+
try {
|
|
33
|
+
await pending;
|
|
34
|
+
return true;
|
|
35
|
+
} catch (error) {
|
|
36
|
+
if (req.transactionID === pending) delete req.transactionID;
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/** A borrowed transaction may already have taken its snapshot. Check the
|
|
41
|
+
* effective isolation on that session before relying on a post-lock read.
|
|
42
|
+
*/ async function isReadCommitted(exec) {
|
|
43
|
+
const { rows } = await exec.query('SHOW transaction_isolation');
|
|
44
|
+
const level = rows[0]?.transaction_isolation;
|
|
45
|
+
// PostgreSQL implements READ UNCOMMITTED as READ COMMITTED (docs §13.2).
|
|
46
|
+
return level === transitionIsolation || level === 'read uncommitted';
|
|
47
|
+
}
|
|
48
|
+
export async function assertReadCommitted(req) {
|
|
49
|
+
const transaction = {
|
|
50
|
+
payload: req.payload,
|
|
51
|
+
transactionID: await req.transactionID
|
|
52
|
+
};
|
|
53
|
+
// The adapter resolves the ID to a unique session object until commit or
|
|
54
|
+
// rollback. Cache the pending check so concurrent hooks share the same query.
|
|
55
|
+
const session = await transactionSession(transaction);
|
|
56
|
+
let checked = checkedSessions.get(session);
|
|
57
|
+
if (!checked) {
|
|
58
|
+
checked = isReadCommitted(txExecutor(transaction)).then((valid)=>{
|
|
59
|
+
if (!valid) {
|
|
60
|
+
try {
|
|
61
|
+
console.error('Experiments requires PostgreSQL READ COMMITTED so it can see changes committed while waiting for locks. Set the Postgres adapter\'s transactionOptions.isolationLevel to "read committed" or remove the override.');
|
|
62
|
+
} catch {}
|
|
63
|
+
throw new XpTransactionIsolationError();
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
checkedSessions.set(session, checked);
|
|
67
|
+
}
|
|
68
|
+
await checked;
|
|
69
|
+
}
|
|
1
70
|
export function assertPostgresAdapter(payload) {
|
|
2
71
|
// @payloadcms/db-postgres/dist/index.js:133 declares this package marker.
|
|
3
72
|
if (payload.db.packageName !== '@payloadcms/db-postgres') throw new Error('Experiments requires @payloadcms/db-postgres');
|
|
@@ -5,5 +74,12 @@ export function assertPostgresAdapter(payload) {
|
|
|
5
74
|
export async function probeTransactions(payload) {
|
|
6
75
|
const id = await payload.db.beginTransaction();
|
|
7
76
|
if (id == null) throw new Error('Experiments transactions are disabled');
|
|
8
|
-
|
|
77
|
+
try {
|
|
78
|
+
if (!await isReadCommitted(txExecutor({
|
|
79
|
+
payload,
|
|
80
|
+
transactionID: id
|
|
81
|
+
}))) throw new Error(isolationMessage);
|
|
82
|
+
} finally{
|
|
83
|
+
await payload.db.rollbackTransaction(id);
|
|
84
|
+
}
|
|
9
85
|
}
|
package/dist/db/appends.d.ts
CHANGED
|
@@ -24,6 +24,19 @@ type AppendArgs<T> = {
|
|
|
24
24
|
* before the audit savepoint can recover.
|
|
25
25
|
*/
|
|
26
26
|
export declare function storedContent(req: PayloadRequest, collection: string, id: DocId): Promise<Record<string, unknown> | undefined>;
|
|
27
|
+
export interface PlacementSavePath {
|
|
28
|
+
versionId?: DocId;
|
|
29
|
+
bulk?: boolean;
|
|
30
|
+
draft?: boolean;
|
|
31
|
+
trashing?: boolean;
|
|
32
|
+
publishSpecificLocale?: string;
|
|
33
|
+
}
|
|
34
|
+
/** Payload 3.90.2: updateByID starts from the latest version; update (bulk)
|
|
35
|
+
* starts from main rows except draft/trash saves. utilities/update then replaces
|
|
36
|
+
* unselected locales with the latest published version (publishSpecificLocale).
|
|
37
|
+
* Localized publication status is refused at init. Restore uses the selected version. */
|
|
38
|
+
export declare function placementMergeBase(path: PlacementSavePath): 'restore' | 'main' | 'published' | 'latest';
|
|
39
|
+
export declare function placementWriteContent(req: PayloadRequest, collection: string, id: DocId, main: Record<string, unknown> | undefined, path?: PlacementSavePath): Promise<Record<string, unknown> | undefined>;
|
|
27
40
|
/** Read the main collection row BEFORE the host write. Draft version retention
|
|
28
41
|
* and unpublishing cannot remove this baseline.
|
|
29
42
|
*/
|