@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.
Files changed (135) hide show
  1. package/dist/admin/blocks/BlockPanel.js +6 -4
  2. package/dist/admin/blocks/inject.js +1 -0
  3. package/dist/admin/blocks/model.d.ts +3 -2
  4. package/dist/admin/blocks/model.js +8 -4
  5. package/dist/admin/copy/blocks.d.ts +3 -2
  6. package/dist/admin/copy/blocks.js +7 -6
  7. package/dist/admin/surface/ResultsRoute.js +2 -1
  8. package/dist/admin/surface/TestsHome.d.ts +2 -1
  9. package/dist/admin/surface/TestsHome.js +91 -37
  10. package/dist/admin/surface/TestsSurface.js +3 -0
  11. package/dist/admin/surface/home.model.d.ts +2 -0
  12. package/dist/admin/surface/newTest/PageWizard.js +1 -0
  13. package/dist/admin/surface/newTest/newTest.css +1 -1
  14. package/dist/admin/views/TestsSurfaceClient.d.ts +3 -0
  15. package/dist/admin/views/TestsSurfaceClient.js +11 -0
  16. package/dist/admin/views/buildSurfaceProps.js +10 -3
  17. package/dist/blocks/bindings.js +3 -2
  18. package/dist/blocks/placementLanguages.d.ts +7 -0
  19. package/dist/blocks/placementLanguages.js +27 -0
  20. package/dist/blocks/placementLocale.d.ts +21 -7
  21. package/dist/blocks/placementLocale.js +218 -67
  22. package/dist/db/appends.d.ts +13 -0
  23. package/dist/db/appends.js +49 -0
  24. package/dist/db/bulkPlacementRemoval.js +8 -4
  25. package/dist/endpoints/contentLocale.d.ts +6 -0
  26. package/dist/endpoints/contentLocale.js +15 -0
  27. package/dist/endpoints/deleteImpact.d.ts +6 -0
  28. package/dist/endpoints/deleteImpact.js +206 -0
  29. package/dist/endpoints/index.js +7 -0
  30. package/dist/endpoints/pages.js +7 -3
  31. package/dist/endpoints/placementStatus.js +6 -1
  32. package/dist/endpoints/preflight.d.ts +1 -1
  33. package/dist/endpoints/preflight.js +17 -2
  34. package/dist/exports/adminClient.d.ts +1 -1
  35. package/dist/exports/adminClient.js +1 -1
  36. package/dist/exports/index.d.ts +1 -1
  37. package/dist/goals/fairness.js +38 -31
  38. package/dist/hooks/blockRemovalRule.d.ts +2 -2
  39. package/dist/hooks/blockRemovalRule.js +16 -14
  40. package/dist/hooks/pageGuard.d.ts +3 -0
  41. package/dist/hooks/pageGuard.js +33 -23
  42. package/dist/hooks/puckNestedTests.d.ts +8 -0
  43. package/dist/hooks/puckNestedTests.js +36 -0
  44. package/dist/lib/placementPages.d.ts +2 -1
  45. package/dist/lib/placementPages.js +10 -2
  46. package/dist/manifest/compile.d.ts +2 -1
  47. package/dist/manifest/compile.js +5 -1
  48. package/dist/puck/ExperimentPicker.js +40 -37
  49. package/dist/puck/editor/ConfigureTestDrawer.d.ts +8 -4
  50. package/dist/puck/editor/ConfigureTestDrawer.js +4 -2
  51. package/dist/puck/editor/ExperimentSlotEditor.js +135 -104
  52. package/dist/puck/editor/LeftoverVersions.d.ts +1 -1
  53. package/dist/puck/editor/LeftoverVersions.js +40 -43
  54. package/dist/puck/editor/VersionBuilder.d.ts +18 -1
  55. package/dist/puck/editor/VersionBuilder.js +217 -39
  56. package/dist/puck/editor/blockClipboard.d.ts +16 -0
  57. package/dist/puck/editor/blockClipboard.js +20 -0
  58. package/dist/puck/editor/copy.d.ts +8 -1
  59. package/dist/puck/editor/copy.js +9 -1
  60. package/dist/puck/editor/editor.chrome.css +117 -3
  61. package/dist/puck/editor/editor.css +130 -8
  62. package/dist/puck/editor/editor.model.d.ts +2 -1
  63. package/dist/puck/editor/editor.model.js +2 -2
  64. package/dist/puck/editor/localPlacements.d.ts +1 -0
  65. package/dist/puck/editor/localPlacements.js +12 -0
  66. package/dist/puck/editor/placementsCache.d.ts +18 -12
  67. package/dist/puck/editor/placementsCache.js +52 -47
  68. package/dist/puck/editor/usePlacementNotice.d.ts +1 -1
  69. package/dist/puck/editor/usePlacementNotice.js +4 -3
  70. package/dist/puck/experimentSlug.d.ts +2 -0
  71. package/dist/puck/experimentSlug.js +3 -0
  72. package/dist/puck/nestedTestCopy.d.ts +8 -0
  73. package/dist/puck/nestedTestCopy.js +22 -0
  74. package/dist/puck/nestedTests.d.ts +17 -0
  75. package/dist/puck/nestedTests.js +30 -0
  76. package/dist/puck/slotConfig.d.ts +1 -1
  77. package/dist/puck/slotConfig.js +17 -4
  78. package/dist/puck/visibility.d.ts +2 -3
  79. package/dist/puck/visibility.js +11 -7
  80. package/dist/server/recordContentChange.js +34 -19
  81. package/dist/server/resolveExperimentData.js +2 -2
  82. package/dist/testSurface/PreviewLinks.js +6 -2
  83. package/dist/testSurface/api.d.ts +6 -3
  84. package/dist/testSurface/api.js +10 -6
  85. package/dist/testSurface/contentLocaleURL.d.ts +2 -0
  86. package/dist/testSurface/contentLocaleURL.js +3 -0
  87. package/dist/testSurface/copy/common.d.ts +4 -0
  88. package/dist/testSurface/copy/common.js +8 -4
  89. package/dist/testSurface/copy/languages.d.ts +11 -0
  90. package/dist/testSurface/copy/languages.js +7 -0
  91. package/dist/testSurface/copy/readiness.d.ts +1 -1
  92. package/dist/testSurface/copy/readiness.js +1 -1
  93. package/dist/testSurface/copy/testPage.d.ts +21 -0
  94. package/dist/testSurface/copy/testPage.js +21 -0
  95. package/dist/testSurface/placementLabel.d.ts +8 -0
  96. package/dist/testSurface/placementLabel.js +24 -0
  97. package/dist/testSurface/placements/placementLabels.d.ts +2 -0
  98. package/dist/testSurface/placements/placementLabels.js +2 -1
  99. package/dist/testSurface/results/results.css +1 -1
  100. package/dist/testSurface/surface/contracts.d.ts +2 -0
  101. package/dist/testSurface/surface/editorPlacement.d.ts +5 -0
  102. package/dist/testSurface/surface/editorPlacement.js +18 -0
  103. package/dist/testSurface/surface/pageBlock/pageBlock.model.js +2 -1
  104. package/dist/testSurface/surface/pageBlock/parts.js +24 -6
  105. package/dist/testSurface/surface/readiness/readiness.model.js +9 -2
  106. package/dist/testSurface/surface/results/useResults.d.ts +4 -1
  107. package/dist/testSurface/surface/test/DeleteTest.d.ts +15 -0
  108. package/dist/testSurface/surface/test/DeleteTest.js +171 -0
  109. package/dist/testSurface/surface/test/TestSurface.js +29 -9
  110. package/dist/testSurface/surface/useTestDocument.d.ts +2 -1
  111. package/dist/testSurface/surface/useTestDocument.js +20 -4
  112. package/dist/testSurface/useApi.d.ts +4 -1
  113. package/dist/transitions/checkStart.d.ts +4 -1
  114. package/dist/transitions/checkStart.js +117 -14
  115. package/dist/transitions/contentFields.js +9 -5
  116. package/dist/transitions/makeContent.js +5 -4
  117. package/dist/transitions/nestedPlacementNames.d.ts +5 -0
  118. package/dist/transitions/nestedPlacementNames.js +33 -0
  119. package/dist/transitions/pageVersions.js +3 -1
  120. package/dist/transitions/placementInteractions.js +7 -4
  121. package/dist/transitions/placements.d.ts +26 -1
  122. package/dist/transitions/placements.js +219 -56
  123. package/dist/transitions/preflightData.d.ts +2 -1
  124. package/dist/transitions/preflightData.js +66 -3
  125. package/dist/transitions/start.js +4 -1
  126. package/dist/types/endpoints.d.ts +35 -1
  127. package/dist/types/endpoints.js +1 -1
  128. package/dist/types/surface.d.ts +2 -0
  129. package/dist/ui/Button.js +2 -2
  130. package/dist/ui/Inputs.d.ts +4 -3
  131. package/dist/ui/Inputs.js +9 -9
  132. package/dist/ui/SelectControl.d.ts +33 -0
  133. package/dist/ui/SelectControl.js +504 -0
  134. package/dist/ui/ui.css +13 -5
  135. package/package.json +3 -2
