@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.
- package/README.md +10 -4
- 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/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 +1 -1
- package/dist/db/adapter.js +14 -4
- package/dist/db/appends.js +1 -1
- 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/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.js +1 -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/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.js +7 -4
- package/dist/hooks/pageGuard.js +1 -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 -1
- 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/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 +46 -10
- 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 +35 -11
- 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.js +1 -1
- 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 +136 -55
- 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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isValidTimeZone } from '../../schedule/activeTime.js';
|
|
1
2
|
import { controlVersionName } from '../../labels/arms.js';
|
|
2
3
|
export const PLACEMENT_FAILURE_COPY = {
|
|
3
4
|
'placements-failed': "Couldn't check where this test is used. Try again.",
|
|
@@ -69,6 +70,37 @@ export const READINESS_COPY = {
|
|
|
69
70
|
};
|
|
70
71
|
export const unsupportedContentCopy = (page)=>`${page} has more than one language, so Make it the content isn't available for it; you'll copy the winning version by hand.`;
|
|
71
72
|
export const pageInUseCopy = (path, version = false, label)=>version ? `${path} is already in another running or decided test. Make a new copy of ${controlVersionName(label)} for this version, or finish that test first.` : `Another running or decided test already uses ${path}. Choose a different page, or finish that test first.`;
|
|
73
|
+
export function occupiedInRangeCopy(detail, place = detail.place ?? 'page') {
|
|
74
|
+
const zone = detail.timeZone && isValidTimeZone(detail.timeZone) ? detail.timeZone : 'UTC';
|
|
75
|
+
const from = new Intl.DateTimeFormat('en-US', {
|
|
76
|
+
timeZone: zone,
|
|
77
|
+
month: 'short',
|
|
78
|
+
day: 'numeric'
|
|
79
|
+
}).format(new Date(detail.from));
|
|
80
|
+
return `${detail.otherTestName} uses this ${place} from ${from}.`;
|
|
81
|
+
}
|
|
82
|
+
export function occupancyMessage(value) {
|
|
83
|
+
if (!value || typeof value !== 'object') return undefined;
|
|
84
|
+
const { otherTestName, from, place, timeZone } = value;
|
|
85
|
+
if (typeof otherTestName !== 'string' || !otherTestName.trim() || typeof from !== 'string' || !Number.isFinite(Date.parse(from))) return undefined;
|
|
86
|
+
return occupiedInRangeCopy({
|
|
87
|
+
otherTestName,
|
|
88
|
+
from,
|
|
89
|
+
timeZone,
|
|
90
|
+
place: place === 'setting' || place === 'traffic group' ? place : 'page'
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
export const scheduleOccupancyCopy = {
|
|
94
|
+
invalidStart: 'Choose a valid start time.',
|
|
95
|
+
pastEnd: 'Choose an end time after the test starts.',
|
|
96
|
+
timeZone: 'Choose a valid time zone for this schedule.',
|
|
97
|
+
windows: 'Choose at least one day for each time window.',
|
|
98
|
+
notLive: 'This test has not gone live. You can cancel a scheduled start before it goes live.',
|
|
99
|
+
notPausable: 'A rollout cannot be paused.',
|
|
100
|
+
paused: 'Resume this test before changing how many people take part.',
|
|
101
|
+
reschedulePast: 'Choose an end time in the future and after the test starts.',
|
|
102
|
+
scheduleStarted: 'You can only cancel a schedule before the test goes live and before anyone has taken part.'
|
|
103
|
+
};
|
|
72
104
|
export const unpublishedPageCopy = (path, context, label)=>!context ? `${path} isn't a published page yet. Publish it, or choose another page.` : context.original ? `${path} isn't published, so it can't be ${controlVersionName(label)}. Publish it, or choose another page.` : context.found ? `${path} is still a draft. Publish it in ${context.collection} to get it ready for the test.` : `${path} isn't published yet, or no page has that address. Publish it in ${context.collection}, or choose another page.`;
|
|
73
105
|
/** Old responses may include raw host errors; unknown strings use authored copy. */ export const placementFailureCopy = (reason)=>PLACEMENT_FAILURE_COPY[typeof reason === 'string' && Object.hasOwn(PLACEMENT_FAILURE_COPY, reason) ? reason : 'placements-failed'];
|
|
74
106
|
const withoutPeriod = (value)=>value.trim().replace(/[.!?]+$/, '');
|
|
@@ -94,28 +126,29 @@ export const attributeNext = (attribute)=>`Remove the rule on ${attribute}: it i
|
|
|
94
126
|
export const firstStartOnlyCopy = (status)=>`Only a draft that has never started can start this way. The test is currently ${status === 'draft' ? 'a draft' : status}.`;
|
|
95
127
|
export const stoppedCopy = (date)=>`Stopped${date ? ` ${date}` : ''}. You can edit the versions, goal, audience or length. Starting again resets the results.`;
|
|
96
128
|
export const decidedCopy = (date, winner)=>`Decided${date ? ` ${date}` : ''}: ${winner}.`;
|
|
97
|
-
function daysToGoCopy(days) {
|
|
129
|
+
function daysToGoCopy(days, weekends) {
|
|
98
130
|
if (days === null) return null;
|
|
99
131
|
if (days === 0) return 'past the planned end';
|
|
100
132
|
if (days === 1) return 'last planned day';
|
|
133
|
+
if (weekends !== null) return `about ${weekends} ${weekends === 1 ? 'weekend' : 'weekends'} to go`;
|
|
101
134
|
return `about ${days} days to go`;
|
|
102
135
|
}
|
|
103
|
-
export const runningCopy = (date, people, days)=>[
|
|
136
|
+
export const runningCopy = (date, people, days, weekends = null)=>[
|
|
104
137
|
date ? `Running since ${date}` : READINESS_COPY.running,
|
|
105
138
|
people === null ? null : `${people.toLocaleString('en-US')} people so far`,
|
|
106
|
-
daysToGoCopy(days)
|
|
139
|
+
daysToGoCopy(days, weekends)
|
|
107
140
|
].filter(Boolean).join(' · ');
|
|
108
|
-
export const lastBlockPlacementCopy = (name, removingPage = false)=>removingPage ? `“${name}” is
|
|
109
|
-
export const hiddenBlockPlacementCopy = (name)=>`“${name}” is
|
|
110
|
-
export const bulkBlockRemovalCopy = (name)=>`“${name}” is
|
|
111
|
-
export const pendingBlockRemovalCopy = (name)=>`“${name}” is
|
|
112
|
-
/** After archive the guard protects the winner and the Original; only the winner page is "the winner". */ export const pageGuardCopy = (name, status, role = 'winner')=>status === 'archived' ? role === 'original' ? `This page's address now shows the winner of the finished test "${name}". Use "Release pages" on the test to free it.` : `This page is shown at other addresses because the finished test "${name}" made it the winner. Use "Release pages" on the test to free it.` : status === 'decided' ? `This page is part of the decided test "${name}". Choose "Make it the content" or "Discard winner" on the test before you delete, rename or unpublish it.` : `This page is part of the
|
|
141
|
+
export const lastBlockPlacementCopy = (name, removingPage = false, status = 'running')=>removingPage ? `“${name}” is ${status} and this page is the only published place it appears. Stop the test first.` : `“${name}” is ${status} and this is the only published place it appears. Stop the test, or keep its block on this page.`;
|
|
142
|
+
export const hiddenBlockPlacementCopy = (name, status = 'running')=>`“${name}” is ${status} and this is the only published place it appears. Stop the test first, or keep its block visible on this page.`;
|
|
143
|
+
export const bulkBlockRemovalCopy = (name, status = 'running')=>`“${name}” is ${status} and the pages in this change are the only published places it appears. Stop the test first.`;
|
|
144
|
+
export const pendingBlockRemovalCopy = (name, status = 'running')=>`“${name}” is ${status} and the pages in this change are the only published places it appears. Stop the test first, or change these pages one at a time.`;
|
|
145
|
+
/** After archive the guard protects the winner and the Original; only the winner page is "the winner". */ export const pageGuardCopy = (name, status, role = 'winner')=>status === 'archived' ? role === 'original' ? `This page's address now shows the winner of the finished test "${name}". Use "Release pages" on the test to free it.` : `This page is shown at other addresses because the finished test "${name}" made it the winner. Use "Release pages" on the test to free it.` : status === 'decided' ? `This page is part of the decided test "${name}". Choose "Make it the content" or "Discard winner" on the test before you delete, rename or unpublish it.` : `This page is part of the ${status} test "${name}". Stop the test before you delete, rename or unpublish it.`;
|
|
113
146
|
export const versionPageUnavailableCopy = (path, status = 'running')=>`${path} isn't published, so visitors assigned to it see an error. Republish it, or ${status === 'decided' ? 'discard the winner' : 'stop the test'}.`;
|
|
114
147
|
export const versionPageUncheckedCopy = (path, status = 'running')=>`Couldn't check whether ${path} is published. Check that it is still published, or ${status === 'decided' ? 'discard the winner' : 'stop the test'}.`;
|
|
115
148
|
export const sameAddressCopy = (label, other, path)=>`${label} has the same address (${path}) as ${other}. Choose a different page.`;
|
|
116
149
|
export const identicalVersionCopy = (version, control)=>`${version} looks the same as ${control}, so the test would compare nothing. Change it before you start.`;
|
|
117
150
|
/** Keep named actions aligned with the actual transition buttons. */ export function placementGuardCopy(page, block, preExisting) {
|
|
118
|
-
const action = (test)=>test.status === 'running' ? `stop ${test.name}` : `choose "Make it the content" or "Discard winner" on ${test.name}`;
|
|
151
|
+
const action = (test)=>test.status === 'running' || test.status === 'paused' ? `stop ${test.name}` : `choose "Make it the content" or "Discard winner" on ${test.name}`;
|
|
119
152
|
return preExisting ? `This page is in two tests that change it, ${page.name} and ${block.name}. Before you publish, ${action(page)} or ${action(block)}.` : `This page is part of the ${page.status} test ${page.name}, so a block from another test can't be added to it. Finish one of the tests first.`;
|
|
120
153
|
}
|
|
121
154
|
export function interactingTestsCopy(page, state, name, version = false) {
|
|
@@ -107,6 +107,7 @@ export declare const shippingTitle: (winner: string) => string;
|
|
|
107
107
|
export declare const keepRunningTo: (date: string) => string;
|
|
108
108
|
export declare const pastPlannedEnd: (date: string) => string;
|
|
109
109
|
export declare const moreDays: (days: string) => string;
|
|
110
|
+
export declare const moreWeekends: (weekends: string) => string;
|
|
110
111
|
export declare const collectingCopy: (n: string, minimum: string, conversions: string, conversionMinimum: string) => string;
|
|
111
112
|
export declare const uncappedTotal: (total: string) => string;
|
|
112
113
|
export declare const cappedCount: (count: string, cap: string) => string;
|
|
@@ -108,6 +108,7 @@ export const shippingTitle = (winner)=>`Since shipping ${winner}`;
|
|
|
108
108
|
export const keepRunningTo = (date)=>`Keep running to the planned end (${date}).`;
|
|
109
109
|
export const pastPlannedEnd = (date)=>`The planned end was ${date}.`;
|
|
110
110
|
export const moreDays = (days)=>`At this traffic, a clear answer needs about ${days} more ${days === '1' ? 'day' : 'days'}.`;
|
|
111
|
+
export const moreWeekends = (weekends)=>`At this traffic, a clear answer needs about ${weekends} more ${weekends === '1' ? 'weekend' : 'weekends'}.`;
|
|
111
112
|
export const collectingCopy = (n, minimum, conversions, conversionMinimum)=>`${n} of ${minimum} people, ${conversions} of ${conversionMinimum} conversions`;
|
|
112
113
|
export const uncappedTotal = (total)=>`Total ${total} (not capped)`;
|
|
113
114
|
export const cappedCount = (count, cap)=>`${count} capped at ${cap}`;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { ScheduleWindow, Weekday } from '../../schedule/types.js';
|
|
2
|
+
export declare const SCHEDULE_COPY: {
|
|
3
|
+
readonly heading: "When it runs";
|
|
4
|
+
readonly start: "Start date and time (optional)";
|
|
5
|
+
readonly end: "End date and time (optional)";
|
|
6
|
+
readonly savedStart: "Start date and time";
|
|
7
|
+
readonly savedEnd: "End date and time";
|
|
8
|
+
readonly timeZone: "Time zone";
|
|
9
|
+
readonly zoneHelp: "Dates and times use this time zone. Changing it keeps the clock times you entered.";
|
|
10
|
+
readonly chooseZone: "Choose a time zone";
|
|
11
|
+
readonly windows: "Recurring hours";
|
|
12
|
+
readonly windowHelp: "Add hours to run only on selected days. Leave this empty to run at all hours.";
|
|
13
|
+
readonly window: (index: number) => string;
|
|
14
|
+
readonly add: "Add hours";
|
|
15
|
+
readonly remove: (index: number) => string;
|
|
16
|
+
readonly weekdays: "Weekdays";
|
|
17
|
+
readonly weekends: "Weekends";
|
|
18
|
+
readonly days: Record<Weekday, string>;
|
|
19
|
+
readonly fullDays: {
|
|
20
|
+
readonly mon: "Monday";
|
|
21
|
+
readonly tue: "Tuesday";
|
|
22
|
+
readonly wed: "Wednesday";
|
|
23
|
+
readonly thu: "Thursday";
|
|
24
|
+
readonly fri: "Friday";
|
|
25
|
+
readonly sat: "Saturday";
|
|
26
|
+
readonly sun: "Sunday";
|
|
27
|
+
};
|
|
28
|
+
readonly from: "From";
|
|
29
|
+
readonly to: "To";
|
|
30
|
+
readonly overnight: "Ends the next morning";
|
|
31
|
+
readonly save: "Save schedule";
|
|
32
|
+
readonly discard: "Discard schedule edits";
|
|
33
|
+
readonly changed: "The saved schedule changed. Discard your edits to see the latest schedule.";
|
|
34
|
+
readonly invalidTime: "Choose a date and time that exists in this time zone.";
|
|
35
|
+
readonly invalidHours: "Enter a start and end time for each window.";
|
|
36
|
+
readonly noZone: "Choose a time zone to set dates and recurring hours.";
|
|
37
|
+
readonly allHours: "at all hours";
|
|
38
|
+
readonly noSchedule: "Runs at all hours once started.";
|
|
39
|
+
readonly starts: (date: string) => string;
|
|
40
|
+
readonly off: (date: string) => string;
|
|
41
|
+
readonly on: (date: string) => string;
|
|
42
|
+
readonly onNow: "On now";
|
|
43
|
+
readonly offNow: "Off now";
|
|
44
|
+
readonly ended: (date: string) => string;
|
|
45
|
+
readonly paused: (progress: string, date?: string, reason?: string, name?: string) => string;
|
|
46
|
+
readonly day: (day: number, planned: number | null) => string;
|
|
47
|
+
};
|
|
48
|
+
export declare function scheduleZoneName(timeZone: string, at: Date): string;
|
|
49
|
+
export declare function scheduleDate(at: Date, timeZone: string, date?: 'day' | 'weekday' | 'time', now?: Date): string;
|
|
50
|
+
export declare function scheduleSummary({ startAt, endAt, timeZone, windows }: {
|
|
51
|
+
startAt?: string | null;
|
|
52
|
+
endAt?: string | null;
|
|
53
|
+
timeZone: string;
|
|
54
|
+
windows: ScheduleWindow[];
|
|
55
|
+
}, now: Date): string;
|
|
56
|
+
export declare function scheduleWindowsCopy(windows: ScheduleWindow[], timeZone: string, at: Date): string;
|
|
57
|
+
export declare const schedulePopulationCopy: (summary: string) => string;
|
|
58
|
+
export declare const pausedShareCopy: (days: number) => string;
|
|
@@ -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
|
+
}
|