@delmaredigital/payload-experiments 0.4.0-rc.7 → 0.4.0

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 (367) hide show
  1. package/README.md +9 -15
  2. package/dist/admin/MetricSourceSelect.js +10 -3
  3. package/dist/admin/armSelect/armSelect.model.d.ts +1 -1
  4. package/dist/admin/blocks/BlockPanel.d.ts +1 -0
  5. package/dist/admin/blocks/BlockPanel.js +75 -29
  6. package/dist/admin/blocks/model.js +7 -6
  7. package/dist/admin/copy/blocks.d.ts +14 -11
  8. package/dist/admin/copy/blocks.js +33 -22
  9. package/dist/admin/copy/goals.d.ts +15 -8
  10. package/dist/admin/copy/goals.js +18 -8
  11. package/dist/admin/copy/newTest.d.ts +10 -7
  12. package/dist/admin/copy/newTest.js +14 -7
  13. package/dist/admin/copy/status.d.ts +1 -1
  14. package/dist/admin/copy/status.js +2 -1
  15. package/dist/admin/pageCollections.d.ts +1 -0
  16. package/dist/admin/pageCollections.js +3 -0
  17. package/dist/admin/placementStatus.model.js +5 -3
  18. package/dist/admin/status.model.d.ts +1 -0
  19. package/dist/admin/status.model.js +2 -1
  20. package/dist/admin/surface/ResultsRoute.js +12 -10
  21. package/dist/admin/surface/SurfaceShell.d.ts +4 -2
  22. package/dist/admin/surface/SurfaceShell.js +28 -3
  23. package/dist/admin/surface/TestRowMenu.d.ts +13 -0
  24. package/dist/admin/surface/TestRowMenu.js +163 -0
  25. package/dist/admin/surface/TestsHome.d.ts +4 -3
  26. package/dist/admin/surface/TestsHome.js +224 -52
  27. package/dist/admin/surface/TestsSurface.js +2 -1
  28. package/dist/admin/surface/goals/DeleteGoalDialog.d.ts +7 -0
  29. package/dist/admin/surface/goals/DeleteGoalDialog.js +42 -0
  30. package/dist/admin/surface/goals/GoalForm.d.ts +1 -0
  31. package/dist/admin/surface/goals/GoalForm.js +280 -198
  32. package/dist/admin/surface/goals/GoalsList.js +102 -33
  33. package/dist/admin/surface/goals/data.d.ts +2 -0
  34. package/dist/admin/surface/goals/data.js +9 -0
  35. package/dist/admin/surface/goals/goals.css +3 -2
  36. package/dist/admin/surface/goals/goals.model.d.ts +2 -2
  37. package/dist/admin/surface/goals/goals.model.js +7 -12
  38. package/dist/admin/surface/home.model.d.ts +15 -8
  39. package/dist/admin/surface/home.model.js +22 -18
  40. package/dist/admin/surface/newTest/NewTest.d.ts +3 -3
  41. package/dist/admin/surface/newTest/NewTest.js +156 -96
  42. package/dist/admin/surface/newTest/PageWizard.d.ts +4 -1
  43. package/dist/admin/surface/newTest/PageWizard.js +99 -68
  44. package/dist/admin/surface/newTest/newTest.css +28 -11
  45. package/dist/admin/surface/results/ResultsHeader.d.ts +1 -1
  46. package/dist/admin/surface/results/ResultsHeader.js +98 -66
  47. package/dist/admin/surface/surface.css +29 -0
  48. package/dist/admin/surface/test/TestPage.js +46 -38
  49. package/dist/admin/surface/useXpStepNav.d.ts +11 -0
  50. package/dist/admin/surface/useXpStepNav.js +14 -0
  51. package/dist/admin/views/TestsSurfaceClient.js +27 -3
  52. package/dist/admin/views/buildSurfaceProps.js +18 -66
  53. package/dist/arms/copy.d.ts +13 -3
  54. package/dist/arms/copy.js +5 -4
  55. package/dist/blocks/createExperimentBlock.js +1 -1
  56. package/dist/blocks/formState.js +2 -2
  57. package/dist/collections/experiments/armInvariants.js +8 -5
  58. package/dist/collections/experiments/config.js +8 -3
  59. package/dist/collections/experiments/deleteGuard.js +2 -2
  60. package/dist/collections/experiments/lockHook.js +21 -2
  61. package/dist/collections/experiments/pickSlug.js +2 -0
  62. package/dist/collections/metrics.js +12 -5
  63. package/dist/collections/metricsGuards.js +2 -0
  64. package/dist/collections/serialize.js +8 -6
  65. package/dist/constants.d.ts +1 -0
  66. package/dist/constants.js +1 -0
  67. package/dist/db/adapter.d.ts +9 -1
  68. package/dist/db/adapter.js +77 -1
  69. package/dist/db/delete.d.ts +1 -1
  70. package/dist/db/delete.js +2 -4
  71. package/dist/db/events.d.ts +9 -0
  72. package/dist/db/events.js +42 -8
  73. package/dist/db/executor.d.ts +7 -1
  74. package/dist/db/executor.js +7 -3
  75. package/dist/db/pageCopies.d.ts +5 -0
  76. package/dist/db/pageCopies.js +31 -0
  77. package/dist/db/results.d.ts +5 -1
  78. package/dist/db/results.js +21 -5
  79. package/dist/db/snapshots.d.ts +2 -0
  80. package/dist/endpoints/deleteImpact.js +2 -1
  81. package/dist/endpoints/duplicateOriginal.d.ts +38 -0
  82. package/dist/endpoints/duplicateOriginal.js +414 -0
  83. package/dist/endpoints/editorSurface.js +1 -1
  84. package/dist/endpoints/events.js +103 -39
  85. package/dist/endpoints/index.js +22 -8
  86. package/dist/endpoints/pages.js +245 -66
  87. package/dist/endpoints/placementStatus.js +8 -4
  88. package/dist/endpoints/results.d.ts +1 -1
  89. package/dist/endpoints/results.js +9 -2
  90. package/dist/endpoints/routeId.d.ts +2 -2
  91. package/dist/endpoints/routeId.js +11 -5
  92. package/dist/endpoints/summary.js +46 -12
  93. package/dist/endpoints/testVersion.d.ts +2 -0
  94. package/dist/endpoints/testVersion.js +38 -0
  95. package/dist/endpoints/transitions.js +41 -29
  96. package/dist/errors.d.ts +4 -0
  97. package/dist/errors.js +6 -0
  98. package/dist/events/request.d.ts +6 -2
  99. package/dist/events/request.js +35 -8
  100. package/dist/events/rows.d.ts +1 -1
  101. package/dist/events/rows.js +24 -8
  102. package/dist/events/writable.d.ts +9 -0
  103. package/dist/events/writable.js +13 -0
  104. package/dist/exports/index.d.ts +1 -1
  105. package/dist/exports/rsc.d.ts +1 -0
  106. package/dist/exports/rsc.js +1 -0
  107. package/dist/goals/fairness.js +2 -2
  108. package/dist/goals/picker/copy.js +1 -1
  109. package/dist/goals/sourceLabel.d.ts +2 -0
  110. package/dist/goals/sourceLabel.js +4 -0
  111. package/dist/hooks/hostHook.js +6 -2
  112. package/dist/hooks/pageGuard.js +4 -0
  113. package/dist/hooks/trackPageCopies.d.ts +11 -0
  114. package/dist/hooks/trackPageCopies.js +7 -0
  115. package/dist/labels/arms.d.ts +3 -0
  116. package/dist/labels/arms.js +8 -0
  117. package/dist/lib/fetchAllDocs.d.ts +1 -1
  118. package/dist/manifest/compile.js +8 -5
  119. package/dist/onInit.js +14 -0
  120. package/dist/options.d.ts +2 -0
  121. package/dist/options.js +23 -2
  122. package/dist/plugin.js +56 -2
  123. package/dist/proxy/pageNavigation.d.ts +4 -0
  124. package/dist/proxy/pageNavigation.js +28 -0
  125. package/dist/proxy/resolve.js +52 -25
  126. package/dist/puck/editor/ConfigureTestDrawer.d.ts +7 -7
  127. package/dist/puck/editor/ConfigureTestDrawer.js +40 -29
  128. package/dist/puck/editor/ExperimentSlotEditor.d.ts +2 -1
  129. package/dist/puck/editor/ExperimentSlotEditor.js +376 -139
  130. package/dist/puck/editor/LeftoverVersions.js +17 -32
  131. package/dist/puck/editor/QuickTestActions.d.ts +6 -3
  132. package/dist/puck/editor/QuickTestActions.js +55 -33
  133. package/dist/puck/editor/ResultsReadout.d.ts +4 -1
  134. package/dist/puck/editor/ResultsReadout.js +28 -15
  135. package/dist/puck/editor/VersionBuilder.d.ts +17 -4
  136. package/dist/puck/editor/VersionBuilder.js +175 -112
  137. package/dist/puck/editor/armWrites.js +2 -2
  138. package/dist/puck/editor/armsCache.js +1 -3
  139. package/dist/puck/editor/copy.d.ts +14 -7
  140. package/dist/puck/editor/copy.js +26 -13
  141. package/dist/puck/editor/editor.chrome.css +10 -8
  142. package/dist/puck/editor/editor.css +15 -9
  143. package/dist/puck/editor/editor.model.d.ts +1 -0
  144. package/dist/puck/editor/placementsCache.d.ts +4 -0
  145. package/dist/puck/editor/usePageSaveReadiness.d.ts +6 -0
  146. package/dist/puck/editor/usePageSaveReadiness.js +31 -0
  147. package/dist/puck/nestedTestCopy.js +2 -2
  148. package/dist/puck/slotConfig.d.ts +1 -1
  149. package/dist/puck/slotConfig.js +1 -1
  150. package/dist/results/aggregate.d.ts +6 -3
  151. package/dist/results/aggregate.js +9 -9
  152. package/dist/results/analyse.d.ts +2 -0
  153. package/dist/results/analyse.js +2 -2
  154. package/dist/results/health.d.ts +8 -0
  155. package/dist/results/health.js +28 -0
  156. package/dist/results/identityCredit.d.ts +1 -0
  157. package/dist/results/identityCredit.js +4 -1
  158. package/dist/results/verdict.d.ts +4 -4
  159. package/dist/results/verdict.js +15 -11
  160. package/dist/runtime/cookie.d.ts +10 -2
  161. package/dist/runtime/cookie.js +38 -6
  162. package/dist/runtime/cookieOptions.d.ts +6 -0
  163. package/dist/runtime/cookieOptions.js +14 -0
  164. package/dist/runtime/proxyRuntime.d.ts +1 -0
  165. package/dist/runtime/proxyRuntime.js +18 -8
  166. package/dist/runtime/signing.d.ts +1 -0
  167. package/dist/runtime/signing.js +5 -0
  168. package/dist/sanitizeReadinessDetail.d.ts +2 -2
  169. package/dist/sanitizeReadinessDetail.js +20 -2
  170. package/dist/server/getAssignments.js +11 -10
  171. package/dist/server/recordContentChange.d.ts +1 -1
  172. package/dist/server/recordContentChange.js +11 -2
  173. package/dist/server/resolveExperimentBlocks.js +2 -4
  174. package/dist/server/resolveExperimentData.js +2 -5
  175. package/dist/server/runResults.js +54 -15
  176. package/dist/server/startExperiment.d.ts +20 -0
  177. package/dist/server/startExperiment.js +70 -0
  178. package/dist/server/trackConversion.js +10 -13
  179. package/dist/testSurface/PreviewLinks.d.ts +2 -1
  180. package/dist/testSurface/PreviewLinks.js +3 -3
  181. package/dist/testSurface/actions/DecideDialog.d.ts +10 -4
  182. package/dist/testSurface/actions/DecideDialog.js +93 -63
  183. package/dist/testSurface/actions/LifecycleAction.d.ts +17 -0
  184. package/dist/testSurface/actions/LifecycleAction.js +107 -0
  185. package/dist/testSurface/actions/MakeContentResult.d.ts +4 -3
  186. package/dist/testSurface/actions/MakeContentResult.js +10 -2
  187. package/dist/testSurface/actions/actions.model.d.ts +13 -5
  188. package/dist/testSurface/actions/actions.model.js +75 -22
  189. package/dist/testSurface/actions/decide.model.d.ts +1 -0
  190. package/dist/testSurface/actions/decide.model.js +1 -0
  191. package/dist/testSurface/allocation.model.js +6 -3
  192. package/dist/testSurface/api.d.ts +9 -6
  193. package/dist/testSurface/api.js +43 -23
  194. package/dist/testSurface/copy/actions.d.ts +37 -14
  195. package/dist/testSurface/copy/actions.js +40 -17
  196. package/dist/testSurface/copy/advanced.d.ts +10 -0
  197. package/dist/testSurface/copy/advanced.js +10 -0
  198. package/dist/testSurface/copy/arms.d.ts +1 -1
  199. package/dist/testSurface/copy/arms.js +1 -1
  200. package/dist/testSurface/copy/audience.d.ts +4 -3
  201. package/dist/testSurface/copy/audience.js +5 -4
  202. package/dist/testSurface/copy/common.d.ts +8 -6
  203. package/dist/testSurface/copy/common.js +8 -6
  204. package/dist/testSurface/copy/languages.d.ts +1 -0
  205. package/dist/testSurface/copy/languages.js +1 -0
  206. package/dist/testSurface/copy/metrics.d.ts +7 -0
  207. package/dist/testSurface/copy/metrics.js +9 -0
  208. package/dist/testSurface/copy/pages.d.ts +67 -7
  209. package/dist/testSurface/copy/pages.js +74 -7
  210. package/dist/testSurface/copy/readiness.d.ts +20 -7
  211. package/dist/testSurface/copy/readiness.js +36 -10
  212. package/dist/testSurface/copy/recommendation.d.ts +1 -22
  213. package/dist/testSurface/copy/recommendation.js +2 -22
  214. package/dist/testSurface/copy/results.d.ts +21 -12
  215. package/dist/testSurface/copy/results.js +24 -13
  216. package/dist/testSurface/copy/review.d.ts +13 -10
  217. package/dist/testSurface/copy/review.js +14 -10
  218. package/dist/testSurface/copy/setting.d.ts +1 -2
  219. package/dist/testSurface/copy/setting.js +1 -2
  220. package/dist/testSurface/copy/surface.d.ts +11 -2
  221. package/dist/testSurface/copy/surface.js +14 -11
  222. package/dist/testSurface/copy/testPage.d.ts +36 -12
  223. package/dist/testSurface/copy/testPage.js +53 -16
  224. package/dist/testSurface/format/date.d.ts +5 -2
  225. package/dist/testSurface/format/date.js +24 -8
  226. package/dist/testSurface/format/roundProgress.d.ts +6 -0
  227. package/dist/testSurface/format/roundProgress.js +15 -0
  228. package/dist/testSurface/format/useDateFormatter.d.ts +3 -0
  229. package/dist/testSurface/format/useDateFormatter.js +8 -0
  230. package/dist/testSurface/labels.d.ts +1 -2
  231. package/dist/testSurface/labels.js +2 -3
  232. package/dist/testSurface/lockedNotice.model.d.ts +2 -0
  233. package/dist/testSurface/lockedNotice.model.js +31 -0
  234. package/dist/testSurface/readPreflight.d.ts +4 -0
  235. package/dist/testSurface/readPreflight.js +6 -0
  236. package/dist/testSurface/readinessRead.d.ts +3 -0
  237. package/dist/testSurface/readinessRead.js +4 -0
  238. package/dist/testSurface/results/CiChart.js +2 -1
  239. package/dist/testSurface/results/DataTable.d.ts +1 -1
  240. package/dist/testSurface/results/DataTable.js +4 -3
  241. package/dist/testSurface/results/VerdictHero.d.ts +3 -2
  242. package/dist/testSurface/results/VerdictHero.js +5 -1
  243. package/dist/testSurface/results/legacy.d.ts +0 -5
  244. package/dist/testSurface/results/legacy.js +0 -14
  245. package/dist/testSurface/results/results.css +2 -2
  246. package/dist/testSurface/results/results.model.d.ts +9 -4
  247. package/dist/testSurface/results/results.model.js +31 -23
  248. package/dist/testSurface/results/snapshot.d.ts +2 -0
  249. package/dist/testSurface/results/snapshot.js +3 -0
  250. package/dist/testSurface/surface/contracts.d.ts +13 -1
  251. package/dist/testSurface/surface/editorPlacement.d.ts +3 -3
  252. package/dist/testSurface/surface/editorPlacement.js +2 -2
  253. package/dist/testSurface/surface/pageBlock/pageBlock.model.js +3 -3
  254. package/dist/testSurface/surface/pageBlock/parts.js +25 -12
  255. package/dist/testSurface/surface/pagePicker/CopyRoute.d.ts +8 -1
  256. package/dist/testSurface/surface/pagePicker/CopyRoute.js +243 -22
  257. package/dist/testSurface/surface/pagePicker/PageCombobox.d.ts +15 -4
  258. package/dist/testSurface/surface/pagePicker/PageCombobox.js +300 -197
  259. package/dist/testSurface/surface/pagePicker/pagePicker.css +73 -10
  260. package/dist/testSurface/surface/pagePicker/pagePicker.model.d.ts +5 -3
  261. package/dist/testSurface/surface/pagePicker/pagePicker.model.js +17 -2
  262. package/dist/testSurface/surface/readiness/ActionDialogs.d.ts +9 -5
  263. package/dist/testSurface/surface/readiness/ActionDialogs.js +241 -230
  264. package/dist/testSurface/surface/readiness/Banner.d.ts +5 -1
  265. package/dist/testSurface/surface/readiness/Banner.js +113 -141
  266. package/dist/testSurface/surface/readiness/SaveStatus.d.ts +8 -4
  267. package/dist/testSurface/surface/readiness/SaveStatus.js +23 -22
  268. package/dist/testSurface/surface/readiness/readiness.model.d.ts +20 -6
  269. package/dist/testSurface/surface/readiness/readiness.model.js +168 -21
  270. package/dist/testSurface/surface/readiness/useTransition.d.ts +6 -4
  271. package/dist/testSurface/surface/readiness/useTransition.js +57 -14
  272. package/dist/testSurface/surface/results/ReleasePages.d.ts +6 -3
  273. package/dist/testSurface/surface/results/ReleasePages.js +42 -41
  274. package/dist/testSurface/surface/results/ResultsBody.d.ts +11 -4
  275. package/dist/testSurface/surface/results/ResultsBody.js +221 -118
  276. package/dist/testSurface/surface/results/recommendation.model.d.ts +6 -9
  277. package/dist/testSurface/surface/results/recommendation.model.js +15 -59
  278. package/dist/testSurface/surface/results/useResults.d.ts +13 -8
  279. package/dist/testSurface/surface/results/useResults.js +3 -2
  280. package/dist/testSurface/surface/setting/parts.js +89 -46
  281. package/dist/testSurface/surface/setting/setting.css +2 -1
  282. package/dist/testSurface/surface/test/AdvancedSection.js +11 -4
  283. package/dist/testSurface/surface/test/DeleteTest.d.ts +10 -2
  284. package/dist/testSurface/surface/test/DeleteTest.js +173 -74
  285. package/dist/testSurface/surface/test/GoalSection.js +18 -14
  286. package/dist/testSurface/surface/test/LengthSection.js +24 -13
  287. package/dist/testSurface/surface/test/PageHoldout.d.ts +1 -1
  288. package/dist/testSurface/surface/test/PageHoldout.js +11 -8
  289. package/dist/testSurface/surface/test/ReadinessBar.d.ts +2 -1
  290. package/dist/testSurface/surface/test/ReadinessBar.js +4 -10
  291. package/dist/testSurface/surface/test/Section.js +8 -0
  292. package/dist/testSurface/surface/test/TargetingSection.js +82 -12
  293. package/dist/testSurface/surface/test/TestSurface.js +73 -37
  294. package/dist/testSurface/surface/test/VersionsSection.js +141 -91
  295. package/dist/testSurface/surface/test/fields.d.ts +32 -6
  296. package/dist/testSurface/surface/test/fields.js +166 -52
  297. package/dist/testSurface/surface/test/pageParts.js +27 -12
  298. package/dist/testSurface/surface/test/testPage.css +9 -2
  299. package/dist/testSurface/surface/test/testPage.model.d.ts +1 -0
  300. package/dist/testSurface/surface/test/testPage.model.js +6 -0
  301. package/dist/testSurface/surface/testDocument.model.d.ts +3 -0
  302. package/dist/testSurface/surface/testDocument.model.js +4 -1
  303. package/dist/testSurface/surface/useTestDocument.d.ts +21 -5
  304. package/dist/testSurface/surface/useTestDocument.js +472 -167
  305. package/dist/testSurface/surface/watchTestDocument.d.ts +15 -0
  306. package/dist/testSurface/surface/watchTestDocument.js +181 -0
  307. package/dist/testSurface/surfaceUrls.d.ts +1 -0
  308. package/dist/testSurface/surfaceUrls.js +4 -0
  309. package/dist/testSurface/useApi.d.ts +8 -5
  310. package/dist/testSurface/useOnTestReturn.d.ts +2 -0
  311. package/dist/testSurface/useOnTestReturn.js +27 -0
  312. package/dist/testSurface/useReadinessPolling.js +3 -1
  313. package/dist/transitions/addMetric.d.ts +2 -5
  314. package/dist/transitions/addMetric.js +5 -1
  315. package/dist/transitions/allocate.d.ts +2 -2
  316. package/dist/transitions/allocate.js +3 -1
  317. package/dist/transitions/archive.d.ts +1 -1
  318. package/dist/transitions/archive.js +3 -2
  319. package/dist/transitions/checkStart.d.ts +1 -0
  320. package/dist/transitions/checkStart.js +17 -6
  321. package/dist/transitions/decide.d.ts +1 -1
  322. package/dist/transitions/decide.js +5 -3
  323. package/dist/transitions/deleteExperiment.d.ts +2 -2
  324. package/dist/transitions/deleteExperiment.js +17 -7
  325. package/dist/transitions/kernel.d.ts +4 -0
  326. package/dist/transitions/kernel.js +9 -4
  327. package/dist/transitions/makeContent.d.ts +2 -1
  328. package/dist/transitions/makeContent.js +12 -8
  329. package/dist/transitions/nestedPlacementNames.d.ts +2 -2
  330. package/dist/transitions/nestedPlacementNames.js +4 -5
  331. package/dist/transitions/pageAddress.d.ts +6 -0
  332. package/dist/transitions/pageAddress.js +71 -0
  333. package/dist/transitions/pageVersions.d.ts +1 -1
  334. package/dist/transitions/phaseRecord.d.ts +2 -0
  335. package/dist/transitions/phaseRecord.js +5 -0
  336. package/dist/transitions/placementInteractions.d.ts +3 -3
  337. package/dist/transitions/placementInteractions.js +8 -7
  338. package/dist/transitions/placements.d.ts +2 -0
  339. package/dist/transitions/placements.js +5 -5
  340. package/dist/transitions/preflightData.d.ts +3 -2
  341. package/dist/transitions/preflightData.js +77 -43
  342. package/dist/transitions/releaseHoldout.d.ts +2 -1
  343. package/dist/transitions/releaseHoldout.js +3 -1
  344. package/dist/transitions/releasePages.d.ts +2 -1
  345. package/dist/transitions/releasePages.js +3 -1
  346. package/dist/transitions/resolveCaps.d.ts +2 -4
  347. package/dist/transitions/start.d.ts +7 -9
  348. package/dist/transitions/start.js +75 -39
  349. package/dist/transitions/startReads.d.ts +7 -0
  350. package/dist/transitions/startReads.js +28 -0
  351. package/dist/transitions/stop.d.ts +2 -1
  352. package/dist/transitions/stop.js +3 -2
  353. package/dist/types/armKey.d.ts +2 -0
  354. package/dist/types/armKey.js +1 -0
  355. package/dist/types/contracts.d.ts +17 -4
  356. package/dist/types/endpoints.d.ts +89 -17
  357. package/dist/types/endpoints.js +1 -1
  358. package/dist/types/runtime.d.ts +15 -9
  359. package/dist/types/snapshot.d.ts +2 -0
  360. package/dist/types/surface.d.ts +7 -9
  361. package/dist/ui/ChipsInput.d.ts +8 -1
  362. package/dist/ui/ChipsInput.js +17 -4
  363. package/dist/ui/Dialog.d.ts +21 -2
  364. package/dist/ui/Dialog.js +101 -4
  365. package/dist/ui/Inputs.js +0 -1
  366. package/dist/ui/ui.css +5 -1
  367. package/package.json +2 -2
