@delmaredigital/payload-experiments 0.4.0-rc.5 → 0.4.0-rc.7
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/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 +8 -4
- package/dist/admin/copy/blocks.d.ts +3 -2
- package/dist/admin/copy/blocks.js +7 -6
- package/dist/admin/copy/newTest.d.ts +1 -1
- package/dist/admin/copy/newTest.js +1 -1
- package/dist/admin/surface/ResultsRoute.js +2 -1
- package/dist/admin/surface/TestsHome.d.ts +2 -1
- package/dist/admin/surface/TestsHome.js +91 -37
- package/dist/admin/surface/TestsSurface.js +3 -0
- package/dist/admin/surface/home.model.d.ts +2 -0
- package/dist/admin/surface/newTest/NewTest.js +16 -18
- package/dist/admin/surface/newTest/PageWizard.js +1 -0
- package/dist/admin/surface/newTest/newTest.css +3 -1
- 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 +8 -14
- package/dist/blocks/placementLanguages.d.ts +7 -0
- package/dist/blocks/placementLanguages.js +27 -0
- package/dist/blocks/placementLocale.d.ts +23 -7
- package/dist/blocks/placementLocale.js +221 -66
- package/dist/db/appends.d.ts +13 -0
- package/dist/db/appends.js +49 -0
- package/dist/db/bulkPlacementRemoval.js +8 -4
- 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 +206 -0
- package/dist/endpoints/index.js +7 -0
- package/dist/endpoints/pages.js +7 -3
- package/dist/endpoints/placementStatus.js +6 -1
- package/dist/endpoints/preflight.d.ts +1 -1
- package/dist/endpoints/preflight.js +17 -2
- 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/goals/fairness.js +43 -34
- package/dist/hooks/blockRemovalRule.d.ts +4 -3
- package/dist/hooks/blockRemovalRule.js +33 -9
- package/dist/hooks/pageGuard.d.ts +3 -0
- package/dist/hooks/pageGuard.js +34 -24
- package/dist/hooks/puckNestedTests.d.ts +8 -0
- package/dist/hooks/puckNestedTests.js +36 -0
- 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 +5 -1
- package/dist/puck/ExperimentPicker.d.ts +2 -1
- package/dist/puck/ExperimentPicker.js +37 -30
- package/dist/puck/ExperimentSlot.js +3 -1
- package/dist/puck/copy.d.ts +1 -0
- package/dist/puck/copy.js +1 -0
- package/dist/puck/editor/ConfigureTestDrawer.d.ts +8 -4
- package/dist/puck/editor/ConfigureTestDrawer.js +4 -2
- package/dist/puck/editor/CreateExperimentDrawer.d.ts +2 -1
- package/dist/puck/editor/CreateExperimentDrawer.js +24 -20
- package/dist/puck/editor/EditorControls.d.ts +1 -1
- package/dist/puck/editor/EditorControls.js +1 -1
- package/dist/puck/editor/ExperimentSlotEditor.js +405 -394
- package/dist/puck/editor/LeftoverVersions.d.ts +4 -2
- package/dist/puck/editor/LeftoverVersions.js +23 -44
- package/dist/puck/editor/QuickTestActions.js +2 -2
- package/dist/puck/editor/VersionBuilder.d.ts +41 -13
- package/dist/puck/editor/VersionBuilder.js +461 -224
- package/dist/puck/editor/armWrites.d.ts +9 -2
- package/dist/puck/editor/armWrites.js +40 -2
- package/dist/puck/editor/armsCache.d.ts +1 -1
- package/dist/puck/editor/armsCache.js +2 -1
- package/dist/puck/editor/blockClipboard.d.ts +16 -0
- package/dist/puck/editor/blockClipboard.js +20 -0
- package/dist/puck/editor/copy.d.ts +27 -26
- package/dist/puck/editor/copy.js +28 -26
- package/dist/puck/editor/createTest.d.ts +3 -0
- package/dist/puck/editor/createTest.js +33 -0
- package/dist/puck/editor/editor.chrome.css +138 -17
- package/dist/puck/editor/editor.css +156 -22
- package/dist/puck/editor/editor.model.d.ts +2 -1
- package/dist/puck/editor/editor.model.js +3 -3
- package/dist/puck/editor/experimentOutlinePlugin.js +1 -1
- package/dist/puck/editor/localPlacements.d.ts +5 -2
- package/dist/puck/editor/localPlacements.js +32 -18
- package/dist/puck/editor/placementsCache.d.ts +18 -12
- package/dist/puck/editor/placementsCache.js +52 -47
- package/dist/puck/editor/sidebar.d.ts +2 -6
- package/dist/puck/editor/sidebar.js +3 -6
- package/dist/puck/editor/usePlacementNotice.d.ts +1 -1
- package/dist/puck/editor/usePlacementNotice.js +4 -3
- package/dist/puck/experimentSlug.d.ts +2 -0
- package/dist/puck/experimentSlug.js +3 -0
- package/dist/puck/nestedTestCopy.d.ts +8 -0
- package/dist/puck/nestedTestCopy.js +22 -0
- package/dist/puck/nestedTests.d.ts +17 -0
- package/dist/puck/nestedTests.js +30 -0
- package/dist/puck/slotConfig.d.ts +1 -1
- package/dist/puck/slotConfig.js +17 -4
- package/dist/puck/visibility.d.ts +20 -0
- package/dist/puck/visibility.js +81 -0
- package/dist/server/recordContentChange.js +37 -20
- package/dist/server/resolveExperimentData.js +6 -3
- package/dist/testSurface/PreviewLinks.js +6 -2
- package/dist/testSurface/api.d.ts +6 -3
- package/dist/testSurface/api.js +10 -6
- package/dist/testSurface/contentLocaleURL.d.ts +2 -0
- package/dist/testSurface/contentLocaleURL.js +3 -0
- package/dist/testSurface/copy/common.d.ts +4 -0
- package/dist/testSurface/copy/common.js +8 -4
- package/dist/testSurface/copy/languages.d.ts +11 -0
- package/dist/testSurface/copy/languages.js +7 -0
- package/dist/testSurface/copy/readiness.d.ts +2 -1
- package/dist/testSurface/copy/readiness.js +2 -1
- package/dist/testSurface/copy/testPage.d.ts +28 -6
- package/dist/testSurface/copy/testPage.js +28 -6
- 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/results/results.css +1 -1
- package/dist/testSurface/results/results.model.d.ts +1 -1
- package/dist/testSurface/surface/contracts.d.ts +2 -0
- package/dist/testSurface/surface/editorPlacement.d.ts +5 -0
- package/dist/testSurface/surface/editorPlacement.js +18 -0
- package/dist/testSurface/surface/pageBlock/pageBlock.model.js +2 -1
- package/dist/testSurface/surface/pageBlock/parts.js +24 -6
- package/dist/testSurface/surface/readiness/ActionDialogs.js +28 -34
- package/dist/testSurface/surface/readiness/readiness.model.js +9 -2
- package/dist/testSurface/surface/results/useResults.d.ts +4 -1
- package/dist/testSurface/surface/test/DeleteTest.d.ts +15 -0
- package/dist/testSurface/surface/test/DeleteTest.js +171 -0
- package/dist/testSurface/surface/test/GoalSection.js +101 -74
- package/dist/testSurface/surface/test/TestSurface.js +29 -9
- package/dist/testSurface/surface/test/fields.d.ts +1 -3
- package/dist/testSurface/surface/test/fields.js +5 -35
- package/dist/testSurface/surface/useTestDocument.d.ts +2 -1
- package/dist/testSurface/surface/useTestDocument.js +20 -4
- package/dist/testSurface/useApi.d.ts +4 -1
- package/dist/transitions/checkStart.d.ts +4 -1
- package/dist/transitions/checkStart.js +117 -14
- package/dist/transitions/contentFields.js +9 -5
- package/dist/transitions/makeContent.js +29 -9
- package/dist/transitions/nestedPlacementNames.d.ts +5 -0
- package/dist/transitions/nestedPlacementNames.js +33 -0
- package/dist/transitions/pageVersions.js +3 -1
- package/dist/transitions/placementInteractions.js +7 -4
- package/dist/transitions/placements.d.ts +26 -1
- package/dist/transitions/placements.js +239 -87
- package/dist/transitions/preflightData.d.ts +2 -1
- package/dist/transitions/preflightData.js +66 -3
- package/dist/transitions/start.js +4 -1
- package/dist/types/endpoints.d.ts +35 -1
- package/dist/types/endpoints.js +1 -1
- package/dist/types/puck.d.ts +1 -0
- package/dist/types/surface.d.ts +2 -0
- package/dist/ui/Button.js +2 -2
- package/dist/ui/Inputs.d.ts +4 -3
- package/dist/ui/Inputs.js +7 -4
- package/dist/ui/SelectControl.d.ts +33 -0
- package/dist/ui/SelectControl.js +504 -0
- package/dist/ui/Tabs.d.ts +0 -1
- package/dist/ui/Tabs.js +28 -40
- package/dist/ui/ui.css +18 -5
- package/package.json +3 -2
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { DeleteTest } from './DeleteTest.js';
|
|
4
|
+
import { surfaceUrls } from '../../surfaceUrls.js';
|
|
3
5
|
import { useEffect, useState, useRef } from 'react';
|
|
4
6
|
import { useTestDocument } from '../useTestDocument.js';
|
|
5
7
|
import { API_MESSAGES } from '../../copy/common.js';
|
|
@@ -28,6 +30,7 @@ export function TestSurface({ id, surface, onTitleChange, renderFrame, embedded
|
|
|
28
30
|
const [barHeight, setBarHeight] = useState();
|
|
29
31
|
const documentState = useTestDocument(id, {
|
|
30
32
|
apiRoute: surface.apiRoute,
|
|
33
|
+
contentLocale: surface.contentLocale,
|
|
31
34
|
refetchPreflightOnFocus: true,
|
|
32
35
|
...!surface.canManage ? {
|
|
33
36
|
enabled: false
|
|
@@ -45,25 +48,29 @@ export function TestSurface({ id, surface, onTitleChange, renderFrame, embedded
|
|
|
45
48
|
const [placementRead, setPlacementRead] = useState();
|
|
46
49
|
const placementKey = JSON.stringify([
|
|
47
50
|
surface.apiRoute,
|
|
48
|
-
String(id)
|
|
51
|
+
String(id),
|
|
52
|
+
...surface.contentLocale ? [
|
|
53
|
+
surface.contentLocale
|
|
54
|
+
] : []
|
|
49
55
|
]);
|
|
50
56
|
const watching = embedded && surface.canManage && documentState.loadState === 'ready';
|
|
51
57
|
useEffect(()=>{
|
|
52
58
|
if (!embedded || !surface.canManage) return;
|
|
53
59
|
return subscribePlacements(surface.apiRoute, id, ()=>setPlacementRead({
|
|
54
60
|
key: placementKey,
|
|
55
|
-
preflight: cachedPreflight(surface.apiRoute, id),
|
|
56
|
-
read: cachedReadinessRead(surface.apiRoute, id),
|
|
57
|
-
pending: placementsPending(surface.apiRoute, id),
|
|
58
|
-
blocking: placementsBlocking(surface.apiRoute, id),
|
|
59
|
-
error: placementReadError(surface.apiRoute, id)
|
|
60
|
-
}));
|
|
61
|
+
preflight: cachedPreflight(surface.apiRoute, id, surface.contentLocale),
|
|
62
|
+
read: cachedReadinessRead(surface.apiRoute, id, surface.contentLocale),
|
|
63
|
+
pending: placementsPending(surface.apiRoute, id, surface.contentLocale),
|
|
64
|
+
blocking: placementsBlocking(surface.apiRoute, id, surface.contentLocale),
|
|
65
|
+
error: placementReadError(surface.apiRoute, id, surface.contentLocale)
|
|
66
|
+
}), surface.contentLocale);
|
|
61
67
|
}, [
|
|
62
68
|
surface.apiRoute,
|
|
63
69
|
id,
|
|
64
70
|
embedded,
|
|
65
71
|
surface.canManage,
|
|
66
|
-
placementKey
|
|
72
|
+
placementKey,
|
|
73
|
+
surface.contentLocale
|
|
67
74
|
]);
|
|
68
75
|
const currentRead = documentState.loadState === 'ready' && placementRead?.key === placementKey ? placementRead : undefined;
|
|
69
76
|
const preflight = currentRead ? currentRead.preflight ?? (currentRead.pending && !currentRead.error ? documentState.preflight : null) : documentState.preflight;
|
|
@@ -88,7 +95,7 @@ export function TestSurface({ id, surface, onTitleChange, renderFrame, embedded
|
|
|
88
95
|
editorPage,
|
|
89
96
|
editorPlacementMessage: message
|
|
90
97
|
};
|
|
91
|
-
usePlacementNotice(surface.apiRoute, id, watching ? sharedDocument.preflightError ?? (placementFailed ? placementReadError(surface.apiRoute, id) : message) : undefined);
|
|
98
|
+
usePlacementNotice(surface.apiRoute, id, watching ? sharedDocument.preflightError ?? (placementFailed ? placementReadError(surface.apiRoute, id, surface.contentLocale) : message) : undefined, surface.contentLocale);
|
|
92
99
|
const setup = documentState.doc?.status === 'draft' || documentState.doc?.status === 'stopped';
|
|
93
100
|
const test = setup ? {
|
|
94
101
|
...sharedDocument,
|
|
@@ -190,6 +197,19 @@ export function TestSurface({ id, surface, onTitleChange, renderFrame, embedded
|
|
|
190
197
|
/*#__PURE__*/ _jsx(AdvancedSection, {
|
|
191
198
|
...props
|
|
192
199
|
}),
|
|
200
|
+
!embedded ? /*#__PURE__*/ _jsx("div", {
|
|
201
|
+
children: /*#__PURE__*/ _jsx(DeleteTest, {
|
|
202
|
+
test: test.doc,
|
|
203
|
+
canManage: surface.canManage,
|
|
204
|
+
apiRoute: surface.apiRoute,
|
|
205
|
+
contentLocale: surface.contentLocale,
|
|
206
|
+
onDeleted: (outcome)=>{
|
|
207
|
+
window.location.assign(surfaceUrls.home(surface.adminRoute, {
|
|
208
|
+
deleted: outcome
|
|
209
|
+
}));
|
|
210
|
+
}
|
|
211
|
+
})
|
|
212
|
+
}) : null,
|
|
193
213
|
embedded && surface.canReadResults && test.doc.status !== 'draft' ? /*#__PURE__*/ _jsx(ResultsBody, {
|
|
194
214
|
id: id,
|
|
195
215
|
surface: surface,
|
|
@@ -54,7 +54,7 @@ export declare function SelectEdit({ label, value, options, groups, reason, onCo
|
|
|
54
54
|
labelAction?: ReactNode;
|
|
55
55
|
groups?: readonly OptionGroup[];
|
|
56
56
|
}): import("react").JSX.Element;
|
|
57
|
-
export declare function CheckboxList({ label, value, options,
|
|
57
|
+
export declare function CheckboxList({ label, value, options, reason, onToggle, readOnlyValue }: {
|
|
58
58
|
label: string;
|
|
59
59
|
value: string[];
|
|
60
60
|
options: readonly {
|
|
@@ -64,8 +64,6 @@ export declare function CheckboxList({ label, value, options, groups, reason, on
|
|
|
64
64
|
reason?: string | null;
|
|
65
65
|
onToggle: (value: string, checked: boolean) => void;
|
|
66
66
|
readOnlyValue?: string;
|
|
67
|
-
searchable?: boolean;
|
|
68
|
-
groups?: readonly OptionGroup[];
|
|
69
67
|
}): import("react").JSX.Element;
|
|
70
68
|
export declare function TestName({ test }: SectionProps): import("react").JSX.Element;
|
|
71
69
|
export declare function Hypothesis({ test }: SectionProps): import("react").JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useId, useState } from 'react';
|
|
4
|
-
import { TextInput, NumberInput, Textarea, Select,
|
|
4
|
+
import { TextInput, NumberInput, Textarea, Select, CheckboxList as UICheckboxList } from '../../../ui/Inputs.js';
|
|
5
5
|
import { TEST_PAGE as C } from '../../copy/testPage.js';
|
|
6
6
|
import { EDITABLE_BY_STATUS } from '../../../collections/experiments/editability.js';
|
|
7
7
|
import { lockedReason } from '../../lockedNotice.model.js';
|
|
@@ -128,52 +128,22 @@ export function SelectEdit({ label, value, options, groups, reason, onCommit, re
|
|
|
128
128
|
}, option.value))
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
|
-
export function CheckboxList({ label, value, options,
|
|
131
|
+
export function CheckboxList({ label, value, options, reason, onToggle, readOnlyValue }) {
|
|
132
132
|
const id = useId();
|
|
133
|
-
const [query, setQuery] = useState('');
|
|
134
|
-
const visible = searchable ? options.filter((option)=>value.includes(option.value) || option.label.toLowerCase().includes(query.toLowerCase())) : options;
|
|
135
133
|
if (reason) return /*#__PURE__*/ _jsx(ReadOnly, {
|
|
136
134
|
label: label,
|
|
137
135
|
reason: reason,
|
|
138
136
|
value: readOnlyValue ?? value.map((v)=>options.find((o)=>o.value === v)?.label ?? v).join(', ')
|
|
139
137
|
});
|
|
140
|
-
return /*#__PURE__*/
|
|
138
|
+
return /*#__PURE__*/ _jsx(UICheckboxList, {
|
|
141
139
|
id: id,
|
|
142
140
|
label: label,
|
|
143
141
|
value: value,
|
|
144
|
-
options:
|
|
142
|
+
options: options,
|
|
145
143
|
onChange: (next)=>{
|
|
146
144
|
const changed = options.find((option)=>next.includes(option.value) !== value.includes(option.value));
|
|
147
145
|
if (changed) onToggle(changed.value, next.includes(changed.value));
|
|
148
|
-
}
|
|
149
|
-
children: [
|
|
150
|
-
searchable ? /*#__PURE__*/ _jsx(SearchInput, {
|
|
151
|
-
id: `${id}-search`,
|
|
152
|
-
label: C.searchGoals,
|
|
153
|
-
value: query,
|
|
154
|
-
onChange: (event)=>setQuery(event.target.value)
|
|
155
|
-
}) : null,
|
|
156
|
-
groups ? groups.map((group, index)=>{
|
|
157
|
-
const items = group.options.filter((option)=>visible.some((item)=>item.value === option.value));
|
|
158
|
-
return items.length ? /*#__PURE__*/ _jsxs("div", {
|
|
159
|
-
children: [
|
|
160
|
-
group.label ? /*#__PURE__*/ _jsx("h3", {
|
|
161
|
-
children: group.label
|
|
162
|
-
}) : null,
|
|
163
|
-
/*#__PURE__*/ _jsx("ul", {
|
|
164
|
-
children: items.map((option)=>/*#__PURE__*/ _jsx("li", {
|
|
165
|
-
children: /*#__PURE__*/ _jsx(Checkbox, {
|
|
166
|
-
id: `${id}-${index}-${option.value}`,
|
|
167
|
-
label: option.label,
|
|
168
|
-
checked: value.includes(option.value),
|
|
169
|
-
onChange: (event)=>onToggle(option.value, event.target.checked)
|
|
170
|
-
})
|
|
171
|
-
}, option.value))
|
|
172
|
-
})
|
|
173
|
-
]
|
|
174
|
-
}, index) : null;
|
|
175
|
-
}) : null
|
|
176
|
-
]
|
|
146
|
+
}
|
|
177
147
|
});
|
|
178
148
|
}
|
|
179
149
|
export function TestName({ test }) {
|
|
@@ -3,8 +3,9 @@ import type { PreflightResult } from '../../types/endpoints.js';
|
|
|
3
3
|
import { type ReadinessRead } from '../readinessRead.js';
|
|
4
4
|
import type { TestDocument, TestDocumentPatch } from './testDocument.model.js';
|
|
5
5
|
/** Section data only: staging never saves. Call commit on blur or a section action. */
|
|
6
|
-
export declare function useTestDocument(id: DocId, { apiRoute, refetchPreflightOnFocus, enabled, onDocument, onPreflight, requestPreflight }: {
|
|
6
|
+
export declare function useTestDocument(id: DocId, { apiRoute, contentLocale, refetchPreflightOnFocus, enabled, onDocument, onPreflight, requestPreflight }: {
|
|
7
7
|
apiRoute: string;
|
|
8
|
+
contentLocale?: string;
|
|
8
9
|
refetchPreflightOnFocus?: boolean;
|
|
9
10
|
enabled?: boolean;
|
|
10
11
|
onDocument?: (doc: TestDocument) => void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
+
import { contentLocaleURL } from '../contentLocaleURL.js';
|
|
2
3
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
4
|
import { API_MESSAGES } from '../copy/common.js';
|
|
4
5
|
import { readPreflight } from '../readPreflight.js';
|
|
@@ -68,16 +69,18 @@ function stage(session, partial) {
|
|
|
68
69
|
if (!session.queue.length) session.view.saving = 'idle';
|
|
69
70
|
session.publish();
|
|
70
71
|
}
|
|
71
|
-
/** Section data only: staging never saves. Call commit on blur or a section action. */ export function useTestDocument(id, { apiRoute, refetchPreflightOnFocus = false, enabled = true, onDocument, onPreflight, requestPreflight }) {
|
|
72
|
+
/** Section data only: staging never saves. Call commit on blur or a section action. */ export function useTestDocument(id, { apiRoute, contentLocale, refetchPreflightOnFocus = false, enabled = true, onDocument, onPreflight, requestPreflight }) {
|
|
72
73
|
const observers = useRef({
|
|
73
74
|
onDocument,
|
|
74
75
|
onPreflight,
|
|
75
|
-
requestPreflight
|
|
76
|
+
requestPreflight,
|
|
77
|
+
contentLocale
|
|
76
78
|
});
|
|
77
79
|
observers.current = {
|
|
78
80
|
onDocument,
|
|
79
81
|
onPreflight,
|
|
80
|
-
requestPreflight
|
|
82
|
+
requestPreflight,
|
|
83
|
+
contentLocale
|
|
81
84
|
};
|
|
82
85
|
const base = apiRoute.replace(/\/$/, '');
|
|
83
86
|
const documentId = String(id);
|
|
@@ -129,13 +132,14 @@ function stage(session, partial) {
|
|
|
129
132
|
async function refreshPreflight(initial = false, supersede = false) {
|
|
130
133
|
if (controller.signal.aborted) return;
|
|
131
134
|
const revision = ++preflightRevision;
|
|
135
|
+
const requestedLocale = observers.current.contentLocale;
|
|
132
136
|
session.preflightLoading = true;
|
|
133
137
|
session.publish();
|
|
134
138
|
// createApi has no signal option; this read must abort without cancelling submitted PATCHes.
|
|
135
139
|
let body;
|
|
136
140
|
let status = 0;
|
|
137
141
|
try {
|
|
138
|
-
const { response, body: answerBody } = await readPreflight((signal)=>observers.current.requestPreflight?.(signal, supersede || initial && reloadCount > 0) ?? fetch(`${base}/xp/experiments/${encodeURIComponent(documentId)}/preflight`, {
|
|
142
|
+
const { response, body: answerBody } = await readPreflight((signal)=>observers.current.requestPreflight?.(signal, supersede || initial && reloadCount > 0) ?? fetch(contentLocaleURL(`${base}/xp/experiments/${encodeURIComponent(documentId)}/preflight`, requestedLocale), {
|
|
139
143
|
method: 'GET',
|
|
140
144
|
credentials: 'include',
|
|
141
145
|
cache: 'no-store',
|
|
@@ -146,6 +150,7 @@ function stage(session, partial) {
|
|
|
146
150
|
} catch {}
|
|
147
151
|
if (controller.signal.aborted) return;
|
|
148
152
|
if (revision !== preflightRevision) return;
|
|
153
|
+
if (requestedLocale !== observers.current.contentLocale) return refreshPreflight(initial, supersede);
|
|
149
154
|
session.preflightLoading = false;
|
|
150
155
|
session.view.preflightRead = classifyReadinessRead(status, body, session.preflightFailures + 1);
|
|
151
156
|
session.preflightFailures = session.view.preflightRead.failed ? session.preflightFailures + 1 : 0;
|
|
@@ -362,6 +367,17 @@ function stage(session, partial) {
|
|
|
362
367
|
reloadCount,
|
|
363
368
|
enabled
|
|
364
369
|
]);
|
|
370
|
+
const previousLocale = useRef(contentLocale);
|
|
371
|
+
useEffect(()=>{
|
|
372
|
+
if (previousLocale.current === contentLocale) return;
|
|
373
|
+
previousLocale.current = contentLocale;
|
|
374
|
+
const entry = commitRef.current;
|
|
375
|
+
if (enabled && entry?.session.key === key && entry.session.view.loadState === 'ready') void entry.refreshPreflight();
|
|
376
|
+
}, [
|
|
377
|
+
contentLocale,
|
|
378
|
+
enabled,
|
|
379
|
+
key
|
|
380
|
+
]);
|
|
365
381
|
const stagePartial = useCallback((partial)=>{
|
|
366
382
|
const session = current.current;
|
|
367
383
|
if (session?.key === key) stage(session, partial);
|
|
@@ -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;
|
|
@@ -36,6 +38,7 @@ export declare function useApi(apiRoute: string): {
|
|
|
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?: {
|
|
@@ -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;
|
|
@@ -50,6 +50,9 @@ export interface CheckStartInput {
|
|
|
50
50
|
flagPoints?: FlagPoint[];
|
|
51
51
|
placements?: BlockPlacement[];
|
|
52
52
|
flagPlacements?: FlagPlacement[];
|
|
53
|
+
placementLocaleCodes?: readonly string[];
|
|
54
|
+
placementLocale?: string;
|
|
55
|
+
placementDefaultLocale?: string;
|
|
53
56
|
placementError?: PlacementFailure;
|
|
54
57
|
flagPlacementError?: PlacementFailure;
|
|
55
58
|
flagPointBusy?: boolean;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { placementLanguageSuffix } from '../testSurface/copy/languages.js';
|
|
1
2
|
import { asymmetricGoal } from '../goals/fairness.js';
|
|
2
3
|
import { checkArms } from '../collections/experiments/armInvariants.js';
|
|
3
4
|
import { normalisePath } from '../runtime/normalisePath.js';
|
|
@@ -19,11 +20,82 @@ export const relationshipId = (value)=>value == null ? undefined : typeof value
|
|
|
19
20
|
* pageTarget, holdout included, normalised the same way ('' is '/'). Occupancy and lock keys use this. */ export const pageTargetPaths = (arms)=>[
|
|
20
21
|
...new Set(arms.filter((arm)=>typeof arm.pageTarget === 'string').map((arm)=>normalisePath(arm.pageTarget)))
|
|
21
22
|
].sort();
|
|
22
|
-
const placementDetail = ({ collection, id, title })=>({
|
|
23
|
+
const placementDetail = ({ collection, id, title, locales, allLocales, locale, localeLabel })=>({
|
|
23
24
|
collection,
|
|
24
25
|
id,
|
|
25
|
-
title
|
|
26
|
+
title: `${title}${placementLanguageSuffix({
|
|
27
|
+
allLocales,
|
|
28
|
+
locales: locales?.length ? locales : locale ? [
|
|
29
|
+
localeLabel ?? locale
|
|
30
|
+
] : undefined
|
|
31
|
+
})}`
|
|
26
32
|
});
|
|
33
|
+
/** Group only the languages with this finding, independently for each page and
|
|
34
|
+
* finding payload. Single-language occurrence details keep their original shape. */ function placementDetails(findings, all, input, findingKey = (detail)=>JSON.stringify(detail)) {
|
|
35
|
+
const groups = new Map();
|
|
36
|
+
const ordered = [];
|
|
37
|
+
for (const { placement, detail } of findings){
|
|
38
|
+
if (!placement.locale) {
|
|
39
|
+
ordered.push({
|
|
40
|
+
placement,
|
|
41
|
+
detail,
|
|
42
|
+
languages: new Map(),
|
|
43
|
+
members: []
|
|
44
|
+
});
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
const key = JSON.stringify([
|
|
48
|
+
placement.collection,
|
|
49
|
+
String(placement.id),
|
|
50
|
+
findingKey(detail)
|
|
51
|
+
]);
|
|
52
|
+
let group = groups.get(key);
|
|
53
|
+
if (!group) {
|
|
54
|
+
group = {
|
|
55
|
+
placement,
|
|
56
|
+
detail,
|
|
57
|
+
languages: new Map(),
|
|
58
|
+
members: []
|
|
59
|
+
};
|
|
60
|
+
groups.set(key, group);
|
|
61
|
+
ordered.push(group);
|
|
62
|
+
}
|
|
63
|
+
group.languages.set(placement.locale, placement.localeLabel ?? placement.locale);
|
|
64
|
+
group.members.push(placement);
|
|
65
|
+
}
|
|
66
|
+
return ordered.map(({ placement, detail, languages, members })=>{
|
|
67
|
+
if (!placement.locale) return {
|
|
68
|
+
...placementDetail(placement),
|
|
69
|
+
...detail
|
|
70
|
+
};
|
|
71
|
+
const page = all.filter((other)=>other.collection === placement.collection && String(other.id) === String(placement.id));
|
|
72
|
+
const configured = input.placementLocaleCodes ?? (page.some((other)=>other.allLocales) ? [
|
|
73
|
+
...new Set(page.flatMap((other)=>other.locale ? [
|
|
74
|
+
other.locale
|
|
75
|
+
] : []))
|
|
76
|
+
] : undefined);
|
|
77
|
+
const allLocales = configured?.length && configured.every((code)=>languages.has(code)) ? true : undefined;
|
|
78
|
+
const names = [
|
|
79
|
+
...languages.values()
|
|
80
|
+
];
|
|
81
|
+
const title = (members.find((row)=>row.locale === input.placementLocale) ?? members.find((row)=>row.locale === input.placementDefaultLocale) ?? placement).title;
|
|
82
|
+
return {
|
|
83
|
+
...placementDetail({
|
|
84
|
+
...placement,
|
|
85
|
+
title,
|
|
86
|
+
locale: undefined,
|
|
87
|
+
allLocales,
|
|
88
|
+
locales: names
|
|
89
|
+
}),
|
|
90
|
+
...allLocales ? {
|
|
91
|
+
allLocales: true
|
|
92
|
+
} : {
|
|
93
|
+
locales: names
|
|
94
|
+
},
|
|
95
|
+
...detail
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
}
|
|
27
99
|
const positive = (value)=>typeof value === 'number' && Number.isFinite(value) && value > 0;
|
|
28
100
|
function invalidParams(arms, point) {
|
|
29
101
|
return arms.flatMap((arm)=>{
|
|
@@ -118,27 +190,58 @@ function invalidParams(arms, point) {
|
|
|
118
190
|
add('no-placements', placementRemoved || e.kind !== 'block' || !input.placementError && placements.length > 0, input.placementError);
|
|
119
191
|
add('placement-removed', !placementRemoved);
|
|
120
192
|
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(
|
|
193
|
+
add('placement-unpublished', unpublished.length === 0, placementDetails(unpublished.map((placement)=>({
|
|
194
|
+
placement,
|
|
195
|
+
detail: {}
|
|
196
|
+
})), placements, input));
|
|
197
|
+
const nested = placements.filter((p)=>p.published).flatMap((placement)=>(placement.nestedTests ?? []).map((detail)=>({
|
|
198
|
+
placement,
|
|
199
|
+
detail
|
|
200
|
+
})));
|
|
201
|
+
const seenPairs = new Set();
|
|
202
|
+
const uniqueNested = nested.filter(({ placement, detail })=>{
|
|
203
|
+
const key = JSON.stringify([
|
|
204
|
+
placement.collection,
|
|
205
|
+
String(placement.id),
|
|
206
|
+
placement.locale,
|
|
207
|
+
detail.outerSlug ?? detail.outer,
|
|
208
|
+
detail.innerSlug ?? detail.inner
|
|
209
|
+
]);
|
|
210
|
+
if (seenPairs.has(key)) return false;
|
|
211
|
+
seenPairs.add(key);
|
|
212
|
+
return true;
|
|
213
|
+
});
|
|
214
|
+
add('nested-tests', nested.length === 0, placementDetails(uniqueNested, placements, input));
|
|
122
215
|
const duplicates = placements.filter((p)=>p.published && p.duplicateRows);
|
|
123
|
-
add('duplicate-version-row', duplicates.length === 0, duplicates.map(
|
|
124
|
-
|
|
125
|
-
|
|
216
|
+
add('duplicate-version-row', duplicates.length === 0, placementDetails(duplicates.map((placement)=>({
|
|
217
|
+
placement,
|
|
218
|
+
detail: {}
|
|
219
|
+
})), placements, input));
|
|
220
|
+
const identical = placements.filter((p)=>p.published).flatMap((placement)=>(placement.identicalSlots ?? []).filter((slot)=>e.arms.some((arm)=>arm.slot === slot && arm.kind !== 'holdout')).map((arm)=>({
|
|
221
|
+
placement,
|
|
222
|
+
detail: {
|
|
223
|
+
arm
|
|
224
|
+
}
|
|
225
|
+
})));
|
|
226
|
+
for (const detail of placementDetails(identical, placements, input)){
|
|
227
|
+
const { arm, ...page } = detail;
|
|
228
|
+
checks.push({
|
|
126
229
|
code: 'version-identical',
|
|
127
230
|
ok: true,
|
|
128
231
|
warning: true,
|
|
129
232
|
detail: {
|
|
130
|
-
arm
|
|
131
|
-
|
|
132
|
-
id: p.id,
|
|
133
|
-
title: p.title
|
|
233
|
+
arm,
|
|
234
|
+
...page
|
|
134
235
|
}
|
|
135
236
|
});
|
|
136
237
|
}
|
|
137
238
|
const empty = placements.filter((placement)=>placement.published && e.arms.some((arm)=>arm.kind !== 'holdout' && (!arm.slot || !(placement.slots[arm.slot] > 0))));
|
|
138
|
-
add('empty-slot', e.kind !== 'block' || empty.length === 0, empty.map((placement)=>({
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
239
|
+
add('empty-slot', e.kind !== 'block' || empty.length === 0, placementDetails(empty.map((placement)=>({
|
|
240
|
+
placement,
|
|
241
|
+
detail: {
|
|
242
|
+
slots: placement.slots
|
|
243
|
+
}
|
|
244
|
+
})), placements, input, (detail)=>JSON.stringify(e.arms.filter((arm)=>arm.kind !== 'holdout' && (!arm.slot || !(detail.slots[arm.slot] > 0))).map((arm)=>arm.key))));
|
|
142
245
|
add('make-content-unsupported', true);
|
|
143
246
|
const localized = placements.find((placement)=>placement.localized);
|
|
144
247
|
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,3 +1,6 @@
|
|
|
1
|
+
import { placementReader } from '../blocks/placementLocale.js';
|
|
2
|
+
import { puckExperimentSlug } from '../puck/experimentSlug.js';
|
|
3
|
+
import { puckVisibility, hiddenOnSizes, visibilitySizes } from '../puck/visibility.js';
|
|
1
4
|
import { Forbidden, NotFound, ValidationError, Locked, commitTransaction, initTransaction, killTransaction } from 'payload';
|
|
2
5
|
import { latestDraftContent, publishedContent as readPublishedContent } from '../db/publishedContent.js';
|
|
3
6
|
import { EXPERIMENT_BLOCK_SLUG, hostBlocks, slotBlocks } from '../blocks/model.js';
|
|
@@ -9,7 +12,7 @@ import { lockContentDefaults } from '../db/appends.js';
|
|
|
9
12
|
import { pooledExecutor, txExecutor } from '../db/executor.js';
|
|
10
13
|
import { currentTxid, txidStatus } from '../db/txid.js';
|
|
11
14
|
import { buildAndStoreManifest } from '../manifest/compile.js';
|
|
12
|
-
import {
|
|
15
|
+
import { puckCollections } from '../options.js';
|
|
13
16
|
import { contentDone } from '../contentDone.js';
|
|
14
17
|
import { archive } from './archive.js';
|
|
15
18
|
import { relationshipId } from './checkStart.js';
|
|
@@ -30,23 +33,40 @@ class LocalizedContent extends Error {
|
|
|
30
33
|
}
|
|
31
34
|
const isNotFound = (error)=>contentFailureReason(error) === 'not-found' || Boolean(error && typeof error === 'object' && 'status' in error && error.status === 404);
|
|
32
35
|
const object = (value)=>value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
33
|
-
/** Flatten selected slots in every content array, including nested selected slots. */ function unwrap(value, slug, slot) {
|
|
36
|
+
/** Flatten selected slots in every content array, including nested selected slots. */ function unwrap(value, slug, slot, visibility = puckVisibility(value)) {
|
|
34
37
|
if (Array.isArray(value)) return value.flatMap((node)=>{
|
|
38
|
+
if (object(node) && visibility.get(node)?.hidden) return [
|
|
39
|
+
node
|
|
40
|
+
];
|
|
35
41
|
if (object(node) && node.type === 'ExperimentSlot' && object(node.props)) {
|
|
36
|
-
|
|
37
|
-
if ((typeof ref === 'string' ? ref : object(ref) ? ref.slug : undefined) === slug) {
|
|
42
|
+
if (puckExperimentSlug(node.props.experiment) === slug) {
|
|
38
43
|
const content = node.props[slot];
|
|
39
44
|
if (!Array.isArray(content)) throw new Error('The winning content slot is missing.');
|
|
40
|
-
|
|
45
|
+
const selected = unwrap(content, slug, slot, visibility);
|
|
46
|
+
const hideOn = hiddenOnSizes(node.props._visibility);
|
|
47
|
+
return hideOn.length ? selected.map((child)=>{
|
|
48
|
+
if (!object(child) || !object(child.props)) return child;
|
|
49
|
+
const current = object(child.props._visibility) ? child.props._visibility : {};
|
|
50
|
+
return {
|
|
51
|
+
...child,
|
|
52
|
+
props: {
|
|
53
|
+
...child.props,
|
|
54
|
+
_visibility: {
|
|
55
|
+
...current,
|
|
56
|
+
hideOn: visibilitySizes.filter((size)=>hideOn.includes(size) || hiddenOnSizes(current).includes(size))
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}) : selected;
|
|
41
61
|
}
|
|
42
62
|
}
|
|
43
63
|
return [
|
|
44
|
-
unwrap(node, slug, slot)
|
|
64
|
+
unwrap(node, slug, slot, visibility)
|
|
45
65
|
];
|
|
46
66
|
});
|
|
47
|
-
if (object(value)) return Object.fromEntries(Object.entries(value).map(([key, child])=>[
|
|
67
|
+
if (object(value)) return visibility.get(value)?.hidden ? value : Object.fromEntries(Object.entries(value).map(([key, child])=>[
|
|
48
68
|
key,
|
|
49
|
-
unwrap(child, slug, slot)
|
|
69
|
+
unwrap(child, slug, slot, visibility)
|
|
50
70
|
]));
|
|
51
71
|
return value;
|
|
52
72
|
}
|
|
@@ -393,7 +413,7 @@ export async function makeContent(req, { experimentId, options }) {
|
|
|
393
413
|
const drafts = Boolean(config?.versions && config.versions.drafts);
|
|
394
414
|
const published = await readPublishedContent(req, collection, id);
|
|
395
415
|
if (!published) throw new NotFound();
|
|
396
|
-
const editor =
|
|
416
|
+
const editor = placementReader(req, collection, options).read(published, 'all-locales').editor;
|
|
397
417
|
const blockRegistration = options.blocks?.collections.find((r)=>r.slug === collection);
|
|
398
418
|
const contentField = editor === 'blocks' ? blockRegistration?.field : field;
|
|
399
419
|
if (!contentField) throw new Error('This content field is no longer configured.');
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { PayloadRequest } from 'payload';
|
|
2
|
+
import type { BlockPlacement } from './placements.js';
|
|
3
|
+
/** Read through manager access, on both preflight and Start's locked rescan. */
|
|
4
|
+
export declare function nestedPlacementNames(req: PayloadRequest, placements: readonly BlockPlacement[]): Promise<Map<string, string>>;
|
|
5
|
+
export declare const nameNestedPlacements: (placements: readonly BlockPlacement[], names: ReadonlyMap<string, string>) => BlockPlacement[];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** Read through manager access, on both preflight and Start's locked rescan. */ export async function nestedPlacementNames(req, placements) {
|
|
2
|
+
const slugs = [
|
|
3
|
+
...new Set(placements.flatMap((p)=>(p.nestedTests ?? []).flatMap((pair)=>[
|
|
4
|
+
pair.outer,
|
|
5
|
+
pair.inner
|
|
6
|
+
])))
|
|
7
|
+
];
|
|
8
|
+
if (!slugs.length) return new Map();
|
|
9
|
+
const found = await req.payload.find({
|
|
10
|
+
collection: 'xp-experiments',
|
|
11
|
+
req,
|
|
12
|
+
overrideAccess: false,
|
|
13
|
+
depth: 0,
|
|
14
|
+
pagination: false,
|
|
15
|
+
where: {
|
|
16
|
+
slug: {
|
|
17
|
+
in: slugs
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
return new Map(found.docs.map((doc)=>[
|
|
22
|
+
String(doc.slug),
|
|
23
|
+
String(doc.name)
|
|
24
|
+
]));
|
|
25
|
+
}
|
|
26
|
+
export const nameNestedPlacements = (placements, names)=>placements.map((p)=>({
|
|
27
|
+
...p,
|
|
28
|
+
nestedTests: p.nestedTests?.map((pair)=>({
|
|
29
|
+
...pair,
|
|
30
|
+
outer: names.get(pair.outer) ?? pair.outer,
|
|
31
|
+
inner: names.get(pair.inner) ?? pair.inner
|
|
32
|
+
}))
|
|
33
|
+
}));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { placementReader } from '../blocks/placementLocale.js';
|
|
1
2
|
import { safeError } from '../log.js';
|
|
2
3
|
import { isDeepStrictEqual } from 'node:util';
|
|
3
4
|
import { pageVersionContent } from '../db/pageContent.js';
|
|
@@ -17,10 +18,11 @@ export async function identicalPageVersions(req, collection, arms) {
|
|
|
17
18
|
if (!page?.published) return null;
|
|
18
19
|
const raw = await pageVersionContent(req, collection.slug, page.id);
|
|
19
20
|
if (!raw || raw._status === 'draft') return null;
|
|
21
|
+
const reader = placementReader(req, collection.slug);
|
|
20
22
|
return {
|
|
21
23
|
arm,
|
|
22
24
|
id: page.id,
|
|
23
|
-
value: comparableContent(collection.contentOf(raw))
|
|
25
|
+
value: reader.documentViews.map((view)=>comparableContent(collection.contentOf(reader.read(raw, 'all-locales', view).doc)))
|
|
24
26
|
};
|
|
25
27
|
} catch (cause) {
|
|
26
28
|
req.payload.logger.error({
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { placementDocumentPaths } from '../blocks/placementLocale.js';
|
|
2
|
+
import { sortLockKeys } from '../db/locks.js';
|
|
1
3
|
import { placementPathContent, placementTests } from '../db/placements.js';
|
|
2
4
|
import { lockPagePaths } from '../db/locks.js';
|
|
3
5
|
import { normalisePath } from '../runtime/normalisePath.js';
|
|
@@ -42,12 +44,13 @@ export async function placementPaths(req, options, docs) {
|
|
|
42
44
|
if (!registration) continue;
|
|
43
45
|
const row = await placementPathContent(req, doc.collection, doc.id);
|
|
44
46
|
if (!row || row._status === 'draft') continue;
|
|
45
|
-
const path
|
|
46
|
-
|
|
47
|
+
for (const path of placementDocumentPaths(req, doc.collection, [
|
|
48
|
+
row
|
|
49
|
+
], 'all-locales', (doc)=>registration.pathOf(doc)))paths.add(normalisePath(path));
|
|
47
50
|
}
|
|
48
|
-
return [
|
|
51
|
+
return sortLockKeys([
|
|
49
52
|
...paths
|
|
50
|
-
]
|
|
53
|
+
]);
|
|
51
54
|
}
|
|
52
55
|
const active = (test)=>test.status === 'running' || test.status === 'decided';
|
|
53
56
|
export async function placementInteractions(req, exec, options, experiment, paths) {
|