@delmaredigital/payload-experiments 0.4.0-rc.6 → 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/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/PageWizard.js +1 -0
- package/dist/admin/surface/newTest/newTest.css +1 -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 +3 -2
- 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/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 +38 -31
- package/dist/hooks/blockRemovalRule.d.ts +2 -2
- package/dist/hooks/blockRemovalRule.js +16 -14
- package/dist/hooks/pageGuard.d.ts +3 -0
- package/dist/hooks/pageGuard.js +33 -23
- 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.js +40 -37
- package/dist/puck/editor/ConfigureTestDrawer.d.ts +8 -4
- package/dist/puck/editor/ConfigureTestDrawer.js +4 -2
- package/dist/puck/editor/ExperimentSlotEditor.js +135 -104
- package/dist/puck/editor/LeftoverVersions.d.ts +1 -1
- package/dist/puck/editor/LeftoverVersions.js +40 -43
- package/dist/puck/editor/VersionBuilder.d.ts +18 -1
- package/dist/puck/editor/VersionBuilder.js +217 -39
- package/dist/puck/editor/blockClipboard.d.ts +16 -0
- package/dist/puck/editor/blockClipboard.js +20 -0
- package/dist/puck/editor/copy.d.ts +8 -1
- package/dist/puck/editor/copy.js +9 -1
- package/dist/puck/editor/editor.chrome.css +117 -3
- package/dist/puck/editor/editor.css +130 -8
- package/dist/puck/editor/editor.model.d.ts +2 -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 +18 -12
- package/dist/puck/editor/placementsCache.js +52 -47
- 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 +2 -3
- package/dist/puck/visibility.js +11 -7
- package/dist/server/recordContentChange.js +34 -19
- package/dist/server/resolveExperimentData.js +2 -2
- 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 +1 -1
- package/dist/testSurface/copy/readiness.js +1 -1
- package/dist/testSurface/copy/testPage.d.ts +21 -0
- package/dist/testSurface/copy/testPage.js +21 -0
- 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/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/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/TestSurface.js +29 -9
- 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 +5 -4
- 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 +219 -56
- 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/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 +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
package/dist/hooks/pageGuard.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import { refuseNewNestedTests } from './puckNestedTests.js';
|
|
2
|
+
import { hasLocalizedFields } from '../transitions/contentFields.js';
|
|
1
3
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
-
import { previousPublishedContent, storedContent } from '../db/appends.js';
|
|
4
|
+
import { previousPublishedContent, storedContent, placementWriteContent } from '../db/appends.js';
|
|
3
5
|
import { lockPlacementScope, sortLockKeys } from '../db/locks.js';
|
|
4
6
|
import { txExecutor, pooledExecutor } from '../db/executor.js';
|
|
5
7
|
import { normalisePath } from '../runtime/normalisePath.js';
|
|
6
8
|
import { XpNoTransactionError, XpRefusal } from '../errors.js';
|
|
7
9
|
import { placementGuardCopy, pageGuardCopy, READINESS_COPY } from '../testSurface/copy/readiness.js';
|
|
8
|
-
import {
|
|
10
|
+
import { allPlacementSlugs, mergedPlacementLocales, placementDocumentPaths } from '../blocks/placementLocale.js';
|
|
9
11
|
import { isObject } from '../blocks/model.js';
|
|
10
12
|
import { placementTests, removableBlockTests, appendPlacementDoc } from '../db/placements.js';
|
|
11
13
|
import { isPageBusy } from '../db/pageBusy.js';
|
|
@@ -86,6 +88,9 @@ export const pageGuardBeforeOperation = ({ args, operation })=>{
|
|
|
86
88
|
request: req,
|
|
87
89
|
draft: call.draft === true,
|
|
88
90
|
restore: operation === 'restoreVersion',
|
|
91
|
+
versionId: operation === 'restoreVersion' ? call.id : undefined,
|
|
92
|
+
isBulk,
|
|
93
|
+
publishSpecificLocale: call.publishSpecificLocale,
|
|
89
94
|
bulk,
|
|
90
95
|
pending: false
|
|
91
96
|
});
|
|
@@ -165,14 +170,9 @@ function registration(req, slug) {
|
|
|
165
170
|
return optionsOf(req).pages?.collections.find((entry)=>entry.slug === slug);
|
|
166
171
|
}
|
|
167
172
|
const active = (test)=>test.status === 'running' || test.status === 'decided';
|
|
168
|
-
const
|
|
173
|
+
const documentPathsOf = (req, collection, rows)=>{
|
|
169
174
|
const page = registration(req, collection);
|
|
170
|
-
return page ?
|
|
171
|
-
const path = row ? page.pathOf(row) : null;
|
|
172
|
-
return path === null ? [] : [
|
|
173
|
-
normalisePath(path)
|
|
174
|
-
];
|
|
175
|
-
})) : [];
|
|
175
|
+
return page ? placementDocumentPaths(req, collection, rows, 'all-locales', (doc)=>page.pathOf(doc)) : [];
|
|
176
176
|
};
|
|
177
177
|
/** The later audit also recognises arm-select tags; include those ids in its lock superset. */ function taggedIds(value, ids = new Set()) {
|
|
178
178
|
if (Array.isArray(value)) value.forEach((v)=>taggedIds(v, ids));
|
|
@@ -233,9 +233,9 @@ export const pageGuardBeforeDelete = async ({ req, id, collection })=>{
|
|
|
233
233
|
// Keep the earlier page guard's baseline read and every refusal intact.
|
|
234
234
|
const published = page ? await previousPublishedContent(req, collection.slug, id) : await storedContent(req, collection.slug, id);
|
|
235
235
|
if (!published || published._status === 'draft') return;
|
|
236
|
-
const paths =
|
|
236
|
+
const paths = sortLockKeys(documentPathsOf(req, collection.slug, [
|
|
237
237
|
published
|
|
238
|
-
]);
|
|
238
|
+
]).map(normalisePath));
|
|
239
239
|
const exec = await req.transactionID != null ? txExecutor(req) : pooledExecutor(req.payload);
|
|
240
240
|
let tests = page ? await placementTests(exec) : undefined;
|
|
241
241
|
const { views, affected } = await blockRemovalRule.prepare(req, collection.slug, collection.trash && published.deletedAt != null ? undefined : published, {}, true, exec, tests);
|
|
@@ -249,7 +249,7 @@ export const pageGuardBeforeDelete = async ({ req, id, collection })=>{
|
|
|
249
249
|
}));
|
|
250
250
|
} else tests = affected;
|
|
251
251
|
} else if (await req.transactionID != null) {
|
|
252
|
-
await lockPlacementScope(exec, guardExperimentIds(tests,
|
|
252
|
+
await lockPlacementScope(exec, guardExperimentIds(tests, allPlacementSlugs(req, collection.slug, published, 'all-locales'), collection.slug, paths, req.context.xpHeldExperiments, taggedIds(published), affected.map((test)=>test.id)), paths);
|
|
253
253
|
tests = await placementTests(exec);
|
|
254
254
|
}
|
|
255
255
|
for (const path of paths)protect(tests.filter((t)=>!t.pageCollection || t.pageCollection === collection.slug), path);
|
|
@@ -272,14 +272,25 @@ export const pageGuardBeforeChange = async ({ req, collection, originalDoc, oper
|
|
|
272
272
|
const options = optionsOf(req);
|
|
273
273
|
try {
|
|
274
274
|
const published = operation === 'create' ? undefined : await previousPublishedContent(req, collection.slug, originalDoc.id);
|
|
275
|
+
// Preserve the localization-off path and its IO. Localized writes mirror
|
|
276
|
+
// the base Payload uses for this operation's unselected languages.
|
|
277
|
+
const stored = operation === 'create' || !hasLocalizedFields(req.payload.config.collections?.find((entry)=>entry.slug === collection.slug)?.fields ?? [], req.payload.config) ? published : await placementWriteContent(req, collection.slug, originalDoc.id, published ?? await storedContent(req, collection.slug, originalDoc.id), {
|
|
278
|
+
versionId: call?.versionId,
|
|
279
|
+
bulk: call?.isBulk,
|
|
280
|
+
draft: call?.draft,
|
|
281
|
+
publishSpecificLocale: call?.publishSpecificLocale,
|
|
282
|
+
trashing: Boolean(collection.trash && data.deletedAt != null)
|
|
283
|
+
});
|
|
275
284
|
const before = published?._status === 'draft' ? undefined : published;
|
|
276
|
-
const beforeSlugs =
|
|
277
|
-
const
|
|
278
|
-
const
|
|
285
|
+
const beforeSlugs = allPlacementSlugs(req, collection.slug, before, 'all-locales');
|
|
286
|
+
const rawAfter = mergedPlacementLocales(req, collection.slug, stored, after);
|
|
287
|
+
const afterSlugs = allPlacementSlugs(req, collection.slug, rawAfter, 'all-locales');
|
|
288
|
+
const oldPaths = documentPathsOf(req, collection.slug, [
|
|
279
289
|
before
|
|
280
|
-
]),
|
|
281
|
-
|
|
290
|
+
]), newPaths = documentPathsOf(req, collection.slug, [
|
|
291
|
+
rawAfter
|
|
282
292
|
]);
|
|
293
|
+
const beforePaths = sortLockKeys(oldPaths.map(normalisePath)), afterPaths = sortLockKeys(newPaths.map(normalisePath));
|
|
283
294
|
const paths = sortLockKeys([
|
|
284
295
|
...beforePaths,
|
|
285
296
|
...afterPaths
|
|
@@ -287,7 +298,7 @@ export const pageGuardBeforeChange = async ({ req, collection, originalDoc, oper
|
|
|
287
298
|
const exec = await req.transactionID != null ? txExecutor(req) : pooledExecutor(req.payload);
|
|
288
299
|
let tests = await placementTests(exec);
|
|
289
300
|
const trashing = Boolean(collection.trash && after.deletedAt != null);
|
|
290
|
-
const { views, affected, hidden } = await blockRemovalRule.prepare(req, collection.slug, collection.trash && before?.deletedAt != null ? undefined : before,
|
|
301
|
+
const { views, affected, hidden } = await blockRemovalRule.prepare(req, collection.slug, collection.trash && before?.deletedAt != null ? undefined : before, rawAfter, trashing || drafts && after._status !== 'published', exec, tests, 'all-locales');
|
|
291
302
|
const publishes = !drafts || after._status === 'published';
|
|
292
303
|
const noTransaction = ()=>{
|
|
293
304
|
if (publishes && tests.some((t)=>t.kind === 'block' && active(t) && afterSlugs.includes(t.slug))) throw new XpNoTransactionError('Save this page with transactions on.');
|
|
@@ -300,7 +311,7 @@ export const pageGuardBeforeChange = async ({ req, collection, originalDoc, oper
|
|
|
300
311
|
...afterSlugs
|
|
301
312
|
], collection.slug, paths, req.context.xpHeldExperiments, taggedIds([
|
|
302
313
|
before,
|
|
303
|
-
|
|
314
|
+
rawAfter
|
|
304
315
|
]), affected.map((test)=>test.id)), paths);
|
|
305
316
|
tests = await placementTests(exec);
|
|
306
317
|
} catch (error) {
|
|
@@ -312,12 +323,11 @@ export const pageGuardBeforeChange = async ({ req, collection, originalDoc, oper
|
|
|
312
323
|
}
|
|
313
324
|
}
|
|
314
325
|
if (operation === 'update' && before) {
|
|
315
|
-
const page = registration(req, collection.slug);
|
|
316
|
-
const old = page?.pathOf(before);
|
|
317
326
|
const unpublishing = drafts && data._status === 'draft';
|
|
318
327
|
const trashing = collection.trash && data.deletedAt != null && !originalDoc.deletedAt;
|
|
319
|
-
|
|
328
|
+
for (const old of oldPaths)if (unpublishing || trashing || !newPaths.includes(old)) protect(tests.filter((t)=>!t.pageCollection || t.pageCollection === collection.slug), normalisePath(old));
|
|
320
329
|
}
|
|
330
|
+
if (publishes) refuseNewNestedTests(req, collection.slug, before, rawAfter, tests);
|
|
321
331
|
if (publishes) refuseInteraction(tests, beforeSlugs, afterSlugs, beforePaths, afterPaths, collection.slug);
|
|
322
332
|
if (affected.length) await blockRemovalRule.check(req, tests, affected, collection.slug, originalDoc.id, trashing || drafts && after._status !== 'published', views, call?.bulk, hidden);
|
|
323
333
|
return data;
|
|
@@ -334,7 +344,7 @@ export const pageGuardBeforeChange = async ({ req, collection, originalDoc, oper
|
|
|
334
344
|
try {
|
|
335
345
|
const stored = await storedContent(req, collection.slug, doc.id);
|
|
336
346
|
if (!stored) throw new Error('The saved placement row was not found.');
|
|
337
|
-
const slugs =
|
|
347
|
+
const slugs = allPlacementSlugs(req, collection.slug, stored, 'all-locales');
|
|
338
348
|
// A later publish in this transaction can restore an earlier removal. Only
|
|
339
349
|
// clear its claim once the stored published row actually contains the block.
|
|
340
350
|
const claims = req.context.xpPlacementRemovals;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type PayloadRequest } from 'payload';
|
|
2
|
+
/** Called by the page guard with its published baseline and merged write, only on publish.
|
|
3
|
+
* Puck's public reducer bypasses slot disallow; this server check covers that path.
|
|
4
|
+
*/
|
|
5
|
+
export declare function refuseNewNestedTests(req: PayloadRequest, collection: string, before: Record<string, unknown> | undefined, after: Record<string, unknown>, tests: readonly {
|
|
6
|
+
slug: string;
|
|
7
|
+
name: string;
|
|
8
|
+
}[]): void;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ValidationError } from 'payload';
|
|
2
|
+
import { placementReader } from '../blocks/placementLocale.js';
|
|
3
|
+
import { puckCollections } from '../options.js';
|
|
4
|
+
import { nestedTests, nestedTestKey, nestedTestLabel, nestedTestSlug, nearestOuterTest } from '../puck/nestedTests.js';
|
|
5
|
+
import { nestedTestCopy } from '../puck/nestedTestCopy.js';
|
|
6
|
+
/** Called by the page guard with its published baseline and merged write, only on publish.
|
|
7
|
+
* Puck's public reducer bypasses slot disallow; this server check covers that path.
|
|
8
|
+
*/ export function refuseNewNestedTests(req, collection, before, after, tests) {
|
|
9
|
+
const options = req.payload.config.custom?.xp;
|
|
10
|
+
const registration = puckCollections(options).find((entry)=>entry.slug === collection);
|
|
11
|
+
if (!registration) return;
|
|
12
|
+
const reader = placementReader(req, collection, options);
|
|
13
|
+
for (const view of reader.views){
|
|
14
|
+
const read = (doc)=>{
|
|
15
|
+
const content = reader.read(doc, 'all-locales', view);
|
|
16
|
+
return content.editor === 'puck' ? nestedTests(content.doc?.[registration.field]) : [];
|
|
17
|
+
};
|
|
18
|
+
const existing = new Set(read(before).map(nestedTestKey));
|
|
19
|
+
const additions = read(after).filter((pair)=>!existing.has(nestedTestKey(pair)));
|
|
20
|
+
const added = additions[0];
|
|
21
|
+
if (!added) continue;
|
|
22
|
+
const name = (block)=>tests.find((test)=>test.slug === nestedTestSlug(block))?.name ?? nestedTestLabel(block);
|
|
23
|
+
const message = nestedTestCopy.publish(name(nearestOuterTest(additions, added.inner.props.id)), name(added.inner));
|
|
24
|
+
const error = new ValidationError({
|
|
25
|
+
collection,
|
|
26
|
+
errors: [
|
|
27
|
+
{
|
|
28
|
+
path: registration.field,
|
|
29
|
+
message
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
});
|
|
33
|
+
error.message = message;
|
|
34
|
+
throw error;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -4,6 +4,7 @@ export type PreviewPage = Placement & {
|
|
|
4
4
|
key: string;
|
|
5
5
|
slotCount: number;
|
|
6
6
|
};
|
|
7
|
-
/**
|
|
7
|
+
/** Localized responses are already grouped by the server. Legacy single-language
|
|
8
|
+
* responses contain occurrences; preserve their page grouping and version counts. */
|
|
8
9
|
export declare function placementPages(placements: readonly Placement[], flagPoint?: string): PreviewPage[];
|
|
9
10
|
export {};
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** Localized responses are already grouped by the server. Legacy single-language
|
|
2
|
+
* responses contain occurrences; preserve their page grouping and version counts. */ export function placementPages(placements, flagPoint) {
|
|
3
|
+
if (placements.some((placement)=>placement.allLocales || placement.locales?.length)) {
|
|
4
|
+
return placements.map((placement, index)=>({
|
|
5
|
+
...placement,
|
|
6
|
+
key: String(index),
|
|
7
|
+
slotCount: placement.slotCount ?? 1
|
|
8
|
+
}));
|
|
9
|
+
}
|
|
2
10
|
const pages = new Map();
|
|
3
11
|
for (const [index, placement] of placements.entries()){
|
|
4
12
|
const key = `${placement.collection}\u0000${String(placement.id)}${placement.collection === flagPoint ? `\u0000${index}` : ''}`;
|
|
@@ -15,7 +23,7 @@
|
|
|
15
23
|
page: {
|
|
16
24
|
...placement,
|
|
17
25
|
key,
|
|
18
|
-
slotCount: 1
|
|
26
|
+
slotCount: placement.slotCount ?? 1
|
|
19
27
|
},
|
|
20
28
|
versions: new Map([
|
|
21
29
|
[
|
|
@@ -46,9 +46,10 @@ export interface ManifestInputs {
|
|
|
46
46
|
excludeIds?: DocId[];
|
|
47
47
|
pruneFlagDefaultIds?: DocId[];
|
|
48
48
|
}
|
|
49
|
-
export declare function loadManifestInputs(req: PayloadRequest, { excludeIds, pruneFlagDefaultIds }?: {
|
|
49
|
+
export declare function loadManifestInputs(req: PayloadRequest, { excludeIds, pruneFlagDefaultIds, signal }?: {
|
|
50
50
|
excludeIds?: DocId[];
|
|
51
51
|
pruneFlagDefaultIds?: DocId[];
|
|
52
|
+
signal?: AbortSignal;
|
|
52
53
|
}): Promise<ManifestInputs>;
|
|
53
54
|
/** Pure compiler. Assignment config comes exclusively from the frozen phase. */
|
|
54
55
|
/**
|
package/dist/manifest/compile.js
CHANGED
|
@@ -2,7 +2,8 @@ import { txExecutor } from '../db/executor.js';
|
|
|
2
2
|
import { bumpRevision, writeManifest } from '../db/state.js';
|
|
3
3
|
import { XpRefusal } from '../errors.js';
|
|
4
4
|
import { xpOptionsFromReq } from '../options/fromReq.js';
|
|
5
|
-
export async function loadManifestInputs(req, { excludeIds = [], pruneFlagDefaultIds = [] } = {}) {
|
|
5
|
+
export async function loadManifestInputs(req, { excludeIds = [], pruneFlagDefaultIds = [], signal } = {}) {
|
|
6
|
+
signal?.throwIfAborted();
|
|
6
7
|
// §7.8 manifest reads: transitions compile all live/archived routing state.
|
|
7
8
|
const result = await req.payload.find({
|
|
8
9
|
collection: 'xp-experiments',
|
|
@@ -20,6 +21,7 @@ export async function loadManifestInputs(req, { excludeIds = [], pruneFlagDefaul
|
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
23
|
});
|
|
24
|
+
signal?.throwIfAborted();
|
|
23
25
|
const excluded = new Set(excludeIds.map(String));
|
|
24
26
|
const experiments = [];
|
|
25
27
|
for (const doc of result.docs){
|
|
@@ -44,6 +46,7 @@ export async function loadManifestInputs(req, { excludeIds = [], pruneFlagDefaul
|
|
|
44
46
|
},
|
|
45
47
|
sort: '-phase'
|
|
46
48
|
});
|
|
49
|
+
signal?.throwIfAborted();
|
|
47
50
|
const rollout = phases.docs[0]?.phaseKind === 'rollout';
|
|
48
51
|
// §7.8 manifest reads: runtime rollout ranges use the test's full weights (including their exact
|
|
49
52
|
// floating-point sum) and its control content. The rollout record has only
|
|
@@ -64,6 +67,7 @@ export async function loadManifestInputs(req, { excludeIds = [], pruneFlagDefaul
|
|
|
64
67
|
},
|
|
65
68
|
sort: '-phase'
|
|
66
69
|
}) : null;
|
|
70
|
+
signal?.throwIfAborted();
|
|
67
71
|
if (rollout && !test?.docs[0]) throw new Error('Missing test phase for rollout ' + doc.id);
|
|
68
72
|
experiments.push({
|
|
69
73
|
...doc,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { SelectControl } from '../ui/SelectControl.js';
|
|
3
4
|
import { useEffect, useId, useState } from 'react';
|
|
4
5
|
import { fetchAllDocs } from '../lib/fetchAllDocs.js';
|
|
5
6
|
import { usePuckRoutes } from './hostContext.js';
|
|
@@ -88,43 +89,45 @@ export function ExperimentPicker({ value, onChange, allowEmpty = true }) {
|
|
|
88
89
|
})
|
|
89
90
|
]
|
|
90
91
|
}) : null,
|
|
91
|
-
/*#__PURE__*/
|
|
92
|
-
|
|
93
|
-
children:
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
value
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
92
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
93
|
+
className: "xp-ui-field",
|
|
94
|
+
children: [
|
|
95
|
+
/*#__PURE__*/ _jsx("label", {
|
|
96
|
+
id: `${id}-label`,
|
|
97
|
+
htmlFor: id,
|
|
98
|
+
children: pickerCopy.label
|
|
99
|
+
}),
|
|
100
|
+
/*#__PURE__*/ _jsxs(SelectControl, {
|
|
101
|
+
id: id,
|
|
102
|
+
value: selected,
|
|
103
|
+
onChange: (event)=>{
|
|
104
|
+
const experiment = experiments.find((doc)=>String(doc.id) === event.currentTarget.value);
|
|
105
|
+
if (experiment || allowEmpty) onChange(experiment ? {
|
|
106
|
+
id: experiment.id,
|
|
107
|
+
slug: experiment.slug
|
|
108
|
+
} : null);
|
|
109
|
+
},
|
|
110
|
+
children: [
|
|
111
|
+
/*#__PURE__*/ _jsx("option", {
|
|
112
|
+
value: "",
|
|
113
|
+
disabled: !allowEmpty,
|
|
114
|
+
children: allowEmpty ? pickerCopy.none : pickerCopy.choose
|
|
115
|
+
}),
|
|
116
|
+
value && !experiments.some((doc)=>String(doc.id) === selected) ? /*#__PURE__*/ _jsx("option", {
|
|
117
|
+
value: selected,
|
|
118
|
+
children: value.slug
|
|
119
|
+
}) : null,
|
|
120
|
+
visible.map((doc)=>/*#__PURE__*/ _jsxs("option", {
|
|
121
|
+
value: String(doc.id),
|
|
122
|
+
children: [
|
|
123
|
+
doc.name,
|
|
124
|
+
" · ",
|
|
125
|
+
pickerCopy.statuses[doc.status]
|
|
126
|
+
]
|
|
127
|
+
}, doc.id))
|
|
128
|
+
]
|
|
129
|
+
})
|
|
130
|
+
]
|
|
128
131
|
}),
|
|
129
132
|
state === 'error' ? /*#__PURE__*/ _jsx("div", {
|
|
130
133
|
className: "xp-ui-banner xp-ui-banner--error",
|
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
import type { DocId } from '../../types/contracts.js';
|
|
2
2
|
import type { resolvePuckRoutes } from '../routes.js';
|
|
3
3
|
import './editor.css';
|
|
4
|
+
type ConfigureRoutes = ReturnType<typeof resolvePuckRoutes> & {
|
|
5
|
+
contentLocale?: string;
|
|
6
|
+
};
|
|
4
7
|
export declare function ConfigureTestDrawer({ id, routes, onClose }: {
|
|
5
8
|
id: DocId;
|
|
6
|
-
routes:
|
|
9
|
+
routes: ConfigureRoutes;
|
|
7
10
|
onClose: () => void;
|
|
8
11
|
}): import("react").JSX.Element;
|
|
9
12
|
/** Separate document root, like the creation dialog: Puck has no ancestor handlers here. */
|
|
10
|
-
export declare function openConfigureTestDrawer(source: HTMLElement, routes:
|
|
13
|
+
export declare function openConfigureTestDrawer(source: HTMLElement, routes: ConfigureRoutes, id: DocId): {
|
|
11
14
|
close: () => void;
|
|
12
15
|
};
|
|
13
16
|
/** The canvas already has current permissions; use them without a second read. */
|
|
14
17
|
export declare function ConfigureTestControl({ id, routes }: {
|
|
15
18
|
id: DocId;
|
|
16
|
-
routes:
|
|
19
|
+
routes: ConfigureRoutes;
|
|
17
20
|
}): import("react").JSX.Element;
|
|
18
21
|
export declare function ConfigureTestButton({ id, routes }: {
|
|
19
22
|
id: DocId;
|
|
20
|
-
routes:
|
|
23
|
+
routes: ConfigureRoutes;
|
|
21
24
|
}): import("react").JSX.Element | null;
|
|
25
|
+
export {};
|
|
@@ -24,7 +24,8 @@ export function ConfigureTestDrawer({ id, routes, onClose }) {
|
|
|
24
24
|
surface: {
|
|
25
25
|
...result.surface,
|
|
26
26
|
adminRoute: routes.admin,
|
|
27
|
-
apiRoute: routes.api
|
|
27
|
+
apiRoute: routes.api,
|
|
28
|
+
contentLocale: routes.contentLocale
|
|
28
29
|
}
|
|
29
30
|
} : result);
|
|
30
31
|
});
|
|
@@ -34,6 +35,7 @@ export function ConfigureTestDrawer({ id, routes, onClose }) {
|
|
|
34
35
|
}, [
|
|
35
36
|
routes.api,
|
|
36
37
|
routes.admin,
|
|
38
|
+
routes.contentLocale,
|
|
37
39
|
attempt
|
|
38
40
|
]);
|
|
39
41
|
// Unknown permissions use the test page's authoritative admin access check.
|
|
@@ -67,7 +69,7 @@ export function ConfigureTestDrawer({ id, routes, onClose }) {
|
|
|
67
69
|
embedded: true,
|
|
68
70
|
onTitleChange: setTitle,
|
|
69
71
|
onDocument: (doc)=>publishExperiment(id, doc),
|
|
70
|
-
requestPreflight: (signal, supersede)=>readEditorPreflight(routes.api, id, signal, supersede)
|
|
72
|
+
requestPreflight: (signal, supersede)=>readEditorPreflight(routes.api, id, signal, supersede, routes.contentLocale)
|
|
71
73
|
}) : /*#__PURE__*/ _jsxs("div", {
|
|
72
74
|
role: state.error ? 'alert' : 'status',
|
|
73
75
|
children: [
|