@cnc-tools/storm 0.0.0-stage → 0.5.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 (513) 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/run/cleanup.d.ts +135 -0
  15. package/dist/commands/run/cleanup.js +171 -0
  16. package/dist/commands/run/command.d.ts +327 -0
  17. package/dist/commands/run/command.js +620 -0
  18. package/dist/commands/run/job-summary.d.ts +6 -0
  19. package/dist/commands/run/job-summary.js +31 -0
  20. package/dist/commands/run/live-view.d.ts +22 -0
  21. package/dist/commands/run/live-view.js +395 -0
  22. package/dist/commands/run/metadata.d.ts +47 -0
  23. package/dist/commands/run/metadata.js +83 -0
  24. package/dist/commands/run/mint-failed.d.ts +11 -0
  25. package/dist/commands/run/mint-failed.js +33 -0
  26. package/dist/commands/run/outcomes.d.ts +307 -0
  27. package/dist/commands/run/outcomes.js +332 -0
  28. package/dist/commands/run/progress.d.ts +44 -0
  29. package/dist/commands/run/progress.js +277 -0
  30. package/dist/commands/run/redaction.d.ts +15 -0
  31. package/dist/commands/run/redaction.js +40 -0
  32. package/dist/commands/run/run-collector.d.ts +30 -0
  33. package/dist/commands/run/run-collector.js +73 -0
  34. package/dist/commands/run/run-record.d.ts +144 -0
  35. package/dist/commands/run/run-record.js +96 -0
  36. package/dist/commands/run/tests-summary.d.ts +34 -0
  37. package/dist/commands/run/tests-summary.js +141 -0
  38. package/dist/commands/run/text.d.ts +22 -0
  39. package/dist/commands/run/text.js +74 -0
  40. package/dist/commands/run/view.d.ts +35 -0
  41. package/dist/commands/run/view.js +163 -0
  42. package/dist/commands/run/waterfall.d.ts +25 -0
  43. package/dist/commands/run/waterfall.js +108 -0
  44. package/dist/commands/run/worker-chart.d.ts +79 -0
  45. package/dist/commands/run/worker-chart.js +313 -0
  46. package/dist/commands/runs/facts.d.ts +150 -0
  47. package/dist/commands/runs/facts.js +292 -0
  48. package/dist/commands/runs/list/command.d.ts +86 -0
  49. package/dist/commands/runs/list/command.js +36 -0
  50. package/dist/commands/runs/list/metadata.d.ts +22 -0
  51. package/dist/commands/runs/list/metadata.js +19 -0
  52. package/dist/commands/runs/list/outcomes.d.ts +74 -0
  53. package/dist/commands/runs/list/outcomes.js +89 -0
  54. package/dist/commands/runs/logs/command.d.ts +72 -0
  55. package/dist/commands/runs/logs/command.js +51 -0
  56. package/dist/commands/runs/logs/metadata.d.ts +22 -0
  57. package/dist/commands/runs/logs/metadata.js +22 -0
  58. package/dist/commands/runs/logs/outcomes.d.ts +55 -0
  59. package/dist/commands/runs/logs/outcomes.js +77 -0
  60. package/dist/commands/runs/metadata.d.ts +3 -0
  61. package/dist/commands/runs/metadata.js +3 -0
  62. package/dist/commands/runs/past-run.d.ts +72 -0
  63. package/dist/commands/runs/past-run.js +99 -0
  64. package/dist/commands/runs/show/command.d.ts +176 -0
  65. package/dist/commands/runs/show/command.js +76 -0
  66. package/dist/commands/runs/show/metadata.d.ts +25 -0
  67. package/dist/commands/runs/show/metadata.js +22 -0
  68. package/dist/commands/runs/show/outcomes.d.ts +164 -0
  69. package/dist/commands/runs/show/outcomes.js +317 -0
  70. package/dist/config/by-name.d.ts +24 -0
  71. package/dist/config/by-name.js +26 -0
  72. package/dist/config/errors.d.ts +58 -0
  73. package/dist/config/errors.js +101 -0
  74. package/dist/config/gateways.d.ts +32 -0
  75. package/dist/config/gateways.js +1 -0
  76. package/dist/config/index.d.ts +9 -0
  77. package/dist/config/index.js +12 -0
  78. package/dist/config/live/config-gateway.d.ts +6 -0
  79. package/dist/config/live/config-gateway.js +71 -0
  80. package/dist/config/load.d.ts +54 -0
  81. package/dist/config/load.js +175 -0
  82. package/dist/config/resolve.d.ts +49 -0
  83. package/dist/config/resolve.js +94 -0
  84. package/dist/config/resource-config.d.ts +132 -0
  85. package/dist/config/resource-config.js +19 -0
  86. package/dist/config/schema.d.ts +64 -0
  87. package/dist/config/schema.js +57 -0
  88. package/dist/config/set.d.ts +16 -0
  89. package/dist/config/set.js +55 -0
  90. package/dist/config/settings-file.d.ts +41 -0
  91. package/dist/config/settings-file.js +72 -0
  92. package/dist/config-file/define.d.ts +37 -0
  93. package/dist/config-file/define.js +9 -0
  94. package/dist/config-file/toolchain.d.ts +9 -0
  95. package/dist/config-file/toolchain.js +41 -0
  96. package/dist/context.d.ts +86 -0
  97. package/dist/context.js +43 -0
  98. package/dist/core/command-provider.d.ts +126 -0
  99. package/dist/core/command-provider.js +13 -0
  100. package/dist/core/command-slots.d.ts +67 -0
  101. package/dist/core/command-slots.js +136 -0
  102. package/dist/core/events.d.ts +128 -0
  103. package/dist/core/events.js +15 -0
  104. package/dist/core/gateways.d.ts +249 -0
  105. package/dist/core/gateways.js +1 -0
  106. package/dist/core/index.d.ts +20 -0
  107. package/dist/core/index.js +18 -0
  108. package/dist/core/keyed.d.ts +12 -0
  109. package/dist/core/keyed.js +24 -0
  110. package/dist/core/lane.d.ts +46 -0
  111. package/dist/core/lane.js +5 -0
  112. package/dist/core/limit.d.ts +9 -0
  113. package/dist/core/limit.js +29 -0
  114. package/dist/core/live/command-gateway.d.ts +11 -0
  115. package/dist/core/live/command-gateway.js +83 -0
  116. package/dist/core/live/job-summary-gateway.d.ts +5 -0
  117. package/dist/core/live/job-summary-gateway.js +20 -0
  118. package/dist/core/live/progress-terminal.d.ts +20 -0
  119. package/dist/core/live/progress-terminal.js +173 -0
  120. package/dist/core/live/run-directory-gateway.d.ts +24 -0
  121. package/dist/core/live/run-directory-gateway.js +437 -0
  122. package/dist/core/mint.d.ts +10 -0
  123. package/dist/core/mint.js +14 -0
  124. package/dist/core/payload.d.ts +26 -0
  125. package/dist/core/payload.js +33 -0
  126. package/dist/core/presentation.d.ts +87 -0
  127. package/dist/core/presentation.js +5 -0
  128. package/dist/core/presentations.d.ts +56 -0
  129. package/dist/core/presentations.js +66 -0
  130. package/dist/core/provider.d.ts +69 -0
  131. package/dist/core/provider.js +5 -0
  132. package/dist/core/resource.d.ts +262 -0
  133. package/dist/core/resource.js +6 -0
  134. package/dist/core/resources.d.ts +131 -0
  135. package/dist/core/resources.js +254 -0
  136. package/dist/core/run-directory.d.ts +69 -0
  137. package/dist/core/run-directory.js +94 -0
  138. package/dist/core/run-state.d.ts +152 -0
  139. package/dist/core/run-state.js +313 -0
  140. package/dist/core/run.d.ts +187 -0
  141. package/dist/core/run.js +321 -0
  142. package/dist/core/state-directory.d.ts +19 -0
  143. package/dist/core/state-directory.js +29 -0
  144. package/dist/core/timeline.d.ts +63 -0
  145. package/dist/core/timeline.js +97 -0
  146. package/dist/core/timing.d.ts +22 -0
  147. package/dist/core/timing.js +26 -0
  148. package/dist/credential/credential.d.ts +46 -0
  149. package/dist/credential/credential.js +80 -0
  150. package/dist/credential/diagnosis.d.ts +18 -0
  151. package/dist/credential/diagnosis.js +99 -0
  152. package/dist/credential/gateways.d.ts +109 -0
  153. package/dist/credential/gateways.js +1 -0
  154. package/dist/credential/index.d.ts +7 -0
  155. package/dist/credential/index.js +7 -0
  156. package/dist/credential/live/github-actions-token-gateway.d.ts +15 -0
  157. package/dist/credential/live/github-actions-token-gateway.js +43 -0
  158. package/dist/credential/live/github-actions-token-response.d.ts +19 -0
  159. package/dist/credential/live/github-actions-token-response.js +49 -0
  160. package/dist/credential/live/vercel-cli-gateway.d.ts +9 -0
  161. package/dist/credential/live/vercel-cli-gateway.js +64 -0
  162. package/dist/credential/live/vercel-output.d.ts +60 -0
  163. package/dist/credential/live/vercel-output.js +122 -0
  164. package/dist/credential/live/vercel-process.d.ts +14 -0
  165. package/dist/credential/live/vercel-process.js +3 -0
  166. package/dist/credential/settle.d.ts +31 -0
  167. package/dist/credential/settle.js +49 -0
  168. package/dist/credential/source.d.ts +110 -0
  169. package/dist/credential/source.js +114 -0
  170. package/dist/help-logo.d.ts +11 -0
  171. package/dist/help-logo.js +56 -0
  172. package/dist/presentation.d.ts +26 -0
  173. package/dist/presentation.js +21 -0
  174. package/dist/resources/github/cleanup.d.ts +23 -0
  175. package/dist/resources/github/cleanup.js +39 -0
  176. package/dist/resources/github/command.d.ts +74 -0
  177. package/dist/resources/github/command.js +117 -0
  178. package/dist/resources/github/config.d.ts +16 -0
  179. package/dist/resources/github/config.js +37 -0
  180. package/dist/resources/github/events.d.ts +26 -0
  181. package/dist/resources/github/events.js +2 -0
  182. package/dist/resources/github/fixture-repo.d.ts +69 -0
  183. package/dist/resources/github/fixture-repo.js +60 -0
  184. package/dist/resources/github/gateways.d.ts +62 -0
  185. package/dist/resources/github/gateways.js +1 -0
  186. package/dist/resources/github/index.d.ts +12 -0
  187. package/dist/resources/github/index.js +15 -0
  188. package/dist/resources/github/live/fixture-repo-gateway.d.ts +12 -0
  189. package/dist/resources/github/live/fixture-repo-gateway.js +92 -0
  190. package/dist/resources/github/live/gateways.d.ts +6 -0
  191. package/dist/resources/github/live/gateways.js +13 -0
  192. package/dist/resources/github/presentation.d.ts +13 -0
  193. package/dist/resources/github/presentation.js +43 -0
  194. package/dist/resources/github/provider.d.ts +66 -0
  195. package/dist/resources/github/provider.js +58 -0
  196. package/dist/resources/github/resource-provider.d.ts +6 -0
  197. package/dist/resources/github/resource-provider.js +20 -0
  198. package/dist/resources/github/resource.d.ts +33 -0
  199. package/dist/resources/github/resource.js +12 -0
  200. package/dist/resources/testserver/cleanup.d.ts +14 -0
  201. package/dist/resources/testserver/cleanup.js +22 -0
  202. package/dist/resources/testserver/command.d.ts +322 -0
  203. package/dist/resources/testserver/command.js +245 -0
  204. package/dist/resources/testserver/commands/app.d.ts +18 -0
  205. package/dist/resources/testserver/commands/app.js +3 -0
  206. package/dist/resources/testserver/commands/create/command.d.ts +136 -0
  207. package/dist/resources/testserver/commands/create/command.js +158 -0
  208. package/dist/resources/testserver/commands/create/metadata.d.ts +31 -0
  209. package/dist/resources/testserver/commands/create/metadata.js +45 -0
  210. package/dist/resources/testserver/commands/create/outcomes.d.ts +111 -0
  211. package/dist/resources/testserver/commands/create/outcomes.js +172 -0
  212. package/dist/resources/testserver/commands/list/command.d.ts +60 -0
  213. package/dist/resources/testserver/commands/list/command.js +56 -0
  214. package/dist/resources/testserver/commands/list/metadata.d.ts +9 -0
  215. package/dist/resources/testserver/commands/list/metadata.js +9 -0
  216. package/dist/resources/testserver/commands/list/outcomes.d.ts +54 -0
  217. package/dist/resources/testserver/commands/list/outcomes.js +152 -0
  218. package/dist/resources/testserver/config.d.ts +18 -0
  219. package/dist/resources/testserver/config.js +77 -0
  220. package/dist/resources/testserver/credential-facts.d.ts +80 -0
  221. package/dist/resources/testserver/credential-facts.js +83 -0
  222. package/dist/resources/testserver/events.d.ts +59 -0
  223. package/dist/resources/testserver/events.js +4 -0
  224. package/dist/resources/testserver/index.d.ts +16 -0
  225. package/dist/resources/testserver/index.js +24 -0
  226. package/dist/resources/testserver/lane.d.ts +28 -0
  227. package/dist/resources/testserver/lane.js +139 -0
  228. package/dist/resources/testserver/live/gateways.d.ts +6 -0
  229. package/dist/resources/testserver/live/gateways.js +26 -0
  230. package/dist/resources/testserver/options.d.ts +5 -0
  231. package/dist/resources/testserver/options.js +5 -0
  232. package/dist/resources/testserver/pool/channels.d.ts +80 -0
  233. package/dist/resources/testserver/pool/channels.js +48 -0
  234. package/dist/resources/testserver/pool/create.d.ts +48 -0
  235. package/dist/resources/testserver/pool/create.js +45 -0
  236. package/dist/resources/testserver/pool/directory.d.ts +4 -0
  237. package/dist/resources/testserver/pool/directory.js +5 -0
  238. package/dist/resources/testserver/pool/gateways.d.ts +190 -0
  239. package/dist/resources/testserver/pool/gateways.js +1 -0
  240. package/dist/resources/testserver/pool/host.d.ts +8 -0
  241. package/dist/resources/testserver/pool/host.js +21 -0
  242. package/dist/resources/testserver/pool/index.d.ts +9 -0
  243. package/dist/resources/testserver/pool/index.js +10 -0
  244. package/dist/resources/testserver/pool/inspect.d.ts +53 -0
  245. package/dist/resources/testserver/pool/inspect.js +45 -0
  246. package/dist/resources/testserver/pool/lease.d.ts +84 -0
  247. package/dist/resources/testserver/pool/lease.js +125 -0
  248. package/dist/resources/testserver/pool/live/pool-records.d.ts +17 -0
  249. package/dist/resources/testserver/pool/live/pool-records.js +70 -0
  250. package/dist/resources/testserver/pool/live/pool-store-gateway.d.ts +12 -0
  251. package/dist/resources/testserver/pool/live/pool-store-gateway.js +435 -0
  252. package/dist/resources/testserver/pool/staleness.d.ts +16 -0
  253. package/dist/resources/testserver/pool/staleness.js +27 -0
  254. package/dist/resources/testserver/presentation.d.ts +9 -0
  255. package/dist/resources/testserver/presentation.js +217 -0
  256. package/dist/resources/testserver/provider.d.ts +177 -0
  257. package/dist/resources/testserver/provider.js +254 -0
  258. package/dist/resources/testserver/ran.d.ts +87 -0
  259. package/dist/resources/testserver/ran.js +140 -0
  260. package/dist/resources/testserver/resource-provider.d.ts +12 -0
  261. package/dist/resources/testserver/resource-provider.js +38 -0
  262. package/dist/resources/testserver/resource.d.ts +32 -0
  263. package/dist/resources/testserver/resource.js +10 -0
  264. package/dist/resources/testserver/run-sandbox.d.ts +13 -0
  265. package/dist/resources/testserver/run-sandbox.js +6 -0
  266. package/dist/resources/testserver/sandbox/channels.d.ts +12 -0
  267. package/dist/resources/testserver/sandbox/channels.js +21 -0
  268. package/dist/resources/testserver/sandbox/create-failure.d.ts +35 -0
  269. package/dist/resources/testserver/sandbox/create-failure.js +65 -0
  270. package/dist/resources/testserver/sandbox/create.d.ts +29 -0
  271. package/dist/resources/testserver/sandbox/create.js +37 -0
  272. package/dist/resources/testserver/sandbox/gateways.d.ts +150 -0
  273. package/dist/resources/testserver/sandbox/gateways.js +1 -0
  274. package/dist/resources/testserver/sandbox/index.d.ts +6 -0
  275. package/dist/resources/testserver/sandbox/index.js +7 -0
  276. package/dist/resources/testserver/sandbox/live/builds-response.d.ts +9 -0
  277. package/dist/resources/testserver/sandbox/live/builds-response.js +27 -0
  278. package/dist/resources/testserver/sandbox/live/control-plane-gateway.d.ts +17 -0
  279. package/dist/resources/testserver/sandbox/live/control-plane-gateway.js +133 -0
  280. package/dist/resources/testserver/sandbox/live/create-response.d.ts +35 -0
  281. package/dist/resources/testserver/sandbox/live/create-response.js +78 -0
  282. package/dist/resources/testserver/sandbox/live/fetch-failure.d.ts +24 -0
  283. package/dist/resources/testserver/sandbox/live/fetch-failure.js +45 -0
  284. package/dist/resources/testserver/sandbox/live/health-check-gateway.d.ts +11 -0
  285. package/dist/resources/testserver/sandbox/live/health-check-gateway.js +36 -0
  286. package/dist/resources/testserver/sandbox/live/sse.d.ts +12 -0
  287. package/dist/resources/testserver/sandbox/live/sse.js +32 -0
  288. package/dist/resources.d.ts +452 -0
  289. package/dist/resources.js +88 -0
  290. package/dist/runner/base.d.ts +40 -0
  291. package/dist/runner/base.js +52 -0
  292. package/dist/runner/context.d.ts +13 -0
  293. package/dist/runner/context.js +9 -0
  294. package/dist/runner/events.d.ts +179 -0
  295. package/dist/runner/events.js +16 -0
  296. package/dist/runner/gateways.d.ts +351 -0
  297. package/dist/runner/gateways.js +3 -0
  298. package/dist/runner/index.d.ts +19 -0
  299. package/dist/runner/index.js +18 -0
  300. package/dist/runner/live/checkout-gateway.d.ts +3 -0
  301. package/dist/runner/live/checkout-gateway.js +206 -0
  302. package/dist/runner/live/git-output.d.ts +14 -0
  303. package/dist/runner/live/git-output.js +32 -0
  304. package/dist/runner/live/sandbox-errors.d.ts +7 -0
  305. package/dist/runner/live/sandbox-errors.js +21 -0
  306. package/dist/runner/live/sandbox-gateway.d.ts +7 -0
  307. package/dist/runner/live/sandbox-gateway.js +427 -0
  308. package/dist/runner/live/snapshot-cache-gateway.d.ts +12 -0
  309. package/dist/runner/live/snapshot-cache-gateway.js +104 -0
  310. package/dist/runner/live/snapshot-records.d.ts +11 -0
  311. package/dist/runner/live/snapshot-records.js +57 -0
  312. package/dist/runner/live/terminal.d.ts +16 -0
  313. package/dist/runner/live/terminal.js +37 -0
  314. package/dist/runner/live/user.d.ts +2 -0
  315. package/dist/runner/live/user.js +11 -0
  316. package/dist/runner/output.d.ts +23 -0
  317. package/dist/runner/output.js +58 -0
  318. package/dist/runner/prepare.d.ts +67 -0
  319. package/dist/runner/prepare.js +59 -0
  320. package/dist/runner/ready.d.ts +68 -0
  321. package/dist/runner/ready.js +159 -0
  322. package/dist/runner/recipe.d.ts +126 -0
  323. package/dist/runner/recipe.js +302 -0
  324. package/dist/runner/remote-command.d.ts +77 -0
  325. package/dist/runner/remote-command.js +127 -0
  326. package/dist/runner/scope.d.ts +58 -0
  327. package/dist/runner/scope.js +117 -0
  328. package/dist/runner/snapshot-build.d.ts +33 -0
  329. package/dist/runner/snapshot-build.js +112 -0
  330. package/dist/runner/snapshot-cache.d.ts +84 -0
  331. package/dist/runner/snapshot-cache.js +126 -0
  332. package/dist/runner/snapshot-key.d.ts +52 -0
  333. package/dist/runner/snapshot-key.js +91 -0
  334. package/dist/runner/steps.d.ts +41 -0
  335. package/dist/runner/steps.js +49 -0
  336. package/dist/sdk/container/api-request.d.ts +32 -0
  337. package/dist/sdk/container/api-request.js +46 -0
  338. package/dist/sdk/container/container.d.ts +144 -0
  339. package/dist/sdk/container/container.js +346 -0
  340. package/dist/sdk/container/feature-flags.d.ts +37 -0
  341. package/dist/sdk/container/feature-flags.js +118 -0
  342. package/dist/sdk/container/gateways.d.ts +108 -0
  343. package/dist/sdk/container/gateways.js +1 -0
  344. package/dist/sdk/container/index.d.ts +5 -0
  345. package/dist/sdk/container/index.js +5 -0
  346. package/dist/sdk/container/live/container-gateway.d.ts +17 -0
  347. package/dist/sdk/container/live/container-gateway.js +114 -0
  348. package/dist/sdk/factories/build.d.ts +66 -0
  349. package/dist/sdk/factories/build.js +98 -0
  350. package/dist/sdk/factories/definition.d.ts +28 -0
  351. package/dist/sdk/factories/definition.js +16 -0
  352. package/dist/sdk/factories/definitions.d.ts +166 -0
  353. package/dist/sdk/factories/definitions.js +235 -0
  354. package/dist/sdk/factories/gateways.d.ts +25 -0
  355. package/dist/sdk/factories/gateways.js +1 -0
  356. package/dist/sdk/factories/index.d.ts +5 -0
  357. package/dist/sdk/factories/index.js +5 -0
  358. package/dist/sdk/factories/live/factory-gateway.d.ts +10 -0
  359. package/dist/sdk/factories/live/factory-gateway.js +29 -0
  360. package/dist/sdk/index.d.ts +7 -0
  361. package/dist/sdk/index.js +15 -0
  362. package/dist/sdk/payload/index.d.ts +2 -0
  363. package/dist/sdk/payload/index.js +4 -0
  364. package/dist/sdk/payload/payload.d.ts +47 -0
  365. package/dist/sdk/payload/payload.js +74 -0
  366. package/dist/sdk/payload/test-events.d.ts +102 -0
  367. package/dist/sdk/payload/test-events.js +59 -0
  368. package/dist/sdk/proxy/exchange.d.ts +58 -0
  369. package/dist/sdk/proxy/exchange.js +173 -0
  370. package/dist/sdk/proxy/faulted-exchange.d.ts +10 -0
  371. package/dist/sdk/proxy/faulted-exchange.js +106 -0
  372. package/dist/sdk/proxy/faults.d.ts +133 -0
  373. package/dist/sdk/proxy/faults.js +147 -0
  374. package/dist/sdk/proxy/index.d.ts +3 -0
  375. package/dist/sdk/proxy/index.js +3 -0
  376. package/dist/sdk/proxy/proxy.d.ts +93 -0
  377. package/dist/sdk/proxy/proxy.js +99 -0
  378. package/dist/sdk/proxy/records.d.ts +56 -0
  379. package/dist/sdk/proxy/records.js +56 -0
  380. package/dist/sdk/records/body.d.ts +89 -0
  381. package/dist/sdk/records/body.js +236 -0
  382. package/dist/sdk/records/index.d.ts +2 -0
  383. package/dist/sdk/records/index.js +4 -0
  384. package/dist/sdk/records/records.d.ts +49 -0
  385. package/dist/sdk/records/records.js +16 -0
  386. package/dist/sdk/seed/index.d.ts +1 -0
  387. package/dist/sdk/seed/index.js +3 -0
  388. package/dist/sdk/seed/seed.d.ts +221 -0
  389. package/dist/sdk/seed/seed.js +171 -0
  390. package/dist/sdk/testserver/clock.d.ts +8 -0
  391. package/dist/sdk/testserver/clock.js +10 -0
  392. package/dist/sdk/testserver/failure.d.ts +73 -0
  393. package/dist/sdk/testserver/failure.js +61 -0
  394. package/dist/sdk/testserver/index.d.ts +5 -0
  395. package/dist/sdk/testserver/index.js +8 -0
  396. package/dist/sdk/testserver/live/connect-failure.d.ts +7 -0
  397. package/dist/sdk/testserver/live/connect-failure.js +30 -0
  398. package/dist/sdk/testserver/live/request.d.ts +69 -0
  399. package/dist/sdk/testserver/live/request.js +89 -0
  400. package/dist/sdk/testserver/service-ids.d.ts +19 -0
  401. package/dist/sdk/testserver/service-ids.js +77 -0
  402. package/dist/sdk/testserver/test-id.d.ts +15 -0
  403. package/dist/sdk/testserver/test-id.js +28 -0
  404. package/dist/story/align.d.ts +37 -0
  405. package/dist/story/align.js +39 -0
  406. package/dist/story/artifact.d.ts +60 -0
  407. package/dist/story/artifact.js +93 -0
  408. package/dist/story/definition.d.ts +52 -0
  409. package/dist/story/definition.js +9 -0
  410. package/dist/story/diff.d.ts +9 -0
  411. package/dist/story/diff.js +97 -0
  412. package/dist/story/errors.d.ts +14 -0
  413. package/dist/story/errors.js +21 -0
  414. package/dist/story/gateways.d.ts +74 -0
  415. package/dist/story/gateways.js +3 -0
  416. package/dist/story/host.d.ts +27 -0
  417. package/dist/story/host.js +97 -0
  418. package/dist/story/index.d.ts +7 -0
  419. package/dist/story/index.js +9 -0
  420. package/dist/story/json.d.ts +16 -0
  421. package/dist/story/json.js +59 -0
  422. package/dist/story/live/artifact-gateway.d.ts +2 -0
  423. package/dist/story/live/artifact-gateway.js +82 -0
  424. package/dist/story/mode.d.ts +17 -0
  425. package/dist/story/mode.js +21 -0
  426. package/dist/story/orphans.d.ts +17 -0
  427. package/dist/story/orphans.js +15 -0
  428. package/dist/story/report.d.ts +30 -0
  429. package/dist/story/report.js +118 -0
  430. package/dist/story/run.d.ts +49 -0
  431. package/dist/story/run.js +160 -0
  432. package/dist/story/sequence.d.ts +30 -0
  433. package/dist/story/sequence.js +74 -0
  434. package/dist/story/settle.d.ts +94 -0
  435. package/dist/story/settle.js +70 -0
  436. package/dist/time/duration.d.ts +19 -0
  437. package/dist/time/duration.js +37 -0
  438. package/dist/time/index.d.ts +2 -0
  439. package/dist/time/index.js +4 -0
  440. package/dist/time/time.d.ts +15 -0
  441. package/dist/time/time.js +23 -0
  442. package/dist/vercel-cli/ansi.d.ts +13 -0
  443. package/dist/vercel-cli/ansi.js +32 -0
  444. package/dist/vercel-cli/arguments.d.ts +25 -0
  445. package/dist/vercel-cli/arguments.js +78 -0
  446. package/dist/vercel-cli/auth-config.d.ts +43 -0
  447. package/dist/vercel-cli/auth-config.js +36 -0
  448. package/dist/vercel-cli/clock.d.ts +9 -0
  449. package/dist/vercel-cli/clock.js +10 -0
  450. package/dist/vercel-cli/config-files.d.ts +24 -0
  451. package/dist/vercel-cli/config-files.js +40 -0
  452. package/dist/vercel-cli/context.d.ts +12 -0
  453. package/dist/vercel-cli/context.js +12 -0
  454. package/dist/vercel-cli/driver.d.ts +218 -0
  455. package/dist/vercel-cli/driver.js +364 -0
  456. package/dist/vercel-cli/entry.d.ts +8 -0
  457. package/dist/vercel-cli/entry.js +13 -0
  458. package/dist/vercel-cli/environment.d.ts +33 -0
  459. package/dist/vercel-cli/environment.js +72 -0
  460. package/dist/vercel-cli/errors.d.ts +8 -0
  461. package/dist/vercel-cli/errors.js +8 -0
  462. package/dist/vercel-cli/gateways.d.ts +103 -0
  463. package/dist/vercel-cli/gateways.js +4 -0
  464. package/dist/vercel-cli/index.d.ts +10 -0
  465. package/dist/vercel-cli/index.js +15 -0
  466. package/dist/vercel-cli/invocation.d.ts +234 -0
  467. package/dist/vercel-cli/invocation.js +397 -0
  468. package/dist/vercel-cli/keys.d.ts +14 -0
  469. package/dist/vercel-cli/keys.js +12 -0
  470. package/dist/vercel-cli/live/config-files.d.ts +28 -0
  471. package/dist/vercel-cli/live/config-files.js +66 -0
  472. package/dist/vercel-cli/live/process-gateway.d.ts +14 -0
  473. package/dist/vercel-cli/live/process-gateway.js +178 -0
  474. package/dist/vercel-cli/redaction.d.ts +13 -0
  475. package/dist/vercel-cli/redaction.js +22 -0
  476. package/dist/vercel-cli/report.d.ts +22 -0
  477. package/dist/vercel-cli/report.js +110 -0
  478. package/dist/vercel-cli/verbose.d.ts +7 -0
  479. package/dist/vercel-cli/verbose.js +24 -0
  480. package/dist/version.d.ts +20 -0
  481. package/dist/version.js +57 -0
  482. package/dist/vitest/config.d.ts +51 -0
  483. package/dist/vitest/config.js +61 -0
  484. package/dist/vitest/container-scope.d.ts +108 -0
  485. package/dist/vitest/container-scope.js +234 -0
  486. package/dist/vitest/diagnostics.d.ts +146 -0
  487. package/dist/vitest/diagnostics.js +306 -0
  488. package/dist/vitest/fixtures.d.ts +64 -0
  489. package/dist/vitest/fixtures.js +172 -0
  490. package/dist/vitest/gateways.d.ts +47 -0
  491. package/dist/vitest/gateways.js +3 -0
  492. package/dist/vitest/index.d.ts +3 -0
  493. package/dist/vitest/index.js +9 -0
  494. package/dist/vitest/list-output.d.ts +3 -0
  495. package/dist/vitest/list-output.js +19 -0
  496. package/dist/vitest/live/list-gateway.d.ts +7 -0
  497. package/dist/vitest/live/list-gateway.js +60 -0
  498. package/dist/vitest/ownership.d.ts +29 -0
  499. package/dist/vitest/ownership.js +68 -0
  500. package/dist/vitest/plan.d.ts +33 -0
  501. package/dist/vitest/plan.js +73 -0
  502. package/dist/vitest/sandbox.d.ts +16 -0
  503. package/dist/vitest/sandbox.js +35 -0
  504. package/dist/vitest/test-events.d.ts +41 -0
  505. package/dist/vitest/test-events.js +92 -0
  506. package/dist/vitest/test-results.d.ts +84 -0
  507. package/dist/vitest/test-results.js +160 -0
  508. package/dist/vitest/types.d.ts +68 -0
  509. package/dist/vitest/types.js +4 -0
  510. package/package.json +123 -4
  511. package/skills/overview.md +32 -0
  512. package/skills/read-run-output.md +65 -0
  513. package/README.md +0 -3
