@delmaredigital/payload-experiments 0.0.0-stage → 0.1.0-rc.3

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 (466) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +582 -2
  3. package/dist/access.d.ts +1 -0
  4. package/dist/access.js +2 -0
  5. package/dist/admin/AllocationField.d.ts +2 -0
  6. package/dist/admin/AllocationField.js +80 -0
  7. package/dist/admin/FlagPointSelect.d.ts +2 -0
  8. package/dist/admin/FlagPointSelect.js +54 -0
  9. package/dist/admin/LayerUsage.d.ts +2 -0
  10. package/dist/admin/LayerUsage.js +24 -0
  11. package/dist/admin/LockedFieldNotice.d.ts +2 -0
  12. package/dist/admin/LockedFieldNotice.js +26 -0
  13. package/dist/admin/MetricSourceSelect.d.ts +2 -0
  14. package/dist/admin/MetricSourceSelect.js +32 -0
  15. package/dist/admin/PhaseHistory.d.ts +2 -0
  16. package/dist/admin/PhaseHistory.js +76 -0
  17. package/dist/admin/PreviewLinks.d.ts +11 -0
  18. package/dist/admin/PreviewLinks.js +69 -0
  19. package/dist/admin/StatusCell.d.ts +3 -0
  20. package/dist/admin/StatusCell.js +19 -0
  21. package/dist/admin/SummaryCell.d.ts +2 -0
  22. package/dist/admin/SummaryCell.js +32 -0
  23. package/dist/admin/actions/AddMetricDialog.d.ts +6 -0
  24. package/dist/admin/actions/AddMetricDialog.js +138 -0
  25. package/dist/admin/actions/AllocateDialog.d.ts +6 -0
  26. package/dist/admin/actions/AllocateDialog.js +81 -0
  27. package/dist/admin/actions/ConfirmDialog.d.ts +14 -0
  28. package/dist/admin/actions/ConfirmDialog.js +192 -0
  29. package/dist/admin/actions/DecideDialog.d.ts +7 -0
  30. package/dist/admin/actions/DecideDialog.js +173 -0
  31. package/dist/admin/actions/ExperimentActions.d.ts +3 -0
  32. package/dist/admin/actions/ExperimentActions.js +110 -0
  33. package/dist/admin/actions/MakeContentResult.d.ts +6 -0
  34. package/dist/admin/actions/MakeContentResult.js +50 -0
  35. package/dist/admin/actions/actions.model.d.ts +37 -0
  36. package/dist/admin/actions/actions.model.js +71 -0
  37. package/dist/admin/actions/decide.model.d.ts +21 -0
  38. package/dist/admin/actions/decide.model.js +38 -0
  39. package/dist/admin/allocation.model.d.ts +20 -0
  40. package/dist/admin/allocation.model.js +38 -0
  41. package/dist/admin/api.d.ts +32 -0
  42. package/dist/admin/api.js +95 -0
  43. package/dist/admin/armSelect/ArmSelectField.d.ts +2 -0
  44. package/dist/admin/armSelect/ArmSelectField.js +185 -0
  45. package/dist/admin/armSelect/armSelect.model.d.ts +30 -0
  46. package/dist/admin/armSelect/armSelect.model.js +20 -0
  47. package/dist/admin/arms/ArmsField.d.ts +2 -0
  48. package/dist/admin/arms/ArmsField.js +310 -0
  49. package/dist/admin/arms/ParamsEditor.d.ts +16 -0
  50. package/dist/admin/arms/ParamsEditor.js +79 -0
  51. package/dist/admin/arms/arms.model.d.ts +21 -0
  52. package/dist/admin/arms/arms.model.js +153 -0
  53. package/dist/admin/arms/pageTarget.model.d.ts +4 -0
  54. package/dist/admin/arms/pageTarget.model.js +19 -0
  55. package/dist/admin/arms/params.model.d.ts +7 -0
  56. package/dist/admin/arms/params.model.js +35 -0
  57. package/dist/admin/copy/actions.d.ts +38 -0
  58. package/dist/admin/copy/actions.js +38 -0
  59. package/dist/admin/copy/armSelect.d.ts +11 -0
  60. package/dist/admin/copy/armSelect.js +11 -0
  61. package/dist/admin/copy/arms.d.ts +37 -0
  62. package/dist/admin/copy/arms.js +47 -0
  63. package/dist/admin/copy/common.d.ts +20 -0
  64. package/dist/admin/copy/common.js +27 -0
  65. package/dist/admin/copy/history.d.ts +9 -0
  66. package/dist/admin/copy/history.js +9 -0
  67. package/dist/admin/copy/metrics.d.ts +9 -0
  68. package/dist/admin/copy/metrics.js +9 -0
  69. package/dist/admin/copy/results.d.ts +78 -0
  70. package/dist/admin/copy/results.js +81 -0
  71. package/dist/admin/copy/review.d.ts +33 -0
  72. package/dist/admin/copy/review.js +127 -0
  73. package/dist/admin/copy/status.d.ts +8 -0
  74. package/dist/admin/copy/status.js +8 -0
  75. package/dist/admin/copy/tabs.d.ts +7 -0
  76. package/dist/admin/copy/tabs.js +7 -0
  77. package/dist/admin/copy/who.d.ts +36 -0
  78. package/dist/admin/copy/who.js +36 -0
  79. package/dist/admin/labels.d.ts +45 -0
  80. package/dist/admin/labels.js +53 -0
  81. package/dist/admin/layerUsage.model.d.ts +15 -0
  82. package/dist/admin/layerUsage.model.js +18 -0
  83. package/dist/admin/lockedNotice.model.d.ts +3 -0
  84. package/dist/admin/lockedNotice.model.js +18 -0
  85. package/dist/admin/metricSource.model.d.ts +7 -0
  86. package/dist/admin/metricSource.model.js +11 -0
  87. package/dist/admin/paths.d.ts +16 -0
  88. package/dist/admin/paths.js +16 -0
  89. package/dist/admin/permissions.model.d.ts +10 -0
  90. package/dist/admin/permissions.model.js +4 -0
  91. package/dist/admin/phaseHistory.model.d.ts +19 -0
  92. package/dist/admin/phaseHistory.model.js +19 -0
  93. package/dist/admin/reload.d.ts +1 -0
  94. package/dist/admin/reload.js +1 -0
  95. package/dist/admin/results/ArmTable.d.ts +8 -0
  96. package/dist/admin/results/ArmTable.js +112 -0
  97. package/dist/admin/results/CappedCell.d.ts +4 -0
  98. package/dist/admin/results/CappedCell.js +24 -0
  99. package/dist/admin/results/CiChart.d.ts +10 -0
  100. package/dist/admin/results/CiChart.js +178 -0
  101. package/dist/admin/results/DataQualityPanel.d.ts +4 -0
  102. package/dist/admin/results/DataQualityPanel.js +40 -0
  103. package/dist/admin/results/ResultsView.d.ts +3 -0
  104. package/dist/admin/results/ResultsView.js +312 -0
  105. package/dist/admin/results/VerdictCard.d.ts +9 -0
  106. package/dist/admin/results/VerdictCard.js +49 -0
  107. package/dist/admin/results/chart.model.d.ts +32 -0
  108. package/dist/admin/results/chart.model.js +52 -0
  109. package/dist/admin/results/format.d.ts +10 -0
  110. package/dist/admin/results/format.js +55 -0
  111. package/dist/admin/results/results.model.d.ts +105 -0
  112. package/dist/admin/results/results.model.js +175 -0
  113. package/dist/admin/review/ReviewPanel.d.ts +2 -0
  114. package/dist/admin/review/ReviewPanel.js +268 -0
  115. package/dist/admin/review/review.model.d.ts +31 -0
  116. package/dist/admin/review/review.model.js +40 -0
  117. package/dist/admin/status.model.d.ts +16 -0
  118. package/dist/admin/status.model.js +17 -0
  119. package/dist/admin/styles.css +10 -0
  120. package/dist/admin/styles.d.ts +1 -0
  121. package/dist/admin/styles.js +2 -0
  122. package/dist/admin/summaryBatcher.d.ts +8 -0
  123. package/dist/admin/summaryBatcher.js +33 -0
  124. package/dist/admin/targeting/TargetingAttributeField.d.ts +2 -0
  125. package/dist/admin/targeting/TargetingAttributeField.js +31 -0
  126. package/dist/admin/targeting/TargetingOpField.d.ts +2 -0
  127. package/dist/admin/targeting/TargetingOpField.js +45 -0
  128. package/dist/admin/targeting/TargetingValueField.d.ts +2 -0
  129. package/dist/admin/targeting/TargetingValueField.js +142 -0
  130. package/dist/admin/targeting/targeting.model.d.ts +18 -0
  131. package/dist/admin/targeting/targeting.model.js +48 -0
  132. package/dist/admin/useApi.d.ts +20 -0
  133. package/dist/admin/useApi.js +10 -0
  134. package/dist/admin/useLayerUsage.d.ts +15 -0
  135. package/dist/admin/useLayerUsage.js +92 -0
  136. package/dist/client/ExperimentPageview.d.ts +1 -0
  137. package/dist/client/ExperimentPageview.js +27 -0
  138. package/dist/client/ExperimentsProvider.d.ts +6 -0
  139. package/dist/client/ExperimentsProvider.js +22 -0
  140. package/dist/client/ViewportExposure.d.ts +9 -0
  141. package/dist/client/ViewportExposure.js +69 -0
  142. package/dist/client/beacon.d.ts +17 -0
  143. package/dist/client/beacon.js +71 -0
  144. package/dist/client/context.d.ts +2 -0
  145. package/dist/client/context.js +2 -0
  146. package/dist/client/idempotency.d.ts +2 -0
  147. package/dist/client/idempotency.js +13 -0
  148. package/dist/client/trackConversionBeacon.d.ts +3 -0
  149. package/dist/client/trackConversionBeacon.js +16 -0
  150. package/dist/client/useExperiment.d.ts +5 -0
  151. package/dist/client/useExperiment.js +27 -0
  152. package/dist/client/useFlagPoint.d.ts +9 -0
  153. package/dist/client/useFlagPoint.js +32 -0
  154. package/dist/collections/access.d.ts +21 -0
  155. package/dist/collections/access.js +25 -0
  156. package/dist/collections/events.d.ts +3 -0
  157. package/dist/collections/events.js +117 -0
  158. package/dist/collections/experiments/armInvariants.d.ts +12 -0
  159. package/dist/collections/experiments/armInvariants.js +89 -0
  160. package/dist/collections/experiments/config.d.ts +3 -0
  161. package/dist/collections/experiments/config.js +574 -0
  162. package/dist/collections/experiments/createDefaults.d.ts +2 -0
  163. package/dist/collections/experiments/createDefaults.js +7 -0
  164. package/dist/collections/experiments/deleteGuard.d.ts +3 -0
  165. package/dist/collections/experiments/deleteGuard.js +8 -0
  166. package/dist/collections/experiments/editability.d.ts +4 -0
  167. package/dist/collections/experiments/editability.js +35 -0
  168. package/dist/collections/experiments/flagControlParams.d.ts +2 -0
  169. package/dist/collections/experiments/flagControlParams.js +32 -0
  170. package/dist/collections/experiments/lockHook.d.ts +2 -0
  171. package/dist/collections/experiments/lockHook.js +134 -0
  172. package/dist/collections/identities.d.ts +3 -0
  173. package/dist/collections/identities.js +30 -0
  174. package/dist/collections/index.d.ts +6 -0
  175. package/dist/collections/index.js +24 -0
  176. package/dist/collections/layers.d.ts +3 -0
  177. package/dist/collections/layers.js +77 -0
  178. package/dist/collections/metrics.d.ts +3 -0
  179. package/dist/collections/metrics.js +115 -0
  180. package/dist/collections/phases.d.ts +3 -0
  181. package/dist/collections/phases.js +59 -0
  182. package/dist/collections/serialize.d.ts +5 -0
  183. package/dist/collections/serialize.js +40 -0
  184. package/dist/collections/snapshots.d.ts +3 -0
  185. package/dist/collections/snapshots.js +47 -0
  186. package/dist/constants.d.ts +7 -0
  187. package/dist/constants.js +7 -0
  188. package/dist/db/adapter.d.ts +3 -0
  189. package/dist/db/adapter.js +9 -0
  190. package/dist/db/appends.d.ts +58 -0
  191. package/dist/db/appends.js +116 -0
  192. package/dist/db/delete.d.ts +17 -0
  193. package/dist/db/delete.js +35 -0
  194. package/dist/db/erase.d.ts +12 -0
  195. package/dist/db/erase.js +55 -0
  196. package/dist/db/events.d.ts +21 -0
  197. package/dist/db/events.js +100 -0
  198. package/dist/db/executor.d.ts +10 -0
  199. package/dist/db/executor.js +37 -0
  200. package/dist/db/identities.d.ts +11 -0
  201. package/dist/db/identities.js +29 -0
  202. package/dist/db/locks.d.ts +15 -0
  203. package/dist/db/locks.js +23 -0
  204. package/dist/db/manifest.d.ts +8 -0
  205. package/dist/db/manifest.js +8 -0
  206. package/dist/db/names.d.ts +271 -0
  207. package/dist/db/names.js +270 -0
  208. package/dist/db/pgExecutor.d.ts +41 -0
  209. package/dist/db/pgExecutor.js +250 -0
  210. package/dist/db/results.d.ts +53 -0
  211. package/dist/db/results.js +103 -0
  212. package/dist/db/slices.d.ts +18 -0
  213. package/dist/db/slices.js +51 -0
  214. package/dist/db/snapshots.d.ts +47 -0
  215. package/dist/db/snapshots.js +89 -0
  216. package/dist/db/sql.d.ts +5 -0
  217. package/dist/db/sql.js +5 -0
  218. package/dist/db/state.d.ts +12 -0
  219. package/dist/db/state.js +27 -0
  220. package/dist/db/sweep.d.ts +13 -0
  221. package/dist/db/sweep.js +90 -0
  222. package/dist/db/txid.d.ts +7 -0
  223. package/dist/db/txid.js +12 -0
  224. package/dist/define.d.ts +3 -0
  225. package/dist/define.js +6 -0
  226. package/dist/endpoints/events.d.ts +7 -0
  227. package/dist/endpoints/events.js +98 -0
  228. package/dist/endpoints/index.d.ts +18 -0
  229. package/dist/endpoints/index.js +160 -0
  230. package/dist/endpoints/manifest.d.ts +7 -0
  231. package/dist/endpoints/manifest.js +30 -0
  232. package/dist/endpoints/preflight.d.ts +8 -0
  233. package/dist/endpoints/preflight.js +25 -0
  234. package/dist/endpoints/previewToken.d.ts +7 -0
  235. package/dist/endpoints/previewToken.js +54 -0
  236. package/dist/endpoints/recompute.d.ts +7 -0
  237. package/dist/endpoints/recompute.js +41 -0
  238. package/dist/endpoints/results.d.ts +24 -0
  239. package/dist/endpoints/results.js +136 -0
  240. package/dist/endpoints/summary.d.ts +7 -0
  241. package/dist/endpoints/summary.js +40 -0
  242. package/dist/endpoints/transitions.d.ts +42 -0
  243. package/dist/endpoints/transitions.js +154 -0
  244. package/dist/errors.d.ts +27 -0
  245. package/dist/errors.js +33 -0
  246. package/dist/events/body.d.ts +7 -0
  247. package/dist/events/body.js +43 -0
  248. package/dist/events/dimensions.d.ts +4 -0
  249. package/dist/events/dimensions.js +51 -0
  250. package/dist/events/preview.d.ts +2 -0
  251. package/dist/events/preview.js +9 -0
  252. package/dist/events/request.d.ts +3 -0
  253. package/dist/events/request.js +14 -0
  254. package/dist/events/rows.d.ts +7 -0
  255. package/dist/events/rows.js +65 -0
  256. package/dist/exports/adminClient.d.ts +16 -0
  257. package/dist/exports/adminClient.js +17 -0
  258. package/dist/exports/client.d.ts +7 -0
  259. package/dist/exports/client.js +7 -0
  260. package/dist/exports/index.d.ts +4 -0
  261. package/dist/exports/index.js +3 -0
  262. package/dist/exports/proxy.d.ts +4 -0
  263. package/dist/exports/proxy.js +3 -0
  264. package/dist/exports/puck.d.ts +4 -0
  265. package/dist/exports/puck.js +3 -0
  266. package/dist/exports/puckEditor.d.ts +1 -0
  267. package/dist/exports/puckEditor.js +2 -0
  268. package/dist/exports/rsc.d.ts +13 -0
  269. package/dist/exports/rsc.js +13 -0
  270. package/dist/exports/runtimeProxy.d.ts +4 -0
  271. package/dist/exports/runtimeProxy.js +2 -0
  272. package/dist/exports/runtimeServer.d.ts +2 -0
  273. package/dist/exports/runtimeServer.js +1 -0
  274. package/dist/fields/armSelect.d.ts +7 -0
  275. package/dist/fields/armSelect.js +33 -0
  276. package/dist/globals/state.d.ts +3 -0
  277. package/dist/globals/state.js +31 -0
  278. package/dist/hooks/contentChanges.d.ts +3 -0
  279. package/dist/hooks/contentChanges.js +10 -0
  280. package/dist/hooks/hostHook.d.ts +5 -0
  281. package/dist/hooks/hostHook.js +20 -0
  282. package/dist/index.d.ts +1 -0
  283. package/dist/index.js +4 -0
  284. package/dist/manifest/cache.d.ts +10 -0
  285. package/dist/manifest/cache.js +51 -0
  286. package/dist/manifest/compile.d.ts +63 -0
  287. package/dist/manifest/compile.js +237 -0
  288. package/dist/onInit.d.ts +5 -0
  289. package/dist/onInit.js +13 -0
  290. package/dist/options/fromReq.d.ts +3 -0
  291. package/dist/options/fromReq.js +5 -0
  292. package/dist/options.d.ts +9 -0
  293. package/dist/options.js +99 -0
  294. package/dist/plugin.d.ts +7 -0
  295. package/dist/plugin.js +62 -0
  296. package/dist/proxy/apply.d.ts +3 -0
  297. package/dist/proxy/apply.js +5 -0
  298. package/dist/proxy/consentFallback.d.ts +5 -0
  299. package/dist/proxy/consentFallback.js +27 -0
  300. package/dist/proxy/control.d.ts +6 -0
  301. package/dist/proxy/control.js +36 -0
  302. package/dist/proxy/createProxy.d.ts +3 -0
  303. package/dist/proxy/createProxy.js +15 -0
  304. package/dist/proxy/pageRewrite.d.ts +4 -0
  305. package/dist/proxy/pageRewrite.js +41 -0
  306. package/dist/proxy/resolve.d.ts +13 -0
  307. package/dist/proxy/resolve.js +163 -0
  308. package/dist/proxy/skip.d.ts +1 -0
  309. package/dist/proxy/skip.js +9 -0
  310. package/dist/puck/ExperimentPicker.d.ts +5 -0
  311. package/dist/puck/ExperimentPicker.js +88 -0
  312. package/dist/puck/ExperimentSlot.d.ts +3 -0
  313. package/dist/puck/ExperimentSlot.js +16 -0
  314. package/dist/puck/copy.d.ts +14 -0
  315. package/dist/puck/copy.js +14 -0
  316. package/dist/puck/editor/CreateExperimentDrawer.d.ts +5 -0
  317. package/dist/puck/editor/CreateExperimentDrawer.js +120 -0
  318. package/dist/puck/editor/ExperimentSlotEditor.d.ts +3 -0
  319. package/dist/puck/editor/ExperimentSlotEditor.js +225 -0
  320. package/dist/puck/editor/cloneSlot.d.ts +3 -0
  321. package/dist/puck/editor/cloneSlot.js +41 -0
  322. package/dist/puck/editor/copy.d.ts +25 -0
  323. package/dist/puck/editor/copy.js +25 -0
  324. package/dist/puck/editor/editor.model.d.ts +16 -0
  325. package/dist/puck/editor/editor.model.js +33 -0
  326. package/dist/puck/experimentSlotField.d.ts +5 -0
  327. package/dist/puck/experimentSlotField.js +13 -0
  328. package/dist/puck/slot.model.d.ts +2 -0
  329. package/dist/puck/slot.model.js +11 -0
  330. package/dist/puck/slotConfig.d.ts +5 -0
  331. package/dist/puck/slotConfig.js +25 -0
  332. package/dist/results/aggregate.d.ts +34 -0
  333. package/dist/results/aggregate.js +66 -0
  334. package/dist/results/analyse.d.ts +79 -0
  335. package/dist/results/analyse.js +378 -0
  336. package/dist/results/cuped.d.ts +16 -0
  337. package/dist/results/cuped.js +31 -0
  338. package/dist/results/decideGuard.d.ts +3 -0
  339. package/dist/results/decideGuard.js +8 -0
  340. package/dist/results/guardrails.d.ts +17 -0
  341. package/dist/results/guardrails.js +10 -0
  342. package/dist/results/history.d.ts +13 -0
  343. package/dist/results/history.js +39 -0
  344. package/dist/results/identityCredit.d.ts +16 -0
  345. package/dist/results/identityCredit.js +46 -0
  346. package/dist/results/power.d.ts +15 -0
  347. package/dist/results/power.js +60 -0
  348. package/dist/results/rolloutUnits.d.ts +17 -0
  349. package/dist/results/rolloutUnits.js +26 -0
  350. package/dist/results/snapshot.d.ts +9 -0
  351. package/dist/results/snapshot.js +154 -0
  352. package/dist/results/srm.d.ts +9 -0
  353. package/dist/results/srm.js +22 -0
  354. package/dist/results/verdict.d.ts +82 -0
  355. package/dist/results/verdict.js +85 -0
  356. package/dist/runtime/assign.d.ts +23 -0
  357. package/dist/runtime/assign.js +104 -0
  358. package/dist/runtime/bot.d.ts +1 -0
  359. package/dist/runtime/bot.js +7 -0
  360. package/dist/runtime/cookie.d.ts +17 -0
  361. package/dist/runtime/cookie.js +35 -0
  362. package/dist/runtime/eligibility.d.ts +22 -0
  363. package/dist/runtime/eligibility.js +20 -0
  364. package/dist/runtime/header.d.ts +17 -0
  365. package/dist/runtime/header.js +97 -0
  366. package/dist/runtime/loaders.d.ts +17 -0
  367. package/dist/runtime/loaders.js +29 -0
  368. package/dist/runtime/normalisePath.d.ts +7 -0
  369. package/dist/runtime/normalisePath.js +15 -0
  370. package/dist/runtime/previewToken.d.ts +9 -0
  371. package/dist/runtime/previewToken.js +23 -0
  372. package/dist/runtime/proxyRuntime.d.ts +2 -0
  373. package/dist/runtime/proxyRuntime.js +22 -0
  374. package/dist/runtime/seed.d.ts +2 -0
  375. package/dist/runtime/seed.js +4 -0
  376. package/dist/runtime/signing.d.ts +3 -0
  377. package/dist/runtime/signing.js +16 -0
  378. package/dist/runtime/targeting.d.ts +6 -0
  379. package/dist/runtime/targeting.js +9 -0
  380. package/dist/server/context.d.ts +10 -0
  381. package/dist/server/context.js +59 -0
  382. package/dist/server/eraseUser.d.ts +7 -0
  383. package/dist/server/eraseUser.js +4 -0
  384. package/dist/server/getAssignments.d.ts +9 -0
  385. package/dist/server/getAssignments.js +227 -0
  386. package/dist/server/getFlagPoint.d.ts +11 -0
  387. package/dist/server/getFlagPoint.js +36 -0
  388. package/dist/server/headerRevision.d.ts +6 -0
  389. package/dist/server/headerRevision.js +10 -0
  390. package/dist/server/linkIdentity.d.ts +9 -0
  391. package/dist/server/linkIdentity.js +34 -0
  392. package/dist/server/metadata.d.ts +7 -0
  393. package/dist/server/metadata.js +24 -0
  394. package/dist/server/previewDraft.d.ts +7 -0
  395. package/dist/server/previewDraft.js +51 -0
  396. package/dist/server/recordContentChange.d.ts +7 -0
  397. package/dist/server/recordContentChange.js +150 -0
  398. package/dist/server/recordExposures.d.ts +7 -0
  399. package/dist/server/recordExposures.js +56 -0
  400. package/dist/server/request.d.ts +7 -0
  401. package/dist/server/request.js +39 -0
  402. package/dist/server/resolveExperimentData.d.ts +6 -0
  403. package/dist/server/resolveExperimentData.js +64 -0
  404. package/dist/server/runResults.d.ts +22 -0
  405. package/dist/server/runResults.js +307 -0
  406. package/dist/server/serverRuntime.d.ts +7 -0
  407. package/dist/server/serverRuntime.js +20 -0
  408. package/dist/server/sitemap.d.ts +3 -0
  409. package/dist/server/sitemap.js +6 -0
  410. package/dist/server/toClientAssignments.d.ts +7 -0
  411. package/dist/server/toClientAssignments.js +56 -0
  412. package/dist/server/trackConversion.d.ts +12 -0
  413. package/dist/server/trackConversion.js +69 -0
  414. package/dist/targeting/ops.d.ts +8 -0
  415. package/dist/targeting/ops.js +58 -0
  416. package/dist/transitions/addMetric.d.ts +16 -0
  417. package/dist/transitions/addMetric.js +126 -0
  418. package/dist/transitions/allocate.d.ts +9 -0
  419. package/dist/transitions/allocate.js +84 -0
  420. package/dist/transitions/archive.d.ts +9 -0
  421. package/dist/transitions/archive.js +46 -0
  422. package/dist/transitions/checkStart.d.ts +61 -0
  423. package/dist/transitions/checkStart.js +104 -0
  424. package/dist/transitions/confirmPhrases.d.ts +5 -0
  425. package/dist/transitions/confirmPhrases.js +18 -0
  426. package/dist/transitions/decide.d.ts +9 -0
  427. package/dist/transitions/decide.js +138 -0
  428. package/dist/transitions/deleteExperiment.d.ts +5 -0
  429. package/dist/transitions/deleteExperiment.js +66 -0
  430. package/dist/transitions/kernel.d.ts +31 -0
  431. package/dist/transitions/kernel.js +69 -0
  432. package/dist/transitions/makeContent.d.ts +20 -0
  433. package/dist/transitions/makeContent.js +411 -0
  434. package/dist/transitions/phaseRecord.d.ts +27 -0
  435. package/dist/transitions/phaseRecord.js +81 -0
  436. package/dist/transitions/placements.d.ts +26 -0
  437. package/dist/transitions/placements.js +89 -0
  438. package/dist/transitions/preflightData.d.ts +21 -0
  439. package/dist/transitions/preflightData.js +317 -0
  440. package/dist/transitions/releaseHoldout.d.ts +8 -0
  441. package/dist/transitions/releaseHoldout.js +30 -0
  442. package/dist/transitions/resolveCaps.d.ts +28 -0
  443. package/dist/transitions/resolveCaps.js +68 -0
  444. package/dist/transitions/start.d.ts +26 -0
  445. package/dist/transitions/start.js +220 -0
  446. package/dist/transitions/stop.d.ts +8 -0
  447. package/dist/transitions/stop.js +25 -0
  448. package/dist/types/admin.d.ts +20 -0
  449. package/dist/types/admin.js +1 -0
  450. package/dist/types/assignments.d.ts +57 -0
  451. package/dist/types/assignments.js +1 -0
  452. package/dist/types/contracts.d.ts +133 -0
  453. package/dist/types/contracts.js +2 -0
  454. package/dist/types/endpoints.d.ts +135 -0
  455. package/dist/types/endpoints.js +1 -0
  456. package/dist/types/index.d.ts +8 -0
  457. package/dist/types/index.js +8 -0
  458. package/dist/types/manifest.d.ts +42 -0
  459. package/dist/types/manifest.js +1 -0
  460. package/dist/types/puck.d.ts +23 -0
  461. package/dist/types/puck.js +1 -0
  462. package/dist/types/runtime.d.ts +59 -0
  463. package/dist/types/runtime.js +1 -0
  464. package/dist/types/snapshot.d.ts +117 -0
  465. package/dist/types/snapshot.js +1 -0
  466. package/package.json +137 -3
