@delmaredigital/payload-experiments 0.4.0-rc.7 → 0.4.0-rc.9
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 +12 -12
- package/dist/admin/blocks/model.js +2 -2
- package/dist/admin/copy/blocks.js +1 -1
- package/dist/admin/surface/ResultsRoute.js +17 -11
- package/dist/admin/surface/TestsHome.js +53 -20
- package/dist/admin/surface/newTest/PageWizard.js +8 -2
- package/dist/admin/surface/results/ResultsHeader.js +11 -6
- package/dist/admin/surface/test/TestPage.js +3 -3
- package/dist/blocks/formState.js +1 -1
- package/dist/collections/experiments/config.js +8 -3
- package/dist/collections/experiments/deleteGuard.js +2 -2
- package/dist/collections/experiments/lockHook.js +21 -2
- package/dist/collections/experiments/pickSlug.js +2 -0
- package/dist/collections/metricsGuards.js +2 -0
- package/dist/collections/serialize.js +5 -4
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/db/adapter.d.ts +9 -1
- package/dist/db/adapter.js +77 -1
- package/dist/db/delete.d.ts +1 -1
- package/dist/db/delete.js +2 -4
- package/dist/db/events.d.ts +9 -0
- package/dist/db/events.js +42 -8
- package/dist/db/executor.d.ts +7 -1
- package/dist/db/executor.js +7 -3
- package/dist/db/results.d.ts +5 -1
- package/dist/db/results.js +21 -5
- package/dist/db/snapshots.d.ts +1 -0
- package/dist/endpoints/deleteImpact.js +2 -1
- package/dist/endpoints/events.js +103 -39
- package/dist/endpoints/index.js +2 -8
- package/dist/endpoints/placementStatus.js +7 -4
- package/dist/endpoints/results.d.ts +1 -1
- package/dist/endpoints/results.js +6 -2
- package/dist/endpoints/routeId.d.ts +2 -2
- package/dist/endpoints/routeId.js +11 -5
- package/dist/endpoints/summary.js +46 -12
- package/dist/endpoints/transitions.js +37 -24
- package/dist/errors.d.ts +4 -0
- package/dist/errors.js +6 -0
- package/dist/events/request.d.ts +6 -2
- package/dist/events/request.js +35 -8
- package/dist/events/rows.d.ts +1 -1
- package/dist/events/rows.js +24 -8
- package/dist/events/writable.d.ts +9 -0
- package/dist/events/writable.js +13 -0
- package/dist/exports/index.d.ts +1 -1
- package/dist/exports/rsc.d.ts +1 -0
- package/dist/exports/rsc.js +1 -0
- package/dist/goals/fairness.js +2 -2
- package/dist/hooks/hostHook.js +6 -2
- package/dist/hooks/pageGuard.js +4 -0
- package/dist/lib/fetchAllDocs.d.ts +1 -1
- package/dist/manifest/compile.js +8 -5
- package/dist/onInit.js +14 -0
- package/dist/options.js +5 -0
- package/dist/proxy/pageNavigation.d.ts +4 -0
- package/dist/proxy/pageNavigation.js +28 -0
- package/dist/proxy/resolve.js +52 -25
- package/dist/puck/editor/ConfigureTestDrawer.js +5 -4
- package/dist/puck/editor/ExperimentSlotEditor.js +182 -58
- package/dist/puck/editor/QuickTestActions.d.ts +5 -2
- package/dist/puck/editor/QuickTestActions.js +16 -4
- package/dist/puck/editor/ResultsReadout.d.ts +2 -1
- package/dist/puck/editor/ResultsReadout.js +2 -1
- package/dist/puck/editor/VersionBuilder.d.ts +13 -2
- package/dist/puck/editor/VersionBuilder.js +133 -49
- package/dist/puck/editor/armWrites.js +1 -1
- package/dist/puck/editor/armsCache.js +1 -3
- package/dist/puck/editor/copy.d.ts +4 -1
- package/dist/puck/editor/copy.js +4 -1
- package/dist/puck/editor/editor.chrome.css +1 -0
- package/dist/puck/editor/editor.css +1 -0
- package/dist/puck/editor/editor.model.d.ts +1 -0
- package/dist/puck/editor/placementsCache.d.ts +5 -1
- package/dist/puck/editor/placementsCache.js +17 -9
- package/dist/puck/editor/usePageSaveReadiness.d.ts +9 -0
- package/dist/puck/editor/usePageSaveReadiness.js +34 -0
- package/dist/puck/editor/usePlacementNotice.d.ts +2 -2
- package/dist/puck/editor/usePlacementNotice.js +5 -4
- package/dist/results/aggregate.d.ts +6 -3
- package/dist/results/aggregate.js +9 -9
- package/dist/results/health.d.ts +8 -0
- package/dist/results/health.js +28 -0
- package/dist/results/identityCredit.d.ts +1 -0
- package/dist/results/identityCredit.js +4 -1
- package/dist/results/verdict.js +2 -1
- package/dist/runtime/cookie.d.ts +10 -2
- package/dist/runtime/cookie.js +38 -6
- package/dist/runtime/cookieOptions.d.ts +6 -0
- package/dist/runtime/cookieOptions.js +14 -0
- package/dist/runtime/proxyRuntime.d.ts +1 -0
- package/dist/runtime/proxyRuntime.js +18 -8
- package/dist/runtime/signing.d.ts +1 -0
- package/dist/runtime/signing.js +5 -0
- package/dist/sanitizeReadinessDetail.d.ts +2 -2
- package/dist/sanitizeReadinessDetail.js +20 -2
- package/dist/server/getAssignments.js +11 -10
- package/dist/server/recordContentChange.d.ts +1 -1
- package/dist/server/recordContentChange.js +11 -2
- package/dist/server/resolveExperimentBlocks.js +2 -4
- package/dist/server/resolveExperimentData.js +2 -5
- package/dist/server/runResults.js +52 -14
- package/dist/server/startExperiment.d.ts +20 -0
- package/dist/server/startExperiment.js +70 -0
- package/dist/server/trackConversion.js +10 -13
- package/dist/testSurface/actions/DecideDialog.d.ts +4 -1
- package/dist/testSurface/actions/DecideDialog.js +32 -14
- package/dist/testSurface/actions/MakeContentResult.d.ts +4 -3
- package/dist/testSurface/actions/MakeContentResult.js +9 -1
- package/dist/testSurface/api.d.ts +5 -5
- package/dist/testSurface/api.js +21 -9
- package/dist/testSurface/copy/actions.d.ts +1 -0
- package/dist/testSurface/copy/actions.js +1 -0
- package/dist/testSurface/copy/common.d.ts +3 -1
- package/dist/testSurface/copy/common.js +4 -2
- package/dist/testSurface/copy/languages.d.ts +1 -0
- package/dist/testSurface/copy/languages.js +1 -0
- package/dist/testSurface/copy/metrics.d.ts +1 -0
- package/dist/testSurface/copy/metrics.js +1 -0
- package/dist/testSurface/copy/readiness.d.ts +12 -1
- package/dist/testSurface/copy/readiness.js +18 -1
- package/dist/testSurface/copy/results.d.ts +5 -2
- package/dist/testSurface/copy/results.js +5 -2
- package/dist/testSurface/copy/testPage.d.ts +20 -2
- package/dist/testSurface/copy/testPage.js +34 -3
- package/dist/testSurface/readPreflight.d.ts +5 -0
- package/dist/testSurface/readPreflight.js +7 -0
- package/dist/testSurface/readinessRead.d.ts +3 -0
- package/dist/testSurface/readinessRead.js +4 -0
- package/dist/testSurface/results/VerdictHero.d.ts +2 -1
- package/dist/testSurface/results/VerdictHero.js +5 -1
- package/dist/testSurface/results/results.model.d.ts +1 -1
- package/dist/testSurface/results/results.model.js +6 -2
- package/dist/testSurface/surface/contracts.d.ts +8 -1
- package/dist/testSurface/surface/editorPlacement.d.ts +2 -2
- package/dist/testSurface/surface/editorPlacement.js +1 -1
- package/dist/testSurface/surface/pageBlock/pageBlock.model.js +2 -2
- package/dist/testSurface/surface/pagePicker/PageCombobox.js +20 -6
- package/dist/testSurface/surface/readiness/ActionDialogs.d.ts +4 -2
- package/dist/testSurface/surface/readiness/ActionDialogs.js +39 -34
- package/dist/testSurface/surface/readiness/Banner.js +23 -12
- package/dist/testSurface/surface/readiness/SaveStatus.d.ts +4 -3
- package/dist/testSurface/surface/readiness/SaveStatus.js +15 -15
- package/dist/testSurface/surface/readiness/readiness.model.d.ts +6 -1
- package/dist/testSurface/surface/readiness/readiness.model.js +108 -11
- package/dist/testSurface/surface/readiness/useTransition.d.ts +4 -4
- package/dist/testSurface/surface/readiness/useTransition.js +12 -10
- package/dist/testSurface/surface/results/ReleasePages.d.ts +4 -2
- package/dist/testSurface/surface/results/ReleasePages.js +5 -4
- package/dist/testSurface/surface/results/ResultsBody.d.ts +4 -2
- package/dist/testSurface/surface/results/ResultsBody.js +86 -43
- package/dist/testSurface/surface/results/useResults.d.ts +7 -6
- package/dist/testSurface/surface/results/useResults.js +3 -2
- package/dist/testSurface/surface/setting/parts.js +58 -18
- package/dist/testSurface/surface/test/AdvancedSection.js +1 -0
- package/dist/testSurface/surface/test/DeleteTest.d.ts +6 -2
- package/dist/testSurface/surface/test/DeleteTest.js +145 -54
- package/dist/testSurface/surface/test/GoalSection.js +7 -3
- package/dist/testSurface/surface/test/LengthSection.js +3 -0
- package/dist/testSurface/surface/test/PageHoldout.js +4 -1
- package/dist/testSurface/surface/test/ReadinessBar.js +1 -1
- package/dist/testSurface/surface/test/TargetingSection.js +77 -12
- package/dist/testSurface/surface/test/TestSurface.js +81 -19
- package/dist/testSurface/surface/test/VersionsSection.js +56 -29
- package/dist/testSurface/surface/test/fields.d.ts +29 -4
- package/dist/testSurface/surface/test/fields.js +159 -39
- package/dist/testSurface/surface/test/pageParts.js +14 -5
- package/dist/testSurface/surface/test/testPage.model.d.ts +1 -0
- package/dist/testSurface/surface/test/testPage.model.js +6 -0
- package/dist/testSurface/surface/testDocument.model.d.ts +3 -0
- package/dist/testSurface/surface/testDocument.model.js +4 -1
- package/dist/testSurface/surface/useTestDocument.d.ts +22 -4
- package/dist/testSurface/surface/useTestDocument.js +407 -160
- package/dist/testSurface/useApi.d.ts +5 -5
- package/dist/testSurface/useOnTestReturn.d.ts +2 -0
- package/dist/testSurface/useOnTestReturn.js +27 -0
- package/dist/testSurface/useReadinessPolling.js +3 -1
- package/dist/transitions/addMetric.d.ts +1 -4
- package/dist/transitions/allocate.d.ts +2 -2
- package/dist/transitions/allocate.js +3 -1
- package/dist/transitions/archive.d.ts +1 -1
- package/dist/transitions/archive.js +3 -2
- package/dist/transitions/checkStart.d.ts +1 -0
- package/dist/transitions/checkStart.js +17 -6
- package/dist/transitions/decide.d.ts +1 -1
- package/dist/transitions/decide.js +5 -3
- package/dist/transitions/deleteExperiment.d.ts +2 -2
- package/dist/transitions/deleteExperiment.js +17 -7
- package/dist/transitions/kernel.d.ts +2 -0
- package/dist/transitions/kernel.js +9 -4
- package/dist/transitions/makeContent.d.ts +2 -1
- package/dist/transitions/makeContent.js +12 -8
- package/dist/transitions/nestedPlacementNames.d.ts +2 -2
- package/dist/transitions/nestedPlacementNames.js +4 -5
- package/dist/transitions/phaseRecord.d.ts +2 -0
- package/dist/transitions/phaseRecord.js +5 -0
- package/dist/transitions/placementInteractions.d.ts +3 -3
- package/dist/transitions/placementInteractions.js +8 -7
- package/dist/transitions/placements.d.ts +2 -0
- package/dist/transitions/placements.js +5 -5
- package/dist/transitions/preflightData.d.ts +3 -2
- package/dist/transitions/preflightData.js +67 -41
- package/dist/transitions/releaseHoldout.d.ts +2 -1
- package/dist/transitions/releaseHoldout.js +3 -1
- package/dist/transitions/releasePages.d.ts +2 -1
- package/dist/transitions/releasePages.js +3 -1
- package/dist/transitions/resolveCaps.d.ts +2 -4
- package/dist/transitions/start.d.ts +6 -8
- package/dist/transitions/start.js +67 -34
- package/dist/transitions/startReads.d.ts +7 -0
- package/dist/transitions/startReads.js +28 -0
- package/dist/transitions/stop.d.ts +2 -1
- package/dist/transitions/stop.js +3 -2
- package/dist/types/contracts.d.ts +6 -3
- package/dist/types/endpoints.d.ts +52 -9
- package/dist/types/runtime.d.ts +15 -9
- package/dist/types/snapshot.d.ts +2 -0
- package/dist/ui/ChipsInput.d.ts +8 -1
- package/dist/ui/ChipsInput.js +17 -4
- package/package.json +2 -2
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export function findStartDocuments(req, query, system = false) {
|
|
2
|
+
// §7.8: Start from trusted host code reads plugin readiness data without a manager actor.
|
|
3
|
+
if (system) return req.payload.find({
|
|
4
|
+
...query,
|
|
5
|
+
req,
|
|
6
|
+
overrideAccess: true
|
|
7
|
+
});
|
|
8
|
+
return req.payload.find({
|
|
9
|
+
...query,
|
|
10
|
+
req,
|
|
11
|
+
overrideAccess: false
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
export function readStartState(req, system = false) {
|
|
15
|
+
// §7.8: system Start needs the effective flag defaults even without a manager actor.
|
|
16
|
+
if (system) return req.payload.findGlobal({
|
|
17
|
+
slug: 'xp-state',
|
|
18
|
+
req,
|
|
19
|
+
overrideAccess: true,
|
|
20
|
+
depth: 0
|
|
21
|
+
});
|
|
22
|
+
return req.payload.findGlobal({
|
|
23
|
+
slug: 'xp-state',
|
|
24
|
+
req,
|
|
25
|
+
overrideAccess: false,
|
|
26
|
+
depth: 0
|
|
27
|
+
});
|
|
28
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PayloadRequest } from 'payload';
|
|
2
2
|
import type { DocId } from '../types/contracts.js';
|
|
3
|
-
|
|
3
|
+
import type { RoundBody } from '../types/endpoints.js';
|
|
4
|
+
export declare function stop(req: PayloadRequest, { experimentId, phase: expectedPhase }: RoundBody & {
|
|
4
5
|
experimentId: DocId;
|
|
5
6
|
}): Promise<{
|
|
6
7
|
doc: import("payload").JsonObject & import("payload").TypeWithID;
|
package/dist/transitions/stop.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { relationshipId } from './checkStart.js';
|
|
2
2
|
import { withTransition } from './kernel.js';
|
|
3
|
-
import { setPhaseEndedAt } from './phaseRecord.js';
|
|
3
|
+
import { requireCurrentRound, setPhaseEndedAt } from './phaseRecord.js';
|
|
4
4
|
import { readExperiment, refuse, updateExperiment } from './start.js';
|
|
5
|
-
export async function stop(req, { experimentId }) {
|
|
5
|
+
export async function stop(req, { experimentId, phase: expectedPhase }) {
|
|
6
6
|
const before = await readExperiment(req, experimentId);
|
|
7
7
|
const { result: doc, revision } = await withTransition(req, {
|
|
8
8
|
experimentId,
|
|
9
9
|
layerId: relationshipId(before.layer)
|
|
10
10
|
}, async ({ req })=>{
|
|
11
11
|
const current = await readExperiment(req, experimentId);
|
|
12
|
+
requireCurrentRound(expectedPhase, current.phase);
|
|
12
13
|
if (current.status !== 'running') refuse('invalid-status');
|
|
13
14
|
const at = new Date().toISOString();
|
|
14
15
|
await setPhaseEndedAt(req, experimentId, current.phase, at);
|
|
@@ -93,10 +93,11 @@ export interface FlagPoint {
|
|
|
93
93
|
req: PayloadRequest;
|
|
94
94
|
}): Promise<void>;
|
|
95
95
|
}
|
|
96
|
-
/**
|
|
96
|
+
/** Combine a trusted client-address cap with a limit for the verified unit. */
|
|
97
97
|
export type RateLimiter = (args: {
|
|
98
98
|
req: PayloadRequest;
|
|
99
99
|
unitId: string;
|
|
100
|
+
unitType: UnitType;
|
|
100
101
|
}) => boolean | Promise<boolean>;
|
|
101
102
|
export type ExperimentsAccess = (args: {
|
|
102
103
|
req: PayloadRequest;
|
|
@@ -173,11 +174,13 @@ export interface ExperimentsPluginOptions<TUser extends {
|
|
|
173
174
|
field?: string;
|
|
174
175
|
}>;
|
|
175
176
|
};
|
|
176
|
-
events
|
|
177
|
+
events: {
|
|
177
178
|
retentionDays?: number;
|
|
178
179
|
maxBodyBytes?: number;
|
|
179
|
-
rateLimit
|
|
180
|
+
rateLimit: RateLimiter | false;
|
|
180
181
|
dimensions?: string[];
|
|
182
|
+
/** Public HTTP(S) origin for clients without Fetch Metadata. Defaults to Payload's serverURL. */
|
|
183
|
+
origin?: string;
|
|
181
184
|
};
|
|
182
185
|
}
|
|
183
186
|
/** Options required by the route table; CORE-02c resolves optional defaults. */
|
|
@@ -7,7 +7,7 @@ import type { Snapshot, VerdictCode } from './snapshot.js';
|
|
|
7
7
|
export type ArmIssueCode = 'weights-total' | 'control-count' | 'control-first' | 'holdout-last' | 'holdout-count' | 'variant-count' | 'duplicate-key' | 'duplicate-slot' | 'slot-required' | 'invalid-key';
|
|
8
8
|
/** Content-report dismiss/restore refusals (CORE-44). */
|
|
9
9
|
export type ContentEntryRefusal = 'not-decided' | 'entry-not-found' | 'entry-ok' | 'entry-dismissed' | 'entry-not-dismissed';
|
|
10
|
-
export type RefusalCode = ArmIssueCode | 'nested-tests' | 'goal-in-some-versions' | 'placement-unchecked' | 'placement-unpublished' | 'duplicate-version-row' | 'interacting-tests' | 'placements-changed' | 'page-busy' | 'wrap-target-missing' | 'version-identical' | 'version-same-address' | 'unknown-collection' | 'not-found' | ContentEntryRefusal | 'no-planned-duration' | 'no-primary-metric' | 'no-placements' | 'placement-removed' | 'empty-slot' | 'page-in-use' | 'page-no-targets' | 'page-target-unpublished' | 'page-user-unit' | 'version-page-unavailable' | 'version-page-unchecked' | 'flag-no-point' | 'flag-params-invalid' | 'flag-point-busy' | 'flag-placement-missing' | 'layer-full' | 'layer-unit-mismatch' | 'unknown-metric-source' | 'unit-source-mismatch' | 'no-reach-per-day' | 'invalid-status' | 'stale-draft' | 'stale-edit' | 'commit-unverified' | 'allocation-lower' | 'confirmation-required' | 'invalid-winner' | 'slices-taken' | 'locked-placement' | 'not-implemented' | 'forbidden' | 'unauthenticated' | 'body-too-large' | 'invalid-body' | 'too-many-ids' | 'invalid-phase' | 'invalid-ids' | 'recompute-failed' | 'analysis-failed' | 'undeclared-targeting-key' | 'invalid-targeting-rule' | 'block-path-rule' | 'duplicate-metric';
|
|
10
|
+
export type RefusalCode = ArmIssueCode | 'nested-tests' | 'goal-in-some-versions' | 'placement-unchecked' | 'placement-unpublished' | 'duplicate-version-row' | 'interacting-tests' | 'placements-changed' | 'page-busy' | 'wrap-target-missing' | 'version-identical' | 'version-same-address' | 'unknown-collection' | 'not-found' | ContentEntryRefusal | 'no-planned-duration' | 'no-primary-metric' | 'no-placements' | 'placement-removed' | 'empty-slot' | 'page-in-use' | 'page-no-targets' | 'page-target-unpublished' | 'page-user-unit' | 'version-page-unavailable' | 'version-page-unchecked' | 'flag-no-point' | 'flag-params-invalid' | 'flag-point-busy' | 'flag-placement-missing' | 'layer-full' | 'layer-unit-mismatch' | 'unknown-metric-source' | 'unit-source-mismatch' | 'no-reach-per-day' | 'invalid-status' | 'first-start-only' | 'stale-draft' | 'stale-edit' | 'round-changed' | 'commit-unverified' | 'allocation-lower' | 'confirmation-required' | 'invalid-winner' | 'slices-taken' | 'locked-placement' | 'not-implemented' | 'forbidden' | 'unauthenticated' | 'body-too-large' | 'invalid-body' | 'too-many-ids' | 'invalid-phase' | 'invalid-ids' | 'recompute-failed' | 'analysis-failed' | 'undeclared-targeting-key' | 'invalid-targeting-rule' | 'block-path-rule' | 'duplicate-metric';
|
|
11
11
|
export type ErrorEnvelope = {
|
|
12
12
|
errors: Array<{
|
|
13
13
|
code: RefusalCode;
|
|
@@ -19,8 +19,31 @@ export type TransitionSuccess = {
|
|
|
19
19
|
doc: Record<string, unknown>;
|
|
20
20
|
revision: number;
|
|
21
21
|
};
|
|
22
|
-
export type
|
|
23
|
-
|
|
22
|
+
export type StartExperimentWarning = {
|
|
23
|
+
metricId: DocId;
|
|
24
|
+
message: string;
|
|
25
|
+
};
|
|
26
|
+
export type StartExperimentFirstStartDetail = {
|
|
27
|
+
status: Status;
|
|
28
|
+
phase: number;
|
|
29
|
+
};
|
|
30
|
+
export type StartExperimentResult = {
|
|
31
|
+
status: 'started';
|
|
32
|
+
phase: number;
|
|
33
|
+
revision: number;
|
|
34
|
+
warnings: StartExperimentWarning[];
|
|
35
|
+
} | {
|
|
36
|
+
status: 'refused';
|
|
37
|
+
code: 'first-start-only';
|
|
38
|
+
message: string;
|
|
39
|
+
detail: StartExperimentFirstStartDetail;
|
|
40
|
+
} | {
|
|
41
|
+
status: 'refused';
|
|
42
|
+
code: Exclude<RefusalCode, 'not-found' | 'commit-unverified' | 'first-start-only'> | 'transaction-open';
|
|
43
|
+
message: string;
|
|
44
|
+
detail?: unknown;
|
|
45
|
+
} | {
|
|
46
|
+
status: 'not-found';
|
|
24
47
|
};
|
|
25
48
|
export type AddMetricWarning = {
|
|
26
49
|
code: 'goal-in-some-versions' | 'goal-added-mid-test' | 'placement-unchecked';
|
|
@@ -33,12 +56,19 @@ export type AddMetricBody = {
|
|
|
33
56
|
metric: DocId;
|
|
34
57
|
role: 'secondary' | 'guardrail';
|
|
35
58
|
};
|
|
36
|
-
|
|
59
|
+
/** When omitted, the action applies to the current round. */
|
|
60
|
+
export type RoundBody = {
|
|
61
|
+
phase?: number;
|
|
62
|
+
};
|
|
63
|
+
export type AllocateBody = RoundBody & {
|
|
64
|
+
allocation: number;
|
|
65
|
+
};
|
|
66
|
+
export type DecideBody = RoundBody & {
|
|
37
67
|
winnerArm: string;
|
|
38
68
|
note?: string;
|
|
39
69
|
confirmation?: string;
|
|
40
70
|
};
|
|
41
|
-
export type ArchiveBody = {
|
|
71
|
+
export type ArchiveBody = RoundBody & {
|
|
42
72
|
mode: 'stopped' | 'after-content' | 'discard' | 'hard-coded';
|
|
43
73
|
confirmation?: string;
|
|
44
74
|
};
|
|
@@ -64,10 +94,23 @@ export type MakeContentResult = TransitionSuccess & {
|
|
|
64
94
|
}>;
|
|
65
95
|
};
|
|
66
96
|
export type PreflightResult = {
|
|
97
|
+
/** Saved document version used for these checks. */
|
|
98
|
+
document?: {
|
|
99
|
+
status: Status;
|
|
100
|
+
phase?: number;
|
|
101
|
+
updatedAt?: string;
|
|
102
|
+
};
|
|
103
|
+
/** Content language selection and labels when block placements are localized. */
|
|
104
|
+
contentLocales?: {
|
|
105
|
+
selected: string;
|
|
106
|
+
labels: Record<string, string>;
|
|
107
|
+
};
|
|
67
108
|
goalNotes?: Array<{
|
|
68
109
|
metricId: DocId;
|
|
69
110
|
message: string;
|
|
70
111
|
}>;
|
|
112
|
+
/** Advisory only. This does not affect Start readiness. */
|
|
113
|
+
browserWritablePrimaryId?: DocId;
|
|
71
114
|
checks: Array<{
|
|
72
115
|
code: ReadinessCode;
|
|
73
116
|
ok: boolean;
|
|
@@ -91,10 +134,12 @@ export type PreflightResult = {
|
|
|
91
134
|
title: string;
|
|
92
135
|
locales?: string[];
|
|
93
136
|
allLocales?: true;
|
|
137
|
+
localeCodes?: string[];
|
|
94
138
|
slotCount?: number;
|
|
95
139
|
url?: string;
|
|
96
140
|
editorUrl?: string;
|
|
97
141
|
slots?: Record<ArmSlot, number>;
|
|
142
|
+
partlyFilledSlots?: ArmSlot[];
|
|
98
143
|
ok: boolean;
|
|
99
144
|
detail?: string;
|
|
100
145
|
}>;
|
|
@@ -130,6 +175,7 @@ export interface PhaseSummary {
|
|
|
130
175
|
kind: MetricSource['kind'];
|
|
131
176
|
role: 'primary' | 'secondary' | 'guardrail';
|
|
132
177
|
clickGoal?: true;
|
|
178
|
+
browserWritable?: true;
|
|
133
179
|
resolvedCap?: number | null;
|
|
134
180
|
historyUnits?: number;
|
|
135
181
|
capNotice?: 'no-history';
|
|
@@ -186,16 +232,13 @@ export type EventBody = {
|
|
|
186
232
|
attributes?: Record<string, string | number | boolean>;
|
|
187
233
|
}>;
|
|
188
234
|
};
|
|
189
|
-
export type AccessKind = 'manage' | 'readResults' | 'surface' | 'manifestKey' | '
|
|
235
|
+
export type AccessKind = 'manage' | 'readResults' | 'surface' | 'manifestKey' | 'browserEvents';
|
|
190
236
|
export type EndpointContext<TUser extends {
|
|
191
237
|
id: string | number;
|
|
192
238
|
} = {
|
|
193
239
|
id: string | number;
|
|
194
240
|
}> = {
|
|
195
241
|
options: ResolvedOptions<TUser>;
|
|
196
|
-
unit?: {
|
|
197
|
-
visitorId: string;
|
|
198
|
-
};
|
|
199
242
|
};
|
|
200
243
|
export type ClickKeysResult = {
|
|
201
244
|
keys: Array<{
|
package/dist/types/runtime.d.ts
CHANGED
|
@@ -2,15 +2,21 @@ import type { Payload } from 'payload';
|
|
|
2
2
|
import type { NextRequest } from 'next/server';
|
|
3
3
|
import type { Attributes } from './contracts.js';
|
|
4
4
|
import type { Manifest } from './manifest.js';
|
|
5
|
+
type CookieOptions = {
|
|
6
|
+
name?: string;
|
|
7
|
+
maxAgeDays?: number;
|
|
8
|
+
/** Reject pre-rc.9 visitor IDs, including upgraded cookies, starting on this UTC date. Can only shorten the release cutoff. */
|
|
9
|
+
legacyCutoff?: string;
|
|
10
|
+
domain?: string;
|
|
11
|
+
/** Called with a request whose URL is a placeholder outside the proxy; read cookies and headers only. */
|
|
12
|
+
consent?(req: NextRequest): boolean;
|
|
13
|
+
};
|
|
5
14
|
export interface ExperimentsProxyRuntimeOptions {
|
|
6
15
|
secret: string | string[];
|
|
7
16
|
apiRoute: string;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
domain?: string; /** Called with a request whose URL is a placeholder outside the proxy; read cookies and headers only. */
|
|
12
|
-
consent?(req: NextRequest): boolean;
|
|
13
|
-
};
|
|
17
|
+
/** Limit new visitor IDs by trusted client address, or pass false when protected upstream. */
|
|
18
|
+
rateLimitUnit: false | ((req: NextRequest) => boolean | Promise<boolean>);
|
|
19
|
+
cookie?: CookieOptions;
|
|
14
20
|
loadManifest?: (opts?: {
|
|
15
21
|
ifRevision?: number;
|
|
16
22
|
}) => Promise<Manifest | 'not-modified' | null>;
|
|
@@ -27,11 +33,10 @@ export interface ExperimentsProxyRuntimeOptions {
|
|
|
27
33
|
export interface ExperimentsProxyRuntime {
|
|
28
34
|
readonly secrets: readonly string[];
|
|
29
35
|
readonly apiRoute: string;
|
|
30
|
-
readonly
|
|
36
|
+
readonly rateLimitUnit: ExperimentsProxyRuntimeOptions['rateLimitUnit'];
|
|
37
|
+
readonly cookie: CookieOptions & {
|
|
31
38
|
name: string;
|
|
32
39
|
maxAgeDays: number;
|
|
33
|
-
domain?: string; /** Called with a request whose URL is a placeholder outside the proxy; read cookies and headers only. */
|
|
34
|
-
consent?(req: NextRequest): boolean;
|
|
35
40
|
};
|
|
36
41
|
readonly loadManifest?: ExperimentsProxyRuntimeOptions['loadManifest'];
|
|
37
42
|
readonly getUnit?: ExperimentsProxyRuntimeOptions['getUnit'];
|
|
@@ -57,3 +62,4 @@ export interface ExperimentsServerRuntime<TUser extends {
|
|
|
57
62
|
userIdOf: NonNullable<ExperimentsServerRuntimeOptions<TUser>['userIdOf']>;
|
|
58
63
|
attributesOf: NonNullable<ExperimentsServerRuntimeOptions<TUser>['attributesOf']>;
|
|
59
64
|
}
|
|
65
|
+
export {};
|
package/dist/types/snapshot.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export type SnapshotHealth = {
|
|
|
12
12
|
id?: string | number;
|
|
13
13
|
path?: string;
|
|
14
14
|
};
|
|
15
|
+
} | {
|
|
16
|
+
code: 'rapid-browser-events';
|
|
15
17
|
};
|
|
16
18
|
import type { GaussianPrior } from '@delmaredigital/experiments-stats';
|
|
17
19
|
import type { DocId, MetricSource } from './contracts.js';
|
package/dist/ui/ChipsInput.d.ts
CHANGED
|
@@ -9,5 +9,12 @@ export interface ChipsInputProps {
|
|
|
9
9
|
placeholder?: string;
|
|
10
10
|
disabled?: boolean;
|
|
11
11
|
id: string;
|
|
12
|
+
draft?: {
|
|
13
|
+
value: string;
|
|
14
|
+
change: (value: string) => void;
|
|
15
|
+
submit: (value: string) => void;
|
|
16
|
+
discard: () => void;
|
|
17
|
+
describedBy?: string;
|
|
18
|
+
};
|
|
12
19
|
}
|
|
13
|
-
export declare function ChipsInput({ value, onChange, label, description, help, error, placeholder, disabled, id }: ChipsInputProps): import("react").JSX.Element;
|
|
20
|
+
export declare function ChipsInput({ value, onChange, label, description, help, error, placeholder, disabled, id, draft: managedDraft }: ChipsInputProps): import("react").JSX.Element;
|
package/dist/ui/ChipsInput.js
CHANGED
|
@@ -2,11 +2,17 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useRef, useState } from 'react';
|
|
4
4
|
import './ui.css';
|
|
5
|
-
export function ChipsInput({ value, onChange, label, description, help = description, error, placeholder, disabled = false, id }) {
|
|
6
|
-
const [
|
|
5
|
+
export function ChipsInput({ value, onChange, label, description, help = description, error, placeholder, disabled = false, id, draft: managedDraft }) {
|
|
6
|
+
const [localDraft, setLocalDraft] = useState('');
|
|
7
|
+
const draft = managedDraft?.value ?? localDraft;
|
|
8
|
+
const setDraft = managedDraft?.change ?? setLocalDraft;
|
|
7
9
|
const input = useRef(null);
|
|
8
10
|
const commit = (text)=>{
|
|
9
11
|
if (disabled) return;
|
|
12
|
+
if (managedDraft) {
|
|
13
|
+
managedDraft.submit(text);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
10
16
|
const next = [
|
|
11
17
|
...new Set([
|
|
12
18
|
...value,
|
|
@@ -60,13 +66,20 @@ export function ChipsInput({ value, onChange, label, description, help = descrip
|
|
|
60
66
|
"aria-invalid": Boolean(error) || undefined,
|
|
61
67
|
"aria-describedby": [
|
|
62
68
|
help ? `${id}-description` : '',
|
|
63
|
-
error ? `${id}-error` : ''
|
|
69
|
+
error ? `${id}-error` : '',
|
|
70
|
+
managedDraft?.describedBy
|
|
64
71
|
].filter(Boolean).join(' ') || undefined,
|
|
65
72
|
onChange: (event)=>setDraft(event.target.value),
|
|
66
73
|
onBlur: ()=>{
|
|
67
74
|
if (draft.trim()) commit(draft);
|
|
68
75
|
},
|
|
69
76
|
onKeyDown: (event)=>{
|
|
77
|
+
if (event.key === 'Escape' && managedDraft && draft) {
|
|
78
|
+
event.preventDefault();
|
|
79
|
+
event.stopPropagation();
|
|
80
|
+
managedDraft.discard();
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
70
83
|
if (disabled || event.nativeEvent.isComposing) return;
|
|
71
84
|
if (event.key === 'Enter' || event.key === ',') {
|
|
72
85
|
event.preventDefault();
|
|
@@ -78,7 +91,7 @@ export function ChipsInput({ value, onChange, label, description, help = descrip
|
|
|
78
91
|
}
|
|
79
92
|
},
|
|
80
93
|
onPaste: (event)=>{
|
|
81
|
-
if (disabled) return;
|
|
94
|
+
if (disabled || managedDraft) return;
|
|
82
95
|
const pasted = event.clipboardData.getData('text');
|
|
83
96
|
if (!pasted.includes(',')) return;
|
|
84
97
|
event.preventDefault();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@delmaredigital/payload-experiments",
|
|
3
|
-
"version": "0.4.0-rc.
|
|
3
|
+
"version": "0.4.0-rc.9",
|
|
4
4
|
"description": "No-code A/B testing for Payload CMS and Next.js: block, page and flag experiments with holdouts, layers, exposure logging and honest statistics inside the admin — no vendor",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
},
|
|
128
128
|
"homepage": "https://delmaredigital.com/developers",
|
|
129
129
|
"devDependencies": {
|
|
130
|
-
"@delmaredigital/payload-puck": "0.12.
|
|
130
|
+
"@delmaredigital/payload-puck": "0.12.2",
|
|
131
131
|
"payload": "^3.90.2",
|
|
132
132
|
"@payloadcms/db-postgres": "^3.90.2",
|
|
133
133
|
"@payloadcms/ui": "^3.90.2",
|