@@ -6,51 +6,59 @@ import { formatAdminURL } from '../../../testSurface/format/adminURL.js';
6
6
  import { surfaceUrls } from '../../../testSurface/surfaceUrls.js';
7
7
  import { Button } from '../../../ui/Button.js';
8
8
  import { StatusChip } from '../../../ui/StatusChip.js';
9
+ import { useXpStepNav } from '../useXpStepNav.js';
9
10
  import { SurfaceShell } from '../SurfaceShell.js';
10
11
  export function TestPage({ id, surface, onTitleChange }) {
11
12
  return /*#__PURE__*/ _jsx(TestSurface, {
12
13
  id: id,
13
14
  surface: surface,
14
15
  onTitleChange: onTitleChange,
15
- renderFrame: ({ test, children })=>{
16
- const doc = test.doc;
17
- return /*#__PURE__*/ _jsx(SurfaceShell, {
18
- adminRoute: surface.adminRoute,
19
- title: doc?.name ?? C.test,
20
- crumbs: [
21
- {
22
- label: C.tests,
23
- href: surfaceUrls.home(surface.adminRoute)
24
- },
25
- {
26
- label: doc?.name ?? C.test
27
- }
28
- ],
29
- status: doc ? /*#__PURE__*/ _jsxs(_Fragment, {
30
- children: [
31
- /*#__PURE__*/ _jsx("span", {
32
- className: "xp-tests-kind",
33
- children: C.kinds[doc.kind]
34
- }),
35
- /*#__PURE__*/ _jsx(StatusChip, {
36
- status: doc.status
37
- })
38
- ]
39
- }) : undefined,
40
- actions: doc && surface.canReadResults && [
41
- 'running',
42
- 'stopped',
43
- 'decided'
44
- ].includes(doc.status) ? /*#__PURE__*/ _jsx(Button, {
45
- variant: "secondary",
46
- href: formatAdminURL({
47
- adminRoute: surface.adminRoute,
48
- path: `/experiments/${encodeURIComponent(String(doc.id))}/results`
49
- }),
50
- children: C.results
51
- }) : undefined,
16
+ renderFrame: ({ test, children })=>/*#__PURE__*/ _jsx(TestPageFrame, {
17
+ test: test,
18
+ surface: surface,
52
19
  children: children
53
- });
20
+ })
21
+ });
22
+ }
23
+ function TestPageFrame({ test, surface, children }) {
24
+ const doc = test.doc;
25
+ const crumbs = [
26
+ {
27
+ label: C.tests,
28
+ url: surfaceUrls.home(surface.adminRoute)
29
+ },
30
+ {
31
+ label: doc?.name ?? C.test
54
32
  }
33
+ ];
34
+ useXpStepNav(crumbs);
35
+ return /*#__PURE__*/ _jsx(SurfaceShell, {
36
+ adminRoute: surface.adminRoute,
37
+ title: doc?.name ?? C.test,
38
+ dynamicTitle: Boolean(doc?.name),
39
+ crumbs: crumbs.map(({ label, url })=>({
40
+ label,
41
+ href: url
42
+ })),
43
+ status: doc ? /*#__PURE__*/ _jsxs(_Fragment, {
44
+ children: [
45
+ /*#__PURE__*/ _jsx("span", {
46
+ className: "xp-tests-kind",
47
+ children: C.kinds[doc.kind]
48
+ }),
49
+ !test.statusReadPending ? /*#__PURE__*/ _jsx(StatusChip, {
50
+ status: doc.status
51
+ }) : null
52
+ ]
53
+ }) : undefined,
54
+ actions: doc && !test.statusReadPending && surface.canReadResults && doc.status !== 'draft' ? /*#__PURE__*/ _jsx(Button, {
55
+ variant: "secondary",
56
+ href: formatAdminURL({
57
+ adminRoute: surface.adminRoute,
58
+ path: `/experiments/${encodeURIComponent(String(doc.id))}/results`
59
+ }),
60
+ children: C.results
61
+ }) : undefined,
62
+ children: children
55
63
  });
56
64
  }
@@ -0,0 +1,11 @@
1
+ import type { TestsRoute } from '../../types/surface.js';
2
+ export type StepNavItem = {
3
+ label: string;
4
+ url?: string;
5
+ };
6
+ export declare const XpStepNavContext: import("react").Context<{
7
+ route: TestsRoute;
8
+ items: StepNavItem[];
9
+ setStepNav: (items: StepNavItem[]) => void;
10
+ } | undefined>;
11
+ export declare function useXpStepNav(items: StepNavItem[]): void;
@@ -0,0 +1,14 @@
1
+ 'use client';
2
+ import { createContext, useContext, useEffect } from 'react';
3
+ export const XpStepNavContext = createContext(undefined);
4
+ export function useXpStepNav(items) {
5
+ const setStepNav = useContext(XpStepNavContext)?.setStepNav;
6
+ // Callers can pass inline crumbs without resetting Payload's provider on every render.
7
+ const crumbs = JSON.stringify(items);
8
+ useEffect(()=>{
9
+ setStepNav?.(JSON.parse(crumbs));
10
+ }, [
11
+ crumbs,
12
+ setStepNav
13
+ ]);
14
+ }
@@ -1,11 +1,35 @@
1
1
  'use client';
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
- import { useLocale } from '@payloadcms/ui';
3
+ import { useLocale, useStepNav } from '@payloadcms/ui';
4
+ import { useCallback, useState } from 'react';
4
5
  import { TestsSurface as Surface } from '../surface/TestsSurface.js';
6
+ import { XpStepNavContext } from '../surface/useXpStepNav.js';
5
7
  /** Payload context stays at the admin entry; the mountable surface stays neutral. */ export function TestsSurface(props) {
6
8
  const locale = useLocale();
7
- return /*#__PURE__*/ _jsx(Surface, {
9
+ const { setStepNav } = useStepNav();
10
+ // Each screen starts with its own shell crumbs until it publishes step nav.
11
+ return /*#__PURE__*/ _jsx(ScreenStepNav, {
8
12
  ...props,
9
- contentLocale: locale?.code
13
+ contentLocale: locale?.code,
14
+ publishToPayload: setStepNav
15
+ }, `${props.route}/${props.id ?? ''}`);
16
+ }
17
+ function ScreenStepNav({ publishToPayload, ...props }) {
18
+ const [items, setItems] = useState([]);
19
+ const setStepNav = useCallback((next)=>{
20
+ setItems(next);
21
+ publishToPayload(next);
22
+ }, [
23
+ publishToPayload
24
+ ]);
25
+ return /*#__PURE__*/ _jsx(XpStepNavContext, {
26
+ value: {
27
+ route: props.route,
28
+ items,
29
+ setStepNav
30
+ },
31
+ children: /*#__PURE__*/ _jsx(Surface, {
32
+ ...props
33
+ })
10
34
  });
11
35
  }
@@ -1,10 +1,8 @@
1
1
  import { placementLanguageNames } from '../../blocks/placementLanguages.js';
2
- import { placementReader } from '../../blocks/placementLocale.js';
3
- import { flattenTopLevelFields, formatAdminURL } from 'payload/shared';
4
2
  import { serializeAttributeKeys, serializeFlagPoints, serializeMetricSources } from '../../collections/serialize.js';
5
3
  import { serializePageCollections } from '../pageCollections.js';
6
4
  import { collectionLabel as resolveLabel } from '../../collections/labels.js';
7
- import { puckCollections } from '../../options.js';
5
+ import { blockPageSlugs, puckCollections } from '../../options.js';
8
6
  import { xpOptionsFromReq } from '../../options/fromReq.js';
9
7
  import { routeAccess } from './access.model.js';
10
8
  export async function buildSurfaceProps({ req, route, id, searchParams }) {
@@ -43,66 +41,20 @@ export async function buildSurfaceProps({ req, route, id, searchParams }) {
43
41
  const defaults = state.flagDefaults;
44
42
  for (const point of flagPoints)point.effectiveDefaults = defaults?.[point.id]?.params ?? point.defaultParams;
45
43
  }
46
- const registrations = [
47
- ...new Set([
48
- ...options.puck?.enabled ? puckCollections(options) : [],
49
- ...options.blocks?.collections ?? []
50
- ].map((entry)=>entry.slug))
51
- ];
52
- const pages = route === 'new' && canManage && registrations.length ? (await Promise.all(registrations.map(async (collection)=>{
53
- try {
54
- const config = req.payload.config.collections.find((item)=>item.slug === collection);
55
- const useAsTitle = config?.admin.useAsTitle ?? 'id';
56
- const collectionLabel = resolveLabel(config?.labels.plural, collection, req);
57
- // appliesTo may inspect any stored field; ordinary Puck lists keep their title-only projection.
58
- const predicateFields = options.blocks?.collections.some((entry)=>entry.slug === collection) ? Object.fromEntries(flattenTopLevelFields(config?.fields ?? []).map((field)=>[
59
- field.name,
60
- true
61
- ])) : {};
62
- const result = await req.payload.find({
63
- collection,
64
- req,
65
- overrideAccess: false,
66
- depth: 0,
67
- limit: 50,
68
- sort: '-updatedAt',
69
- draft: true,
70
- select: {
71
- [useAsTitle]: true,
72
- ...predicateFields
73
- }
74
- });
75
- // The new-test list uses the latest draft's editing intent, as the "Test a block" field condition does (§4.1).
76
- return result.docs.map((row)=>{
77
- const placement = placementReader(req, collection, options).read(row, req.locale === 'all' ? 'all-locales' : 'localized');
78
- const doc = placement.doc;
79
- const editor = placement.editor;
80
- if (editor !== 'puck' && editor !== 'blocks') return null;
81
- const id = doc.id;
82
- const customUrl = options.admin?.editorUrl?.({
83
- collection,
84
- id,
85
- draft: true,
86
- editor,
87
- doc
88
- });
89
- const title = doc[useAsTitle];
90
- return {
91
- collection,
92
- collectionLabel,
93
- id,
94
- editor,
95
- title: typeof title === 'string' || typeof title === 'number' ? String(title) : String(id),
96
- editorUrl: typeof customUrl === 'string' ? customUrl : formatAdminURL({
97
- adminRoute,
98
- path: `/collections/${collection}/${encodeURIComponent(String(id))}`
99
- })
100
- };
101
- }).filter((page)=>page !== null);
102
- } catch {
103
- return [];
104
- }
105
- }))).flat() : undefined;
44
+ const blockPageCollections = route === 'new' && canManage ? blockPageSlugs(options).map((slug)=>{
45
+ const config = req.payload.config.collections.find((item)=>item.slug === slug);
46
+ const block = options.blocks?.collections.find((entry)=>entry.slug === slug);
47
+ const puck = options.puck?.enabled && puckCollections(options).some((entry)=>entry.slug === slug);
48
+ const editors = block ? [
49
+ 'blocks'
50
+ ] : [];
51
+ if (puck && (!block || block.appliesTo)) editors.push('puck');
52
+ return {
53
+ slug,
54
+ label: resolveLabel(config?.labels.plural, slug, req),
55
+ editors
56
+ };
57
+ }) : [];
106
58
  const descriptions = options.admin?.descriptions;
107
59
  const returnToTest = (await searchParams)?.return;
108
60
  return {
@@ -122,9 +74,9 @@ export async function buildSurfaceProps({ req, route, id, searchParams }) {
122
74
  canReadResults,
123
75
  isAdmin,
124
76
  flagPoints,
125
- ...pages === undefined ? {} : {
126
- pages
127
- },
77
+ ...blockPageCollections.length ? {
78
+ blockPageCollections
79
+ } : {},
128
80
  pageCollections: serializePageCollections(options.pages?.collections ?? [], req),
129
81
  collectionTitles: Object.fromEntries(req.payload.config.collections.flatMap((collection)=>{
130
82
  const title = collection.admin.useAsTitle;
@@ -1,6 +1,16 @@
1
- import type { ArmIssueCode } from '../types/endpoints.js';
2
- export declare const ISSUE_COPY: Record<ArmIssueCode, string>;
1
+ export declare const ISSUE_COPY: {
2
+ 'weights-total': string;
3
+ 'control-count': string;
4
+ 'control-first': (label?: string) => string;
5
+ 'holdout-last': string;
6
+ 'holdout-count': string;
7
+ 'variant-count': string;
8
+ 'duplicate-key': string;
9
+ 'duplicate-slot': string;
10
+ 'slot-required': string;
11
+ 'invalid-key': string;
12
+ };
3
13
  export declare function issueMessage(issue: {
4
14
  code: string;
5
15
  message: string;
6
- }, total: number): string;
16
+ }, total: number, controlLabel?: string): string;
package/dist/arms/copy.js CHANGED
@@ -1,7 +1,8 @@
1
+ import { controlVersionName } from '../labels/arms.js';
1
2
  export const ISSUE_COPY = {
2
3
  'weights-total': 'Weights must add up to 100%. They add up to {total}% now.',
3
- 'control-count': 'Include exactly one Original.',
4
- 'control-first': 'Put the Original first.',
4
+ 'control-count': 'Include exactly one version that visitors see today.',
5
+ 'control-first': (label)=>`Put ${controlVersionName(label)} first.`,
5
6
  'holdout-last': 'Put the holdout last.',
6
7
  'holdout-count': 'Include only one holdout.',
7
8
  'variant-count': 'Include up to three variants.',
@@ -10,7 +11,7 @@ export const ISSUE_COPY = {
10
11
  'slot-required': 'Choose the matching content slot for this group.',
11
12
  'invalid-key': 'Use the standard group names: Original, Variant A–C, Holdout.'
12
13
  };
13
- export function issueMessage(issue, total) {
14
+ export function issueMessage(issue, total, controlLabel) {
14
15
  const copy = Object.hasOwn(ISSUE_COPY, issue.code) ? ISSUE_COPY[issue.code] : issue.message;
15
- return copy.replace('{total}', String(total));
16
+ return typeof copy === 'function' ? copy(controlLabel) : copy.replace('{total}', String(total));
16
17
  }
@@ -6,7 +6,7 @@ export function validateExperimentSlots(value) {
6
6
  return new Set(slots).size === slots.length ? true : 'Each version appears once';
7
7
  }
8
8
  export function createExperimentBlock({ blocks, slug = EXPERIMENT_BLOCK_SLUG }) {
9
- if (blocks.some((block)=>block.slug === slug)) throw new Error('Experiment blocks cannot be nested.');
9
+ if (blocks.some((block)=>block.slug === slug)) throw new Error("Test blocks can't be placed inside another Test block.");
10
10
  return {
11
11
  slug,
12
12
  labels: {
@@ -55,7 +55,7 @@ import { BLOCK_SLOTS, EXPERIMENT_BLOCK_SLUG, isObject, slotBlocks } from './mode
55
55
  return copyRows(value, field);
56
56
  }
57
57
  export function wrapExperimentBlock(block, experiment, field, config = {}, blockSlug = EXPERIMENT_BLOCK_SLUG) {
58
- if (block.blockType === blockSlug) throw new Error('Experiment blocks cannot be nested.');
58
+ if (block.blockType === blockSlug) throw new Error("Test blocks can't be placed inside another Test block.");
59
59
  return {
60
60
  id: globalThis.crypto.randomUUID(),
61
61
  blockType: blockSlug,
@@ -86,7 +86,7 @@ function copySlotBlocks(block, slot, field, config) {
86
86
  ], field, config)[0], slot);
87
87
  }
88
88
  export function syncExperimentSlots(block, arms, field, config = {}) {
89
- const wanted = arms.filter((a)=>a.kind !== 'holdout' && a.key !== 'holdout').map((a)=>a.slot ?? a.key).filter((slot)=>BLOCK_SLOTS.includes(slot));
89
+ const wanted = arms.filter((a)=>a.kind !== 'holdout' && a.key !== 'holdout').map((a)=>a.key).filter((slot)=>BLOCK_SLOTS.includes(slot));
90
90
  const slots = [
91
91
  ...new Set(wanted)
92
92
  ].map((slot)=>block.slots.find((row)=>row.slot === slot) ?? {
@@ -1,3 +1,4 @@
1
+ import { ARM_LABELS, controlVersionName } from '../../labels/arms.js';
1
2
  /** The groups a new experiment starts with: Original 50 / Variant A 50, no holdout (spec §5.1, O4). Block slots equal the key. */ export function defaultArms(kind) {
2
3
  const slot = (key)=>kind === 'block' ? {
3
4
  slot: key
@@ -6,7 +7,7 @@
6
7
  {
7
8
  key: 'control',
8
9
  kind: 'control',
9
- label: 'Original',
10
+ label: ARM_LABELS.control,
10
11
  weight: 50,
11
12
  ...slot('control')
12
13
  },
@@ -34,8 +35,10 @@ export function checkArms(arms, kind) {
34
35
  if (arms.some((arm)=>!Number.isInteger(arm.weight) || arm.weight < 0) || arms.reduce((total, arm)=>total + arm.weight, 0) !== 100) {
35
36
  issue('weights-total', 'Group shares must be whole numbers that add up to exactly 100.');
36
37
  }
37
- if (arms.filter((arm)=>arm.kind === 'control').length !== 1) issue('control-count', 'Exactly one Original is required.');
38
- if (arms.some((arm, index)=>arm.kind === 'control' && index !== 0)) issue('control-first', 'The Original must be first.');
38
+ const controls = arms.filter((arm)=>arm.kind === 'control');
39
+ const controlLabel = controls[0]?.label;
40
+ if (controls.length !== 1) issue('control-count', 'Exactly one version must be the one visitors see today.');
41
+ if (arms.some((arm, index)=>arm.kind === 'control' && index !== 0)) issue('control-first', `${controlVersionName(controlLabel, true)} must be first.`);
39
42
  if (arms.filter((arm)=>arm.kind === 'holdout').length > 1) issue('holdout-count', 'Only one Holdout is allowed.');
40
43
  if (arms.some((arm, index)=>arm.kind === 'holdout' && index !== arms.length - 1)) issue('holdout-last', 'The Holdout must be the last group.');
41
44
  if (arms.filter((arm)=>arm.kind === 'variant').length > 3) issue('variant-count', 'At most three variants are allowed.');
@@ -53,9 +56,9 @@ export function checkArms(arms, kind) {
53
56
  keys.add(arm.key);
54
57
  if (kind === 'block') {
55
58
  if (arm.kind === 'holdout') {
56
- if (arm.slot != null) issue('invalid-key', 'The Holdout has no content of its own; it sees the Original.', index);
59
+ if (arm.slot != null) issue('invalid-key', `The Holdout has no content of its own; it sees ${controlVersionName(controlLabel)}.`, index);
57
60
  } else {
58
- if (!arm.slot || arm.slot !== arm.key) issue('slot-required', 'Each Original and Variant needs its own content area.', index);
61
+ if (!arm.slot || arm.slot !== arm.key) issue('slot-required', 'Each version needs its own content area.', index);
59
62
  if (arm.slot && slots.has(arm.slot)) issue('duplicate-slot', 'Two groups cannot share the same content area.', index);
60
63
  if (arm.slot) slots.add(arm.slot);
61
64
  }
@@ -44,16 +44,21 @@ export function experimentsCollection(options) {
44
44
  },
45
45
  access: {
46
46
  ...managedAccess(options),
47
- delete: async ({ req })=>await options.access.manage({
47
+ delete: async ({ req, id })=>{
48
+ if (await options.access.manage({
48
49
  req
49
- }) === true ? {
50
+ }) !== true) return false;
51
+ // Single deletes report status through the locked beforeDelete guard.
52
+ // Payload catches per-document hook failures in bulk deletes, so keep their status filter in access.
53
+ return id != null ? true : {
50
54
  status: {
51
55
  in: [
52
56
  'draft',
53
57
  'archived'
54
58
  ]
55
59
  }
56
- } : false
60
+ };
61
+ }
57
62
  },
58
63
  admin: {
59
64
  group: SURFACE_COPY.title,
@@ -3,8 +3,8 @@ import { xpOptionsFromReq } from '../../options/fromReq.js';
3
3
  export const deleteGuard = async ({ req, id })=>{
4
4
  await deleteExperiment(req, id);
5
5
  };
6
- export const deleteGuardAfter = async ({ req, id, doc })=>{
7
- await deleteExperimentAfter(req, id);
6
+ export const deleteGuardAfter = async ({ req, doc })=>{
7
+ await deleteExperimentAfter(req);
8
8
  return doc;
9
9
  };
10
10
  export const deleteGuardBeforeOperation = async ({ operation, args, req })=>{
@@ -1,3 +1,4 @@
1
+ import { withSlotsFor } from '../../arms/model.js';
1
2
  import { XpLockedFieldError, XpRefusal } from '../../errors.js';
2
3
  import { XP_IF_UPDATED_AT_HEADER } from '../../constants.js';
3
4
  import { txExecutor } from '../../db/executor.js';
@@ -64,6 +65,24 @@ const dates = new Set([
64
65
  }
65
66
  const same = (a, b, path)=>JSON.stringify(normalize(a, path)) === JSON.stringify(normalize(b, path));
66
67
  export const lockHook = async ({ data, originalDoc, operation, req })=>{
68
+ const kind = operation === 'create' ? data.kind : originalDoc.kind;
69
+ const storedArms = operation === 'update' ? originalDoc.arms : undefined;
70
+ const canonicalSlots = (value)=>{
71
+ if (kind !== 'block' || !Array.isArray(value) || value.some((row)=>!isObject(row))) return value;
72
+ return withSlotsFor(value, 'block');
73
+ };
74
+ const canonicalArms = canonicalSlots(storedArms);
75
+ // Payload runs collection beforeChange before field validation on Create,
76
+ // Update and Restore. Derive slots here so the arms validator sees them.
77
+ const arms = data.arms === undefined ? storedArms : data.arms;
78
+ const repaired = arms === storedArms ? canonicalArms : canonicalSlots(arms);
79
+ if (repaired !== arms) {
80
+ if (operation === 'create') data = {
81
+ ...data,
82
+ arms: repaired
83
+ };
84
+ else data.arms = repaired;
85
+ }
67
86
  if (req.context.xpTransition === true) return data;
68
87
  const baseline = req.headers.get(XP_IF_UPDATED_AT_HEADER);
69
88
  if (operation === 'update' && baseline !== null) {
@@ -71,7 +90,7 @@ export const lockHook = async ({ data, originalDoc, operation, req })=>{
71
90
  // so a competing save observes the preceding save's committed timestamp.
72
91
  const stored = await lockExperimentUpdatedAt(txExecutor(req), originalDoc.id);
73
92
  if (stored === null || new Date(baseline).getTime() !== new Date(stored).getTime()) {
74
- throw new XpRefusal('stale-edit', 'Someone else changed this test. Reload to see their changes.', undefined, 409);
93
+ throw new XpRefusal('stale-edit', 'This test changed. Read the latest settings and try again.', undefined, 409);
75
94
  }
76
95
  }
77
96
  const admin = async ()=>{
@@ -139,7 +158,7 @@ export const lockHook = async ({ data, originalDoc, operation, req })=>{
139
158
  ].includes(field) && isObject(value)) {
140
159
  for (const [key, nested] of Object.entries(value))await check(`${field}.${key}`, nested, originalDoc[field]?.[key]);
141
160
  } else {
142
- await check(field, value, originalDoc[field]);
161
+ await check(field, value, field === 'arms' ? canonicalArms : originalDoc[field]);
143
162
  // Replacing the group also changes its method, including clearing it.
144
163
  if (field === 'analysis' && !same(value, originalDoc.analysis, field) && originalDoc.analysis?.method != null && !await admin()) throw new XpLockedFieldError('analysis.method', status);
145
164
  }
@@ -1,8 +1,10 @@
1
+ import { assertReadCommitted } from '../../db/adapter.js';
1
2
  import { pickSlug } from '../../db/slugs.js';
2
3
  import { pooledExecutor, txExecutor } from '../../db/executor.js';
3
4
  export const pickExperimentSlug = async ({ req, data, operation })=>{
4
5
  if (operation !== 'create' || typeof data.slug !== 'string' || !data.slug) return data;
5
6
  const transactional = await req.transactionID != null;
7
+ if (transactional) await assertReadCommitted(req);
6
8
  data.slug = await pickSlug(transactional ? txExecutor(req) : pooledExecutor(req.payload), data.slug, transactional);
7
9
  return data;
8
10
  };
@@ -19,6 +19,12 @@ export function metricsCollection(options) {
19
19
  admin: {
20
20
  group: SURFACE_COPY.title,
21
21
  useAsTitle: 'name',
22
+ meta: {
23
+ title: {
24
+ absolute: 'Goals · Tests'
25
+ },
26
+ titleSuffix: ''
27
+ },
22
28
  components: {
23
29
  views: {
24
30
  list: {
@@ -54,11 +60,12 @@ export function metricsCollection(options) {
54
60
  const source = sources.find((source)=>source.id === (data.source ?? originalDoc?.source));
55
61
  const capping = data.capping === undefined ? originalDoc?.capping : data.capping;
56
62
  // Payload may submit an empty optional group as { type: null, value: null }.
57
- const hasCapping = capping != null && (capping.type != null || capping.value != null);
58
- if (source?.kind === 'revenue' && !hasCapping) data.capping = {
59
- type: 'percentile',
60
- value: 0.99
61
- };
63
+ if (source?.kind === 'revenue' && capping?.type == null && capping?.value == null) {
64
+ data.capping = {
65
+ type: 'percentile',
66
+ value: 0.99
67
+ };
68
+ }
62
69
  return data;
63
70
  }
64
71
  ]
@@ -1,3 +1,4 @@
1
+ import { assertReadCommitted } from '../db/adapter.js';
1
2
  import { pooledExecutor, txExecutor } from '../db/executor.js';
2
3
  import { findMetricUsage, lockMetricRow } from '../db/metricUsage.js';
3
4
  /** Payload's REST formatter preserves public plugin errors and their 4xx status. */ export class XpGoalInUseError extends Error {
@@ -8,6 +9,7 @@ import { findMetricUsage, lockMetricRow } from '../db/metricUsage.js';
8
9
  async function executor(req, id, mode) {
9
10
  const transactionID = await req.transactionID;
10
11
  if (transactionID != null) {
12
+ await assertReadCommitted(req);
11
13
  const exec = txExecutor(req);
12
14
  await lockMetricRow(exec, id, mode);
13
15
  return exec;
@@ -1,3 +1,5 @@
1
+ import { browserWritableMetric } from '../events/writable.js';
2
+ import { goalSourceLabel } from '../goals/sourceLabel.js';
1
3
  export function serializeFlagPoints(options) {
2
4
  return (options.flagPoints ?? []).map(({ id, label, description, params, defaultParams })=>({
3
5
  id,
@@ -19,19 +21,19 @@ export function serializeMetricSources(options) {
19
21
  keyedBy: 'visitor',
20
22
  clientWritable: true
21
23
  },
22
- ...(options.metricSources ?? []).map(({ id, label, kind, keyedBy, clientWritable })=>({
24
+ ...(options.metricSources ?? []).map(({ id, label, kind, keyedBy })=>({
23
25
  id,
24
- label,
26
+ label: label?.trim() || goalSourceLabel(id),
25
27
  kind,
26
28
  keyedBy,
27
- clientWritable: clientWritable === true
29
+ clientWritable: browserWritableMetric(id, options)
28
30
  })),
29
- ...(options.eventSources ?? []).map(({ name, clientWritable })=>({
31
+ ...(options.eventSources ?? []).map(({ name })=>({
30
32
  id: `events:${name}`,
31
- label: name,
33
+ label: goalSourceLabel(name),
32
34
  kind: 'binomial',
33
35
  keyedBy: 'visitor',
34
- clientWritable
36
+ clientWritable: browserWritableMetric(`events:${name}`, options)
35
37
  }))
36
38
  ];
37
39
  }
@@ -7,3 +7,4 @@ export declare const XP_PREVIEW_PARAM = "xp_preview";
7
7
  export declare const XP_MANIFEST_KEY_HEADER = "x-xp-manifest-key";
8
8
  export declare const XP_REQUEST_HEADER = "x-xp-request";
9
9
  export declare const XP_IF_UPDATED_AT_HEADER = "x-xp-if-updated-at";
10
+ export declare const USER_BROWSER_CONVERSION_PREFIX = "conversion:cu:";
package/dist/constants.js CHANGED
@@ -7,3 +7,4 @@ export const XP_PREVIEW_PARAM = 'xp_preview';
7
7
  export const XP_MANIFEST_KEY_HEADER = 'x-xp-manifest-key';
8
8
  export const XP_REQUEST_HEADER = 'x-xp-request';
9
9
  export const XP_IF_UPDATED_AT_HEADER = 'x-xp-if-updated-at';
10
+ export const USER_BROWSER_CONVERSION_PREFIX = 'conversion:cu:';
@@ -1,3 +1,11 @@
1
- import type { Payload } from 'payload';
1
+ import { APIError, type Payload, type PayloadRequest } from 'payload';
2
+ export declare class XpTransactionIsolationError extends APIError {
3
+ constructor();
4
+ }
5
+ /** Payload's initTransaction cannot pass options to the adapter. Like that
6
+ * helper, publish the pending transaction on the request before awaiting it.
7
+ */
8
+ export declare function initTransitionTransaction(req: PayloadRequest): Promise<boolean>;
9
+ export declare function assertReadCommitted(req: PayloadRequest): Promise<void>;
2
10
  export declare function assertPostgresAdapter(payload: Payload): void;
3
11
  export declare function probeTransactions(payload: Payload): Promise<void>;