@delmaredigital/payload-experiments 0.4.0-rc.6 → 0.4.0-rc.9
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 +12 -12
- package/dist/admin/blocks/BlockPanel.js +6 -4
- package/dist/admin/blocks/inject.js +1 -0
- package/dist/admin/blocks/model.d.ts +3 -2
- package/dist/admin/blocks/model.js +9 -5
- package/dist/admin/copy/blocks.d.ts +3 -2
- package/dist/admin/copy/blocks.js +8 -7
- package/dist/admin/surface/ResultsRoute.js +18 -11
- package/dist/admin/surface/TestsHome.d.ts +2 -1
- package/dist/admin/surface/TestsHome.js +131 -44
- package/dist/admin/surface/TestsSurface.js +3 -0
- package/dist/admin/surface/home.model.d.ts +2 -0
- package/dist/admin/surface/newTest/PageWizard.js +9 -2
- package/dist/admin/surface/newTest/newTest.css +1 -1
- package/dist/admin/surface/results/ResultsHeader.js +11 -6
- package/dist/admin/surface/test/TestPage.js +3 -3
- package/dist/admin/views/TestsSurfaceClient.d.ts +3 -0
- package/dist/admin/views/TestsSurfaceClient.js +11 -0
- package/dist/admin/views/buildSurfaceProps.js +10 -3
- package/dist/blocks/bindings.js +3 -2
- 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 +21 -7
- package/dist/blocks/placementLocale.js +218 -67
- package/dist/collections/experiments/config.js +8 -3
- 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/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.js +8 -4
- 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/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/events.js +103 -39
- package/dist/endpoints/index.js +9 -8
- package/dist/endpoints/pages.js +7 -3
- 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/transitions.js +37 -24
- package/dist/errors.d.ts +4 -0
- package/dist/errors.js +6 -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/index.d.ts +1 -1
- package/dist/exports/rsc.d.ts +1 -0
- package/dist/exports/rsc.js +1 -0
- package/dist/goals/fairness.js +38 -31
- package/dist/hooks/blockRemovalRule.d.ts +2 -2
- package/dist/hooks/blockRemovalRule.js +16 -14
- package/dist/hooks/hostHook.js +6 -2
- package/dist/hooks/pageGuard.d.ts +3 -0
- package/dist/hooks/pageGuard.js +37 -23
- package/dist/hooks/puckNestedTests.d.ts +8 -0
- package/dist/hooks/puckNestedTests.js +36 -0
- package/dist/lib/fetchAllDocs.d.ts +1 -1
- package/dist/lib/placementPages.d.ts +2 -1
- package/dist/lib/placementPages.js +10 -2
- package/dist/manifest/compile.d.ts +2 -1
- package/dist/manifest/compile.js +13 -6
- package/dist/onInit.js +14 -0
- package/dist/options.js +5 -0
- 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.js +40 -37
- package/dist/puck/editor/ConfigureTestDrawer.d.ts +8 -4
- package/dist/puck/editor/ConfigureTestDrawer.js +5 -2
- package/dist/puck/editor/ExperimentSlotEditor.js +313 -158
- package/dist/puck/editor/LeftoverVersions.d.ts +1 -1
- package/dist/puck/editor/LeftoverVersions.js +40 -43
- package/dist/puck/editor/QuickTestActions.d.ts +5 -2
- package/dist/puck/editor/QuickTestActions.js +16 -4
- package/dist/puck/editor/ResultsReadout.d.ts +2 -1
- package/dist/puck/editor/ResultsReadout.js +2 -1
- package/dist/puck/editor/VersionBuilder.d.ts +31 -3
- package/dist/puck/editor/VersionBuilder.js +336 -74
- package/dist/puck/editor/armWrites.js +1 -1
- package/dist/puck/editor/armsCache.js +1 -3
- package/dist/puck/editor/blockClipboard.d.ts +16 -0
- package/dist/puck/editor/blockClipboard.js +20 -0
- package/dist/puck/editor/copy.d.ts +12 -2
- package/dist/puck/editor/copy.js +13 -2
- package/dist/puck/editor/editor.chrome.css +118 -3
- package/dist/puck/editor/editor.css +131 -8
- package/dist/puck/editor/editor.model.d.ts +3 -1
- package/dist/puck/editor/editor.model.js +2 -2
- package/dist/puck/editor/localPlacements.d.ts +1 -0
- package/dist/puck/editor/localPlacements.js +12 -0
- package/dist/puck/editor/placementsCache.d.ts +22 -12
- package/dist/puck/editor/placementsCache.js +62 -49
- package/dist/puck/editor/usePageSaveReadiness.d.ts +9 -0
- package/dist/puck/editor/usePageSaveReadiness.js +34 -0
- package/dist/puck/editor/usePlacementNotice.d.ts +2 -2
- package/dist/puck/editor/usePlacementNotice.js +6 -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 +2 -3
- package/dist/puck/visibility.js +11 -7
- 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 +20 -2
- package/dist/server/getAssignments.js +11 -10
- package/dist/server/recordContentChange.d.ts +1 -1
- package/dist/server/recordContentChange.js +45 -21
- package/dist/server/resolveExperimentBlocks.js +2 -4
- package/dist/server/resolveExperimentData.js +4 -7
- 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/testSurface/PreviewLinks.js +6 -2
- package/dist/testSurface/actions/DecideDialog.d.ts +4 -1
- package/dist/testSurface/actions/DecideDialog.js +32 -14
- package/dist/testSurface/actions/MakeContentResult.d.ts +4 -3
- package/dist/testSurface/actions/MakeContentResult.js +9 -1
- package/dist/testSurface/api.d.ts +11 -8
- package/dist/testSurface/api.js +27 -11
- package/dist/testSurface/contentLocaleURL.d.ts +2 -0
- package/dist/testSurface/contentLocaleURL.js +3 -0
- package/dist/testSurface/copy/actions.d.ts +1 -0
- package/dist/testSurface/copy/actions.js +1 -0
- package/dist/testSurface/copy/common.d.ts +6 -0
- package/dist/testSurface/copy/common.js +11 -5
- package/dist/testSurface/copy/languages.d.ts +12 -0
- package/dist/testSurface/copy/languages.js +8 -0
- package/dist/testSurface/copy/metrics.d.ts +1 -0
- package/dist/testSurface/copy/metrics.js +1 -0
- package/dist/testSurface/copy/readiness.d.ts +13 -2
- package/dist/testSurface/copy/readiness.js +19 -2
- package/dist/testSurface/copy/results.d.ts +5 -2
- package/dist/testSurface/copy/results.js +5 -2
- package/dist/testSurface/copy/testPage.d.ts +40 -1
- package/dist/testSurface/copy/testPage.js +53 -1
- package/dist/testSurface/placementLabel.d.ts +8 -0
- package/dist/testSurface/placementLabel.js +24 -0
- package/dist/testSurface/placements/placementLabels.d.ts +2 -0
- package/dist/testSurface/placements/placementLabels.js +2 -1
- package/dist/testSurface/readPreflight.d.ts +5 -0
- package/dist/testSurface/readPreflight.js +7 -0
- package/dist/testSurface/readinessRead.d.ts +3 -0
- package/dist/testSurface/readinessRead.js +4 -0
- package/dist/testSurface/results/VerdictHero.d.ts +2 -1
- package/dist/testSurface/results/VerdictHero.js +5 -1
- package/dist/testSurface/results/results.css +1 -1
- package/dist/testSurface/results/results.model.d.ts +1 -1
- package/dist/testSurface/results/results.model.js +6 -2
- package/dist/testSurface/surface/contracts.d.ts +10 -1
- package/dist/testSurface/surface/editorPlacement.d.ts +7 -2
- package/dist/testSurface/surface/editorPlacement.js +19 -1
- package/dist/testSurface/surface/pageBlock/pageBlock.model.js +4 -3
- package/dist/testSurface/surface/pageBlock/parts.js +24 -6
- package/dist/testSurface/surface/pagePicker/PageCombobox.js +20 -6
- package/dist/testSurface/surface/readiness/ActionDialogs.d.ts +4 -2
- package/dist/testSurface/surface/readiness/ActionDialogs.js +39 -34
- package/dist/testSurface/surface/readiness/Banner.js +23 -12
- package/dist/testSurface/surface/readiness/SaveStatus.d.ts +4 -3
- package/dist/testSurface/surface/readiness/SaveStatus.js +15 -15
- package/dist/testSurface/surface/readiness/readiness.model.d.ts +6 -1
- package/dist/testSurface/surface/readiness/readiness.model.js +116 -12
- package/dist/testSurface/surface/readiness/useTransition.d.ts +4 -4
- package/dist/testSurface/surface/readiness/useTransition.js +12 -10
- package/dist/testSurface/surface/results/ReleasePages.d.ts +4 -2
- package/dist/testSurface/surface/results/ReleasePages.js +5 -4
- package/dist/testSurface/surface/results/ResultsBody.d.ts +4 -2
- package/dist/testSurface/surface/results/ResultsBody.js +86 -43
- package/dist/testSurface/surface/results/useResults.d.ts +11 -7
- package/dist/testSurface/surface/results/useResults.js +3 -2
- package/dist/testSurface/surface/setting/parts.js +58 -18
- package/dist/testSurface/surface/test/AdvancedSection.js +1 -0
- package/dist/testSurface/surface/test/DeleteTest.d.ts +19 -0
- package/dist/testSurface/surface/test/DeleteTest.js +262 -0
- package/dist/testSurface/surface/test/GoalSection.js +7 -3
- package/dist/testSurface/surface/test/LengthSection.js +3 -0
- package/dist/testSurface/surface/test/PageHoldout.js +4 -1
- package/dist/testSurface/surface/test/ReadinessBar.js +1 -1
- package/dist/testSurface/surface/test/TargetingSection.js +77 -12
- package/dist/testSurface/surface/test/TestSurface.js +97 -15
- package/dist/testSurface/surface/test/VersionsSection.js +56 -29
- package/dist/testSurface/surface/test/fields.d.ts +29 -4
- package/dist/testSurface/surface/test/fields.js +159 -39
- package/dist/testSurface/surface/test/pageParts.js +14 -5
- package/dist/testSurface/surface/test/testPage.model.d.ts +1 -0
- package/dist/testSurface/surface/test/testPage.model.js +6 -0
- package/dist/testSurface/surface/testDocument.model.d.ts +3 -0
- package/dist/testSurface/surface/testDocument.model.js +4 -1
- package/dist/testSurface/surface/useTestDocument.d.ts +23 -4
- package/dist/testSurface/surface/useTestDocument.js +425 -162
- package/dist/testSurface/useApi.d.ts +9 -6
- package/dist/testSurface/useOnTestReturn.d.ts +2 -0
- package/dist/testSurface/useOnTestReturn.js +27 -0
- package/dist/testSurface/useReadinessPolling.js +3 -1
- package/dist/transitions/addMetric.d.ts +1 -4
- 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 +5 -1
- package/dist/transitions/checkStart.js +130 -16
- package/dist/transitions/contentFields.js +9 -5
- package/dist/transitions/decide.d.ts +1 -1
- package/dist/transitions/decide.js +5 -3
- package/dist/transitions/deleteExperiment.d.ts +2 -2
- package/dist/transitions/deleteExperiment.js +17 -7
- package/dist/transitions/kernel.d.ts +2 -0
- package/dist/transitions/kernel.js +9 -4
- package/dist/transitions/makeContent.d.ts +2 -1
- package/dist/transitions/makeContent.js +17 -12
- package/dist/transitions/nestedPlacementNames.d.ts +5 -0
- package/dist/transitions/nestedPlacementNames.js +32 -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 +15 -11
- package/dist/transitions/placements.d.ts +28 -1
- package/dist/transitions/placements.js +223 -60
- package/dist/transitions/preflightData.d.ts +5 -3
- package/dist/transitions/preflightData.js +126 -37
- 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 +70 -34
- 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 +6 -3
- package/dist/types/endpoints.d.ts +86 -9
- package/dist/types/endpoints.js +1 -1
- package/dist/types/runtime.d.ts +15 -9
- package/dist/types/snapshot.d.ts +2 -0
- package/dist/types/surface.d.ts +2 -0
- package/dist/ui/Button.js +2 -2
- package/dist/ui/ChipsInput.d.ts +8 -1
- package/dist/ui/ChipsInput.js +17 -4
- package/dist/ui/Inputs.d.ts +4 -3
- package/dist/ui/Inputs.js +9 -9
- package/dist/ui/SelectControl.d.ts +33 -0
- package/dist/ui/SelectControl.js +504 -0
- package/dist/ui/ui.css +13 -5
- package/package.json +3 -2
|
@@ -5,7 +5,9 @@ export declare function useApi(apiRoute: string): {
|
|
|
5
5
|
ok: true;
|
|
6
6
|
data: import("../types/contracts.js").DocId;
|
|
7
7
|
}>;
|
|
8
|
-
deleteTest: (id: import("../types/contracts.js").DocId
|
|
8
|
+
deleteTest: (id: import("../types/contracts.js").DocId, { draft }?: {
|
|
9
|
+
draft?: boolean;
|
|
10
|
+
}) => Promise<import("./api.js").ApiResult<unknown>>;
|
|
9
11
|
wrapBlock: (body: import("../types/endpoints.js").WrapBlockBody) => Promise<import("./api.js").ApiResult<Record<string, unknown>>>;
|
|
10
12
|
pages: (query: {
|
|
11
13
|
collection: string;
|
|
@@ -14,7 +16,7 @@ export declare function useApi(apiRoute: string): {
|
|
|
14
16
|
page?: number;
|
|
15
17
|
}, signal?: AbortSignal) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").PagesResult>>;
|
|
16
18
|
placementStatus: (body: import("../types/endpoints.js").PlacementStatusBody) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").PlacementStatusResult>>;
|
|
17
|
-
start: (id: import("../types/contracts.js").DocId) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").TransitionSuccess>>;
|
|
19
|
+
start: (id: import("../types/contracts.js").DocId, phase?: number) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").TransitionSuccess>>;
|
|
18
20
|
allocate: (id: import("../types/contracts.js").DocId, body: import("../types/endpoints.js").AllocateBody, options?: {
|
|
19
21
|
notFound?: string;
|
|
20
22
|
forbidden?: string;
|
|
@@ -27,15 +29,16 @@ export declare function useApi(apiRoute: string): {
|
|
|
27
29
|
codes?: Readonly<Record<string, string>>;
|
|
28
30
|
fallback?: string;
|
|
29
31
|
}) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").AddMetricResult>>;
|
|
30
|
-
stop: (id: import("../types/contracts.js").DocId) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").TransitionSuccess>>;
|
|
32
|
+
stop: (id: import("../types/contracts.js").DocId, phase?: number) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").TransitionSuccess>>;
|
|
31
33
|
decide: (id: import("../types/contracts.js").DocId, body: import("../types/endpoints.js").DecideBody) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").TransitionSuccess>>;
|
|
32
|
-
releaseHoldout: (id: import("../types/contracts.js").DocId) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").TransitionSuccess>>;
|
|
33
|
-
releasePages: (id: import("../types/contracts.js").DocId) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").TransitionSuccess>>;
|
|
34
|
-
makeContent: (id: import("../types/contracts.js").DocId) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").MakeContentResult>>;
|
|
34
|
+
releaseHoldout: (id: import("../types/contracts.js").DocId, phase?: number) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").TransitionSuccess>>;
|
|
35
|
+
releasePages: (id: import("../types/contracts.js").DocId, phase?: number) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").TransitionSuccess>>;
|
|
36
|
+
makeContent: (id: import("../types/contracts.js").DocId, phase?: number) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").MakeContentResult>>;
|
|
35
37
|
dismissContentEntry: (id: import("../types/contracts.js").DocId, body: import("../types/endpoints.js").DismissContentEntryBody) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").DismissContentEntryResult>>;
|
|
36
38
|
restoreContentEntry: (id: import("../types/contracts.js").DocId, body: import("../types/endpoints.js").RestoreContentEntryBody) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").RestoreContentEntryResult>>;
|
|
37
39
|
archive: (id: import("../types/contracts.js").DocId, body: import("../types/endpoints.js").ArchiveBody) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").TransitionSuccess>>;
|
|
38
40
|
clickKeys: (id: import("../types/contracts.js").DocId) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").ClickKeysResult>>;
|
|
41
|
+
deleteImpact: (id: import("../types/contracts.js").DocId, signal?: AbortSignal) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").DeleteImpactResult>>;
|
|
39
42
|
preflight: (id: import("../types/contracts.js").DocId) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").PreflightResult>>;
|
|
40
43
|
previewToken: (id: import("../types/contracts.js").DocId, arm: string) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").PreviewTokenResult>>;
|
|
41
44
|
results: (id: import("../types/contracts.js").DocId, options?: {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
/** Focus and visibility can both fire when returning to a tab. */ export function useOnTestReturn(onReturn, enabled = true) {
|
|
4
|
+
useEffect(()=>{
|
|
5
|
+
if (!enabled) return;
|
|
6
|
+
let lastReturn = -Infinity;
|
|
7
|
+
const refresh = ()=>{
|
|
8
|
+
if (document.visibilityState !== 'visible' || Date.now() - lastReturn < 100) return;
|
|
9
|
+
lastReturn = Date.now();
|
|
10
|
+
onReturn();
|
|
11
|
+
};
|
|
12
|
+
const restored = (event)=>{
|
|
13
|
+
if (event.persisted) refresh();
|
|
14
|
+
};
|
|
15
|
+
window.addEventListener('focus', refresh);
|
|
16
|
+
window.addEventListener('pageshow', restored);
|
|
17
|
+
document.addEventListener('visibilitychange', refresh);
|
|
18
|
+
return ()=>{
|
|
19
|
+
window.removeEventListener('focus', refresh);
|
|
20
|
+
window.removeEventListener('pageshow', restored);
|
|
21
|
+
document.removeEventListener('visibilitychange', refresh);
|
|
22
|
+
};
|
|
23
|
+
}, [
|
|
24
|
+
enabled,
|
|
25
|
+
onReturn
|
|
26
|
+
]);
|
|
27
|
+
}
|
|
@@ -8,7 +8,9 @@ import { useEffect, useRef } from 'react';
|
|
|
8
8
|
let timer;
|
|
9
9
|
const schedule = ()=>{
|
|
10
10
|
clearTimeout(timer);
|
|
11
|
-
if (document.visibilityState === 'visible') timer = setTimeout(()=>
|
|
11
|
+
if (document.visibilityState === 'visible') timer = setTimeout(()=>{
|
|
12
|
+
if (document.visibilityState === 'visible') action.current();
|
|
13
|
+
}, read.pollDelay);
|
|
12
14
|
};
|
|
13
15
|
schedule();
|
|
14
16
|
document.addEventListener('visibilitychange', schedule);
|
|
@@ -7,10 +7,7 @@ export declare function addMetric<TUser extends {
|
|
|
7
7
|
experimentId: DocId;
|
|
8
8
|
options: ResolvedOptions<TUser>;
|
|
9
9
|
}): Promise<{
|
|
10
|
-
detail?:
|
|
11
|
-
metricId: DocId;
|
|
12
|
-
message: string;
|
|
13
|
-
}[] | undefined;
|
|
10
|
+
detail?: import("../types/endpoints.js").StartExperimentWarning[] | undefined;
|
|
14
11
|
warnings: AddMetricWarning[];
|
|
15
12
|
doc: import("payload").JsonObject & import("payload").TypeWithID;
|
|
16
13
|
revision: number;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { PayloadRequest } from 'payload';
|
|
2
2
|
import type { DocId } from '../types/contracts.js';
|
|
3
|
-
|
|
3
|
+
import type { AllocateBody } from '../types/endpoints.js';
|
|
4
|
+
export declare function allocate(req: PayloadRequest, { experimentId, allocation, phase: expectedPhase }: AllocateBody & {
|
|
4
5
|
experimentId: DocId;
|
|
5
|
-
allocation: number;
|
|
6
6
|
}): Promise<{
|
|
7
7
|
doc: import("payload").JsonObject & import("payload").TypeWithID;
|
|
8
8
|
revision: number;
|
|
@@ -3,8 +3,9 @@ import { appendAllocationChange } from '../db/appends.js';
|
|
|
3
3
|
import { claimSlices } from '../db/slices.js';
|
|
4
4
|
import { relationshipId } from './checkStart.js';
|
|
5
5
|
import { withTransition } from './kernel.js';
|
|
6
|
+
import { requireCurrentRound } from './phaseRecord.js';
|
|
6
7
|
import { readExperiment, refuse, updateExperiment } from './start.js';
|
|
7
|
-
export async function allocate(req, { experimentId, allocation }) {
|
|
8
|
+
export async function allocate(req, { experimentId, allocation, phase: expectedPhase }) {
|
|
8
9
|
if (!Number.isInteger(allocation) || allocation < 1 || allocation > 100) refuse('invalid-body');
|
|
9
10
|
const before = await readExperiment(req, experimentId);
|
|
10
11
|
const { result: doc, revision } = await withTransition(req, {
|
|
@@ -12,6 +13,7 @@ export async function allocate(req, { experimentId, allocation }) {
|
|
|
12
13
|
layerId: relationshipId(before.layer)
|
|
13
14
|
}, async ({ req, exec })=>{
|
|
14
15
|
const current = await readExperiment(req, experimentId);
|
|
16
|
+
requireCurrentRound(expectedPhase, current.phase);
|
|
15
17
|
if (current.status !== 'running') refuse('invalid-status');
|
|
16
18
|
if (allocation <= current.allocation) refuse('allocation-lower');
|
|
17
19
|
const layerId = relationshipId(current.layer);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PayloadRequest } from 'payload';
|
|
2
2
|
import type { DocId } from '../types/contracts.js';
|
|
3
3
|
import type { ArchiveBody } from '../types/endpoints.js';
|
|
4
|
-
export declare function archive(req: PayloadRequest, { experimentId, mode, confirmation }: ArchiveBody & {
|
|
4
|
+
export declare function archive(req: PayloadRequest, { experimentId, mode, confirmation, phase: expectedPhase }: ArchiveBody & {
|
|
5
5
|
experimentId: DocId;
|
|
6
6
|
}): Promise<{
|
|
7
7
|
doc: import("payload").JsonObject & import("payload").TypeWithID;
|
|
@@ -2,15 +2,16 @@ import { contentDone } from '../contentDone.js';
|
|
|
2
2
|
import { relationshipId } from './checkStart.js';
|
|
3
3
|
import { expectedConfirm, matchesConfirm, storedWinnerLabel } from './confirmPhrases.js';
|
|
4
4
|
import { withTransition } from './kernel.js';
|
|
5
|
-
import { setPhaseEndedAt } from './phaseRecord.js';
|
|
5
|
+
import { requireCurrentRound, setPhaseEndedAt } from './phaseRecord.js';
|
|
6
6
|
import { readExperiment, refuse, updateExperiment } from './start.js';
|
|
7
|
-
export async function archive(req, { experimentId, mode, confirmation }) {
|
|
7
|
+
export async function archive(req, { experimentId, mode, confirmation, phase: expectedPhase }) {
|
|
8
8
|
const before = await readExperiment(req, experimentId);
|
|
9
9
|
const { result: doc, revision } = await withTransition(req, {
|
|
10
10
|
experimentId,
|
|
11
11
|
layerId: relationshipId(before.layer)
|
|
12
12
|
}, async ({ req })=>{
|
|
13
13
|
const current = await readExperiment(req, experimentId);
|
|
14
|
+
requireCurrentRound(expectedPhase, current.phase);
|
|
14
15
|
const decision = current.decision;
|
|
15
16
|
if (mode === 'stopped' ? current.status !== 'stopped' : current.status !== 'decided') refuse('invalid-status');
|
|
16
17
|
if (mode === 'hard-coded' && current.kind !== 'code') refuse('invalid-status');
|
|
@@ -2,7 +2,7 @@ import { type GoalContent } from '../goals/fairness.js';
|
|
|
2
2
|
import type { Arm, DocId, ExperimentKind, ExposurePolicy, FlagPoint, MetricSource, ResolvedOptions, Status, TargetingRule, UnitType } from '../types/contracts.js';
|
|
3
3
|
import type { ArmIssueCode, PreflightResult } from '../types/endpoints.js';
|
|
4
4
|
import type { BlockPlacement, FlagPlacement } from './placements.js';
|
|
5
|
-
export type ReadinessCode = ArmIssueCode | 'goal-in-some-versions' | 'placement-unchecked' | 'invalid-status' | 'no-planned-duration' | 'no-primary-metric' | 'no-reach-per-day' | 'placement-unpublished' | 'duplicate-version-row' | 'interacting-tests' | 'version-identical' | 'version-same-address' | 'unknown-collection' | 'page-no-targets' | 'page-in-use' | 'page-target-unpublished' | 'page-targets-unchecked' | 'version-page-unavailable' | 'version-page-unchecked' | 'page-user-unit' | 'flag-no-point' | 'flag-params-invalid' | 'flag-point-busy' | 'flag-placement-missing' | 'no-placements' | 'placement-removed' | 'empty-slot' | 'make-content-unsupported' | 'layer-unit-mismatch' | 'layer-full' | 'unknown-metric-source' | 'unit-source-mismatch' | 'block-path-rule' | 'undeclared-targeting-key' | 'invalid-targeting-rule';
|
|
5
|
+
export type ReadinessCode = ArmIssueCode | 'nested-tests' | 'goal-in-some-versions' | 'placement-unchecked' | 'invalid-status' | 'no-planned-duration' | 'no-primary-metric' | 'no-reach-per-day' | 'placement-unpublished' | 'duplicate-version-row' | 'interacting-tests' | 'version-identical' | 'version-same-address' | 'unknown-collection' | 'page-no-targets' | 'page-in-use' | 'page-target-unpublished' | 'page-targets-unchecked' | 'version-page-unavailable' | 'version-page-unchecked' | 'page-user-unit' | 'flag-no-point' | 'flag-params-invalid' | 'flag-point-busy' | 'flag-placement-missing' | 'no-placements' | 'placement-removed' | 'empty-slot' | 'make-content-unsupported' | 'layer-unit-mismatch' | 'layer-full' | 'unknown-metric-source' | 'unit-source-mismatch' | 'block-path-rule' | 'undeclared-targeting-key' | 'invalid-targeting-rule';
|
|
6
6
|
export interface StartExperiment {
|
|
7
7
|
id: DocId;
|
|
8
8
|
slug: string;
|
|
@@ -10,6 +10,7 @@ export interface StartExperiment {
|
|
|
10
10
|
kind: ExperimentKind;
|
|
11
11
|
unitType: UnitType;
|
|
12
12
|
phase?: number;
|
|
13
|
+
updatedAt?: string;
|
|
13
14
|
pageCollection?: string | null;
|
|
14
15
|
arms: Arm[];
|
|
15
16
|
allocation: number;
|
|
@@ -50,6 +51,9 @@ export interface CheckStartInput {
|
|
|
50
51
|
flagPoints?: FlagPoint[];
|
|
51
52
|
placements?: BlockPlacement[];
|
|
52
53
|
flagPlacements?: FlagPlacement[];
|
|
54
|
+
placementLocaleCodes?: readonly string[];
|
|
55
|
+
placementLocale?: string;
|
|
56
|
+
placementDefaultLocale?: string;
|
|
53
57
|
placementError?: PlacementFailure;
|
|
54
58
|
flagPlacementError?: PlacementFailure;
|
|
55
59
|
flagPointBusy?: boolean;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { placementLanguageSuffix } from '../testSurface/copy/languages.js';
|
|
1
2
|
import { asymmetricGoal } from '../goals/fairness.js';
|
|
3
|
+
import { withSlotsFor } from '../arms/model.js';
|
|
2
4
|
import { checkArms } from '../collections/experiments/armInvariants.js';
|
|
3
5
|
import { normalisePath } from '../runtime/normalisePath.js';
|
|
4
6
|
import { isOpValid } from '../targeting/ops.js';
|
|
@@ -19,11 +21,87 @@ export const relationshipId = (value)=>value == null ? undefined : typeof value
|
|
|
19
21
|
* pageTarget, holdout included, normalised the same way ('' is '/'). Occupancy and lock keys use this. */ export const pageTargetPaths = (arms)=>[
|
|
20
22
|
...new Set(arms.filter((arm)=>typeof arm.pageTarget === 'string').map((arm)=>normalisePath(arm.pageTarget)))
|
|
21
23
|
].sort();
|
|
22
|
-
const placementDetail = ({ collection, id, title })=>({
|
|
24
|
+
const placementDetail = ({ collection, id, title, locales, allLocales, locale, localeLabel })=>({
|
|
23
25
|
collection,
|
|
24
26
|
id,
|
|
25
|
-
title
|
|
27
|
+
title: `${title}${placementLanguageSuffix({
|
|
28
|
+
allLocales,
|
|
29
|
+
locales: locales?.length ? locales : locale ? [
|
|
30
|
+
localeLabel ?? locale
|
|
31
|
+
] : undefined
|
|
32
|
+
})}`
|
|
26
33
|
});
|
|
34
|
+
/** Group only the languages with this finding, independently for each page and
|
|
35
|
+
* finding payload. Single-language occurrence details keep their original shape. */ function placementDetails(findings, all, input, { findingKey = (detail)=>JSON.stringify(detail), includeLocaleCodes = false } = {}) {
|
|
36
|
+
const groups = new Map();
|
|
37
|
+
const ordered = [];
|
|
38
|
+
for (const { placement, detail } of findings){
|
|
39
|
+
if (!placement.locale) {
|
|
40
|
+
ordered.push({
|
|
41
|
+
placement,
|
|
42
|
+
detail,
|
|
43
|
+
languages: new Map(),
|
|
44
|
+
members: []
|
|
45
|
+
});
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
const key = JSON.stringify([
|
|
49
|
+
placement.collection,
|
|
50
|
+
String(placement.id),
|
|
51
|
+
findingKey(detail)
|
|
52
|
+
]);
|
|
53
|
+
let group = groups.get(key);
|
|
54
|
+
if (!group) {
|
|
55
|
+
group = {
|
|
56
|
+
placement,
|
|
57
|
+
detail,
|
|
58
|
+
languages: new Map(),
|
|
59
|
+
members: []
|
|
60
|
+
};
|
|
61
|
+
groups.set(key, group);
|
|
62
|
+
ordered.push(group);
|
|
63
|
+
}
|
|
64
|
+
group.languages.set(placement.locale, placement.localeLabel ?? placement.locale);
|
|
65
|
+
group.members.push(placement);
|
|
66
|
+
}
|
|
67
|
+
return ordered.map(({ placement, detail, languages, members })=>{
|
|
68
|
+
if (!placement.locale) return {
|
|
69
|
+
...placementDetail(placement),
|
|
70
|
+
...detail
|
|
71
|
+
};
|
|
72
|
+
const page = all.filter((other)=>other.collection === placement.collection && String(other.id) === String(placement.id));
|
|
73
|
+
const configured = input.placementLocaleCodes ?? (page.some((other)=>other.allLocales) ? [
|
|
74
|
+
...new Set(page.flatMap((other)=>other.locale ? [
|
|
75
|
+
other.locale
|
|
76
|
+
] : []))
|
|
77
|
+
] : undefined);
|
|
78
|
+
const allLocales = configured?.length && configured.every((code)=>languages.has(code)) ? true : undefined;
|
|
79
|
+
const names = [
|
|
80
|
+
...languages.values()
|
|
81
|
+
];
|
|
82
|
+
const title = (members.find((row)=>row.locale === input.placementLocale) ?? members.find((row)=>row.locale === input.placementDefaultLocale) ?? placement).title;
|
|
83
|
+
return {
|
|
84
|
+
...placementDetail({
|
|
85
|
+
...placement,
|
|
86
|
+
title,
|
|
87
|
+
locale: undefined,
|
|
88
|
+
allLocales,
|
|
89
|
+
locales: names
|
|
90
|
+
}),
|
|
91
|
+
...allLocales ? {
|
|
92
|
+
allLocales: true
|
|
93
|
+
} : {
|
|
94
|
+
locales: names
|
|
95
|
+
},
|
|
96
|
+
...includeLocaleCodes ? {
|
|
97
|
+
localeCodes: [
|
|
98
|
+
...languages.keys()
|
|
99
|
+
]
|
|
100
|
+
} : {},
|
|
101
|
+
...detail
|
|
102
|
+
};
|
|
103
|
+
});
|
|
104
|
+
}
|
|
27
105
|
const positive = (value)=>typeof value === 'number' && Number.isFinite(value) && value > 0;
|
|
28
106
|
function invalidParams(arms, point) {
|
|
29
107
|
return arms.flatMap((arm)=>{
|
|
@@ -54,7 +132,7 @@ function invalidParams(arms, point) {
|
|
|
54
132
|
} : {}
|
|
55
133
|
});
|
|
56
134
|
add('invalid-status', e.status === 'draft' || e.status === 'stopped');
|
|
57
|
-
const issues = checkArms(e.arms, e.kind);
|
|
135
|
+
const issues = checkArms(e.kind === 'block' && Array.isArray(e.arms) ? withSlotsFor(e.arms, 'block') : e.arms, e.kind);
|
|
58
136
|
for (const code of ARM_CHECK_ORDER){
|
|
59
137
|
const matches = issues.filter((issue)=>issue.code === code);
|
|
60
138
|
add(code, matches.length === 0, matches);
|
|
@@ -118,27 +196,63 @@ function invalidParams(arms, point) {
|
|
|
118
196
|
add('no-placements', placementRemoved || e.kind !== 'block' || !input.placementError && placements.length > 0, input.placementError);
|
|
119
197
|
add('placement-removed', !placementRemoved);
|
|
120
198
|
const unpublished = placements.filter((p)=>!p.published && !placements.some((other)=>other.published && other.collection === p.collection && String(other.id) === String(p.id)));
|
|
121
|
-
add('placement-unpublished', unpublished.length === 0, unpublished.map(
|
|
199
|
+
add('placement-unpublished', unpublished.length === 0, placementDetails(unpublished.map((placement)=>({
|
|
200
|
+
placement,
|
|
201
|
+
detail: {}
|
|
202
|
+
})), placements, input));
|
|
203
|
+
const nested = placements.filter((p)=>p.published).flatMap((placement)=>(placement.nestedTests ?? []).map((detail)=>({
|
|
204
|
+
placement,
|
|
205
|
+
detail
|
|
206
|
+
})));
|
|
207
|
+
const seenPairs = new Set();
|
|
208
|
+
const uniqueNested = nested.filter(({ placement, detail })=>{
|
|
209
|
+
const key = JSON.stringify([
|
|
210
|
+
placement.collection,
|
|
211
|
+
String(placement.id),
|
|
212
|
+
placement.locale,
|
|
213
|
+
detail.outerSlug ?? detail.outer,
|
|
214
|
+
detail.innerSlug ?? detail.inner
|
|
215
|
+
]);
|
|
216
|
+
if (seenPairs.has(key)) return false;
|
|
217
|
+
seenPairs.add(key);
|
|
218
|
+
return true;
|
|
219
|
+
});
|
|
220
|
+
add('nested-tests', nested.length === 0, placementDetails(uniqueNested, placements, input));
|
|
122
221
|
const duplicates = placements.filter((p)=>p.published && p.duplicateRows);
|
|
123
|
-
add('duplicate-version-row', duplicates.length === 0, duplicates.map(
|
|
124
|
-
|
|
125
|
-
|
|
222
|
+
add('duplicate-version-row', duplicates.length === 0, placementDetails(duplicates.map((placement)=>({
|
|
223
|
+
placement,
|
|
224
|
+
detail: {}
|
|
225
|
+
})), placements, input));
|
|
226
|
+
const identical = placements.filter((p)=>p.published).flatMap((placement)=>(placement.identicalSlots ?? []).filter((slot)=>e.arms.some((arm)=>arm.key === slot && arm.kind !== 'holdout')).map((arm)=>({
|
|
227
|
+
placement,
|
|
228
|
+
detail: {
|
|
229
|
+
arm
|
|
230
|
+
}
|
|
231
|
+
})));
|
|
232
|
+
for (const detail of placementDetails(identical, placements, input)){
|
|
233
|
+
const { arm, ...page } = detail;
|
|
234
|
+
checks.push({
|
|
126
235
|
code: 'version-identical',
|
|
127
236
|
ok: true,
|
|
128
237
|
warning: true,
|
|
129
238
|
detail: {
|
|
130
|
-
arm
|
|
131
|
-
|
|
132
|
-
id: p.id,
|
|
133
|
-
title: p.title
|
|
239
|
+
arm,
|
|
240
|
+
...page
|
|
134
241
|
}
|
|
135
242
|
});
|
|
136
243
|
}
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
244
|
+
const missingVersions = (slots)=>e.arms.filter((arm)=>arm.kind !== 'holdout' && arm.key !== 'holdout' && !(slots[arm.key] > 0)).map((arm)=>arm.key);
|
|
245
|
+
const empty = placements.filter((placement)=>placement.published && missingVersions(placement.slots).length > 0);
|
|
246
|
+
add('empty-slot', e.kind !== 'block' || empty.length === 0, placementDetails(empty.map((placement)=>({
|
|
247
|
+
placement,
|
|
248
|
+
detail: {
|
|
249
|
+
slots: placement.slots,
|
|
250
|
+
missing: missingVersions(placement.slots)
|
|
251
|
+
}
|
|
252
|
+
})), placements, input, {
|
|
253
|
+
findingKey: (detail)=>JSON.stringify(detail.missing),
|
|
254
|
+
includeLocaleCodes: true
|
|
255
|
+
}));
|
|
142
256
|
add('make-content-unsupported', true);
|
|
143
257
|
const localized = placements.find((placement)=>placement.localized);
|
|
144
258
|
if (localized) Object.assign(checks[checks.length - 1], {
|
|
@@ -11,10 +11,14 @@
|
|
|
11
11
|
const blocks = config.blocks ?? [];
|
|
12
12
|
return fields.some((field)=>{
|
|
13
13
|
if (seen.has(field)) return false;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
seen.add(field);
|
|
15
|
+
try {
|
|
16
|
+
if ('localized' in field && field.localized) return true;
|
|
17
|
+
if ('tabs' in field && field.tabs.some((tab)=>tab.localized || hasLocalizedFields(tab.fields, config, seen))) return true;
|
|
18
|
+
if ('fields' in field && hasLocalizedFields(field.fields, config, seen)) return true;
|
|
19
|
+
return field.type === 'blocks' && contentBlocks(field, blocks).some((block)=>hasLocalizedFields(block.fields, config, seen));
|
|
20
|
+
} finally{
|
|
21
|
+
seen.delete(field);
|
|
22
|
+
}
|
|
19
23
|
});
|
|
20
24
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PayloadRequest } from 'payload';
|
|
2
2
|
import type { DocId } from '../types/contracts.js';
|
|
3
3
|
import type { DecideBody } from '../types/endpoints.js';
|
|
4
|
-
export declare function decide(req: PayloadRequest, { experimentId, winnerArm, note, confirmation }: DecideBody & {
|
|
4
|
+
export declare function decide(req: PayloadRequest, { experimentId, winnerArm, note, confirmation, phase: expectedPhase }: DecideBody & {
|
|
5
5
|
experimentId: DocId;
|
|
6
6
|
}): Promise<{
|
|
7
7
|
doc: import("payload").JsonObject & import("payload").TypeWithID;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { withSlotsFor } from '../arms/model.js';
|
|
1
2
|
import { detached, scanPlacements, lockAndRescanPlacements, placementInteractions } from './placementInteractions.js';
|
|
2
3
|
import { DEFAULT_SEQUENTIAL_TUNING_PARAMETER } from '../constants.js';
|
|
3
4
|
import { refreshPlacementDocs } from '../db/placements.js';
|
|
@@ -9,9 +10,9 @@ import { routedPageTests } from '../db/pageOccupancy.js';
|
|
|
9
10
|
import { pageTargetPaths, relationshipId } from './checkStart.js';
|
|
10
11
|
import { expectedConfirm, matchesConfirm, storedWinnerLabel } from './confirmPhrases.js';
|
|
11
12
|
import { withTransition } from './kernel.js';
|
|
12
|
-
import { readPhaseRecord, setPhaseEndedAt, writePhaseRecord } from './phaseRecord.js';
|
|
13
|
+
import { requireCurrentRound, readPhaseRecord, setPhaseEndedAt, writePhaseRecord } from './phaseRecord.js';
|
|
13
14
|
import { readExperiment, refuse, updateExperiment } from './start.js';
|
|
14
|
-
export async function decide(req, { experimentId, winnerArm, note, confirmation }) {
|
|
15
|
+
export async function decide(req, { experimentId, winnerArm, note, confirmation, phase: expectedPhase }) {
|
|
15
16
|
const before = await readExperiment(req, experimentId);
|
|
16
17
|
const options = req.payload.config.custom?.xp;
|
|
17
18
|
const placements = before.status === 'stopped' && before.kind === 'block' ? await detached(req, ()=>scanPlacements(req, options, before.slug)) : [];
|
|
@@ -21,6 +22,7 @@ export async function decide(req, { experimentId, winnerArm, note, confirmation
|
|
|
21
22
|
flagPointId: before.kind === 'flag' ? before.flagPoint : undefined
|
|
22
23
|
}, async ({ req, exec })=>{
|
|
23
24
|
const current = await readExperiment(req, experimentId);
|
|
25
|
+
requireCurrentRound(expectedPhase, current.phase);
|
|
24
26
|
if (current.status !== 'running' && current.status !== 'stopped') refuse('invalid-status');
|
|
25
27
|
if (current.kind === 'flag' && current.flagPoint) {
|
|
26
28
|
// §7.8: recheck point occupancy under its lock before restoring live routing.
|
|
@@ -148,7 +150,7 @@ export async function decide(req, { experimentId, winnerArm, note, confirmation
|
|
|
148
150
|
phaseKind: 'rollout',
|
|
149
151
|
startedAt: at,
|
|
150
152
|
seed: test.seed,
|
|
151
|
-
arms,
|
|
153
|
+
arms: current.kind === 'block' ? withSlotsFor(arms, 'block') : arms,
|
|
152
154
|
allocation: test.allocation,
|
|
153
155
|
allocationChanges: [],
|
|
154
156
|
targeting: test.targeting,
|
|
@@ -3,5 +3,5 @@ import type { DocId } from '../types/contracts.js';
|
|
|
3
3
|
/** Lock the entire bulk scope before any per-document hook can take state. */
|
|
4
4
|
export declare function prepareBulkDelete(req: PayloadRequest, where: Where): Promise<void>;
|
|
5
5
|
/** Payload deleteByID owns the request transaction; never commit inside hooks. */
|
|
6
|
-
export declare function deleteExperiment(req: PayloadRequest,
|
|
7
|
-
export declare function deleteExperimentAfter(req: PayloadRequest
|
|
6
|
+
export declare function deleteExperiment(req: PayloadRequest, requestedId: DocId): Promise<void>;
|
|
7
|
+
export declare function deleteExperimentAfter(req: PayloadRequest): Promise<void>;
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
import { safeError } from '../log.js';
|
|
2
2
|
import { retireSlug } from '../db/slugs.js';
|
|
3
3
|
import { txExecutor } from '../db/executor.js';
|
|
4
|
+
import { assertReadCommitted } from '../db/adapter.js';
|
|
4
5
|
import { deleteExperimentSnapshots, serializeDelete } from '../db/delete.js';
|
|
5
6
|
import { deleteExperimentEvents } from '../db/events.js';
|
|
6
7
|
import { lockTransitionScope, sortLockKeys } from '../db/locks.js';
|
|
8
|
+
import { experimentId as canonicalExperimentId } from '../endpoints/routeId.js';
|
|
9
|
+
import { XpRefusal } from '../errors.js';
|
|
7
10
|
import { buildAndStoreManifest } from '../manifest/compile.js';
|
|
8
|
-
import {
|
|
11
|
+
import { API_MESSAGES } from '../testSurface/copy/common.js';
|
|
12
|
+
import { readExperiment } from './start.js';
|
|
9
13
|
/** Lock the entire bulk scope before any per-document hook can take state. */ export async function prepareBulkDelete(req, where) {
|
|
10
14
|
await serializeDelete(req, async ()=>{
|
|
15
|
+
const exec = txExecutor(req);
|
|
16
|
+
await assertReadCommitted(req);
|
|
11
17
|
// §7.8 transition exception: hook read only discovers the lock set; delete still checks access.
|
|
12
18
|
const { docs } = await req.payload.find({
|
|
13
19
|
collection: 'xp-experiments',
|
|
@@ -22,20 +28,25 @@ import { readExperiment, refuse } from './start.js';
|
|
|
22
28
|
where
|
|
23
29
|
});
|
|
24
30
|
for (const experimentId of sortLockKeys(docs.map((doc)=>String(doc.id)))){
|
|
25
|
-
await lockTransitionScope(
|
|
31
|
+
await lockTransitionScope(exec, {
|
|
26
32
|
experimentId
|
|
27
33
|
});
|
|
28
34
|
}
|
|
29
35
|
});
|
|
30
36
|
}
|
|
31
|
-
/** Payload deleteByID owns the request transaction; never commit inside hooks. */ export async function deleteExperiment(req,
|
|
37
|
+
/** Payload deleteByID owns the request transaction; never commit inside hooks. */ export async function deleteExperiment(req, requestedId) {
|
|
32
38
|
await serializeDelete(req, async (state)=>{
|
|
33
39
|
const exec = txExecutor(req);
|
|
40
|
+
await assertReadCommitted(req);
|
|
41
|
+
const experimentId = canonicalExperimentId(req, requestedId, 'payload');
|
|
42
|
+
if (experimentId === undefined) throw new XpRefusal('not-found', 'Experiment not found', undefined, 404);
|
|
34
43
|
await lockTransitionScope(exec, {
|
|
35
44
|
experimentId
|
|
36
45
|
});
|
|
37
46
|
const current = await readExperiment(req, experimentId);
|
|
38
|
-
if (current.status !== 'draft' && current.status !== 'archived')
|
|
47
|
+
if (current.status !== 'draft' && current.status !== 'archived') {
|
|
48
|
+
throw new XpRefusal('invalid-status', API_MESSAGES.deleteInvalidStatus, undefined, 409);
|
|
49
|
+
}
|
|
39
50
|
try {
|
|
40
51
|
const collection = 'xp-phases';
|
|
41
52
|
// §7.8 transition exception: cascade while FK references still exist.
|
|
@@ -76,14 +87,13 @@ import { readExperiment, refuse } from './start.js';
|
|
|
76
87
|
}
|
|
77
88
|
});
|
|
78
89
|
}
|
|
79
|
-
export async function deleteExperimentAfter(req
|
|
90
|
+
export async function deleteExperimentAfter(req) {
|
|
80
91
|
await serializeDelete(req, async (state)=>{
|
|
81
92
|
for (const slug of state.retiredSlugs)await retireSlug(txExecutor(req), slug);
|
|
82
93
|
state.retiredSlugs.clear();
|
|
83
94
|
await buildAndStoreManifest(req, {
|
|
84
95
|
excludeIds: [
|
|
85
|
-
...state.excludedIds.values()
|
|
86
|
-
experimentId
|
|
96
|
+
...state.excludedIds.values()
|
|
87
97
|
],
|
|
88
98
|
pruneFlagDefaultIds: [
|
|
89
99
|
...state.pruneFlagDefaultIds.values()
|
|
@@ -9,6 +9,8 @@ export interface TransitionScope {
|
|
|
9
9
|
bump?: boolean;
|
|
10
10
|
/** Best-effort content audit only; a borrowed transaction must never be killed here. */
|
|
11
11
|
audit?: boolean;
|
|
12
|
+
/** Trusted server-side Start must commit its own transaction. Preflight passes the request to host callbacks. */
|
|
13
|
+
requireOwnedTransaction?: boolean;
|
|
12
14
|
excludeIds?: DocId[];
|
|
13
15
|
}
|
|
14
16
|
/** Runs transition writes on the request's transaction under ordered locks.
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { commitTransaction,
|
|
1
|
+
import { commitTransaction, killTransaction } from 'payload';
|
|
2
|
+
import { assertReadCommitted, initTransitionTransaction } from '../db/adapter.js';
|
|
2
3
|
import { pooledExecutor, txExecutor } from '../db/executor.js';
|
|
3
4
|
import { lockTransitionScope } from '../db/locks.js';
|
|
4
5
|
import { currentTxid, txidStatus } from '../db/txid.js';
|
|
5
6
|
import { contentChangeSavepoint } from '../db/appends.js';
|
|
6
7
|
import { isPageBusy } from '../db/pageBusy.js';
|
|
7
|
-
import { XpRefusal } from '../errors.js';
|
|
8
|
+
import { XpRefusal, XpStartTransactionOpen } from '../errors.js';
|
|
8
9
|
import { buildAndStoreManifest } from '../manifest/compile.js';
|
|
9
10
|
/** Runs transition writes on the request's transaction under ordered locks.
|
|
10
11
|
* Returns the callback result and, unless bump is false, the stored manifest's
|
|
@@ -17,15 +18,19 @@ import { buildAndStoreManifest } from '../manifest/compile.js';
|
|
|
17
18
|
* itself fails: the host must observe its own failed commit. Other failures kill
|
|
18
19
|
* even a borrowed transaction. Owned audits follow the ordinary owned path.
|
|
19
20
|
*/ export async function withTransition(req, scope, fn) {
|
|
21
|
+
if (scope.requireOwnedTransaction && req.transactionID != null) {
|
|
22
|
+
throw new XpStartTransactionOpen();
|
|
23
|
+
}
|
|
20
24
|
const hadTransition = Object.prototype.hasOwnProperty.call(req.context, 'xpTransition');
|
|
21
25
|
const previousTransition = req.context.xpTransition;
|
|
22
26
|
let borrowedAudit = scope.audit === true && req.transactionID != null;
|
|
23
27
|
try {
|
|
24
|
-
const owns = await
|
|
28
|
+
const owns = await initTransitionTransaction(req);
|
|
25
29
|
borrowedAudit = scope.audit === true && !owns;
|
|
26
30
|
const exec = txExecutor(req);
|
|
27
|
-
req.context.xpTransition = true;
|
|
28
31
|
const work = async ()=>{
|
|
32
|
+
if (!owns) await assertReadCommitted(req);
|
|
33
|
+
req.context.xpTransition = true;
|
|
29
34
|
await lockTransitionScope(exec, scope);
|
|
30
35
|
return fn({
|
|
31
36
|
exec,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RoundBody } from '../types/endpoints.js';
|
|
1
2
|
import { type PayloadRequest } from 'payload';
|
|
2
3
|
import type { ContentReportReason } from '../types/reasons.js';
|
|
3
4
|
import type { DocId, ResolvedOptions } from '../types/contracts.js';
|
|
@@ -17,7 +18,7 @@ type ContentDoc = {
|
|
|
17
18
|
export declare function hostTransaction(req: PayloadRequest, experimentId: DocId, fn: () => Promise<void>): Promise<void>;
|
|
18
19
|
export declare function makeContent<TUser extends {
|
|
19
20
|
id: DocId;
|
|
20
|
-
}>(req: PayloadRequest, { experimentId, options }: {
|
|
21
|
+
}>(req: PayloadRequest, { experimentId, options, phase: expectedPhase }: RoundBody & {
|
|
21
22
|
experimentId: DocId;
|
|
22
23
|
options: ResolvedOptions<TUser>;
|
|
23
24
|
}): Promise<{
|