@delmaredigital/payload-experiments 0.4.0-rc.3 → 0.4.0-rc.4
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/dist/admin/LayerUsage.js +1 -1
- package/dist/admin/MetricSourceSelect.js +2 -2
- package/dist/admin/PlacementStatus.js +1 -1
- package/dist/admin/TestsDashboardCards.js +2 -2
- package/dist/admin/TestsNavLink.js +2 -2
- package/dist/admin/blocks/BlockPanel.js +3 -3
- package/dist/admin/blocks/TestBlockField.js +3 -3
- package/dist/admin/blocks/formApi.js +1 -1
- package/dist/admin/blocks/model.js +1 -1
- package/dist/admin/blocks/statusCache.js +1 -1
- package/dist/admin/components/RootViewMessage.js +1 -1
- package/dist/admin/copy/blocks.d.ts +2 -2
- package/dist/admin/copy/blocks.js +3 -2
- package/dist/admin/copy/goals.d.ts +5 -1
- package/dist/admin/copy/goals.js +9 -3
- package/dist/admin/goals/XpGoalField.js +155 -129
- package/dist/admin/goals/xpGoalField.css +2 -3
- package/dist/admin/status.model.js +1 -1
- package/dist/admin/surface/ResultsRoute.d.ts +2 -1
- package/dist/admin/surface/ResultsRoute.js +4 -3
- package/dist/admin/surface/SurfaceShell.js +2 -2
- package/dist/admin/surface/TestsHome.d.ts +1 -1
- package/dist/admin/surface/TestsHome.js +3 -3
- package/dist/admin/surface/TestsSurface.js +2 -2
- package/dist/admin/surface/goals/GoalForm.d.ts +1 -1
- package/dist/admin/surface/goals/GoalForm.js +55 -7
- package/dist/admin/surface/goals/GoalsList.d.ts +1 -1
- package/dist/admin/surface/goals/GoalsList.js +4 -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 +1 -1
- package/dist/admin/surface/home.model.js +5 -5
- package/dist/admin/surface/newTest/NewTest.d.ts +1 -1
- package/dist/admin/surface/newTest/NewTest.js +1 -1
- package/dist/admin/surface/newTest/PageWizard.d.ts +1 -1
- package/dist/admin/surface/newTest/PageWizard.js +13 -13
- package/dist/admin/surface/results/ResultsHeader.d.ts +2 -2
- package/dist/admin/surface/results/ResultsHeader.js +8 -8
- package/dist/admin/surface/test/TestPage.d.ts +1 -2
- package/dist/admin/surface/test/TestPage.js +45 -156
- package/dist/admin/views/ExperimentsRootView.js +1 -1
- package/dist/admin/views/TestsNavLinkServer.js +1 -1
- package/dist/admin/views/renderCollectionList.js +1 -1
- package/dist/admin/views/renderTestsSurface.js +1 -1
- package/dist/blocks/placementLocale.d.ts +21 -0
- package/dist/blocks/placementLocale.js +115 -0
- package/dist/collections/experiments/config.js +1 -1
- package/dist/collections/metrics.js +1 -1
- package/dist/db/bulkPlacementRemoval.d.ts +30 -0
- package/dist/db/bulkPlacementRemoval.js +107 -0
- package/dist/db/placements.d.ts +2 -0
- package/dist/db/placements.js +8 -0
- package/dist/endpoints/editorSurface.d.ts +3 -0
- package/dist/endpoints/editorSurface.js +31 -0
- package/dist/endpoints/index.js +28 -1
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +2 -0
- package/dist/fields/xpGoal.js +1 -1
- 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 +4 -2
- package/dist/goals/picker/copy.js +4 -2
- package/dist/goals/picker/useClickGoalPicker.d.ts +1 -1
- package/dist/goals/picker/useClickGoalPicker.js +4 -2
- package/dist/hooks/blockRemovalRule.d.ts +29 -0
- package/dist/hooks/blockRemovalRule.js +141 -0
- package/dist/hooks/pageGuard.d.ts +24 -2
- package/dist/hooks/pageGuard.js +178 -24
- package/dist/lib/placementPages.d.ts +9 -0
- package/dist/{admin/previewLinks.model.js → lib/placementPages.js} +1 -4
- package/dist/onInit.js +22 -0
- package/dist/plugin.js +2 -1
- package/dist/puck/ExperimentPicker.js +25 -10
- package/dist/puck/copy.d.ts +4 -1
- package/dist/puck/copy.js +4 -1
- package/dist/puck/editor/ConfigureTestDrawer.d.ts +21 -0
- package/dist/puck/editor/ConfigureTestDrawer.js +147 -0
- package/dist/puck/editor/CreateExperimentDrawer.d.ts +11 -2
- package/dist/puck/editor/CreateExperimentDrawer.js +69 -9
- package/dist/puck/editor/EditorControls.d.ts +14 -0
- package/dist/puck/editor/EditorControls.js +99 -0
- package/dist/puck/editor/ExperimentSlotEditor.js +317 -51
- package/dist/puck/editor/ResultsReadout.js +3 -5
- package/dist/puck/editor/VersionBuilder.js +2 -2
- package/dist/puck/editor/armsCache.d.ts +3 -1
- package/dist/puck/editor/armsCache.js +20 -3
- package/dist/puck/editor/copy.d.ts +18 -2
- package/dist/puck/editor/copy.js +19 -3
- package/dist/puck/editor/editor.chrome.css +33 -0
- package/dist/puck/editor/editor.css +39 -0
- package/dist/puck/editor/editor.model.d.ts +14 -0
- package/dist/puck/editor/editor.model.js +58 -1
- package/dist/puck/editor/editorSurface.d.ts +10 -0
- package/dist/puck/editor/editorSurface.js +65 -0
- package/dist/puck/editor/localPlacements.d.ts +2 -0
- package/dist/puck/editor/localPlacements.js +29 -0
- package/dist/puck/editor/placementsCache.d.ts +19 -0
- package/dist/puck/editor/placementsCache.js +83 -0
- package/dist/puck/editor/xpGoalPuckEditorField.js +109 -98
- package/dist/puck/experimentSlotField.d.ts +3 -0
- package/dist/puck/experimentSlotField.js +15 -4
- package/dist/{admin → testSurface}/actions/DecideDialog.d.ts +2 -1
- package/dist/{admin → testSurface}/actions/DecideDialog.js +6 -4
- package/dist/{admin → testSurface}/api.js +4 -5
- package/dist/{admin → testSurface}/copy/common.d.ts +2 -0
- package/dist/{admin → testSurface}/copy/common.js +2 -0
- package/dist/{admin → testSurface}/copy/readiness.d.ts +3 -0
- package/dist/{admin → testSurface}/copy/readiness.js +3 -0
- package/dist/{admin → testSurface}/copy/testPage.d.ts +3 -0
- package/dist/{admin → testSurface}/copy/testPage.js +7 -2
- package/dist/testSurface/format/adminURL.d.ts +7 -0
- package/dist/testSurface/format/adminURL.js +9 -0
- package/dist/{admin → testSurface}/placements/placementLabels.js +1 -1
- package/dist/{admin → testSurface}/previewLinks.model.d.ts +1 -6
- package/dist/testSurface/previewLinks.model.js +4 -0
- package/dist/testSurface/results/results.css +64 -0
- package/dist/{admin → testSurface}/surface/contracts.d.ts +1 -0
- package/dist/{admin → testSurface}/surface/pageBlock/parts.js +6 -6
- package/dist/testSurface/surface/pagePicker/pagePicker.css +10 -0
- package/dist/{admin → testSurface}/surface/readiness/useTransition.js +1 -0
- package/dist/{admin → testSurface}/surface/results/ResultsBody.d.ts +2 -2
- package/dist/{admin → testSurface}/surface/results/ResultsBody.js +18 -11
- package/dist/testSurface/surface/setting/setting.css +17 -0
- package/dist/testSurface/surface/test/GoalSection.d.ts +4 -0
- package/dist/{admin → testSurface}/surface/test/GoalSection.js +3 -2
- package/dist/testSurface/surface/test/TestSurface.d.ts +18 -0
- package/dist/testSurface/surface/test/TestSurface.js +152 -0
- package/dist/testSurface/surface/test/VersionsSection.d.ts +5 -0
- package/dist/{admin → testSurface}/surface/test/VersionsSection.js +12 -6
- package/dist/testSurface/surface/test/testPage.css +92 -0
- package/dist/{admin → testSurface}/surface/useTestDocument.d.ts +5 -1
- package/dist/{admin → testSurface}/surface/useTestDocument.js +34 -3
- package/dist/{admin → testSurface}/surfaceUrls.js +1 -1
- package/dist/transitions/placementInteractions.js +1 -1
- package/dist/transitions/placements.d.ts +27 -8
- package/dist/transitions/placements.js +77 -6
- package/dist/transitions/start.js +2 -2
- package/dist/types/endpoints.d.ts +1 -1
- package/dist/ui/Dialog.d.ts +4 -1
- package/dist/ui/Dialog.js +41 -3
- package/dist/ui/Drawer.d.ts +10 -0
- package/dist/ui/Drawer.js +29 -0
- package/dist/ui/Tabs.d.ts +3 -3
- package/dist/ui/Tabs.js +35 -33
- package/dist/ui/ui.css +6 -0
- package/package.json +1 -1
- package/dist/admin/actions/ConfirmDialog.d.ts +0 -19
- package/dist/admin/actions/ConfirmDialog.js +0 -149
- 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/pagePicker/pagePicker.css +0 -10
- package/dist/admin/surface/setting/setting.css +0 -17
- package/dist/admin/surface/test/GoalSection.d.ts +0 -2
- package/dist/admin/surface/test/VersionsSection.d.ts +0 -4
- package/dist/admin/surface/test/testPage.css +0 -92
- /package/dist/{admin → testSurface}/PreviewLinks.d.ts +0 -0
- /package/dist/{admin → testSurface}/PreviewLinks.js +0 -0
- /package/dist/{admin → testSurface}/actions/MakeContentResult.d.ts +0 -0
- /package/dist/{admin → testSurface}/actions/MakeContentResult.js +0 -0
- /package/dist/{admin → testSurface}/actions/actions.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/actions/actions.model.js +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}/api.d.ts +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/actions.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/actions.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/metrics.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/metrics.js +0 -0
- /package/dist/{admin → testSurface}/copy/pages.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/pages.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/results.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/results.js +0 -0
- /package/dist/{admin → testSurface}/copy/review.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/review.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}/copy/surface.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/surface.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.d.ts +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/VerdictHero.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/VerdictHero.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/results.model.js +0 -0
- /package/dist/{admin → testSurface}/results/snapshot.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/snapshot.js +0 -0
- /package/dist/{admin → testSurface}/review/review.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/review/review.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/contracts.js +0 -0
- /package/dist/{admin → testSurface}/surface/pageBlock/pageBlock.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/pageBlock/pageBlock.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/pageBlock/parts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/pagePicker/CopyRoute.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/pagePicker/CopyRoute.js +0 -0
- /package/dist/{admin → testSurface}/surface/pagePicker/PageCombobox.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/pagePicker/PageCombobox.js +0 -0
- /package/dist/{admin → testSurface}/surface/pagePicker/pagePicker.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/pagePicker/pagePicker.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/ActionDialogs.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/ActionDialogs.js +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/Banner.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/Banner.js +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/SaveStatus.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/SaveStatus.js +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/parts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/parts.js +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/readiness.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/readiness.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/useTransition.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/results/ReleasePages.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/results/ReleasePages.js +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/results/useResults.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/results/useResults.js +0 -0
- /package/dist/{admin → testSurface}/surface/setting/parts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/setting/parts.js +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/AdvancedSection.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/LengthSection.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/LengthSection.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/PageHoldout.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/PageHoldout.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/Rail.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/Rail.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/ReadinessBar.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/ReadinessBar.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/Section.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/Section.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/TargetingSection.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/TargetingSection.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/fields.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/fields.js +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}/surface/test/pageParts.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/testPage.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/testPage.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/testDocument.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/testDocument.model.js +0 -0
- /package/dist/{admin → testSurface}/surfaceUrls.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.d.ts +0 -0
- /package/dist/{admin → testSurface}/useApi.js +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type PayloadRequest } from 'payload';
|
|
2
|
+
import type { DocId } from '../types/contracts.js';
|
|
3
|
+
/** Adapter rows retain locale maps; Start's Local API scan flattens these fields
|
|
4
|
+
* to req.locale (and req.fallbackLocale). Registrations name top-level fields.
|
|
5
|
+
* Match Payload afterRead/promise.js:50-89: [] is present, not a fallback.
|
|
6
|
+
*/
|
|
7
|
+
export declare function placementLocaleContent(req: PayloadRequest, collection: string, doc: Record<string, unknown> | undefined): Record<string, unknown> | undefined;
|
|
8
|
+
export interface PlacementLocaleView {
|
|
9
|
+
locale: string;
|
|
10
|
+
fallbackLocale: import('payload').TypedFallbackLocale;
|
|
11
|
+
}
|
|
12
|
+
export declare const placementDocumentKey: (collection: string, id: DocId, view: PlacementLocaleView) => string;
|
|
13
|
+
export type RemovedPlacementViews = Map<string, PlacementLocaleView[]>;
|
|
14
|
+
export declare function localeRequest(req: PayloadRequest, view: PlacementLocaleView): PayloadRequest;
|
|
15
|
+
/** Canonical views of registered content, without multiplying nonlocalized rows. */
|
|
16
|
+
export declare function placementLocaleViews(req: PayloadRequest, collection: string): PlacementLocaleView[];
|
|
17
|
+
/** Compare every locale view: a localized edit can also change fallback
|
|
18
|
+
* content in another locale. Whole-row removals replace every view with absence.
|
|
19
|
+
* The incoming hook document is already flattened to the writing locale.
|
|
20
|
+
*/
|
|
21
|
+
export declare function removedPlacementViews(req: PayloadRequest, collection: string, before: Record<string, unknown> | undefined, after: Record<string, unknown>, removingPage: boolean): RemovedPlacementViews;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { sanitizeFallbackLocale } from 'payload';
|
|
2
|
+
import { flattenTopLevelFields } from 'payload/shared';
|
|
3
|
+
import { puckCollections } from '../options.js';
|
|
4
|
+
import { placementSlugs } from './bindings.js';
|
|
5
|
+
import { isObject } from './model.js';
|
|
6
|
+
/** Adapter rows retain locale maps; Start's Local API scan flattens these fields
|
|
7
|
+
* to req.locale (and req.fallbackLocale). Registrations name top-level fields.
|
|
8
|
+
* Match Payload afterRead/promise.js:50-89: [] is present, not a fallback.
|
|
9
|
+
*/ export function placementLocaleContent(req, collection, doc) {
|
|
10
|
+
const localization = req.payload.config.localization;
|
|
11
|
+
if (!doc || !localization || req.locale === 'all') return doc;
|
|
12
|
+
const config = req.payload.config.collections?.find((entry)=>entry.slug === collection);
|
|
13
|
+
if (!config) return doc;
|
|
14
|
+
const options = req.payload.config.custom.xp;
|
|
15
|
+
const names = new Set([
|
|
16
|
+
...puckCollections(options).filter((entry)=>entry.slug === collection).map((entry)=>entry.field),
|
|
17
|
+
...(options.blocks?.collections ?? []).filter((entry)=>entry.slug === collection).map((entry)=>entry.field)
|
|
18
|
+
]);
|
|
19
|
+
const result = {
|
|
20
|
+
...doc
|
|
21
|
+
};
|
|
22
|
+
const locale = req.locale || localization.defaultLocale;
|
|
23
|
+
const fallback = sanitizeFallbackLocale({
|
|
24
|
+
fallbackLocale: req.fallbackLocale ?? null,
|
|
25
|
+
locale,
|
|
26
|
+
localization
|
|
27
|
+
});
|
|
28
|
+
for (const field of flattenTopLevelFields(config.fields)){
|
|
29
|
+
if (!('name' in field) || typeof field.name !== 'string' || !names.has(field.name) || !('localized' in field) || !field.localized) continue;
|
|
30
|
+
const values = doc[field.name];
|
|
31
|
+
if (!isObject(values)) continue;
|
|
32
|
+
let value = values[locale];
|
|
33
|
+
if (value == null && fallback && fallback !== locale) {
|
|
34
|
+
for (const code of Array.isArray(fallback) ? fallback : [
|
|
35
|
+
fallback
|
|
36
|
+
]){
|
|
37
|
+
if (values[code] != null && values[code] !== '') {
|
|
38
|
+
value = values[code];
|
|
39
|
+
break;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
result[field.name] = value;
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
46
|
+
}
|
|
47
|
+
export const placementDocumentKey = (collection, id, view)=>JSON.stringify([
|
|
48
|
+
collection,
|
|
49
|
+
String(id),
|
|
50
|
+
view
|
|
51
|
+
]);
|
|
52
|
+
export function localeRequest(req, view) {
|
|
53
|
+
return {
|
|
54
|
+
...req,
|
|
55
|
+
...view
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/** Canonical views of registered content, without multiplying nonlocalized rows. */ export function placementLocaleViews(req, collection) {
|
|
59
|
+
const localization = req.payload.config.localization;
|
|
60
|
+
const config = req.payload.config.collections?.find((entry)=>entry.slug === collection);
|
|
61
|
+
const options = req.payload.config.custom.xp;
|
|
62
|
+
const names = new Set([
|
|
63
|
+
...puckCollections(options).filter((entry)=>entry.slug === collection).map((entry)=>entry.field),
|
|
64
|
+
...(options.blocks?.collections ?? []).filter((entry)=>entry.slug === collection).map((entry)=>entry.field)
|
|
65
|
+
]);
|
|
66
|
+
const localized = config && flattenTopLevelFields(config.fields).some((field)=>'name' in field && names.has(field.name) && 'localized' in field && field.localized);
|
|
67
|
+
return localization && localized ? localization.localeCodes.map((locale)=>({
|
|
68
|
+
locale,
|
|
69
|
+
fallbackLocale: sanitizeFallbackLocale({
|
|
70
|
+
fallbackLocale: null,
|
|
71
|
+
locale,
|
|
72
|
+
localization
|
|
73
|
+
})
|
|
74
|
+
})) : [
|
|
75
|
+
{
|
|
76
|
+
locale: '',
|
|
77
|
+
fallbackLocale: false
|
|
78
|
+
}
|
|
79
|
+
];
|
|
80
|
+
}
|
|
81
|
+
/** Compare every locale view: a localized edit can also change fallback
|
|
82
|
+
* content in another locale. Whole-row removals replace every view with absence.
|
|
83
|
+
* The incoming hook document is already flattened to the writing locale.
|
|
84
|
+
*/ export function removedPlacementViews(req, collection, before, after, removingPage) {
|
|
85
|
+
const result = new Map();
|
|
86
|
+
if (!before) return result;
|
|
87
|
+
const localization = req.payload.config.localization;
|
|
88
|
+
const config = req.payload.config.collections?.find((entry)=>entry.slug === collection);
|
|
89
|
+
const options = req.payload.config.custom.xp;
|
|
90
|
+
const fields = config ? flattenTopLevelFields(config.fields) : [];
|
|
91
|
+
const localized = fields.filter((field)=>'name' in field && 'localized' in field && field.localized);
|
|
92
|
+
// Keep the raw locale maps for unchanged languages when merging a partial,
|
|
93
|
+
// flattened main-row write back into the adapter baseline.
|
|
94
|
+
const rawAfter = {
|
|
95
|
+
...after
|
|
96
|
+
};
|
|
97
|
+
if (localization && req.locale !== 'all') for (const field of localized){
|
|
98
|
+
if (!('name' in field) || typeof field.name !== 'string' || !(field.name in after)) continue;
|
|
99
|
+
const previousValue = before[field.name];
|
|
100
|
+
rawAfter[field.name] = {
|
|
101
|
+
...isObject(previousValue) ? previousValue : {},
|
|
102
|
+
[req.locale || localization.defaultLocale]: after[field.name]
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
for (const view of placementLocaleViews(req, collection)){
|
|
106
|
+
const viewReq = localeRequest(req, view);
|
|
107
|
+
const previous = placementSlugs(options, collection, placementLocaleContent(viewReq, collection, before));
|
|
108
|
+
const next = removingPage ? [] : placementSlugs(options, collection, placementLocaleContent(viewReq, collection, rawAfter));
|
|
109
|
+
for (const slug of previous.filter((slug)=>!next.includes(slug)))result.set(slug, [
|
|
110
|
+
...result.get(slug) ?? [],
|
|
111
|
+
view
|
|
112
|
+
]);
|
|
113
|
+
}
|
|
114
|
+
return result;
|
|
115
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SURFACE_COPY } from '../../
|
|
1
|
+
import { SURFACE_COPY } from '../../testSurface/copy/surface.js';
|
|
2
2
|
import * as paths from '../../admin/paths.js';
|
|
3
3
|
import { managedAccess } from '../access.js';
|
|
4
4
|
import { serializeAttributeKeys, serializeFlagPoints } from '../serialize.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SURFACE_COPY } from '../
|
|
1
|
+
import { SURFACE_COPY } from '../testSurface/copy/surface.js';
|
|
2
2
|
import { CLICK_KEY, isClickSource, validClickSource } from '../goals/key.js';
|
|
3
3
|
import { XP_METRIC_SOURCE_SELECT, XP_GOALS_COLLECTION_LIST, XP_GOAL_EDIT_REDIRECT } from '../admin/paths.js';
|
|
4
4
|
import { managedAccess } from './access.js';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { PayloadRequest, Where } from 'payload';
|
|
2
|
+
import { type PlacementLocaleView } from '../blocks/placementLocale.js';
|
|
3
|
+
import type { DocId } from '../types/contracts.js';
|
|
4
|
+
export interface BulkPlacementRemoval {
|
|
5
|
+
documents: Set<string>;
|
|
6
|
+
change?: {
|
|
7
|
+
collection: string;
|
|
8
|
+
data?: Record<string, unknown>;
|
|
9
|
+
draft: boolean;
|
|
10
|
+
deleting: boolean;
|
|
11
|
+
};
|
|
12
|
+
refusals: Map<string, string>;
|
|
13
|
+
}
|
|
14
|
+
export declare function usesBulkDocumentTransactions(req: PayloadRequest): boolean;
|
|
15
|
+
/** A distinct operation identity without copying the transaction/context. Native
|
|
16
|
+
* Request accessors and methods must use the original receiver.
|
|
17
|
+
*/
|
|
18
|
+
export declare function placementOperationRequest(req: PayloadRequest, fields: Map<PropertyKey, unknown>, failed?: () => void): PayloadRequest;
|
|
19
|
+
/** Observe Payload's actual, access-filtered bulk selection before it dispatches
|
|
20
|
+
* any document hooks. This request-only proxy adds no reads and never replaces
|
|
21
|
+
* the shared adapter. Matching the original Where node avoids capturing nested
|
|
22
|
+
* access-hook reads. queryDrafts prefixes keys but preserves condition objects.
|
|
23
|
+
* Payload 3's update/delete operations select the entire set before Promise.all.
|
|
24
|
+
*/
|
|
25
|
+
export declare function bulkPlacementRequest(req: PayloadRequest, collection: string, where: Where, data: Record<string, unknown> | undefined, draft: boolean, deleting: boolean, bulk: BulkPlacementRemoval): PayloadRequest;
|
|
26
|
+
/** Evaluate the common change against the published row seen under E, rather
|
|
27
|
+
* than a draft version or a selection snapshot from before the lock. */
|
|
28
|
+
export declare function bulkRemoves(bulk: BulkPlacementRemoval | undefined, req: PayloadRequest, collection: string, doc: Record<string, unknown> & {
|
|
29
|
+
id: DocId;
|
|
30
|
+
}, slug: string, view: PlacementLocaleView): boolean;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { removedPlacementViews, placementDocumentKey } from '../blocks/placementLocale.js';
|
|
2
|
+
// Payload starts/ends a transaction per bulk document with this adapter option.
|
|
3
|
+
export function usesBulkDocumentTransactions(req) {
|
|
4
|
+
return req.payload.db.bulkOperationsSingleTransaction === true;
|
|
5
|
+
}
|
|
6
|
+
const operationRequestState = Symbol('xpPlacementRequestState');
|
|
7
|
+
/** A distinct operation identity without copying the transaction/context. Native
|
|
8
|
+
* Request accessors and methods must use the original receiver.
|
|
9
|
+
*/ export function placementOperationRequest(req, fields, failed) {
|
|
10
|
+
const parent = req[operationRequestState];
|
|
11
|
+
const state = {
|
|
12
|
+
target: parent?.target ?? req,
|
|
13
|
+
failed: failed ?? parent?.failed
|
|
14
|
+
};
|
|
15
|
+
return new Proxy(req, {
|
|
16
|
+
deleteProperty (target, key) {
|
|
17
|
+
// Transaction deletion must reach the shared request without ending any
|
|
18
|
+
// ancestor operation. Extra wrappers of this operation inherit its cleanup.
|
|
19
|
+
if (key === 'transactionID') {
|
|
20
|
+
state.failed?.();
|
|
21
|
+
return Reflect.deleteProperty(state.target, key);
|
|
22
|
+
}
|
|
23
|
+
return Reflect.deleteProperty(target, key);
|
|
24
|
+
},
|
|
25
|
+
get (target, key) {
|
|
26
|
+
if (key === operationRequestState) return state;
|
|
27
|
+
if (fields.has(key)) return fields.get(key);
|
|
28
|
+
const value = Reflect.get(target, key, target);
|
|
29
|
+
return typeof Object.getOwnPropertyDescriptor(Request.prototype, key)?.value === 'function' ? value.bind(target) : value;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/** Observe Payload's actual, access-filtered bulk selection before it dispatches
|
|
34
|
+
* any document hooks. This request-only proxy adds no reads and never replaces
|
|
35
|
+
* the shared adapter. Matching the original Where node avoids capturing nested
|
|
36
|
+
* access-hook reads. queryDrafts prefixes keys but preserves condition objects.
|
|
37
|
+
* Payload 3's update/delete operations select the entire set before Promise.all.
|
|
38
|
+
*/ export function bulkPlacementRequest(req, collection, where, data, draft, deleting, bulk) {
|
|
39
|
+
const config = req.payload.config.collections.find((entry)=>entry.slug === collection);
|
|
40
|
+
const draftOnly = draft && Boolean(config?.versions && config.versions.drafts) && data?._status !== 'published';
|
|
41
|
+
bulk.change = {
|
|
42
|
+
collection,
|
|
43
|
+
data,
|
|
44
|
+
draft: draftOnly,
|
|
45
|
+
deleting
|
|
46
|
+
};
|
|
47
|
+
let captured = false;
|
|
48
|
+
const matches = (value, expected, versions)=>{
|
|
49
|
+
if (value === expected) return true;
|
|
50
|
+
if (!versions) return false;
|
|
51
|
+
if (!value || !expected || typeof value !== 'object' || typeof expected !== 'object') return false;
|
|
52
|
+
const actual = value;
|
|
53
|
+
return Object.entries(expected).every(([key, condition])=>{
|
|
54
|
+
if (key === 'and' || key === 'or') return Array.isArray(actual[key]) && Array.isArray(condition) && condition.length === actual[key].length && condition.every((entry, i)=>matches(actual[key][i], entry, versions));
|
|
55
|
+
return actual[versions ? key === 'id' ? 'parent' : `version.${key}` : key] === condition;
|
|
56
|
+
}) && Object.keys(actual).length === Object.keys(expected).length;
|
|
57
|
+
};
|
|
58
|
+
const contains = (value, versions)=>matches(value, where, versions) || !!value && typeof value === 'object' && [
|
|
59
|
+
'and',
|
|
60
|
+
'or'
|
|
61
|
+
].some((key)=>{
|
|
62
|
+
const children = value[key];
|
|
63
|
+
return Array.isArray(children) && children.some((child)=>contains(child, versions));
|
|
64
|
+
});
|
|
65
|
+
const database = new Proxy(req.payload.db, {
|
|
66
|
+
get (target, key, receiver) {
|
|
67
|
+
const method = Reflect.get(target, key, receiver);
|
|
68
|
+
if (key !== 'find' && key !== 'queryDrafts') return method;
|
|
69
|
+
return async (query)=>{
|
|
70
|
+
const selection = !captured && (key !== 'queryDrafts' || 'pagination' in query && query.pagination === false) && query.req === scoped && query.collection === collection && contains(query.where, key === 'queryDrafts');
|
|
71
|
+
const result = await method.call(target, query);
|
|
72
|
+
if (selection) {
|
|
73
|
+
captured = true;
|
|
74
|
+
for (const doc of result.docs)bulk.documents.add(JSON.stringify([
|
|
75
|
+
collection,
|
|
76
|
+
String(doc.id)
|
|
77
|
+
]));
|
|
78
|
+
}
|
|
79
|
+
return result;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
const payload = new Proxy(req.payload, {
|
|
84
|
+
get: (target, key, receiver)=>key === 'db' ? database : Reflect.get(target, key, receiver)
|
|
85
|
+
});
|
|
86
|
+
const scoped = placementOperationRequest(req, new Map([
|
|
87
|
+
[
|
|
88
|
+
'payload',
|
|
89
|
+
payload
|
|
90
|
+
]
|
|
91
|
+
]));
|
|
92
|
+
return scoped;
|
|
93
|
+
}
|
|
94
|
+
/** Evaluate the common change against the published row seen under E, rather
|
|
95
|
+
* than a draft version or a selection snapshot from before the lock. */ export function bulkRemoves(bulk, req, collection, doc, slug, view) {
|
|
96
|
+
const change = bulk?.change;
|
|
97
|
+
if (!change || change.draft || change.collection !== collection || !bulk.documents.has(JSON.stringify([
|
|
98
|
+
collection,
|
|
99
|
+
String(doc.id)
|
|
100
|
+
]))) return false;
|
|
101
|
+
const after = {
|
|
102
|
+
...doc,
|
|
103
|
+
...change.data
|
|
104
|
+
};
|
|
105
|
+
const views = removedPlacementViews(req, collection, doc, after, change.deleting || after.deletedAt != null || after._status === 'draft');
|
|
106
|
+
return (views.get(slug) ?? []).some((removed)=>placementDocumentKey(collection, doc.id, removed) === placementDocumentKey(collection, doc.id, view));
|
|
107
|
+
}
|
package/dist/db/placements.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export interface PlacementTest {
|
|
|
21
21
|
}
|
|
22
22
|
/** Raw reads only: guard discovery includes every status, interaction checks filter under the locks. */
|
|
23
23
|
export declare function placementTests(exec: Executor): Promise<PlacementTest[]>;
|
|
24
|
+
/** Indexed slug lookup for the removal guard; startable tests share E with Start before status is rechecked. */
|
|
25
|
+
export declare function removableBlockTests(exec: Executor, slugs: readonly string[]): Promise<Array<Pick<PlacementTest, 'id' | 'slug' | 'name' | 'status'>>>;
|
|
24
26
|
/** §7.8: interacting-tests computes placement paths from published rows. */
|
|
25
27
|
export declare function placementPathContent(req: PayloadRequest, collection: string, id: DocId): Promise<(Record<string, unknown> & {
|
|
26
28
|
id: DocId;
|
package/dist/db/placements.js
CHANGED
|
@@ -14,6 +14,14 @@ import { qualifiedTable, quoteIdentifier as q } from './sql.js';
|
|
|
14
14
|
placementDocs: row.placementDocs ?? null
|
|
15
15
|
}));
|
|
16
16
|
}
|
|
17
|
+
/** Indexed slug lookup for the removal guard; startable tests share E with Start before status is rechecked. */ export async function removableBlockTests(exec, slugs) {
|
|
18
|
+
const e = COLUMNS.experiments;
|
|
19
|
+
const { rows } = await exec.query(`SELECT ${q(e.id)} AS id, ${q(e.slug)} AS slug, ${q(e.name)} AS name, ${q(e.status)} AS status
|
|
20
|
+
FROM ${qualifiedTable(exec, TABLES.experiments)} WHERE ${q(e.slug)} = ANY($1::text[]) AND ${q(e.kind)} = 'block' AND ${q(e.status)} IN ('draft', 'stopped', 'running')`, [
|
|
21
|
+
slugs
|
|
22
|
+
]);
|
|
23
|
+
return rows;
|
|
24
|
+
}
|
|
17
25
|
/** §7.8: interacting-tests computes placement paths from published rows. */ export async function placementPathContent(req, collection, id) {
|
|
18
26
|
return req.payload.db.findOne({
|
|
19
27
|
collection,
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { buildSurfaceProps } from '../admin/views/buildSurfaceProps.js';
|
|
2
|
+
/** The same request-scoped configuration the admin view sends this user. */ export async function handleEditorSurface(req) {
|
|
3
|
+
const props = await buildSurfaceProps({
|
|
4
|
+
req,
|
|
5
|
+
route: 'test',
|
|
6
|
+
searchParams: {}
|
|
7
|
+
}) ?? await buildSurfaceProps({
|
|
8
|
+
req,
|
|
9
|
+
route: 'results',
|
|
10
|
+
searchParams: {}
|
|
11
|
+
});
|
|
12
|
+
if (!props) return Response.json({
|
|
13
|
+
errors: [
|
|
14
|
+
{
|
|
15
|
+
code: 'forbidden',
|
|
16
|
+
message: 'Access denied'
|
|
17
|
+
}
|
|
18
|
+
]
|
|
19
|
+
}, {
|
|
20
|
+
status: 403,
|
|
21
|
+
headers: {
|
|
22
|
+
'Cache-Control': 'private, no-store'
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
const { route: _route, id: _id, pages: _pages, returnToTest: _return, ...surface } = props;
|
|
26
|
+
return Response.json(surface, {
|
|
27
|
+
headers: {
|
|
28
|
+
'Cache-Control': 'private, no-store'
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
package/dist/endpoints/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { handleEditorSurface } from './editorSurface.js';
|
|
1
2
|
import { handleClickKeys } from './clickKeys.js';
|
|
2
3
|
import { createHmac, timingSafeEqual } from 'node:crypto';
|
|
3
4
|
import { XP_MANIFEST_KEY_HEADER } from '../constants.js';
|
|
@@ -146,9 +147,15 @@ export const ROUTES = [
|
|
|
146
147
|
path: '/xp/placements/status',
|
|
147
148
|
access: 'manage',
|
|
148
149
|
handler: handlePlacementStatus
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
method: 'get',
|
|
153
|
+
path: '/xp/editor-surface',
|
|
154
|
+
access: 'surface',
|
|
155
|
+
handler: handleEditorSurface
|
|
149
156
|
}
|
|
150
157
|
];
|
|
151
|
-
function
|
|
158
|
+
function endpointError(status, code, message, detail) {
|
|
152
159
|
return Response.json({
|
|
153
160
|
errors: [
|
|
154
161
|
{
|
|
@@ -172,6 +179,11 @@ export function buildEndpoints(ctx) {
|
|
|
172
179
|
const handlerContext = {
|
|
173
180
|
options
|
|
174
181
|
};
|
|
182
|
+
const error = (status, code, message, detail)=>{
|
|
183
|
+
const response = endpointError(status, code, message, detail);
|
|
184
|
+
if (route.access === 'surface') response.headers.set('Cache-Control', 'private, no-store');
|
|
185
|
+
return response;
|
|
186
|
+
};
|
|
175
187
|
try {
|
|
176
188
|
if (route.access === 'manage' || route.access === 'readResults') {
|
|
177
189
|
if (!req.user) return error(401, 'unauthenticated', 'Authentication required');
|
|
@@ -179,6 +191,21 @@ export function buildEndpoints(ctx) {
|
|
|
179
191
|
if (await access({
|
|
180
192
|
req
|
|
181
193
|
}) !== true) return error(403, 'forbidden', 'Access denied');
|
|
194
|
+
} else if (route.access === 'surface') {
|
|
195
|
+
if (!req.user) return error(401, 'unauthenticated', 'Authentication required');
|
|
196
|
+
// Match the admin surface: a failed host access check denies that permission.
|
|
197
|
+
const permits = async (access)=>{
|
|
198
|
+
try {
|
|
199
|
+
return await access({
|
|
200
|
+
req
|
|
201
|
+
}) === true;
|
|
202
|
+
} catch {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
const manage = await permits(options.access.manage);
|
|
207
|
+
const read = options.access.readResults ? await permits(options.access.readResults) : manage;
|
|
208
|
+
if (!manage && !read) return error(403, 'forbidden', 'Access denied');
|
|
182
209
|
} else if (route.access === 'manifestKey') {
|
|
183
210
|
const secret = options.runtime.proxyRuntime.secrets[0];
|
|
184
211
|
if (!secret) return error(401, 'unauthenticated', 'Invalid manifest key');
|
package/dist/errors.d.ts
CHANGED
|
@@ -22,6 +22,7 @@ export declare class XpRefusal extends Error {
|
|
|
22
22
|
readonly detail: unknown | undefined;
|
|
23
23
|
readonly status: 409 | 413 | 422 | 500 | 404;
|
|
24
24
|
name: string;
|
|
25
|
+
readonly isOperational = true;
|
|
25
26
|
readonly isPublic = true;
|
|
26
27
|
constructor(code: RefusalCode, message: string, detail: unknown | undefined, status: 409 | 413 | 422 | 500 | 404, options?: ErrorOptions);
|
|
27
28
|
}
|
package/dist/errors.js
CHANGED
|
@@ -26,6 +26,8 @@ export class XpRefusal extends Error {
|
|
|
26
26
|
detail;
|
|
27
27
|
status;
|
|
28
28
|
name = 'XpRefusal';
|
|
29
|
+
// Payload-compatible marker used by Puck's public-error response mapper.
|
|
30
|
+
isOperational = true;
|
|
29
31
|
isPublic = true;
|
|
30
32
|
constructor(code, message, detail, status, options){
|
|
31
33
|
super(message, options), this.code = code, this.detail = detail, this.status = status;
|
package/dist/fields/xpGoal.js
CHANGED
|
@@ -6,7 +6,7 @@ import { validateClickGoal } from '../goals/validate.js';
|
|
|
6
6
|
label: 'Click goal',
|
|
7
7
|
type: 'text',
|
|
8
8
|
admin: {
|
|
9
|
-
description: 'Choose the
|
|
9
|
+
description: 'Choose the click goal to count here.',
|
|
10
10
|
components: {
|
|
11
11
|
Field: XP_GOAL_FIELD
|
|
12
12
|
}
|
|
@@ -8,7 +8,14 @@ export type PickerStatus = 'loading' | 'ready' | 'not-manager' | 'error';
|
|
|
8
8
|
export declare function goalSlug(name: string): string;
|
|
9
9
|
export declare function clickGoalSlug(name: string): string;
|
|
10
10
|
export declare function definedClickGoals(rows: readonly ClickGoal[]): ClickGoal[];
|
|
11
|
-
|
|
11
|
+
/** Keep legacy values visible without changing stored data during a read. */
|
|
12
|
+
export declare function clickGoalOptions(status: PickerStatus, goals: readonly ClickGoal[], value: string): {
|
|
13
|
+
options: {
|
|
14
|
+
value: string;
|
|
15
|
+
label: string;
|
|
16
|
+
}[];
|
|
17
|
+
missing: boolean;
|
|
18
|
+
};
|
|
12
19
|
export declare function clickGoalBody(name: string, slug: string): {
|
|
13
20
|
name: string;
|
|
14
21
|
slug: string;
|
|
@@ -9,8 +9,26 @@ export function clickGoalSlug(name) {
|
|
|
9
9
|
export function definedClickGoals(rows) {
|
|
10
10
|
return rows.filter((row)=>isClickSource(row.source));
|
|
11
11
|
}
|
|
12
|
-
export function
|
|
13
|
-
|
|
12
|
+
/** Keep legacy values visible without changing stored data during a read. */ export function clickGoalOptions(status, goals, value) {
|
|
13
|
+
const missing = status === 'ready' && Boolean(value) && !goals.some((goal)=>goal.slug === value);
|
|
14
|
+
const options = [
|
|
15
|
+
{
|
|
16
|
+
value: '',
|
|
17
|
+
label: C.none
|
|
18
|
+
},
|
|
19
|
+
...goals.map((goal)=>({
|
|
20
|
+
value: goal.slug,
|
|
21
|
+
label: goal.name
|
|
22
|
+
}))
|
|
23
|
+
];
|
|
24
|
+
if (value && !goals.some((goal)=>goal.slug === value)) options.push({
|
|
25
|
+
value,
|
|
26
|
+
label: missing ? `${value} (missing)` : value
|
|
27
|
+
});
|
|
28
|
+
return {
|
|
29
|
+
options,
|
|
30
|
+
missing
|
|
31
|
+
};
|
|
14
32
|
}
|
|
15
33
|
export function clickGoalBody(name, slug) {
|
|
16
34
|
return {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
/** Shared by Payload's field and the Puck sidebar, without either UI dependency. */
|
|
2
2
|
export declare const CLICK_GOAL_COPY: {
|
|
3
3
|
readonly label: "Click goal";
|
|
4
|
-
readonly
|
|
4
|
+
readonly none: "No click goal";
|
|
5
|
+
readonly loadError: "Couldn't load goals. Try again.";
|
|
6
|
+
readonly retry: "Try again";
|
|
5
7
|
readonly newGoal: "+ New click goal";
|
|
6
8
|
readonly title: "New click goal";
|
|
7
9
|
readonly name: "Name";
|
|
@@ -9,7 +11,7 @@ export declare const CLICK_GOAL_COPY: {
|
|
|
9
11
|
readonly advanced: "Advanced";
|
|
10
12
|
readonly createGoal: "Create goal";
|
|
11
13
|
readonly cancel: "Cancel";
|
|
12
|
-
readonly undefinedKey: "
|
|
14
|
+
readonly undefinedKey: "This click goal is missing. Choose another goal or “No click goal”.";
|
|
13
15
|
readonly invalidKey: "Use a click goal short name.";
|
|
14
16
|
readonly slugRule: "Use 1–64 lowercase letters, numbers, underscores or hyphens, starting with a letter or number.";
|
|
15
17
|
readonly duplicateSlug: "Another goal already uses this short name. Change it under Advanced.";
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/** Shared by Payload's field and the Puck sidebar, without either UI dependency. */ export const CLICK_GOAL_COPY = {
|
|
2
2
|
label: 'Click goal',
|
|
3
|
-
|
|
3
|
+
none: 'No click goal',
|
|
4
|
+
loadError: "Couldn't load goals. Try again.",
|
|
5
|
+
retry: 'Try again',
|
|
4
6
|
newGoal: '+ New click goal',
|
|
5
7
|
title: 'New click goal',
|
|
6
8
|
name: 'Name',
|
|
@@ -8,7 +10,7 @@
|
|
|
8
10
|
advanced: 'Advanced',
|
|
9
11
|
createGoal: 'Create goal',
|
|
10
12
|
cancel: 'Cancel',
|
|
11
|
-
undefinedKey: '
|
|
13
|
+
undefinedKey: 'This click goal is missing. Choose another goal or “No click goal”.',
|
|
12
14
|
invalidKey: 'Use a click goal short name.',
|
|
13
15
|
slugRule: 'Use 1–64 lowercase letters, numbers, underscores or hyphens, starting with a letter or number.',
|
|
14
16
|
duplicateSlug: 'Another goal already uses this short name. Change it under Advanced.',
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { useEffect, useRef, useState } from 'react';
|
|
3
3
|
import { fetchAllDocs } from '../../lib/fetchAllDocs.js';
|
|
4
4
|
import { CLICK_KEY } from '../key.js';
|
|
5
|
-
import { clickGoalBody, clickGoalCreateError, clickGoalSlug, definedClickGoals
|
|
5
|
+
import { clickGoalBody, clickGoalCreateError, clickGoalSlug, definedClickGoals } from './clickGoalPicker.model.js';
|
|
6
6
|
const goalLists = new Map();
|
|
7
7
|
function publish(list, state) {
|
|
8
8
|
// A read may finish after its last row unmounts and a new list has started.
|
|
@@ -180,7 +180,9 @@ const emptyPanel = ()=>({
|
|
|
180
180
|
status,
|
|
181
181
|
goals,
|
|
182
182
|
canManage,
|
|
183
|
-
|
|
183
|
+
retry: ()=>{
|
|
184
|
+
loadGoals(api);
|
|
185
|
+
},
|
|
184
186
|
panel,
|
|
185
187
|
open: ()=>{
|
|
186
188
|
if (canManage) setPanel({
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { PayloadRequest } from 'payload';
|
|
2
|
+
import type { Executor } from '../db/executor.js';
|
|
3
|
+
import { type PlacementTest } from '../db/placements.js';
|
|
4
|
+
import { type BulkPlacementRemoval } from '../db/bulkPlacementRemoval.js';
|
|
5
|
+
import { type RemovedPlacementViews } from '../blocks/placementLocale.js';
|
|
6
|
+
import type { DocId } from '../types/contracts.js';
|
|
7
|
+
export type RemovalClaims = {
|
|
8
|
+
transaction: unknown;
|
|
9
|
+
tests: Map<string, Set<string>>;
|
|
10
|
+
counts?: Map<string, Map<string, number>>;
|
|
11
|
+
absent?: Set<string>;
|
|
12
|
+
};
|
|
13
|
+
export declare function releaseRemovalClaim(req: PayloadRequest, collection: string, id: DocId, ownKeys?: Map<string, Set<string>>): void;
|
|
14
|
+
/** A removal must have reached afterChange before a later write can restore it.
|
|
15
|
+
* A write merely retaining another locale cannot clear an in-flight removal.
|
|
16
|
+
*/
|
|
17
|
+
export declare function observeUnpublishedRemoval(req: PayloadRequest, collection: string, id: DocId): void;
|
|
18
|
+
export declare function releaseRestoredRemovalClaims(req: PayloadRequest, collection: string, doc: Record<string, unknown> & {
|
|
19
|
+
id: DocId;
|
|
20
|
+
}, test: PlacementTest): void;
|
|
21
|
+
export declare const blockRemovalRule: {
|
|
22
|
+
prepare(req: PayloadRequest, collection: string, before: Record<string, unknown> | undefined, after: Record<string, unknown>, removingPage: boolean, exec?: Executor, tests?: readonly PlacementTest[]): Promise<{
|
|
23
|
+
views: RemovedPlacementViews;
|
|
24
|
+
affected: PlacementTest[];
|
|
25
|
+
}>;
|
|
26
|
+
discover(exec: Executor, removed: string[], tests?: readonly PlacementTest[]): Promise<PlacementTest[]>;
|
|
27
|
+
claim(req: PayloadRequest, transaction: unknown, affected: readonly PlacementTest[], collection: string, id: DocId, views: RemovedPlacementViews): RemovalClaims;
|
|
28
|
+
check(req: PayloadRequest, current: readonly PlacementTest[], affected: readonly PlacementTest[], collection: string, id: DocId, removingPage: boolean, views: RemovedPlacementViews, bulk?: BulkPlacementRemoval): Promise<void>;
|
|
29
|
+
};
|