@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.
Files changed (221) hide show
  1. package/README.md +12 -12
  2. package/dist/admin/blocks/model.js +2 -2
  3. package/dist/admin/copy/blocks.js +1 -1
  4. package/dist/admin/surface/ResultsRoute.js +17 -11
  5. package/dist/admin/surface/TestsHome.js +53 -20
  6. package/dist/admin/surface/newTest/PageWizard.js +8 -2
  7. package/dist/admin/surface/results/ResultsHeader.js +11 -6
  8. package/dist/admin/surface/test/TestPage.js +3 -3
  9. package/dist/blocks/formState.js +1 -1
  10. package/dist/collections/experiments/config.js +8 -3
  11. package/dist/collections/experiments/deleteGuard.js +2 -2
  12. package/dist/collections/experiments/lockHook.js +21 -2
  13. package/dist/collections/experiments/pickSlug.js +2 -0
  14. package/dist/collections/metricsGuards.js +2 -0
  15. package/dist/collections/serialize.js +5 -4
  16. package/dist/constants.d.ts +1 -0
  17. package/dist/constants.js +1 -0
  18. package/dist/db/adapter.d.ts +9 -1
  19. package/dist/db/adapter.js +77 -1
  20. package/dist/db/delete.d.ts +1 -1
  21. package/dist/db/delete.js +2 -4
  22. package/dist/db/events.d.ts +9 -0
  23. package/dist/db/events.js +42 -8
  24. package/dist/db/executor.d.ts +7 -1
  25. package/dist/db/executor.js +7 -3
  26. package/dist/db/results.d.ts +5 -1
  27. package/dist/db/results.js +21 -5
  28. package/dist/db/snapshots.d.ts +1 -0
  29. package/dist/endpoints/deleteImpact.js +2 -1
  30. package/dist/endpoints/events.js +103 -39
  31. package/dist/endpoints/index.js +2 -8
  32. package/dist/endpoints/placementStatus.js +7 -4
  33. package/dist/endpoints/results.d.ts +1 -1
  34. package/dist/endpoints/results.js +6 -2
  35. package/dist/endpoints/routeId.d.ts +2 -2
  36. package/dist/endpoints/routeId.js +11 -5
  37. package/dist/endpoints/summary.js +46 -12
  38. package/dist/endpoints/transitions.js +37 -24
  39. package/dist/errors.d.ts +4 -0
  40. package/dist/errors.js +6 -0
  41. package/dist/events/request.d.ts +6 -2
  42. package/dist/events/request.js +35 -8
  43. package/dist/events/rows.d.ts +1 -1
  44. package/dist/events/rows.js +24 -8
  45. package/dist/events/writable.d.ts +9 -0
  46. package/dist/events/writable.js +13 -0
  47. package/dist/exports/index.d.ts +1 -1
  48. package/dist/exports/rsc.d.ts +1 -0
  49. package/dist/exports/rsc.js +1 -0
  50. package/dist/goals/fairness.js +2 -2
  51. package/dist/hooks/hostHook.js +6 -2
  52. package/dist/hooks/pageGuard.js +4 -0
  53. package/dist/lib/fetchAllDocs.d.ts +1 -1
  54. package/dist/manifest/compile.js +8 -5
  55. package/dist/onInit.js +14 -0
  56. package/dist/options.js +5 -0
  57. package/dist/proxy/pageNavigation.d.ts +4 -0
  58. package/dist/proxy/pageNavigation.js +28 -0
  59. package/dist/proxy/resolve.js +52 -25
  60. package/dist/puck/editor/ConfigureTestDrawer.js +5 -4
  61. package/dist/puck/editor/ExperimentSlotEditor.js +182 -58
  62. package/dist/puck/editor/QuickTestActions.d.ts +5 -2
  63. package/dist/puck/editor/QuickTestActions.js +16 -4
  64. package/dist/puck/editor/ResultsReadout.d.ts +2 -1
  65. package/dist/puck/editor/ResultsReadout.js +2 -1
  66. package/dist/puck/editor/VersionBuilder.d.ts +13 -2
  67. package/dist/puck/editor/VersionBuilder.js +133 -49
  68. package/dist/puck/editor/armWrites.js +1 -1
  69. package/dist/puck/editor/armsCache.js +1 -3
  70. package/dist/puck/editor/copy.d.ts +4 -1
  71. package/dist/puck/editor/copy.js +4 -1
  72. package/dist/puck/editor/editor.chrome.css +1 -0
  73. package/dist/puck/editor/editor.css +1 -0
  74. package/dist/puck/editor/editor.model.d.ts +1 -0
  75. package/dist/puck/editor/placementsCache.d.ts +5 -1
  76. package/dist/puck/editor/placementsCache.js +17 -9
  77. package/dist/puck/editor/usePageSaveReadiness.d.ts +9 -0
  78. package/dist/puck/editor/usePageSaveReadiness.js +34 -0
  79. package/dist/puck/editor/usePlacementNotice.d.ts +2 -2
  80. package/dist/puck/editor/usePlacementNotice.js +5 -4
  81. package/dist/results/aggregate.d.ts +6 -3
  82. package/dist/results/aggregate.js +9 -9
  83. package/dist/results/health.d.ts +8 -0
  84. package/dist/results/health.js +28 -0
  85. package/dist/results/identityCredit.d.ts +1 -0
  86. package/dist/results/identityCredit.js +4 -1
  87. package/dist/results/verdict.js +2 -1
  88. package/dist/runtime/cookie.d.ts +10 -2
  89. package/dist/runtime/cookie.js +38 -6
  90. package/dist/runtime/cookieOptions.d.ts +6 -0
  91. package/dist/runtime/cookieOptions.js +14 -0
  92. package/dist/runtime/proxyRuntime.d.ts +1 -0
  93. package/dist/runtime/proxyRuntime.js +18 -8
  94. package/dist/runtime/signing.d.ts +1 -0
  95. package/dist/runtime/signing.js +5 -0
  96. package/dist/sanitizeReadinessDetail.d.ts +2 -2
  97. package/dist/sanitizeReadinessDetail.js +20 -2
  98. package/dist/server/getAssignments.js +11 -10
  99. package/dist/server/recordContentChange.d.ts +1 -1
  100. package/dist/server/recordContentChange.js +11 -2
  101. package/dist/server/resolveExperimentBlocks.js +2 -4
  102. package/dist/server/resolveExperimentData.js +2 -5
  103. package/dist/server/runResults.js +52 -14
  104. package/dist/server/startExperiment.d.ts +20 -0
  105. package/dist/server/startExperiment.js +70 -0
  106. package/dist/server/trackConversion.js +10 -13
  107. package/dist/testSurface/actions/DecideDialog.d.ts +4 -1
  108. package/dist/testSurface/actions/DecideDialog.js +32 -14
  109. package/dist/testSurface/actions/MakeContentResult.d.ts +4 -3
  110. package/dist/testSurface/actions/MakeContentResult.js +9 -1
  111. package/dist/testSurface/api.d.ts +5 -5
  112. package/dist/testSurface/api.js +21 -9
  113. package/dist/testSurface/copy/actions.d.ts +1 -0
  114. package/dist/testSurface/copy/actions.js +1 -0
  115. package/dist/testSurface/copy/common.d.ts +3 -1
  116. package/dist/testSurface/copy/common.js +4 -2
  117. package/dist/testSurface/copy/languages.d.ts +1 -0
  118. package/dist/testSurface/copy/languages.js +1 -0
  119. package/dist/testSurface/copy/metrics.d.ts +1 -0
  120. package/dist/testSurface/copy/metrics.js +1 -0
  121. package/dist/testSurface/copy/readiness.d.ts +12 -1
  122. package/dist/testSurface/copy/readiness.js +18 -1
  123. package/dist/testSurface/copy/results.d.ts +5 -2
  124. package/dist/testSurface/copy/results.js +5 -2
  125. package/dist/testSurface/copy/testPage.d.ts +20 -2
  126. package/dist/testSurface/copy/testPage.js +34 -3
  127. package/dist/testSurface/readPreflight.d.ts +5 -0
  128. package/dist/testSurface/readPreflight.js +7 -0
  129. package/dist/testSurface/readinessRead.d.ts +3 -0
  130. package/dist/testSurface/readinessRead.js +4 -0
  131. package/dist/testSurface/results/VerdictHero.d.ts +2 -1
  132. package/dist/testSurface/results/VerdictHero.js +5 -1
  133. package/dist/testSurface/results/results.model.d.ts +1 -1
  134. package/dist/testSurface/results/results.model.js +6 -2
  135. package/dist/testSurface/surface/contracts.d.ts +8 -1
  136. package/dist/testSurface/surface/editorPlacement.d.ts +2 -2
  137. package/dist/testSurface/surface/editorPlacement.js +1 -1
  138. package/dist/testSurface/surface/pageBlock/pageBlock.model.js +2 -2
  139. package/dist/testSurface/surface/pagePicker/PageCombobox.js +20 -6
  140. package/dist/testSurface/surface/readiness/ActionDialogs.d.ts +4 -2
  141. package/dist/testSurface/surface/readiness/ActionDialogs.js +39 -34
  142. package/dist/testSurface/surface/readiness/Banner.js +23 -12
  143. package/dist/testSurface/surface/readiness/SaveStatus.d.ts +4 -3
  144. package/dist/testSurface/surface/readiness/SaveStatus.js +15 -15
  145. package/dist/testSurface/surface/readiness/readiness.model.d.ts +6 -1
  146. package/dist/testSurface/surface/readiness/readiness.model.js +108 -11
  147. package/dist/testSurface/surface/readiness/useTransition.d.ts +4 -4
  148. package/dist/testSurface/surface/readiness/useTransition.js +12 -10
  149. package/dist/testSurface/surface/results/ReleasePages.d.ts +4 -2
  150. package/dist/testSurface/surface/results/ReleasePages.js +5 -4
  151. package/dist/testSurface/surface/results/ResultsBody.d.ts +4 -2
  152. package/dist/testSurface/surface/results/ResultsBody.js +86 -43
  153. package/dist/testSurface/surface/results/useResults.d.ts +7 -6
  154. package/dist/testSurface/surface/results/useResults.js +3 -2
  155. package/dist/testSurface/surface/setting/parts.js +58 -18
  156. package/dist/testSurface/surface/test/AdvancedSection.js +1 -0
  157. package/dist/testSurface/surface/test/DeleteTest.d.ts +6 -2
  158. package/dist/testSurface/surface/test/DeleteTest.js +145 -54
  159. package/dist/testSurface/surface/test/GoalSection.js +7 -3
  160. package/dist/testSurface/surface/test/LengthSection.js +3 -0
  161. package/dist/testSurface/surface/test/PageHoldout.js +4 -1
  162. package/dist/testSurface/surface/test/ReadinessBar.js +1 -1
  163. package/dist/testSurface/surface/test/TargetingSection.js +77 -12
  164. package/dist/testSurface/surface/test/TestSurface.js +81 -19
  165. package/dist/testSurface/surface/test/VersionsSection.js +56 -29
  166. package/dist/testSurface/surface/test/fields.d.ts +29 -4
  167. package/dist/testSurface/surface/test/fields.js +159 -39
  168. package/dist/testSurface/surface/test/pageParts.js +14 -5
  169. package/dist/testSurface/surface/test/testPage.model.d.ts +1 -0
  170. package/dist/testSurface/surface/test/testPage.model.js +6 -0
  171. package/dist/testSurface/surface/testDocument.model.d.ts +3 -0
  172. package/dist/testSurface/surface/testDocument.model.js +4 -1
  173. package/dist/testSurface/surface/useTestDocument.d.ts +22 -4
  174. package/dist/testSurface/surface/useTestDocument.js +407 -160
  175. package/dist/testSurface/useApi.d.ts +5 -5
  176. package/dist/testSurface/useOnTestReturn.d.ts +2 -0
  177. package/dist/testSurface/useOnTestReturn.js +27 -0
  178. package/dist/testSurface/useReadinessPolling.js +3 -1
  179. package/dist/transitions/addMetric.d.ts +1 -4
  180. package/dist/transitions/allocate.d.ts +2 -2
  181. package/dist/transitions/allocate.js +3 -1
  182. package/dist/transitions/archive.d.ts +1 -1
  183. package/dist/transitions/archive.js +3 -2
  184. package/dist/transitions/checkStart.d.ts +1 -0
  185. package/dist/transitions/checkStart.js +17 -6
  186. package/dist/transitions/decide.d.ts +1 -1
  187. package/dist/transitions/decide.js +5 -3
  188. package/dist/transitions/deleteExperiment.d.ts +2 -2
  189. package/dist/transitions/deleteExperiment.js +17 -7
  190. package/dist/transitions/kernel.d.ts +2 -0
  191. package/dist/transitions/kernel.js +9 -4
  192. package/dist/transitions/makeContent.d.ts +2 -1
  193. package/dist/transitions/makeContent.js +12 -8
  194. package/dist/transitions/nestedPlacementNames.d.ts +2 -2
  195. package/dist/transitions/nestedPlacementNames.js +4 -5
  196. package/dist/transitions/phaseRecord.d.ts +2 -0
  197. package/dist/transitions/phaseRecord.js +5 -0
  198. package/dist/transitions/placementInteractions.d.ts +3 -3
  199. package/dist/transitions/placementInteractions.js +8 -7
  200. package/dist/transitions/placements.d.ts +2 -0
  201. package/dist/transitions/placements.js +5 -5
  202. package/dist/transitions/preflightData.d.ts +3 -2
  203. package/dist/transitions/preflightData.js +67 -41
  204. package/dist/transitions/releaseHoldout.d.ts +2 -1
  205. package/dist/transitions/releaseHoldout.js +3 -1
  206. package/dist/transitions/releasePages.d.ts +2 -1
  207. package/dist/transitions/releasePages.js +3 -1
  208. package/dist/transitions/resolveCaps.d.ts +2 -4
  209. package/dist/transitions/start.d.ts +6 -8
  210. package/dist/transitions/start.js +67 -34
  211. package/dist/transitions/startReads.d.ts +7 -0
  212. package/dist/transitions/startReads.js +28 -0
  213. package/dist/transitions/stop.d.ts +2 -1
  214. package/dist/transitions/stop.js +3 -2
  215. package/dist/types/contracts.d.ts +6 -3
  216. package/dist/types/endpoints.d.ts +52 -9
  217. package/dist/types/runtime.d.ts +15 -9
  218. package/dist/types/snapshot.d.ts +2 -0
  219. package/dist/ui/ChipsInput.d.ts +8 -1
  220. package/dist/ui/ChipsInput.js +17 -4
  221. 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
- export declare function stop(req: PayloadRequest, { experimentId }: {
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;
@@ -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
- /** Host adapter: true permits the request; false drops it. */
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?: RateLimiter;
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 AllocateBody = {
23
- allocation: number;
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
- export type DecideBody = {
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' | 'signedCookie';
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<{
@@ -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
- cookie?: {
9
- name?: string;
10
- maxAgeDays?: number;
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 cookie: {
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 {};
@@ -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';
@@ -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;
@@ -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 [draft, setDraft] = useState('');
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.7",
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.1",
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",