@@ -0,0 +1,26 @@
1
+ import type { PayloadRequest } from 'payload';
2
+ import type { DocId, ResolvedOptions } from '../types/contracts.js';
3
+ import type { RefusalCode } from '../types/endpoints.js';
4
+ import { type StartExperiment } from './checkStart.js';
5
+ export type TransitionExperiment = StartExperiment & Record<string, unknown> & {
6
+ phase?: number;
7
+ seed?: string;
8
+ updatedAt?: string;
9
+ layerSlices?: number[] | null;
10
+ };
11
+ export declare function readExperiment(req: PayloadRequest, id: DocId): Promise<TransitionExperiment>;
12
+ export declare function refuse(code: RefusalCode, detail?: unknown): never;
13
+ export declare function updateExperiment(req: PayloadRequest, id: DocId, data: Record<string, unknown>): Promise<import("payload").JsonObject & import("payload").TypeWithID>;
14
+ export declare function start<TUser extends {
15
+ id: DocId;
16
+ }>(req: PayloadRequest, { experimentId, options }: {
17
+ experimentId: DocId;
18
+ options: ResolvedOptions<TUser>;
19
+ }): Promise<{
20
+ detail?: {
21
+ metricId: DocId;
22
+ message: string;
23
+ }[] | undefined;
24
+ doc: import("payload").JsonObject & import("payload").TypeWithID;
25
+ revision: number;
26
+ }>;
@@ -0,0 +1,220 @@
1
+ import { randomBytes } from 'node:crypto';
2
+ import { claimSlices } from '../db/slices.js';
3
+ import { XpRefusal } from '../errors.js';
4
+ import { isOpValid } from '../targeting/ops.js';
5
+ import { checkStart, relationshipId } from './checkStart.js';
6
+ import { withTransition } from './kernel.js';
7
+ import { writePhaseRecord } from './phaseRecord.js';
8
+ import { loadStartInputs } from './preflightData.js';
9
+ import { resolveCaps } from './resolveCaps.js';
10
+ export async function readExperiment(req, id) {
11
+ // §7.8: internal lookup serves the authorised transition write. Preserve
12
+ // admin-only analysis.method/kind for freezing; return access-filtered docs.
13
+ const { docs } = await req.payload.find({
14
+ collection: 'xp-experiments',
15
+ req,
16
+ overrideAccess: true,
17
+ depth: 0,
18
+ limit: 1,
19
+ where: {
20
+ id: {
21
+ equals: id
22
+ }
23
+ }
24
+ });
25
+ if (!docs[0]) throw new XpRefusal('not-found', 'Experiment not found', undefined, 404);
26
+ return docs[0];
27
+ }
28
+ export function refuse(code, detail) {
29
+ const messages = {
30
+ 'invalid-status': 'This action is not available in the current status.',
31
+ 'stale-draft': 'The experiment changed. Review it again before starting.',
32
+ 'flag-point-busy': 'Another experiment is running or decided on this flag point.',
33
+ 'layer-full': 'There is not enough room in this layer.',
34
+ 'allocation-lower': 'Allocation can only increase while running. Stop and start a new round to lower it.',
35
+ 'invalid-body': 'Check the experiment settings and try again.'
36
+ };
37
+ const conflict = [
38
+ 'invalid-status',
39
+ 'stale-draft',
40
+ 'flag-point-busy',
41
+ 'layer-full',
42
+ 'allocation-lower'
43
+ ].includes(code);
44
+ throw new XpRefusal(code, messages[code] ?? 'The experiment is not ready to start.', detail, conflict ? 409 : 422);
45
+ }
46
+ export async function updateExperiment(req, id, data) {
47
+ // §7.8: access-authorised transition writes locked plugin fields.
48
+ await req.payload.update({
49
+ collection: 'xp-experiments',
50
+ req,
51
+ id,
52
+ data,
53
+ overrideAccess: true
54
+ });
55
+ const { docs } = await req.payload.find({
56
+ collection: 'xp-experiments',
57
+ req,
58
+ overrideAccess: false,
59
+ depth: 0,
60
+ limit: 1,
61
+ where: {
62
+ id: {
63
+ equals: id
64
+ }
65
+ }
66
+ });
67
+ if (!docs[0]) throw new XpRefusal('not-found', 'Experiment not found', undefined, 404);
68
+ return docs[0];
69
+ }
70
+ export async function start(req, { experimentId, options }) {
71
+ const input = await loadStartInputs(req, options, experimentId);
72
+ if (!input) throw new XpRefusal('not-found', 'Experiment not found', undefined, 404);
73
+ const full = await readExperiment(req, experimentId);
74
+ if (full.updatedAt !== input.experiment.updatedAt) refuse('stale-draft');
75
+ // Review reads respect field access; internal writes must preserve hidden config.
76
+ input.experiment = {
77
+ ...input.experiment,
78
+ kind: full.kind,
79
+ analysis: full.analysis
80
+ };
81
+ const failed = checkStart(input).find((check)=>!check.ok);
82
+ if (failed) refuse(failed.code, failed.detail);
83
+ const before = input.experiment;
84
+ const updatedAt = before.updatedAt;
85
+ const at = new Date();
86
+ const caps = await resolveCaps(input.metrics, options.metricSources ?? [], at);
87
+ const { result: doc, revision } = await withTransition(req, {
88
+ experimentId,
89
+ layerId: relationshipId(before.layer),
90
+ flagPointId: before.kind === 'flag' ? before.flagPoint : undefined
91
+ }, async ({ req, exec })=>{
92
+ const current = await readExperiment(req, experimentId);
93
+ if (current.updatedAt !== updatedAt) refuse('stale-draft');
94
+ if (current.status !== 'draft' && current.status !== 'stopped') refuse('invalid-status');
95
+ if (current.kind === 'flag' && current.flagPoint) {
96
+ const busy = await req.payload.find({
97
+ collection: 'xp-experiments',
98
+ req,
99
+ overrideAccess: false,
100
+ depth: 0,
101
+ limit: 2,
102
+ where: {
103
+ and: [
104
+ {
105
+ flagPoint: {
106
+ equals: current.flagPoint
107
+ }
108
+ },
109
+ {
110
+ status: {
111
+ in: [
112
+ 'running',
113
+ 'decided'
114
+ ]
115
+ }
116
+ }
117
+ ]
118
+ }
119
+ });
120
+ if (busy.docs.some((doc)=>String(doc.id) !== String(experimentId))) refuse('flag-point-busy');
121
+ const point = options.flagPoints.find((point)=>point.id === current.flagPoint);
122
+ const state = await req.payload.findGlobal({
123
+ slug: 'xp-state',
124
+ req,
125
+ overrideAccess: false,
126
+ depth: 0
127
+ });
128
+ const defaults = state.flagDefaults;
129
+ current.arms = current.arms.map((arm)=>arm.kind === 'control' ? {
130
+ ...arm,
131
+ params: defaults?.[point.id]?.params ?? point.defaultParams
132
+ } : arm);
133
+ const recheck = checkStart({
134
+ ...input,
135
+ experiment: current
136
+ }).find((check)=>!check.ok);
137
+ if (recheck) refuse(recheck.code, recheck.detail);
138
+ }
139
+ const targeting = (current.targeting ?? []).map((rule)=>{
140
+ const type = Object.hasOwn(options.attributeKeys ?? {}, rule.attribute) ? options.attributeKeys[rule.attribute].type : undefined;
141
+ const validValue = type === 'string' && [
142
+ 'in',
143
+ 'nin'
144
+ ].includes(rule.op) ? Array.isArray(rule.value) && rule.value.length > 0 && rule.value.every((value)=>typeof value === 'string') : typeof rule.value === type && (type !== 'number' || Number.isFinite(rule.value));
145
+ if (!type) refuse('undeclared-targeting-key', {
146
+ attribute: rule.attribute
147
+ });
148
+ if (!isOpValid(type, rule.op) || !validValue) refuse('invalid-targeting-rule', {
149
+ attribute: rule.attribute
150
+ });
151
+ return {
152
+ ...rule,
153
+ type
154
+ };
155
+ });
156
+ const layerId = relationshipId(current.layer);
157
+ const layerSlices = layerId === undefined ? [] : await claimSlices(exec, {
158
+ layerId,
159
+ experimentId,
160
+ count: current.allocation
161
+ });
162
+ const phase = (current.phase ?? 0) + 1;
163
+ const seed = `${randomBytes(16).toString('hex')}|`;
164
+ const startedAt = at.toISOString();
165
+ const definitions = caps.definitions.map((metric)=>({
166
+ ...metric,
167
+ metricId: metric.id,
168
+ addedAt: startedAt,
169
+ role: String(relationshipId(current.metrics?.primary)) === String(metric.id) ? 'primary' : current.metrics?.guardrails?.some((id)=>String(relationshipId(id)) === String(metric.id)) ? 'guardrail' : 'secondary'
170
+ }));
171
+ await writePhaseRecord(req, {
172
+ experiment: experimentId,
173
+ phase,
174
+ phaseKind: 'test',
175
+ seed,
176
+ startedAt,
177
+ arms: current.arms,
178
+ allocation: current.allocation,
179
+ allocationChanges: [],
180
+ targeting,
181
+ metricDefinitions: definitions,
182
+ analysis: {
183
+ ...current.analysis,
184
+ method: current.analysis?.method ?? 'sequential',
185
+ alpha: 0.05,
186
+ cupedLookbackDays: 14,
187
+ layerSlices,
188
+ minSampleSizes: Object.fromEntries(definitions.map((metric)=>[
189
+ metric.id,
190
+ metric.minSampleSize ?? 150
191
+ ])),
192
+ guardrailThresholds: Object.fromEntries(definitions.filter((metric)=>metric.role === 'guardrail').map((metric)=>[
193
+ metric.id,
194
+ metric.guardrailThreshold ?? 0.05
195
+ ])),
196
+ bayesian: {
197
+ ctw: 0.95,
198
+ risk: 0.0125
199
+ }
200
+ },
201
+ contentChanges: []
202
+ });
203
+ return updateExperiment(req, experimentId, {
204
+ status: 'running',
205
+ phase,
206
+ seed,
207
+ startedAt,
208
+ stoppedAt: null,
209
+ layerSlices,
210
+ arms: current.arms
211
+ });
212
+ });
213
+ return {
214
+ doc,
215
+ revision: revision,
216
+ ...caps.detail.length ? {
217
+ detail: caps.detail
218
+ } : {}
219
+ };
220
+ }
@@ -0,0 +1,8 @@
1
+ import type { PayloadRequest } from 'payload';
2
+ import type { DocId } from '../types/contracts.js';
3
+ export declare function stop(req: PayloadRequest, { experimentId }: {
4
+ experimentId: DocId;
5
+ }): Promise<{
6
+ doc: import("payload").JsonObject & import("payload").TypeWithID;
7
+ revision: number;
8
+ }>;
@@ -0,0 +1,25 @@
1
+ import { relationshipId } from './checkStart.js';
2
+ import { withTransition } from './kernel.js';
3
+ import { setPhaseEndedAt } from './phaseRecord.js';
4
+ import { readExperiment, refuse, updateExperiment } from './start.js';
5
+ export async function stop(req, { experimentId }) {
6
+ const before = await readExperiment(req, experimentId);
7
+ const { result: doc, revision } = await withTransition(req, {
8
+ experimentId,
9
+ layerId: relationshipId(before.layer)
10
+ }, async ({ req })=>{
11
+ const current = await readExperiment(req, experimentId);
12
+ if (current.status !== 'running') refuse('invalid-status');
13
+ const at = new Date().toISOString();
14
+ await setPhaseEndedAt(req, experimentId, current.phase, at);
15
+ return updateExperiment(req, experimentId, {
16
+ status: 'stopped',
17
+ layerSlices: [],
18
+ stoppedAt: at
19
+ });
20
+ });
21
+ return {
22
+ doc,
23
+ revision: revision
24
+ };
25
+ }
@@ -0,0 +1,20 @@
1
+ import type { MetricSource, ParamField } from './contracts.js';
2
+ export type SerializedFlagPoint = {
3
+ id: string;
4
+ label: string;
5
+ params: Record<string, ParamField>;
6
+ defaultParams: Record<string, unknown>;
7
+ effectiveDefaults: Record<string, unknown>;
8
+ };
9
+ export type SerializedMetricSource = {
10
+ id: string;
11
+ label: string;
12
+ kind: MetricSource['kind'];
13
+ keyedBy: MetricSource['keyedBy'];
14
+ clientWritable: boolean;
15
+ };
16
+ export type SerializedAttributeKeys = Record<string, {
17
+ type: 'string' | 'number' | 'boolean';
18
+ values?: string[];
19
+ }>;
20
+ export type EditableField = 'name' | 'hypothesis' | 'arms' | 'targeting' | 'allocation' | 'flagPoint' | 'metrics' | 'analysis' | 'exposurePolicy';
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,57 @@
1
+ import type { DocId, ExposurePolicy } from './contracts.js';
2
+ export interface Assignment {
3
+ slug: string;
4
+ experimentId: DocId;
5
+ arm: string;
6
+ phase: number;
7
+ exposable: boolean;
8
+ policy: ExposurePolicy;
9
+ source: 'header' | 'recomputed' | 'preview' | 'fallback';
10
+ }
11
+ export interface Assignments {
12
+ archivedWinners: Record<string, string>;
13
+ revision: number;
14
+ visitorId?: string;
15
+ userId?: string;
16
+ bySlug: Record<string, Assignment>;
17
+ flagPoints: Record<string, FlagPointResult>;
18
+ staff: boolean;
19
+ bot: boolean;
20
+ preview: boolean;
21
+ sessionUnknown: boolean;
22
+ method: string;
23
+ }
24
+ export interface FlagPointResult {
25
+ arm: string;
26
+ params: Record<string, unknown>;
27
+ source: 'experiment' | 'default';
28
+ experiment?: string;
29
+ experimentId?: DocId;
30
+ phase?: number;
31
+ policy?: ExposurePolicy;
32
+ exposable: boolean;
33
+ }
34
+ export interface ClientAssignments {
35
+ v: 1;
36
+ revision: number;
37
+ apiRoute: string;
38
+ experiments: Record<string, {
39
+ arm: string;
40
+ experimentId: DocId;
41
+ phase: number;
42
+ params: Record<string, unknown>;
43
+ policy: ExposurePolicy;
44
+ exposable: boolean;
45
+ }>;
46
+ flagPoints: Record<string, FlagPointResult>;
47
+ pageviews: Array<{
48
+ slug: string;
49
+ phase: number;
50
+ arm: string;
51
+ }>;
52
+ }
53
+ export interface RenderedExposure {
54
+ slug: string;
55
+ arm: string;
56
+ phase: number;
57
+ }
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,133 @@
1
+ import type { PayloadRequest } from 'payload';
2
+ import type { ExperimentsServerRuntime } from './runtime.js';
3
+ import type { ArmSlot } from './puck.js';
4
+ import type { TargetingOp } from '../targeting/ops.js';
5
+ export type DocId = string | number;
6
+ export type Attributes = Record<string, string | number | boolean>;
7
+ export type ExposurePolicy = 'render' | 'viewport' | 'pageview' | 'manual';
8
+ export type ExperimentKind = 'block' | 'page' | 'flag' | 'code';
9
+ export type Status = 'draft' | 'running' | 'stopped' | 'decided' | 'archived';
10
+ export type UnitType = 'visitor' | 'user';
11
+ export type ArmKey = 'control' | 'variantA' | 'variantB' | 'variantC' | 'holdout';
12
+ export type ArmKind = 'control' | 'variant' | 'holdout';
13
+ export interface TargetingRule {
14
+ attribute: string;
15
+ op: TargetingOp;
16
+ value: string | number | boolean | string[];
17
+ }
18
+ export interface Arm {
19
+ key: ArmKey;
20
+ label: string;
21
+ weight: number;
22
+ kind: ArmKind;
23
+ slot?: ArmSlot;
24
+ params?: Record<string, unknown>;
25
+ pageTarget?: string;
26
+ }
27
+ export interface ParamField {
28
+ type: 'text' | 'textarea' | 'number' | 'checkbox' | 'select';
29
+ label: string;
30
+ required?: boolean;
31
+ options?: Array<{
32
+ label: string;
33
+ value: string;
34
+ }>;
35
+ min?: number;
36
+ max?: number;
37
+ }
38
+ export interface MetricSource {
39
+ id: string;
40
+ label: string;
41
+ kind: 'binomial' | 'count' | 'revenue';
42
+ keyedBy: UnitType;
43
+ clientWritable?: boolean;
44
+ query(args: {
45
+ from: Date;
46
+ to: Date;
47
+ unitIds?: string[];
48
+ }): Promise<Array<{
49
+ unitId: string;
50
+ value: number;
51
+ ts: Date;
52
+ }>>;
53
+ covariate?(args: {
54
+ units: Array<{
55
+ unitId: string;
56
+ firstExposureTs: Date;
57
+ }>;
58
+ lookbackDays: number;
59
+ }): Promise<Array<{
60
+ unitId: string;
61
+ value: number;
62
+ }>>;
63
+ }
64
+ export interface FlagPoint {
65
+ id: string;
66
+ label: string;
67
+ params: Record<string, ParamField>;
68
+ defaultParams: Record<string, unknown>;
69
+ placements?(args: {
70
+ experimentId: DocId;
71
+ arms: string[];
72
+ req: PayloadRequest;
73
+ }): Promise<Array<{
74
+ arm: string;
75
+ ok: boolean;
76
+ detail?: string;
77
+ }>>;
78
+ makeContent?(args: {
79
+ experimentId: DocId;
80
+ winner: {
81
+ arm: string;
82
+ params: Record<string, unknown>;
83
+ };
84
+ req: PayloadRequest;
85
+ }): Promise<void>;
86
+ }
87
+ /** Host adapter: true permits the request; false drops it. */
88
+ export type RateLimiter = (args: {
89
+ req: PayloadRequest;
90
+ unitId: string;
91
+ }) => boolean | Promise<boolean>;
92
+ export type ExperimentsAccess = (args: {
93
+ req: PayloadRequest;
94
+ }) => boolean | Promise<boolean>;
95
+ export interface ExperimentsPluginOptions<TUser extends {
96
+ id: string | number;
97
+ } = {
98
+ id: string | number;
99
+ }> {
100
+ runtime: ExperimentsServerRuntime<TUser>;
101
+ access: {
102
+ manage: ExperimentsAccess;
103
+ admin?: ExperimentsAccess;
104
+ readResults?: ExperimentsAccess;
105
+ readIdentities?: ExperimentsAccess;
106
+ };
107
+ metricSources?: MetricSource[];
108
+ eventSources?: string[];
109
+ flagPoints?: FlagPoint[];
110
+ attributeKeys?: Record<string, {
111
+ type: 'string' | 'number' | 'boolean';
112
+ values?: string[];
113
+ }>;
114
+ puck?: {
115
+ enabled: boolean;
116
+ collections: Array<string | {
117
+ slug: string;
118
+ field?: string;
119
+ }>;
120
+ };
121
+ events?: {
122
+ retentionDays?: number;
123
+ maxBodyBytes?: number;
124
+ rateLimit?: RateLimiter;
125
+ dimensions?: string[];
126
+ };
127
+ }
128
+ /** Options required by the route table; CORE-02c resolves optional defaults. */
129
+ export type ResolvedOptions<TUser extends {
130
+ id: string | number;
131
+ } = {
132
+ id: string | number;
133
+ }> = ExperimentsPluginOptions<TUser>;
@@ -0,0 +1,2 @@
1
+ /** Options required by the route table; CORE-02c resolves optional defaults. */ // CORE-02c may narrow this alias (pre-authorised exception to the src/types freeze)
2
+ export { };
@@ -0,0 +1,135 @@
1
+ import type { ArmKind, DocId, ExposurePolicy, MetricSource, ResolvedOptions } from './contracts.js';
2
+ import type { Snapshot, VerdictCode } from './snapshot.js';
3
+ export type ArmIssueCode = 'weights-total' | 'control-count' | 'control-first' | 'holdout-last' | 'holdout-count' | 'variant-count' | 'duplicate-key' | 'duplicate-slot' | 'slot-required' | 'invalid-key';
4
+ export type RefusalCode = ArmIssueCode | 'not-found' | 'no-planned-duration' | 'no-primary-metric' | 'no-placements' | 'empty-slot' | 'page-no-targets' | 'page-user-unit' | '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' | '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' | 'undeclared-targeting-key' | 'invalid-targeting-rule' | 'duplicate-metric';
5
+ export type ErrorEnvelope = {
6
+ errors: Array<{
7
+ code: RefusalCode;
8
+ message: string;
9
+ detail?: unknown;
10
+ }>;
11
+ };
12
+ export type TransitionSuccess = {
13
+ doc: Record<string, unknown>;
14
+ revision: number;
15
+ };
16
+ export type AllocateBody = {
17
+ allocation: number;
18
+ };
19
+ export type AddMetricBody = {
20
+ metric: DocId;
21
+ role: 'secondary' | 'guardrail';
22
+ };
23
+ export type DecideBody = {
24
+ winnerArm: string;
25
+ note?: string;
26
+ confirmation?: string;
27
+ };
28
+ export type ArchiveBody = {
29
+ mode: 'stopped' | 'after-content' | 'discard' | 'hard-coded';
30
+ confirmation?: string;
31
+ };
32
+ export type MakeContentResult = TransitionSuccess & {
33
+ docs: Array<{
34
+ collection: string;
35
+ id: DocId;
36
+ ok: boolean;
37
+ error?: string;
38
+ }>;
39
+ };
40
+ export type PreflightResult = {
41
+ checks: Array<{
42
+ code: RefusalCode;
43
+ ok: boolean;
44
+ detail?: unknown;
45
+ }>;
46
+ placements: Array<{
47
+ collection: string;
48
+ id: DocId;
49
+ title: string;
50
+ url?: string;
51
+ ok: boolean;
52
+ detail?: string;
53
+ }>;
54
+ baseline: {
55
+ metricId: DocId;
56
+ value: number;
57
+ days: 28;
58
+ } | null;
59
+ trafficPerDay: number | null;
60
+ estimate: {
61
+ weeks: number;
62
+ plannedDurationDays: number;
63
+ sequentialTuningParameter: number;
64
+ feasible: boolean;
65
+ } | null;
66
+ };
67
+ export type PreviewTokenResult = {
68
+ token: string;
69
+ };
70
+ export interface PhaseSummary {
71
+ phase: number;
72
+ phaseKind: 'test' | 'rollout';
73
+ startedAt: string;
74
+ endedAt: string | null;
75
+ arms: Array<{
76
+ key: string;
77
+ label: string;
78
+ kind: ArmKind;
79
+ }>;
80
+ metrics: Array<{
81
+ metricId: DocId;
82
+ name: string;
83
+ kind: MetricSource['kind'];
84
+ role: 'primary' | 'secondary' | 'guardrail';
85
+ resolvedCap?: number | null;
86
+ historyUnits?: number;
87
+ capNotice?: 'no-history';
88
+ }>;
89
+ }
90
+ export type ResultsResponse = {
91
+ phases: PhaseSummary[];
92
+ snapshot: Snapshot | null;
93
+ decisionSnapshot?: Snapshot;
94
+ series?: Array<{
95
+ computedAt: string;
96
+ metricId: DocId;
97
+ arm: string;
98
+ lift: number;
99
+ ci: [number | null, number | null];
100
+ }>;
101
+ };
102
+ export type SummaryResponse = Record<DocId, {
103
+ exposures: number;
104
+ days: number;
105
+ verdict: {
106
+ code: VerdictCode;
107
+ headline: string;
108
+ } | null;
109
+ }>;
110
+ export type EventBody = {
111
+ events: Array<{
112
+ type: 'exposure';
113
+ experiment: string;
114
+ phase: number;
115
+ arm: string;
116
+ policy: ExposurePolicy;
117
+ } | {
118
+ type: 'conversion';
119
+ eventName: string;
120
+ value?: number;
121
+ idempotencyKey: string;
122
+ attributes?: Record<string, string | number | boolean>;
123
+ }>;
124
+ };
125
+ export type AccessKind = 'manage' | 'readResults' | 'manifestKey' | 'signedCookie';
126
+ export type EndpointContext<TUser extends {
127
+ id: string | number;
128
+ } = {
129
+ id: string | number;
130
+ }> = {
131
+ options: ResolvedOptions<TUser>;
132
+ unit?: {
133
+ visitorId: string;
134
+ };
135
+ };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,8 @@
1
+ export * from './contracts.js';
2
+ export * from './runtime.js';
3
+ export * from './manifest.js';
4
+ export * from './assignments.js';
5
+ export * from './puck.js';
6
+ export * from './admin.js';
7
+ export * from './endpoints.js';
8
+ export * from './snapshot.js';
@@ -0,0 +1,8 @@
1
+ export * from './contracts.js';
2
+ export * from './runtime.js';
3
+ export * from './manifest.js';
4
+ export * from './assignments.js';
5
+ export * from './puck.js';
6
+ export * from './admin.js';
7
+ export * from './endpoints.js';
8
+ export * from './snapshot.js';