@cnc-tools/storm 0.0.0 → 0.6.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 (527) hide show
  1. package/bin/node-version.js +24 -0
  2. package/bin/storm.js +16 -0
  3. package/dist/application.d.ts +13 -0
  4. package/dist/application.js +23 -0
  5. package/dist/bin/storm.d.ts +1 -0
  6. package/dist/bin/storm.js +45 -0
  7. package/dist/build-info.js +3 -0
  8. package/dist/closed-terminal.d.ts +7 -0
  9. package/dist/closed-terminal.js +18 -0
  10. package/dist/combine-errors.d.ts +11 -0
  11. package/dist/combine-errors.js +19 -0
  12. package/dist/commands/dashboard.d.ts +11 -0
  13. package/dist/commands/dashboard.js +18 -0
  14. package/dist/commands/exec/cleanup.d.ts +135 -0
  15. package/dist/commands/exec/cleanup.js +171 -0
  16. package/dist/commands/exec/command.d.ts +272 -0
  17. package/dist/commands/exec/command.js +23 -0
  18. package/dist/commands/exec/job-summary.d.ts +10 -0
  19. package/dist/commands/exec/job-summary.js +34 -0
  20. package/dist/commands/exec/live-view.d.ts +22 -0
  21. package/dist/commands/exec/live-view.js +395 -0
  22. package/dist/commands/exec/metadata.d.ts +66 -0
  23. package/dist/commands/exec/metadata.js +55 -0
  24. package/dist/commands/exec/mint-failed.d.ts +11 -0
  25. package/dist/commands/exec/mint-failed.js +33 -0
  26. package/dist/commands/exec/outcomes.d.ts +614 -0
  27. package/dist/commands/exec/outcomes.js +338 -0
  28. package/dist/commands/exec/progress.d.ts +44 -0
  29. package/dist/commands/exec/progress.js +277 -0
  30. package/dist/commands/exec/redaction.d.ts +15 -0
  31. package/dist/commands/exec/redaction.js +40 -0
  32. package/dist/commands/exec/run-collector.d.ts +30 -0
  33. package/dist/commands/exec/run-collector.js +73 -0
  34. package/dist/commands/exec/run-command.d.ts +221 -0
  35. package/dist/commands/exec/run-command.js +663 -0
  36. package/dist/commands/exec/run-metadata.d.ts +56 -0
  37. package/dist/commands/exec/run-metadata.js +58 -0
  38. package/dist/commands/exec/run-record.d.ts +170 -0
  39. package/dist/commands/exec/run-record.js +104 -0
  40. package/dist/commands/exec/tests-summary.d.ts +34 -0
  41. package/dist/commands/exec/tests-summary.js +141 -0
  42. package/dist/commands/exec/testserver-flags.d.ts +48 -0
  43. package/dist/commands/exec/testserver-flags.js +80 -0
  44. package/dist/commands/exec/text.d.ts +22 -0
  45. package/dist/commands/exec/text.js +74 -0
  46. package/dist/commands/exec/view.d.ts +35 -0
  47. package/dist/commands/exec/view.js +163 -0
  48. package/dist/commands/exec/waterfall.d.ts +25 -0
  49. package/dist/commands/exec/waterfall.js +108 -0
  50. package/dist/commands/exec/worker-chart.d.ts +79 -0
  51. package/dist/commands/exec/worker-chart.js +313 -0
  52. package/dist/commands/runs/facts.d.ts +150 -0
  53. package/dist/commands/runs/facts.js +292 -0
  54. package/dist/commands/runs/list/command.d.ts +86 -0
  55. package/dist/commands/runs/list/command.js +36 -0
  56. package/dist/commands/runs/list/metadata.d.ts +22 -0
  57. package/dist/commands/runs/list/metadata.js +19 -0
  58. package/dist/commands/runs/list/outcomes.d.ts +74 -0
  59. package/dist/commands/runs/list/outcomes.js +89 -0
  60. package/dist/commands/runs/logs/command.d.ts +72 -0
  61. package/dist/commands/runs/logs/command.js +51 -0
  62. package/dist/commands/runs/logs/metadata.d.ts +22 -0
  63. package/dist/commands/runs/logs/metadata.js +22 -0
  64. package/dist/commands/runs/logs/outcomes.d.ts +55 -0
  65. package/dist/commands/runs/logs/outcomes.js +80 -0
  66. package/dist/commands/runs/metadata.d.ts +3 -0
  67. package/dist/commands/runs/metadata.js +3 -0
  68. package/dist/commands/runs/past-run.d.ts +72 -0
  69. package/dist/commands/runs/past-run.js +99 -0
  70. package/dist/commands/runs/show/command.d.ts +176 -0
  71. package/dist/commands/runs/show/command.js +76 -0
  72. package/dist/commands/runs/show/metadata.d.ts +25 -0
  73. package/dist/commands/runs/show/metadata.js +22 -0
  74. package/dist/commands/runs/show/outcomes.d.ts +164 -0
  75. package/dist/commands/runs/show/outcomes.js +320 -0
  76. package/dist/commands/vitest/command.d.ts +299 -0
  77. package/dist/commands/vitest/command.js +138 -0
  78. package/dist/commands/vitest/metadata.d.ts +66 -0
  79. package/dist/commands/vitest/metadata.js +35 -0
  80. package/dist/commands/vitest/outcomes.d.ts +273 -0
  81. package/dist/commands/vitest/outcomes.js +77 -0
  82. package/dist/config/by-name.d.ts +24 -0
  83. package/dist/config/by-name.js +26 -0
  84. package/dist/config/errors.d.ts +58 -0
  85. package/dist/config/errors.js +101 -0
  86. package/dist/config/gateways.d.ts +32 -0
  87. package/dist/config/gateways.js +1 -0
  88. package/dist/config/index.d.ts +10 -0
  89. package/dist/config/index.js +13 -0
  90. package/dist/config/live/config-gateway.d.ts +6 -0
  91. package/dist/config/live/config-gateway.js +71 -0
  92. package/dist/config/load.d.ts +54 -0
  93. package/dist/config/load.js +175 -0
  94. package/dist/config/resolve.d.ts +49 -0
  95. package/dist/config/resolve.js +94 -0
  96. package/dist/config/resource-config.d.ts +132 -0
  97. package/dist/config/resource-config.js +19 -0
  98. package/dist/config/schema.d.ts +64 -0
  99. package/dist/config/schema.js +57 -0
  100. package/dist/config/set.d.ts +27 -0
  101. package/dist/config/set.js +71 -0
  102. package/dist/config/settings-file.d.ts +41 -0
  103. package/dist/config/settings-file.js +72 -0
  104. package/dist/config-file/define.d.ts +39 -0
  105. package/dist/config-file/define.js +9 -0
  106. package/dist/config-file/toolchain.d.ts +9 -0
  107. package/dist/config-file/toolchain.js +41 -0
  108. package/dist/context.d.ts +89 -0
  109. package/dist/context.js +45 -0
  110. package/dist/core/command-provider.d.ts +126 -0
  111. package/dist/core/command-provider.js +13 -0
  112. package/dist/core/command-slots.d.ts +67 -0
  113. package/dist/core/command-slots.js +136 -0
  114. package/dist/core/events.d.ts +128 -0
  115. package/dist/core/events.js +15 -0
  116. package/dist/core/gateways.d.ts +249 -0
  117. package/dist/core/gateways.js +1 -0
  118. package/dist/core/index.d.ts +20 -0
  119. package/dist/core/index.js +18 -0
  120. package/dist/core/keyed.d.ts +12 -0
  121. package/dist/core/keyed.js +24 -0
  122. package/dist/core/lane.d.ts +46 -0
  123. package/dist/core/lane.js +5 -0
  124. package/dist/core/limit.d.ts +9 -0
  125. package/dist/core/limit.js +29 -0
  126. package/dist/core/live/command-gateway.d.ts +11 -0
  127. package/dist/core/live/command-gateway.js +83 -0
  128. package/dist/core/live/job-summary-gateway.d.ts +5 -0
  129. package/dist/core/live/job-summary-gateway.js +20 -0
  130. package/dist/core/live/progress-terminal.d.ts +20 -0
  131. package/dist/core/live/progress-terminal.js +173 -0
  132. package/dist/core/live/run-directory-gateway.d.ts +24 -0
  133. package/dist/core/live/run-directory-gateway.js +437 -0
  134. package/dist/core/mint.d.ts +10 -0
  135. package/dist/core/mint.js +14 -0
  136. package/dist/core/payload.d.ts +26 -0
  137. package/dist/core/payload.js +33 -0
  138. package/dist/core/presentation.d.ts +87 -0
  139. package/dist/core/presentation.js +5 -0
  140. package/dist/core/presentations.d.ts +56 -0
  141. package/dist/core/presentations.js +66 -0
  142. package/dist/core/provider.d.ts +69 -0
  143. package/dist/core/provider.js +5 -0
  144. package/dist/core/resource.d.ts +262 -0
  145. package/dist/core/resource.js +6 -0
  146. package/dist/core/resources.d.ts +131 -0
  147. package/dist/core/resources.js +254 -0
  148. package/dist/core/run-directory.d.ts +69 -0
  149. package/dist/core/run-directory.js +94 -0
  150. package/dist/core/run-state.d.ts +152 -0
  151. package/dist/core/run-state.js +313 -0
  152. package/dist/core/run.d.ts +187 -0
  153. package/dist/core/run.js +321 -0
  154. package/dist/core/state-directory.d.ts +19 -0
  155. package/dist/core/state-directory.js +29 -0
  156. package/dist/core/timeline.d.ts +63 -0
  157. package/dist/core/timeline.js +97 -0
  158. package/dist/core/timing.d.ts +22 -0
  159. package/dist/core/timing.js +26 -0
  160. package/dist/credential/credential.d.ts +46 -0
  161. package/dist/credential/credential.js +80 -0
  162. package/dist/credential/diagnosis.d.ts +18 -0
  163. package/dist/credential/diagnosis.js +99 -0
  164. package/dist/credential/gateways.d.ts +109 -0
  165. package/dist/credential/gateways.js +1 -0
  166. package/dist/credential/index.d.ts +7 -0
  167. package/dist/credential/index.js +7 -0
  168. package/dist/credential/live/github-actions-token-gateway.d.ts +15 -0
  169. package/dist/credential/live/github-actions-token-gateway.js +43 -0
  170. package/dist/credential/live/github-actions-token-response.d.ts +19 -0
  171. package/dist/credential/live/github-actions-token-response.js +49 -0
  172. package/dist/credential/live/vercel-cli-gateway.d.ts +9 -0
  173. package/dist/credential/live/vercel-cli-gateway.js +64 -0
  174. package/dist/credential/live/vercel-output.d.ts +60 -0
  175. package/dist/credential/live/vercel-output.js +122 -0
  176. package/dist/credential/live/vercel-process.d.ts +14 -0
  177. package/dist/credential/live/vercel-process.js +3 -0
  178. package/dist/credential/settle.d.ts +31 -0
  179. package/dist/credential/settle.js +49 -0
  180. package/dist/credential/source.d.ts +110 -0
  181. package/dist/credential/source.js +114 -0
  182. package/dist/help-logo.d.ts +11 -0
  183. package/dist/help-logo.js +56 -0
  184. package/dist/presentation.d.ts +26 -0
  185. package/dist/presentation.js +21 -0
  186. package/dist/resources/github/cleanup.d.ts +23 -0
  187. package/dist/resources/github/cleanup.js +39 -0
  188. package/dist/resources/github/command.d.ts +74 -0
  189. package/dist/resources/github/command.js +117 -0
  190. package/dist/resources/github/config.d.ts +16 -0
  191. package/dist/resources/github/config.js +37 -0
  192. package/dist/resources/github/events.d.ts +26 -0
  193. package/dist/resources/github/events.js +2 -0
  194. package/dist/resources/github/fixture-repo.d.ts +69 -0
  195. package/dist/resources/github/fixture-repo.js +60 -0
  196. package/dist/resources/github/gateways.d.ts +62 -0
  197. package/dist/resources/github/gateways.js +1 -0
  198. package/dist/resources/github/index.d.ts +12 -0
  199. package/dist/resources/github/index.js +15 -0
  200. package/dist/resources/github/live/fixture-repo-gateway.d.ts +12 -0
  201. package/dist/resources/github/live/fixture-repo-gateway.js +92 -0
  202. package/dist/resources/github/live/gateways.d.ts +6 -0
  203. package/dist/resources/github/live/gateways.js +13 -0
  204. package/dist/resources/github/presentation.d.ts +13 -0
  205. package/dist/resources/github/presentation.js +43 -0
  206. package/dist/resources/github/provider.d.ts +66 -0
  207. package/dist/resources/github/provider.js +58 -0
  208. package/dist/resources/github/resource-provider.d.ts +6 -0
  209. package/dist/resources/github/resource-provider.js +20 -0
  210. package/dist/resources/github/resource.d.ts +33 -0
  211. package/dist/resources/github/resource.js +12 -0
  212. package/dist/resources/testserver/cleanup.d.ts +14 -0
  213. package/dist/resources/testserver/cleanup.js +22 -0
  214. package/dist/resources/testserver/command.d.ts +322 -0
  215. package/dist/resources/testserver/command.js +245 -0
  216. package/dist/resources/testserver/commands/app.d.ts +18 -0
  217. package/dist/resources/testserver/commands/app.js +3 -0
  218. package/dist/resources/testserver/commands/create/command.d.ts +136 -0
  219. package/dist/resources/testserver/commands/create/command.js +158 -0
  220. package/dist/resources/testserver/commands/create/metadata.d.ts +31 -0
  221. package/dist/resources/testserver/commands/create/metadata.js +45 -0
  222. package/dist/resources/testserver/commands/create/outcomes.d.ts +111 -0
  223. package/dist/resources/testserver/commands/create/outcomes.js +172 -0
  224. package/dist/resources/testserver/commands/list/command.d.ts +60 -0
  225. package/dist/resources/testserver/commands/list/command.js +56 -0
  226. package/dist/resources/testserver/commands/list/metadata.d.ts +9 -0
  227. package/dist/resources/testserver/commands/list/metadata.js +9 -0
  228. package/dist/resources/testserver/commands/list/outcomes.d.ts +54 -0
  229. package/dist/resources/testserver/commands/list/outcomes.js +152 -0
  230. package/dist/resources/testserver/config.d.ts +18 -0
  231. package/dist/resources/testserver/config.js +78 -0
  232. package/dist/resources/testserver/credential-facts.d.ts +80 -0
  233. package/dist/resources/testserver/credential-facts.js +83 -0
  234. package/dist/resources/testserver/events.d.ts +59 -0
  235. package/dist/resources/testserver/events.js +4 -0
  236. package/dist/resources/testserver/index.d.ts +16 -0
  237. package/dist/resources/testserver/index.js +24 -0
  238. package/dist/resources/testserver/lane.d.ts +28 -0
  239. package/dist/resources/testserver/lane.js +139 -0
  240. package/dist/resources/testserver/live/gateways.d.ts +6 -0
  241. package/dist/resources/testserver/live/gateways.js +26 -0
  242. package/dist/resources/testserver/options.d.ts +5 -0
  243. package/dist/resources/testserver/options.js +5 -0
  244. package/dist/resources/testserver/pool/channels.d.ts +80 -0
  245. package/dist/resources/testserver/pool/channels.js +48 -0
  246. package/dist/resources/testserver/pool/create.d.ts +48 -0
  247. package/dist/resources/testserver/pool/create.js +45 -0
  248. package/dist/resources/testserver/pool/directory.d.ts +4 -0
  249. package/dist/resources/testserver/pool/directory.js +5 -0
  250. package/dist/resources/testserver/pool/gateways.d.ts +190 -0
  251. package/dist/resources/testserver/pool/gateways.js +1 -0
  252. package/dist/resources/testserver/pool/host.d.ts +8 -0
  253. package/dist/resources/testserver/pool/host.js +21 -0
  254. package/dist/resources/testserver/pool/index.d.ts +9 -0
  255. package/dist/resources/testserver/pool/index.js +10 -0
  256. package/dist/resources/testserver/pool/inspect.d.ts +53 -0
  257. package/dist/resources/testserver/pool/inspect.js +45 -0
  258. package/dist/resources/testserver/pool/lease.d.ts +84 -0
  259. package/dist/resources/testserver/pool/lease.js +125 -0
  260. package/dist/resources/testserver/pool/live/pool-records.d.ts +17 -0
  261. package/dist/resources/testserver/pool/live/pool-records.js +70 -0
  262. package/dist/resources/testserver/pool/live/pool-store-gateway.d.ts +12 -0
  263. package/dist/resources/testserver/pool/live/pool-store-gateway.js +435 -0
  264. package/dist/resources/testserver/pool/staleness.d.ts +16 -0
  265. package/dist/resources/testserver/pool/staleness.js +27 -0
  266. package/dist/resources/testserver/presentation.d.ts +9 -0
  267. package/dist/resources/testserver/presentation.js +217 -0
  268. package/dist/resources/testserver/provider.d.ts +177 -0
  269. package/dist/resources/testserver/provider.js +254 -0
  270. package/dist/resources/testserver/ran.d.ts +87 -0
  271. package/dist/resources/testserver/ran.js +140 -0
  272. package/dist/resources/testserver/resource-provider.d.ts +12 -0
  273. package/dist/resources/testserver/resource-provider.js +38 -0
  274. package/dist/resources/testserver/resource.d.ts +32 -0
  275. package/dist/resources/testserver/resource.js +10 -0
  276. package/dist/resources/testserver/run-sandbox.d.ts +13 -0
  277. package/dist/resources/testserver/run-sandbox.js +6 -0
  278. package/dist/resources/testserver/sandbox/channels.d.ts +12 -0
  279. package/dist/resources/testserver/sandbox/channels.js +21 -0
  280. package/dist/resources/testserver/sandbox/create-failure.d.ts +35 -0
  281. package/dist/resources/testserver/sandbox/create-failure.js +65 -0
  282. package/dist/resources/testserver/sandbox/create.d.ts +29 -0
  283. package/dist/resources/testserver/sandbox/create.js +37 -0
  284. package/dist/resources/testserver/sandbox/gateways.d.ts +150 -0
  285. package/dist/resources/testserver/sandbox/gateways.js +1 -0
  286. package/dist/resources/testserver/sandbox/index.d.ts +6 -0
  287. package/dist/resources/testserver/sandbox/index.js +7 -0
  288. package/dist/resources/testserver/sandbox/live/builds-response.d.ts +9 -0
  289. package/dist/resources/testserver/sandbox/live/builds-response.js +27 -0
  290. package/dist/resources/testserver/sandbox/live/control-plane-gateway.d.ts +17 -0
  291. package/dist/resources/testserver/sandbox/live/control-plane-gateway.js +133 -0
  292. package/dist/resources/testserver/sandbox/live/create-response.d.ts +35 -0
  293. package/dist/resources/testserver/sandbox/live/create-response.js +78 -0
  294. package/dist/resources/testserver/sandbox/live/fetch-failure.d.ts +24 -0
  295. package/dist/resources/testserver/sandbox/live/fetch-failure.js +45 -0
  296. package/dist/resources/testserver/sandbox/live/health-check-gateway.d.ts +11 -0
  297. package/dist/resources/testserver/sandbox/live/health-check-gateway.js +36 -0
  298. package/dist/resources/testserver/sandbox/live/sse.d.ts +12 -0
  299. package/dist/resources/testserver/sandbox/live/sse.js +32 -0
  300. package/dist/resources.d.ts +455 -0
  301. package/dist/resources.js +88 -0
  302. package/dist/runner/base.d.ts +40 -0
  303. package/dist/runner/base.js +52 -0
  304. package/dist/runner/context.d.ts +13 -0
  305. package/dist/runner/context.js +9 -0
  306. package/dist/runner/events.d.ts +179 -0
  307. package/dist/runner/events.js +16 -0
  308. package/dist/runner/gateways.d.ts +351 -0
  309. package/dist/runner/gateways.js +3 -0
  310. package/dist/runner/index.d.ts +19 -0
  311. package/dist/runner/index.js +18 -0
  312. package/dist/runner/live/checkout-gateway.d.ts +3 -0
  313. package/dist/runner/live/checkout-gateway.js +206 -0
  314. package/dist/runner/live/git-output.d.ts +14 -0
  315. package/dist/runner/live/git-output.js +32 -0
  316. package/dist/runner/live/sandbox-errors.d.ts +7 -0
  317. package/dist/runner/live/sandbox-errors.js +21 -0
  318. package/dist/runner/live/sandbox-gateway.d.ts +7 -0
  319. package/dist/runner/live/sandbox-gateway.js +427 -0
  320. package/dist/runner/live/snapshot-cache-gateway.d.ts +12 -0
  321. package/dist/runner/live/snapshot-cache-gateway.js +104 -0
  322. package/dist/runner/live/snapshot-records.d.ts +11 -0
  323. package/dist/runner/live/snapshot-records.js +57 -0
  324. package/dist/runner/live/terminal.d.ts +16 -0
  325. package/dist/runner/live/terminal.js +37 -0
  326. package/dist/runner/live/user.d.ts +2 -0
  327. package/dist/runner/live/user.js +11 -0
  328. package/dist/runner/output.d.ts +23 -0
  329. package/dist/runner/output.js +58 -0
  330. package/dist/runner/prepare.d.ts +67 -0
  331. package/dist/runner/prepare.js +59 -0
  332. package/dist/runner/ready.d.ts +68 -0
  333. package/dist/runner/ready.js +159 -0
  334. package/dist/runner/recipe.d.ts +126 -0
  335. package/dist/runner/recipe.js +302 -0
  336. package/dist/runner/remote-command.d.ts +77 -0
  337. package/dist/runner/remote-command.js +127 -0
  338. package/dist/runner/scope.d.ts +58 -0
  339. package/dist/runner/scope.js +117 -0
  340. package/dist/runner/snapshot-build.d.ts +33 -0
  341. package/dist/runner/snapshot-build.js +112 -0
  342. package/dist/runner/snapshot-cache.d.ts +84 -0
  343. package/dist/runner/snapshot-cache.js +126 -0
  344. package/dist/runner/snapshot-key.d.ts +52 -0
  345. package/dist/runner/snapshot-key.js +91 -0
  346. package/dist/runner/steps.d.ts +41 -0
  347. package/dist/runner/steps.js +49 -0
  348. package/dist/sdk/container/api-request.d.ts +32 -0
  349. package/dist/sdk/container/api-request.js +46 -0
  350. package/dist/sdk/container/container.d.ts +144 -0
  351. package/dist/sdk/container/container.js +346 -0
  352. package/dist/sdk/container/feature-flags.d.ts +37 -0
  353. package/dist/sdk/container/feature-flags.js +118 -0
  354. package/dist/sdk/container/gateways.d.ts +108 -0
  355. package/dist/sdk/container/gateways.js +1 -0
  356. package/dist/sdk/container/index.d.ts +5 -0
  357. package/dist/sdk/container/index.js +5 -0
  358. package/dist/sdk/container/live/container-gateway.d.ts +17 -0
  359. package/dist/sdk/container/live/container-gateway.js +114 -0
  360. package/dist/sdk/factories/build.d.ts +66 -0
  361. package/dist/sdk/factories/build.js +98 -0
  362. package/dist/sdk/factories/definition.d.ts +28 -0
  363. package/dist/sdk/factories/definition.js +16 -0
  364. package/dist/sdk/factories/definitions.d.ts +166 -0
  365. package/dist/sdk/factories/definitions.js +235 -0
  366. package/dist/sdk/factories/gateways.d.ts +25 -0
  367. package/dist/sdk/factories/gateways.js +1 -0
  368. package/dist/sdk/factories/index.d.ts +5 -0
  369. package/dist/sdk/factories/index.js +5 -0
  370. package/dist/sdk/factories/live/factory-gateway.d.ts +10 -0
  371. package/dist/sdk/factories/live/factory-gateway.js +29 -0
  372. package/dist/sdk/index.d.ts +7 -0
  373. package/dist/sdk/index.js +15 -0
  374. package/dist/sdk/payload/index.d.ts +2 -0
  375. package/dist/sdk/payload/index.js +4 -0
  376. package/dist/sdk/payload/payload.d.ts +47 -0
  377. package/dist/sdk/payload/payload.js +74 -0
  378. package/dist/sdk/payload/test-events.d.ts +102 -0
  379. package/dist/sdk/payload/test-events.js +59 -0
  380. package/dist/sdk/proxy/exchange.d.ts +58 -0
  381. package/dist/sdk/proxy/exchange.js +173 -0
  382. package/dist/sdk/proxy/faulted-exchange.d.ts +10 -0
  383. package/dist/sdk/proxy/faulted-exchange.js +106 -0
  384. package/dist/sdk/proxy/faults.d.ts +133 -0
  385. package/dist/sdk/proxy/faults.js +147 -0
  386. package/dist/sdk/proxy/index.d.ts +3 -0
  387. package/dist/sdk/proxy/index.js +3 -0
  388. package/dist/sdk/proxy/proxy.d.ts +93 -0
  389. package/dist/sdk/proxy/proxy.js +99 -0
  390. package/dist/sdk/proxy/records.d.ts +56 -0
  391. package/dist/sdk/proxy/records.js +56 -0
  392. package/dist/sdk/records/body.d.ts +89 -0
  393. package/dist/sdk/records/body.js +236 -0
  394. package/dist/sdk/records/index.d.ts +2 -0
  395. package/dist/sdk/records/index.js +4 -0
  396. package/dist/sdk/records/records.d.ts +49 -0
  397. package/dist/sdk/records/records.js +16 -0
  398. package/dist/sdk/seed/index.d.ts +1 -0
  399. package/dist/sdk/seed/index.js +3 -0
  400. package/dist/sdk/seed/seed.d.ts +221 -0
  401. package/dist/sdk/seed/seed.js +171 -0
  402. package/dist/sdk/testserver/clock.d.ts +8 -0
  403. package/dist/sdk/testserver/clock.js +10 -0
  404. package/dist/sdk/testserver/failure.d.ts +73 -0
  405. package/dist/sdk/testserver/failure.js +61 -0
  406. package/dist/sdk/testserver/index.d.ts +5 -0
  407. package/dist/sdk/testserver/index.js +8 -0
  408. package/dist/sdk/testserver/live/connect-failure.d.ts +7 -0
  409. package/dist/sdk/testserver/live/connect-failure.js +30 -0
  410. package/dist/sdk/testserver/live/request.d.ts +69 -0
  411. package/dist/sdk/testserver/live/request.js +89 -0
  412. package/dist/sdk/testserver/service-ids.d.ts +19 -0
  413. package/dist/sdk/testserver/service-ids.js +77 -0
  414. package/dist/sdk/testserver/test-id.d.ts +15 -0
  415. package/dist/sdk/testserver/test-id.js +28 -0
  416. package/dist/story/align.d.ts +37 -0
  417. package/dist/story/align.js +39 -0
  418. package/dist/story/artifact.d.ts +60 -0
  419. package/dist/story/artifact.js +93 -0
  420. package/dist/story/definition.d.ts +52 -0
  421. package/dist/story/definition.js +9 -0
  422. package/dist/story/diff.d.ts +9 -0
  423. package/dist/story/diff.js +97 -0
  424. package/dist/story/errors.d.ts +14 -0
  425. package/dist/story/errors.js +21 -0
  426. package/dist/story/gateways.d.ts +74 -0
  427. package/dist/story/gateways.js +3 -0
  428. package/dist/story/host.d.ts +27 -0
  429. package/dist/story/host.js +97 -0
  430. package/dist/story/index.d.ts +7 -0
  431. package/dist/story/index.js +9 -0
  432. package/dist/story/json.d.ts +16 -0
  433. package/dist/story/json.js +59 -0
  434. package/dist/story/live/artifact-gateway.d.ts +2 -0
  435. package/dist/story/live/artifact-gateway.js +82 -0
  436. package/dist/story/mode.d.ts +17 -0
  437. package/dist/story/mode.js +21 -0
  438. package/dist/story/orphans.d.ts +17 -0
  439. package/dist/story/orphans.js +15 -0
  440. package/dist/story/report.d.ts +30 -0
  441. package/dist/story/report.js +118 -0
  442. package/dist/story/run.d.ts +49 -0
  443. package/dist/story/run.js +160 -0
  444. package/dist/story/sequence.d.ts +30 -0
  445. package/dist/story/sequence.js +74 -0
  446. package/dist/story/settle.d.ts +94 -0
  447. package/dist/story/settle.js +70 -0
  448. package/dist/time/duration.d.ts +19 -0
  449. package/dist/time/duration.js +37 -0
  450. package/dist/time/index.d.ts +2 -0
  451. package/dist/time/index.js +4 -0
  452. package/dist/time/time.d.ts +15 -0
  453. package/dist/time/time.js +23 -0
  454. package/dist/vercel-cli/ansi.d.ts +13 -0
  455. package/dist/vercel-cli/ansi.js +32 -0
  456. package/dist/vercel-cli/arguments.d.ts +25 -0
  457. package/dist/vercel-cli/arguments.js +78 -0
  458. package/dist/vercel-cli/auth-config.d.ts +43 -0
  459. package/dist/vercel-cli/auth-config.js +36 -0
  460. package/dist/vercel-cli/clock.d.ts +9 -0
  461. package/dist/vercel-cli/clock.js +10 -0
  462. package/dist/vercel-cli/config-files.d.ts +24 -0
  463. package/dist/vercel-cli/config-files.js +40 -0
  464. package/dist/vercel-cli/context.d.ts +12 -0
  465. package/dist/vercel-cli/context.js +12 -0
  466. package/dist/vercel-cli/driver.d.ts +218 -0
  467. package/dist/vercel-cli/driver.js +364 -0
  468. package/dist/vercel-cli/entry.d.ts +8 -0
  469. package/dist/vercel-cli/entry.js +13 -0
  470. package/dist/vercel-cli/environment.d.ts +33 -0
  471. package/dist/vercel-cli/environment.js +72 -0
  472. package/dist/vercel-cli/errors.d.ts +8 -0
  473. package/dist/vercel-cli/errors.js +8 -0
  474. package/dist/vercel-cli/gateways.d.ts +103 -0
  475. package/dist/vercel-cli/gateways.js +4 -0
  476. package/dist/vercel-cli/index.d.ts +10 -0
  477. package/dist/vercel-cli/index.js +15 -0
  478. package/dist/vercel-cli/invocation.d.ts +234 -0
  479. package/dist/vercel-cli/invocation.js +397 -0
  480. package/dist/vercel-cli/keys.d.ts +14 -0
  481. package/dist/vercel-cli/keys.js +12 -0
  482. package/dist/vercel-cli/live/config-files.d.ts +28 -0
  483. package/dist/vercel-cli/live/config-files.js +66 -0
  484. package/dist/vercel-cli/live/process-gateway.d.ts +14 -0
  485. package/dist/vercel-cli/live/process-gateway.js +178 -0
  486. package/dist/vercel-cli/redaction.d.ts +13 -0
  487. package/dist/vercel-cli/redaction.js +22 -0
  488. package/dist/vercel-cli/report.d.ts +22 -0
  489. package/dist/vercel-cli/report.js +110 -0
  490. package/dist/vercel-cli/verbose.d.ts +7 -0
  491. package/dist/vercel-cli/verbose.js +24 -0
  492. package/dist/version.d.ts +20 -0
  493. package/dist/version.js +57 -0
  494. package/dist/vitest/config.d.ts +51 -0
  495. package/dist/vitest/config.js +61 -0
  496. package/dist/vitest/container-scope.d.ts +108 -0
  497. package/dist/vitest/container-scope.js +234 -0
  498. package/dist/vitest/diagnostics.d.ts +146 -0
  499. package/dist/vitest/diagnostics.js +306 -0
  500. package/dist/vitest/find-vitest.d.ts +7 -0
  501. package/dist/vitest/find-vitest.js +28 -0
  502. package/dist/vitest/fixtures.d.ts +64 -0
  503. package/dist/vitest/fixtures.js +172 -0
  504. package/dist/vitest/gateways.d.ts +78 -0
  505. package/dist/vitest/gateways.js +4 -0
  506. package/dist/vitest/index.d.ts +3 -0
  507. package/dist/vitest/index.js +9 -0
  508. package/dist/vitest/list-output.d.ts +3 -0
  509. package/dist/vitest/list-output.js +19 -0
  510. package/dist/vitest/live/list-gateway.d.ts +11 -0
  511. package/dist/vitest/live/list-gateway.js +107 -0
  512. package/dist/vitest/ownership.d.ts +29 -0
  513. package/dist/vitest/ownership.js +68 -0
  514. package/dist/vitest/plan.d.ts +66 -0
  515. package/dist/vitest/plan.js +104 -0
  516. package/dist/vitest/sandbox.d.ts +16 -0
  517. package/dist/vitest/sandbox.js +35 -0
  518. package/dist/vitest/test-events.d.ts +41 -0
  519. package/dist/vitest/test-events.js +92 -0
  520. package/dist/vitest/test-results.d.ts +84 -0
  521. package/dist/vitest/test-results.js +160 -0
  522. package/dist/vitest/types.d.ts +68 -0
  523. package/dist/vitest/types.js +4 -0
  524. package/package.json +119 -3
  525. package/skills/overview.md +33 -0
  526. package/skills/read-run-output.md +65 -0
  527. package/README.md +0 -3