@@ -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 { placementSlugs } from '../blocks/bindings.js';
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 pathsOf = (req, collection, rows)=>{
173
+ const documentPathsOf = (req, collection, rows)=>{
169
174
  const page = registration(req, collection);
170
- return page ? sortLockKeys(rows.flatMap((row)=>{
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 = pathsOf(req, collection.slug, [
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, placementSlugs(optionsOf(req), collection.slug, published), collection.slug, paths, req.context.xpHeldExperiments, taggedIds(published), affected.map((test)=>test.id)), paths);
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 = placementSlugs(options, collection.slug, before);
277
- const afterSlugs = placementSlugs(options, collection.slug, after);
278
- const beforePaths = pathsOf(req, collection.slug, [
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
- ]), afterPaths = pathsOf(req, collection.slug, [
281
- after
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, after, trashing || drafts && after._status !== 'published', exec, tests);
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
- after
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
- if (old != null && (unpublishing || trashing || page.pathOf(after) !== old)) protect(tests.filter((t)=>!t.pageCollection || t.pageCollection === collection.slug), normalisePath(old));
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 = placementSlugs(optionsOf(req), collection.slug, stored);
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
- /** Preview URLs identify pages; counts use the most placements in any one version. */
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
- /** Preview URLs identify pages; counts use the most placements in any one version. */ export function placementPages(placements, flagPoint) {
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
  /**
@@ -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__*/ _jsx("label", {
92
- htmlFor: id,
93
- children: pickerCopy.label
94
- }),
95
- /*#__PURE__*/ _jsx("span", {
96
- className: "xp-ui-select-wrap",
97
- children: /*#__PURE__*/ _jsxs("select", {
98
- id: id,
99
- className: "xp-ui-input xp-ui-select",
100
- value: selected,
101
- onChange: (event)=>{
102
- const experiment = experiments.find((doc)=>String(doc.id) === event.currentTarget.value);
103
- if (experiment || allowEmpty) onChange(experiment ? {
104
- id: experiment.id,
105
- slug: experiment.slug
106
- } : null);
107
- },
108
- children: [
109
- /*#__PURE__*/ _jsx("option", {
110
- value: "",
111
- disabled: !allowEmpty,
112
- children: allowEmpty ? pickerCopy.none : pickerCopy.choose
113
- }),
114
- value && !experiments.some((doc)=>String(doc.id) === selected) ? /*#__PURE__*/ _jsx("option", {
115
- value: selected,
116
- children: value.slug
117
- }) : null,
118
- visible.map((doc)=>/*#__PURE__*/ _jsxs("option", {
119
- value: String(doc.id),
120
- children: [
121
- doc.name,
122
- " · ",
123
- pickerCopy.statuses[doc.status]
124
- ]
125
- }, doc.id))
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: ReturnType<typeof resolvePuckRoutes>;
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: ReturnType<typeof resolvePuckRoutes>, id: DocId): {
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: ReturnType<typeof resolvePuckRoutes>;
19
+ routes: ConfigureRoutes;
17
20
  }): import("react").JSX.Element;
18
21
  export declare function ConfigureTestButton({ id, routes }: {
19
22
  id: DocId;
20
- routes: ReturnType<typeof resolvePuckRoutes>;
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: [