@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
@@ -0,0 +1,20 @@
1
+ 'use client';
2
+ import { useEffect, useState } from 'react';
3
+ import { scheduleStatus } from './scheduleStatus.js';
4
+ /** Refresh a mounted surface when its next scheduled label or action changes. */ export function useScheduleClock(tests, defaultZone) {
5
+ const [, refresh] = useState(0);
6
+ const now = Date.now();
7
+ const next = tests.reduce((earliest, test)=>{
8
+ const change = test.status === 'paused' ? Date.parse(test.schedule?.endAt ?? '') : scheduleStatus(test, now, undefined, defaultZone).at;
9
+ return change !== undefined && change > now ? Math.min(earliest, change) : earliest;
10
+ }, Infinity);
11
+ useEffect(()=>{
12
+ if (!Number.isFinite(next)) return;
13
+ const timer = setTimeout(()=>refresh((value)=>value + 1), Math.max(1, Math.min(next - Date.now(), 2 ** 31 - 1)));
14
+ return ()=>clearTimeout(timer);
15
+ }, [
16
+ next,
17
+ now
18
+ ]);
19
+ return now;
20
+ }
@@ -1,14 +1,9 @@
1
- import type { ExperimentKind, Status } from '../types/contracts.js';
1
+ import type { ExperimentKind } from '../types/contracts.js';
2
2
  import type { VerdictCode } from '../types/snapshot.js';
3
3
  import { ARM_LABELS } from '../labels/arms.js';
4
+ import { type DisplayStatus } from '../labels/status.js';
4
5
  export { ARM_LABELS };
