@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
|
@@ -12,15 +12,21 @@ const relationships = new Set([
|
|
|
12
12
|
'metrics.primary',
|
|
13
13
|
'metrics.secondary',
|
|
14
14
|
'metrics.guardrails',
|
|
15
|
+
'pausedBy',
|
|
15
16
|
'decision.decidedBy',
|
|
16
17
|
'decision.pagesReleasedBy',
|
|
17
18
|
'decision.snapshotId'
|
|
18
19
|
]);
|
|
19
20
|
const dates = new Set([
|
|
21
|
+
'claimFrom',
|
|
22
|
+
'claimTo',
|
|
20
23
|
'startedAt',
|
|
21
24
|
'stoppedAt',
|
|
25
|
+
'pausedAt',
|
|
22
26
|
'decidedAt',
|
|
23
27
|
'archivedAt',
|
|
28
|
+
'schedule.startAt',
|
|
29
|
+
'schedule.endAt',
|
|
24
30
|
'decision.discardedAt',
|
|
25
31
|
'decision.holdoutReleasedAt',
|
|
26
32
|
'decision.pagesReleasedAt'
|
|
@@ -42,25 +48,32 @@ const dates = new Set([
|
|
|
42
48
|
const date = new Date(value);
|
|
43
49
|
if (!Number.isNaN(date.valueOf())) return date.toISOString();
|
|
44
50
|
}
|
|
45
|
-
if (Array.isArray(value))
|
|
46
|
-
if (
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
]
|
|
62
|
-
|
|
63
|
-
|
|
51
|
+
if (Array.isArray(value)) {
|
|
52
|
+
if (path === 'schedule.windows' && !value.length) return undefined;
|
|
53
|
+
return value.map((item)=>{
|
|
54
|
+
if (!json && [
|
|
55
|
+
'arms',
|
|
56
|
+
'targeting',
|
|
57
|
+
'schedule.windows'
|
|
58
|
+
].includes(path) && isObject(item)) {
|
|
59
|
+
const { id: _rowId, ...row } = item;
|
|
60
|
+
return normalize(row, path);
|
|
61
|
+
}
|
|
62
|
+
return normalize(item, path, json);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
if (isObject(value)) {
|
|
66
|
+
const entries = Object.keys(value).sort().flatMap((key)=>{
|
|
67
|
+
const nested = normalize(value[key], `${path}.${key}`, json);
|
|
68
|
+
return nested === undefined ? [] : [
|
|
69
|
+
[
|
|
70
|
+
key,
|
|
71
|
+
nested
|
|
72
|
+
]
|
|
73
|
+
];
|
|
74
|
+
});
|
|
75
|
+
return path === 'schedule' && !entries.length ? undefined : Object.fromEntries(entries);
|
|
76
|
+
}
|
|
64
77
|
return value;
|
|
65
78
|
}
|
|
66
79
|
const same = (a, b, path)=>JSON.stringify(normalize(a, path)) === JSON.stringify(normalize(b, path));
|
|
@@ -111,8 +124,13 @@ export const lockHook = async ({ data, originalDoc, operation, req })=>{
|
|
|
111
124
|
for (const field of [
|
|
112
125
|
'seed',
|
|
113
126
|
'layerSlices',
|
|
127
|
+
'claimFrom',
|
|
128
|
+
'claimTo',
|
|
114
129
|
'startedAt',
|
|
115
130
|
'stoppedAt',
|
|
131
|
+
'pausedAt',
|
|
132
|
+
'pausedBy',
|
|
133
|
+
'pauseReason',
|
|
116
134
|
'decidedAt',
|
|
117
135
|
'archivedAt',
|
|
118
136
|
'decision'
|
|
@@ -154,7 +172,8 @@ export const lockHook = async ({ data, originalDoc, operation, req })=>{
|
|
|
154
172
|
if ([
|
|
155
173
|
'analysis',
|
|
156
174
|
'metrics',
|
|
157
|
-
'decision'
|
|
175
|
+
'decision',
|
|
176
|
+
'schedule'
|
|
158
177
|
].includes(field) && isObject(value)) {
|
|
159
178
|
for (const [key, nested] of Object.entries(value))await check(`${field}.${key}`, nested, originalDoc[field]?.[key]);
|
|
160
179
|
} else {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { cohortMembersCollection, cohortsCollection } from './cohortMembers.js';
|
|
1
2
|
import { experimentsCollection } from './experiments/config.js';
|
|
2
3
|
import { phasesCollection } from './phases.js';
|
|
3
4
|
import { layersCollection } from './layers.js';
|
|
@@ -15,7 +16,9 @@ export function buildCollections(options) {
|
|
|
15
16
|
metricsCollection(options),
|
|
16
17
|
eventsCollection(options),
|
|
17
18
|
identitiesCollection(options),
|
|
18
|
-
snapshotsCollection(options)
|
|
19
|
+
snapshotsCollection(options),
|
|
20
|
+
cohortMembersCollection(options),
|
|
21
|
+
cohortsCollection(options)
|
|
19
22
|
],
|
|
20
23
|
globals: [
|
|
21
24
|
stateGlobal(options)
|
package/dist/constants.d.ts
CHANGED
|
@@ -2,9 +2,11 @@ export declare const DEFAULT_SEQUENTIAL_TUNING_PARAMETER = 5000;
|
|
|
2
2
|
export declare const MAX_EVENTS_PER_BODY = 20;
|
|
3
3
|
export declare const DEFAULT_MAX_BODY_BYTES = 8192;
|
|
4
4
|
export declare const XP_COOKIE = "xp_id";
|
|
5
|
+
export declare const XP_COHORT_COOKIE = "xp_c";
|
|
5
6
|
export declare const XP_HEADER = "x-xp-assignments";
|
|
6
7
|
export declare const XP_PREVIEW_PARAM = "xp_preview";
|
|
7
8
|
export declare const XP_MANIFEST_KEY_HEADER = "x-xp-manifest-key";
|
|
8
9
|
export declare const XP_REQUEST_HEADER = "x-xp-request";
|
|
9
10
|
export declare const XP_IF_UPDATED_AT_HEADER = "x-xp-if-updated-at";
|
|
10
11
|
export declare const USER_BROWSER_CONVERSION_PREFIX = "conversion:cu:";
|
|
12
|
+
export declare const COHORT_START_BUDGET_MS = 20000;
|
package/dist/constants.js
CHANGED
|
@@ -2,9 +2,11 @@ export const DEFAULT_SEQUENTIAL_TUNING_PARAMETER = 5000;
|
|
|
2
2
|
export const MAX_EVENTS_PER_BODY = 20;
|
|
3
3
|
export const DEFAULT_MAX_BODY_BYTES = 8192;
|
|
4
4
|
export const XP_COOKIE = 'xp_id';
|
|
5
|
+
export const XP_COHORT_COOKIE = 'xp_c';
|
|
5
6
|
export const XP_HEADER = 'x-xp-assignments';
|
|
6
7
|
export const XP_PREVIEW_PARAM = 'xp_preview';
|
|
7
8
|
export const XP_MANIFEST_KEY_HEADER = 'x-xp-manifest-key';
|
|
8
9
|
export const XP_REQUEST_HEADER = 'x-xp-request';
|
|
9
10
|
export const XP_IF_UPDATED_AT_HEADER = 'x-xp-if-updated-at';
|
|
10
11
|
export const USER_BROWSER_CONVERSION_PREFIX = 'conversion:cu:';
|
|
12
|
+
export const COHORT_START_BUDGET_MS = 20_000;
|
package/dist/db/adapter.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ export declare class XpTransactionIsolationError extends APIError {
|
|
|
5
5
|
/** Payload's initTransaction cannot pass options to the adapter. Like that
|
|
6
6
|
* helper, publish the pending transaction on the request before awaiting it.
|
|
7
7
|
*/
|
|
8
|
-
export declare function initTransitionTransaction(req: PayloadRequest): Promise<boolean>;
|
|
8
|
+
export declare function initTransitionTransaction(req: PayloadRequest, deadline?: number): Promise<boolean>;
|
|
9
9
|
export declare function assertReadCommitted(req: PayloadRequest): Promise<void>;
|
|
10
10
|
export declare function assertPostgresAdapter(payload: Payload): void;
|
|
11
|
+
export declare function usesRelationalBlocks(payload: Payload): boolean;
|
|
11
12
|
export declare function probeTransactions(payload: Payload): Promise<void>;
|
package/dist/db/adapter.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { APIError } from 'payload';
|
|
2
2
|
import { XpNoTransactionError } from '../errors.js';
|
|
3
3
|
import { API_MESSAGES } from '../testSurface/copy/common.js';
|
|
4
|
-
import { transactionSession, txExecutor } from './executor.js';
|
|
4
|
+
import { raceDeadline, ResultsBudgetError, transactionSession, txExecutor } from './executor.js';
|
|
5
5
|
const transitionIsolation = 'read committed';
|
|
6
6
|
const isolationMessage = 'Experiments requires PostgreSQL READ COMMITTED so it can see changes committed while waiting for locks. Set the Postgres adapter\'s transactionOptions.isolationLevel to "read committed" or remove the override.';
|
|
7
7
|
const checkedSessions = new WeakMap();
|
|
@@ -12,17 +12,24 @@ export class XpTransactionIsolationError extends APIError {
|
|
|
12
12
|
}
|
|
13
13
|
/** Payload's initTransaction cannot pass options to the adapter. Like that
|
|
14
14
|
* helper, publish the pending transaction on the request before awaiting it.
|
|
15
|
-
*/ export async function initTransitionTransaction(req) {
|
|
15
|
+
*/ export async function initTransitionTransaction(req, deadline) {
|
|
16
16
|
if (req.transactionID != null) {
|
|
17
17
|
await req.transactionID;
|
|
18
18
|
return false;
|
|
19
19
|
}
|
|
20
|
+
if (deadline !== undefined && Date.now() >= deadline) throw new ResultsBudgetError();
|
|
20
21
|
const db = req.payload.db;
|
|
21
22
|
const pending = db.beginTransaction({
|
|
22
23
|
...db.transactionOptions || {},
|
|
23
24
|
isolationLevel: transitionIsolation
|
|
24
|
-
}).then((id)=>{
|
|
25
|
+
}).then(async (id)=>{
|
|
25
26
|
if (id == null) throw new XpNoTransactionError();
|
|
27
|
+
// Acquisition can finish after the results deadline. Return the connection
|
|
28
|
+
// without exposing the transaction or letting any transition writes start.
|
|
29
|
+
if (deadline !== undefined && Date.now() >= deadline) {
|
|
30
|
+
await db.rollbackTransaction(id);
|
|
31
|
+
throw new ResultsBudgetError();
|
|
32
|
+
}
|
|
26
33
|
const session = db.sessions?.[id];
|
|
27
34
|
if (session) checkedSessions.set(session, Promise.resolve());
|
|
28
35
|
req.transactionID = id;
|
|
@@ -30,10 +37,13 @@ export class XpTransactionIsolationError extends APIError {
|
|
|
30
37
|
});
|
|
31
38
|
req.transactionID = pending;
|
|
32
39
|
try {
|
|
33
|
-
await pending;
|
|
40
|
+
await (deadline === undefined ? pending : raceDeadline(deadline, ()=>pending));
|
|
34
41
|
return true;
|
|
35
42
|
} catch (error) {
|
|
36
43
|
if (req.transactionID === pending) delete req.transactionID;
|
|
44
|
+
// If the timer won before attaching to the already-started acquisition,
|
|
45
|
+
// the late acquisition still rolls back independently.
|
|
46
|
+
if (deadline !== undefined) void pending.catch(()=>{});
|
|
37
47
|
throw error;
|
|
38
48
|
}
|
|
39
49
|
}
|
|
@@ -71,6 +81,9 @@ export function assertPostgresAdapter(payload) {
|
|
|
71
81
|
// @payloadcms/db-postgres/dist/index.js:133 declares this package marker.
|
|
72
82
|
if (payload.db.packageName !== '@payloadcms/db-postgres') throw new Error('Experiments requires @payloadcms/db-postgres');
|
|
73
83
|
}
|
|
84
|
+
export function usesRelationalBlocks(payload) {
|
|
85
|
+
return payload.db.blocksAsJSON !== true;
|
|
86
|
+
}
|
|
74
87
|
export async function probeTransactions(payload) {
|
|
75
88
|
const id = await payload.db.beginTransaction();
|
|
76
89
|
if (id == null) throw new Error('Experiments transactions are disabled');
|
package/dist/db/appends.d.ts
CHANGED
|
@@ -34,7 +34,8 @@ export interface PlacementSavePath {
|
|
|
34
34
|
/** Payload 3.90.2: updateByID starts from the latest version; update (bulk)
|
|
35
35
|
* starts from main rows except draft/trash saves. utilities/update then replaces
|
|
36
36
|
* unselected locales with the latest published version (publishSpecificLocale).
|
|
37
|
-
* Localized
|
|
37
|
+
* Localized status uses the main row for a single-locale publish. The caller
|
|
38
|
+
* selects that base separately. Restore uses the selected version. */
|
|
38
39
|
export declare function placementMergeBase(path: PlacementSavePath): 'restore' | 'main' | 'published' | 'latest';
|
|
39
40
|
export declare function placementWriteContent(req: PayloadRequest, collection: string, id: DocId, main: Record<string, unknown> | undefined, path?: PlacementSavePath): Promise<Record<string, unknown> | undefined>;
|
|
40
41
|
/** Read the main collection row BEFORE the host write. Draft version retention
|
package/dist/db/appends.js
CHANGED
|
@@ -21,7 +21,8 @@ import { qualifiedTable, quoteIdentifier as quote } from './sql.js';
|
|
|
21
21
|
/** Payload 3.90.2: updateByID starts from the latest version; update (bulk)
|
|
22
22
|
* starts from main rows except draft/trash saves. utilities/update then replaces
|
|
23
23
|
* unselected locales with the latest published version (publishSpecificLocale).
|
|
24
|
-
* Localized
|
|
24
|
+
* Localized status uses the main row for a single-locale publish. The caller
|
|
25
|
+
* selects that base separately. Restore uses the selected version. */ export function placementMergeBase(path) {
|
|
25
26
|
if (path.versionId != null) return 'restore';
|
|
26
27
|
if (path.publishSpecificLocale) return 'published';
|
|
27
28
|
return path.bulk && !path.draft && !path.trashing ? 'main' : 'latest';
|
|
@@ -111,7 +112,7 @@ export async function placementWriteContent(req, collection, id, main, path = {}
|
|
|
111
112
|
*/ export async function runningContentExperiment(exec, binding) {
|
|
112
113
|
const table = qualifiedTable(exec, TABLES.experiments);
|
|
113
114
|
const c = COLUMNS.experiments;
|
|
114
|
-
const { rows } = await exec.query(`SELECT ${quote(c.id)} AS id, ${quote(c.phase)} AS phase FROM ${table} WHERE ${quote(c[binding.field])} = $1 AND ${quote(c.status)}
|
|
115
|
+
const { rows } = await exec.query(`SELECT ${quote(c.id)} AS id, ${quote(c.phase)} AS phase FROM ${table} WHERE ${quote(c[binding.field])} = $1 AND ${quote(c.status)} IN ('running', 'paused') LIMIT 1`, [
|
|
115
116
|
binding.value
|
|
116
117
|
]);
|
|
117
118
|
return rows[0];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { PayloadRequest, Where } from 'payload';
|
|
2
2
|
import { type PlacementLocaleView } from '../blocks/placementLocale.js';
|
|
3
|
+
import { type PublicationStatus } from '../blocks/placementPublication.js';
|
|
3
4
|
import type { DocId } from '../types/contracts.js';
|
|
4
5
|
export interface BulkPlacementRemoval {
|
|
5
6
|
documents: Set<string>;
|
|
@@ -8,6 +9,10 @@ export interface BulkPlacementRemoval {
|
|
|
8
9
|
data?: Record<string, unknown>;
|
|
9
10
|
draft: boolean;
|
|
10
11
|
deleting: boolean;
|
|
12
|
+
all?: {
|
|
13
|
+
status: PublicationStatus;
|
|
14
|
+
locales: string[];
|
|
15
|
+
};
|
|
11
16
|
};
|
|
12
17
|
refusals: Map<string, string>;
|
|
13
18
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { placementLocaleContent, mergedPlacementLocales, removedPlacementViews, placementDocumentKey } from '../blocks/placementLocale.js';
|
|
1
|
+
import { localizedPlacementAfter, placementLocaleContent, mergedPlacementLocales, removedPlacementViews, placementDocumentKey } from '../blocks/placementLocale.js';
|
|
2
|
+
import { usesLocalizedPublication } from '../blocks/placementPublication.js';
|
|
2
3
|
// Payload starts/ends a transaction per bulk document with this adapter option.
|
|
3
4
|
export function usesBulkDocumentTransactions(req) {
|
|
4
5
|
return req.payload.db.bulkOperationsSingleTransaction === true;
|
|
@@ -105,7 +106,11 @@ const operationRequestState = Symbol('xpPlacementRequestState');
|
|
|
105
106
|
...input === 'all-locales' ? doc : placementLocaleContent(req, collection, doc, 'all-locales'),
|
|
106
107
|
...change.data
|
|
107
108
|
};
|
|
108
|
-
const
|
|
109
|
+
const localized = usesLocalizedPublication(req, collection);
|
|
110
|
+
const after = localized ? localizedPlacementAfter(req, collection, doc, doc, pending, {
|
|
111
|
+
status: change.data?._status ?? pending._status,
|
|
112
|
+
all: change.all
|
|
113
|
+
}) : input === 'all-locales' ? pending : mergedPlacementLocales(req, collection, doc, pending);
|
|
109
114
|
const views = removedPlacementViews(req, collection, doc, after, change.deleting || after.deletedAt != null || after._status === 'draft', 'all-locales');
|
|
110
115
|
return (views.get(slug) ?? []).some((removed)=>placementDocumentKey(collection, doc.id, removed) === placementDocumentKey(collection, doc.id, view));
|
|
111
116
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Executor } from './pgExecutor.js';
|
|
2
|
+
export type CohortLookupArgs = {
|
|
3
|
+
keys: string[];
|
|
4
|
+
visitorId?: string;
|
|
5
|
+
userId?: string;
|
|
6
|
+
};
|
|
7
|
+
/** CTEs usable in a query or a correlated LATERAL subquery. The two inputs are
|
|
8
|
+
* trusted SQL expressions, normally bind parameters or typed input columns. */
|
|
9
|
+
export declare function cohortIdentitySet(exec: Partial<Executor>, visitor: string, user: string): string;
|
|
10
|
+
export declare function cohortMembershipQuery(exec: Partial<Executor>, keys?: string, visitor?: string, user?: string): string;
|
|
11
|
+
export declare function lookupCohortMembership(exec: Executor, { keys, visitorId, userId }: CohortLookupArgs): Promise<Set<string>>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { COLUMNS, TABLES } from './names.js';
|
|
2
|
+
import { qualifiedTable, quoteIdentifier as q } from './sql.js';
|
|
3
|
+
/** CTEs usable in a query or a correlated LATERAL subquery. The two inputs are
|
|
4
|
+
* trusted SQL expressions, normally bind parameters or typed input columns. */ export function cohortIdentitySet(exec, visitor, user) {
|
|
5
|
+
const identities = qualifiedTable(exec, TABLES.identities);
|
|
6
|
+
const i = COLUMNS.identities;
|
|
7
|
+
return `me AS (
|
|
8
|
+
SELECT (${visitor})::text AS id WHERE (${visitor})::text IS NOT NULL
|
|
9
|
+
UNION SELECT (${user})::text WHERE (${user})::text IS NOT NULL
|
|
10
|
+
UNION SELECT ${q(i.userId)} FROM ${identities} WHERE ${q(i.anonymousId)} = (${visitor})::text
|
|
11
|
+
), ids AS (
|
|
12
|
+
SELECT id FROM me
|
|
13
|
+
UNION SELECT ${q(i.anonymousId)} FROM ${identities} WHERE ${q(i.userId)} IN (SELECT id FROM me)
|
|
14
|
+
)`;
|
|
15
|
+
}
|
|
16
|
+
export function cohortMembershipQuery(exec, keys = '$1', visitor = '$2', user = '$3') {
|
|
17
|
+
const members = qualifiedTable(exec, TABLES.cohortMembers);
|
|
18
|
+
const { cohortKey, unitId, exitedAt } = COLUMNS.cohortMembers;
|
|
19
|
+
// Any current member among the person's linked IDs counts, even if other IDs saw a different arm.
|
|
20
|
+
return `WITH ${cohortIdentitySet(exec, visitor, user)}
|
|
21
|
+
SELECT DISTINCT ${q(cohortKey)} FROM ${members}
|
|
22
|
+
WHERE ${q(cohortKey)} = ANY(${keys}::text[]) AND ${q(unitId)} IN (SELECT id FROM ids) AND ${q(exitedAt)} IS NULL`;
|
|
23
|
+
}
|
|
24
|
+
export async function lookupCohortMembership(exec, { keys, visitorId, userId }) {
|
|
25
|
+
const { rows } = await exec.query(cohortMembershipQuery(exec), [
|
|
26
|
+
keys,
|
|
27
|
+
visitorId ?? null,
|
|
28
|
+
userId ?? null
|
|
29
|
+
]);
|
|
30
|
+
return new Set(rows.map((row)=>row.cohort_key));
|
|
31
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Pool } from 'pg';
|
|
2
|
+
import type { Payload } from 'payload';
|
|
3
|
+
import { type CohortLookupArgs } from './cohortMembership.js';
|
|
4
|
+
export declare const COHORT_LOOKUP_TIMEOUT_MS = 200;
|
|
5
|
+
export declare function lookupPooledCohorts(pool: Pool, schemaName: string | undefined, { keys, visitorId, userId }: CohortLookupArgs): Promise<Set<string>>;
|
|
6
|
+
export declare function payloadCohortPool(payload: Payload): {
|
|
7
|
+
pool: Pool;
|
|
8
|
+
schemaName?: string;
|
|
9
|
+
} | undefined;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { cohortMembershipQuery } from './cohortMembership.js';
|
|
2
|
+
import { connectionError, raceDeadline, ResultsBudgetError } from './pgExecutor.js';
|
|
3
|
+
export const COHORT_LOOKUP_TIMEOUT_MS = 200;
|
|
4
|
+
export async function lookupPooledCohorts(pool, schemaName, { keys, visitorId, userId }) {
|
|
5
|
+
const deadline = Date.now() + COHORT_LOOKUP_TIMEOUT_MS;
|
|
6
|
+
if (keys.some((key)=>typeof key !== 'string' || key.length !== 16 || /[^0-9a-f]/.test(key))) {
|
|
7
|
+
throw new Error('Invalid cohort key');
|
|
8
|
+
}
|
|
9
|
+
if (visitorId !== undefined && (typeof visitorId !== 'string' || !visitorId.length || /[^A-Za-z0-9_-]/.test(visitorId))) {
|
|
10
|
+
throw new Error('Invalid cohort visitor id');
|
|
11
|
+
}
|
|
12
|
+
if (!keys.length || !visitorId && !userId) return new Set();
|
|
13
|
+
const keyArray = `ARRAY[${keys.map((key)=>`'${key}'`).join(', ')}]`;
|
|
14
|
+
const visitor = visitorId === undefined ? 'NULL' : `'${visitorId}'`;
|
|
15
|
+
const user = userId === undefined ? 'NULL' : `convert_from(decode('${Buffer.from(userId, 'utf8').toString('hex')}', 'hex'), 'UTF8')`;
|
|
16
|
+
// A single simple Query runs both statements in an implicit transaction.
|
|
17
|
+
// PostgreSQL restores SET LOCAL when that transaction ends, including on cancellation.
|
|
18
|
+
const sql = `SET LOCAL statement_timeout = 150; ${cohortMembershipQuery({
|
|
19
|
+
schemaName
|
|
20
|
+
}, keyArray, visitor, user)}`;
|
|
21
|
+
let client;
|
|
22
|
+
let releaseError;
|
|
23
|
+
let finished = false;
|
|
24
|
+
try {
|
|
25
|
+
return await raceDeadline(deadline, async ()=>{
|
|
26
|
+
const acquired = await pool.connect();
|
|
27
|
+
if (finished) {
|
|
28
|
+
acquired.release();
|
|
29
|
+
throw new ResultsBudgetError();
|
|
30
|
+
}
|
|
31
|
+
client = acquired;
|
|
32
|
+
if (Date.now() >= deadline) throw new ResultsBudgetError();
|
|
33
|
+
const results = await acquired.query(sql);
|
|
34
|
+
const select = Array.isArray(results) ? results.at(-1) : undefined;
|
|
35
|
+
if (select?.command !== 'SELECT') throw new Error('Cohort lookup returned no SELECT result');
|
|
36
|
+
return new Set(select.rows.map((row)=>row.cohort_key));
|
|
37
|
+
});
|
|
38
|
+
} catch (error) {
|
|
39
|
+
releaseError = connectionError(error);
|
|
40
|
+
throw error;
|
|
41
|
+
} finally{
|
|
42
|
+
finished = true;
|
|
43
|
+
client?.release(releaseError);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export function payloadCohortPool(payload) {
|
|
47
|
+
// §0.5 cohorts: cohort lookup (design 2026-12-04 §8), using the adapter's pool directly.
|
|
48
|
+
const db = payload.db;
|
|
49
|
+
return db?.pool ? {
|
|
50
|
+
pool: db.pool,
|
|
51
|
+
schemaName: db.schemaName
|
|
52
|
+
} : undefined;
|
|
53
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { resultsExecutor } from './snapshots.js';
|
|
2
|
+
import { raceDeadline, ResultsBudgetError, txExecutor } from './executor.js';
|
|
3
|
+
import { currentTxid, txidStatus } from './txid.js';
|
|
4
|
+
import { XpRefusal } from '../errors.js';
|
|
5
|
+
export async function inCohortTransaction(payload, deadline, work) {
|
|
6
|
+
let abandoned = false;
|
|
7
|
+
const begin = async ()=>{
|
|
8
|
+
const db = payload.db;
|
|
9
|
+
const id = await db.beginTransaction({
|
|
10
|
+
...db.transactionOptions,
|
|
11
|
+
isolationLevel: 'read committed'
|
|
12
|
+
});
|
|
13
|
+
if (id == null) throw new Error('Experiments: cohort writes require a transaction');
|
|
14
|
+
if (abandoned) await payload.db.rollbackTransaction(id);
|
|
15
|
+
return id;
|
|
16
|
+
};
|
|
17
|
+
let transactionID;
|
|
18
|
+
try {
|
|
19
|
+
transactionID = await raceDeadline(deadline, begin);
|
|
20
|
+
} catch (error) {
|
|
21
|
+
abandoned = true;
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
const exec = txExecutor({
|
|
25
|
+
payload,
|
|
26
|
+
transactionID
|
|
27
|
+
});
|
|
28
|
+
let xid;
|
|
29
|
+
let result;
|
|
30
|
+
try {
|
|
31
|
+
result = await raceDeadline(deadline, ()=>work(exec));
|
|
32
|
+
xid = await raceDeadline(deadline, ()=>currentTxid(exec));
|
|
33
|
+
if (Date.now() >= deadline) {
|
|
34
|
+
throw new ResultsBudgetError();
|
|
35
|
+
}
|
|
36
|
+
} catch (error) {
|
|
37
|
+
const rollback = payload.db.rollbackTransaction(transactionID);
|
|
38
|
+
// Observe a late rollback without allowing it to block the remaining cron work.
|
|
39
|
+
void rollback.catch(()=>undefined);
|
|
40
|
+
if (Date.now() < deadline) await raceDeadline(deadline, ()=>rollback).catch(()=>undefined);
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
// No rollback once commit has started. If it settles late, the next attempt
|
|
44
|
+
// rechecks the registry under the key lock before using or refreshing it.
|
|
45
|
+
const commit = payload.db.commitTransaction(transactionID);
|
|
46
|
+
void commit.catch(()=>undefined);
|
|
47
|
+
await raceDeadline(deadline, ()=>commit);
|
|
48
|
+
if (await txidStatus(resultsExecutor(payload, ()=>deadline - Date.now()), xid) !== 'committed') {
|
|
49
|
+
throw new XpRefusal('commit-unverified', 'The cohort build commit could not be verified.', undefined, 500);
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { FrozenCohortRule } from '../cohorts/rule.js';
|
|
2
|
+
import type { ActiveSpec, RoundTiming } from '../schedule/types.js';
|
|
3
|
+
import type { ResultsPhase } from './snapshots.js';
|
|
4
|
+
import type { DocId, UnitType } from '../types/contracts.js';
|
|
5
|
+
import { type Executor } from './executor.js';
|
|
6
|
+
export type CohortSource = {
|
|
7
|
+
phase: ResultsPhase;
|
|
8
|
+
unitType: UnitType;
|
|
9
|
+
};
|
|
10
|
+
export type CohortRegistry = {
|
|
11
|
+
key: string;
|
|
12
|
+
rule: Omit<FrozenCohortRule, 'include'>;
|
|
13
|
+
closed: boolean;
|
|
14
|
+
members: number;
|
|
15
|
+
builtAt: string;
|
|
16
|
+
};
|
|
17
|
+
type ExposureQuery = {
|
|
18
|
+
experiment: DocId;
|
|
19
|
+
phase: number;
|
|
20
|
+
to: Date;
|
|
21
|
+
from?: Date;
|
|
22
|
+
inactive: Array<{
|
|
23
|
+
from: Date;
|
|
24
|
+
to: Date;
|
|
25
|
+
}>;
|
|
26
|
+
};
|
|
27
|
+
/** Exclude the same half-open intervals from cohort membership and results. */
|
|
28
|
+
export declare function inactiveRangesPredicate(column: string, fromParam: string, toParam: string): string;
|
|
29
|
+
/** Append the bound inactive ranges to the results query. */
|
|
30
|
+
export declare function inactiveTimeFilter(spec: ActiveSpec, pauses: NonNullable<RoundTiming['pauses']>, range: {
|
|
31
|
+
from: Date;
|
|
32
|
+
to: Date;
|
|
33
|
+
}, params: unknown[], alias?: string): string;
|
|
34
|
+
export declare function sourceExposureCount(exec: Executor, query: ExposureQuery): Promise<number>;
|
|
35
|
+
export declare function hasExposure(exec: Executor, query: ExposureQuery): Promise<boolean>;
|
|
36
|
+
export declare function cohortExposureUnits(exec: Executor, query: ExposureQuery): Promise<{
|
|
37
|
+
unitId: string;
|
|
38
|
+
arm: string;
|
|
39
|
+
firstTs: string;
|
|
40
|
+
}[]>;
|
|
41
|
+
export declare function replaceExposureCohort(exec: Executor, key: string, now: Date, query: ExposureQuery, arms: readonly string[]): Promise<number>;
|
|
42
|
+
export declare function replaceGoalCohort(exec: Executor, key: string, now: Date, ids: readonly string[]): Promise<number>;
|
|
43
|
+
export declare function readCohort(exec: Executor, key: string): Promise<CohortRegistry | undefined>;
|
|
44
|
+
export declare function writeCohort(exec: Executor, rule: FrozenCohortRule, { closed, members, now }: {
|
|
45
|
+
closed: boolean;
|
|
46
|
+
members: number;
|
|
47
|
+
now: Date;
|
|
48
|
+
}): Promise<void>;
|
|
49
|
+
export declare function readCohortSource(exec: Executor, experiment: DocId, phase: number | 'latest'): Promise<CohortSource | undefined>;
|
|
50
|
+
/** Managers may see the latest test round's dates and number. Frozen settings
|
|
51
|
+
* and snapshots are still read through Payload under readResults. */
|
|
52
|
+
export declare function latestCohortRounds(exec: Executor, ids: DocId[]): Promise<{
|
|
53
|
+
id: DocId;
|
|
54
|
+
phase: number;
|
|
55
|
+
startedAt: string | Date;
|
|
56
|
+
endedAt: string | Date | null;
|
|
57
|
+
}[]>;
|
|
58
|
+
export declare function cohortDependencies(exec: Executor, experiment: DocId): Promise<string[]>;
|
|
59
|
+
export declare function referencedCohortKeys(exec: Executor): Promise<string[]>;
|
|
60
|
+
export declare function cohortIsReferenced(exec: Executor, key: string): Promise<boolean>;
|
|
61
|
+
export declare function refreshableCohortKeys(exec: Executor): Promise<string[]>;
|
|
62
|
+
export declare function sweepableCohortKeys(exec: Executor, stale: Date, cutoff: Date): Promise<string[]>;
|
|
63
|
+
/** Recheck after obtaining the key lock in case Start claimed it meanwhile. */
|
|
64
|
+
export declare function sweepCohortKey(exec: Executor, key: string, stale: Date, cutoff: Date): Promise<void>;
|
|
65
|
+
export declare function cohortExitedUnits(exec: Executor, rule: FrozenCohortRule, unitType: UnitType, units: ReadonlyMap<string, {
|
|
66
|
+
firstTs: Date | string | number;
|
|
67
|
+
}>): Promise<Set<string>>;
|
|
68
|
+
export declare function isCohortTimeout(error: unknown): boolean;
|
|
69
|
+
/** The wrapped executor stays on the caller's transaction. A failed statement
|
|
70
|
+
* aborts it, so rollback restores settings. On success restore them explicitly. */
|
|
71
|
+
export declare function withCohortTimeout<T>(exec: Executor, deadline: number, work: (timed: Executor) => Promise<T>): Promise<T>;
|
|
72
|
+
export {};
|