@@ -0,0 +1,102 @@
1
+ /** How a test ended, as a test event reports it. */
2
+ export type TestEventState = "pass" | "fail" | "skip";
3
+ /**
4
+ * What a vitest worker reports as it runs a test file. Every one names the test file (`file`, its path relative to
5
+ * the project), the worker that ran it (`worker`, a vitest worker's `VITEST_POOL_ID`, from 1) and when it happened by
6
+ * the worker's clock (`at`, milliseconds since the epoch).
7
+ *
8
+ * - `file-started` and `file-finished`: the worker started and finished the file.
9
+ * - `test-started`: the worker started an attempt at test `test`, one of the file's `fileTests` tests.
10
+ * - `test-attempt-finished`: that attempt ended `state` after `ms`, its container's start among it. A retried test
11
+ * reports one for each attempt, so these are not the test's final result.
12
+ * - `container-starting` and `container-started`: the worker started a container for the file's tests, or for one
13
+ * test, which took `ms` and succeeded or not (`ok`). When the worker then warmed the new container's services,
14
+ * `container-started` comes once the warmup has ended, with `warmupMs`, how long it took, and `warmupFailed`, how
15
+ * many services failed to start; both are absent when nothing was warmed.
16
+ */
17
+ export type WorkerTestEvent = {
18
+ readonly kind: "file-started";
19
+ readonly file: string;
20
+ readonly worker: number;
21
+ readonly at: number;
22
+ } | {
23
+ readonly kind: "file-finished";
24
+ readonly file: string;
25
+ readonly worker: number;
26
+ readonly at: number;
27
+ } | {
28
+ readonly kind: "test-started";
29
+ readonly file: string;
30
+ readonly worker: number;
31
+ readonly at: number;
32
+ readonly test: string;
33
+ readonly fileTests: number;
34
+ } | {
35
+ readonly kind: "test-attempt-finished";
36
+ readonly file: string;
37
+ readonly worker: number;
38
+ readonly at: number;
39
+ readonly test: string;
40
+ readonly state: TestEventState;
41
+ readonly ms: number;
42
+ } | {
43
+ readonly kind: "container-starting";
44
+ readonly file: string;
45
+ readonly worker: number;
46
+ readonly at: number;
47
+ } | {
48
+ readonly kind: "container-started";
49
+ readonly file: string;
50
+ readonly worker: number;
51
+ readonly at: number;
52
+ readonly ms: number;
53
+ readonly ok: boolean;
54
+ readonly warmupMs?: number;
55
+ readonly warmupFailed?: number;
56
+ };
57
+ /** One error a test's final result carries: its name, message, and, when the test runner gave them, stack and diff. */
58
+ export interface TestResultError {
59
+ readonly name: string;
60
+ readonly message: string;
61
+ readonly stack?: string;
62
+ readonly diff?: string;
63
+ }
64
+ /**
65
+ * A test's test output: its console output, stdout and stderr in arrival order, the last characters of it, starting at
66
+ * a line's start unless one line alone is longer than what is kept, and how many earlier characters were dropped to
67
+ * keep it that size.
68
+ */
69
+ export interface TestResultOutput {
70
+ readonly text: string;
71
+ readonly droppedChars: number;
72
+ }
73
+ /**
74
+ * A test's final result, which vitest's main process reports once per test, retries settled: `id`, vitest's id for
75
+ * the test, unique within the run; `file`, the test file's path relative to the project; `test`, its full name, for
76
+ * display only; `state`, how it ended; `retryCount`, how many times it was retried; `flaky`, whether it passed on a
77
+ * retry; `at`, when it was reported by the main process's clock; `errors`, when the test runner gave any, a failed
78
+ * test's errors or a flaky pass's retries'; and `output`, its test output, when it printed any. It names no worker:
79
+ * the main process can't see which one ran the test.
80
+ */
81
+ export interface TestResultEvent {
82
+ readonly kind: "test-result";
83
+ readonly id: string;
84
+ readonly file: string;
85
+ readonly test: string;
86
+ readonly state: TestEventState;
87
+ readonly retryCount: number;
88
+ readonly flaky: boolean;
89
+ readonly at: number;
90
+ readonly errors?: readonly TestResultError[];
91
+ readonly output?: TestResultOutput;
92
+ }
93
+ /**
94
+ * What a command's test runner reports as it goes, one JSON object a line, appended to the run payload's
95
+ * `testEvents` file: a worker's progress through a file (`WorkerTestEvent`), or a test's final result
96
+ * (`TestResultEvent`).
97
+ */
98
+ export type TestEvent = WorkerTestEvent | TestResultEvent;
99
+ /** The line a test event is appended as: its JSON, without a newline. */
100
+ export declare function testEventLine(event: TestEvent): string;
101
+ /** The test event on `line`, or undefined when it holds none: not JSON, or not an event this SDK knows. */
102
+ export declare function parseTestEvent(line: string): TestEvent | undefined;
@@ -0,0 +1,59 @@
1
+ import { z } from "zod";
2
+ const where = { file: z.string(), worker: z.number().int().positive(), at: z.number() };
3
+ const state = z.enum(["pass", "fail", "skip"]);
4
+ const testEventSchema = z.discriminatedUnion("kind", [
5
+ z.object({ kind: z.literal("file-started"), ...where }),
6
+ z.object({ kind: z.literal("file-finished"), ...where }),
7
+ z.object({ kind: z.literal("test-started"), ...where, test: z.string(), fileTests: z.number().int().nonnegative() }),
8
+ z.object({
9
+ kind: z.literal("test-attempt-finished"),
10
+ ...where,
11
+ test: z.string(),
12
+ state,
13
+ ms: z.number().nonnegative(),
14
+ }),
15
+ z.object({ kind: z.literal("container-starting"), ...where }),
16
+ z.object({
17
+ kind: z.literal("container-started"),
18
+ ...where,
19
+ ms: z.number().nonnegative(),
20
+ ok: z.boolean(),
21
+ warmupMs: z.number().nonnegative().exactOptional(),
22
+ warmupFailed: z.number().int().nonnegative().exactOptional(),
23
+ }),
24
+ z.object({
25
+ kind: z.literal("test-result"),
26
+ id: z.string().min(1),
27
+ file: z.string(),
28
+ test: z.string(),
29
+ state,
30
+ retryCount: z.number().int().nonnegative(),
31
+ flaky: z.boolean(),
32
+ at: z.number(),
33
+ errors: z
34
+ .array(z.object({
35
+ name: z.string(),
36
+ message: z.string(),
37
+ stack: z.string().exactOptional(),
38
+ diff: z.string().exactOptional(),
39
+ }))
40
+ .exactOptional(),
41
+ output: z.object({ text: z.string(), droppedChars: z.number().int().nonnegative() }).exactOptional(),
42
+ }),
43
+ ]);
44
+ /** The line a test event is appended as: its JSON, without a newline. */
45
+ export function testEventLine(event) {
46
+ return JSON.stringify(event);
47
+ }
48
+ /** The test event on `line`, or undefined when it holds none: not JSON, or not an event this SDK knows. */
49
+ export function parseTestEvent(line) {
50
+ let json;
51
+ try {
52
+ json = JSON.parse(line);
53
+ }
54
+ catch {
55
+ return undefined;
56
+ }
57
+ const parsed = testEventSchema.safeParse(json);
58
+ return parsed.success ? parsed.data : undefined;
59
+ }
@@ -0,0 +1,58 @@
1
+ import type { ClientRequest, IncomingHttpHeaders, IncomingMessage, ServerResponse } from "node:http";
2
+ import { BodyCapture, type RecordedBody, type RequestOutcome } from "../records/index.ts";
3
+ import type { FaultRule, FaultUpstream } from "./faults.ts";
4
+ import { type ProxyRequestRecord } from "./records.ts";
5
+ /** Testserver's status and headers once they arrive, and its body so far. */
6
+ export interface UpstreamAnswer {
7
+ readonly status: number;
8
+ readonly headers: IncomingHttpHeaders;
9
+ readonly body: BodyCapture;
10
+ }
11
+ /** What an exchange needs of its proxy. */
12
+ export interface ExchangeDeps {
13
+ /** The proxy clock's reading. */
14
+ now(): number;
15
+ /** Sends `request` on to Testserver with the test id added, its body still to be written. */
16
+ send(request: IncomingMessage, onAnswer: (answer: IncomingMessage) => void): ClientRequest;
17
+ /** Hears each record as its exchange ends; what it throws is dropped. */
18
+ readonly onRequest?: ((record: ProxyRequestRecord) => void) | undefined;
19
+ }
20
+ /**
21
+ * One request the proxy received and the response it sends: its record, open until the exchange ends and set once
22
+ * when it does, the first way it ends winning. A pass-through (`passThrough`) or a fault rule (`applyFault` in
23
+ * `faulted-exchange.ts`) drives it. A client that closes its connection before the response finished writing ends it
24
+ * at once, and so does the proxy's close (`finalize`); either destroys the request sent on to Testserver.
25
+ */
26
+ export declare class Exchange {
27
+ #private;
28
+ readonly request: IncomingMessage;
29
+ readonly response: ServerResponse;
30
+ readonly method: string;
31
+ /** The request's bearer token, which its record's bodies redact. */
32
+ readonly bearer: string | undefined;
33
+ constructor(request: IncomingMessage, response: ServerResponse, deps: ExchangeDeps, faultAction: FaultRule["action"] | undefined);
34
+ /** Whether its record has ended. */
35
+ get ended(): boolean;
36
+ /** Its record: the ended one once it ended, otherwise an open record as of now. */
37
+ read(): ProxyRequestRecord;
38
+ /** Records it as ended by the proxy's close; does nothing once it has ended. */
39
+ finalize(): void;
40
+ /**
41
+ * Ends its record with `outcome`, what the client got, and under a forwarding fault `upstream`, what Testserver
42
+ * answered, then tells `onRequest`. Does nothing once it has ended.
43
+ */
44
+ record(outcome: RequestOutcome, responseBody?: RecordedBody, upstream?: FaultUpstream): void;
45
+ /** Sends the request on to Testserver, its body still to be written; a hangup or close destroys it. */
46
+ forward(onAnswer: (answer: IncomingMessage) => void): ClientRequest;
47
+ /** Records that the client is being sent Testserver's answer, so a hangup or close records how far it got. */
48
+ answering(answer: UpstreamAnswer): void;
49
+ /** Records a Testserver that couldn't be reached, with `upstream` under a forwarding fault, and answers with a 502. */
50
+ unreachable(error: Error, upstream?: FaultUpstream): void;
51
+ /** Runs `step` after `delayMs`, at once for 0; the exchange's end cancels a pending one. */
52
+ after(delayMs: number, step: () => void): void;
53
+ }
54
+ /**
55
+ * Forwards the request with no fault rule: Testserver's status and headers go to the client as they arrive, and both
56
+ * bodies stream through undecoded while the exchange keeps a copy of each for its record.
57
+ */
58
+ export declare function passThrough(exchange: Exchange): void;
@@ -0,0 +1,173 @@
1
+ import { bearerToken, BodyCapture } from "../records/index.js";
2
+ import { forwardableHeaders, proxyRecord } from "./records.js";
3
+ /** The error of an exchange that was still open when its proxy closed. */
4
+ const CLOSED_ERROR = "the proxy closed";
5
+ /** The error of an exchange whose client closed its connection before the response ended. */
6
+ const HANGUP_ERROR = "the client closed the connection";
7
+ /**
8
+ * One request the proxy received and the response it sends: its record, open until the exchange ends and set once
9
+ * when it does, the first way it ends winning. A pass-through (`passThrough`) or a fault rule (`applyFault` in
10
+ * `faulted-exchange.ts`) drives it. A client that closes its connection before the response finished writing ends it
11
+ * at once, and so does the proxy's close (`finalize`); either destroys the request sent on to Testserver.
12
+ */
13
+ export class Exchange {
14
+ request;
15
+ response;
16
+ method;
17
+ /** The request's bearer token, which its record's bodies redact. */
18
+ bearer;
19
+ #target;
20
+ #startedAt;
21
+ #deps;
22
+ /** The action of the fault rule the request matched, if any, which its record names. */
23
+ #faultAction;
24
+ #requestBody = new BodyCapture();
25
+ #requestEnded = false;
26
+ /** The request body's record once it has arrived whole, decoded once. */
27
+ #wholeRequestBody;
28
+ /** Its record, set once when the exchange ends. */
29
+ #ended;
30
+ /** Set once the client is being sent Testserver's answer, so a hangup or close records its status and body so far. */
31
+ #answered;
32
+ /** The request sent on to Testserver, once sent. */
33
+ #outgoing;
34
+ /** A fault rule's delay, cleared however the exchange ends. */
35
+ #delay;
36
+ constructor(request, response, deps, faultAction) {
37
+ this.request = request;
38
+ this.response = response;
39
+ this.method = request.method ?? "GET";
40
+ this.#target = request.url ?? "/";
41
+ const authorization = request.headers.authorization;
42
+ this.bearer = bearerToken(typeof authorization === "string" ? authorization : undefined);
43
+ this.#startedAt = deps.now();
44
+ this.#deps = deps;
45
+ this.#faultAction = faultAction;
46
+ request.on("data", (chunk) => this.#requestBody.push(chunk));
47
+ request.on("end", () => {
48
+ this.#requestEnded = true;
49
+ });
50
+ // `close` also follows a response that finished writing; only one that hadn't means the client hung up. An
51
+ // exchange that already ended, such as one whose answer ended before the hangup, keeps its record.
52
+ response.on("close", () => {
53
+ if (response.writableFinished || this.ended)
54
+ return;
55
+ this.#breakOff(HANGUP_ERROR);
56
+ this.#outgoing?.destroy();
57
+ });
58
+ }
59
+ /** Whether its record has ended. */
60
+ get ended() {
61
+ return this.#ended !== undefined;
62
+ }
63
+ /** Its record: the ended one once it ended, otherwise an open record as of now. */
64
+ read() {
65
+ return this.#ended ?? this.#build({ open: true });
66
+ }
67
+ /** Records it as ended by the proxy's close; does nothing once it has ended. */
68
+ finalize() {
69
+ this.#breakOff(CLOSED_ERROR);
70
+ }
71
+ /**
72
+ * Ends its record with `outcome`, what the client got, and under a forwarding fault `upstream`, what Testserver
73
+ * answered, then tells `onRequest`. Does nothing once it has ended.
74
+ */
75
+ record(outcome, responseBody, upstream) {
76
+ if (this.#ended !== undefined)
77
+ return;
78
+ clearTimeout(this.#delay);
79
+ const entry = this.#build(outcome, responseBody, upstream);
80
+ this.#ended = entry;
81
+ try {
82
+ this.#deps.onRequest?.(entry);
83
+ }
84
+ catch {
85
+ // A listener's failure is its own.
86
+ }
87
+ }
88
+ /** Sends the request on to Testserver, its body still to be written; a hangup or close destroys it. */
89
+ forward(onAnswer) {
90
+ this.#outgoing = this.#deps.send(this.request, onAnswer);
91
+ return this.#outgoing;
92
+ }
93
+ /** Records that the client is being sent Testserver's answer, so a hangup or close records how far it got. */
94
+ answering(answer) {
95
+ this.#answered = answer;
96
+ }
97
+ /** Records a Testserver that couldn't be reached, with `upstream` under a forwarding fault, and answers with a 502. */
98
+ unreachable(error, upstream) {
99
+ this.record({ error: error.message }, undefined, upstream);
100
+ this.response.writeHead(502, { "content-type": "text/plain" });
101
+ this.response.end(`storm proxy: Testserver could not be reached: ${error.message}`);
102
+ }
103
+ /** Runs `step` after `delayMs`, at once for 0; the exchange's end cancels a pending one. */
104
+ after(delayMs, step) {
105
+ if (delayMs === 0)
106
+ step();
107
+ else
108
+ this.#delay = setTimeout(step, delayMs);
109
+ }
110
+ /** Records it as ended by `error` partway: with Testserver's status and the body so far if its answer began. */
111
+ #breakOff(error) {
112
+ if (this.#answered === undefined) {
113
+ this.record({ error });
114
+ return;
115
+ }
116
+ this.record({ status: this.#answered.status, error }, this.#answered.body.incomplete(this.#answered.headers));
117
+ }
118
+ #build(outcome, responseBody, upstream) {
119
+ return proxyRecord({
120
+ method: this.method,
121
+ target: this.#target,
122
+ headers: this.request.headers,
123
+ startedAt: this.#startedAt,
124
+ durationMs: this.#deps.now() - this.#startedAt,
125
+ outcome,
126
+ requestBody: this.#recordedRequestBody(),
127
+ responseBody,
128
+ fault: this.#faultAction === undefined
129
+ ? undefined
130
+ : { action: this.#faultAction, ...(upstream === undefined ? {} : { upstream }) },
131
+ });
132
+ }
133
+ #recordedRequestBody() {
134
+ if (!this.#requestEnded)
135
+ return this.#requestBody.incomplete(this.request.headers);
136
+ this.#wholeRequestBody ??= { body: this.#requestBody.complete(this.request.headers, this.bearer) };
137
+ return this.#wholeRequestBody.body;
138
+ }
139
+ }
140
+ /**
141
+ * Forwards the request with no fault rule: Testserver's status and headers go to the client as they arrive, and both
142
+ * bodies stream through undecoded while the exchange keeps a copy of each for its record.
143
+ */
144
+ export function passThrough(exchange) {
145
+ const { request, response } = exchange;
146
+ const outgoing = exchange.forward((answer) => {
147
+ const status = answer.statusCode ?? 502;
148
+ response.writeHead(status, forwardableHeaders(answer.headers));
149
+ const responseBody = new BodyCapture();
150
+ exchange.answering({ status, headers: answer.headers, body: responseBody });
151
+ answer.on("data", (chunk) => responseBody.push(chunk));
152
+ // Registered before `pipe`, whose own `end` listener ends the client's response: the record is in
153
+ // `requests` before the client sees its answer end.
154
+ answer.on("end", () => exchange.record({ status }, responseBody.complete(answer.headers, exchange.bearer)));
155
+ answer.on("error", (error) => {
156
+ exchange.record({ status, error: error.message }, responseBody.incomplete(answer.headers));
157
+ response.destroy();
158
+ });
159
+ answer.pipe(response);
160
+ });
161
+ outgoing.on("error", (error) => {
162
+ // The client hung up and the exchange ended with it; `outgoing` errs only because it was destroyed.
163
+ if (response.destroyed && exchange.ended)
164
+ return;
165
+ if (response.headersSent) {
166
+ exchange.record({ status: response.statusCode, error: error.message });
167
+ response.destroy();
168
+ return;
169
+ }
170
+ exchange.unreachable(error);
171
+ });
172
+ request.pipe(outgoing);
173
+ }
@@ -0,0 +1,10 @@
1
+ import type { Exchange } from "./exchange.ts";
2
+ import type { CheckedRule } from "./faults.ts";
3
+ /**
4
+ * Drives `exchange` under the fault rule its request matched. The request body arrives whole before the delay and the
5
+ * action, so every faulted record holds it. A forwarding fault (`replace`, an `after-answer` reset) holds the body,
6
+ * sends it on after the delay, reads Testserver's whole answer, sends the client none of it, then acts; `respond` and
7
+ * a `before-forward` reset act after the delay without forwarding. The held body lives only until the request ends,
8
+ * when the delayed step takes it, or closes first, such as on a hangup or the proxy's close.
9
+ */
10
+ export declare function applyFault(exchange: Exchange, rule: CheckedRule): void;
@@ -0,0 +1,106 @@
1
+ import { BodyCapture } from "../records/index.js";
2
+ /** The error of an exchange a `reset` fault rule ended before the proxy forwarded its request. */
3
+ const RESET_BEFORE_ERROR = "the proxy injected a reset before forwarding";
4
+ /** The error of an exchange a `reset` fault rule ended after Testserver answered: a lost response. */
5
+ const RESET_AFTER_ERROR = "the proxy injected a reset after Testserver answered";
6
+ /**
7
+ * Drives `exchange` under the fault rule its request matched. The request body arrives whole before the delay and the
8
+ * action, so every faulted record holds it. A forwarding fault (`replace`, an `after-answer` reset) holds the body,
9
+ * sends it on after the delay, reads Testserver's whole answer, sends the client none of it, then acts; `respond` and
10
+ * a `before-forward` reset act after the delay without forwarding. The held body lives only until the request ends,
11
+ * when the delayed step takes it, or closes first, such as on a hangup or the proxy's close.
12
+ */
13
+ export function applyFault(exchange, rule) {
14
+ const { request } = exchange;
15
+ const forwarding = rule.action === "replace" || (rule.action === "reset" && rule.when === "after-answer");
16
+ /** The request body as sent, held whole for a forwarding fault. */
17
+ let held = [];
18
+ const hold = (chunk) => {
19
+ held.push(chunk);
20
+ };
21
+ /** Stops holding the body and hands over what arrived; a request holds no body once it has ended or closed. */
22
+ const release = () => {
23
+ request.off("data", hold);
24
+ const body = Buffer.concat(held);
25
+ held = [];
26
+ return body;
27
+ };
28
+ if (forwarding) {
29
+ request.on("data", hold);
30
+ request.once("close", release);
31
+ }
32
+ request.once("end", () => {
33
+ const body = forwarding ? release() : undefined;
34
+ if (exchange.ended)
35
+ return;
36
+ exchange.after(rule.delayMs, () => {
37
+ if (body === undefined)
38
+ act(exchange, rule);
39
+ else
40
+ forwardThenAct(exchange, rule, body);
41
+ });
42
+ });
43
+ }
44
+ /**
45
+ * Ends the record, with `upstream` under a forwarding fault, then sends the client the fake response or resets its
46
+ * connection.
47
+ */
48
+ function act(exchange, rule, upstream) {
49
+ if (rule.action === "reset") {
50
+ const error = rule.when === "before-forward" ? RESET_BEFORE_ERROR : RESET_AFTER_ERROR;
51
+ exchange.record({ error }, undefined, upstream);
52
+ exchange.request.socket.resetAndDestroy();
53
+ return;
54
+ }
55
+ // HTTP sends no body in a response to HEAD, so neither does the proxy or its record.
56
+ const body = exchange.method === "HEAD" ? Buffer.alloc(0) : rule.response.body;
57
+ const fake = new BodyCapture();
58
+ fake.push(body);
59
+ exchange.record({ status: rule.response.status }, fake.complete(rule.response.headers, exchange.bearer), upstream);
60
+ exchange.response.writeHead(rule.response.status, rule.response.headers);
61
+ exchange.response.end(body);
62
+ }
63
+ /**
64
+ * Forwards the held request body, reads Testserver's whole answer, then acts. When Testserver fails, with no answer
65
+ * or one that stops before its end, the proxy doesn't fake over it: the client gets a 502 or a destroyed connection,
66
+ * and only `fault.upstream` holds Testserver's status and body.
67
+ */
68
+ function forwardThenAct(exchange, rule, body) {
69
+ let answer;
70
+ const brokenOff = (error) => {
71
+ if (exchange.ended || answer === undefined)
72
+ return;
73
+ const responseBody = answer.body.incomplete(answer.headers);
74
+ exchange.record({ error: error.message }, undefined, {
75
+ status: answer.status,
76
+ error: error.message,
77
+ ...(responseBody === undefined ? {} : { responseBody }),
78
+ });
79
+ exchange.response.destroy();
80
+ };
81
+ const outgoing = exchange.forward((incoming) => {
82
+ const status = incoming.statusCode ?? 502;
83
+ const captured = new BodyCapture();
84
+ answer = { status, headers: incoming.headers, body: captured };
85
+ incoming.on("data", (chunk) => captured.push(chunk));
86
+ incoming.on("end", () => {
87
+ if (exchange.ended)
88
+ return;
89
+ const responseBody = captured.complete(incoming.headers, exchange.bearer);
90
+ act(exchange, rule, { status, ...(responseBody === undefined ? {} : { responseBody }) });
91
+ });
92
+ incoming.on("error", brokenOff);
93
+ });
94
+ outgoing.on("error", (error) => {
95
+ // The client hung up or the proxy closed, and the exchange ended with it; `outgoing` errs only because it was
96
+ // destroyed.
97
+ if (exchange.ended)
98
+ return;
99
+ if (answer !== undefined) {
100
+ brokenOff(error);
101
+ return;
102
+ }
103
+ exchange.unreachable(error, { error: error.message });
104
+ });
105
+ outgoing.end(body);
106
+ }
@@ -0,0 +1,133 @@
1
+ import type { RecordedBody, RequestOutcome } from "../records/index.ts";
2
+ /**
3
+ * The response a `respond` or `replace` fault rule sends the client in place of Testserver's. The proxy adds no
4
+ * error format of its own, so a fake error body must match the real service's error format.
5
+ */
6
+ export interface FaultResponse {
7
+ /** A final response status, an integer from 200 to 599. */
8
+ readonly status: number;
9
+ /**
10
+ * The response's only headers: Testserver's are never merged in. The proxy adds `content-type` when there is a
11
+ * body and these don't set it, and sets `content-length` itself except for 204 and 304, so these can't set it or
12
+ * `transfer-encoding`.
13
+ */
14
+ readonly headers?: Readonly<Record<string, string>>;
15
+ /**
16
+ * The body. A string goes out as `text/plain; charset=utf-8`; any other value goes out as `JSON.stringify(value)`,
17
+ * `application/json; charset=utf-8`. A `content-type` in `headers` overrides either; to send a JSON string, set
18
+ * `content-type` and pass `JSON.stringify(...)`. Absent, the body is empty. A 204, 205 or 304 response can't have
19
+ * one. The proxy sends no body in its response to a `HEAD` request.
20
+ */
21
+ readonly body?: unknown;
22
+ }
23
+ /**
24
+ * A fault rule: a rule a test sets on a running proxy with `proxy.fault(rule)`, which changes what the client gets
25
+ * for each matching request. A request matches when its method equals `method`, without regard to case, and its
26
+ * record's `path` (no query, no Testserver prefix) matches the path template `path` one segment at a time: a
27
+ * `:name` segment matches one non-empty segment, every other segment must be equal, raw, and the segment counts must
28
+ * be equal, so `/a/` doesn't match `/a`. The actions:
29
+ *
30
+ * - `respond`: the client gets `response`; the proxy never forwards the request.
31
+ * - `replace`: the proxy forwards the request and reads Testserver's whole answer, and the client gets `response`
32
+ * in its place.
33
+ * - `reset`, `when: "before-forward"`: the proxy resets the connection without forwarding.
34
+ * - `reset`, `when: "after-answer"`: the proxy forwards the request, reads Testserver's whole answer, then resets
35
+ * the connection: a lost response.
36
+ */
37
+ export type FaultRule = {
38
+ /** The request method, compared without regard to case. */
39
+ readonly method: string;
40
+ /** A path template, such as `/v1/registrar/orders/:id`: it starts with `/` and holds no `?` or `#`. */
41
+ readonly path: string;
42
+ /** How many matching requests the rule applies to, a positive integer; default 1. */
43
+ readonly times?: number;
44
+ /**
45
+ * Milliseconds to wait, a finite number, 0 or more, once the request body has arrived: before forwarding for
46
+ * `replace` and `after-answer`, before acting for `respond` and `before-forward`.
47
+ */
48
+ readonly delayMs?: number;
49
+ } & ({
50
+ readonly action: "respond";
51
+ readonly response: FaultResponse;
52
+ } | {
53
+ readonly action: "replace";
54
+ readonly response: FaultResponse;
55
+ } | {
56
+ readonly action: "reset";
57
+ readonly when: "before-forward" | "after-answer";
58
+ });
59
+ /**
60
+ * What `proxy.fault(rule)` returns: the rule as it was given, how many requests it has applied to, and how many it
61
+ * still will.
62
+ */
63
+ export interface FaultHandle {
64
+ readonly rule: FaultRule;
65
+ readonly hits: number;
66
+ readonly remaining: number;
67
+ }
68
+ /**
69
+ * The fault rule a proxy record's request matched. Set on the record as soon as the request matched, open records
70
+ * included.
71
+ */
72
+ export interface ProxyFault {
73
+ readonly action: FaultRule["action"];
74
+ /**
75
+ * What Testserver answered, under `replace` and an `after-answer` reset. Absent when the proxy didn't forward,
76
+ * and when the proxy itself cut the exchange off (the client hung up, or the proxy closed) before Testserver's
77
+ * answer ended. An `error` here means Testserver failed: no answer, or one that stopped before its end.
78
+ */
79
+ readonly upstream?: FaultUpstream;
80
+ }
81
+ /** Testserver's answer under a forwarding fault: `RequestOutcome`'s shape, plus the body, recorded as usual. */
82
+ export type FaultUpstream = RequestOutcome & {
83
+ readonly responseBody?: RecordedBody;
84
+ };
85
+ /** A rule checked by `checkRule`, its method upper-cased, its template split and its response serialized once. */
86
+ export type CheckedRule = {
87
+ readonly method: string;
88
+ readonly path: string;
89
+ readonly times: number;
90
+ readonly delayMs: number;
91
+ } & ({
92
+ readonly action: "respond" | "replace";
93
+ readonly response: PreparedResponse;
94
+ } | {
95
+ readonly action: "reset";
96
+ readonly when: "before-forward" | "after-answer";
97
+ });
98
+ /** A fake response ready to send: its status, its headers with names lower-cased, and its body's bytes. */
99
+ export interface PreparedResponse {
100
+ readonly status: number;
101
+ /**
102
+ * The rule's headers, `content-type` added when the body is set and they lack one, and `content-length` except for
103
+ * 204 and 304.
104
+ */
105
+ readonly headers: Readonly<Record<string, string>>;
106
+ readonly body: Buffer;
107
+ }
108
+ /** `rule` checked and prepared; throws a `TypeError` naming what is wrong with it. */
109
+ export declare function checkRule(rule: FaultRule): CheckedRule;
110
+ /** A fault response's body as bytes with its default `content-type`, or `undefined` for none. */
111
+ export declare function serializeBody(body: unknown): {
112
+ readonly bytes: Buffer;
113
+ readonly contentType: string;
114
+ } | undefined;
115
+ /**
116
+ * Whether `path`, a record's `path`, matches the path template `template`: the same number of `/`-separated
117
+ * segments, each `:name` segment (more than one character) matching one non-empty segment and every other equal,
118
+ * raw. As vercel-internal's `matchPathTemplate`, without reading the parameters.
119
+ */
120
+ export declare function matchesTemplate(template: string, path: string): boolean;
121
+ /**
122
+ * A proxy's fault rules, in the order they were added. `take` finds the first rule that matches a request and has
123
+ * hits left, and uses one of its hits.
124
+ */
125
+ export declare class FaultRules {
126
+ #private;
127
+ /** The handle of every rule, in the order they were added. */
128
+ get handles(): readonly FaultHandle[];
129
+ /** Checks `rule` and adds it after the others; throws a `TypeError` for a bad rule. */
130
+ add(rule: FaultRule): FaultHandle;
131
+ /** The first rule with hits left that matches `method` and `path`, after using one of its hits, or `undefined`. */
132
+ take(method: string, path: string): CheckedRule | undefined;
133
+ }