@delmaredigital/payload-experiments 0.4.1 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -5
- package/dist/admin/blocks/model.js +2 -0
- package/dist/admin/copy/blocks.d.ts +1 -0
- package/dist/admin/copy/blocks.js +1 -0
- package/dist/admin/copy/status.d.ts +3 -0
- package/dist/admin/copy/status.js +3 -0
- package/dist/admin/placementStatus.model.js +3 -0
- package/dist/admin/status.model.d.ts +3 -2
- package/dist/admin/status.model.js +9 -3
- package/dist/admin/surface/ResultsRoute.js +2 -1
- package/dist/admin/surface/TestsHome.d.ts +2 -1
- package/dist/admin/surface/TestsHome.js +31 -11
- package/dist/admin/surface/TestsSurface.js +4 -0
- package/dist/admin/surface/home.model.d.ts +11 -6
- package/dist/admin/surface/home.model.js +19 -8
- package/dist/admin/surface/newTest/PageWizard.js +13 -3
- package/dist/admin/surface/results/ResultsHeader.js +43 -9
- package/dist/admin/surface/test/TestPage.js +11 -1
- package/dist/admin/useLayerUsage.d.ts +1 -1
- package/dist/admin/views/buildSurfaceProps.js +3 -0
- package/dist/blocks/placementLocale.d.ts +14 -0
- package/dist/blocks/placementLocale.js +80 -13
- package/dist/blocks/placementPublication.d.ts +14 -0
- package/dist/blocks/placementPublication.js +24 -0
- package/dist/cohorts/build.d.ts +35 -0
- package/dist/cohorts/build.js +134 -0
- package/dist/cohorts/key.d.ts +12 -0
- package/dist/cohorts/key.js +15 -0
- package/dist/cohorts/maintenance.d.ts +10 -0
- package/dist/cohorts/maintenance.js +70 -0
- package/dist/cohorts/readiness.d.ts +30 -0
- package/dist/cohorts/readiness.js +54 -0
- package/dist/cohorts/readinessData.d.ts +29 -0
- package/dist/cohorts/readinessData.js +123 -0
- package/dist/cohorts/rule.d.ts +33 -0
- package/dist/cohorts/rule.js +50 -0
- package/dist/collections/cohortMembers.d.ts +4 -0
- package/dist/collections/cohortMembers.js +95 -0
- package/dist/collections/experiments/config.js +157 -7
- package/dist/collections/experiments/editability.js +10 -6
- package/dist/collections/experiments/lockHook.js +39 -20
- package/dist/collections/index.js +4 -1
- package/dist/collections/phases.js +4 -1
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +2 -0
- package/dist/db/adapter.d.ts +2 -1
- package/dist/db/adapter.js +17 -4
- package/dist/db/appends.d.ts +2 -1
- package/dist/db/appends.js +3 -2
- package/dist/db/bulkPlacementRemoval.d.ts +5 -0
- package/dist/db/bulkPlacementRemoval.js +7 -2
- package/dist/db/cohortMembership.d.ts +11 -0
- package/dist/db/cohortMembership.js +31 -0
- package/dist/db/cohortPool.d.ts +9 -0
- package/dist/db/cohortPool.js +53 -0
- package/dist/db/cohortTransactions.d.ts +3 -0
- package/dist/db/cohortTransactions.js +52 -0
- package/dist/db/cohorts.d.ts +72 -0
- package/dist/db/cohorts.js +280 -0
- package/dist/db/erase.d.ts +2 -0
- package/dist/db/erase.js +21 -2
- package/dist/db/events.d.ts +2 -0
- package/dist/db/events.js +8 -0
- package/dist/db/executor.d.ts +2 -0
- package/dist/db/executor.js +8 -0
- package/dist/db/locks.d.ts +7 -0
- package/dist/db/locks.js +13 -1
- package/dist/db/names.d.ts +95 -1
- package/dist/db/names.js +95 -1
- package/dist/db/occupancy.d.ts +21 -0
- package/dist/db/occupancy.js +46 -0
- package/dist/db/pageBindings.d.ts +2 -2
- package/dist/db/pageBindings.js +3 -3
- package/dist/db/pageOccupancy.d.ts +4 -4
- package/dist/db/pageOccupancy.js +13 -10
- package/dist/db/pgExecutor.d.ts +4 -0
- package/dist/db/pgExecutor.js +1 -1
- package/dist/db/placements.d.ts +6 -1
- package/dist/db/placements.js +27 -1
- package/dist/db/results.d.ts +5 -2
- package/dist/db/results.js +32 -5
- package/dist/db/slices.d.ts +9 -2
- package/dist/db/slices.js +15 -8
- package/dist/db/snapshots.d.ts +16 -1
- package/dist/db/snapshots.js +27 -2
- package/dist/db/sql.d.ts +2 -2
- package/dist/db/sql.js +1 -2
- package/dist/endpoints/cohortSources.d.ts +16 -0
- package/dist/endpoints/cohortSources.js +335 -0
- package/dist/endpoints/contentLocale.d.ts +1 -1
- package/dist/endpoints/duplicateOriginal.d.ts +1 -0
- package/dist/endpoints/events.js +82 -18
- package/dist/endpoints/index.js +45 -1
- package/dist/endpoints/pausedBy.d.ts +14 -0
- package/dist/endpoints/pausedBy.js +94 -0
- package/dist/endpoints/preflight.js +4 -1
- package/dist/endpoints/previewToken.js +2 -0
- package/dist/endpoints/results.d.ts +2 -2
- package/dist/endpoints/results.js +111 -3
- package/dist/endpoints/routeId.d.ts +2 -1
- package/dist/endpoints/routeId.js +6 -2
- package/dist/endpoints/summary.js +24 -1
- package/dist/endpoints/transitions.d.ts +7 -0
- package/dist/endpoints/transitions.js +50 -1
- package/dist/events/rows.d.ts +1 -1
- package/dist/events/rows.js +5 -3
- package/dist/exports/index.d.ts +2 -0
- package/dist/exports/index.js +1 -0
- package/dist/exports/runtimeProxy.d.ts +1 -0
- package/dist/exports/runtimeProxy.js +1 -0
- package/dist/hooks/blockRemovalRule.d.ts +1 -1
- package/dist/hooks/blockRemovalRule.js +12 -8
- package/dist/hooks/pageGuard.d.ts +7 -1
- package/dist/hooks/pageGuard.js +177 -4
- package/dist/hooks/puckNestedTests.d.ts +1 -1
- package/dist/hooks/puckNestedTests.js +3 -1
- package/dist/labels/status.d.ts +15 -0
- package/dist/labels/status.js +12 -0
- package/dist/manifest/compile.d.ts +15 -4
- package/dist/manifest/compile.js +91 -3
- package/dist/onInit.js +4 -6
- package/dist/options.d.ts +1 -0
- package/dist/options.js +10 -0
- package/dist/proxy/consentFallback.d.ts +1 -1
- package/dist/proxy/consentFallback.js +4 -4
- package/dist/proxy/control.d.ts +1 -1
- package/dist/proxy/control.js +2 -2
- package/dist/proxy/pageRewrite.d.ts +1 -1
- package/dist/proxy/pageRewrite.js +3 -2
- package/dist/proxy/resolve.js +76 -17
- package/dist/puck/ExperimentPicker.js +2 -1
- package/dist/puck/copy.d.ts +6 -5
- package/dist/puck/copy.js +3 -7
- package/dist/puck/editor/ExperimentSlotEditor.js +16 -5
- package/dist/puck/editor/QuickTestActions.js +7 -1
- package/dist/puck/editor/armWrites.js +6 -1
- package/dist/puck/editor/copy.d.ts +3 -0
- package/dist/puck/editor/copy.js +3 -0
- package/dist/puck/editor/editor.css +2 -1
- package/dist/puck/editor/editor.model.d.ts +2 -1
- package/dist/puck/editor/editor.model.js +2 -0
- package/dist/puck/editor/placementsCache.d.ts +1 -1
- package/dist/puck/editor/placementsCache.js +6 -3
- package/dist/results/analyse.d.ts +3 -1
- package/dist/results/analyse.js +20 -3
- package/dist/results/health.d.ts +11 -0
- package/dist/results/health.js +38 -0
- package/dist/results/power.d.ts +1 -1
- package/dist/results/power.js +1 -1
- package/dist/results/snapshot.d.ts +8 -2
- package/dist/results/snapshot.js +23 -1
- package/dist/results/unitValues.d.ts +48 -0
- package/dist/results/unitValues.js +166 -0
- package/dist/runtime/assign.d.ts +7 -3
- package/dist/runtime/assign.js +12 -4
- package/dist/runtime/cohortCookie.d.ts +15 -0
- package/dist/runtime/cohortCookie.js +72 -0
- package/dist/runtime/cohortLookup.d.ts +9 -0
- package/dist/runtime/cohortLookup.js +25 -0
- package/dist/runtime/eligibility.d.ts +11 -5
- package/dist/runtime/eligibility.js +33 -7
- package/dist/runtime/header.d.ts +1 -0
- package/dist/runtime/header.js +1 -1
- package/dist/runtime/proxyRuntime.js +5 -1
- package/dist/runtime/targeting.d.ts +3 -2
- package/dist/runtime/targeting.js +2 -1
- package/dist/sanitizeReadinessDetail.d.ts +2 -2
- package/dist/sanitizeReadinessDetail.js +41 -4
- package/dist/schedule/activeTime.d.ts +28 -0
- package/dist/schedule/activeTime.js +322 -0
- package/dist/schedule/ranges.d.ts +13 -0
- package/dist/schedule/ranges.js +11 -0
- package/dist/schedule/roundTime.d.ts +10 -0
- package/dist/schedule/roundTime.js +45 -0
- package/dist/schedule/types.d.ts +29 -0
- package/dist/schedule/types.js +1 -0
- package/dist/server/cohortLookup.d.ts +3 -0
- package/dist/server/cohortLookup.js +7 -0
- package/dist/server/eraseUser.d.ts +1 -0
- package/dist/server/getAssignments.js +63 -40
- package/dist/server/previewDraft.d.ts +1 -1
- package/dist/server/previewDraft.js +3 -2
- package/dist/server/recordContentChange.d.ts +1 -1
- package/dist/server/recordContentChange.js +42 -20
- package/dist/server/recordExposures.js +4 -2
- package/dist/server/runResults.js +97 -150
- package/dist/testSurface/actions/LifecycleAction.d.ts +2 -1
- package/dist/testSurface/actions/LifecycleAction.js +15 -5
- package/dist/testSurface/actions/actions.model.d.ts +13 -2
- package/dist/testSurface/actions/actions.model.js +38 -5
- package/dist/testSurface/api.d.ts +13 -1
- package/dist/testSurface/api.js +19 -0
- package/dist/testSurface/copy/actions.d.ts +13 -0
- package/dist/testSurface/copy/actions.js +13 -0
- package/dist/testSurface/copy/cohorts.d.ts +68 -0
- package/dist/testSurface/copy/cohorts.js +81 -0
- package/dist/testSurface/copy/common.d.ts +2 -3
- package/dist/testSurface/copy/common.js +4 -4
- package/dist/testSurface/copy/inputs.d.ts +3 -0
- package/dist/testSurface/copy/inputs.js +3 -0
- package/dist/testSurface/copy/readiness.d.ts +20 -6
- package/dist/testSurface/copy/readiness.js +42 -9
- package/dist/testSurface/copy/results.d.ts +1 -0
- package/dist/testSurface/copy/results.js +1 -0
- package/dist/testSurface/copy/schedule.d.ts +58 -0
- package/dist/testSurface/copy/schedule.js +150 -0
- package/dist/testSurface/copy/surface.d.ts +2 -0
- package/dist/testSurface/copy/surface.js +2 -0
- package/dist/testSurface/copy/testPage.d.ts +12 -2
- package/dist/testSurface/copy/testPage.js +17 -2
- package/dist/testSurface/format/roundProgress.d.ts +13 -1
- package/dist/testSurface/format/roundProgress.js +34 -5
- package/dist/testSurface/format/scheduleStatus.d.ts +34 -0
- package/dist/testSurface/format/scheduleStatus.js +93 -0
- package/dist/testSurface/format/useScheduleClock.d.ts +3 -0
- package/dist/testSurface/format/useScheduleClock.js +20 -0
- package/dist/testSurface/labels.d.ts +4 -9
- package/dist/testSurface/labels.js +2 -7
- package/dist/testSurface/lockedNotice.model.d.ts +2 -2
- package/dist/testSurface/lockedNotice.model.js +16 -3
- package/dist/testSurface/readPreflight.d.ts +3 -0
- package/dist/testSurface/readPreflight.js +14 -0
- package/dist/testSurface/readinessRead.d.ts +2 -2
- package/dist/testSurface/results/DataQualityPanel.js +7 -7
- package/dist/testSurface/results/results.model.d.ts +1 -1
- package/dist/testSurface/results/results.model.js +34 -6
- package/dist/testSurface/review/cohortEstimate.d.ts +11 -0
- package/dist/testSurface/review/cohortEstimate.js +32 -0
- package/dist/testSurface/surface/contracts.d.ts +2 -1
- package/dist/testSurface/surface/contracts.js +1 -0
- package/dist/testSurface/surface/editorPlacement.d.ts +1 -0
- package/dist/testSurface/surface/readiness/ActionDialogs.d.ts +3 -2
- package/dist/testSurface/surface/readiness/ActionDialogs.js +121 -32
- package/dist/testSurface/surface/readiness/Banner.js +29 -11
- package/dist/testSurface/surface/readiness/readiness.model.d.ts +20 -2
- package/dist/testSurface/surface/readiness/readiness.model.js +35 -5
- package/dist/testSurface/surface/readiness/useTransition.js +17 -5
- package/dist/testSurface/surface/results/ResultsBody.js +44 -8
- package/dist/testSurface/surface/results/useResults.d.ts +16 -1
- package/dist/testSurface/surface/results/useResults.js +17 -6
- package/dist/testSurface/surface/test/CohortRuleEditor.d.ts +16 -0
- package/dist/testSurface/surface/test/CohortRuleEditor.js +492 -0
- package/dist/testSurface/surface/test/LengthSection.js +26 -6
- package/dist/testSurface/surface/test/ScheduleDateInput.d.ts +4 -0
- package/dist/testSurface/surface/test/ScheduleDateInput.js +15 -0
- package/dist/testSurface/surface/test/ScheduleSection.d.ts +2 -0
- package/dist/testSurface/surface/test/ScheduleSection.js +322 -0
- package/dist/testSurface/surface/test/Section.js +1 -1
- package/dist/testSurface/surface/test/TargetingSection.js +306 -182
- package/dist/testSurface/surface/test/TestSurface.js +9 -0
- package/dist/testSurface/surface/test/fields.d.ts +2 -1
- package/dist/testSurface/surface/test/fields.js +3 -3
- package/dist/testSurface/surface/test/jumpToSection.d.ts +1 -1
- package/dist/testSurface/surface/test/jumpToSection.js +4 -4
- package/dist/testSurface/surface/test/testPage.css +26 -0
- package/dist/testSurface/surface/testDocument.model.d.ts +12 -1
- package/dist/testSurface/surface/testDocument.model.js +2 -1
- package/dist/testSurface/surface/useTestDocument.js +11 -4
- package/dist/testSurface/targeting/targeting.model.d.ts +2 -1
- package/dist/testSurface/targeting/targeting.model.js +1 -1
- package/dist/testSurface/useApi.d.ts +12 -0
- package/dist/transitions/addMetric.js +5 -2
- package/dist/transitions/allocate.js +6 -1
- package/dist/transitions/assertNoOverlap.d.ts +9 -0
- package/dist/transitions/assertNoOverlap.js +24 -0
- package/dist/transitions/buildCohorts.d.ts +10 -0
- package/dist/transitions/buildCohorts.js +68 -0
- package/dist/transitions/cancelSchedule.d.ts +4 -0
- package/dist/transitions/cancelSchedule.js +42 -0
- package/dist/transitions/checkStart.d.ts +17 -3
- package/dist/transitions/checkStart.js +20 -7
- package/dist/transitions/decide.js +40 -13
- package/dist/transitions/kernel.d.ts +3 -1
- package/dist/transitions/kernel.js +5 -2
- package/dist/transitions/pause.d.ts +4 -0
- package/dist/transitions/pause.js +35 -0
- package/dist/transitions/phaseRecord.d.ts +19 -2
- package/dist/transitions/phaseRecord.js +50 -11
- package/dist/transitions/placementInteractions.d.ts +7 -2
- package/dist/transitions/placementInteractions.js +9 -7
- package/dist/transitions/placements.d.ts +4 -3
- package/dist/transitions/placements.js +28 -14
- package/dist/transitions/preflightData.d.ts +11 -3
- package/dist/transitions/preflightData.js +134 -81
- package/dist/transitions/reschedule.d.ts +4 -0
- package/dist/transitions/reschedule.js +58 -0
- package/dist/transitions/resume.d.ts +4 -0
- package/dist/transitions/resume.js +32 -0
- package/dist/transitions/scheduledRound.d.ts +18 -0
- package/dist/transitions/scheduledRound.js +42 -0
- package/dist/transitions/start.d.ts +4 -0
- package/dist/transitions/start.js +139 -56
- package/dist/transitions/startReads.d.ts +14 -0
- package/dist/transitions/startReads.js +27 -0
- package/dist/transitions/stop.d.ts +10 -0
- package/dist/transitions/stop.js +35 -22
- package/dist/types/admin.d.ts +1 -1
- package/dist/types/contracts.d.ts +7 -1
- package/dist/types/endpoints.d.ts +72 -3
- package/dist/types/manifest.d.ts +9 -0
- package/dist/types/runtime.d.ts +5 -0
- package/dist/types/snapshot.d.ts +10 -0
- package/dist/types/status.d.ts +1 -0
- package/dist/types/status.js +1 -0
- package/dist/types/surface.d.ts +1 -0
- package/dist/ui/Feedback.d.ts +9 -6
- package/dist/ui/Feedback.js +10 -9
- package/dist/ui/SelectControl.js +1 -1
- package/dist/ui/ui.css +2 -1
- package/package.json +2 -2
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
const weekdays = [
|
|
2
|
+
'mon',
|
|
3
|
+
'tue',
|
|
4
|
+
'wed',
|
|
5
|
+
'thu',
|
|
6
|
+
'fri',
|
|
7
|
+
'sat',
|
|
8
|
+
'sun'
|
|
9
|
+
];
|
|
10
|
+
const labels = [
|
|
11
|
+
'Mon',
|
|
12
|
+
'Tue',
|
|
13
|
+
'Wed',
|
|
14
|
+
'Thu',
|
|
15
|
+
'Fri',
|
|
16
|
+
'Sat',
|
|
17
|
+
'Sun'
|
|
18
|
+
];
|
|
19
|
+
export const SCHEDULE_COPY = {
|
|
20
|
+
heading: 'When it runs',
|
|
21
|
+
start: 'Start date and time (optional)',
|
|
22
|
+
end: 'End date and time (optional)',
|
|
23
|
+
savedStart: 'Start date and time',
|
|
24
|
+
savedEnd: 'End date and time',
|
|
25
|
+
timeZone: 'Time zone',
|
|
26
|
+
zoneHelp: 'Dates and times use this time zone. Changing it keeps the clock times you entered.',
|
|
27
|
+
chooseZone: 'Choose a time zone',
|
|
28
|
+
windows: 'Recurring hours',
|
|
29
|
+
windowHelp: 'Add hours to run only on selected days. Leave this empty to run at all hours.',
|
|
30
|
+
window: (index)=>`Schedule window ${index}`,
|
|
31
|
+
add: 'Add hours',
|
|
32
|
+
remove: (index)=>`Remove window ${index}`,
|
|
33
|
+
weekdays: 'Weekdays',
|
|
34
|
+
weekends: 'Weekends',
|
|
35
|
+
days: Object.fromEntries(weekdays.map((day, index)=>[
|
|
36
|
+
day,
|
|
37
|
+
labels[index]
|
|
38
|
+
])),
|
|
39
|
+
fullDays: {
|
|
40
|
+
mon: 'Monday',
|
|
41
|
+
tue: 'Tuesday',
|
|
42
|
+
wed: 'Wednesday',
|
|
43
|
+
thu: 'Thursday',
|
|
44
|
+
fri: 'Friday',
|
|
45
|
+
sat: 'Saturday',
|
|
46
|
+
sun: 'Sunday'
|
|
47
|
+
},
|
|
48
|
+
from: 'From',
|
|
49
|
+
to: 'To',
|
|
50
|
+
overnight: 'Ends the next morning',
|
|
51
|
+
save: 'Save schedule',
|
|
52
|
+
discard: 'Discard schedule edits',
|
|
53
|
+
changed: 'The saved schedule changed. Discard your edits to see the latest schedule.',
|
|
54
|
+
invalidTime: 'Choose a date and time that exists in this time zone.',
|
|
55
|
+
invalidHours: 'Enter a start and end time for each window.',
|
|
56
|
+
noZone: 'Choose a time zone to set dates and recurring hours.',
|
|
57
|
+
allHours: 'at all hours',
|
|
58
|
+
noSchedule: 'Runs at all hours once started.',
|
|
59
|
+
starts: (date)=>`Starts ${date}`,
|
|
60
|
+
off: (date)=>`Off now · back ${date}`,
|
|
61
|
+
on: (date)=>`On now · until ${date}`,
|
|
62
|
+
onNow: 'On now',
|
|
63
|
+
offNow: 'Off now',
|
|
64
|
+
ended: (date)=>`Off now · ended ${date}`,
|
|
65
|
+
paused: (progress, date, reason, name)=>{
|
|
66
|
+
// One sentence (design §4.1): after a leading "Paused · Day N of M", the detail continues in lowercase.
|
|
67
|
+
const details = name || date ? `${progress ? 'paused' : 'Paused'}${name ? ` by ${name}` : ''}${date ? ` on ${date}` : ''}` : '';
|
|
68
|
+
const note = details ? `${details}${reason ? `: ${reason}` : ''}` : reason;
|
|
69
|
+
return [
|
|
70
|
+
progress || !details ? 'Paused' : '',
|
|
71
|
+
progress,
|
|
72
|
+
note
|
|
73
|
+
].filter(Boolean).join(' · ');
|
|
74
|
+
},
|
|
75
|
+
day: (day, planned)=>planned == null ? `Day ${day}` : `Day ${day} of ${planned}`
|
|
76
|
+
};
|
|
77
|
+
export function scheduleZoneName(timeZone, at) {
|
|
78
|
+
return new Intl.DateTimeFormat('en-US', {
|
|
79
|
+
timeZone,
|
|
80
|
+
timeZoneName: timeZone === 'UTC' ? 'short' : 'shortGeneric'
|
|
81
|
+
}).formatToParts(at).find((part)=>part.type === 'timeZoneName')?.value ?? timeZone;
|
|
82
|
+
}
|
|
83
|
+
export function scheduleDate(at, timeZone, date = 'day', now = at) {
|
|
84
|
+
const day = date === 'time' ? '' : new Intl.DateTimeFormat('en-US', {
|
|
85
|
+
timeZone,
|
|
86
|
+
...date === 'weekday' ? {
|
|
87
|
+
weekday: 'short'
|
|
88
|
+
} : {
|
|
89
|
+
month: 'short',
|
|
90
|
+
day: 'numeric',
|
|
91
|
+
...at.getUTCFullYear() === now.getUTCFullYear() ? {} : {
|
|
92
|
+
year: 'numeric'
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}).format(at);
|
|
96
|
+
const time = new Intl.DateTimeFormat('en-US', {
|
|
97
|
+
timeZone,
|
|
98
|
+
hour: 'numeric',
|
|
99
|
+
minute: '2-digit'
|
|
100
|
+
}).format(at);
|
|
101
|
+
return `${day ? `${day}${date === 'day' ? ',' : ''} ` : ''}${time} ${scheduleZoneName(timeZone, at)}`;
|
|
102
|
+
}
|
|
103
|
+
export function scheduleSummary({ startAt, endAt, timeZone, windows }, now) {
|
|
104
|
+
const date = new Intl.DateTimeFormat('en-US', {
|
|
105
|
+
timeZone,
|
|
106
|
+
month: 'short',
|
|
107
|
+
day: 'numeric'
|
|
108
|
+
});
|
|
109
|
+
const start = startAt ? date.format(new Date(startAt)) : '';
|
|
110
|
+
const end = endAt ? date.format(new Date(endAt)) : '';
|
|
111
|
+
if (!start && !end && !windows.length) return SCHEDULE_COPY.noSchedule;
|
|
112
|
+
const hours = windows.length ? scheduleWindowsCopy(windows, timeZone, now) : SCHEDULE_COPY.allHours;
|
|
113
|
+
return `Runs ${hours}${start && end ? `, from ${start} to ${end}` : start ? `, from ${start}` : end ? `, until ${end}` : ''}.`;
|
|
114
|
+
}
|
|
115
|
+
function daysLabel(days) {
|
|
116
|
+
if (days.size === 7) return 'every day';
|
|
117
|
+
if (days.size === 5 && weekdays.slice(0, 5).every((day)=>days.has(day))) return 'weekdays';
|
|
118
|
+
if (days.size === 2 && days.has('sat') && days.has('sun')) return 'weekends';
|
|
119
|
+
const groups = [];
|
|
120
|
+
for(let index = 0; index < weekdays.length; index++){
|
|
121
|
+
if (!days.has(weekdays[index])) continue;
|
|
122
|
+
let end = index;
|
|
123
|
+
while(end + 1 < weekdays.length && days.has(weekdays[end + 1]))end++;
|
|
124
|
+
groups.push(end === index ? labels[index] : `${labels[index]}–${labels[end]}`);
|
|
125
|
+
index = end;
|
|
126
|
+
}
|
|
127
|
+
return groups.join(', ');
|
|
128
|
+
}
|
|
129
|
+
function clockLabel(time) {
|
|
130
|
+
const [hour, minutes] = time.split(':');
|
|
131
|
+
return `${Number(hour) % 12 || 12}${minutes === '00' ? '' : `:${minutes}`} ${Number(hour) < 12 ? 'AM' : 'PM'}`;
|
|
132
|
+
}
|
|
133
|
+
export function scheduleWindowsCopy(windows, timeZone, at) {
|
|
134
|
+
const zone = scheduleZoneName(timeZone, at);
|
|
135
|
+
const groups = new Map();
|
|
136
|
+
for (const { days, from, to } of windows){
|
|
137
|
+
const label = `${clockLabel(from)}–${clockLabel(to)} ${zone}${to <= from ? ' the next day' : ''}`;
|
|
138
|
+
const group = groups.get(label) ?? new Set();
|
|
139
|
+
for (const day of days)group.add(day);
|
|
140
|
+
groups.set(label, group);
|
|
141
|
+
}
|
|
142
|
+
return [
|
|
143
|
+
...groups
|
|
144
|
+
].map(([hours, days])=>`${daysLabel(days)}, ${hours}`).join(' and ');
|
|
145
|
+
}
|
|
146
|
+
export const schedulePopulationCopy = (summary)=>`Results describe visitors ${summary.startsWith('every day,') ? '' : 'on '}${summary}.`;
|
|
147
|
+
export const pausedShareCopy = (days)=>{
|
|
148
|
+
const duration = Math.max(0.1, Math.round(days * 10) / 10);
|
|
149
|
+
return `This test was paused for ${duration.toLocaleString('en-US')} ${duration === 1 ? 'day' : 'days'}; results describe the days it ran.`;
|
|
150
|
+
};
|
|
@@ -21,6 +21,8 @@ export declare const SURFACE_COPY: {
|
|
|
21
21
|
readonly groups: {
|
|
22
22
|
readonly attention: "Needs attention";
|
|
23
23
|
readonly running: "Running";
|
|
24
|
+
readonly scheduled: "Scheduled";
|
|
25
|
+
readonly paused: "Paused";
|
|
24
26
|
readonly ready: "Ready to start";
|
|
25
27
|
readonly draft: "Draft";
|
|
26
28
|
readonly stopped: "Stopped";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ExperimentKind } from '../../types/contracts.js';
|
|
2
|
+
import type { ScheduleWindow } from '../../schedule/types.js';
|
|
2
3
|
export declare const TEST_PAGE: {
|
|
3
4
|
readonly noAudienceRules: "No audience choices are available here. Everyone eligible takes part; leave this section as it is.";
|
|
4
5
|
readonly editVersionsOnCanvas: "Edit version content on the canvas.";
|
|
@@ -46,6 +47,7 @@ export declare const TEST_PAGE: {
|
|
|
46
47
|
readonly win: "What counts as a win";
|
|
47
48
|
readonly who: "Who takes part (optional)";
|
|
48
49
|
readonly length: "How long";
|
|
50
|
+
readonly schedule: "When it runs";
|
|
49
51
|
readonly advanced: "Advanced settings · for developers";
|
|
50
52
|
};
|
|
51
53
|
readonly hypothesis: "Why are you testing this? (optional)";
|
|
@@ -108,6 +110,7 @@ export declare const TEST_PAGE: {
|
|
|
108
110
|
readonly reach: "About how many people will see this per day?";
|
|
109
111
|
readonly reachHelp: "A rough number is fine. It only sets the suggested length.";
|
|
110
112
|
readonly duration: "Planned length (days)";
|
|
113
|
+
readonly activeDuration: "Planned length (active days)";
|
|
111
114
|
readonly endDate: "Planned end date";
|
|
112
115
|
readonly noSuggestion: "Enter a daily number above to get a suggestion. 4 weeks is a safe default.";
|
|
113
116
|
readonly chooseGoalSuggestion: "Choose a goal to get a suggestion.";
|
|
@@ -115,8 +118,9 @@ export declare const TEST_PAGE: {
|
|
|
115
118
|
readonly apply: "Apply";
|
|
116
119
|
readonly infeasible: "This may need more people than are available.";
|
|
117
120
|
};
|
|
118
|
-
export declare const suggestedWeeks: (weeks: number) => string;
|
|
119
|
-
export declare const
|
|
121
|
+
export declare const suggestedWeeks: (weeks: number, weekends?: boolean) => string;
|
|
122
|
+
export declare const scheduledEstimateCopy: (weeks: number, weekends: boolean, windows: ScheduleWindow[], zone: string, at: Date) => string;
|
|
123
|
+
export declare const weeksHint: (days: number, daysPerWeek?: number, weekends?: boolean) => string;
|
|
120
124
|
export declare const NUMBER_COMPARISONS: {
|
|
121
125
|
readonly eq: "is";
|
|
122
126
|
readonly neq: "is not";
|
|
@@ -152,3 +156,9 @@ export declare const DELETE_TEST: {
|
|
|
152
156
|
readonly morePages: (count: number) => string;
|
|
153
157
|
};
|
|
154
158
|
export declare function deleteStatusCopy(status: string, kind?: ExperimentKind): string;
|
|
159
|
+
export declare const SCHEDULE_VALIDATION: {
|
|
160
|
+
readonly endAt: "Choose an end date and time after the start.";
|
|
161
|
+
readonly timeZone: "Enter an IANA time zone, such as America/New_York.";
|
|
162
|
+
readonly days: "Choose at least one day of the week.";
|
|
163
|
+
readonly clockTime: "Enter a time in HH:MM format using a 24-hour clock.";
|
|
164
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { GOAL_ROLES } from './metrics.js';
|
|
2
2
|
import { API_MESSAGES } from './common.js';
|
|
3
3
|
import { PLACEMENT_LANGUAGES } from './languages.js';
|
|
4
|
+
import { SCHEDULE_COPY, scheduleWindowsCopy } from './schedule.js';
|
|
4
5
|
export const TEST_PAGE = {
|
|
5
6
|
noAudienceRules: 'No audience choices are available here. Everyone eligible takes part; leave this section as it is.',
|
|
6
7
|
editVersionsOnCanvas: 'Edit version content on the canvas.',
|
|
@@ -48,6 +49,7 @@ export const TEST_PAGE = {
|
|
|
48
49
|
win: 'What counts as a win',
|
|
49
50
|
who: 'Who takes part (optional)',
|
|
50
51
|
length: 'How long',
|
|
52
|
+
schedule: SCHEDULE_COPY.heading,
|
|
51
53
|
advanced: 'Advanced settings · for developers'
|
|
52
54
|
},
|
|
53
55
|
hypothesis: 'Why are you testing this? (optional)',
|
|
@@ -110,6 +112,7 @@ export const TEST_PAGE = {
|
|
|
110
112
|
reach: 'About how many people will see this per day?',
|
|
111
113
|
reachHelp: 'A rough number is fine. It only sets the suggested length.',
|
|
112
114
|
duration: 'Planned length (days)',
|
|
115
|
+
activeDuration: 'Planned length (active days)',
|
|
113
116
|
endDate: 'Planned end date',
|
|
114
117
|
noSuggestion: 'Enter a daily number above to get a suggestion. 4 weeks is a safe default.',
|
|
115
118
|
chooseGoalSuggestion: 'Choose a goal to get a suggestion.',
|
|
@@ -117,8 +120,13 @@ export const TEST_PAGE = {
|
|
|
117
120
|
apply: 'Apply',
|
|
118
121
|
infeasible: 'This may need more people than are available.'
|
|
119
122
|
};
|
|
120
|
-
|
|
121
|
-
|
|
123
|
+
const weeksLabel = (weeks, weekends)=>{
|
|
124
|
+
const count = weekends ? Math.ceil(weeks) : Math.round(weeks * 10) / 10;
|
|
125
|
+
return `${count} ${weekends ? 'weekend' : 'week'}${count === 1 ? '' : 's'}`;
|
|
126
|
+
};
|
|
127
|
+
export const suggestedWeeks = (weeks, weekends = false)=>`Suggested: about ${weeksLabel(weeks, weekends)}`;
|
|
128
|
+
export const scheduledEstimateCopy = (weeks, weekends, windows, zone, at)=>`Runs ${scheduleWindowsCopy(windows, zone, at)}. About ${weeksLabel(weeks, weekends)} to reach a reliable answer.`;
|
|
129
|
+
export const weeksHint = (days, daysPerWeek = 7, weekends = false)=>`About ${weeksLabel(days / daysPerWeek, weekends)}`;
|
|
122
130
|
export const NUMBER_COMPARISONS = {
|
|
123
131
|
eq: 'is',
|
|
124
132
|
neq: 'is not',
|
|
@@ -156,6 +164,7 @@ export const DELETE_TEST = {
|
|
|
156
164
|
};
|
|
157
165
|
export function deleteStatusCopy(status, kind) {
|
|
158
166
|
switch(status){
|
|
167
|
+
case 'paused':
|
|
159
168
|
case 'running':
|
|
160
169
|
return DELETE_TEST.archiveFirst;
|
|
161
170
|
case 'stopped':
|
|
@@ -167,3 +176,9 @@ export function deleteStatusCopy(status, kind) {
|
|
|
167
176
|
return API_MESSAGES.deleteInvalidStatus;
|
|
168
177
|
}
|
|
169
178
|
}
|
|
179
|
+
export const SCHEDULE_VALIDATION = {
|
|
180
|
+
endAt: 'Choose an end date and time after the start.',
|
|
181
|
+
timeZone: 'Enter an IANA time zone, such as America/New_York.',
|
|
182
|
+
days: 'Choose at least one day of the week.',
|
|
183
|
+
clockTime: 'Enter a time in HH:MM format using a 24-hour clock.'
|
|
184
|
+
};
|
|
@@ -1,6 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
import type { RoundTiming } from '../../schedule/types.js';
|
|
2
|
+
export declare function roundProgress(startedAt: unknown, duration: number | null | undefined, now: number, fallbackElapsedDays?: number, timing?: RoundTiming | null): {
|
|
3
|
+
day: number;
|
|
4
|
+
plannedDays: number | null;
|
|
5
|
+
daysToGo: number | null;
|
|
6
|
+
end: number | null;
|
|
7
|
+
timeZone: string;
|
|
8
|
+
daysPerWeekend: number | null;
|
|
9
|
+
weekendsToGo: number | null;
|
|
10
|
+
} | {
|
|
2
11
|
day: number | null;
|
|
3
12
|
plannedDays: number | null;
|
|
4
13
|
end: number | null;
|
|
5
14
|
daysToGo: number | null;
|
|
15
|
+
timeZone: undefined;
|
|
16
|
+
weekendsToGo: null;
|
|
17
|
+
daysPerWeekend: null;
|
|
6
18
|
};
|
|
@@ -1,15 +1,44 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { activeDayDate, activeWeek } from '../../schedule/activeTime.js';
|
|
2
|
+
import { DAY_MS, hasRoundTiming, roundActiveSpec, roundDays } from '../../schedule/roundTime.js';
|
|
3
|
+
export function roundProgress(startedAt, duration, now, fallbackElapsedDays, timing) {
|
|
3
4
|
const start = typeof startedAt === 'string' ? Date.parse(startedAt) : NaN;
|
|
4
5
|
const plannedDays = duration != null && Number.isFinite(duration) && duration > 0 ? duration : null;
|
|
5
|
-
|
|
6
|
+
if (hasRoundTiming(timing) && Number.isFinite(start) && Number.isFinite(now)) {
|
|
7
|
+
const spec = roundActiveSpec(timing);
|
|
8
|
+
const pauses = timing.pauses ?? [];
|
|
9
|
+
const endsAt = spec.to ? Date.parse(spec.to) : Infinity;
|
|
10
|
+
const from = new Date(start);
|
|
11
|
+
const { days, completed } = roundDays(timing, from, new Date(Math.min(now, endsAt)));
|
|
12
|
+
const week = activeWeek(spec.windows);
|
|
13
|
+
const daysToGo = plannedDays === null ? null : Math.max(0, plannedDays - (now >= endsAt ? days : completed));
|
|
14
|
+
const openPause = pauses.some((pause)=>!pause.to && Date.parse(pause.from) <= now);
|
|
15
|
+
// Even a one-day weekly schedule can fit N active dates within N + 1 weeks.
|
|
16
|
+
const horizon = plannedDays === null ? now : Math.max(now, start) + (plannedDays + 1) * 7 * DAY_MS;
|
|
17
|
+
const end = plannedDays === null || openPause && days < plannedDays ? null : activeDayDate(spec, pauses, {
|
|
18
|
+
from,
|
|
19
|
+
to: new Date(Math.min(horizon, endsAt))
|
|
20
|
+
}, plannedDays);
|
|
21
|
+
return {
|
|
22
|
+
day: plannedDays === null ? days : Math.min(days, plannedDays),
|
|
23
|
+
plannedDays,
|
|
24
|
+
daysToGo,
|
|
25
|
+
end,
|
|
26
|
+
timeZone: spec.tz,
|
|
27
|
+
daysPerWeekend: week.weekendsOnly ? week.days : null,
|
|
28
|
+
weekendsToGo: week.weekendsOnly && daysToGo !== null ? Math.ceil(daysToGo / week.days) : null
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const elapsed = Number.isFinite(start) ? (now - start) / DAY_MS : fallbackElapsedDays;
|
|
6
32
|
// The first 24 hours are Day 1. Countdown includes the part of today still ahead.
|
|
7
33
|
const day = elapsed != null && Number.isFinite(elapsed) ? Math.max(1, Math.floor(elapsed) + 1) : null;
|
|
8
|
-
const end = plannedDays !== null && Number.isFinite(start) ? start + plannedDays *
|
|
34
|
+
const end = plannedDays !== null && Number.isFinite(start) ? start + plannedDays * DAY_MS : null;
|
|
9
35
|
return {
|
|
10
36
|
day: day !== null && plannedDays !== null ? Math.min(day, plannedDays) : day,
|
|
11
37
|
plannedDays,
|
|
12
38
|
end,
|
|
13
|
-
daysToGo: end !== null && Number.isFinite(now) ? Math.max(0, Math.ceil((end - now) /
|
|
39
|
+
daysToGo: end !== null && Number.isFinite(now) ? Math.max(0, Math.ceil((end - now) / DAY_MS)) : null,
|
|
40
|
+
timeZone: undefined,
|
|
41
|
+
weekendsToGo: null,
|
|
42
|
+
daysPerWeekend: null
|
|
14
43
|
};
|
|
15
44
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { RoundTiming } from '../../schedule/types.js';
|
|
2
|
+
import type { PauseAttribution } from '../../types/endpoints.js';
|
|
3
|
+
import type { TestDocument } from '../surface/testDocument.model.js';
|
|
4
|
+
type ScheduleStatus = Pick<TestDocument, 'status' | 'startedAt' | 'schedule' | 'pausedAt' | 'pauseReason' | 'analysis'>;
|
|
5
|
+
export declare function scheduleStatus(doc: ScheduleStatus, now: number, timing?: RoundTiming | null, defaultZone?: string, attribution?: PauseAttribution): {
|
|
6
|
+
status: "scheduled";
|
|
7
|
+
line: string;
|
|
8
|
+
at: number;
|
|
9
|
+
} | {
|
|
10
|
+
status: "paused";
|
|
11
|
+
line: string;
|
|
12
|
+
at?: undefined;
|
|
13
|
+
} | {
|
|
14
|
+
status: "decided" | "draft" | "stopped" | "archived";
|
|
15
|
+
at: number | undefined;
|
|
16
|
+
line?: undefined;
|
|
17
|
+
} | {
|
|
18
|
+
status: "running";
|
|
19
|
+
line: string;
|
|
20
|
+
at?: undefined;
|
|
21
|
+
} | {
|
|
22
|
+
status: "running";
|
|
23
|
+
at: number | undefined;
|
|
24
|
+
line?: undefined;
|
|
25
|
+
} | {
|
|
26
|
+
status: "running";
|
|
27
|
+
line: "On now" | "Off now";
|
|
28
|
+
at: number | undefined;
|
|
29
|
+
} | {
|
|
30
|
+
status: "running";
|
|
31
|
+
line: string;
|
|
32
|
+
at: number;
|
|
33
|
+
};
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { isActive, isValidTimeZone, nextActiveChange } from '../../schedule/activeTime.js';
|
|
2
|
+
import { SCHEDULE_COPY as C, scheduleDate } from '../copy/schedule.js';
|
|
3
|
+
import { displayStatus } from '../labels.js';
|
|
4
|
+
import { roundProgress } from './roundProgress.js';
|
|
5
|
+
export function scheduleStatus(doc, now, timing, defaultZone, attribution) {
|
|
6
|
+
const status = displayStatus(doc, now);
|
|
7
|
+
const saved = doc.schedule ?? timing?.schedule;
|
|
8
|
+
const configuredZone = saved?.timeZone || defaultZone;
|
|
9
|
+
const zone = configuredZone && isValidTimeZone(configuredZone) ? configuredZone : 'UTC';
|
|
10
|
+
const date = new Date(now);
|
|
11
|
+
const startedAt = Date.parse(doc.startedAt ?? '');
|
|
12
|
+
const endAt = Date.parse(saved?.endAt ?? '');
|
|
13
|
+
if (status === 'scheduled') return {
|
|
14
|
+
status,
|
|
15
|
+
line: C.starts(scheduleDate(new Date(startedAt), zone, 'day', date)),
|
|
16
|
+
at: startedAt
|
|
17
|
+
};
|
|
18
|
+
if (status === 'paused') {
|
|
19
|
+
const pause = timing?.pauses?.find((item)=>!item.to);
|
|
20
|
+
const paused = Date.parse(doc.pausedAt ?? pause?.from ?? '');
|
|
21
|
+
const pauses = doc.pausedAt && !pause ? [
|
|
22
|
+
...timing?.pauses ?? [],
|
|
23
|
+
{
|
|
24
|
+
from: doc.pausedAt
|
|
25
|
+
}
|
|
26
|
+
] : timing?.pauses;
|
|
27
|
+
const schedule = timing ? timing.schedule : saved && (saved.startAt || saved.endAt || saved.windows?.length) ? {
|
|
28
|
+
timeZone: zone,
|
|
29
|
+
windows: saved.windows ?? [],
|
|
30
|
+
startAt: saved.startAt ?? undefined,
|
|
31
|
+
endAt: saved.endAt ?? undefined
|
|
32
|
+
} : undefined;
|
|
33
|
+
const progress = roundProgress(doc.startedAt, doc.analysis?.plannedDurationDays, now, undefined, {
|
|
34
|
+
schedule,
|
|
35
|
+
pauses
|
|
36
|
+
});
|
|
37
|
+
const pauseDate = Number.isFinite(paused) ? new Intl.DateTimeFormat('en-US', {
|
|
38
|
+
timeZone: zone,
|
|
39
|
+
month: 'short',
|
|
40
|
+
day: 'numeric'
|
|
41
|
+
}).format(paused) : undefined;
|
|
42
|
+
const name = attribution?.pausedAt === (doc.pausedAt ?? null) ? attribution.name : undefined;
|
|
43
|
+
return {
|
|
44
|
+
status,
|
|
45
|
+
line: C.paused(progress.day == null ? '' : C.day(progress.day, progress.plannedDays), pauseDate, doc.pauseReason?.trim(), name)
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
if (status !== 'running') {
|
|
49
|
+
const start = Date.parse(doc.schedule?.startAt ?? '');
|
|
50
|
+
return {
|
|
51
|
+
status,
|
|
52
|
+
at: (status === 'draft' || status === 'stopped') && start > now ? start : undefined
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if (endAt <= now) return {
|
|
56
|
+
status,
|
|
57
|
+
line: C.ended(scheduleDate(new Date(endAt), zone, 'day', date))
|
|
58
|
+
};
|
|
59
|
+
if (!saved?.windows?.length) return {
|
|
60
|
+
status,
|
|
61
|
+
at: Number.isFinite(endAt) ? endAt : undefined
|
|
62
|
+
};
|
|
63
|
+
const next = nextActiveChange({
|
|
64
|
+
tz: zone,
|
|
65
|
+
from: doc.startedAt ?? undefined,
|
|
66
|
+
to: saved.endAt ?? undefined,
|
|
67
|
+
windows: saved.windows
|
|
68
|
+
}, date);
|
|
69
|
+
if (!next) {
|
|
70
|
+
const active = isActive({
|
|
71
|
+
tz: zone,
|
|
72
|
+
from: doc.startedAt ?? undefined,
|
|
73
|
+
to: saved.endAt ?? undefined,
|
|
74
|
+
windows: saved.windows
|
|
75
|
+
}, [], date);
|
|
76
|
+
return {
|
|
77
|
+
status,
|
|
78
|
+
line: active ? C.onNow : C.offNow,
|
|
79
|
+
at: Number.isFinite(endAt) ? endAt : undefined
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
const localDay = new Intl.DateTimeFormat('en-US', {
|
|
83
|
+
timeZone: zone,
|
|
84
|
+
dateStyle: 'short'
|
|
85
|
+
});
|
|
86
|
+
const sameDay = localDay.format(date) === localDay.format(next.at);
|
|
87
|
+
const when = scheduleDate(next.at, zone, sameDay ? 'time' : 'weekday');
|
|
88
|
+
return {
|
|
89
|
+
status,
|
|
90
|
+
line: next.active ? C.off(when) : C.on(when),
|
|
91
|
+
at: +next.at
|
|
92
|
+
};
|
|
93
|
+
}
|
|
@@ -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
|
|
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
|
|
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:
|
|
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
|
|
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[]
|
|
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;
|