@storyshelf/core 0.6.2 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (628) hide show
  1. package/README.md +49 -32
  2. package/dist/adapter/capture-queue.d.mts +44 -2
  3. package/dist/adapter/capture-runner.d.mts +127 -10
  4. package/dist/adapter/capture-runner.mjs +5 -12
  5. package/dist/adapter/database.d.mts +27 -8
  6. package/dist/adapter/database.mjs.map +1 -1
  7. package/dist/adapter/design.d.mts +85 -0
  8. package/dist/adapter/design.mjs +28 -0
  9. package/dist/adapter/design.mjs.map +1 -0
  10. package/dist/adapter/metadata.d.mts +3 -10
  11. package/dist/adapter/notifier.d.mts +6 -3
  12. package/dist/adapter/notifier.mjs +5 -1
  13. package/dist/adapter/oauth.d.mts +52 -0
  14. package/dist/adapter/setup.d.mts +4 -5
  15. package/dist/adapter/setup.mjs +2 -1
  16. package/dist/adapter/setup.mjs.map +1 -1
  17. package/dist/adapter/webhook-events.mjs +1 -1
  18. package/dist/adapters/capture-target-offers.d.mts +28 -0
  19. package/dist/adapters/capture-target-offers.mjs +58 -0
  20. package/dist/adapters/capture-target-offers.mjs.map +1 -0
  21. package/dist/adapters/capture-target.d.mts +71 -0
  22. package/dist/adapters/capture-target.mjs +76 -0
  23. package/dist/adapters/capture-target.mjs.map +1 -0
  24. package/dist/adapters/notifier/build-comment.d.mts +24 -0
  25. package/dist/adapters/notifier/build-comment.mjs +24 -0
  26. package/dist/adapters/notifier/build-comment.mjs.map +1 -0
  27. package/dist/adapters/notifier/build-state.d.mts +99 -0
  28. package/dist/adapters/notifier/build-state.mjs +218 -0
  29. package/dist/adapters/notifier/build-state.mjs.map +1 -0
  30. package/dist/adapters/notifier/events.d.mts +4 -2
  31. package/dist/adapters/notifier/events.mjs +31 -18
  32. package/dist/adapters/notifier/events.mjs.map +1 -1
  33. package/dist/adapters/notifier/provider.d.mts +53 -7
  34. package/dist/adapters/notifier/provider.mjs +12 -0
  35. package/dist/adapters/notifier/provider.mjs.map +1 -0
  36. package/dist/adapters/notifier/state.d.mts +24 -0
  37. package/dist/adapters/notifier/state.mjs +66 -0
  38. package/dist/adapters/notifier/state.mjs.map +1 -0
  39. package/dist/adapters/notifier/types.d.mts +51 -2
  40. package/dist/adapters/remote-browser.d.mts +87 -0
  41. package/dist/adapters/remote-browser.mjs +103 -0
  42. package/dist/adapters/remote-browser.mjs.map +1 -0
  43. package/dist/adapters/render-runs.d.mts +25 -0
  44. package/dist/adapters/render-runs.mjs +41 -0
  45. package/dist/adapters/render-runs.mjs.map +1 -0
  46. package/dist/adapters/setup-runner.mjs +2 -4
  47. package/dist/adapters/setup-runner.mjs.map +1 -1
  48. package/dist/adapters/sources.d.mts +12 -0
  49. package/dist/adapters/sources.mjs +20 -0
  50. package/dist/adapters/sources.mjs.map +1 -0
  51. package/dist/adapters/validate.mjs +25 -18
  52. package/dist/adapters/validate.mjs.map +1 -1
  53. package/dist/ai.d.mts +105 -0
  54. package/dist/ai.mjs +19 -0
  55. package/dist/ai.mjs.map +1 -0
  56. package/dist/capture/a11y/axe-source.d.mts +18 -0
  57. package/dist/capture/a11y/axe-source.mjs +37 -0
  58. package/dist/capture/a11y/axe-source.mjs.map +1 -0
  59. package/dist/capture/a11y/in-page.d.mts +27 -0
  60. package/dist/capture/a11y/in-page.mjs +60 -0
  61. package/dist/capture/a11y/in-page.mjs.map +1 -0
  62. package/dist/capture/a11y/map.d.mts +24 -0
  63. package/dist/capture/a11y/map.mjs +48 -0
  64. package/dist/capture/a11y/map.mjs.map +1 -0
  65. package/dist/capture/a11y/options.d.mts +23 -0
  66. package/dist/capture/a11y/options.mjs +75 -0
  67. package/dist/capture/a11y/options.mjs.map +1 -0
  68. package/dist/capture/adapter.d.mts +41 -3
  69. package/dist/capture/adapter.mjs.map +1 -1
  70. package/dist/capture/affected.d.mts +2 -0
  71. package/dist/capture/affected.mjs +13 -4
  72. package/dist/capture/affected.mjs.map +1 -1
  73. package/dist/capture/attempt-logger.mjs +84 -0
  74. package/dist/capture/attempt-logger.mjs.map +1 -0
  75. package/dist/capture/browsers.d.mts +35 -0
  76. package/dist/capture/browsers.mjs +67 -0
  77. package/dist/capture/browsers.mjs.map +1 -0
  78. package/dist/capture/build-state/deliver.d.mts +32 -0
  79. package/dist/capture/build-state/deliver.mjs +118 -0
  80. package/dist/capture/build-state/deliver.mjs.map +1 -0
  81. package/dist/capture/build-state/index.d.mts +8 -0
  82. package/dist/capture/build-state/notify-job.d.mts +56 -0
  83. package/dist/capture/build-state/notify-job.mjs +133 -0
  84. package/dist/capture/build-state/notify-job.mjs.map +1 -0
  85. package/dist/capture/build-state/publisher.d.mts +23 -0
  86. package/dist/capture/build-state/publisher.mjs +107 -0
  87. package/dist/capture/build-state/publisher.mjs.map +1 -0
  88. package/dist/capture/build-state/resume.d.mts +9 -0
  89. package/dist/capture/build-state/resume.mjs +47 -0
  90. package/dist/capture/build-state/resume.mjs.map +1 -0
  91. package/dist/capture/build-state/types.d.mts +49 -0
  92. package/dist/capture/catalog/catalogue.d.mts +22 -0
  93. package/dist/capture/catalog/catalogue.mjs +53 -0
  94. package/dist/capture/catalog/catalogue.mjs.map +1 -0
  95. package/dist/capture/catalog/components.d.mts +23 -0
  96. package/dist/capture/catalog/components.mjs +55 -0
  97. package/dist/capture/catalog/components.mjs.map +1 -0
  98. package/dist/capture/catalog/history.d.mts +30 -0
  99. package/dist/capture/catalog/history.mjs +51 -0
  100. package/dist/capture/catalog/history.mjs.map +1 -0
  101. package/dist/capture/catalog/hook.d.mts +14 -0
  102. package/dist/capture/catalog/hook.mjs +19 -0
  103. package/dist/capture/catalog/hook.mjs.map +1 -0
  104. package/dist/capture/catalog/index.d.mts +11 -0
  105. package/dist/capture/catalog/load.d.mts +26 -0
  106. package/dist/capture/catalog/load.mjs +49 -0
  107. package/dist/capture/catalog/load.mjs.map +1 -0
  108. package/dist/capture/catalog/parse.d.mts +15 -0
  109. package/dist/capture/catalog/parse.mjs +56 -0
  110. package/dist/capture/catalog/parse.mjs.map +1 -0
  111. package/dist/capture/catalog/read.d.mts +12 -0
  112. package/dist/capture/catalog/read.mjs +33 -0
  113. package/dist/capture/catalog/read.mjs.map +1 -0
  114. package/dist/capture/catalog/types.d.mts +33 -0
  115. package/dist/capture/consumer/capture-handler.d.mts +58 -0
  116. package/dist/capture/consumer/capture-handler.mjs +118 -0
  117. package/dist/capture/consumer/capture-handler.mjs.map +1 -0
  118. package/dist/capture/consumer/idle.d.mts +17 -0
  119. package/dist/capture/consumer/idle.mjs +25 -0
  120. package/dist/capture/consumer/idle.mjs.map +1 -0
  121. package/dist/capture/consumer/index.d.mts +13 -0
  122. package/dist/capture/consumer/index.mjs +139 -0
  123. package/dist/capture/consumer/index.mjs.map +1 -0
  124. package/dist/capture/consumer/loop.mjs +110 -0
  125. package/dist/capture/consumer/loop.mjs.map +1 -0
  126. package/dist/capture/consumer/metrics.d.mts +41 -0
  127. package/dist/capture/consumer/metrics.mjs +38 -0
  128. package/dist/capture/consumer/metrics.mjs.map +1 -0
  129. package/dist/capture/consumer/retry.d.mts +33 -0
  130. package/dist/capture/consumer/retry.mjs +34 -0
  131. package/dist/capture/consumer/retry.mjs.map +1 -0
  132. package/dist/capture/consumer/run-job.mjs +195 -0
  133. package/dist/capture/consumer/run-job.mjs.map +1 -0
  134. package/dist/capture/consumer/startup.mjs +38 -0
  135. package/dist/capture/consumer/startup.mjs.map +1 -0
  136. package/dist/capture/consumer/types.d.mts +97 -0
  137. package/dist/capture/crash-failure.d.mts +25 -0
  138. package/dist/capture/crash-failure.mjs +70 -0
  139. package/dist/capture/crash-failure.mjs.map +1 -0
  140. package/dist/capture/db-queue/cadence.d.mts +32 -0
  141. package/dist/capture/db-queue/cadence.mjs +38 -0
  142. package/dist/capture/db-queue/cadence.mjs.map +1 -0
  143. package/dist/capture/db-queue/claim.d.mts +9 -0
  144. package/dist/capture/db-queue/claim.mjs +132 -0
  145. package/dist/capture/db-queue/claim.mjs.map +1 -0
  146. package/dist/capture/db-queue/clock.mjs +12 -0
  147. package/dist/capture/db-queue/clock.mjs.map +1 -0
  148. package/dist/capture/db-queue/codec.mjs +76 -0
  149. package/dist/capture/db-queue/codec.mjs.map +1 -0
  150. package/dist/capture/db-queue/index.d.mts +20 -0
  151. package/dist/capture/db-queue/index.mjs +89 -0
  152. package/dist/capture/db-queue/index.mjs.map +1 -0
  153. package/dist/capture/db-queue/keeper.d.mts +36 -0
  154. package/dist/capture/db-queue/keeper.mjs +92 -0
  155. package/dist/capture/db-queue/keeper.mjs.map +1 -0
  156. package/dist/capture/db-queue/lease.mjs +46 -0
  157. package/dist/capture/db-queue/lease.mjs.map +1 -0
  158. package/dist/capture/db-queue/lifecycle.mjs +36 -0
  159. package/dist/capture/db-queue/lifecycle.mjs.map +1 -0
  160. package/dist/capture/db-queue/operations.mjs +94 -0
  161. package/dist/capture/db-queue/operations.mjs.map +1 -0
  162. package/dist/capture/db-queue/poll-loop.d.mts +30 -0
  163. package/dist/capture/db-queue/poll-loop.mjs +89 -0
  164. package/dist/capture/db-queue/poll-loop.mjs.map +1 -0
  165. package/dist/capture/db-queue/poll.d.mts +10 -0
  166. package/dist/capture/db-queue/poll.mjs +69 -0
  167. package/dist/capture/db-queue/poll.mjs.map +1 -0
  168. package/dist/capture/db-queue/timers.d.mts +12 -0
  169. package/dist/capture/db-queue/timers.mjs +37 -0
  170. package/dist/capture/db-queue/timers.mjs.map +1 -0
  171. package/dist/capture/db-queue/types.d.mts +83 -0
  172. package/dist/capture/db-queue/types.mjs +12 -0
  173. package/dist/capture/db-queue/types.mjs.map +1 -0
  174. package/dist/capture/db-queue/wake.mjs +48 -0
  175. package/dist/capture/db-queue/wake.mjs.map +1 -0
  176. package/dist/capture/design.mjs +39 -0
  177. package/dist/capture/design.mjs.map +1 -0
  178. package/dist/capture/diff-record.mjs +23 -3
  179. package/dist/capture/diff-record.mjs.map +1 -1
  180. package/dist/capture/dispatch.d.mts +12 -7
  181. package/dist/capture/dispatch.mjs +86 -107
  182. package/dist/capture/dispatch.mjs.map +1 -1
  183. package/dist/capture/enrich.mjs +60 -0
  184. package/dist/capture/enrich.mjs.map +1 -0
  185. package/dist/capture/failure-sets.mjs +22 -0
  186. package/dist/capture/failure-sets.mjs.map +1 -0
  187. package/dist/capture/fingerprint.d.mts +42 -0
  188. package/dist/capture/fingerprint.mjs +83 -0
  189. package/dist/capture/fingerprint.mjs.map +1 -0
  190. package/dist/capture/forked/channel.d.mts +25 -0
  191. package/dist/capture/forked/child.d.mts +34 -0
  192. package/dist/capture/forked/child.mjs +202 -0
  193. package/dist/capture/forked/child.mjs.map +1 -0
  194. package/dist/capture/forked/crash-tracker.mjs +23 -0
  195. package/dist/capture/forked/crash-tracker.mjs.map +1 -0
  196. package/dist/capture/forked/decision.d.mts +26 -0
  197. package/dist/capture/forked/decision.mjs +27 -0
  198. package/dist/capture/forked/decision.mjs.map +1 -0
  199. package/dist/capture/forked/exit.mjs +12 -0
  200. package/dist/capture/forked/exit.mjs.map +1 -0
  201. package/dist/capture/forked/fork.d.mts +31 -0
  202. package/dist/capture/forked/fork.mjs +93 -0
  203. package/dist/capture/forked/fork.mjs.map +1 -0
  204. package/dist/capture/forked/forked-capture.d.mts +40 -0
  205. package/dist/capture/forked/forked-capture.mjs +240 -0
  206. package/dist/capture/forked/forked-capture.mjs.map +1 -0
  207. package/dist/capture/forked/lease-book.mjs +46 -0
  208. package/dist/capture/forked/lease-book.mjs.map +1 -0
  209. package/dist/capture/forked/protocol.d.mts +38 -0
  210. package/dist/capture/forked/protocol.mjs +25 -0
  211. package/dist/capture/forked/protocol.mjs.map +1 -0
  212. package/dist/capture/forked/runs.mjs +75 -0
  213. package/dist/capture/forked/runs.mjs.map +1 -0
  214. package/dist/capture/isolate.mjs +141 -0
  215. package/dist/capture/isolate.mjs.map +1 -0
  216. package/dist/capture/job-lease.d.mts +28 -0
  217. package/dist/capture/job-lease.mjs +57 -0
  218. package/dist/capture/job-lease.mjs.map +1 -0
  219. package/dist/capture/matrix.mjs +298 -0
  220. package/dist/capture/matrix.mjs.map +1 -0
  221. package/dist/capture/modes.d.mts +25 -0
  222. package/dist/capture/modes.mjs +107 -0
  223. package/dist/capture/modes.mjs.map +1 -0
  224. package/dist/capture/orchestrator.d.mts +37 -5
  225. package/dist/capture/orchestrator.mjs +118 -107
  226. package/dist/capture/orchestrator.mjs.map +1 -1
  227. package/dist/capture/pipeline.d.mts +9 -2
  228. package/dist/capture/pipeline.mjs +250 -45
  229. package/dist/capture/pipeline.mjs.map +1 -1
  230. package/dist/capture/progress.d.mts +11 -0
  231. package/dist/capture/progress.mjs +28 -0
  232. package/dist/capture/progress.mjs.map +1 -0
  233. package/dist/capture/publish/accept.d.mts +39 -0
  234. package/dist/capture/publish/accept.mjs +28 -0
  235. package/dist/capture/publish/accept.mjs.map +1 -0
  236. package/dist/capture/publish/complete.d.mts +46 -0
  237. package/dist/capture/publish/complete.mjs +64 -0
  238. package/dist/capture/publish/complete.mjs.map +1 -0
  239. package/dist/capture/publish/extract.d.mts +20 -0
  240. package/dist/capture/publish/extract.mjs +119 -0
  241. package/dist/capture/publish/extract.mjs.map +1 -0
  242. package/dist/capture/publish/handler.d.mts +28 -0
  243. package/dist/capture/publish/handler.mjs +62 -0
  244. package/dist/capture/publish/handler.mjs.map +1 -0
  245. package/dist/capture/publish/index.d.mts +10 -0
  246. package/dist/capture/publish/limits.d.mts +37 -0
  247. package/dist/capture/publish/limits.mjs +39 -0
  248. package/dist/capture/publish/limits.mjs.map +1 -0
  249. package/dist/capture/publish/published.d.mts +15 -0
  250. package/dist/capture/publish/published.mjs +18 -0
  251. package/dist/capture/publish/published.mjs.map +1 -0
  252. package/dist/capture/publish/run.d.mts +33 -0
  253. package/dist/capture/publish/run.mjs +30 -0
  254. package/dist/capture/publish/run.mjs.map +1 -0
  255. package/dist/capture/rediff.d.mts +1 -1
  256. package/dist/capture/rediff.mjs +4 -3
  257. package/dist/capture/rediff.mjs.map +1 -1
  258. package/dist/capture/render.mjs +53 -0
  259. package/dist/capture/render.mjs.map +1 -0
  260. package/dist/capture/scratch.d.mts +44 -0
  261. package/dist/capture/scratch.mjs +138 -0
  262. package/dist/capture/scratch.mjs.map +1 -0
  263. package/dist/capture/shard-plan.mjs +128 -0
  264. package/dist/capture/shard-plan.mjs.map +1 -0
  265. package/dist/capture/shards/context.mjs +51 -0
  266. package/dist/capture/shards/context.mjs.map +1 -0
  267. package/dist/capture/shards/execute.mjs +174 -0
  268. package/dist/capture/shards/execute.mjs.map +1 -0
  269. package/dist/capture/shards/fan-out.mjs +126 -0
  270. package/dist/capture/shards/fan-out.mjs.map +1 -0
  271. package/dist/capture/shards/history.mjs +35 -0
  272. package/dist/capture/shards/history.mjs.map +1 -0
  273. package/dist/capture/shards/reduce.mjs +97 -0
  274. package/dist/capture/shards/reduce.mjs.map +1 -0
  275. package/dist/capture/sizing.mjs +1 -11
  276. package/dist/capture/sizing.mjs.map +1 -1
  277. package/dist/capture/skip-checks.mjs +2 -65
  278. package/dist/capture/skip-checks.mjs.map +1 -1
  279. package/dist/capture/statics.d.mts +7 -8
  280. package/dist/capture/statics.mjs +25 -71
  281. package/dist/capture/statics.mjs.map +1 -1
  282. package/dist/capture/storybook-urls.d.mts +40 -0
  283. package/dist/capture/storybook-urls.mjs +41 -0
  284. package/dist/capture/storybook-urls.mjs.map +1 -0
  285. package/dist/capture/storybook.d.mts +12 -4
  286. package/dist/capture/storybook.mjs +56 -16
  287. package/dist/capture/storybook.mjs.map +1 -1
  288. package/dist/capture/target.mjs +21 -0
  289. package/dist/capture/target.mjs.map +1 -0
  290. package/dist/capture/targets.d.mts +25 -0
  291. package/dist/capture/targets.mjs +32 -0
  292. package/dist/capture/targets.mjs.map +1 -0
  293. package/dist/capture/tests.d.mts +37 -0
  294. package/dist/capture/tests.mjs +126 -0
  295. package/dist/capture/tests.mjs.map +1 -0
  296. package/dist/capture/token-chunks.mjs +74 -0
  297. package/dist/capture/token-chunks.mjs.map +1 -0
  298. package/dist/capture.d.mts +60 -7
  299. package/dist/capture.mjs +48 -3
  300. package/dist/config.d.mts +121 -12
  301. package/dist/config.mjs +9 -6
  302. package/dist/config.mjs.map +1 -1
  303. package/dist/diff.d.mts +9 -3
  304. package/dist/diff.mjs +16 -3
  305. package/dist/diff.mjs.map +1 -0
  306. package/dist/index.d.mts +1 -1
  307. package/dist/insights/budget.d.mts +20 -0
  308. package/dist/insights/budget.mjs +33 -0
  309. package/dist/insights/budget.mjs.map +1 -0
  310. package/dist/insights/envelope.d.mts +59 -0
  311. package/dist/insights/envelope.mjs +60 -0
  312. package/dist/insights/envelope.mjs.map +1 -0
  313. package/dist/insights/evidence-health.d.mts +32 -0
  314. package/dist/insights/evidence-health.mjs +28 -0
  315. package/dist/insights/evidence-health.mjs.map +1 -0
  316. package/dist/insights/evidence.d.mts +55 -0
  317. package/dist/insights/evidence.mjs +64 -0
  318. package/dist/insights/evidence.mjs.map +1 -0
  319. package/dist/insights/hash.d.mts +18 -0
  320. package/dist/insights/hash.mjs +21 -0
  321. package/dist/insights/hash.mjs.map +1 -0
  322. package/dist/insights/limits.d.mts +24 -0
  323. package/dist/insights/limits.mjs +24 -0
  324. package/dist/insights/limits.mjs.map +1 -0
  325. package/dist/insights/prompts/v1.d.mts +13 -0
  326. package/dist/insights/prompts/v1.mjs +34 -0
  327. package/dist/insights/prompts/v1.mjs.map +1 -0
  328. package/dist/insights/redact.d.mts +9 -0
  329. package/dist/insights/redact.mjs +24 -0
  330. package/dist/insights/redact.mjs.map +1 -0
  331. package/dist/insights/text.mjs +44 -0
  332. package/dist/insights/text.mjs.map +1 -0
  333. package/dist/insights.d.mts +11 -0
  334. package/dist/insights.mjs +12 -0
  335. package/dist/logger.mjs +17 -1
  336. package/dist/logger.mjs.map +1 -1
  337. package/dist/models/ai-budget-alert.d.mts +23 -0
  338. package/dist/models/ai-budget-alert.mjs +38 -0
  339. package/dist/models/ai-budget-alert.mjs.map +1 -0
  340. package/dist/models/ai-usage.d.mts +40 -0
  341. package/dist/models/ai-usage.mjs +61 -0
  342. package/dist/models/ai-usage.mjs.map +1 -0
  343. package/dist/models/baseline-archive.d.mts +84 -0
  344. package/dist/models/baseline-archive.mjs +106 -0
  345. package/dist/models/baseline-archive.mjs.map +1 -0
  346. package/dist/models/baseline-export.d.mts +19 -0
  347. package/dist/models/baseline-export.mjs +136 -0
  348. package/dist/models/baseline-export.mjs.map +1 -0
  349. package/dist/models/baseline-import.mjs +118 -0
  350. package/dist/models/baseline-import.mjs.map +1 -0
  351. package/dist/models/baseline-transfer.d.mts +49 -0
  352. package/dist/models/baseline-transfer.mjs +121 -0
  353. package/dist/models/baseline-transfer.mjs.map +1 -0
  354. package/dist/models/baseline.d.mts +32 -5
  355. package/dist/models/baseline.mjs +65 -20
  356. package/dist/models/baseline.mjs.map +1 -1
  357. package/dist/models/build-component.d.mts +28 -0
  358. package/dist/models/build-component.mjs +55 -0
  359. package/dist/models/build-component.mjs.map +1 -0
  360. package/dist/models/build-review-status.d.mts +29 -0
  361. package/dist/models/build-review-status.mjs +37 -0
  362. package/dist/models/build-review-status.mjs.map +1 -0
  363. package/dist/models/build-review.d.mts +28 -0
  364. package/dist/models/build-review.mjs +54 -0
  365. package/dist/models/build-review.mjs.map +1 -0
  366. package/dist/models/build.d.mts +25 -3
  367. package/dist/models/build.mjs +50 -11
  368. package/dist/models/build.mjs.map +1 -1
  369. package/dist/models/capture-attempt.d.mts +7 -1
  370. package/dist/models/capture-attempt.mjs +29 -4
  371. package/dist/models/capture-attempt.mjs.map +1 -1
  372. package/dist/models/capture-job.d.mts +106 -0
  373. package/dist/models/capture-job.mjs +288 -0
  374. package/dist/models/capture-job.mjs.map +1 -0
  375. package/dist/models/capture-log.d.mts +1 -1
  376. package/dist/models/capture-log.mjs +4 -3
  377. package/dist/models/capture-log.mjs.map +1 -1
  378. package/dist/models/capture-shard.d.mts +62 -0
  379. package/dist/models/capture-shard.mjs +190 -0
  380. package/dist/models/capture-shard.mjs.map +1 -0
  381. package/dist/models/changeset.d.mts +48 -0
  382. package/dist/models/changeset.mjs +81 -0
  383. package/dist/models/changeset.mjs.map +1 -0
  384. package/dist/models/columns.mjs +19 -0
  385. package/dist/models/columns.mjs.map +1 -0
  386. package/dist/models/comment.d.mts +4 -1
  387. package/dist/models/comment.mjs +7 -4
  388. package/dist/models/comment.mjs.map +1 -1
  389. package/dist/models/component.d.mts +43 -0
  390. package/dist/models/component.mjs +60 -0
  391. package/dist/models/component.mjs.map +1 -0
  392. package/dist/models/connections.d.mts +41 -0
  393. package/dist/models/connections.mjs +112 -0
  394. package/dist/models/connections.mjs.map +1 -0
  395. package/dist/models/content-ref.d.mts +1 -1
  396. package/dist/models/content-ref.mjs +1 -1
  397. package/dist/models/content-ref.mjs.map +1 -1
  398. package/dist/models/credentials.mjs +12 -2
  399. package/dist/models/credentials.mjs.map +1 -1
  400. package/dist/models/design-credentials.d.mts +41 -0
  401. package/dist/models/design-credentials.mjs +86 -0
  402. package/dist/models/design-credentials.mjs.map +1 -0
  403. package/dist/models/design-health.d.mts +16 -0
  404. package/dist/models/design-health.mjs +25 -0
  405. package/dist/models/design-health.mjs.map +1 -0
  406. package/dist/models/design-nodes.d.mts +83 -0
  407. package/dist/models/design-nodes.mjs +222 -0
  408. package/dist/models/design-nodes.mjs.map +1 -0
  409. package/dist/models/design-renders.mjs +74 -0
  410. package/dist/models/design-renders.mjs.map +1 -0
  411. package/dist/models/design-resolve.d.mts +29 -0
  412. package/dist/models/design-resolve.mjs +41 -0
  413. package/dist/models/design-resolve.mjs.map +1 -0
  414. package/dist/models/design.d.mts +39 -0
  415. package/dist/models/design.mjs +90 -0
  416. package/dist/models/design.mjs.map +1 -0
  417. package/dist/models/inherited-ratio.d.mts +21 -0
  418. package/dist/models/inherited-ratio.mjs +22 -0
  419. package/dist/models/inherited-ratio.mjs.map +1 -0
  420. package/dist/models/insight.d.mts +70 -0
  421. package/dist/models/insight.mjs +162 -0
  422. package/dist/models/insight.mjs.map +1 -0
  423. package/dist/models/label.d.mts +4 -2
  424. package/dist/models/label.mjs +25 -10
  425. package/dist/models/label.mjs.map +1 -1
  426. package/dist/models/member.d.mts +1 -1
  427. package/dist/models/member.mjs +5 -4
  428. package/dist/models/member.mjs.map +1 -1
  429. package/dist/models/notification-channel.d.mts +37 -3
  430. package/dist/models/notification-channel.mjs +88 -9
  431. package/dist/models/notification-channel.mjs.map +1 -1
  432. package/dist/models/notification-subscription.d.mts +1 -2
  433. package/dist/models/notification-subscription.mjs +7 -9
  434. package/dist/models/notification-subscription.mjs.map +1 -1
  435. package/dist/models/project-group-mapping.d.mts +6 -1
  436. package/dist/models/project-group-mapping.mjs +14 -4
  437. package/dist/models/project-group-mapping.mjs.map +1 -1
  438. package/dist/models/project.d.mts +9 -1
  439. package/dist/models/project.mjs +9 -4
  440. package/dist/models/project.mjs.map +1 -1
  441. package/dist/models/public-origin.d.mts +63 -0
  442. package/dist/models/public-origin.mjs +114 -0
  443. package/dist/models/public-origin.mjs.map +1 -0
  444. package/dist/models/review-switch-off.d.mts +14 -0
  445. package/dist/models/review-switch-off.mjs +26 -0
  446. package/dist/models/review-switch-off.mjs.map +1 -0
  447. package/dist/models/site-settings.d.mts +23 -0
  448. package/dist/models/site-settings.mjs +48 -0
  449. package/dist/models/site-settings.mjs.map +1 -0
  450. package/dist/models/snapshot.d.mts +36 -1
  451. package/dist/models/snapshot.mjs +50 -3
  452. package/dist/models/snapshot.mjs.map +1 -1
  453. package/dist/models/token.d.mts +13 -1
  454. package/dist/models/token.mjs +23 -5
  455. package/dist/models/token.mjs.map +1 -1
  456. package/dist/models/usage.d.mts +76 -0
  457. package/dist/models/usage.mjs +149 -0
  458. package/dist/models/usage.mjs.map +1 -0
  459. package/dist/models/user.d.mts +1 -1
  460. package/dist/models/user.mjs +4 -3
  461. package/dist/models/user.mjs.map +1 -1
  462. package/dist/models/webhook.d.mts +15 -1
  463. package/dist/models/webhook.mjs +33 -4
  464. package/dist/models/webhook.mjs.map +1 -1
  465. package/dist/models.d.mts +26 -3
  466. package/dist/models.mjs +27 -5
  467. package/dist/options.d.mts +18 -0
  468. package/dist/options.mjs +90 -0
  469. package/dist/options.mjs.map +1 -0
  470. package/dist/paths.d.mts +19 -4
  471. package/dist/paths.mjs +51 -10
  472. package/dist/paths.mjs.map +1 -1
  473. package/dist/retention/ai.d.mts +18 -0
  474. package/dist/retention/ai.mjs +23 -0
  475. package/dist/retention/ai.mjs.map +1 -0
  476. package/dist/retention/pending.mjs +47 -0
  477. package/dist/retention/pending.mjs.map +1 -0
  478. package/dist/retention/screenshot-sweep.d.mts +51 -0
  479. package/dist/retention/screenshot-sweep.mjs +128 -0
  480. package/dist/retention/screenshot-sweep.mjs.map +1 -0
  481. package/dist/retention.d.mts +16 -2
  482. package/dist/retention.mjs +71 -14
  483. package/dist/retention.mjs.map +1 -1
  484. package/dist/schema/baseline.d.mts +6 -0
  485. package/dist/schema/build-component.d.mts +25 -0
  486. package/dist/schema/build-review.d.mts +17 -0
  487. package/dist/schema/build.d.mts +7 -0
  488. package/dist/schema/capture-job.d.mts +60 -0
  489. package/dist/schema/capture-shard.d.mts +35 -0
  490. package/dist/schema/comment.d.mts +2 -0
  491. package/dist/schema/connection.d.mts +24 -0
  492. package/dist/schema/design.d.mts +58 -0
  493. package/dist/schema/insight.d.mts +54 -0
  494. package/dist/schema/notification.d.mts +4 -0
  495. package/dist/schema/project.d.mts +21 -0
  496. package/dist/schema/site-setting.d.mts +21 -0
  497. package/dist/schema/snapshot.d.mts +12 -0
  498. package/dist/schema/usage.d.mts +30 -0
  499. package/dist/schema.d.mts +11 -3
  500. package/dist/serverless.d.mts +21 -0
  501. package/dist/serverless.mjs +37 -0
  502. package/dist/serverless.mjs.map +1 -0
  503. package/dist/test-helpers/create-project.d.mts +1 -1
  504. package/dist/test-helpers/deferred.d.mts +39 -0
  505. package/dist/test-helpers/deferred.mjs +61 -0
  506. package/dist/test-helpers/deferred.mjs.map +1 -0
  507. package/dist/test-helpers/design-contract.d.mts +21 -0
  508. package/dist/test-helpers/design-contract.mjs +40 -0
  509. package/dist/test-helpers/design-contract.mjs.map +1 -0
  510. package/dist/test-helpers/fake-database.mjs +14 -2
  511. package/dist/test-helpers/fake-database.mjs.map +1 -1
  512. package/dist/test-helpers/fake-design.d.mts +43 -0
  513. package/dist/test-helpers/fake-design.mjs +114 -0
  514. package/dist/test-helpers/fake-design.mjs.map +1 -0
  515. package/dist/test-helpers/fake-notifier.d.mts +21 -0
  516. package/dist/test-helpers/fake-notifier.mjs +44 -0
  517. package/dist/test-helpers/fake-notifier.mjs.map +1 -0
  518. package/dist/test-helpers/fake-tables.mjs +255 -67
  519. package/dist/test-helpers/fake-tables.mjs.map +1 -1
  520. package/dist/test-helpers/manual-clock.d.mts +27 -0
  521. package/dist/test-helpers/manual-clock.mjs +56 -0
  522. package/dist/test-helpers/manual-clock.mjs.map +1 -0
  523. package/dist/test-helpers/notifier-contract.d.mts +7 -1
  524. package/dist/test-helpers/notifier-contract.mjs +32 -3
  525. package/dist/test-helpers/notifier-contract.mjs.map +1 -1
  526. package/dist/test-helpers/queue-contract.d.mts +16 -2
  527. package/dist/test-helpers/queue-contract.mjs +195 -1
  528. package/dist/test-helpers/queue-contract.mjs.map +1 -1
  529. package/dist/test-helpers/queue-multi-instance.d.mts +20 -0
  530. package/dist/test-helpers/queue-multi-instance.mjs +206 -0
  531. package/dist/test-helpers/queue-multi-instance.mjs.map +1 -0
  532. package/dist/test-helpers/runner-contract.mjs +11 -0
  533. package/dist/test-helpers/runner-contract.mjs.map +1 -1
  534. package/dist/test-helpers/sql-chunks.mjs +23 -0
  535. package/dist/test-helpers/sql-chunks.mjs.map +1 -1
  536. package/dist/test-helpers/storage-contract.mjs +1 -1
  537. package/dist/test-helpers.d.mts +9 -4
  538. package/dist/test-helpers.mjs +8 -3
  539. package/dist/types.d.mts +14 -3
  540. package/dist/types.mjs +21 -4
  541. package/dist/types.mjs.map +1 -1
  542. package/dist/urls.d.mts +4 -0
  543. package/dist/urls.mjs +11 -2
  544. package/dist/urls.mjs.map +1 -1
  545. package/dist/utils/adaptive-concurrency.d.mts +66 -0
  546. package/dist/utils/adaptive-concurrency.mjs +149 -0
  547. package/dist/utils/adaptive-concurrency.mjs.map +1 -0
  548. package/dist/utils/connect-retry.d.mts +26 -0
  549. package/dist/utils/connect-retry.mjs +43 -0
  550. package/dist/utils/connect-retry.mjs.map +1 -0
  551. package/dist/utils/environment.d.mts +19 -0
  552. package/dist/utils/environment.mjs +59 -0
  553. package/dist/utils/environment.mjs.map +1 -0
  554. package/dist/utils/http.d.mts +17 -1
  555. package/dist/utils/http.mjs +22 -3
  556. package/dist/utils/http.mjs.map +1 -1
  557. package/dist/utils/map-adaptive.d.mts +15 -0
  558. package/dist/utils/map-adaptive.mjs +72 -0
  559. package/dist/utils/map-adaptive.mjs.map +1 -0
  560. package/dist/utils/map-limit.d.mts +10 -0
  561. package/dist/utils/map-limit.mjs +32 -0
  562. package/dist/utils/map-limit.mjs.map +1 -0
  563. package/dist/utils/page-limiter.d.mts +37 -0
  564. package/dist/utils/page-limiter.mjs +56 -0
  565. package/dist/utils/page-limiter.mjs.map +1 -0
  566. package/dist/utils/public-origin.d.mts +20 -0
  567. package/dist/utils/public-origin.mjs +75 -0
  568. package/dist/utils/public-origin.mjs.map +1 -0
  569. package/dist/utils/redact.mjs +3 -0
  570. package/dist/utils/redact.mjs.map +1 -1
  571. package/dist/utils/remote-environment.d.mts +39 -0
  572. package/dist/utils/remote-environment.mjs +114 -0
  573. package/dist/utils/remote-environment.mjs.map +1 -0
  574. package/dist/utils/resources.d.mts +64 -0
  575. package/dist/utils/resources.mjs +122 -0
  576. package/dist/utils/resources.mjs.map +1 -0
  577. package/dist/utils/screenshot-store.d.mts +15 -0
  578. package/dist/utils/screenshot-store.mjs +41 -0
  579. package/dist/utils/screenshot-store.mjs.map +1 -0
  580. package/dist/utils/session-gate.d.mts +22 -0
  581. package/dist/utils/session-gate.mjs +53 -0
  582. package/dist/utils/session-gate.mjs.map +1 -0
  583. package/dist/utils/storybook-token.d.mts +81 -0
  584. package/dist/utils/storybook-token.mjs +134 -0
  585. package/dist/utils/storybook-token.mjs.map +1 -0
  586. package/dist/utils/storybook-url.d.mts +15 -0
  587. package/dist/utils/storybook-url.mjs +21 -0
  588. package/dist/utils/storybook-url.mjs.map +1 -0
  589. package/dist/utils/timing.mjs +1 -1
  590. package/dist/utils/timing.mjs.map +1 -1
  591. package/dist/utils/zip-read.mjs +129 -0
  592. package/dist/utils/zip-read.mjs.map +1 -0
  593. package/dist/utils/zip-write.d.mts +18 -0
  594. package/dist/utils/zip-write.mjs +188 -0
  595. package/dist/utils/zip-write.mjs.map +1 -0
  596. package/dist/utils.d.mts +17 -3
  597. package/dist/utils.mjs +18 -4
  598. package/package.json +32 -23
  599. package/dist/adapter/capture-runner.mjs.map +0 -1
  600. package/dist/adapter/git-host/comments.d.mts +0 -41
  601. package/dist/adapter/git-host/comments.mjs +0 -54
  602. package/dist/adapter/git-host/comments.mjs.map +0 -1
  603. package/dist/adapter/git-host/helpers.d.mts +0 -13
  604. package/dist/adapter/git-host/helpers.mjs +0 -30
  605. package/dist/adapter/git-host/helpers.mjs.map +0 -1
  606. package/dist/adapter/git-host.d.mts +0 -42
  607. package/dist/capture/queue.d.mts +0 -38
  608. package/dist/capture/queue.mjs +0 -98
  609. package/dist/capture/queue.mjs.map +0 -1
  610. package/dist/capture/recovery.d.mts +0 -21
  611. package/dist/capture/recovery.mjs +0 -83
  612. package/dist/capture/recovery.mjs.map +0 -1
  613. package/dist/capture/status-fanout.mjs +0 -72
  614. package/dist/capture/status-fanout.mjs.map +0 -1
  615. package/dist/diff/engine.d.mts +0 -16
  616. package/dist/diff/engine.mjs +0 -87
  617. package/dist/diff/engine.mjs.map +0 -1
  618. package/dist/diff/options.d.mts +0 -42
  619. package/dist/diff/options.mjs +0 -15
  620. package/dist/diff/options.mjs.map +0 -1
  621. package/dist/models/status-config.d.mts +0 -38
  622. package/dist/models/status-config.mjs +0 -63
  623. package/dist/models/status-config.mjs.map +0 -1
  624. package/dist/schema/status-config.d.mts +0 -16
  625. package/dist/test-helpers/git-contract.d.mts +0 -11
  626. package/dist/test-helpers/git-contract.mjs +0 -34
  627. package/dist/test-helpers/git-contract.mjs.map +0 -1
  628. /package/dist/adapter/{git-host.mjs → oauth.mjs} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.mjs","names":[],"sources":["../../../src/capture/catalog/components.ts"],"sourcesContent":["/** Catalog entries grouped into components, hashed, and compared between builds. */\nimport { createHash } from \"node:crypto\";\nimport type { BuildComponentInput } from \"../../models/build-component.ts\";\nimport type { CatalogComponent, CatalogEntry } from \"./types.ts\";\n\n/** Group entries by story file (entries without one by title), ordered by title then file. */\nexport function groupComponents(entries: readonly CatalogEntry[]): CatalogComponent[] {\n const groups = Map.groupBy(entries, (entry) => entry.importPath || `title:${entry.title}`);\n return [...groups.values()]\n .map((group): CatalogComponent => {\n const [first] = group;\n return {\n importPath: first?.importPath ?? \"\",\n title: first?.title ?? \"\",\n storyCount: group.filter((entry) => entry.type === \"story\").length,\n hash: hashEntries(group),\n entries: group,\n };\n })\n .toSorted((a, b) => a.title.localeCompare(b.title) || a.importPath.localeCompare(b.importPath));\n}\n\n/** What `build_components` stores of a component. */\nexport function toBuildComponent(component: CatalogComponent): BuildComponentInput {\n const { importPath, title, storyCount, hash } = component;\n return { importPath, title, storyCount, hash };\n}\n\n/** SHA-256 over the entries' id, name, type and title, in id order: equal sets hash equal. */\nexport function hashEntries(entries: readonly CatalogEntry[]): string {\n const lines = entries\n .map((entry) => [entry.id, entry.name, entry.type, entry.title].join(\"\\t\"))\n .toSorted();\n return createHash(\"sha256\").update(lines.join(\"\\n\")).digest(\"hex\");\n}\n\n/** How one component's entries differ between two builds. */\nexport interface EntryChanges {\n added: number;\n removed: number;\n /** Same id, new display name. */\n renamed: number;\n}\n\n/** Entries added, removed and renamed from `before` to `after` (matched by entry id). */\nexport function diffEntries(\n before: readonly CatalogEntry[],\n after: readonly CatalogEntry[],\n): EntryChanges {\n const was = new Map(before.map((entry) => [entry.id, entry] as const));\n const now = new Map(after.map((entry) => [entry.id, entry] as const));\n let renamed = 0;\n for (const [id, entry] of now) {\n if (was.has(id) && was.get(id)?.name !== entry.name) {\n renamed += 1;\n }\n }\n return {\n added: [...now.keys()].filter((id) => !was.has(id)).length,\n removed: [...was.keys()].filter((id) => !now.has(id)).length,\n renamed,\n };\n}\n"],"mappings":";;;;;;;AAMA,SAAgB,gBAAgB,SAAsD;CAEpF,OAAO,CAAC,GADO,IAAI,QAAQ,UAAU,UAAU,MAAM,cAAc,SAAS,MAAM,OAClE,CAAC,CAAC,OAAO,CAAC,CAAC,CACxB,KAAK,UAA4B;EAChC,MAAM,CAAC,SAAS;EAChB,OAAO;GACL,YAAY,OAAO,cAAc;GACjC,OAAO,OAAO,SAAS;GACvB,YAAY,MAAM,QAAQ,UAAU,MAAM,SAAS,OAAO,CAAC,CAAC;GAC5D,MAAM,YAAY,KAAK;GACvB,SAAS;EACX;CACF,CAAC,CAAC,CACD,UAAU,GAAG,MAAM,EAAE,MAAM,cAAc,EAAE,KAAK,KAAK,EAAE,WAAW,cAAc,EAAE,UAAU,CAAC;AAClG;;AAGA,SAAgB,iBAAiB,WAAkD;CACjF,MAAM,EAAE,YAAY,OAAO,YAAY,SAAS;CAChD,OAAO;EAAE;EAAY;EAAO;EAAY;CAAK;AAC/C;;AAGA,SAAgB,YAAY,SAA0C;CACpE,MAAM,QAAQ,QACX,KAAK,UAAU;EAAC,MAAM;EAAI,MAAM;EAAM,MAAM;EAAM,MAAM;CAAK,CAAC,CAAC,KAAK,GAAI,CAAC,CAAC,CAC1E,SAAS;CACZ,OAAO,WAAW,QAAQ,CAAC,CAAC,OAAO,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,OAAO,KAAK;AACnE;;AAWA,SAAgB,YACd,QACA,OACc;CACd,MAAM,MAAM,IAAI,IAAI,OAAO,KAAK,UAAU,CAAC,MAAM,IAAI,KAAK,CAAU,CAAC;CACrE,MAAM,MAAM,IAAI,IAAI,MAAM,KAAK,UAAU,CAAC,MAAM,IAAI,KAAK,CAAU,CAAC;CACpE,IAAI,UAAU;CACd,KAAK,MAAM,CAAC,IAAI,UAAU,KACxB,IAAI,IAAI,IAAI,EAAE,KAAK,IAAI,IAAI,EAAE,CAAC,EAAE,SAAS,MAAM,MAC7C,WAAW;CAGf,OAAO;EACL,OAAO,CAAC,GAAG,IAAI,KAAK,CAAC,CAAC,CAAC,QAAQ,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC;EACpD,SAAS,CAAC,GAAG,IAAI,KAAK,CAAC,CAAC,CAAC,QAAQ,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC;EACtD;CACF;AACF"}