5
- export declare const STATUS_LABELS: {
6
- draft: string;
7
- running: string;
8
- stopped: string;
9
- decided: string;
10
- archived: string;
11
- };
6
+ export { STATUS_LABELS, displayStatus, type DisplayStatus } from '../labels/status.js';
12
7
  export declare const PHASE_KIND_LABELS: {
13
8
  readonly test: "during the test";
14
9
  readonly rollout: "after shipping";
@@ -33,7 +28,7 @@ export declare const VERDICT_LABELS: {
33
28
  'rollout-readout': string;
34
29
  };
35
30
  export declare function armLabel(key: string, storedLabel?: string): string;
36
- export declare function statusLabel(status: Status): string;
31
+ export declare function statusLabel(status: DisplayStatus): string;
37
32
  export declare function phaseKindLabel(kind: 'test' | 'rollout'): string;
38
33
  export declare function verdictCodeLabel(code: VerdictCode, controlLabel?: string): string;
39
34
  export declare function kindLabel(kind: ExperimentKind): string;
@@ -1,12 +1,7 @@
1
1
  import { ARM_LABELS } from '../labels/arms.js';
2
+ import { STATUS_LABELS } from '../labels/status.js';
2
3
  export { ARM_LABELS };
3
- export const STATUS_LABELS = {
4
- draft: 'Draft',
5
- running: 'Running',
6
- stopped: 'Stopped',
7
- decided: 'Decided',
8
- archived: 'Archived'
9
- };
4
+ export { STATUS_LABELS, displayStatus } from '../labels/status.js';
10
5
  export const PHASE_KIND_LABELS = {
11
6
  test: 'during the test',
12
7
  rollout: 'after shipping'
@@ -1,5 +1,5 @@
1
1
  import type { Status } from '../types/contracts.js';
2
2
  import type { EditableField } from '../types/admin.js';
3
3
  import type { SectionId } from './surface/contracts.js';
4
- export declare function sectionLockNotice(status: Status, section: SectionId): string | null;
5
- export declare function lockedReason(status: Status, field: string, table: Record<Status, readonly EditableField[]>): string | null;
4
+ export declare function sectionLockNotice(status: Status, section: SectionId, startedAt?: string | null): string | null;
5
+ export declare function lockedReason(status: Status, field: string, table: Record<Status, readonly EditableField[]>, startedAt?: string | null): string | null;
@@ -1,5 +1,6 @@
1
1
  import { EDITABLE_BY_STATUS } from '../collections/experiments/editability.js';
2
2
  import { LOCKED_MESSAGES } from './copy/common.js';
3
+ import { displayStatus } from './labels.js';
3
4
  const sectionFields = {
4
5
  what: [
5
6
  'name',
@@ -20,29 +21,41 @@ const sectionFields = {
20
21
  length: [
21
22
  'analysis'
22
23
  ],
24
+ schedule: [
25
+ 'schedule'
26
+ ],
23
27
  advanced: [
24
28
  'analysis',
25
29
  'exposurePolicy'
26
30
  ]
27
31
  };
28
- export function sectionLockNotice(status, section) {
32
+ export function sectionLockNotice(status, section, startedAt) {
29
33
  const fields = sectionFields[section];
34
+ if (displayStatus({
35
+ status,
36
+ startedAt
37
+ }) === 'scheduled') return LOCKED_MESSAGES.scheduled;
30
38
  if (fields.some((field)=>EDITABLE_BY_STATUS[status].includes(field))) return null;
31
- return lockedReason(status, fields[0], EDITABLE_BY_STATUS);
39
+ return lockedReason(status, fields[0], EDITABLE_BY_STATUS, startedAt);
32
40
  }
33
- export function lockedReason(status, field, table) {
41
+ export function lockedReason(status, field, table, startedAt) {
34
42
  if ([
35
43
  'slug',
36
44
  'kind',
37
45
  'unitType',
38
46
  'layer'
39
47
  ].includes(field)) return LOCKED_MESSAGES.creation;
48
+ if (displayStatus({
49
+ status,
50
+ startedAt
51
+ }) === 'scheduled') return LOCKED_MESSAGES.scheduled;
40
52
  if (table[status].some((editable)=>editable === field)) return null;
41
53
  if (status === 'running') {
42
54
  if (field === 'allocation') return LOCKED_MESSAGES.runningAllocation;
43
55
  if (field === 'metrics') return LOCKED_MESSAGES.runningMetrics;
44
56
  return LOCKED_MESSAGES.running;
45
57
  }
58
+ if (status === 'paused') return field === 'metrics' ? LOCKED_MESSAGES.runningMetrics : LOCKED_MESSAGES.paused;
46
59
  if (status === 'decided') return LOCKED_MESSAGES.decided;
47
60
  if (status === 'archived') return LOCKED_MESSAGES.archived;
48
61
  return LOCKED_MESSAGES.other;
@@ -5,6 +5,9 @@ export declare function statusOrRoundChanged(answer: DocumentVersion | undefined
5
5
  export declare function documentChanged(answer: DocumentVersion | undefined, current: DocumentVersion): boolean;
6
6
  /** The answer must support both readiness and placement consumers. */
7
7
  export declare function isPreflightResult(value: unknown): value is PreflightResult;
8
+ export declare function preflightURL(path: string, locale?: string, previous?: PreflightResult): string;
9
+ /** A revalidation of the same pause omits the optional user lookup. */
10
+ export declare function retainPauseAttribution(answer: unknown, previous?: PreflightResult): unknown;
8
11
  /** Bound the response and body read, even when a producer ignores cancellation. */
9
12
  export declare function readPreflight(request: (signal: AbortSignal) => Promise<Response>, signal: AbortSignal): Promise<{
10
13
  response: Response;
@@ -1,3 +1,4 @@
1
+ import { contentLocaleURL } from './contentLocaleURL.js';
1
2
  export const PREFLIGHT_TIMEOUT_MS = 15_000;
2
3
  export function statusOrRoundChanged(answer, current) {
3
4
  return !!answer && (answer.status !== current.status || answer.phase !== undefined && answer.phase !== current.phase);
@@ -9,6 +10,19 @@ export function documentChanged(answer, current) {
9
10
  const data = value;
10
11
  return !!data && Array.isArray(data.placements) && Array.isArray(data.checks) && data.checks.every((check)=>check && typeof check.code === 'string' && typeof check.ok === 'boolean');
11
12
  }
13
+ export function preflightURL(path, locale, previous) {
14
+ const url = contentLocaleURL(path, locale);
15
+ const pausedAt = previous?.document?.pausedAt;
16
+ return pausedAt === undefined ? url : `${url}${locale ? '&' : '?'}seenPause=${encodeURIComponent(pausedAt ?? '')}`;
17
+ }
18
+ /** A revalidation of the same pause omits the optional user lookup. */ export function retainPauseAttribution(answer, previous) {
19
+ const attribution = previous?.pauseAttribution;
20
+ if (attribution && isPreflightResult(answer) && answer.pauseLookupSkipped === true && answer.document?.status === 'paused' && answer.document.pausedAt === attribution.pausedAt) return {
21
+ ...answer,
22
+ pauseAttribution: attribution
23
+ };
24
+ return answer;
25
+ }
12
26
  /** Bound the response and body read, even when a producer ignores cancellation. */ export async function readPreflight(request, signal) {
13
27
  const controller = new AbortController();
14
28
  let timer;
@@ -14,7 +14,7 @@ export declare function classifyReadinessRead(status: number, body?: unknown, fa
14
14
  loadState: "forbidden" | "error" | "missing" | "ready";
15
15
  kind: string;
16
16
  answer: PreflightResult | undefined;
17
- message: "Couldn't check where this test is used. Try again." | "You don't have permission to check where this test is used." | "A page used by this test no longer exists. Choose another page." | "This test's setup couldn't be checked." | "Couldn't check readiness. Try again." | "This test no longer exists." | "This isn't available yet." | "Your session has expired. Sign in again." | "Couldn't load this test. Try selecting it again." | "You don't have access to this test." | "Couldn't load this test." | "You don't have access to this test. You can still edit its content." | "This test isn't available to you. You can still edit its content." | "You can view this test's results." | undefined;
17
+ message: "Couldn't check where this test is used. Try again." | "You don't have permission to check where this test is used." | "A page used by this test no longer exists. Choose another page." | "This test's setup couldn't be checked." | "Couldn't check readiness. Try again." | "This test no longer exists." | "This isn't available yet." | "Your session has expired. Sign in again." | "You don't have access to this test." | "Couldn't load this test." | "Couldn't load this test. Try selecting it again." | "You don't have access to this test. You can still edit its content." | "This test isn't available to you. You can still edit its content." | "You can view this test's results." | undefined;
18
18
  failed: boolean;
19
19
  retry: boolean;
20
20
  pollDelay: number | null;
@@ -29,7 +29,7 @@ export declare function readinessRead(test: {
29
29
  loadState: "forbidden" | "error" | "missing" | "ready";
30
30
  kind: string;
31
31
  answer: PreflightResult | undefined;
32
- message: "Couldn't check where this test is used. Try again." | "You don't have permission to check where this test is used." | "A page used by this test no longer exists. Choose another page." | "This test's setup couldn't be checked." | "Couldn't check readiness. Try again." | "This test no longer exists." | "This isn't available yet." | "Your session has expired. Sign in again." | "Couldn't load this test. Try selecting it again." | "You don't have access to this test." | "Couldn't load this test." | "You don't have access to this test. You can still edit its content." | "This test isn't available to you. You can still edit its content." | "You can view this test's results." | undefined;
32
+ message: "Couldn't check where this test is used. Try again." | "You don't have permission to check where this test is used." | "A page used by this test no longer exists. Choose another page." | "This test's setup couldn't be checked." | "Couldn't check readiness. Try again." | "This test no longer exists." | "This isn't available yet." | "Your session has expired. Sign in again." | "You don't have access to this test." | "Couldn't load this test." | "Couldn't load this test. Try selecting it again." | "You don't have access to this test. You can still edit its content." | "This test isn't available to you. You can still edit its content." | "You can view this test's results." | undefined;
33
33
  failed: boolean;
34
34
  retry: boolean;
35
35
  pollDelay: number | null;
@@ -2,12 +2,12 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { RESULTS_COPY as C } from '../copy/results.js';
4
4
  import './results.css';
5
- const quality = (item)=>item.id === 'srm' || item.id.startsWith('version-page-unavailable') ? 'problem' : 'watch';
5
+ const quality = (item)=>item.id === 'schedule-population' ? 'ok' : item.id === 'srm' || item.id.startsWith('version-page-unavailable') ? 'problem' : 'watch';
6
6
  export function DataQualityPanel({ items, problem = false }) {
7
- const overall = problem || items.some((item)=>quality(item) === 'problem') ? 'problem' : items.length ? 'watch' : 'ok';
7
+ const overall = problem || items.some((item)=>quality(item) === 'problem') ? 'problem' : items.some((item)=>quality(item) === 'watch') ? 'watch' : 'ok';
8
8
  return /*#__PURE__*/ _jsxs("details", {
9
9
  className: "xp-results-panel xp-data-quality",
10
- open: overall !== 'ok',
10
+ open: problem || items.length > 0,
11
11
  children: [
12
12
  /*#__PURE__*/ _jsxs("summary", {
13
13
  children: [
@@ -23,10 +23,10 @@ export function DataQualityPanel({ items, problem = false }) {
23
23
  children: items.length ? items.map((item)=>/*#__PURE__*/ _jsxs("div", {
24
24
  className: "xp-quality-row",
25
25
  children: [
26
- /*#__PURE__*/ _jsx("span", {
26
+ quality(item) !== 'ok' ? /*#__PURE__*/ _jsx("span", {
27
27
  className: `xp-quality-chip xp-quality-chip--${quality(item)}`,
28
28
  children: C.qualityStates[quality(item)]
29
- }),
29
+ }) : null,
30
30
  /*#__PURE__*/ _jsx("p", {
31
31
  children: item.message
32
32
  }),
@@ -39,13 +39,13 @@ export function DataQualityPanel({ items, problem = false }) {
39
39
  children: share
40
40
  }, index))
41
41
  }) : null,
42
- /*#__PURE__*/ _jsx("p", {
42
+ item.nextStep ? /*#__PURE__*/ _jsx("p", {
43
43
  className: "xp-quality-next",
44
44
  children: item.href ? /*#__PURE__*/ _jsx("a", {
45
45
  href: item.href,
46
46
  children: item.nextStep
47
47
  }) : item.nextStep
48
- })
48
+ }) : null
49
49
  ]
50
50
  }, item.id)) : /*#__PURE__*/ _jsx("p", {
51
51
  className: "xp-quality-row",
@@ -1,7 +1,7 @@
1
1
  import type { DocId, Status } from '../../types/contracts.js';
2
2
  import type { PhaseSummary, ResultsResponse } from '../../types/endpoints.js';
3
3
  import type { Snapshot } from '../../types/snapshot.js';
4
- import type { DateFormatter } from '../format/date.js';
4
+ import { type DateFormatter } from '../format/date.js';
5
5
  import type { roundProgress } from '../format/roundProgress.js';
6
6
  import { type DisplaySnapshot } from './snapshot.js';
7
7
  import type { PlacementLabel } from '../placements/placementLabels.model.js';
@@ -1,7 +1,10 @@
1
+ import { COHORT_COPY, cohortExitsLabel } from '../copy/cohorts.js';
1
2
  import { isLongDuration } from '../../results/verdict.js';
3
+ import { createDateFormatter } from '../format/date.js';
4
+ import { pausedShareCopy, schedulePopulationCopy } from '../copy/schedule.js';
2
5
  import { READINESS_COPY, placementUncheckedCopy, versionPageUnavailableCopy, versionPageUncheckedCopy } from '../copy/readiness.js';
3
6
  import { armLabel, phaseKindLabel, verdictCodeLabel } from '../labels.js';
4
- import { RESULTS_COPY, cappedCount, collectingCopy, conflictCopy, decidedTitle, exclusionCopy, ignoredCopy, keepRunningTo, metricUnavailable, moreDays, pastPlannedEnd, roundLabel, shareCopy, shippingTitle, srmP, uncappedTotal, verdictControlCopy } from '../copy/results.js';
7
+ import { RESULTS_COPY, cappedCount, collectingCopy, conflictCopy, decidedTitle, exclusionCopy, ignoredCopy, keepRunningTo, metricUnavailable, moreDays, moreWeekends, pastPlannedEnd, roundLabel, shareCopy, shippingTitle, srmP, uncappedTotal, verdictControlCopy } from '../copy/results.js';
5
8
  import { formatCI, formatCount, formatMetric, formatPercent, formatProbability } from './format.js';
6
9
  import { legacyMinimum, legacyRolloutLine, legacyTooFew } from './legacy.js';
7
10
  import { isLegacySnapshot } from './snapshot.js';
@@ -119,10 +122,12 @@ export function guardrailChips(snapshot) {
119
122
  }));
120
123
  }
121
124
  export function runningPlanLine(snapshot, progress, formatDate) {
122
- const date = progress.end === null ? null : formatDate(progress.end);
125
+ const date = progress.end === null ? null : (progress.timeZone ? createDateFormatter(progress.timeZone) : formatDate)(progress.end);
123
126
  const planned = date === null ? RESULTS_COPY.plannedEnd : progress.daysToGo === 0 ? pastPlannedEnd(date) : keepRunningTo(date);
124
127
  const days = snapshot.power.daysRemaining;
125
- return days !== null && progress.daysToGo !== null && days > progress.daysToGo ? `${planned} ${moreDays(formatCount(Math.ceil(days)))}` : planned;
128
+ if (days === null || progress.daysToGo === null || days <= progress.daysToGo) return planned;
129
+ const extra = progress.daysPerWeekend && days > 1 ? moreWeekends(formatCount(Math.ceil(days / progress.daysPerWeekend))) : moreDays(formatCount(Math.ceil(days)));
130
+ return `${planned} ${extra}`;
126
131
  }
127
132
  export function powerLine({ snapshot, phaseKind, status }, planned) {
128
133
  if (phaseKind !== 'test' || status !== 'running' || snapshot.verdict.code !== 'collecting') return null;
@@ -142,18 +147,36 @@ function smallest(values) {
142
147
  return collectingCopy(formatCount(smallest(keys.map((key)=>snapshot.exposures.perArm[key]))), formatCount(isLegacySnapshot(snapshot) ? legacyMinimum(snapshot, ctx) : snapshot.minExposuresPerArm), formatCount(smallest(keys.map((key)=>primary?.perArm.find((arm)=>arm.arm === key)?.converters))), formatCount(primary ? snapshot.params.minSampleSizes[primary.metricId] : undefined));
143
148
  }
144
149
  export function dataQuality(snapshot, ctx = {}) {
145
- const items = (snapshot.health ?? []).map((item)=>item.code === 'rapid-browser-events' ? {
150
+ const items = (snapshot.health ?? []).map((item)=>{
151
+ if (item.code === 'cohort-no-exposures') return {
152
+ id: item.code,
153
+ message: COHORT_COPY.noExposures,
154
+ nextStep: ''
155
+ };
156
+ if (item.code === 'paused-share') return {
157
+ id: item.code,
158
+ message: pausedShareCopy(item.pausedDays),
159
+ nextStep: ''
160
+ };
161
+ if (item.code === 'schedule-population') return {
162
+ id: item.code,
163
+ message: schedulePopulationCopy(item.summary),
164
+ nextStep: ''
165
+ };
166
+ if (item.code === 'rapid-browser-events') return {
146
167
  id: item.code,
147
168
  message: RESULTS_COPY.rapidBrowserEvents,
148
169
  nextStep: RESULTS_COPY.rapidBrowserEventsNext
149
- } : {
170
+ };
171
+ return {
150
172
  id: item.code === 'placement-unchecked' ? `${item.code}:${JSON.stringify(item.detail)}` : `${item.code}:${'path' in item ? item.path : item.metricId}`,
151
173
  message: item.code === 'placement-unchecked' ? placementUncheckedCopy(ctx.placementLabels?.get(placementDetailKey(item.detail))?.title ?? item.detail.path ?? 'This page') : item.code === 'goal-in-some-versions' ? `${item.name} now appears in some versions but not all, so this result is no longer a fair comparison. Add it to every version, or remove it.` : READINESS_COPY.needsAttention,
152
174
  ...item.code === 'placement-unchecked' ? {
153
175
  href: ctx.placementLabels?.get(placementDetailKey(item.detail))?.href
154
176
  } : {},
155
177
  nextStep: item.code === 'placement-unchecked' ? `Open ${ctx.placementLabels?.get(placementDetailKey(item.detail))?.title ?? item.detail.path ?? 'the page'}` : item.code === 'goal-in-some-versions' ? 'Edit the versions' : item.code === 'version-page-unavailable' ? versionPageUnavailableCopy(item.path, ctx.status) : versionPageUncheckedCopy(item.path, ctx.status)
156
- });
178
+ };
179
+ });
157
180
  const srmTotal = Object.keys(snapshot.srm.expected).reduce((total, key)=>total + (snapshot.exposures.perArm[key] ?? 0), 0);
158
181
  if (snapshot.srm.flagged) items.push({
159
182
  id: 'srm',
@@ -162,6 +185,11 @@ export function dataQuality(snapshot, ctx = {}) {
162
185
  shares: Object.entries(snapshot.srm.expected).map(([key, expected])=>shareCopy(ctx.phase?.arms.find((arm)=>arm.key === key)?.label ?? armLabel(key), formatPercent(expected), formatPercent(srmTotal > 0 ? (snapshot.exposures.perArm[key] ?? 0) / srmTotal : undefined)))
163
186
  });
164
187
  const exposures = snapshot.exposures;
188
+ if ((exposures.cohortExits ?? 0) > 0) items.push({
189
+ id: 'cohort-exits',
190
+ message: cohortExitsLabel(exposures.cohortExits),
191
+ nextStep: ''
192
+ });
165
193
  if (exposures.excludedMultiArm > 0 || exposures.multiArmShare > 0) items.push({
166
194
  id: 'multi-group',
167
195
  message: RESULTS_COPY.multiGroup,
@@ -0,0 +1,11 @@
1
+ import type { CohortRule } from '../../cohorts/rule.js';
2
+ import type { CohortSourceOption } from '../../types/endpoints.js';
3
+ export declare function selectedCohortRound(source: CohortSourceOption | undefined, phase: CohortRule['phase']): import("../../types/endpoints.js").CohortSourceRound | undefined;
4
+ export declare function cohortSize(rule: CohortRule, source: CohortSourceOption | undefined): number | undefined;
5
+ export declare function audienceReview(entries: Array<{
6
+ include: boolean;
7
+ size?: number;
8
+ }>, minExposuresPerArm: number, comparedVersions: number): {
9
+ warning?: "This audience may be too small to reach a reliable answer." | undefined;
10
+ lines: string[];
11
+ };
@@ -0,0 +1,32 @@
1
+ import { COHORT_EDITOR, cohortReviewLabel } from '../copy/cohorts.js';
2
+ export function selectedCohortRound(source, phase) {
3
+ return phase === 'latest' ? source?.rounds[0] : source?.rounds.find((round)=>round.phase === phase);
4
+ }
5
+ export function cohortSize(rule, source) {
6
+ const estimate = selectedCohortRound(source, rule.phase)?.estimate;
7
+ if (!estimate || !rule.arms.length) return;
8
+ let total = 0;
9
+ for (const key of rule.arms){
10
+ const arm = estimate.perArm[key];
11
+ if (!arm) return;
12
+ if (!rule.goal) {
13
+ total += arm.exposed;
14
+ continue;
15
+ }
16
+ const converters = arm.converters[rule.goal.metricId];
17
+ if (converters === undefined) return;
18
+ total += rule.goal.completed ? converters : Math.max(0, arm.exposed - converters);
19
+ }
20
+ return total;
21
+ }
22
+ export function audienceReview(entries, minExposuresPerArm, comparedVersions) {
23
+ const sizes = entries.flatMap(({ include, size })=>include && size !== undefined ? [
24
+ size
25
+ ] : []);
26
+ return {
27
+ lines: sizes.map(cohortReviewLabel),
28
+ ...sizes.some((size)=>size < minExposuresPerArm * comparedVersions) ? {
29
+ warning: COHORT_EDITOR.tooSmall
30
+ } : {}
31
+ };
32
+ }
@@ -4,7 +4,7 @@ import type { SerializedAttributeKeys, SerializedFlagPoint, SerializedMetricSour
4
4
  import type { ArmSlot } from '../../types/puck.js';
5
5
  import type { useTestDocument } from './useTestDocument.js';
6
6
  /** Sections of the test page, in readiness order (surface spec §6.2, §8). */
7
- export type SectionId = 'what' | 'versions' | 'win' | 'who' | 'length' | 'advanced';
7
+ export type SectionId = 'what' | 'versions' | 'win' | 'who' | 'length' | 'schedule' | 'advanced';
8
8
  export declare const SECTION_ORDER: readonly SectionId[];
9
9
  /** The data layer's return value; every section takes it as `test`. */
10
10
  type DocumentApi = ReturnType<typeof useTestDocument>;
@@ -28,6 +28,7 @@ export interface SurfaceProps {
28
28
  editorPlacementMessage?: string;
29
29
  adminRoute: string;
30
30
  apiRoute: string;
31
+ timeZone?: string;
31
32
  contentLanguageLabels?: string[];
32
33
  contentLocale?: string;
33
34
  collectionTitles?: Record<string, string>;
@@ -4,5 +4,6 @@ export const SECTION_ORDER = [
4
4
  'win',
5
5
  'who',
6
6
  'length',
7
+ 'schedule',
7
8
  'advanced'
8
9
  ];
@@ -10,6 +10,7 @@ export declare function editorPlacementMessage(placements: PreflightResult['plac
10
10
  export declare function editorPreflight(answer: PreflightResult | null, surface: SurfaceProps, includeLocalBlocker?: boolean): PreflightResult | null;
11
11
  /** Shared sidebar policy; the bounded list renders these steps verbatim. */
12
12
  export declare function sidebarReadinessBlockers(test: ActionTestApi, surface: SurfaceProps): ({
13
+ rule?: number | undefined;
13
14
  arm?: import("../../types/armKey.js").ArmKey | undefined;
14
15
  section: "header" | import("./contracts.js").SectionId;
15
16
  sentence: string;
@@ -6,11 +6,12 @@ type Props = {
6
6
  onClose(): void;
7
7
  };
8
8
  export declare function dialogTitle(label: string, test: ActionTestApi): string;
9
- /** Prop-driven ConfirmDialog adapter: same model/copy, section reload instead of a page reload. */
10
- export declare function ConfirmAction({ test, surface, action, winnerLabel, onClose, onSuccess }: Props & {
9
+ export declare function ConfirmAction({ test, surface, action, winnerLabel, onClose, onSuccess, unavailable, now }: Props & {
11
10
  action: ExperimentAction;
12
11
  winnerLabel: string;
13
12
  onSuccess?: () => void;
13
+ unavailable?: boolean;
14
+ now?: number;
14
15
  }): import("react").JSX.Element;
15
16
  /** AllocateDialog's validation and copy, with data supplied by the test document. */
16
17
  export declare function AllocateAction({ test, surface, onClose }: Props): import("react").JSX.Element;