@delmaredigital/payload-experiments 0.4.0 → 0.5.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 (290) hide show
  1. package/README.md +10 -4
  2. package/dist/admin/blocks/model.js +2 -0
  3. package/dist/admin/copy/blocks.d.ts +1 -0
  4. package/dist/admin/copy/blocks.js +1 -0
  5. package/dist/admin/copy/status.d.ts +3 -0
  6. package/dist/admin/copy/status.js +3 -0
  7. package/dist/admin/placementStatus.model.js +3 -0
  8. package/dist/admin/status.model.d.ts +3 -2
  9. package/dist/admin/status.model.js +9 -3
  10. package/dist/admin/surface/ResultsRoute.js +2 -1
  11. package/dist/admin/surface/TestsHome.d.ts +2 -1
  12. package/dist/admin/surface/TestsHome.js +31 -11
  13. package/dist/admin/surface/TestsSurface.js +4 -0
  14. package/dist/admin/surface/home.model.d.ts +11 -6
  15. package/dist/admin/surface/home.model.js +19 -8
  16. package/dist/admin/surface/newTest/PageWizard.js +13 -3
  17. package/dist/admin/surface/results/ResultsHeader.js +43 -9
  18. package/dist/admin/surface/test/TestPage.js +11 -1
  19. package/dist/admin/useLayerUsage.d.ts +1 -1
  20. package/dist/admin/views/buildSurfaceProps.js +3 -0
  21. package/dist/cohorts/build.d.ts +35 -0
  22. package/dist/cohorts/build.js +134 -0
  23. package/dist/cohorts/key.d.ts +12 -0
  24. package/dist/cohorts/key.js +15 -0
  25. package/dist/cohorts/maintenance.d.ts +10 -0
  26. package/dist/cohorts/maintenance.js +70 -0
  27. package/dist/cohorts/readiness.d.ts +30 -0
  28. package/dist/cohorts/readiness.js +54 -0
  29. package/dist/cohorts/readinessData.d.ts +29 -0
  30. package/dist/cohorts/readinessData.js +123 -0
  31. package/dist/cohorts/rule.d.ts +33 -0
  32. package/dist/cohorts/rule.js +50 -0
  33. package/dist/collections/cohortMembers.d.ts +4 -0
  34. package/dist/collections/cohortMembers.js +95 -0
  35. package/dist/collections/experiments/config.js +157 -7
  36. package/dist/collections/experiments/editability.js +10 -6
  37. package/dist/collections/experiments/lockHook.js +39 -20
  38. package/dist/collections/index.js +4 -1
  39. package/dist/collections/phases.js +4 -1
  40. package/dist/constants.d.ts +2 -0
  41. package/dist/constants.js +2 -0
  42. package/dist/db/adapter.d.ts +1 -1
  43. package/dist/db/adapter.js +14 -4
  44. package/dist/db/appends.js +1 -1
  45. package/dist/db/cohortMembership.d.ts +11 -0
  46. package/dist/db/cohortMembership.js +31 -0
  47. package/dist/db/cohortPool.d.ts +9 -0
  48. package/dist/db/cohortPool.js +53 -0
  49. package/dist/db/cohortTransactions.d.ts +3 -0
  50. package/dist/db/cohortTransactions.js +52 -0
  51. package/dist/db/cohorts.d.ts +72 -0
  52. package/dist/db/cohorts.js +280 -0
  53. package/dist/db/erase.d.ts +2 -0
  54. package/dist/db/erase.js +21 -2
  55. package/dist/db/events.d.ts +2 -0
  56. package/dist/db/events.js +8 -0
  57. package/dist/db/executor.d.ts +2 -0
  58. package/dist/db/executor.js +8 -0
  59. package/dist/db/locks.d.ts +7 -0
  60. package/dist/db/locks.js +13 -1
  61. package/dist/db/names.d.ts +95 -1
  62. package/dist/db/names.js +95 -1
  63. package/dist/db/occupancy.d.ts +21 -0
  64. package/dist/db/occupancy.js +46 -0
  65. package/dist/db/pageOccupancy.d.ts +4 -4
  66. package/dist/db/pageOccupancy.js +13 -10
  67. package/dist/db/pgExecutor.d.ts +4 -0
  68. package/dist/db/pgExecutor.js +1 -1
  69. package/dist/db/placements.js +1 -1
  70. package/dist/db/results.d.ts +5 -2
  71. package/dist/db/results.js +32 -5
  72. package/dist/db/slices.d.ts +9 -2
  73. package/dist/db/slices.js +15 -8
  74. package/dist/db/snapshots.d.ts +16 -1
  75. package/dist/db/snapshots.js +27 -2
  76. package/dist/db/sql.d.ts +2 -2
  77. package/dist/db/sql.js +1 -2
  78. package/dist/endpoints/cohortSources.d.ts +16 -0
  79. package/dist/endpoints/cohortSources.js +335 -0
  80. package/dist/endpoints/contentLocale.d.ts +1 -1
  81. package/dist/endpoints/events.js +82 -18
  82. package/dist/endpoints/index.js +45 -1
  83. package/dist/endpoints/pausedBy.d.ts +14 -0
  84. package/dist/endpoints/pausedBy.js +94 -0
  85. package/dist/endpoints/preflight.js +4 -1
  86. package/dist/endpoints/previewToken.js +2 -0
  87. package/dist/endpoints/results.d.ts +2 -2
  88. package/dist/endpoints/results.js +111 -3
  89. package/dist/endpoints/routeId.d.ts +2 -1
  90. package/dist/endpoints/routeId.js +6 -2
  91. package/dist/endpoints/summary.js +24 -1
  92. package/dist/endpoints/transitions.d.ts +7 -0
  93. package/dist/endpoints/transitions.js +50 -1
  94. package/dist/events/rows.d.ts +1 -1
  95. package/dist/events/rows.js +5 -3
  96. package/dist/exports/index.d.ts +2 -0
  97. package/dist/exports/index.js +1 -0
  98. package/dist/exports/runtimeProxy.d.ts +1 -0
  99. package/dist/exports/runtimeProxy.js +1 -0
  100. package/dist/hooks/blockRemovalRule.js +7 -4
  101. package/dist/hooks/pageGuard.js +1 -1
  102. package/dist/labels/status.d.ts +15 -0
  103. package/dist/labels/status.js +12 -0
  104. package/dist/manifest/compile.d.ts +15 -4
  105. package/dist/manifest/compile.js +91 -3
  106. package/dist/onInit.js +4 -1
  107. package/dist/options.d.ts +1 -0
  108. package/dist/options.js +10 -0
  109. package/dist/proxy/consentFallback.d.ts +1 -1
  110. package/dist/proxy/consentFallback.js +4 -4
  111. package/dist/proxy/control.d.ts +1 -1
  112. package/dist/proxy/control.js +2 -2
  113. package/dist/proxy/pageRewrite.d.ts +1 -1
  114. package/dist/proxy/pageRewrite.js +3 -2
  115. package/dist/proxy/resolve.js +76 -17
  116. package/dist/puck/ExperimentPicker.js +2 -1
  117. package/dist/puck/copy.d.ts +6 -5
  118. package/dist/puck/copy.js +3 -7
  119. package/dist/puck/editor/ExperimentSlotEditor.js +16 -5
  120. package/dist/puck/editor/QuickTestActions.js +7 -1
  121. package/dist/puck/editor/armWrites.js +6 -1
  122. package/dist/puck/editor/copy.d.ts +3 -0
  123. package/dist/puck/editor/copy.js +3 -0
  124. package/dist/puck/editor/editor.css +2 -1
  125. package/dist/puck/editor/editor.model.d.ts +2 -1
  126. package/dist/puck/editor/editor.model.js +2 -0
  127. package/dist/puck/editor/placementsCache.d.ts +1 -1
  128. package/dist/puck/editor/placementsCache.js +6 -3
  129. package/dist/results/analyse.d.ts +3 -1
  130. package/dist/results/analyse.js +20 -3
  131. package/dist/results/health.d.ts +11 -0
  132. package/dist/results/health.js +38 -0
  133. package/dist/results/power.d.ts +1 -1
  134. package/dist/results/power.js +1 -1
  135. package/dist/results/snapshot.d.ts +8 -2
  136. package/dist/results/snapshot.js +23 -1
  137. package/dist/results/unitValues.d.ts +48 -0
  138. package/dist/results/unitValues.js +166 -0
  139. package/dist/runtime/assign.d.ts +7 -3
  140. package/dist/runtime/assign.js +12 -4
  141. package/dist/runtime/cohortCookie.d.ts +15 -0
  142. package/dist/runtime/cohortCookie.js +72 -0
  143. package/dist/runtime/cohortLookup.d.ts +9 -0
  144. package/dist/runtime/cohortLookup.js +25 -0
  145. package/dist/runtime/eligibility.d.ts +11 -5
  146. package/dist/runtime/eligibility.js +33 -7
  147. package/dist/runtime/header.d.ts +1 -0
  148. package/dist/runtime/header.js +1 -1
  149. package/dist/runtime/proxyRuntime.js +5 -1
  150. package/dist/runtime/targeting.d.ts +3 -2
  151. package/dist/runtime/targeting.js +2 -1
  152. package/dist/sanitizeReadinessDetail.d.ts +2 -2
  153. package/dist/sanitizeReadinessDetail.js +41 -4
  154. package/dist/schedule/activeTime.d.ts +28 -0
  155. package/dist/schedule/activeTime.js +322 -0
  156. package/dist/schedule/ranges.d.ts +13 -0
  157. package/dist/schedule/ranges.js +11 -0
  158. package/dist/schedule/roundTime.d.ts +10 -0
  159. package/dist/schedule/roundTime.js +45 -0
  160. package/dist/schedule/types.d.ts +29 -0
  161. package/dist/schedule/types.js +1 -0
  162. package/dist/server/cohortLookup.d.ts +3 -0
  163. package/dist/server/cohortLookup.js +7 -0
  164. package/dist/server/eraseUser.d.ts +1 -0
  165. package/dist/server/getAssignments.js +63 -40
  166. package/dist/server/previewDraft.d.ts +1 -1
  167. package/dist/server/previewDraft.js +3 -2
  168. package/dist/server/recordExposures.js +4 -2
  169. package/dist/server/runResults.js +97 -150
  170. package/dist/testSurface/actions/LifecycleAction.d.ts +2 -1
  171. package/dist/testSurface/actions/LifecycleAction.js +15 -5
  172. package/dist/testSurface/actions/actions.model.d.ts +13 -2
  173. package/dist/testSurface/actions/actions.model.js +38 -5
  174. package/dist/testSurface/api.d.ts +13 -1
  175. package/dist/testSurface/api.js +19 -0
  176. package/dist/testSurface/copy/actions.d.ts +13 -0
  177. package/dist/testSurface/copy/actions.js +13 -0
  178. package/dist/testSurface/copy/cohorts.d.ts +68 -0
  179. package/dist/testSurface/copy/cohorts.js +81 -0
  180. package/dist/testSurface/copy/common.d.ts +2 -3
  181. package/dist/testSurface/copy/common.js +4 -4
  182. package/dist/testSurface/copy/inputs.d.ts +3 -0
  183. package/dist/testSurface/copy/inputs.js +3 -0
  184. package/dist/testSurface/copy/readiness.d.ts +20 -6
  185. package/dist/testSurface/copy/readiness.js +42 -9
  186. package/dist/testSurface/copy/results.d.ts +1 -0
  187. package/dist/testSurface/copy/results.js +1 -0
  188. package/dist/testSurface/copy/schedule.d.ts +58 -0
  189. package/dist/testSurface/copy/schedule.js +150 -0
  190. package/dist/testSurface/copy/surface.d.ts +2 -0
  191. package/dist/testSurface/copy/surface.js +2 -0
  192. package/dist/testSurface/copy/testPage.d.ts +12 -2
  193. package/dist/testSurface/copy/testPage.js +17 -2
  194. package/dist/testSurface/format/roundProgress.d.ts +13 -1
  195. package/dist/testSurface/format/roundProgress.js +34 -5
  196. package/dist/testSurface/format/scheduleStatus.d.ts +34 -0
  197. package/dist/testSurface/format/scheduleStatus.js +93 -0
  198. package/dist/testSurface/format/useScheduleClock.d.ts +3 -0
  199. package/dist/testSurface/format/useScheduleClock.js +20 -0
  200. package/dist/testSurface/labels.d.ts +4 -9
  201. package/dist/testSurface/labels.js +2 -7
  202. package/dist/testSurface/lockedNotice.model.d.ts +2 -2
  203. package/dist/testSurface/lockedNotice.model.js +16 -3
  204. package/dist/testSurface/readPreflight.d.ts +3 -0
  205. package/dist/testSurface/readPreflight.js +14 -0
  206. package/dist/testSurface/readinessRead.d.ts +2 -2
  207. package/dist/testSurface/results/DataQualityPanel.js +7 -7
  208. package/dist/testSurface/results/results.model.d.ts +1 -1
  209. package/dist/testSurface/results/results.model.js +34 -6
  210. package/dist/testSurface/review/cohortEstimate.d.ts +11 -0
  211. package/dist/testSurface/review/cohortEstimate.js +32 -0
  212. package/dist/testSurface/surface/contracts.d.ts +2 -1
  213. package/dist/testSurface/surface/contracts.js +1 -0
  214. package/dist/testSurface/surface/editorPlacement.d.ts +1 -0
  215. package/dist/testSurface/surface/readiness/ActionDialogs.d.ts +3 -2
  216. package/dist/testSurface/surface/readiness/ActionDialogs.js +121 -32
  217. package/dist/testSurface/surface/readiness/Banner.js +29 -11
  218. package/dist/testSurface/surface/readiness/readiness.model.d.ts +20 -2
  219. package/dist/testSurface/surface/readiness/readiness.model.js +35 -5
  220. package/dist/testSurface/surface/readiness/useTransition.js +17 -5
  221. package/dist/testSurface/surface/results/ResultsBody.js +46 -10
  222. package/dist/testSurface/surface/results/useResults.d.ts +16 -1
  223. package/dist/testSurface/surface/results/useResults.js +17 -6
  224. package/dist/testSurface/surface/test/CohortRuleEditor.d.ts +16 -0
  225. package/dist/testSurface/surface/test/CohortRuleEditor.js +492 -0
  226. package/dist/testSurface/surface/test/LengthSection.js +26 -6
  227. package/dist/testSurface/surface/test/ScheduleDateInput.d.ts +4 -0
  228. package/dist/testSurface/surface/test/ScheduleDateInput.js +15 -0
  229. package/dist/testSurface/surface/test/ScheduleSection.d.ts +2 -0
  230. package/dist/testSurface/surface/test/ScheduleSection.js +322 -0
  231. package/dist/testSurface/surface/test/Section.js +1 -1
  232. package/dist/testSurface/surface/test/TargetingSection.js +306 -182
  233. package/dist/testSurface/surface/test/TestSurface.js +9 -0
  234. package/dist/testSurface/surface/test/fields.d.ts +2 -1
  235. package/dist/testSurface/surface/test/fields.js +3 -3
  236. package/dist/testSurface/surface/test/jumpToSection.d.ts +1 -1
  237. package/dist/testSurface/surface/test/jumpToSection.js +4 -4
  238. package/dist/testSurface/surface/test/testPage.css +26 -0
  239. package/dist/testSurface/surface/testDocument.model.d.ts +12 -1
  240. package/dist/testSurface/surface/testDocument.model.js +2 -1
  241. package/dist/testSurface/surface/useTestDocument.js +11 -4
  242. package/dist/testSurface/targeting/targeting.model.d.ts +2 -1
  243. package/dist/testSurface/targeting/targeting.model.js +1 -1
  244. package/dist/testSurface/useApi.d.ts +12 -0
  245. package/dist/transitions/addMetric.js +5 -2
  246. package/dist/transitions/allocate.js +6 -1
  247. package/dist/transitions/assertNoOverlap.d.ts +9 -0
  248. package/dist/transitions/assertNoOverlap.js +24 -0
  249. package/dist/transitions/buildCohorts.d.ts +10 -0
  250. package/dist/transitions/buildCohorts.js +68 -0
  251. package/dist/transitions/cancelSchedule.d.ts +4 -0
  252. package/dist/transitions/cancelSchedule.js +42 -0
  253. package/dist/transitions/checkStart.d.ts +17 -3
  254. package/dist/transitions/checkStart.js +20 -7
  255. package/dist/transitions/decide.js +35 -11
  256. package/dist/transitions/kernel.d.ts +3 -1
  257. package/dist/transitions/kernel.js +5 -2
  258. package/dist/transitions/pause.d.ts +4 -0
  259. package/dist/transitions/pause.js +35 -0
  260. package/dist/transitions/phaseRecord.d.ts +19 -2
  261. package/dist/transitions/phaseRecord.js +50 -11
  262. package/dist/transitions/placementInteractions.js +1 -1
  263. package/dist/transitions/preflightData.d.ts +11 -3
  264. package/dist/transitions/preflightData.js +134 -81
  265. package/dist/transitions/reschedule.d.ts +4 -0
  266. package/dist/transitions/reschedule.js +58 -0
  267. package/dist/transitions/resume.d.ts +4 -0
  268. package/dist/transitions/resume.js +32 -0
  269. package/dist/transitions/scheduledRound.d.ts +18 -0
  270. package/dist/transitions/scheduledRound.js +42 -0
  271. package/dist/transitions/start.d.ts +4 -0
  272. package/dist/transitions/start.js +136 -55
  273. package/dist/transitions/startReads.d.ts +14 -0
  274. package/dist/transitions/startReads.js +27 -0
  275. package/dist/transitions/stop.d.ts +10 -0
  276. package/dist/transitions/stop.js +35 -22
  277. package/dist/types/admin.d.ts +1 -1
  278. package/dist/types/contracts.d.ts +7 -1
  279. package/dist/types/endpoints.d.ts +72 -3
  280. package/dist/types/manifest.d.ts +9 -0
  281. package/dist/types/runtime.d.ts +5 -0
  282. package/dist/types/snapshot.d.ts +10 -0
  283. package/dist/types/status.d.ts +1 -0
  284. package/dist/types/status.js +1 -0
  285. package/dist/types/surface.d.ts +1 -0
  286. package/dist/ui/Feedback.d.ts +9 -6
  287. package/dist/ui/Feedback.js +10 -9
  288. package/dist/ui/SelectControl.js +1 -1
  289. package/dist/ui/ui.css +2 -1
  290. package/package.json +2 -2