@@ -0,0 +1,30 @@
1
+ import __tsdown_shims_path from 'node:path';
2
+ import __tsdown_shims_url from 'node:url';
3
+ import { Build } from "../../schema/build.mjs";
4
+ import { BuildComponent } from "../../schema/build-component.mjs";
5
+ import { ComponentPresence } from "../../models/component.mjs";
6
+ //#region src/capture/catalog/history.d.ts
7
+ /** How a build's version of a component compares with the build before it on the same branch. */
8
+ type ComponentChange = "new" | "changed" | "unchanged";
9
+ /** One build's row of a component's history. */
10
+ interface ComponentBuildRow {
11
+ build: Build;
12
+ component: BuildComponent;
13
+ change: ComponentChange;
14
+ /** The same component in the build before on the branch; null when this is its first. */
15
+ previous: BuildComponent | null;
16
+ }
17
+ /**
18
+ * Component history, newest build first. `rows` are the component's `build_components` rows;
19
+ * a row whose build is missing is skipped. The build before is the next older one on the same
20
+ * branch, so a feature branch compares with itself rather than with an unrelated default build.
21
+ */
22
+ declare function componentBuildHistory(rows: readonly BuildComponent[], builds: readonly Build[]): ComponentBuildRow[];
23
+ /**
24
+ * Where a component stands against the project's latest build. `latest` holds that build's
25
+ * component rows, or null when it has no catalog (the answer is then unknown, never "deleted").
26
+ */
27
+ declare function catalogPresence(history: readonly ComponentBuildRow[], importPath: string, latest: readonly BuildComponent[] | null): ComponentPresence;
28
+ //#endregion
29
+ export { ComponentBuildRow, ComponentChange, catalogPresence, componentBuildHistory };
30
+ //# sourceMappingURL=history.d.mts.map
@@ -0,0 +1,51 @@
1
+ import "node:path";
2
+ import "node:url";
3
+ import.meta.url;
4
+ //#region src/capture/catalog/history.ts
5
+ /**
6
+ * Component history, newest build first. `rows` are the component's `build_components` rows;
7
+ * a row whose build is missing is skipped. The build before is the next older one on the same
8
+ * branch, so a feature branch compares with itself rather than with an unrelated default build.
9
+ */
10
+ function componentBuildHistory(rows, builds) {
11
+ const byId = new Map(builds.map((build) => [build.id, build]));
12
+ const known = rows.flatMap((component) => {
13
+ const build = byId.get(component.buildId);
14
+ return build ? [{
15
+ build,
16
+ component
17
+ }] : [];
18
+ }).toSorted((a, b) => b.build.createdAt.localeCompare(a.build.createdAt));
19
+ return known.map((entry, index) => {
20
+ const previous = known.slice(index + 1).find((older) => older.build.gitBranch === entry.build.gitBranch)?.component ?? null;
21
+ const change = previous ? previous.hash === entry.component.hash ? "unchanged" : "changed" : "new";
22
+ return {
23
+ build: entry.build,
24
+ component: entry.component,
25
+ change,
26
+ previous
27
+ };
28
+ });
29
+ }
30
+ /**
31
+ * Where a component stands against the project's latest build. `latest` holds that build's
32
+ * component rows, or null when it has no catalog (the answer is then unknown, never "deleted").
33
+ */
34
+ function catalogPresence(history, importPath, latest) {
35
+ const newest = history[0];
36
+ if (!latest || !newest) return { kind: "unknown" };
37
+ if (latest.some((row) => row.importPath === importPath)) return { kind: "present" };
38
+ const moved = latest.find((row) => row.title === newest.component.title && row.importPath !== "");
39
+ return moved ? {
40
+ kind: "moved",
41
+ to: moved.importPath,
42
+ title: moved.title
43
+ } : {
44
+ kind: "deleted",
45
+ lastSeen: newest.build
46
+ };
47
+ }
48
+ //#endregion
49
+ export { catalogPresence, componentBuildHistory };
50
+
51
+ //# sourceMappingURL=history.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"history.mjs","names":[],"sources":["../../../src/capture/catalog/history.ts"],"sourcesContent":["/** A component across builds: which builds hold it, whether its stories changed, and where it went. */\nimport type { ComponentPresence } from \"../../models/component.ts\";\nimport type { BuildComponent } from \"../../schema/build-component.ts\";\nimport type { Build } from \"../../schema/build.ts\";\n\n/** How a build's version of a component compares with the build before it on the same branch. */\nexport type ComponentChange = \"new\" | \"changed\" | \"unchanged\";\n\n/** One build's row of a component's history. */\nexport interface ComponentBuildRow {\n build: Build;\n component: BuildComponent;\n change: ComponentChange;\n /** The same component in the build before on the branch; null when this is its first. */\n previous: BuildComponent | null;\n}\n\n/**\n * Component history, newest build first. `rows` are the component's `build_components` rows;\n * a row whose build is missing is skipped. The build before is the next older one on the same\n * branch, so a feature branch compares with itself rather than with an unrelated default build.\n */\nexport function componentBuildHistory(\n rows: readonly BuildComponent[],\n builds: readonly Build[],\n): ComponentBuildRow[] {\n const byId = new Map(builds.map((build) => [build.id, build] as const));\n const known = rows\n .flatMap((component) => {\n const build = byId.get(component.buildId);\n return build ? [{ build, component }] : [];\n })\n .toSorted((a, b) => b.build.createdAt.localeCompare(a.build.createdAt));\n return known.map((entry, index) => {\n const previous =\n known.slice(index + 1).find((older) => older.build.gitBranch === entry.build.gitBranch)\n ?.component ?? null;\n const change: ComponentChange = previous\n ? previous.hash === entry.component.hash\n ? \"unchanged\"\n : \"changed\"\n : \"new\";\n return { build: entry.build, component: entry.component, change, previous };\n });\n}\n\n/**\n * Where a component stands against the project's latest build. `latest` holds that build's\n * component rows, or null when it has no catalog (the answer is then unknown, never \"deleted\").\n */\nexport function catalogPresence(\n history: readonly ComponentBuildRow[],\n importPath: string,\n latest: readonly BuildComponent[] | null,\n): ComponentPresence {\n const newest = history[0];\n if (!latest || !newest) {\n return { kind: \"unknown\" };\n }\n if (latest.some((row) => row.importPath === importPath)) {\n return { kind: \"present\" };\n }\n const moved = latest.find((row) => row.title === newest.component.title && row.importPath !== \"\");\n return moved\n ? { kind: \"moved\", to: moved.importPath, title: moved.title }\n : { kind: \"deleted\", lastSeen: newest.build };\n}\n"],"mappings":";;;;;;;;;AAsBA,SAAgB,sBACd,MACA,QACqB;CACrB,MAAM,OAAO,IAAI,IAAI,OAAO,KAAK,UAAU,CAAC,MAAM,IAAI,KAAK,CAAU,CAAC;CACtE,MAAM,QAAQ,KACX,SAAS,cAAc;EACtB,MAAM,QAAQ,KAAK,IAAI,UAAU,OAAO;EACxC,OAAO,QAAQ,CAAC;GAAE;GAAO;EAAU,CAAC,IAAI,CAAC;CAC3C,CAAC,CAAC,CACD,UAAU,GAAG,MAAM,EAAE,MAAM,UAAU,cAAc,EAAE,MAAM,SAAS,CAAC;CACxE,OAAO,MAAM,KAAK,OAAO,UAAU;EACjC,MAAM,WACJ,MAAM,MAAM,QAAQ,CAAC,CAAC,CAAC,MAAM,UAAU,MAAM,MAAM,cAAc,MAAM,MAAM,SAAS,CAAC,EACnF,aAAa;EACnB,MAAM,SAA0B,WAC5B,SAAS,SAAS,MAAM,UAAU,OAChC,cACA,YACF;EACJ,OAAO;GAAE,OAAO,MAAM;GAAO,WAAW,MAAM;GAAW;GAAQ;EAAS;CAC5E,CAAC;AACH;;;;;AAMA,SAAgB,gBACd,SACA,YACA,QACmB;CACnB,MAAM,SAAS,QAAQ;CACvB,IAAI,CAAC,UAAU,CAAC,QACd,OAAO,EAAE,MAAM,UAAU;CAE3B,IAAI,OAAO,MAAM,QAAQ,IAAI,eAAe,UAAU,GACpD,OAAO,EAAE,MAAM,UAAU;CAE3B,MAAM,QAAQ,OAAO,MAAM,QAAQ,IAAI,UAAU,OAAO,UAAU,SAAS,IAAI,eAAe,EAAE;CAChG,OAAO,QACH;EAAE,MAAM;EAAS,IAAI,MAAM;EAAY,OAAO,MAAM;CAAM,IAC1D;EAAE,MAAM;EAAW,UAAU,OAAO;CAAM;AAChD"}
@@ -0,0 +1,14 @@
1
+ import __tsdown_shims_path from 'node:path';
2
+ import __tsdown_shims_url from 'node:url';
3
+ import { AfterPublishHook } from "../publish/complete.mjs";
4
+ import { CatalogLoader } from "./load.mjs";
5
+ //#region src/capture/catalog/hook.d.ts
6
+ /**
7
+ * Catalogue every build that published successfully, whatever its verdict and with `testing` on or
8
+ * off. A failed publish writes nothing. A build with no readable index is logged and left for the
9
+ * lazy loader, which tries again on first view.
10
+ */
11
+ declare function createCatalogHook(loader: CatalogLoader): AfterPublishHook;
12
+ //#endregion
13
+ export { createCatalogHook };
14
+ //# sourceMappingURL=hook.d.mts.map
@@ -0,0 +1,19 @@
1
+ import "node:path";
2
+ import "node:url";
3
+ import.meta.url;
4
+ //#region src/capture/catalog/hook.ts
5
+ /**
6
+ * Catalogue every build that published successfully, whatever its verdict and with `testing` on or
7
+ * off. A failed publish writes nothing. A build with no readable index is logged and left for the
8
+ * lazy loader, which tries again on first view.
9
+ */
10
+ function createCatalogHook(loader) {
11
+ return async ({ build, project, outcome, logger }) => {
12
+ if (!outcome.ok) return;
13
+ if (!await loader.refresh(project.id, build.id)) logger.warn("published build has no readable Storybook index; no catalog written");
14
+ };
15
+ }
16
+ //#endregion
17
+ export { createCatalogHook };
18
+
19
+ //# sourceMappingURL=hook.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hook.mjs","names":[],"sources":["../../../src/capture/catalog/hook.ts"],"sourcesContent":["/** The `afterPublish` hook that catalogues a build the moment its publishing succeeds. */\nimport type { AfterPublishHook } from \"../publish/complete.ts\";\nimport type { CatalogLoader } from \"./load.ts\";\n\n/**\n * Catalogue every build that published successfully, whatever its verdict and with `testing` on or\n * off. A failed publish writes nothing. A build with no readable index is logged and left for the\n * lazy loader, which tries again on first view.\n */\nexport function createCatalogHook(loader: CatalogLoader): AfterPublishHook {\n return async ({ build, project, outcome, logger }) => {\n if (!outcome.ok) {\n return;\n }\n const catalog = await loader.refresh(project.id, build.id);\n if (!catalog) {\n logger.warn(\"published build has no readable Storybook index; no catalog written\");\n }\n };\n}\n"],"mappings":";;;;;;;;;AASA,SAAgB,kBAAkB,QAAyC;CACzE,OAAO,OAAO,EAAE,OAAO,SAAS,SAAS,aAAa;EACpD,IAAI,CAAC,QAAQ,IACX;EAGF,IAAI,CAAC,MADiB,OAAO,QAAQ,QAAQ,IAAI,MAAM,EAAE,GAEvD,OAAO,KAAK,qEAAqE;CAErF;AACF"}
@@ -0,0 +1,11 @@
1
+ import __tsdown_shims_path from 'node:path';
2
+ import __tsdown_shims_url from 'node:url';
3
+ import { Catalog, CatalogComponent, CatalogEntry } from "./types.mjs";
4
+ import { CatalogDeps, catalogueBuild, readCatalog } from "./catalogue.mjs";
5
+ import { CatalogLoader, CatalogLoaderOptions, DEFAULT_CATALOG_CACHE_SIZE, createCatalogLoader } from "./load.mjs";
6
+ import { createCatalogHook } from "./hook.mjs";
7
+ import { EntryChanges, diffEntries, groupComponents, hashEntries, toBuildComponent } from "./components.mjs";
8
+ import { parseStorybookIndex, parseStorybookIndexText } from "./parse.mjs";
9
+ import { readPublishedFile } from "./read.mjs";
10
+ import { ComponentBuildRow, ComponentChange, catalogPresence, componentBuildHistory } from "./history.mjs";
11
+ export { type Catalog, type CatalogComponent, type CatalogDeps, type CatalogEntry, type CatalogLoader, type CatalogLoaderOptions, type ComponentBuildRow, type ComponentChange, DEFAULT_CATALOG_CACHE_SIZE, type EntryChanges, catalogPresence, catalogueBuild, componentBuildHistory, createCatalogHook, createCatalogLoader, diffEntries, groupComponents, hashEntries, parseStorybookIndex, parseStorybookIndexText, readCatalog, readPublishedFile, toBuildComponent };
@@ -0,0 +1,26 @@
1
+ import __tsdown_shims_path from 'node:path';
2
+ import __tsdown_shims_url from 'node:url';
3
+ import { Logger } from "../../logger.mjs";
4
+ import { Catalog } from "./types.mjs";
5
+ import { CatalogDeps } from "./catalogue.mjs";
6
+ //#region src/capture/catalog/load.d.ts
7
+ /** Reads catalogs; one per app, so the cache is shared by every request. */
8
+ interface CatalogLoader {
9
+ /** The build's catalog, or null when it has no catalog and no readable index. */
10
+ load(projectId: string, buildId: string): Promise<Catalog | null>;
11
+ /** Catalogue the build again from its statics (a publish ended) and cache the result. */
12
+ refresh(projectId: string, buildId: string): Promise<Catalog | null>;
13
+ }
14
+ /** Catalogs kept in memory by default. */
15
+ declare const DEFAULT_CATALOG_CACHE_SIZE = 32;
16
+ /** What {@link createCatalogLoader} needs. */
17
+ interface CatalogLoaderOptions extends CatalogDeps {
18
+ /** Catalogs kept in memory (least recently used leave first). */
19
+ cacheSize?: number;
20
+ logger?: Logger;
21
+ }
22
+ /** A loader over `options.db` and `options.storage`. */
23
+ declare function createCatalogLoader(options: CatalogLoaderOptions): CatalogLoader;
24
+ //#endregion
25
+ export { CatalogLoader, CatalogLoaderOptions, DEFAULT_CATALOG_CACHE_SIZE, createCatalogLoader };
26
+ //# sourceMappingURL=load.d.mts.map
@@ -0,0 +1,49 @@
1
+ import "node:path";
2
+ import "node:url";
3
+ import.meta.url;
4
+ import { catalogueBuild, readCatalog } from "./catalogue.mjs";
5
+ //#region src/capture/catalog/load.ts
6
+ /** Catalogs kept in memory by default. */
7
+ const DEFAULT_CATALOG_CACHE_SIZE = 32;
8
+ /** A loader over `options.db` and `options.storage`. */
9
+ function createCatalogLoader(options) {
10
+ const limit = Math.max(1, options.cacheSize ?? 32);
11
+ const cache = /* @__PURE__ */ new Map();
12
+ const inflight = /* @__PURE__ */ new Map();
13
+ const remember = (buildId, catalog) => {
14
+ cache.delete(buildId);
15
+ cache.set(buildId, catalog);
16
+ const oldest = cache.keys().next().value;
17
+ if (cache.size > limit && oldest !== void 0) cache.delete(oldest);
18
+ return catalog;
19
+ };
20
+ const fetchCatalog = async (projectId, buildId) => {
21
+ const stored = await readCatalog(options.storage, projectId, buildId);
22
+ if (stored) return stored;
23
+ options.logger?.info({ buildId }, "cataloguing a build published before the catalog");
24
+ return await catalogueBuild(options, projectId, buildId);
25
+ };
26
+ return {
27
+ load: async (projectId, buildId) => {
28
+ const hit = cache.get(buildId);
29
+ if (hit) return remember(buildId, hit);
30
+ const pending = inflight.get(buildId) ?? fetchCatalog(projectId, buildId);
31
+ inflight.set(buildId, pending);
32
+ try {
33
+ const catalog = await pending;
34
+ return catalog ? remember(buildId, catalog) : null;
35
+ } finally {
36
+ inflight.delete(buildId);
37
+ }
38
+ },
39
+ refresh: async (projectId, buildId) => {
40
+ cache.delete(buildId);
41
+ const catalog = await catalogueBuild(options, projectId, buildId);
42
+ return catalog ? remember(buildId, catalog) : null;
43
+ }
44
+ };
45
+ }
46
+ //#endregion
47
+ export { DEFAULT_CATALOG_CACHE_SIZE, createCatalogLoader };
48
+
49
+ //# sourceMappingURL=load.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load.mjs","names":[],"sources":["../../../src/capture/catalog/load.ts"],"sourcesContent":["/**\n * The catalog loader: a build's catalog from `catalog.json`, kept in a small in-process LRU cache\n * by build id; a build that has none (published before the catalog existed) is catalogued on first\n * view from its persisted statics (ADR 0006, decision 9).\n */\nimport type { Logger } from \"../../logger.ts\";\nimport { catalogueBuild, readCatalog, type CatalogDeps } from \"./catalogue.ts\";\nimport type { Catalog } from \"./types.ts\";\n\n/** Reads catalogs; one per app, so the cache is shared by every request. */\nexport interface CatalogLoader {\n /** The build's catalog, or null when it has no catalog and no readable index. */\n load(projectId: string, buildId: string): Promise<Catalog | null>;\n /** Catalogue the build again from its statics (a publish ended) and cache the result. */\n refresh(projectId: string, buildId: string): Promise<Catalog | null>;\n}\n\n/** Catalogs kept in memory by default. */\nexport const DEFAULT_CATALOG_CACHE_SIZE = 32;\n\n/** What {@link createCatalogLoader} needs. */\nexport interface CatalogLoaderOptions extends CatalogDeps {\n /** Catalogs kept in memory (least recently used leave first). */\n cacheSize?: number;\n logger?: Logger;\n}\n\n/** A loader over `options.db` and `options.storage`. */\nexport function createCatalogLoader(options: CatalogLoaderOptions): CatalogLoader {\n const limit = Math.max(1, options.cacheSize ?? DEFAULT_CATALOG_CACHE_SIZE);\n const cache = new Map<string, Catalog>();\n const inflight = new Map<string, Promise<Catalog | null>>();\n const remember = (buildId: string, catalog: Catalog): Catalog => {\n cache.delete(buildId);\n cache.set(buildId, catalog);\n const oldest = cache.keys().next().value;\n if (cache.size > limit && oldest !== undefined) {\n cache.delete(oldest);\n }\n return catalog;\n };\n const fetchCatalog = async (projectId: string, buildId: string): Promise<Catalog | null> => {\n const stored = await readCatalog(options.storage, projectId, buildId);\n if (stored) {\n return stored;\n }\n options.logger?.info({ buildId }, \"cataloguing a build published before the catalog\");\n return await catalogueBuild(options, projectId, buildId);\n };\n return {\n load: async (projectId, buildId) => {\n const hit = cache.get(buildId);\n if (hit) {\n return remember(buildId, hit);\n }\n const pending = inflight.get(buildId) ?? fetchCatalog(projectId, buildId);\n inflight.set(buildId, pending);\n try {\n const catalog = await pending;\n return catalog ? remember(buildId, catalog) : null;\n } finally {\n inflight.delete(buildId);\n }\n },\n refresh: async (projectId, buildId) => {\n cache.delete(buildId);\n const catalog = await catalogueBuild(options, projectId, buildId);\n return catalog ? remember(buildId, catalog) : null;\n },\n };\n}\n"],"mappings":";;;;;;AAkBA,MAAa,6BAA6B;;AAU1C,SAAgB,oBAAoB,SAA8C;CAChF,MAAM,QAAQ,KAAK,IAAI,GAAG,QAAQ,aAAA,EAAuC;CACzE,MAAM,wBAAQ,IAAI,IAAqB;CACvC,MAAM,2BAAW,IAAI,IAAqC;CAC1D,MAAM,YAAY,SAAiB,YAA8B;EAC/D,MAAM,OAAO,OAAO;EACpB,MAAM,IAAI,SAAS,OAAO;EAC1B,MAAM,SAAS,MAAM,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC;EACnC,IAAI,MAAM,OAAO,SAAS,WAAW,KAAA,GACnC,MAAM,OAAO,MAAM;EAErB,OAAO;CACT;CACA,MAAM,eAAe,OAAO,WAAmB,YAA6C;EAC1F,MAAM,SAAS,MAAM,YAAY,QAAQ,SAAS,WAAW,OAAO;EACpE,IAAI,QACF,OAAO;EAET,QAAQ,QAAQ,KAAK,EAAE,QAAQ,GAAG,kDAAkD;EACpF,OAAO,MAAM,eAAe,SAAS,WAAW,OAAO;CACzD;CACA,OAAO;EACL,MAAM,OAAO,WAAW,YAAY;GAClC,MAAM,MAAM,MAAM,IAAI,OAAO;GAC7B,IAAI,KACF,OAAO,SAAS,SAAS,GAAG;GAE9B,MAAM,UAAU,SAAS,IAAI,OAAO,KAAK,aAAa,WAAW,OAAO;GACxE,SAAS,IAAI,SAAS,OAAO;GAC7B,IAAI;IACF,MAAM,UAAU,MAAM;IACtB,OAAO,UAAU,SAAS,SAAS,OAAO,IAAI;GAChD,UAAU;IACR,SAAS,OAAO,OAAO;GACzB;EACF;EACA,SAAS,OAAO,WAAW,YAAY;GACrC,MAAM,OAAO,OAAO;GACpB,MAAM,UAAU,MAAM,eAAe,SAAS,WAAW,OAAO;GAChE,OAAO,UAAU,SAAS,SAAS,OAAO,IAAI;EAChD;CACF;AACF"}
@@ -0,0 +1,15 @@
1
+ import __tsdown_shims_path from 'node:path';
2
+ import __tsdown_shims_url from 'node:url';
3
+ import { CatalogEntry } from "./types.mjs";
4
+ //#region src/capture/catalog/parse.d.ts
5
+ /**
6
+ * Entries of a parsed index document, or null when it is not an index. Test entries (Storybook 10
7
+ * `subtype: "test"`) are left out, as capture leaves them out; entries without an id or title are
8
+ * skipped, never an error.
9
+ */
10
+ declare function parseStorybookIndex(document: unknown): CatalogEntry[] | null;
11
+ /** Parse the text of an index file; null when it is not JSON or not an index. */
12
+ declare function parseStorybookIndexText(text: string): CatalogEntry[] | null;
13
+ //#endregion
14
+ export { parseStorybookIndex, parseStorybookIndexText };
15
+ //# sourceMappingURL=parse.d.mts.map
@@ -0,0 +1,56 @@
1
+ import "node:path";
2
+ import "node:url";
3
+ import.meta.url;
4
+ import { normalizeImportPath } from "../../models/design-resolve.mjs";
5
+ //#region src/capture/catalog/parse.ts
6
+ /** Storybook index to catalog entries: `index.json` (v4/v5), `stories.json` (v3 and older). */
7
+ /**
8
+ * Entries of a parsed index document, or null when it is not an index. Test entries (Storybook 10
9
+ * `subtype: "test"`) are left out, as capture leaves them out; entries without an id or title are
10
+ * skipped, never an error.
11
+ */
12
+ function parseStorybookIndex(document) {
13
+ if (typeof document !== "object" || document === null) return null;
14
+ const record = document;
15
+ const table = [record.entries, record.stories].find((value) => isRecord(value));
16
+ if (!table) return null;
17
+ return Object.values(table).flatMap((raw) => {
18
+ const entry = toEntry(raw);
19
+ return entry ? [entry] : [];
20
+ });
21
+ }
22
+ /** Parse the text of an index file; null when it is not JSON or not an index. */
23
+ function parseStorybookIndexText(text) {
24
+ try {
25
+ return parseStorybookIndex(JSON.parse(text));
26
+ } catch {
27
+ return null;
28
+ }
29
+ }
30
+ function isRecord(value) {
31
+ return typeof value === "object" && value !== null && !Array.isArray(value);
32
+ }
33
+ function str(value) {
34
+ return typeof value === "string" && value !== "" ? value : void 0;
35
+ }
36
+ /** One raw entry; every field is optional on old Storybooks, so each is read defensively. */
37
+ function toEntry(raw) {
38
+ if (!isRecord(raw) || raw["subtype"] === "test") return null;
39
+ const id = str(raw["id"]);
40
+ const title = str(raw["title"]) ?? str(raw["kind"]);
41
+ if (!id || !title) return null;
42
+ const importPath = str(raw["importPath"]);
43
+ const tags = raw["tags"];
44
+ return {
45
+ id,
46
+ title,
47
+ name: str(raw["name"]) ?? str(raw["story"]) ?? id,
48
+ importPath: importPath ? normalizeImportPath(importPath) : "",
49
+ type: raw["type"] === "docs" ? "docs" : "story",
50
+ tags: Array.isArray(tags) ? tags.filter((tag) => typeof tag === "string") : []
51
+ };
52
+ }
53
+ //#endregion
54
+ export { parseStorybookIndex, parseStorybookIndexText };
55
+
56
+ //# sourceMappingURL=parse.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse.mjs","names":[],"sources":["../../../src/capture/catalog/parse.ts"],"sourcesContent":["/** Storybook index to catalog entries: `index.json` (v4/v5), `stories.json` (v3 and older). */\nimport { normalizeImportPath } from \"../../models/design-resolve.ts\";\nimport type { CatalogEntry } from \"./types.ts\";\n\n/**\n * Entries of a parsed index document, or null when it is not an index. Test entries (Storybook 10\n * `subtype: \"test\"`) are left out, as capture leaves them out; entries without an id or title are\n * skipped, never an error.\n */\nexport function parseStorybookIndex(document: unknown): CatalogEntry[] | null {\n if (typeof document !== \"object\" || document === null) {\n return null;\n }\n const record = document as { entries?: unknown; stories?: unknown };\n const table = [record.entries, record.stories].find((value) => isRecord(value));\n if (!table) {\n return null;\n }\n return Object.values(table).flatMap((raw) => {\n const entry = toEntry(raw);\n return entry ? [entry] : [];\n });\n}\n\n/** Parse the text of an index file; null when it is not JSON or not an index. */\nexport function parseStorybookIndexText(text: string): CatalogEntry[] | null {\n try {\n return parseStorybookIndex(JSON.parse(text));\n } catch {\n return null;\n }\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction str(value: unknown): string | undefined {\n return typeof value === \"string\" && value !== \"\" ? value : undefined;\n}\n\n/** One raw entry; every field is optional on old Storybooks, so each is read defensively. */\nfunction toEntry(raw: unknown): CatalogEntry | null {\n if (!isRecord(raw) || raw[\"subtype\"] === \"test\") {\n return null;\n }\n const id = str(raw[\"id\"]);\n const title = str(raw[\"title\"]) ?? str(raw[\"kind\"]);\n if (!id || !title) {\n return null;\n }\n const importPath = str(raw[\"importPath\"]);\n const tags = raw[\"tags\"];\n return {\n id,\n title,\n name: str(raw[\"name\"]) ?? str(raw[\"story\"]) ?? id,\n importPath: importPath ? normalizeImportPath(importPath) : \"\",\n type: raw[\"type\"] === \"docs\" ? \"docs\" : \"story\",\n tags: Array.isArray(tags) ? tags.filter((tag): tag is string => typeof tag === \"string\") : [],\n };\n}\n"],"mappings":";;;;;;;;;;;AASA,SAAgB,oBAAoB,UAA0C;CAC5E,IAAI,OAAO,aAAa,YAAY,aAAa,MAC/C,OAAO;CAET,MAAM,SAAS;CACf,MAAM,QAAQ,CAAC,OAAO,SAAS,OAAO,OAAO,CAAC,CAAC,MAAM,UAAU,SAAS,KAAK,CAAC;CAC9E,IAAI,CAAC,OACH,OAAO;CAET,OAAO,OAAO,OAAO,KAAK,CAAC,CAAC,SAAS,QAAQ;EAC3C,MAAM,QAAQ,QAAQ,GAAG;EACzB,OAAO,QAAQ,CAAC,KAAK,IAAI,CAAC;CAC5B,CAAC;AACH;;AAGA,SAAgB,wBAAwB,MAAqC;CAC3E,IAAI;EACF,OAAO,oBAAoB,KAAK,MAAM,IAAI,CAAC;CAC7C,QAAQ;EACN,OAAO;CACT;AACF;AAEA,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAS,IAAI,OAAoC;CAC/C,OAAO,OAAO,UAAU,YAAY,UAAU,KAAK,QAAQ,KAAA;AAC7D;;AAGA,SAAS,QAAQ,KAAmC;CAClD,IAAI,CAAC,SAAS,GAAG,KAAK,IAAI,eAAe,QACvC,OAAO;CAET,MAAM,KAAK,IAAI,IAAI,KAAK;CACxB,MAAM,QAAQ,IAAI,IAAI,QAAQ,KAAK,IAAI,IAAI,OAAO;CAClD,IAAI,CAAC,MAAM,CAAC,OACV,OAAO;CAET,MAAM,aAAa,IAAI,IAAI,aAAa;CACxC,MAAM,OAAO,IAAI;CACjB,OAAO;EACL;EACA;EACA,MAAM,IAAI,IAAI,OAAO,KAAK,IAAI,IAAI,QAAQ,KAAK;EAC/C,YAAY,aAAa,oBAAoB,UAAU,IAAI;EAC3D,MAAM,IAAI,YAAY,SAAS,SAAS;EACxC,MAAM,MAAM,QAAQ,IAAI,IAAI,KAAK,QAAQ,QAAuB,OAAO,QAAQ,QAAQ,IAAI,CAAC;CAC9F;AACF"}
@@ -0,0 +1,12 @@
1
+ import __tsdown_shims_path from 'node:path';
2
+ import __tsdown_shims_url from 'node:url';
3
+ import { StorageAdapter } from "../../adapter/storage.mjs";
4
+ //#region src/capture/catalog/read.d.ts
5
+ /**
6
+ * A file of a build's published Storybook by its path inside the build, or null when it is gone.
7
+ * Content-addressed builds answer through their manifest; older ones from the per-build copy.
8
+ */
9
+ declare function readPublishedFile(storage: StorageAdapter, projectId: string, buildId: string, rel: string): Promise<Buffer | null>;
10
+ //#endregion
11
+ export { readPublishedFile };
12
+ //# sourceMappingURL=read.d.mts.map
@@ -0,0 +1,33 @@
1
+ import "node:path";
2
+ import "node:url";
3
+ import.meta.url;
4
+ import { storybookDir } from "../../paths.mjs";
5
+ import { posix } from "node:path";
6
+ //#region src/capture/catalog/read.ts
7
+ /** Reading a published build's files from storage. */
8
+ /**
9
+ * A file of a build's published Storybook by its path inside the build, or null when it is gone.
10
+ * Content-addressed builds answer through their manifest; older ones from the per-build copy.
11
+ */
12
+ async function readPublishedFile(storage, projectId, buildId, rel) {
13
+ const dir = storybookDir(projectId, buildId);
14
+ const viaManifest = await readViaManifest(storage, dir, rel);
15
+ if (viaManifest) return viaManifest;
16
+ const legacy = posix.join(dir, rel);
17
+ return await storage.exists(legacy) ? await storage.read(legacy) : null;
18
+ }
19
+ async function readViaManifest(storage, dir, rel) {
20
+ try {
21
+ const manifestPath = posix.join(dir, "manifest.json");
22
+ if (!await storage.exists(manifestPath)) return null;
23
+ const hash = JSON.parse((await storage.read(manifestPath)).toString("utf8"))[rel];
24
+ const path = hash ? `content/${hash}` : void 0;
25
+ return path && await storage.exists(path) ? await storage.read(path) : null;
26
+ } catch {
27
+ return null;
28
+ }
29
+ }
30
+ //#endregion
31
+ export { readPublishedFile };
32
+
33
+ //# sourceMappingURL=read.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read.mjs","names":[],"sources":["../../../src/capture/catalog/read.ts"],"sourcesContent":["/** Reading a published build's files from storage. */\nimport { posix } from \"node:path\";\nimport type { StorageAdapter } from \"../../adapters/storage.ts\";\nimport { storybookDir } from \"../../utils/paths.ts\";\n\n/**\n * A file of a build's published Storybook by its path inside the build, or null when it is gone.\n * Content-addressed builds answer through their manifest; older ones from the per-build copy.\n */\nexport async function readPublishedFile(\n storage: StorageAdapter,\n projectId: string,\n buildId: string,\n rel: string,\n): Promise<Buffer | null> {\n const dir = storybookDir(projectId, buildId);\n const viaManifest = await readViaManifest(storage, dir, rel);\n if (viaManifest) {\n return viaManifest;\n }\n const legacy = posix.join(dir, rel);\n return (await storage.exists(legacy)) ? await storage.read(legacy) : null;\n}\n\nasync function readViaManifest(\n storage: StorageAdapter,\n dir: string,\n rel: string,\n): Promise<Buffer | null> {\n try {\n const manifestPath = posix.join(dir, \"manifest.json\");\n if (!(await storage.exists(manifestPath))) {\n return null;\n }\n const manifest = JSON.parse((await storage.read(manifestPath)).toString(\"utf8\")) as Record<\n string,\n string\n >;\n const hash = manifest[rel];\n const path = hash ? `content/${hash}` : undefined;\n return path && (await storage.exists(path)) ? await storage.read(path) : null;\n } catch {\n // an unreadable manifest falls back to the per-build copy\n return null;\n }\n}\n"],"mappings":";;;;;;;;;;;AASA,eAAsB,kBACpB,SACA,WACA,SACA,KACwB;CACxB,MAAM,MAAM,aAAa,WAAW,OAAO;CAC3C,MAAM,cAAc,MAAM,gBAAgB,SAAS,KAAK,GAAG;CAC3D,IAAI,aACF,OAAO;CAET,MAAM,SAAS,MAAM,KAAK,KAAK,GAAG;CAClC,OAAQ,MAAM,QAAQ,OAAO,MAAM,IAAK,MAAM,QAAQ,KAAK,MAAM,IAAI;AACvE;AAEA,eAAe,gBACb,SACA,KACA,KACwB;CACxB,IAAI;EACF,MAAM,eAAe,MAAM,KAAK,KAAK,eAAe;EACpD,IAAI,CAAE,MAAM,QAAQ,OAAO,YAAY,GACrC,OAAO;EAMT,MAAM,OAJW,KAAK,OAAO,MAAM,QAAQ,KAAK,YAAY,EAAA,CAAG,SAAS,MAAM,CAI1D,CAAC,CAAC;EACtB,MAAM,OAAO,OAAO,WAAW,SAAS,KAAA;EACxC,OAAO,QAAS,MAAM,QAAQ,OAAO,IAAI,IAAK,MAAM,QAAQ,KAAK,IAAI,IAAI;CAC3E,QAAQ;EAEN,OAAO;CACT;AACF"}
@@ -0,0 +1,33 @@
1
+ import __tsdown_shims_path from 'node:path';
2
+ import __tsdown_shims_url from 'node:url';
3
+ //#region src/capture/catalog/types.d.ts
4
+ /** Shapes of the persisted catalog (ADR 0006, decision 9). */
5
+ /** One Storybook index entry, kept compact: story and docs entries, never test entries. */
6
+ interface CatalogEntry {
7
+ id: string;
8
+ title: string;
9
+ name: string;
10
+ /** Story file without a leading `./`; empty when the index carries none. */
11
+ importPath: string;
12
+ type: "story" | "docs";
13
+ tags: string[];
14
+ }
15
+ /** A build's catalog as stored in `catalog.json`. */
16
+ interface Catalog {
17
+ /** Format version of the file. */
18
+ v: 1;
19
+ entries: CatalogEntry[];
20
+ }
21
+ /** The entries of one story file, with what `build_components` stores of them. */
22
+ interface CatalogComponent {
23
+ importPath: string;
24
+ title: string;
25
+ /** Story entries; docs entries are not counted. */
26
+ storyCount: number;
27
+ /** SHA-256 over the component's entries, so two builds compare with one string. */
28
+ hash: string;
29
+ entries: CatalogEntry[];
30
+ }
31
+ //#endregion
32
+ export { Catalog, CatalogComponent, CatalogEntry };
33
+ //# sourceMappingURL=types.d.mts.map
@@ -0,0 +1,58 @@
1
+ import __tsdown_shims_path from 'node:path';
2
+ import __tsdown_shims_url from 'node:url';
3
+ import { CaptureRunner } from "../../adapter/capture-runner.mjs";
4
+ import { DatabaseAdapter } from "../../adapter/database.mjs";
5
+ import { Logger } from "../../logger.mjs";
6
+ import { DesignProvider } from "../../adapter/design.mjs";
7
+ import { NotifierProvider } from "../../adapters/notifier/provider.mjs";
8
+ import { StorageAdapter } from "../../adapter/storage.mjs";
9
+ import { ShelfConfig } from "../../config.mjs";
10
+ import { SecretInput } from "../../utils/encrypt.mjs";
11
+ import { CaptureJobOptions, ShardJob } from "../orchestrator.mjs";
12
+ import { BuildStatePublisher } from "../build-state/types.mjs";
13
+ import { DispatchDeps } from "../dispatch.mjs";
14
+ import { KindHandler } from "./types.mjs";
15
+ //#region src/capture/consumer/capture-handler.d.ts
16
+ /** What the capture handler needs: the same adapters the server's own capture setup uses. */
17
+ interface CaptureHandlerOptions {
18
+ /** Database adapter; its own `tables` are used (never a dialect's defaults). */
19
+ db: DatabaseAdapter;
20
+ storage: StorageAdapter;
21
+ /** Pure renderer; `cancel` is called when a job's lease is lost or the job is cancelled. */
22
+ runner: CaptureRunner;
23
+ /** Scratch directory for Storybook extraction. */
24
+ scratchDir: string;
25
+ logger: Logger;
26
+ /** Puts a shard job on the queue; sharding needs it. Defaults to the consumed queue's `enqueue`. */
27
+ enqueue: (job: ShardJob) => Promise<void>;
28
+ /** Notifier providers; `state` channels (git hosts) get the build statuses. */
29
+ notifiers?: NotifierProvider[];
30
+ /**
31
+ * Shows a build's state on its git channels at every transition. Default: deliver inline through
32
+ * `notifiers` (a capture always has `testing` on); the app passes its queue-backed publisher.
33
+ */
34
+ buildState?: BuildStatePublisher;
35
+ /** Links in statuses are absolute from `publicBaseUrl`; published Storybooks use `publishedBaseDomain`. */
36
+ config?: Pick<ShelfConfig, "publicBaseUrl" | "publishedBaseDomain" | "maxZipEntries" | "maxUnzippedBytes">;
37
+ /**
38
+ * The resolved public origin (ADR 0007, decision 6): status links and URL-reaching targets use it.
39
+ * Default: `config.publicBaseUrl`, then the platform's address, then the origin an admin stored.
40
+ */
41
+ publicOrigin?: () => Promise<string | undefined>;
42
+ /** Design providers validating declared design links during capture. */
43
+ design?: DesignProvider[];
44
+ /** Server secret for webhook decryption. */
45
+ secret?: SecretInput;
46
+ viewports?: CaptureJobOptions["viewports"];
47
+ /** Captures per shard; unset keeps every build in one job. */
48
+ shardSize?: number;
49
+ /** Retries assumed for jobs that do not state `maxAttempts` (default 2). */
50
+ maxRetries?: number;
51
+ }
52
+ /** The `capture` handler: runs `createDispatchJob`'s runner, cancels through `runner.cancel`. */
53
+ declare function createCaptureHandler(options: CaptureHandlerOptions): KindHandler;
54
+ /** The dispatch dependencies the handler runs captures with; the host reuses them to write failures the pipeline never got to. */
55
+ declare function captureDispatchDeps(options: CaptureHandlerOptions, maxRetries: number): DispatchDeps;
56
+ //#endregion
57
+ export { CaptureHandlerOptions, captureDispatchDeps, createCaptureHandler };
58
+ //# sourceMappingURL=capture-handler.d.mts.map
@@ -0,0 +1,118 @@
1
+ import "node:path";
2
+ import "node:url";
3
+ import.meta.url;
4
+ import { extractionLimitsOf, resolvePublishLimits } from "../publish/limits.mjs";
5
+ import { retriesOf } from "./retry.mjs";
6
+ import { createBuildStatePublisher } from "../build-state/publisher.mjs";
7
+ import { createPublicOriginResolver } from "../../models/public-origin.mjs";
8
+ import { createDispatchJob } from "../dispatch.mjs";
9
+ //#region src/capture/consumer/capture-handler.ts
10
+ /** Whether a polled capture job carries the minimum shape to execute. */
11
+ function isValidCaptureJob(job) {
12
+ return typeof job.buildId === "string" && job.buildId.length > 0;
13
+ }
14
+ /** The `capture` handler: runs `createDispatchJob`'s runner, cancels through `runner.cancel`. */
15
+ function createCaptureHandler(options) {
16
+ const fallbackRetries = options.maxRetries ?? 2;
17
+ const dispatches = /* @__PURE__ */ new Map();
18
+ const dispatchFor = (retries) => {
19
+ const existing = dispatches.get(retries);
20
+ if (existing !== void 0) return existing;
21
+ const created = createDispatchJob(captureDispatchDeps(options, retries));
22
+ dispatches.set(retries, created);
23
+ return created;
24
+ };
25
+ dispatchFor(fallbackRetries);
26
+ return {
27
+ accepts: isValidCaptureJob,
28
+ run: async (job, context) => {
29
+ await dispatchFor(retriesOf(job, fallbackRetries))(toDispatchJob(job), { touch: () => {
30
+ context.touch();
31
+ } });
32
+ },
33
+ cancel: async (job) => {
34
+ await options.runner.cancel(job.buildId, job.shard);
35
+ }
36
+ };
37
+ }
38
+ function toDispatchJob(job) {
39
+ return {
40
+ buildId: job.buildId,
41
+ shard: job.shard,
42
+ attempts: job.attempts,
43
+ ...job.reqId === void 0 ? {} : { reqId: job.reqId },
44
+ ...job.traceparent === void 0 ? {} : { traceparent: job.traceparent }
45
+ };
46
+ }
47
+ /** The dispatch dependencies the handler runs captures with; the host reuses them to write failures the pipeline never got to. */
48
+ function captureDispatchDeps(options, maxRetries) {
49
+ const t = options.db.tables;
50
+ const publicOrigin = originOf(options);
51
+ const jobOptions = {
52
+ db: options.db,
53
+ tables: {
54
+ projects: t.projects,
55
+ builds: t.builds,
56
+ buildLabels: t.buildLabels,
57
+ snapshots: t.snapshots,
58
+ baselines: t.baselines,
59
+ captureAttempts: t.captureAttempts,
60
+ captureLogs: t.captureLogs
61
+ },
62
+ storage: options.storage,
63
+ runner: options.runner,
64
+ scratchDir: options.scratchDir,
65
+ limits: extractionLimitsOf(resolvePublishLimits(options.config)),
66
+ viewports: options.viewports,
67
+ logger: options.logger,
68
+ secret: options.secret,
69
+ design: options.design,
70
+ publicOrigin,
71
+ shardSize: options.shardSize,
72
+ enqueue: options.enqueue
73
+ };
74
+ return {
75
+ db: options.db,
76
+ tables: {
77
+ projects: t.projects,
78
+ builds: t.builds,
79
+ buildLabels: t.buildLabels,
80
+ snapshots: t.snapshots,
81
+ captureAttempts: t.captureAttempts,
82
+ captureLogs: t.captureLogs
83
+ },
84
+ jobOptions,
85
+ buildState: options.buildState ?? inlineBuildState(options, publicOrigin),
86
+ logger: options.logger,
87
+ maxRetries
88
+ };
89
+ }
90
+ /** Inline delivery of captured builds' states through the handler's own adapters. */
91
+ function inlineBuildState(options, publicOrigin) {
92
+ return createBuildStatePublisher({ deps: {
93
+ db: options.db,
94
+ storage: options.storage,
95
+ notifiers: options.notifiers ?? [],
96
+ secret: options.secret,
97
+ config: options.config ?? {},
98
+ publicOrigin,
99
+ flags: () => ({
100
+ testing: true,
101
+ review: false
102
+ }),
103
+ logger: options.logger
104
+ } });
105
+ }
106
+ /** The host's origin resolver, else one built from the database and `config.publicBaseUrl`. */
107
+ function originOf(options) {
108
+ if (options.publicOrigin !== void 0) return options.publicOrigin;
109
+ const resolver = createPublicOriginResolver({
110
+ db: options.db,
111
+ config: options.config
112
+ });
113
+ return async () => await resolver.url();
114
+ }
115
+ //#endregion
116
+ export { captureDispatchDeps, createCaptureHandler, originOf };
117
+
118
+ //# sourceMappingURL=capture-handler.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capture-handler.mjs","names":[],"sources":["../../../src/capture/consumer/capture-handler.ts"],"sourcesContent":["/** The `capture` kind's handler: builds the existing core dispatch from the host's adapters. */\nimport type { CaptureRunner } from \"../../adapters/capture-runner.ts\";\nimport type { DatabaseAdapter } from \"../../adapters/database.ts\";\nimport type { DesignProvider } from \"../../adapters/design.ts\";\nimport type { NotifierProvider } from \"../../adapters/notifier/provider.ts\";\nimport type { StorageAdapter } from \"../../adapters/storage.ts\";\nimport type { ShelfConfig } from \"../../config.ts\";\nimport type { Logger } from \"../../logger.ts\";\nimport { createPublicOriginResolver } from \"../../models/public-origin.ts\";\nimport type { SecretInput } from \"../../utils/encrypt.ts\";\nimport { createBuildStatePublisher } from \"../build-state/publisher.ts\";\nimport type { BuildStatePublisher } from \"../build-state/types.ts\";\nimport { createDispatchJob, type CaptureDispatchJob, type DispatchDeps } from \"../dispatch.ts\";\nimport type { CaptureJobOptions, ShardJob } from \"../orchestrator.ts\";\nimport { extractionLimitsOf, resolvePublishLimits } from \"../publish/limits.ts\";\nimport { DEFAULT_MAX_RETRIES, retriesOf } from \"./retry.ts\";\nimport type { ConsumerJob, KindHandler } from \"./types.ts\";\n\n/** What the capture handler needs: the same adapters the server's own capture setup uses. */\nexport interface CaptureHandlerOptions {\n /** Database adapter; its own `tables` are used (never a dialect's defaults). */\n db: DatabaseAdapter;\n storage: StorageAdapter;\n /** Pure renderer; `cancel` is called when a job's lease is lost or the job is cancelled. */\n runner: CaptureRunner;\n /** Scratch directory for Storybook extraction. */\n scratchDir: string;\n logger: Logger;\n /** Puts a shard job on the queue; sharding needs it. Defaults to the consumed queue's `enqueue`. */\n enqueue: (job: ShardJob) => Promise<void>;\n /** Notifier providers; `state` channels (git hosts) get the build statuses. */\n notifiers?: NotifierProvider[];\n /**\n * Shows a build's state on its git channels at every transition. Default: deliver inline through\n * `notifiers` (a capture always has `testing` on); the app passes its queue-backed publisher.\n */\n buildState?: BuildStatePublisher;\n /** Links in statuses are absolute from `publicBaseUrl`; published Storybooks use `publishedBaseDomain`. */\n config?: Pick<\n ShelfConfig,\n \"publicBaseUrl\" | \"publishedBaseDomain\" | \"maxZipEntries\" | \"maxUnzippedBytes\"\n >;\n /**\n * The resolved public origin (ADR 0007, decision 6): status links and URL-reaching targets use it.\n * Default: `config.publicBaseUrl`, then the platform's address, then the origin an admin stored.\n */\n publicOrigin?: () => Promise<string | undefined>;\n /** Design providers validating declared design links during capture. */\n design?: DesignProvider[];\n /** Server secret for webhook decryption. */\n secret?: SecretInput;\n viewports?: CaptureJobOptions[\"viewports\"];\n /** Captures per shard; unset keeps every build in one job. */\n shardSize?: number;\n /** Retries assumed for jobs that do not state `maxAttempts` (default 2). */\n maxRetries?: number;\n}\n\n/** Whether a polled capture job carries the minimum shape to execute. */\nfunction isValidCaptureJob(job: ConsumerJob): boolean {\n return typeof job.buildId === \"string\" && job.buildId.length > 0;\n}\n\n/** The `capture` handler: runs `createDispatchJob`'s runner, cancels through `runner.cancel`. */\nexport function createCaptureHandler(options: CaptureHandlerOptions): KindHandler {\n const fallbackRetries = options.maxRetries ?? DEFAULT_MAX_RETRIES;\n // The shard rule (\"a shard's last try is its final word\") depends on the queue's retry limit,\n // which a database job states itself, so one dispatch exists per distinct limit.\n const dispatches = new Map<number, ReturnType<typeof createDispatchJob>>();\n const dispatchFor = (retries: number): ReturnType<typeof createDispatchJob> => {\n const existing = dispatches.get(retries);\n if (existing !== undefined) {\n return existing;\n }\n const created = createDispatchJob(captureDispatchDeps(options, retries));\n dispatches.set(retries, created);\n return created;\n };\n dispatchFor(fallbackRetries);\n return {\n accepts: isValidCaptureJob,\n run: async (job, context) => {\n await dispatchFor(retriesOf(job, fallbackRetries))(toDispatchJob(job), {\n touch: () => {\n context.touch();\n },\n });\n },\n cancel: async (job) => {\n await options.runner.cancel(job.buildId, job.shard);\n },\n };\n}\n\nfunction toDispatchJob(job: ConsumerJob): CaptureDispatchJob {\n return {\n buildId: job.buildId,\n shard: job.shard,\n attempts: job.attempts,\n ...(job.reqId === undefined ? {} : { reqId: job.reqId }),\n ...(job.traceparent === undefined ? {} : { traceparent: job.traceparent }),\n };\n}\n\n/** The dispatch dependencies the handler runs captures with; the host reuses them to write failures the pipeline never got to. */\nexport function captureDispatchDeps(\n options: CaptureHandlerOptions,\n maxRetries: number,\n): DispatchDeps {\n const t = options.db.tables;\n const publicOrigin = originOf(options);\n const jobOptions: CaptureJobOptions = {\n db: options.db,\n tables: {\n projects: t.projects,\n builds: t.builds,\n buildLabels: t.buildLabels,\n snapshots: t.snapshots,\n baselines: t.baselines,\n captureAttempts: t.captureAttempts,\n captureLogs: t.captureLogs,\n },\n storage: options.storage,\n runner: options.runner,\n scratchDir: options.scratchDir,\n limits: extractionLimitsOf(resolvePublishLimits(options.config)),\n viewports: options.viewports,\n logger: options.logger,\n secret: options.secret,\n design: options.design,\n publicOrigin,\n shardSize: options.shardSize,\n enqueue: options.enqueue,\n };\n return {\n db: options.db,\n tables: {\n projects: t.projects,\n builds: t.builds,\n buildLabels: t.buildLabels,\n snapshots: t.snapshots,\n captureAttempts: t.captureAttempts,\n captureLogs: t.captureLogs,\n },\n jobOptions,\n buildState: options.buildState ?? inlineBuildState(options, publicOrigin),\n logger: options.logger,\n maxRetries,\n };\n}\n\n/** Inline delivery of captured builds' states through the handler's own adapters. */\nfunction inlineBuildState(\n options: CaptureHandlerOptions,\n publicOrigin: () => Promise<string | undefined>,\n): BuildStatePublisher {\n return createBuildStatePublisher({\n deps: {\n db: options.db,\n storage: options.storage,\n notifiers: options.notifiers ?? [],\n secret: options.secret,\n config: options.config ?? {},\n publicOrigin,\n flags: () => ({ testing: true, review: false }),\n logger: options.logger,\n },\n });\n}\n\n/** The host's origin resolver, else one built from the database and `config.publicBaseUrl`. */\nexport function originOf(\n options: Pick<CaptureHandlerOptions, \"db\" | \"config\" | \"publicOrigin\">,\n): () => Promise<string | undefined> {\n if (options.publicOrigin !== undefined) {\n return options.publicOrigin;\n }\n const resolver = createPublicOriginResolver({ db: options.db, config: options.config });\n return async () => await resolver.url();\n}\n"],"mappings":";;;;;;;;;;AA2DA,SAAS,kBAAkB,KAA2B;CACpD,OAAO,OAAO,IAAI,YAAY,YAAY,IAAI,QAAQ,SAAS;AACjE;;AAGA,SAAgB,qBAAqB,SAA6C;CAChF,MAAM,kBAAkB,QAAQ,cAAA;CAGhC,MAAM,6BAAa,IAAI,IAAkD;CACzE,MAAM,eAAe,YAA0D;EAC7E,MAAM,WAAW,WAAW,IAAI,OAAO;EACvC,IAAI,aAAa,KAAA,GACf,OAAO;EAET,MAAM,UAAU,kBAAkB,oBAAoB,SAAS,OAAO,CAAC;EACvE,WAAW,IAAI,SAAS,OAAO;EAC/B,OAAO;CACT;CACA,YAAY,eAAe;CAC3B,OAAO;EACL,SAAS;EACT,KAAK,OAAO,KAAK,YAAY;GAC3B,MAAM,YAAY,UAAU,KAAK,eAAe,CAAC,CAAC,CAAC,cAAc,GAAG,GAAG,EACrE,aAAa;IACX,QAAQ,MAAM;GAChB,EACF,CAAC;EACH;EACA,QAAQ,OAAO,QAAQ;GACrB,MAAM,QAAQ,OAAO,OAAO,IAAI,SAAS,IAAI,KAAK;EACpD;CACF;AACF;AAEA,SAAS,cAAc,KAAsC;CAC3D,OAAO;EACL,SAAS,IAAI;EACb,OAAO,IAAI;EACX,UAAU,IAAI;EACd,GAAI,IAAI,UAAU,KAAA,IAAY,CAAC,IAAI,EAAE,OAAO,IAAI,MAAM;EACtD,GAAI,IAAI,gBAAgB,KAAA,IAAY,CAAC,IAAI,EAAE,aAAa,IAAI,YAAY;CAC1E;AACF;;AAGA,SAAgB,oBACd,SACA,YACc;CACd,MAAM,IAAI,QAAQ,GAAG;CACrB,MAAM,eAAe,SAAS,OAAO;CACrC,MAAM,aAAgC;EACpC,IAAI,QAAQ;EACZ,QAAQ;GACN,UAAU,EAAE;GACZ,QAAQ,EAAE;GACV,aAAa,EAAE;GACf,WAAW,EAAE;GACb,WAAW,EAAE;GACb,iBAAiB,EAAE;GACnB,aAAa,EAAE;EACjB;EACA,SAAS,QAAQ;EACjB,QAAQ,QAAQ;EAChB,YAAY,QAAQ;EACpB,QAAQ,mBAAmB,qBAAqB,QAAQ,MAAM,CAAC;EAC/D,WAAW,QAAQ;EACnB,QAAQ,QAAQ;EAChB,QAAQ,QAAQ;EAChB,QAAQ,QAAQ;EAChB;EACA,WAAW,QAAQ;EACnB,SAAS,QAAQ;CACnB;CACA,OAAO;EACL,IAAI,QAAQ;EACZ,QAAQ;GACN,UAAU,EAAE;GACZ,QAAQ,EAAE;GACV,aAAa,EAAE;GACf,WAAW,EAAE;GACb,iBAAiB,EAAE;GACnB,aAAa,EAAE;EACjB;EACA;EACA,YAAY,QAAQ,cAAc,iBAAiB,SAAS,YAAY;EACxE,QAAQ,QAAQ;EAChB;CACF;AACF;;AAGA,SAAS,iBACP,SACA,cACqB;CACrB,OAAO,0BAA0B,EAC/B,MAAM;EACJ,IAAI,QAAQ;EACZ,SAAS,QAAQ;EACjB,WAAW,QAAQ,aAAa,CAAC;EACjC,QAAQ,QAAQ;EAChB,QAAQ,QAAQ,UAAU,CAAC;EAC3B;EACA,cAAc;GAAE,SAAS;GAAM,QAAQ;EAAM;EAC7C,QAAQ,QAAQ;CAClB,EACF,CAAC;AACH;;AAGA,SAAgB,SACd,SACmC;CACnC,IAAI,QAAQ,iBAAiB,KAAA,GAC3B,OAAO,QAAQ;CAEjB,MAAM,WAAW,2BAA2B;EAAE,IAAI,QAAQ;EAAI,QAAQ,QAAQ;CAAO,CAAC;CACtF,OAAO,YAAY,MAAM,SAAS,IAAI;AACxC"}
@@ -0,0 +1,17 @@
1
+ import __tsdown_shims_path from 'node:path';
2
+ import __tsdown_shims_url from 'node:url';
3
+ //#region src/capture/consumer/idle.d.ts
4
+ /**
5
+ * Idle backoff for queues whose `poll()` returns immediately when empty (GCP Pub/Sub synchronous
6
+ * pull, Azure Storage Queues). Queues that long-poll (SQS, Redis, Service Bus, the IPC queue) block
7
+ * inside `poll()` and never trigger it. The database queue paces itself (`db-queue/cadence.ts`).
8
+ */
9
+ /** An empty poll that returns faster than this did not long-poll. */
10
+ declare const MIN_BLOCKING_POLL_MS = 1000;
11
+ /** Sleep for consecutive fast empty polls: 250ms doubling up to 5s. */
12
+ declare function idleDelayMs(emptyStreak: number): number;
13
+ /** Whether an empty poll came back too fast to have blocked on the queue. */
14
+ declare function isFastEmptyPoll(elapsedMs: number): boolean;
15
+ //#endregion
16
+ export { MIN_BLOCKING_POLL_MS, idleDelayMs, isFastEmptyPoll };
17
+ //# sourceMappingURL=idle.d.mts.map