@@ -0,0 +1,147 @@
1
+ import { validateHeaderName, validateHeaderValue } from "node:http";
2
+ /** Headers that frame the message, which the proxy sets itself. */
3
+ const FRAMING_HEADERS = new Set(["content-length", "transfer-encoding"]);
4
+ /** Final response statuses HTTP sends without a body. */
5
+ const BODYLESS_STATUSES = new Set([204, 205, 304]);
6
+ /** Final response statuses HTTP sends without `content-length`. */
7
+ const UNFRAMED_STATUSES = new Set([204, 304]);
8
+ /** `rule` checked and prepared; throws a `TypeError` naming what is wrong with it. */
9
+ export function checkRule(rule) {
10
+ if (typeof rule !== "object" || rule === null)
11
+ throw new TypeError("a fault rule must be an object");
12
+ const { method, path, times = 1, delayMs = 0 } = rule;
13
+ if (typeof method !== "string" || !/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/.test(method)) {
14
+ throw new TypeError(`a fault rule's method must be an HTTP method, not ${JSON.stringify(method)}`);
15
+ }
16
+ if (typeof path !== "string" || !path.startsWith("/") || /[?#]/.test(path)) {
17
+ throw new TypeError(`a fault rule's path must be a path template that starts with "/" and holds no "?" or "#", not ${JSON.stringify(path)}`);
18
+ }
19
+ if (!Number.isSafeInteger(times) || times < 1) {
20
+ throw new TypeError(`a fault rule's times must be a positive integer, not ${String(times)}`);
21
+ }
22
+ if (typeof delayMs !== "number" || !Number.isFinite(delayMs) || delayMs < 0) {
23
+ throw new TypeError(`a fault rule's delayMs must be a finite number, 0 or more, not ${String(delayMs)}`);
24
+ }
25
+ const base = { method: method.toUpperCase(), path, times, delayMs };
26
+ switch (rule.action) {
27
+ case "respond":
28
+ case "replace":
29
+ return { ...base, action: rule.action, response: prepareResponse(rule.response) };
30
+ case "reset":
31
+ if (rule.when !== "before-forward" && rule.when !== "after-answer") {
32
+ throw new TypeError(`a reset fault rule's when must be "before-forward" or "after-answer", not ${JSON.stringify(rule.when)}`);
33
+ }
34
+ return { ...base, action: "reset", when: rule.when };
35
+ default:
36
+ throw new TypeError(`a fault rule's action must be "respond", "replace" or "reset", not ${JSON.stringify(rule.action)}`);
37
+ }
38
+ }
39
+ function prepareResponse(response) {
40
+ if (typeof response !== "object" || response === null) {
41
+ throw new TypeError("a respond or replace fault rule needs a response");
42
+ }
43
+ const { status, headers = {}, body } = response;
44
+ if (!Number.isInteger(status) || status < 200 || status > 599) {
45
+ throw new TypeError(`a fault response's status must be a final response status from 200 to 599, not ${String(status)}`);
46
+ }
47
+ const prepared = new Map();
48
+ for (const [name, value] of Object.entries(headers)) {
49
+ const key = name.toLowerCase();
50
+ if (typeof value !== "string") {
51
+ throw new TypeError(`a fault response's header ${JSON.stringify(name)} must be a string`);
52
+ }
53
+ try {
54
+ validateHeaderName(name);
55
+ validateHeaderValue(name, value);
56
+ }
57
+ catch (error) {
58
+ throw new TypeError(`a fault response's header ${JSON.stringify(name)} is invalid: ${error.message}`, {
59
+ cause: error,
60
+ });
61
+ }
62
+ if (FRAMING_HEADERS.has(key))
63
+ throw new TypeError(`a fault response can't set ${key}: the proxy sets it`);
64
+ if (prepared.has(key))
65
+ throw new TypeError(`a fault response sets the header ${key} twice`);
66
+ prepared.set(key, value);
67
+ }
68
+ const serialized = serializeBody(body);
69
+ if (serialized !== undefined && BODYLESS_STATUSES.has(status)) {
70
+ throw new TypeError(`a fault response with status ${status} can't have a body`);
71
+ }
72
+ if (serialized !== undefined && !prepared.has("content-type"))
73
+ prepared.set("content-type", serialized.contentType);
74
+ const bytes = serialized?.bytes ?? Buffer.alloc(0);
75
+ if (!UNFRAMED_STATUSES.has(status))
76
+ prepared.set("content-length", String(bytes.byteLength));
77
+ return { status, headers: Object.fromEntries(prepared), body: bytes };
78
+ }
79
+ /** A fault response's body as bytes with its default `content-type`, or `undefined` for none. */
80
+ export function serializeBody(body) {
81
+ if (body === undefined)
82
+ return undefined;
83
+ if (typeof body === "string")
84
+ return { bytes: Buffer.from(body, "utf8"), contentType: "text/plain; charset=utf-8" };
85
+ let json;
86
+ try {
87
+ json = JSON.stringify(body);
88
+ }
89
+ catch (error) {
90
+ throw new TypeError(`a fault response's body can't be sent as JSON: ${error.message}`, { cause: error });
91
+ }
92
+ if (json === undefined)
93
+ throw new TypeError(`a fault response's body can't be sent as JSON: ${typeof body}`);
94
+ return { bytes: Buffer.from(json, "utf8"), contentType: "application/json; charset=utf-8" };
95
+ }
96
+ /**
97
+ * Whether `path`, a record's `path`, matches the path template `template`: the same number of `/`-separated
98
+ * segments, each `:name` segment (more than one character) matching one non-empty segment and every other equal,
99
+ * raw. As vercel-internal's `matchPathTemplate`, without reading the parameters.
100
+ */
101
+ export function matchesTemplate(template, path) {
102
+ const want = template.split("/");
103
+ const got = path.split("/");
104
+ if (want.length !== got.length)
105
+ return false;
106
+ return want.every((segment, index) => {
107
+ const actual = got[index] ?? "";
108
+ return segment.length > 1 && segment.startsWith(":") ? actual !== "" : segment === actual;
109
+ });
110
+ }
111
+ /**
112
+ * A proxy's fault rules, in the order they were added. `take` finds the first rule that matches a request and has
113
+ * hits left, and uses one of its hits.
114
+ */
115
+ export class FaultRules {
116
+ #rules = [];
117
+ #handles = [];
118
+ /** The handle of every rule, in the order they were added. */
119
+ get handles() {
120
+ return [...this.#handles];
121
+ }
122
+ /** Checks `rule` and adds it after the others; throws a `TypeError` for a bad rule. */
123
+ add(rule) {
124
+ const entry = { rule: checkRule(rule), hits: 0 };
125
+ this.#rules.push(entry);
126
+ const handle = {
127
+ rule: { ...rule },
128
+ get hits() {
129
+ return entry.hits;
130
+ },
131
+ get remaining() {
132
+ return entry.rule.times - entry.hits;
133
+ },
134
+ };
135
+ this.#handles.push(handle);
136
+ return handle;
137
+ }
138
+ /** The first rule with hits left that matches `method` and `path`, after using one of its hits, or `undefined`. */
139
+ take(method, path) {
140
+ const wanted = method.toUpperCase();
141
+ const entry = this.#rules.find((each) => each.hits < each.rule.times && each.rule.method === wanted && matchesTemplate(each.rule.path, path));
142
+ if (entry === undefined)
143
+ return undefined;
144
+ entry.hits += 1;
145
+ return entry.rule;
146
+ }
147
+ }
@@ -0,0 +1,3 @@
1
+ export type { FaultHandle, FaultResponse, FaultRule, FaultUpstream, ProxyFault } from "./faults.ts";
2
+ export { type ContainerProxy, type ProxyOptions, type ProxyTarget, startProxy, withProxy } from "./proxy.ts";
3
+ export { isOpenRecord, type OpenRequestOutcome, type ProxyRequestOutcome, type ProxyRequestRecord } from "./records.ts";
@@ -0,0 +1,3 @@
1
+ // The SDK's `proxy` module: a local server that adds a container's test id for clients that can't send one.
2
+ export { startProxy, withProxy } from "./proxy.js";
3
+ export { isOpenRecord } from "./records.js";
@@ -0,0 +1,93 @@
1
+ import { type FaultHandle, type FaultRule } from "./faults.ts";
2
+ import { type ProxyRequestRecord } from "./records.ts";
3
+ /**
4
+ * The container a proxy adds the test id of. A `Container` qualifies, and its `redact` becomes the proxy's; a target
5
+ * without one leaves the proxy's `redact` replacing nothing.
6
+ */
7
+ export interface ProxyTarget {
8
+ readonly testserverUrl: string;
9
+ readonly testId: string;
10
+ /** `text` with every token secret the container has seen replaced by `<token>`. */
11
+ readonly redact?: (text: string) => string;
12
+ }
13
+ export interface ProxyOptions {
14
+ readonly container: ProxyTarget;
15
+ /** The address to listen on; default `127.0.0.1`. */
16
+ readonly host?: string;
17
+ /** The port to listen on; default 0, a free one. */
18
+ readonly port?: number;
19
+ /**
20
+ * Hears each request as it is recorded, when its exchange ends, before its client sees the end of the response.
21
+ * What it throws is dropped: it never touches the exchange.
22
+ */
23
+ readonly onRequest?: (record: ProxyRequestRecord) => void;
24
+ }
25
+ /** A running proxy: a local server that adds a container's test id for clients that can't. */
26
+ export interface ContainerProxy {
27
+ /** Where the proxy listens, such as `http://127.0.0.1:53124`, with no trailing slash. */
28
+ readonly url: string;
29
+ /**
30
+ * Every request received so far, in arrival order. A request is recorded at its arrival, as an open record
31
+ * (`open: true`), and its record is replaced when its exchange ends: when Testserver's answer ends, breaks off or
32
+ * can't be had, when a fault rule's response or reset ends it, when its client closes the connection first
33
+ * (`error: "the client closed the connection"`), or at `close()`. An exchange is recorded as ended before its
34
+ * client sees the end of the response or the reset, so once a client has its whole answer, its request's record
35
+ * has ended, and once `close()` resolves, every record has.
36
+ */
37
+ readonly requests: readonly ProxyRequestRecord[];
38
+ /**
39
+ * Adds a fault rule after the others, and returns its handle: the rule as given, and `hits` and `remaining`, which
40
+ * count the requests it applied to and those it still will. A request that arrives after this returns is matched as its headers arrive,
41
+ * against the rules in the order they were added: the first that matches and has hits left wins and uses one hit.
42
+ * A request no rule matches passes through as usual. `container.fetch` never goes through the proxy, so rules
43
+ * never affect it. Throws a `TypeError` for a bad rule, a body `JSON.stringify` can't serialize among them, and
44
+ * once `close()` has been called.
45
+ *
46
+ * For a matching request the proxy reads the client's request body whole, then waits `delayMs`, then acts, so its
47
+ * record (`fault: { action }` from the match on, open records included) always holds the whole request body:
48
+ *
49
+ * - `respond`: the proxy sends `response` and never forwards. The record has its status and its body.
50
+ * - `replace`: the proxy forwards, reads Testserver's whole answer, sends none of it, and sends `response`. The
51
+ * record has the fake status and body, and `fault.upstream` Testserver's status and body.
52
+ * - `reset`, `before-forward`: the proxy resets the connection (`socket.resetAndDestroy()`) without forwarding.
53
+ * The record has no status, and `error: "the proxy injected a reset before forwarding"`.
54
+ * - `reset`, `after-answer`: the proxy forwards, reads Testserver's whole answer, then resets the connection, a
55
+ * lost response. The record has no status, `error: "the proxy injected a reset after Testserver answered"`, and
56
+ * `fault.upstream` Testserver's status and body.
57
+ *
58
+ * A fake response to a `HEAD` request sends no body, and its record has none. Fake bodies and Testserver's are recorded as any other body: decoded, capped and redacted. The proxy has no
59
+ * error format of its own: a fake error body must match the real service's error format. A forwarding fault holds
60
+ * the request body and Testserver's whole answer, so a streaming endpoint under one doesn't stream. A reset ends
61
+ * the client's connection, so another request of a keep-alive client on the same connection fails with it.
62
+ *
63
+ * When Testserver fails under a forwarding fault, with no answer or one that stops before its end, the proxy
64
+ * doesn't fake over it: the client gets a 502 or a destroyed connection, and the record says so, as with no rule.
65
+ * `fault.upstream.error` holds the failure, beside any status and incomplete body Testserver sent, and the record's
66
+ * other fields hold only what the client got. The hit still counts. A status Testserver answered, a 500
67
+ * included, is an answer, not a failure. The SDK only records the failure: a caller that doesn't use the Vitest
68
+ * adapter, which fails the test, checks `fault.upstream` itself. A client hangup or `close()` while the proxy
69
+ * waits ends the exchange with its usual error, `fault: { action }` and no `upstream`.
70
+ */
71
+ fault(rule: FaultRule): FaultHandle;
72
+ /** The handle of every fault rule added so far, in the order they were added, each with its rule. */
73
+ readonly faults: readonly FaultHandle[];
74
+ /**
75
+ * `text` redacted with the container's `redact`, every token secret it has seen reading `<token>`; `text`
76
+ * unchanged when the proxy's target has no `redact`. For printing what a client of the proxy received.
77
+ */
78
+ redact(text: string): string;
79
+ /**
80
+ * Records every exchange still open as ended by the close (`error: "the proxy closed"`), stops listening, ends
81
+ * open connections, and resolves once closed. Calling it again does nothing.
82
+ */
83
+ close(): Promise<void>;
84
+ }
85
+ /**
86
+ * Starts a proxy that forwards each request to the container's Testserver URL with its test id added, unless a
87
+ * fault rule (`proxy.fault`) changes what the client gets for it. Method, path, query, headers and body pass
88
+ * through, `host` becomes Testserver's, and bodies stream both ways undecoded, while the proxy keeps a decoded,
89
+ * redacted copy of each for its record. A request Testserver can't be reached for gets a 502.
90
+ */
91
+ export declare function startProxy(options: ProxyOptions): Promise<ContainerProxy>;
92
+ /** Starts a proxy, runs `body` with it, and closes it however `body` finishes. */
93
+ export declare function withProxy<T>(options: ProxyOptions, body: (proxy: ContainerProxy) => Promise<T>): Promise<T>;
@@ -0,0 +1,99 @@
1
+ import { Agent, createServer, request as httpRequest, } from "node:http";
2
+ import { Agent as HttpsAgent, request as httpsRequest } from "node:https";
3
+ import { splitTarget } from "../records/index.js";
4
+ import { systemClock, TEST_ID_HEADER } from "../testserver/index.js";
5
+ import { Exchange, passThrough } from "./exchange.js";
6
+ import { applyFault } from "./faulted-exchange.js";
7
+ import { FaultRules } from "./faults.js";
8
+ import { upstreamHeaders } from "./records.js";
9
+ /**
10
+ * Starts a proxy that forwards each request to the container's Testserver URL with its test id added, unless a
11
+ * fault rule (`proxy.fault`) changes what the client gets for it. Method, path, query, headers and body pass
12
+ * through, `host` becomes Testserver's, and bodies stream both ways undecoded, while the proxy keeps a decoded,
13
+ * redacted copy of each for its record. A request Testserver can't be reached for gets a 502.
14
+ */
15
+ export async function startProxy(options) {
16
+ const upstream = new URL(options.container.testserverUrl);
17
+ const secure = upstream.protocol === "https:";
18
+ if (!secure && upstream.protocol !== "http:") {
19
+ throw new TypeError(`the proxy forwards only to an http or https Testserver URL, not ${upstream.protocol}`);
20
+ }
21
+ const prefix = upstream.pathname.replace(/\/+$/, "");
22
+ const agent = secure ? new HttpsAgent({ keepAlive: true }) : new Agent({ keepAlive: true });
23
+ const sendRequest = secure ? httpsRequest : httpRequest;
24
+ /** Every exchange received, in arrival order. */
25
+ const exchanges = [];
26
+ const faults = new FaultRules();
27
+ const send = (request, onAnswer) => sendRequest({
28
+ protocol: upstream.protocol,
29
+ hostname: upstream.hostname,
30
+ port: upstream.port,
31
+ method: request.method,
32
+ path: `${prefix}${request.url ?? "/"}`,
33
+ headers: upstreamHeaders(request.headers, {
34
+ host: upstream.host,
35
+ testIdHeader: TEST_ID_HEADER,
36
+ testId: options.container.testId,
37
+ }),
38
+ agent,
39
+ }, onAnswer);
40
+ const deps = { now: () => systemClock.now(), send, onRequest: options.onRequest };
41
+ const server = createServer((request, response) => {
42
+ // Matched once, as the headers arrive: a rule added later never applies to this request.
43
+ const rule = faults.take(request.method ?? "GET", splitTarget(request.url ?? "/").path);
44
+ const exchange = new Exchange(request, response, deps, rule?.action);
45
+ exchanges.push(exchange);
46
+ if (rule === undefined)
47
+ passThrough(exchange);
48
+ else
49
+ applyFault(exchange, rule);
50
+ });
51
+ await listen(server, options.host ?? "127.0.0.1", options.port ?? 0);
52
+ const address = server.address();
53
+ const host = address.family === "IPv6" ? `[${address.address}]` : address.address;
54
+ let closing;
55
+ return {
56
+ url: `http://${host}:${address.port}`,
57
+ get requests() {
58
+ return exchanges.map((exchange) => exchange.read());
59
+ },
60
+ redact: (text) => (options.container.redact === undefined ? text : options.container.redact(text)),
61
+ fault: (rule) => {
62
+ if (closing !== undefined)
63
+ throw new TypeError("a fault rule can't be added once the proxy is closed");
64
+ return faults.add(rule);
65
+ },
66
+ get faults() {
67
+ return faults.handles;
68
+ },
69
+ close: () => {
70
+ closing ??= new Promise((resolve) => {
71
+ for (const exchange of exchanges)
72
+ exchange.finalize();
73
+ server.close(() => resolve());
74
+ server.closeAllConnections();
75
+ agent.destroy();
76
+ });
77
+ return closing;
78
+ },
79
+ };
80
+ }
81
+ /** Starts a proxy, runs `body` with it, and closes it however `body` finishes. */
82
+ export async function withProxy(options, body) {
83
+ const proxy = await startProxy(options);
84
+ try {
85
+ return await body(proxy);
86
+ }
87
+ finally {
88
+ await proxy.close();
89
+ }
90
+ }
91
+ function listen(server, host, port) {
92
+ return new Promise((resolve, reject) => {
93
+ server.once("error", reject);
94
+ server.listen(port, host, () => {
95
+ server.off("error", reject);
96
+ resolve();
97
+ });
98
+ });
99
+ }
@@ -0,0 +1,56 @@
1
+ import type { IncomingHttpHeaders } from "node:http";
2
+ import { type RecordedBody, type RequestOutcome, type RequestRecordFields } from "../records/index.ts";
3
+ import type { ProxyFault } from "./faults.ts";
4
+ /** The header the `vercel` CLI sends with the same id on every request of one invocation. */
5
+ export declare const SESSION_ID_HEADER = "x-vercel-cli-session-id";
6
+ /**
7
+ * The outcome of a proxy record whose exchange was still open when `proxy.requests` was read: no `status` or
8
+ * `error`, no `responseBody`, and a `durationMs` that runs to the read.
9
+ */
10
+ export type OpenRequestOutcome = {
11
+ readonly open: true;
12
+ };
13
+ /** How a proxied exchange stands: ended as `RequestOutcome` says, or still open. */
14
+ export type ProxyRequestOutcome = RequestOutcome | OpenRequestOutcome;
15
+ /**
16
+ * One request the proxy received, recorded at its arrival: what the client sent, and what the client got (Testserver's
17
+ * answer, or a fault rule's) or why it failed, or `open: true` while its exchange is still open. `url` is the target
18
+ * as the client sent it, `startedAt` is the proxy clock's reading at its arrival, `durationMs` runs from its arrival
19
+ * to the exchange's end (or, for an open record, to the read), a fault rule's delay included, and `error` without a
20
+ * `status` means no answer reached the client. No token reaches a record (`records/body.ts`).
21
+ */
22
+ export type ProxyRequestRecord = RequestRecordFields & {
23
+ readonly userAgent?: string;
24
+ /** The `vercel` CLI's `x-vercel-cli-session-id`, the same for every request of one invocation. */
25
+ readonly sessionId?: string;
26
+ /**
27
+ * The fault rule the request matched, if any: its action, and what Testserver answered when the proxy forwarded
28
+ * it. Then `status`, `error` and `responseBody` say what the client got.
29
+ */
30
+ readonly fault?: ProxyFault;
31
+ } & ProxyRequestOutcome;
32
+ /** Whether `record`'s exchange was still open when it was read. */
33
+ export declare function isOpenRecord(record: ProxyRequestRecord): record is ProxyRequestRecord & OpenRequestOutcome;
34
+ /** The record of a request with `method`, `target` and `headers` whose exchange stands as `outcome`. */
35
+ export declare function proxyRecord(request: {
36
+ readonly method: string;
37
+ readonly target: string;
38
+ readonly headers: IncomingHttpHeaders;
39
+ readonly startedAt: number;
40
+ readonly durationMs: number;
41
+ readonly outcome: ProxyRequestOutcome;
42
+ readonly requestBody?: RecordedBody | undefined;
43
+ readonly responseBody?: RecordedBody | undefined;
44
+ readonly fault?: ProxyFault | undefined;
45
+ }): ProxyRequestRecord;
46
+ /**
47
+ * The headers to send upstream: the client's, less hop-by-hop headers, with `host` set to Testserver's and the
48
+ * test id header set to `testId`, replacing any the client sent.
49
+ */
50
+ export declare function upstreamHeaders(headers: IncomingHttpHeaders, upstream: {
51
+ readonly host: string;
52
+ readonly testIdHeader: string;
53
+ readonly testId: string;
54
+ }): Record<string, string | string[]>;
55
+ /** `headers` less hop-by-hop headers and unset values. */
56
+ export declare function forwardableHeaders(headers: IncomingHttpHeaders): Record<string, string | string[]>;
@@ -0,0 +1,56 @@
1
+ import { headerText, splitTarget, } from "../records/index.js";
2
+ /** The header the `vercel` CLI sends with the same id on every request of one invocation. */
3
+ export const SESSION_ID_HEADER = "x-vercel-cli-session-id";
4
+ /** Whether `record`'s exchange was still open when it was read. */
5
+ export function isOpenRecord(record) {
6
+ return "open" in record;
7
+ }
8
+ /** The record of a request with `method`, `target` and `headers` whose exchange stands as `outcome`. */
9
+ export function proxyRecord(request) {
10
+ const userAgent = headerText(request.headers["user-agent"]);
11
+ const sessionId = headerText(request.headers[SESSION_ID_HEADER]);
12
+ return {
13
+ method: request.method,
14
+ url: request.target,
15
+ ...splitTarget(request.target),
16
+ authorization: request.headers.authorization !== undefined,
17
+ ...(userAgent === undefined ? {} : { userAgent }),
18
+ ...(sessionId === undefined ? {} : { sessionId }),
19
+ ...(request.requestBody === undefined ? {} : { requestBody: request.requestBody }),
20
+ ...(request.responseBody === undefined ? {} : { responseBody: request.responseBody }),
21
+ ...(request.fault === undefined ? {} : { fault: request.fault }),
22
+ startedAt: request.startedAt,
23
+ durationMs: request.durationMs,
24
+ ...request.outcome,
25
+ };
26
+ }
27
+ /** Headers that describe one connection, not the message, so the proxy never forwards them. */
28
+ const HOP_BY_HOP = new Set([
29
+ "connection",
30
+ "keep-alive",
31
+ "proxy-authenticate",
32
+ "proxy-authorization",
33
+ "proxy-connection",
34
+ "te",
35
+ "trailer",
36
+ "upgrade",
37
+ ]);
38
+ /**
39
+ * The headers to send upstream: the client's, less hop-by-hop headers, with `host` set to Testserver's and the
40
+ * test id header set to `testId`, replacing any the client sent.
41
+ */
42
+ export function upstreamHeaders(headers, upstream) {
43
+ const forwarded = forwardableHeaders(headers);
44
+ forwarded["host"] = upstream.host;
45
+ forwarded[upstream.testIdHeader] = upstream.testId;
46
+ return forwarded;
47
+ }
48
+ /** `headers` less hop-by-hop headers and unset values. */
49
+ export function forwardableHeaders(headers) {
50
+ const forwarded = {};
51
+ for (const [name, value] of Object.entries(headers)) {
52
+ if (value !== undefined && !HOP_BY_HOP.has(name))
53
+ forwarded[name] = value;
54
+ }
55
+ return forwarded;
56
+ }
@@ -0,0 +1,89 @@
1
+ import type { IncomingHttpHeaders } from "node:http";
2
+ /**
3
+ * The most bytes of a body a request record keeps, as sent and after decompressing; a bigger one is noted, not
4
+ * kept.
5
+ */
6
+ export declare const RECORDED_BODY_CAP_BYTES: number;
7
+ /** A request or response body as a request record holds it: the proxy's, or an API request's. */
8
+ export type RecordedBody =
9
+ /** A body whose `content-type` is JSON, or absent, decoded. */
10
+ {
11
+ readonly kind: "json";
12
+ readonly value: unknown;
13
+ }
14
+ /** An `application/x-www-form-urlencoded` body; a key given more than once maps to every value, in order. */
15
+ | {
16
+ readonly kind: "form";
17
+ readonly fields: Readonly<Record<string, string | readonly string[]>>;
18
+ }
19
+ /** A `text/*` or XML body, or a JSON one that doesn't parse. */
20
+ | {
21
+ readonly kind: "text";
22
+ readonly text: string;
23
+ }
24
+ /**
25
+ * A body kept only as a note: how many bytes were sent, and why it wasn't kept. `too-deep` is a JSON body nested
26
+ * more than 64 levels deep.
27
+ */
28
+ | {
29
+ readonly kind: "omitted";
30
+ readonly reason: OmittedReason;
31
+ readonly bytes: number;
32
+ readonly contentType?: string;
33
+ };
34
+ type OmittedReason = "binary" | "too-large" | "too-deep" | "undecodable" | "incomplete";
35
+ /** What a body is recorded as in place of a token. */
36
+ export declare const REDACTED = "<token>";
37
+ /** Collects a body as it streams through, keeping at most `RECORDED_BODY_CAP_BYTES` of it. */
38
+ export declare class BodyCapture {
39
+ #private;
40
+ push(chunk: Uint8Array): void;
41
+ /** The whole body, decoded by `headers`; `undefined` when it was empty. */
42
+ complete(headers: IncomingHttpHeaders, bearer: string | undefined): RecordedBody | undefined;
43
+ /** A body that broke off partway; `undefined` when none of it arrived. */
44
+ incomplete(headers: IncomingHttpHeaders): RecordedBody | undefined;
45
+ }
46
+ /**
47
+ * A request or response body as a record keeps it: decoded by `headers`, capped, and redacted with the request's own
48
+ * bearer token. The body was `bytes` bytes long, and `kept` holds all of it unless it was over
49
+ * `RECORDED_BODY_CAP_BYTES`, when it is ignored. `undefined` for an empty body. The proxy's `BodyCapture` and an API
50
+ * request's whole body both come through here.
51
+ */
52
+ export declare function recordedBody(kept: Uint8Array, bytes: number, headers: IncomingHttpHeaders, bearer: string | undefined): RecordedBody | undefined;
53
+ /**
54
+ * The record of a body of `bytes` bytes sent with `headers`. `raw` is the body as sent, or `undefined` when it was
55
+ * over the cap. Decompresses gzip, deflate and br, then decodes by `content-type`.
56
+ */
57
+ export declare function decodeBody(raw: Uint8Array | undefined, bytes: number, headers: IncomingHttpHeaders): RecordedBody;
58
+ /**
59
+ * `body` with every token field's string value, directly or inside arrays, replaced by `<token>`, and `bearer`, the
60
+ * request's own bearer token, replaced wherever it appears. An object under a token field is redacted like any
61
+ * other. Expects a body from `decodeBody`, whose JSON nesting is bounded; `recordedBody` composes the two.
62
+ */
63
+ export declare function redactBody(body: RecordedBody, bearer: string | undefined): RecordedBody;
64
+ /**
65
+ * `value` with every token field's string value, directly or inside arrays, replaced by `<token>`, as a JSON body's
66
+ * are in a record. An object under a token field is redacted like any other. For printing a value no record holds,
67
+ * such as a factory call's input or response.
68
+ */
69
+ export declare function redactTokenFields(value: unknown): unknown;
70
+ /**
71
+ * Every non-empty string under a token field in `value`, directly or inside arrays, as `redactBody` would replace
72
+ * it. An object under a token field is searched like any other. Looks no deeper than `RECORDED_BODY_MAX_DEPTH` levels.
73
+ */
74
+ export declare function tokenSecrets(value: unknown): Set<string>;
75
+ /**
76
+ * `text` with every one of `secrets` replaced by `<token>` wherever it appears, longest first, so a secret that holds
77
+ * another is replaced whole. An empty secret is skipped. A container's `redact` and the Vercel CLI driver's use it.
78
+ */
79
+ export declare function redactSecrets(text: string, secrets: Iterable<string>): string;
80
+ /** The bearer token in an `authorization` header, such as `Bearer abc`, or `undefined`. */
81
+ export declare function bearerToken(authorization: string | undefined): string | undefined;
82
+ /**
83
+ * Parsed search params; a key given more than once maps to every value, in order. Collects into a `Map` so a key
84
+ * such as `__proto__` becomes a plain own property.
85
+ */
86
+ export declare function parseParams(params: URLSearchParams): Record<string, string | string[]>;
87
+ /** A header's value as one string, a repeated header's values joined with `, `. */
88
+ export declare function headerText(value: string | readonly string[] | undefined): string | undefined;
89
+ export {};