@@ -4,8 +4,9 @@ import { useId, useState } from 'react';
4
4
  import { Button } from '../../ui/Button.js';
5
5
  import { AddMetricAction, AllocateAction, ConfirmAction } from '../surface/readiness/ActionDialogs.js';
6
6
  import { ReleasePagesDialog } from '../surface/results/ReleasePages.js';
7
- import { actionGroupLabel, availableActions } from './actions.model.js';
7
+ import { actionGroupLabel, availableActions, buildAudienceAction } from './actions.model.js';
8
8
  import { DecideDialog } from './DecideDialog.js';
9
+ import { useScheduleClock } from '../format/useScheduleClock.js';
9
10
  export function LifecycleButton({ action, reason, showReason = true, disabled, ariaDisabled, busy, onClick }) {
10
11
  const id = useId();
11
12
  const help = showReason ? reason ?? action.hint : action.hint;
@@ -34,9 +35,12 @@ export function LifecycleButton({ action, reason, showReason = true, disabled, a
34
35
  ]
35
36
  });
36
37
  }
37
- export function LifecycleDialog({ action, test, surface, onClose }) {
38
+ export function LifecycleDialog({ action, test, surface, onClose, onSuccess }) {
38
39
  const [opened] = useState(test.doc);
39
40
  const doc = test.doc ?? opened;
41
+ const now = useScheduleClock([
42
+ doc
43
+ ], surface.timeZone);
40
44
  const decision = doc.decision;
41
45
  const winner = actionGroupLabel(decision?.winnerArm ?? 'control', doc.arms.find((arm)=>arm.key === decision?.winnerArm)?.label);
42
46
  const props = {
@@ -44,12 +48,15 @@ export function LifecycleDialog({ action, test, surface, onClose }) {
44
48
  surface,
45
49
  onClose
46
50
  };
47
- const changed = !test.doc || doc.phase !== opened.phase || !availableActions({
51
+ const current = action.id === 'build-cohorts' && surface.canManage && (doc.status === 'draft' || doc.status === 'stopped') ? buildAudienceAction : availableActions({
48
52
  ...doc,
49
53
  decision,
54
+ timeZone: surface.timeZone,
55
+ now,
50
56
  canManage: surface.canManage,
51
57
  canReadResults: surface.canReadResults
52
- }).some((item)=>item.id === action.id);
58
+ }).find((item)=>item.id === action.id);
59
+ const changed = !test.doc || doc.phase !== opened.phase || !current || action.id === 'start' && (current.label !== action.label || current.confirm.body !== action.confirm.body);
53
60
  if (action.id === 'decide') return /*#__PURE__*/ _jsx(DecideDialog, {
54
61
  name: opened.name,
55
62
  id: opened.id,
@@ -102,6 +109,9 @@ export function LifecycleDialog({ action, test, surface, onClose }) {
102
109
  return /*#__PURE__*/ _jsx(ConfirmAction, {
103
110
  ...props,
104
111
  action: action,
105
- winnerLabel: winner
112
+ winnerLabel: winner,
113
+ now: now,
114
+ unavailable: changed,
115
+ onSuccess: onSuccess
106
116
  });
107
117
  }
@@ -1,6 +1,7 @@
1
1
  import type { ExperimentKind, Status } from '../../types/contracts.js';
2
2
  import type { ArchiveBody, ContentReport } from '../../types/endpoints.js';
3
3
  import { type PageReleaseDecision } from '../results/releasePages.model.js';
4
+ import type { ScheduleWindow } from '../../schedule/types.js';
4
5
  export type ActionGroup = {
5
6
  key: string;
6
7
  label?: string;
@@ -11,7 +12,7 @@ export type ActionDecision = PageReleaseDecision & {
11
12
  holdoutReleasedAt?: string | null;
12
13
  contentReport?: ContentReport | null;
13
14
  };
14
- export type ActionId = 'start' | 'stop' | 'decide' | 'release-holdout' | 'make-content' | 'after-content' | 'archive' | 'discard' | 'hard-coded' | 'allocate' | 'add-metric' | 'delete' | 'release-pages';
15
+ export type ActionId = 'build-cohorts' | 'start' | 'stop' | 'pause' | 'resume' | 'reschedule' | 'cancel-schedule' | 'decide' | 'release-holdout' | 'make-content' | 'after-content' | 'archive' | 'discard' | 'hard-coded' | 'allocate' | 'add-metric' | 'delete' | 'release-pages';
15
16
  export declare function isDestructiveAction(id: ActionId): boolean;
16
17
  export type ExperimentAction = {
17
18
  id: ActionId;
@@ -29,15 +30,25 @@ export type ExperimentAction = {
29
30
  hint?: string;
30
31
  unavailable?: string;
31
32
  };
33
+ export declare const buildAudienceAction: ExperimentAction;
32
34
  export declare function actionGroupLabel(key: string, storedLabel?: string): string;
33
35
  export declare function canDeleteTest(status: string): status is "draft" | "archived";
34
- export declare function availableActions({ name, status, kind, arms, allocation, decision, canManage, canReadResults }: {
36
+ export declare function availableActions({ name, status, kind, arms, allocation, decision, startedAt, schedule, timeZone, now, canManage, canReadResults }: {
35
37
  name?: string;
36
38
  status: Status;
37
39
  kind: ExperimentKind;
38
40
  arms?: readonly ActionGroup[] | null;
39
41
  allocation?: number;
40
42
  decision?: ActionDecision | null;
43
+ startedAt?: string | null;
44
+ schedule?: {
45
+ startAt?: string | null;
46
+ endAt?: string | null;
47
+ timeZone?: string | null;
48
+ windows?: ScheduleWindow[] | null;
49
+ } | null;
50
+ now?: number;
41
51
  canManage: boolean;
42
52
  canReadResults?: boolean;
53
+ timeZone?: string;
43
54
  }): ExperimentAction[];
@@ -1,13 +1,17 @@
1
1
  import { contentDone } from '../../contentDone.js';
2
- import { armLabel } from '../labels.js';
3
- import { ACTIONS_COPY as C, actionTitle, archiveCopy, discardCopy, hardCodedLabel, makeContentCopy, releaseCopy, stopCopy } from '../copy/actions.js';
2
+ import { armLabel, displayStatus } from '../labels.js';
3
+ import { ACTIONS_COPY as C, actionTitle, archiveCopy, discardCopy, hardCodedLabel, makeContentCopy, releaseCopy, scheduleStartCopy, stopCopy } from '../copy/actions.js';
4
4
  import { REVIEW_COPY } from '../copy/review.js';
5
5
  import { READINESS_COPY } from '../copy/readiness.js';
6
6
  import { DELETE_TEST } from '../copy/testPage.js';
7
7
  import { RESULTS_COPY } from '../copy/results.js';
8
8
  import { canReleasePages } from '../results/releasePages.model.js';
9
+ import { isValidTimeZone } from '../../schedule/activeTime.js';
10
+ import { COHORT_COPY, COHORT_EDITOR } from '../copy/cohorts.js';
11
+ import { scheduleDate } from '../copy/schedule.js';
9
12
  const destructiveActions = new Set([
10
13
  'stop',
14
+ 'cancel-schedule',
11
15
  'decide',
12
16
  'release-holdout',
13
17
  'make-content',
@@ -22,17 +26,26 @@ const destructiveActions = new Set([
22
26
  export function isDestructiveAction(id) {
23
27
  return destructiveActions.has(id);
24
28
  }
29
+ export const buildAudienceAction = {
30
+ id: 'build-cohorts',
31
+ label: COHORT_EDITOR.build,
32
+ tone: 'secondary',
33
+ confirm: {
34
+ title: COHORT_EDITOR.build,
35
+ body: COHORT_COPY.timeout
36
+ }
37
+ };
25
38
  export function actionGroupLabel(key, storedLabel) {
26
39
  return storedLabel?.trim() || armLabel(key);
27
40
  }
28
41
  export function canDeleteTest(status) {
29
42
  return status === 'draft' || status === 'archived';
30
43
  }
31
- export function availableActions({ name, status, kind, arms = [], allocation, decision, canManage, canReadResults = canManage }) {
44
+ export function availableActions({ name, status, kind, arms = [], allocation, decision, startedAt, schedule, timeZone, now = Date.now(), canManage, canReadResults = canManage }) {
32
45
  if (!canManage) return [];
33
46
  const action = (id, label, body, tone = 'secondary', archive, phrase)=>{
34
47
  const confirmLabel = id === 'hard-coded' ? C.confirmPermanentWinner : label;
35
- const titleKey = id === 'start' && status === 'stopped' ? 'restart' : id;
48
+ const titleKey = id === 'start' && label === C.restart ? 'restart' : id;
36
49
  const titleLead = Object.hasOwn(C.titleLead, titleKey) ? C.titleLead[titleKey] : confirmLabel;
37
50
  return {
38
51
  id,
@@ -53,7 +66,9 @@ export function availableActions({ name, status, kind, arms = [], allocation, de
53
66
  } : {}
54
67
  };
55
68
  };
56
- const start = action('start', status === 'stopped' ? C.restart : C.start, status === 'stopped' ? C.restartBody : C.startBody, 'primary');
69
+ const scheduledStart = Date.parse(schedule?.startAt ?? '');
70
+ const zone = schedule?.timeZone || timeZone;
71
+ const start = scheduledStart > now ? action('start', C.schedule, scheduleStartCopy(scheduleDate(new Date(scheduledStart), zone && isValidTimeZone(zone) ? zone : 'UTC', 'day', new Date(now)), Boolean(schedule?.windows?.length)), 'primary') : action('start', status === 'stopped' ? C.restart : C.start, status === 'stopped' ? C.restartBody : C.startBody, 'primary');
57
72
  const control = actionGroupLabel('control', arms?.find((group)=>group.kind === 'control' || group.key === 'control')?.label);
58
73
  const decide = canReadResults ? [
59
74
  action('decide', C.decide, C.decideBody, 'primary')
@@ -72,13 +87,31 @@ export function availableActions({ name, status, kind, arms = [], allocation, de
72
87
  ] : [],
73
88
  remove
74
89
  ];
90
+ if (displayStatus({
91
+ status,
92
+ startedAt
93
+ }, now) === 'scheduled') return [
94
+ action('cancel-schedule', C.cancelSchedule, C.cancelScheduleBody, 'danger')
95
+ ];
96
+ const reschedule = schedule?.startAt || schedule?.endAt || schedule?.windows?.length ? [
97
+ action('reschedule', C.reschedule, C.rescheduleBody)
98
+ ] : [];
99
+ if (status === 'paused') return [
100
+ action('resume', C.resume, C.resumeBody, 'primary'),
101
+ ...decide,
102
+ action('add-metric', READINESS_COPY.addGoal, ''),
103
+ ...reschedule,
104
+ action('stop', C.stop, stopCopy(control), 'danger')
105
+ ];
75
106
  if (status === 'running') return [
76
107
  ...decide,
108
+ action('pause', C.pause, C.pauseBody),
77
109
  action('add-metric', READINESS_COPY.addGoal, ''),
78
110
  {
79
111
  ...action('allocate', READINESS_COPY.allocate, REVIEW_COPY.allocationBody),
80
112
  unavailable: allocation !== undefined && allocation >= 100 ? READINESS_COPY.everyone : undefined
81
113
  },
114
+ ...reschedule,
82
115
  action('stop', C.stop, stopCopy(control), 'danger')
83
116
  ];
84
117
  if (status === 'stopped') return [
@@ -1,5 +1,5 @@
1
1
  import type { DocId } from '../types/contracts.js';
2
- import type { CopyPagePlan, CopyPageResult, DeleteImpactResult, WrapBlockBody, PagesResult, PlacementStatusBody, PlacementStatusResult, RestoreContentEntryBody, RestoreContentEntryResult, DismissContentEntryBody, DismissContentEntryResult, AddMetricBody, AllocateBody, ArchiveBody, DecideBody, MakeContentResult, AddMetricResult, ClickKeysResult, PreflightResult, PreviewTokenResult, RefusalCode, ResultsResponse, SummaryResponse, TransitionSuccess } from '../types/endpoints.js';
2
+ import type { CohortSourcesResult, CopyPagePlan, CopyPageResult, DeleteImpactResult, WrapBlockBody, PagesResult, PlacementStatusBody, PlacementStatusResult, RestoreContentEntryBody, RestoreContentEntryResult, DismissContentEntryBody, DismissContentEntryResult, AddMetricBody, AllocateBody, ArchiveBody, DecideBody, MakeContentResult, AddMetricResult, ClickKeysResult, PauseAttribution, PauseBody, PreflightResult, PreviewTokenResult, RefusalCode, RescheduleBody, ResultsResponse, SummaryResponse, TransitionSuccess } from '../types/endpoints.js';
3
3
  import { refusalMessage } from './copy/common.js';
4
4
  export type ApiResult<T> = {
5
5
  ok: true;
@@ -30,6 +30,13 @@ export declare function createApi(apiBase: string, contentLocale?: string): {
30
30
  page?: number;
31
31
  mode?: "block";
32
32
  }, signal?: AbortSignal) => Promise<ApiResult<PagesResult>>;
33
+ cohortSources: (q: string, exclude: DocId, signal?: AbortSignal) => Promise<ApiResult<CohortSourcesResult>>;
34
+ buildCohorts: (id: DocId) => Promise<ApiResult<{
35
+ cohorts: Array<{
36
+ key: string;
37
+ members: number;
38
+ }>;
39
+ }>>;
33
40
  previewPageCopy: (id: DocId, arm: string, signal?: AbortSignal) => Promise<ApiResult<CopyPagePlan>>;
34
41
  makePageCopy: (id: DocId, arm: string, plan: CopyPagePlan) => Promise<ApiResult<CopyPageResult>>;
35
42
  placementStatus: (body: PlacementStatusBody) => Promise<ApiResult<PlacementStatusResult>>;
@@ -37,6 +44,10 @@ export declare function createApi(apiBase: string, contentLocale?: string): {
37
44
  allocate: (id: DocId, body: AllocateBody, options?: RequestOptions) => Promise<ApiResult<TransitionSuccess>>;
38
45
  addMetric: (id: DocId, body: AddMetricBody, options?: RequestOptions) => Promise<ApiResult<AddMetricResult>>;
39
46
  stop: (id: DocId, phase?: number) => Promise<ApiResult<TransitionSuccess>>;
47
+ pause: (id: DocId, body: PauseBody) => Promise<ApiResult<TransitionSuccess>>;
48
+ resume: (id: DocId, phase?: number) => Promise<ApiResult<TransitionSuccess>>;
49
+ reschedule: (id: DocId, body: RescheduleBody) => Promise<ApiResult<TransitionSuccess>>;
50
+ cancelSchedule: (id: DocId, phase?: number) => Promise<ApiResult<TransitionSuccess>>;
40
51
  decide: (id: DocId, body: DecideBody) => Promise<ApiResult<TransitionSuccess>>;
41
52
  releaseHoldout: (id: DocId, phase?: number) => Promise<ApiResult<TransitionSuccess>>;
42
53
  releasePages: (id: DocId, phase?: number) => Promise<ApiResult<TransitionSuccess>>;
@@ -55,6 +66,7 @@ export declare function createApi(apiBase: string, contentLocale?: string): {
55
66
  recompute: (id: DocId) => Promise<ApiResult<{
56
67
  snapshotId: string;
57
68
  }>>;
69
+ pausedBy: (signal: AbortSignal) => Promise<ApiResult<Record<string, PauseAttribution>>>;
58
70
  summary: (ids: readonly DocId[]) => Promise<ApiResult<SummaryResponse>>;
59
71
  };
60
72
  export {};
@@ -1,6 +1,7 @@
1
1
  import { XP_IF_UPDATED_AT_HEADER } from '../constants.js';
2
2
  import { contentLocaleURL } from './contentLocaleURL.js';
3
3
  import { API_MESSAGES, refusalMessage } from './copy/common.js';
4
+ import { COHORT_REFUSALS } from './copy/cohorts.js';
4
5
  import { CONTENT_ENTRY_REFUSALS } from './copy/actions.js';
5
6
  export function createApi(apiBase, contentLocale) {
6
7
  const collectionBase = `${apiBase.replace(/\/$/, '')}/xp-experiments`;
@@ -106,6 +107,13 @@ export function createApi(apiBase, contentLocale) {
106
107
  if (contentLocale) params.set('locale', contentLocale);
107
108
  return `${apiBase.replace(/\/$/, '')}/xp/pages?${params}`;
108
109
  }, 'GET', undefined, undefined, signal),
110
+ cohortSources: (q, exclude, signal)=>request(()=>`${apiBase.replace(/\/$/, '')}/xp/cohort-sources?${new URLSearchParams({
111
+ q,
112
+ exclude: String(exclude)
113
+ })}`, 'GET', undefined, undefined, signal),
114
+ buildCohorts: (id)=>post(id, 'build-cohorts', {}, {
115
+ codes: COHORT_REFUSALS
116
+ }),
109
117
  previewPageCopy: (id, arm, signal)=>request(()=>`${route(id, 'duplicate-original')}?arm=${encodeURIComponent(arm)}`, 'GET', undefined, undefined, signal),
110
118
  makePageCopy: (id, arm, plan)=>request(()=>route(id, 'duplicate-original'), 'POST', {
111
119
  ...plan,
@@ -114,12 +122,22 @@ export function createApi(apiBase, contentLocale) {
114
122
  placementStatus: (body)=>request(()=>`${apiBase.replace(/\/$/, '')}/xp/placements/status`, 'POST', body),
115
123
  start: (id, phase)=>post(id, 'start', phase === undefined ? undefined : {
116
124
  phase
125
+ }, {
126
+ codes: COHORT_REFUSALS
117
127
  }),
118
128
  allocate: (id, body, options)=>post(id, 'allocate', body, options),
119
129
  addMetric: (id, body, options)=>post(id, 'add-metric', body, options),
120
130
  stop: (id, phase)=>post(id, 'stop', phase === undefined ? undefined : {
121
131
  phase
122
132
  }),
133
+ pause: (id, body)=>post(id, 'pause', body),
134
+ resume: (id, phase)=>post(id, 'resume', {
135
+ phase
136
+ }),
137
+ reschedule: (id, body)=>post(id, 'reschedule', body),
138
+ cancelSchedule: (id, phase)=>post(id, 'cancel-schedule', {
139
+ phase
140
+ }),
123
141
  decide: (id, body)=>post(id, 'decide', body),
124
142
  releaseHoldout: (id, phase)=>post(id, 'release-holdout', phase === undefined ? undefined : {
125
143
  phase
@@ -150,6 +168,7 @@ export function createApi(apiBase, contentLocale) {
150
168
  return `${route(id, 'results')}${qs ? `?${qs}` : ''}`;
151
169
  }, 'GET', undefined, options),
152
170
  recompute: (id)=>post(id, 'recompute'),
171
+ pausedBy: (signal)=>request(()=>`${base}/paused-by`, 'GET', undefined, undefined, signal),
153
172
  summary: async (ids)=>{
154
173
  const data = {};
155
174
  // Wire format: comma-separated ids, each URI-encoded; at most 100 per request.
@@ -5,6 +5,18 @@ export declare const ACTIONS_COPY: {
5
5
  readonly restart: "Start a new round";
6
6
  readonly stop: "Stop";
7
7
  readonly decide: "Decide";
8
+ readonly schedule: "Schedule";
9
+ readonly pause: "Pause";
10
+ readonly resume: "Resume";
11
+ readonly reschedule: "Change end date";
12
+ readonly cancelSchedule: "Cancel schedule";
13
+ readonly pauseReason: "Reason for pausing (optional)";
14
+ readonly pauseCount: (count: number, limit: number) => string;
15
+ readonly pauseBody: "Everyone will see the Original until you resume. Results keep counting from where they stopped.";
16
+ readonly resumeBody: "Visitors in this test will see their version again.";
17
+ readonly resumeEndedBody: "The scheduled end has passed. Confirming will stop this round and keep its results.";
18
+ readonly rescheduleBody: "Set a new end date and time, or leave it blank to run without an end date.";
19
+ readonly cancelScheduleBody: "The scheduled round will be removed. Any earlier results will be kept.";
8
20
  readonly release: "Release holdout";
9
21
  readonly makeContent: "Make it the content";
10
22
  readonly finish: "Finish archiving";
@@ -72,6 +84,7 @@ export declare const ACTIONS_COPY: {
72
84
  readonly partial: "Some pages still need changes.";
73
85
  };
74
86
  export declare const actionTitle: (action: string, test: string) => string;
87
+ export declare const scheduleStartCopy: (date: string, recurring?: boolean) => string;
75
88
  export declare const actionTitleFor: (action: string, test: string) => string;
76
89
  export declare const actionsForTest: (test: string) => string;
77
90
  export declare const stopCopy: (control: string) => string;
@@ -5,6 +5,18 @@ export const ACTIONS_COPY = {
5
5
  restart: 'Start a new round',
6
6
  stop: 'Stop',
7
7
  decide: 'Decide',
8
+ schedule: 'Schedule',
9
+ pause: 'Pause',
10
+ resume: 'Resume',
11
+ reschedule: 'Change end date',
12
+ cancelSchedule: 'Cancel schedule',
13
+ pauseReason: 'Reason for pausing (optional)',
14
+ pauseCount: (count, limit)=>`${count} of ${limit} characters`,
15
+ pauseBody: 'Everyone will see the Original until you resume. Results keep counting from where they stopped.',
16
+ resumeBody: 'Visitors in this test will see their version again.',
17
+ resumeEndedBody: 'The scheduled end has passed. Confirming will stop this round and keep its results.',
18
+ rescheduleBody: 'Set a new end date and time, or leave it blank to run without an end date.',
19
+ cancelScheduleBody: 'The scheduled round will be removed. Any earlier results will be kept.',
8
20
  release: 'Release holdout',
9
21
  makeContent: 'Make it the content',
10
22
  finish: 'Finish archiving',
@@ -72,6 +84,7 @@ export const ACTIONS_COPY = {
72
84
  partial: "Some pages still need changes."
73
85
  };
74
86
  export const actionTitle = (action, test)=>`${action} “${test}”?`;
87
+ export const scheduleStartCopy = (date, recurring = false)=>recurring ? `The schedule starts on ${date}. Visitors will see test versions during your recurring hours.` : `Visitors will start seeing test versions on ${date}.`;
75
88
  export const actionTitleFor = (action, test)=>`${action} for “${test}”?`;
76
89
  export const actionsForTest = (test)=>`Actions for ${test}`;
77
90
  export const stopCopy = (control)=>`Visitors will go back to ${control}. The test stops collecting data and keeps its results. Starting again begins a new round.`;
@@ -0,0 +1,68 @@
1
+ import type { ArmKey } from '../../types/contracts.js';
2
+ import type { CohortRule } from '../../cohorts/rule.js';
3
+ export declare const COHORT_COPY: {
4
+ readonly invalid: "Check the earlier test, round, versions and goal for this audience.";
5
+ readonly cycle: "An earlier test in this audience also depends on this test.";
6
+ readonly open: "To use people who didn't complete a goal, wait until 24 hours after the earlier round ends.";
7
+ readonly lookup: "Ask your developer to enable audiences from earlier tests.";
8
+ readonly noExposures: "No one has seen this test in its first hour. If your site's proxy doesn't look up audiences from earlier tests, every visitor sees the Original: check that `lookupCohorts` is set in the proxy runtime.";
9
+ readonly timeout: "This audience needs more time. Build the audience, then start the test.";
10
+ readonly source: "Choose an earlier test.";
11
+ readonly self: "Choose a different test.";
12
+ readonly arms: "Choose at least one version.";
13
+ readonly goal: "Choose whether people completed the goal.";
14
+ readonly round: "Enter a positive whole round number.";
15
+ readonly unavailable: "Audience from an earlier test";
16
+ };
17
+ export declare function cohortRuleSummary(rule: CohortRule, names?: {
18
+ experiment?: string;
19
+ arms?: Partial<Record<ArmKey, string>>;
20
+ goal?: string;
21
+ }): string;
22
+ export declare const COHORT_EDITOR: {
23
+ readonly add: "Add people from an earlier test";
24
+ readonly test: "Test";
25
+ readonly search: "Search earlier tests";
26
+ readonly invalidSearch: "Enter a valid search or test ID.";
27
+ readonly noAttributes: "No visitor attributes are available for rules.";
28
+ readonly loading: "Loading tests…";
29
+ readonly empty: "No earlier tests are available.";
30
+ readonly noMatches: "No earlier tests match your search.";
31
+ readonly searchError: "Couldn't load earlier tests.";
32
+ readonly round: "Round";
33
+ readonly chooseTestFirst: "Choose a test first";
34
+ readonly draftLabel: "Earlier-test audience";
35
+ readonly versions: "Versions";
36
+ readonly outcome: "Outcome";
37
+ readonly any: "Any outcome";
38
+ readonly completed: "Completed it";
39
+ readonly notCompleted: "Didn't complete it";
40
+ readonly participation: "Include or exclude";
41
+ readonly include: "Only these people";
42
+ readonly exclude: "Everyone except these people";
43
+ readonly noEstimate: "Size shows after the first results run.";
44
+ readonly tooSmall: "This audience may be too small to reach a reliable answer.";
45
+ readonly build: "Build the audience";
46
+ readonly progress: "Building the audience… this can take up to a minute";
47
+ readonly whoTookPart: "Who took part";
48
+ readonly singularExit: "1 person left this audience after they first saw the test. They stay in the results, and saw the Original afterwards.";
49
+ };
50
+ export declare const cohortRoundCount: (count: number) => string;
51
+ export declare const latestCohortRound: (round: number | null) => string;
52
+ /** Dates read in the site's time zone (the schedule default), else the browser's. */
53
+ export declare function cohortRoundLabel({ phase, startedAt, endedAt }: {
54
+ phase: number;
55
+ startedAt: string;
56
+ endedAt: string | null;
57
+ }, timeZone?: string): string;
58
+ export declare const cohortGrowth: (name: string) => string;
59
+ export declare const cohortSizeLabel: (size: number, include: boolean) => string;
60
+ export declare const cohortReviewLabel: (size: number) => string;
61
+ export declare const cohortExitsLabel: (size: number) => string;
62
+ export declare const COHORT_REFUSALS: {
63
+ readonly 'cohort-source-invalid': "Check the earlier test, round, versions and goal for this audience.";
64
+ readonly 'cohort-cycle': "An earlier test in this audience also depends on this test.";
65
+ readonly 'cohort-source-open': "To use people who didn't complete a goal, wait until 24 hours after the earlier round ends.";
66
+ readonly 'cohort-lookup-missing': "Ask your developer to enable audiences from earlier tests.";
67
+ readonly 'cohort-build-timeout': "This audience needs more time. Build the audience, then start the test.";
68
+ };
@@ -0,0 +1,81 @@
1
+ import { GROUP_LABELS } from './arms.js';
2
+ export const COHORT_COPY = {
3
+ invalid: 'Check the earlier test, round, versions and goal for this audience.',
4
+ cycle: 'An earlier test in this audience also depends on this test.',
5
+ open: "To use people who didn't complete a goal, wait until 24 hours after the earlier round ends.",
6
+ lookup: 'Ask your developer to enable audiences from earlier tests.',
7
+ noExposures: "No one has seen this test in its first hour. If your site's proxy doesn't look up audiences from earlier tests, every visitor sees the Original: check that `lookupCohorts` is set in the proxy runtime.",
8
+ timeout: 'This audience needs more time. Build the audience, then start the test.',
9
+ source: 'Choose an earlier test.',
10
+ self: 'Choose a different test.',
11
+ arms: 'Choose at least one version.',
12
+ goal: 'Choose whether people completed the goal.',
13
+ round: 'Enter a positive whole round number.',
14
+ unavailable: 'Audience from an earlier test'
15
+ };
16
+ const versionList = new Intl.ListFormat('en-US', {
17
+ type: 'disjunction'
18
+ });
19
+ export function cohortRuleSummary(rule, names = {}) {
20
+ const audience = rule.include ? 'People who saw' : 'Excluding people who saw';
21
+ const versions = rule.arms.map((arm)=>names.arms?.[arm] ?? (arm === 'control' ? 'the Original' : GROUP_LABELS[arm]));
22
+ const round = rule.phase === 'latest' ? 'latest round' : `round ${rule.phase}`;
23
+ const goal = rule.goal ? ` and ${rule.goal.completed ? 'completed' : "didn't complete"} ${names.goal ?? 'the selected goal'}` : '';
24
+ return `${audience} ${versionList.format(versions)} in ${names.experiment ?? 'an earlier test'} (${round})${goal}`;
25
+ }
26
+ const audienceCount = new Intl.NumberFormat('en-US', {
27
+ maximumSignificantDigits: 2
28
+ });
29
+ const exitCount = new Intl.NumberFormat('en-US');
30
+ export const COHORT_EDITOR = {
31
+ add: 'Add people from an earlier test',
32
+ test: 'Test',
33
+ search: 'Search earlier tests',
34
+ invalidSearch: 'Enter a valid search or test ID.',
35
+ noAttributes: 'No visitor attributes are available for rules.',
36
+ loading: 'Loading tests…',
37
+ empty: 'No earlier tests are available.',
38
+ noMatches: 'No earlier tests match your search.',
39
+ searchError: "Couldn't load earlier tests.",
40
+ round: 'Round',
41
+ chooseTestFirst: 'Choose a test first',
42
+ draftLabel: 'Earlier-test audience',
43
+ versions: 'Versions',
44
+ outcome: 'Outcome',
45
+ any: 'Any outcome',
46
+ completed: 'Completed it',
47
+ notCompleted: "Didn't complete it",
48
+ participation: 'Include or exclude',
49
+ include: 'Only these people',
50
+ exclude: 'Everyone except these people',
51
+ noEstimate: 'Size shows after the first results run.',
52
+ tooSmall: 'This audience may be too small to reach a reliable answer.',
53
+ build: 'Build the audience',
54
+ progress: 'Building the audience… this can take up to a minute',
55
+ whoTookPart: 'Who took part',
56
+ singularExit: '1 person left this audience after they first saw the test. They stay in the results, and saw the Original afterwards.'
57
+ };
58
+ export const cohortRoundCount = (count)=>count === 1 ? '1 round' : `${count} rounds`;
59
+ export const latestCohortRound = (round)=>round == null ? 'Latest round' : `Latest round (round ${round})`;
60
+ /** Dates read in the site's time zone (the schedule default), else the browser's. */ export function cohortRoundLabel({ phase, startedAt, endedAt }, timeZone) {
61
+ const roundDate = new Intl.DateTimeFormat('en-US', {
62
+ month: 'short',
63
+ day: 'numeric',
64
+ ...timeZone ? {
65
+ timeZone
66
+ } : {}
67
+ });
68
+ const from = roundDate.format(new Date(startedAt));
69
+ return `Round ${phase} · ${from}${endedAt ? `–${roundDate.format(new Date(endedAt))}` : ''}`;
70
+ }
71
+ export const cohortGrowth = (name)=>`This group grows while ${name} runs.`;
72
+ export const cohortSizeLabel = (size, include)=>include ? `About ${audienceCount.format(size)} people` : `Leaves out about ${audienceCount.format(size)} people`;
73
+ export const cohortReviewLabel = (size)=>`Only about ${audienceCount.format(size)} people can take part.`;
74
+ export const cohortExitsLabel = (size)=>size === 1 ? COHORT_EDITOR.singularExit : `${exitCount.format(size)} people left this audience after they first saw the test. They stay in the results, and saw the Original afterwards.`;
75
+ export const COHORT_REFUSALS = {
76
+ 'cohort-source-invalid': COHORT_COPY.invalid,
77
+ 'cohort-cycle': COHORT_COPY.cycle,
78
+ 'cohort-source-open': COHORT_COPY.open,
79
+ 'cohort-lookup-missing': COHORT_COPY.lookup,
80
+ 'cohort-build-timeout': COHORT_COPY.timeout
81
+ };
@@ -19,6 +19,8 @@ export declare const API_MESSAGES: {
19
19
  export declare const LOCKED_MESSAGES: {
20
20
  readonly creation: "Set when the test was created.";
21
21
  readonly running: "Locked while the test is running. Stop the test to change this.";
22
+ readonly paused: "Locked while the test is paused. Stop the test to change this.";
23
+ readonly scheduled: "Cancel the schedule to change this.";
22
24
  readonly runningAllocation: "To include more people, use \"Let more people in\" at the bottom of the page. To include fewer, stop the test; the change applies when you start it again.";
23
25
  readonly runningMetrics: "Use \"Add a goal\" to track another goal. The main goal is fixed for this round.";
24
26
  readonly decided: "Locked after the decision.";
@@ -31,6 +33,3 @@ export declare function refusalMessage(code: string | undefined, status: number,
31
33
  codes?: Readonly<Record<string, string>>;
32
34
  fallback?: string;
33
35
  }, detail?: unknown): string;
34
- export declare const INPUT_COPY: {
35
- readonly selectRequired: "Choose an option.";
36
- };
@@ -1,4 +1,4 @@
1
- import { unpublishedPlacementsCopy } from './readiness.js';
1
+ import { occupancyMessage, unpublishedPlacementsCopy } from './readiness.js';
2
2
  export const API_MESSAGES = {
3
3
  testAlreadyDeleted: 'This test was already deleted. Reload the page.',
4
4
  deleteInvalidStatus: 'Only draft and archived tests can be deleted. Open the test to see how to archive it.',
@@ -20,6 +20,8 @@ export const API_MESSAGES = {
20
20
  export const LOCKED_MESSAGES = {
21
21
  creation: 'Set when the test was created.',
22
22
  running: 'Locked while the test is running. Stop the test to change this.',
23
+ paused: 'Locked while the test is paused. Stop the test to change this.',
24
+ scheduled: 'Cancel the schedule to change this.',
23
25
  runningAllocation: 'To include more people, use "Let more people in" at the bottom of the page. To include fewer, stop the test; the change applies when you start it again.',
24
26
  runningMetrics: 'Use "Add a goal" to track another goal. The main goal is fixed for this round.',
25
27
  decided: 'Locked after the decision.',
@@ -35,9 +37,7 @@ export function refusalMessage(code, status, message, options, detail) {
35
37
  if (code === 'commit-unverified') return API_MESSAGES.commitUnverified;
36
38
  if (code === 'not-implemented' || status === 501) return API_MESSAGES.notImplemented;
37
39
  if (mapped !== undefined) return mapped;
40
+ if (code === 'occupied-in-range') return occupancyMessage(detail) ?? message ?? API_MESSAGES.failed;
38
41
  if (code === 'placement-unpublished') return unpublishedPlacementsCopy(detail);
39
42
  return options?.fallback ?? (message || API_MESSAGES.failed);
40
43
  }
41
- export const INPUT_COPY = {
42
- selectRequired: 'Choose an option.'
43
- };
@@ -0,0 +1,3 @@
1
+ export declare const INPUT_COPY: {
2
+ readonly selectRequired: "Choose an option.";
3
+ };
@@ -0,0 +1,3 @@
1
+ export const INPUT_COPY = {
2
+ selectRequired: 'Choose an option.'
3
+ };
@@ -1,3 +1,4 @@
1
+ import type { OccupiedInRangeDetail } from '../../types/endpoints.js';
1
2
  export declare const PLACEMENT_FAILURE_COPY: {
2
3
  readonly 'placements-failed': "Couldn't check where this test is used. Try again.";
3
4
  readonly forbidden: "You don't have permission to check where this test is used.";
@@ -67,6 +68,19 @@ export declare const READINESS_COPY: {
67
68
  };
68
69
  export declare const unsupportedContentCopy: (page: string) => string;
69
70
  export declare const pageInUseCopy: (path: string, version?: boolean, label?: string) => string;
71
+ export declare function occupiedInRangeCopy(detail: Pick<OccupiedInRangeDetail, 'otherTestName' | 'from' | 'place' | 'timeZone'>, place?: "page" | "setting" | "traffic group"): string;
72
+ export declare function occupancyMessage(value?: unknown): string | undefined;
73
+ export declare const scheduleOccupancyCopy: {
74
+ readonly invalidStart: "Choose a valid start time.";
75
+ readonly pastEnd: "Choose an end time after the test starts.";
76
+ readonly timeZone: "Choose a valid time zone for this schedule.";
77
+ readonly windows: "Choose at least one day for each time window.";
78
+ readonly notLive: "This test has not gone live. You can cancel a scheduled start before it goes live.";
79
+ readonly notPausable: "A rollout cannot be paused.";
80
+ readonly paused: "Resume this test before changing how many people take part.";
81
+ readonly reschedulePast: "Choose an end time in the future and after the test starts.";
82
+ readonly scheduleStarted: "You can only cancel a schedule before the test goes live and before anyone has taken part.";
83
+ };
70
84
  export declare const unpublishedPageCopy: (path: string, context?: {
71
85
  original: boolean;
72
86
  found: boolean;
@@ -90,13 +104,13 @@ export declare const attributeNext: (attribute: string) => string;
90
104
  export declare const firstStartOnlyCopy: (status: string) => string;
91
105
  export declare const stoppedCopy: (date: string | null) => string;
92
106
  export declare const decidedCopy: (date: string | null, winner: string) => string;
93
- export declare const runningCopy: (date: string | null, people: number | null, days: number | null) => string;
94
- export declare const lastBlockPlacementCopy: (name: string, removingPage?: boolean) => string;
95
- export declare const hiddenBlockPlacementCopy: (name: string) => string;
96
- export declare const bulkBlockRemovalCopy: (name: string) => string;
97
- export declare const pendingBlockRemovalCopy: (name: string) => string;
107
+ export declare const runningCopy: (date: string | null, people: number | null, days: number | null, weekends?: number | null) => string;
108
+ export declare const lastBlockPlacementCopy: (name: string, removingPage?: boolean, status?: string) => string;
109
+ export declare const hiddenBlockPlacementCopy: (name: string, status?: string) => string;
110
+ export declare const bulkBlockRemovalCopy: (name: string, status?: string) => string;
111
+ export declare const pendingBlockRemovalCopy: (name: string, status?: string) => string;
98
112
  /** After archive the guard protects the winner and the Original; only the winner page is "the winner". */
99
- export declare const pageGuardCopy: (name: string, status: "running" | "decided" | "archived", role?: "winner" | "original") => string;
113
+ export declare const pageGuardCopy: (name: string, status: "running" | "paused" | "decided" | "archived", role?: "winner" | "original") => string;
100
114
  export declare const versionPageUnavailableCopy: (path: string, status?: string) => string;
101
115
  export declare const versionPageUncheckedCopy: (path: string, status?: string) => string;
102
116
  export declare const sameAddressCopy: (label: string, other: string, path: string) => string;