@preventive/triage 1.0.0-alpha.8 → 1.0.0-alpha.81

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 (442) hide show
  1. package/LICENSE-APACHE +202 -0
  2. package/README.md +16 -0
  3. package/api/reap.ts +16 -78
  4. package/cli.js +6 -0
  5. package/client/dependency-paths.d.ts +3 -0
  6. package/client/dependency-paths.js +36 -0
  7. package/client/finding-link.js +305 -0
  8. package/client/linked-findings.d.ts +1 -0
  9. package/client/linked-findings.js +115 -0
  10. package/common/bundle-commit.d.ts +1 -0
  11. package/common/bundle-commit.js +4 -0
  12. package/common/bundle-compare-diff.d.ts +6 -0
  13. package/common/bundle-compare-diff.js +377 -0
  14. package/common/bundle-compare-inputs.d.ts +3 -0
  15. package/common/bundle-compare-inputs.js +141 -0
  16. package/common/bundle-compare-versions.js +172 -0
  17. package/common/bundle-comparison.d.ts +8 -0
  18. package/common/bundle-comparison.js +69 -0
  19. package/common/bundle-imports.js +20 -0
  20. package/common/bundle-metadata.d.ts +15 -0
  21. package/common/bundle-metadata.js +226 -0
  22. package/common/bundle-pkg-of.d.ts +1 -0
  23. package/common/bundle-pkg-of.js +90 -0
  24. package/common/bundle-reasons.d.ts +6 -0
  25. package/common/bundle-reasons.js +58 -0
  26. package/common/bundle-source-links.d.ts +6 -0
  27. package/common/bundle-source-links.js +216 -0
  28. package/common/bundle-sourcemap.d.ts +10 -0
  29. package/common/bundle-sourcemap.js +100 -0
  30. package/common/bundle-sources.d.ts +10 -0
  31. package/common/bundle-sources.js +374 -0
  32. package/common/bundle-stats.js +41 -0
  33. package/common/bundle-tabs.js +1 -0
  34. package/common/code-language.js +66 -0
  35. package/common/default-scan-models.ts +36 -0
  36. package/common/dependency-reviews.d.ts +18 -0
  37. package/common/dependency-reviews.js +64 -0
  38. package/common/finding-duplicates.js +63 -0
  39. package/common/finding-filters.js +313 -0
  40. package/common/finding-id.js +47 -0
  41. package/common/finding-repo.d.ts +5 -0
  42. package/common/finding-repo.js +67 -0
  43. package/common/github-issue-labels.d.ts +1 -0
  44. package/common/github-issue-labels.js +11 -0
  45. package/common/github-pr.ts +56 -0
  46. package/common/gzip.js +59 -0
  47. package/common/line-diff.d.ts +14 -0
  48. package/common/line-diff.js +181 -0
  49. package/common/linked-workspace-groups.js +63 -0
  50. package/common/managed/agent-tasks.ts +292 -0
  51. package/common/managed/comments.ts +43 -0
  52. package/common/managed/dependency-routes.js +25 -0
  53. package/common/managed/directory-packages.ts +28 -0
  54. package/common/managed/finding-detail.d.ts +5 -0
  55. package/common/managed/finding-detail.js +75 -0
  56. package/common/managed/finding-values.d.ts +2 -0
  57. package/common/managed/finding-values.js +138 -0
  58. package/common/managed/github-agents.ts +114 -0
  59. package/common/managed/github-logins.ts +49 -0
  60. package/common/managed/lite-name.d.ts +2 -0
  61. package/common/managed/lite-name.js +20 -0
  62. package/common/managed/npm-packages.d.ts +9 -0
  63. package/common/managed/npm-packages.js +63 -0
  64. package/common/managed/permissions.ts +31 -0
  65. package/common/managed/report-content.ts +72 -0
  66. package/common/managed/report-filter.ts +120 -0
  67. package/common/managed/repository-alias.ts +65 -0
  68. package/common/managed/review-view-routes.js +23 -0
  69. package/common/managed/risk-routes.js +30 -0
  70. package/common/managed/roles.ts +41 -0
  71. package/common/managed/routes.d.ts +2 -0
  72. package/common/managed/routes.js +385 -0
  73. package/common/managed/scan-models.ts +6 -0
  74. package/common/managed/stasis-config.ts +7 -0
  75. package/common/managed/team-app.d.ts +19 -0
  76. package/common/managed/team-app.js +129 -0
  77. package/common/managed/team-filters.js +26 -0
  78. package/common/managed/triage.ts +83 -0
  79. package/common/managed/upload-seal.ts +126 -0
  80. package/common/pretty-json.js +98 -0
  81. package/common/pretty-kinds.js +20 -0
  82. package/common/pretty-print.d.ts +6 -0
  83. package/common/pretty-print.js +36 -0
  84. package/common/pretty-sourcemap.js +70 -0
  85. package/common/repo-commit.d.ts +4 -0
  86. package/common/repo-commit.js +30 -0
  87. package/common/revalidation-conflicts.js +48 -0
  88. package/common/revalidation-input-groups.js +56 -0
  89. package/common/save-error-reason.ts +20 -7
  90. package/common/scan-server.ts +13 -0
  91. package/common/security-links.d.ts +5 -0
  92. package/common/security-links.js +33 -0
  93. package/common/server-info.ts +46 -0
  94. package/common/sourcemap-listing.js +78 -0
  95. package/common/sourcemap-mappings.js +136 -0
  96. package/common/sourcemap-unlist.js +85 -0
  97. package/common/stasis-files.d.ts +5 -0
  98. package/common/stasis-files.js +20 -0
  99. package/common/stasis-tgz.d.ts +6 -0
  100. package/common/stasis-tgz.js +27 -0
  101. package/common/utf8.d.ts +3 -0
  102. package/common/utf8.js +45 -0
  103. package/common/whitespace-insensitive.js +19 -0
  104. package/common/workspace-app.js +91 -0
  105. package/common/workspace-groups.js +176 -0
  106. package/out/activity.js +2 -0
  107. package/out/brotli-fallback.js +3 -3
  108. package/out/chunk-2XUEZHIP.js +28 -0
  109. package/out/chunk-55YIWY3H.js +5 -0
  110. package/out/chunk-563V5VVT.js +266 -0
  111. package/out/chunk-5AVGKFMR.js +1 -0
  112. package/out/chunk-5EAVJAD2.js +3 -0
  113. package/out/chunk-5M2X3QPK.js +6 -0
  114. package/out/chunk-5QWPKTCE.js +40 -0
  115. package/out/chunk-5UJHJWFU.js +4 -0
  116. package/out/chunk-6CCSTJWB.js +1 -0
  117. package/out/chunk-6VOB5WXX.js +2 -0
  118. package/out/chunk-6WMQVUT2.js +3 -0
  119. package/out/chunk-6Y6PZ2BU.js +9 -0
  120. package/out/chunk-74JZTGTO.js +11 -0
  121. package/out/chunk-7BKKYVWR.js +7 -0
  122. package/out/chunk-7C7DWL7I.js +1 -0
  123. package/out/chunk-7HP2VYIC.js +2 -0
  124. package/out/chunk-7YFJUT2P.js +1 -0
  125. package/out/chunk-7YO4QV5P.js +1 -0
  126. package/out/chunk-A4BBBHQU.js +1 -0
  127. package/out/chunk-B64CTMVU.js +4 -0
  128. package/out/chunk-BEKYZCPX.js +14 -0
  129. package/out/chunk-C4Z6ZBXV.js +10 -0
  130. package/out/chunk-CU3FPB3P.js +1 -0
  131. package/out/chunk-DEVAORP2.js +1 -0
  132. package/out/chunk-DOYTKRIR.js +53 -0
  133. package/out/chunk-DUASGS2O.js +8 -0
  134. package/out/chunk-EEJA7JBI.js +13 -0
  135. package/out/chunk-FSU2PLJL.js +1 -0
  136. package/out/chunk-GO7FT4OD.js +1 -0
  137. package/out/chunk-GX5UXWT4.js +1 -0
  138. package/out/chunk-H4FEC57K.js +1 -0
  139. package/out/chunk-ITUKKCCK.js +10 -0
  140. package/out/chunk-IYPY47MC.js +1 -0
  141. package/out/chunk-K4XJHM2T.js +1 -0
  142. package/out/chunk-LBD3M3J6.js +1 -0
  143. package/out/chunk-LVSLM7HB.js +1 -0
  144. package/out/chunk-LVW7WWV4.js +1 -0
  145. package/out/chunk-N57OWFKY.js +15 -0
  146. package/out/chunk-NRPC74AM.js +1 -0
  147. package/out/chunk-OAWQNDAO.js +3 -0
  148. package/out/chunk-OOJM4CTU.js +1 -0
  149. package/out/chunk-PEE47ANR.js +1 -0
  150. package/out/chunk-PKLVXUEI.js +11 -0
  151. package/out/chunk-PLGH63UC.js +2 -0
  152. package/out/chunk-PNHBZGDD.js +1 -0
  153. package/out/chunk-PTFYDJUP.js +1 -0
  154. package/out/chunk-PWFUOLZK.js +17 -0
  155. package/out/chunk-PXK7EU4V.js +1 -0
  156. package/out/chunk-QD3IBSF4.js +7 -0
  157. package/out/chunk-QI66YA4F.js +1 -0
  158. package/out/chunk-QRKFPLA4.js +80 -0
  159. package/out/chunk-R3NZFXVR.js +1 -0
  160. package/out/chunk-R5O6FAW4.js +2 -0
  161. package/out/chunk-RPNO56H2.js +1 -0
  162. package/out/chunk-SSPDMA6D.js +1 -0
  163. package/out/chunk-SZWPYLPC.js +1 -0
  164. package/out/chunk-TUII34K2.js +1 -0
  165. package/out/chunk-UJP4PQJA.js +1 -0
  166. package/out/chunk-UJSJMXEG.js +1 -0
  167. package/out/chunk-UR4WYMIP.js +1 -0
  168. package/out/chunk-VHEXSGGP.js +1 -0
  169. package/out/chunk-VYYUMYVW.js +9 -0
  170. package/out/chunk-WCDYSIKG.js +1 -0
  171. package/out/chunk-WFBVS4QI.js +1 -0
  172. package/out/chunk-XM4RLC4A.js +2 -0
  173. package/out/chunk-ZQHLECTI.js +1 -0
  174. package/out/client-managed-import.js +4 -0
  175. package/out/client-managed.js +37 -0
  176. package/out/client-sync.js +11 -17
  177. package/out/compare.js +26 -0
  178. package/out/dialogs.js +40 -0
  179. package/out/github-issue-authorized.html +3 -0
  180. package/out/github-issue-authorized.js +1 -0
  181. package/out/graph.js +19 -4
  182. package/out/index.html +104 -24
  183. package/out/prism.js +14 -10
  184. package/out/scan.js +2 -0
  185. package/out/stasis.svg +20 -0
  186. package/out/terminal.js +367 -39
  187. package/out/view.css +1 -1
  188. package/out/view.js +19 -147
  189. package/package.json +409 -64
  190. package/risk/actions/findings.js +161 -0
  191. package/risk/actions/resolve.js +287 -0
  192. package/risk/actions/scripts/commands.js +182 -0
  193. package/risk/actions/scripts/grade.js +113 -0
  194. package/risk/actions/scripts/packages.js +123 -0
  195. package/risk/actions/scripts/shell.js +169 -0
  196. package/risk/actions/uses.js +94 -0
  197. package/risk/actions/workflow.js +183 -0
  198. package/risk/files/characters.js +354 -0
  199. package/risk/files/hosts.js +206 -0
  200. package/risk/files/readability.js +185 -0
  201. package/risk/files/runs-code.js +568 -0
  202. package/risk/files/script.js +410 -0
  203. package/risk/files/source-map-link.js +43 -0
  204. package/risk/files/stamps.js +47 -0
  205. package/risk/index.d.ts +294 -0
  206. package/risk/index.js +12 -0
  207. package/risk/npm/assess.js +285 -0
  208. package/risk/npm/combined.js +68 -0
  209. package/risk/npm/compare.js +236 -0
  210. package/risk/npm/dependencies.js +172 -0
  211. package/risk/npm/diff.js +79 -0
  212. package/risk/npm/downloads.js +84 -0
  213. package/risk/npm/files.js +445 -0
  214. package/risk/npm/held.js +67 -0
  215. package/risk/npm/install-scripts.js +34 -0
  216. package/risk/npm/malware.js +38 -0
  217. package/risk/npm/manifest.js +65 -0
  218. package/risk/npm/new-dependency.js +60 -0
  219. package/risk/npm/old-version.js +108 -0
  220. package/risk/npm/registry.js +393 -0
  221. package/risk/npm/release.js +85 -0
  222. package/risk/npm/score.js +59 -0
  223. package/risk/npm/specs.js +124 -0
  224. package/risk/npm/tarball.js +169 -0
  225. package/server-common/database-config.ts +16 -0
  226. package/server-common/initialize.ts +18 -0
  227. package/server-common/npm-advisories.ts +101 -0
  228. package/{server → server-common}/origin.ts +5 -5
  229. package/server-common/reap.ts +48 -0
  230. package/server-common/scan-config.ts +19 -0
  231. package/server-common/standalone.ts +29 -0
  232. package/server-common/storage-crypto.ts +182 -0
  233. package/server-common/storage-log.ts +38 -0
  234. package/server-common/vercel-blob.ts +103 -0
  235. package/server-e2e/app.ts +487 -0
  236. package/{server → server-e2e}/bus-receiver.ts +2 -1
  237. package/{server → server-e2e}/cli.js +9 -4
  238. package/{server → server-e2e}/config.ts +50 -42
  239. package/{server → server-e2e}/db-neon.ts +2 -2
  240. package/{server → server-e2e}/db-revision-sql.ts +1 -1
  241. package/{server → server-e2e}/db-stmt.ts +2 -2
  242. package/{server → server-e2e}/db.ts +7 -7
  243. package/{server → server-e2e}/http.ts +44 -13
  244. package/{server → server-e2e}/hub.ts +40 -9
  245. package/server-e2e/index.ts +17 -0
  246. package/server-e2e/lifecycle.ts +95 -0
  247. package/{server → server-e2e}/neon-driver.ts +2 -2
  248. package/{server → server-e2e}/npm-proxy.ts +12 -145
  249. package/{server → server-e2e}/objstore/blob-vercel.ts +10 -114
  250. package/{server → server-e2e}/objstore/blob.ts +1 -1
  251. package/{server → server-e2e}/objstore/fetch-mint-guard.ts +2 -2
  252. package/{server → server-e2e}/objstore/handlers.ts +9 -8
  253. package/{server → server-e2e}/objstore/init.ts +19 -27
  254. package/{server → server-e2e}/objstore/reaper.ts +1 -1
  255. package/{server → server-e2e}/objstore/rest-deny.ts +1 -1
  256. package/{server → server-e2e}/objstore/rest-mint.ts +3 -3
  257. package/{server → server-e2e}/objstore/rest.ts +3 -3
  258. package/{server → server-e2e}/objstore/store-neon.ts +6 -10
  259. package/{server → server-e2e}/objstore/store.ts +7 -7
  260. package/{server → server-e2e}/objstore/tokens.ts +2 -2
  261. package/{server → server-e2e}/pubsub.ts +12 -9
  262. package/{server → server-e2e}/sign.ts +4 -4
  263. package/{server → server-e2e}/sse-server.ts +60 -33
  264. package/{server → server-e2e}/static.ts +18 -17
  265. package/{server → server-e2e}/sync-handlers.ts +64 -30
  266. package/{server → server-e2e}/ws-server.ts +20 -9
  267. package/server-managed/activity.ts +269 -0
  268. package/server-managed/agent-merges.ts +109 -0
  269. package/server-managed/app-agents.ts +23 -0
  270. package/server-managed/avatar-store.ts +13 -0
  271. package/server-managed/blob-store.ts +26 -0
  272. package/server-managed/brotli.ts +10 -0
  273. package/server-managed/bundle-advisories.ts +79 -0
  274. package/server-managed/bundle-advisory-inventory.ts +85 -0
  275. package/server-managed/bundle-build-diagnostics.d.ts +10 -0
  276. package/server-managed/bundle-build-diagnostics.js +23 -0
  277. package/server-managed/bundle-build-leases.ts +41 -0
  278. package/server-managed/bundle-build-worker.js +380 -0
  279. package/server-managed/bundle-build.ts +326 -0
  280. package/server-managed/bundle-cache.ts +261 -0
  281. package/server-managed/bundle-catalog.ts +29 -0
  282. package/server-managed/bundle-commits.ts +133 -0
  283. package/server-managed/bundle-dependency-reviews.ts +91 -0
  284. package/server-managed/bundle-store.ts +24 -0
  285. package/server-managed/bundle-summary-cache.ts +139 -0
  286. package/server-managed/bundle-validation.ts +33 -0
  287. package/server-managed/bundle.ts +151 -0
  288. package/server-managed/cache-storage.ts +20 -0
  289. package/server-managed/cli.js +21 -0
  290. package/server-managed/combined.ts +43 -0
  291. package/server-managed/comments.ts +138 -0
  292. package/server-managed/commit-coauthors.ts +105 -0
  293. package/server-managed/commit-lockfiles.ts +78 -0
  294. package/server-managed/comparison.ts +51 -0
  295. package/server-managed/config.ts +163 -0
  296. package/server-managed/content-access.ts +15 -0
  297. package/server-managed/crypto.ts +25 -0
  298. package/server-managed/db-methods.ts +1915 -0
  299. package/server-managed/db-neon.ts +398 -0
  300. package/server-managed/db-schema.ts +263 -0
  301. package/server-managed/db-table-names.ts +22 -0
  302. package/server-managed/db.ts +149 -0
  303. package/server-managed/dependabot-access.ts +61 -0
  304. package/server-managed/dependabot-alerts.ts +180 -0
  305. package/server-managed/dependency-review-comments.ts +158 -0
  306. package/server-managed/dependency-reviews.ts +369 -0
  307. package/server-managed/github-accounts.ts +59 -0
  308. package/server-managed/github-actions.ts +71 -0
  309. package/server-managed/github-app.ts +347 -0
  310. package/server-managed/github-errors.ts +92 -0
  311. package/server-managed/github-graphql.ts +42 -0
  312. package/server-managed/github-issue-links.ts +264 -0
  313. package/server-managed/github-issue-oauth.ts +30 -0
  314. package/server-managed/github-issues.ts +157 -0
  315. package/server-managed/github-link-oauth.ts +56 -0
  316. package/server-managed/github-links.ts +204 -0
  317. package/server-managed/github-metadata.ts +213 -0
  318. package/server-managed/github-oauth.ts +264 -0
  319. package/server-managed/github-pulls.ts +257 -0
  320. package/server-managed/github-requests.ts +181 -0
  321. package/server-managed/github-users.ts +30 -0
  322. package/server-managed/github-values.ts +26 -0
  323. package/server-managed/history-windows.ts +172 -0
  324. package/server-managed/http-response.ts +76 -0
  325. package/server-managed/http.ts +6327 -0
  326. package/server-managed/import-triage.ts +51 -0
  327. package/server-managed/index.ts +204 -0
  328. package/server-managed/kept-briefly.ts +37 -0
  329. package/server-managed/kept.ts +28 -0
  330. package/server-managed/link-reports.ts +149 -0
  331. package/server-managed/listed-activity.ts +39 -0
  332. package/server-managed/locked-packages.ts +234 -0
  333. package/server-managed/lockfile-scope.ts +58 -0
  334. package/server-managed/lru.ts +30 -0
  335. package/server-managed/managed-issues.ts +92 -0
  336. package/server-managed/management-catalog.ts +45 -0
  337. package/server-managed/management.ts +116 -0
  338. package/server-managed/npm-delta-worker.js +142 -0
  339. package/server-managed/npm-delta.ts +277 -0
  340. package/server-managed/npm-insights.ts +455 -0
  341. package/server-managed/npm-kept.ts +265 -0
  342. package/server-managed/npm-loads.ts +259 -0
  343. package/server-managed/npm-manifest.ts +117 -0
  344. package/server-managed/npm-packages.ts +469 -0
  345. package/server-managed/npm-patch-paths.ts +86 -0
  346. package/server-managed/npm-patch.ts +455 -0
  347. package/server-managed/npm-provenance.ts +127 -0
  348. package/server-managed/npm-risk.ts +287 -0
  349. package/server-managed/object-storage-disk.ts +147 -0
  350. package/server-managed/object-storage-vercel.ts +71 -0
  351. package/server-managed/object-storage.ts +82 -0
  352. package/server-managed/package-entry-points.ts +127 -0
  353. package/server-managed/pretty-copies.ts +22 -0
  354. package/server-managed/pretty-format.d.ts +3 -0
  355. package/server-managed/pretty-format.js +13 -0
  356. package/server-managed/pretty-print.ts +442 -0
  357. package/server-managed/public-workspace.ts +243 -0
  358. package/server-managed/pull-comment-reviews.ts +161 -0
  359. package/server-managed/pull-dependencies.ts +370 -0
  360. package/server-managed/pull-dependency-reviews.ts +407 -0
  361. package/server-managed/pull-reviews.ts +202 -0
  362. package/server-managed/queue.ts +54 -0
  363. package/server-managed/release-commits.ts +85 -0
  364. package/server-managed/rename-diff-worker.js +30 -0
  365. package/server-managed/rename-diff.ts +237 -0
  366. package/server-managed/repo-path.ts +21 -0
  367. package/server-managed/report-migration.ts +32 -0
  368. package/server-managed/report-opening.ts +77 -0
  369. package/server-managed/report-query.ts +10 -0
  370. package/server-managed/report-response.ts +16 -0
  371. package/server-managed/report-sources.ts +185 -0
  372. package/server-managed/report-store.ts +77 -0
  373. package/server-managed/repository-actions.ts +220 -0
  374. package/server-managed/repository-agents.ts +422 -0
  375. package/server-managed/repository-aliases.ts +119 -0
  376. package/server-managed/repository-browser.ts +361 -0
  377. package/server-managed/repository-changes.ts +280 -0
  378. package/server-managed/repository-code.ts +222 -0
  379. package/server-managed/repository-dependency-reviews.ts +182 -0
  380. package/server-managed/repository-discovery.ts +83 -0
  381. package/server-managed/repository-history.ts +428 -0
  382. package/server-managed/repository-issues.ts +293 -0
  383. package/server-managed/repository-policy.ts +27 -0
  384. package/server-managed/repository-pulls.ts +207 -0
  385. package/server-managed/repository-pulse.ts +477 -0
  386. package/server-managed/repository-risk-assess.ts +108 -0
  387. package/server-managed/repository-risk-audit.ts +78 -0
  388. package/server-managed/repository-risk-caches.ts +37 -0
  389. package/server-managed/repository-risk-read.ts +260 -0
  390. package/server-managed/repository-risk-stasis.ts +61 -0
  391. package/server-managed/repository-risk-turn.ts +97 -0
  392. package/server-managed/repository-risk.ts +516 -0
  393. package/server-managed/repository-squashes.ts +160 -0
  394. package/server-managed/repository-stamp.ts +41 -0
  395. package/server-managed/request-timing.ts +63 -0
  396. package/server-managed/reviewed-dependencies.ts +170 -0
  397. package/server-managed/revisions.ts +35 -0
  398. package/server-managed/scan-downloads.ts +121 -0
  399. package/server-managed/session.ts +132 -0
  400. package/server-managed/slugs.ts +38 -0
  401. package/server-managed/solidity-entry-points.ts +71 -0
  402. package/server-managed/sql-postgres.ts +34 -0
  403. package/server-managed/sql.ts +107 -0
  404. package/server-managed/stasis-config.ts +147 -0
  405. package/server-managed/stasis-dependencies.ts +221 -0
  406. package/server-managed/static.ts +28 -0
  407. package/server-managed/storage-command.ts +16 -0
  408. package/server-managed/storage-db.ts +183 -0
  409. package/server-managed/storage-encryption.ts +288 -0
  410. package/server-managed/storage-maintenance.ts +259 -0
  411. package/server-managed/storage-payload.ts +121 -0
  412. package/server-managed/storage-stores.ts +91 -0
  413. package/server-managed/storage.ts +82 -0
  414. package/server-managed/team-app-summaries.ts +56 -0
  415. package/server-managed/team-app.ts +156 -0
  416. package/server-managed/team-catalog.ts +7 -0
  417. package/server-managed/team-feed.ts +180 -0
  418. package/server-managed/team-npm-scopes.ts +103 -0
  419. package/server-managed/team-reports.ts +368 -0
  420. package/server-managed/triage-response.ts +16 -0
  421. package/server-managed/type-only-proof.js +161 -0
  422. package/server-managed/type-only-worker.js +31 -0
  423. package/server-managed/type-only.ts +135 -0
  424. package/server-managed/uploads.ts +106 -0
  425. package/server-managed/upstream-cache.ts +256 -0
  426. package/server-managed/view-as.ts +58 -0
  427. package/server-managed/worker-turns.ts +76 -0
  428. package/server-managed/workspace-shares.ts +170 -0
  429. package/server.ts +70 -0
  430. package/strip-types-loader.js +13 -10
  431. package/server/index.ts +0 -480
  432. package/server/lifecycle.ts +0 -208
  433. /package/{LICENSE → LICENSE-MIT} +0 -0
  434. /package/{server → server-e2e}/auth.ts +0 -0
  435. /package/{server → server-e2e}/config.example.json +0 -0
  436. /package/{server → server-e2e}/objstore/blob-fs.ts +0 -0
  437. /package/{server → server-e2e}/objstore/fs.ts +0 -0
  438. /package/{server → server-e2e}/objstore/sign.ts +0 -0
  439. /package/{server → server-e2e}/peer.ts +0 -0
  440. /package/{server → server-e2e}/sse-session.ts +0 -0
  441. /package/{server → server-e2e}/util.ts +0 -0
  442. /package/{server → server-e2e}/validation.ts +0 -0
@@ -0,0 +1,370 @@
1
+ // The package versions a pull request's lockfiles lock that they didn't
2
+ // before it, as the code viewer's Pull requests tab shows them on an open
3
+ // one's tile and its popup on any (GET
4
+ // /api/admin/repositories/pull-dependencies): read only where it changes a
5
+ // lockfile of npm's ecosystem that @preventive/lockfile reads
6
+ // (package-lock.json and npm-shrinkwrap.json of `lockfileVersion: 3`,
7
+ // pnpm-lock.yaml of pnpm 9 to 12 and Yarn 1's yarn.lock, locked-packages.ts),
8
+ // and Bun's, which it doesn't (bun.lock and bun.lockb, its directory told
9
+ // `lockfile-unsupported`); none under a node_modules nor a test's fixtures
10
+ // (isTestFixture), which no install takes. Its files are GitHub's comparison of its base with its head
11
+ // (GET /repos/:owner/:repo/compare/:base...:head), which names where its
12
+ // branch left its base, its merge base, as GitHub's own Files changed
13
+ // compares from it, and lists as many as a commit's files are read
14
+ // (repository-changes.ts MAX_FILES, 300, the most it lists); one changing as
15
+ // many, from its own list of them, a page at a time, as many as PULL_FILES.
16
+ // Each directory's lockfiles it changes are read at its merge base and at its
17
+ // head, a lockfile replaced by another, Yarn's by pnpm's say, read as the
18
+ // one it replaced; a version new to a directory is one its lockfiles lock at
19
+ // the head that none of them locked at the merge base, from where it is
20
+ // installed: a package new to it, or a version of one they locked others of,
21
+ // a bump's, told with those (`was`). What a pair of commits holds never
22
+ // changes, so what is told of one is kept by them (`kept`), and each
23
+ // lockfile read is kept in this instance's memory by its commit
24
+ // (`lockfileReads`): the pull requests branching off the same commit, as a
25
+ // bot's do, read their base's once. One read as a commit lists it, with its
26
+ // blob's id (commit-lockfiles.ts), is kept by its blob instead, and beyond
27
+ // this instance where its reader keeps it (LockfileStore): what a blob holds
28
+ // never changes either, and a push changing no lockfile changes none.
29
+ import { createClient } from '@preventive/upstream/github.js'
30
+ import { GithubApiError, upstreamGithub } from './github-errors.ts'
31
+ import { USER_AGENT, githubJson, repoApi } from './github-requests.ts'
32
+ import { branchName } from './bundle-build.ts'
33
+ import { SHA } from './github-values.ts'
34
+ import { compareVersions, isExactVersion } from '@preventive/upstream/semver.js'
35
+ import { type LockedPackage, isTestFixture, lockedPackages, patchedIn } from './locked-packages.ts'
36
+ import { isStasisConfig } from './lockfile-scope.ts'
37
+ import { type Lru, lru } from './lru.ts'
38
+ import { eachOf } from './queue.ts'
39
+ import { type ChangedFile, commitChanges } from './repository-changes.ts'
40
+
41
+ // The files of a pull request read from its own list past those compared,
42
+ // FILES_PAGE a page, as many as GitHub lists (3,000).
43
+ const FILES_PAGE = 100
44
+ const PULL_FILES = 3000
45
+ // The directories whose lockfiles are read, those past them left out
46
+ // (`cut`), and the packages told new of each, those past them counted.
47
+ export const MAX_DIRECTORIES = 20
48
+ export const MAX_ADDED = 200
49
+ // The versions a directory's lockfiles lock at the head kept with what they
50
+ // add, as many as MAX_LOCKED, those past them counted, for those not new to
51
+ // be reviewed as well (pull-dependency-reviews.ts).
52
+ export const MAX_LOCKED = 20_000
53
+ // Lockfiles read at once.
54
+ const READ_PARALLEL = 4
55
+ // The rules what is told was told by, kept with it (http.ts
56
+ // pullDependencyKept), and the lockfiles read for it (lockfileKept): one
57
+ // told or read by others is told or read again, as those read before pnpm's
58
+ // patches' files were, and those told before their lockfiles' directories,
59
+ // or read with the files of patches pnpm 9 names by an md5.
60
+ export const PULL_DEPENDENCIES_READ = 6
61
+
62
+ type Format = 'npm' | 'pnpm' | 'yarn' | 'bun'
63
+
64
+ // The format of the lockfile of npm's ecosystem at `path`, as
65
+ // findRepoLockfiles names it (with pnpm's of a branch,
66
+ // pnpm-lock.<branch>.yaml, and of before pnpm 3, shrinkwrap.yaml, which its
67
+ // reader refuses); null for another file, and for one under a node_modules or
68
+ // of a test's fixtures. Bun's alone isn't read.
69
+ export function lockfileFormat(path: string): Format | null {
70
+ const dirs = path.split('/')
71
+ const name = dirs.pop() ?? ''
72
+ if (dirs.includes('node_modules') || isTestFixture(path)) return null
73
+ if (name === 'package-lock.json' || name === 'npm-shrinkwrap.json') return 'npm'
74
+ if (/^pnpm-lock(?:\..+)?\.yaml$/u.test(name) || name === 'shrinkwrap.yaml') return 'pnpm'
75
+ if (name === 'bun.lock' || name === 'bun.lockb') return 'bun'
76
+ return name === 'yarn.lock' ? 'yarn' : null
77
+ }
78
+
79
+ // Whether a pull request changing `paths` changes a lockfile read here, or
80
+ // a stasis.config.json, which a review may hold to: null where none of them
81
+ // is one but they are fewer than it changes (`changed`), which it may yet.
82
+ export function touchesLockfile(paths: string[], changed: number): boolean | null {
83
+ if (paths.some(path => lockfileFormat(path) !== null || isStasisConfig(path))) return true
84
+ return changed > paths.length ? null : false
85
+ }
86
+
87
+ // A package version new to a directory, as its lockfile locks it, with its
88
+ // integrity, which its reviews are held to; of a package its lockfiles locked
89
+ // before, the versions of it they did (`was`, the highest first), none of one
90
+ // new to it; and the version the host names to review it against (`base`).
91
+ export type AddedPackage = LockedPackage & { was?: string[]; base?: { name: string; version: string } }
92
+ // A directory's lockfiles the pull request changes (`paths`, those it adds,
93
+ // modifies, removes or renames, by either name): the package versions they
94
+ // lock new to it, by name and version (as many as MAX_LOCKED, told as many
95
+ // as MAX_ADDED, `more` past them), and all they lock (`locked`, as many as MAX_LOCKED, how many more
96
+ // `moreLocked`); or why they couldn't be told, a lockfile's reader refusing one
97
+ // (`lockfile-unreadable`, with what it said), one of a format not read
98
+ // (`lockfile-unsupported`, Bun's) or GitHub having none at a commit compared.
99
+ // A stasis.config.json a review holds to is told as one too, by its own path
100
+ // (stasis-dependencies.ts stasisDirectory), or as `stasis-pending` or `stasis-failed`.
101
+ export type DirectoryDependencies = { paths: string[]; builds?: StasisBuild[] } & ({ added: AddedPackage[]; more: number; locked: LockedPackage[]; moreLocked: number }
102
+ | { error: string; detail?: string })
103
+ // A Stasis build a stasis.config.json's directory reads (stasis-dependencies.ts
104
+ // stasisDirectory): of the commit, and whether it is made, or failed, as kept.
105
+ export interface StasisBuild { commit: string; built: boolean }
106
+ // What a pull request's lockfiles add: the commits compared (`base`, its
107
+ // merge base, and `head`); each directory's, of those it changes a lockfile
108
+ // in; and `cut` where it changes more files than GitHub lists, or lockfiles
109
+ // in more directories than are read, with, where only those cut it and they
110
+ // are few enough, the paths of those directories' lockfiles (`omitted`), for
111
+ // a review holding to none of them to fail in nothing; and whether it was
112
+ // read without its merge base (`baseless`), every version new to it.
113
+ export interface PullDependencies { base: string; head: string; lockfiles: DirectoryDependencies[]; cut: boolean; omitted?: string[]; baseless?: true }
114
+ const MAX_OMITTED = 1000
115
+
116
+ // What is told of a pull request, by the commits it is of, `${base}...${head}`,
117
+ // read without its merge base apart (pullKey).
118
+ export const pullKey = (commits: string, baseless: boolean) => baseless ? `${commits}\0baseless` : commits
119
+ export interface PullDependencyStore {
120
+ read(key: string): Promise<PullDependencies | null>
121
+ write(key: string, value: PullDependencies): Promise<void>
122
+ }
123
+
124
+ // A lockfile's packages, or why its reader refused it, by its repository and
125
+ // readKey, read in this instance; by the packages each holds, as the scan's
126
+ // are (repository-risk.ts riskCaches).
127
+ export type LockfileRead = { packages: LockedPackage[] } | { error: string; detail?: string }
128
+ const lockfileReads: Lru<LockfileRead> = lru(200_000, read => 'packages' in read ? read.packages.length + 1 : 1)
129
+ // Those being read, by the token reading them too, lest each asking at once
130
+ // read them, with whether GitHub was asked.
131
+ const lockfilesReading = new Map<string, Promise<{ read: LockfileRead; github: boolean }>>()
132
+ // A lockfile at a commit as findRepoLockfiles lists it, by its path, with its
133
+ // format (lockfileFormat) and its blob's id (`sha`).
134
+ export interface ListedLockfile { path: string; format: Format; sha: string }
135
+ // What a repository's lockfiles read for its dependency review keep beyond
136
+ // this instance (http.ts lockfileKept), by what never changes: a commit's
137
+ // lockfiles as listed (`listings`, by the commit), and a lockfile's read
138
+ // (`lockfiles`, by its readKey). A read GitHub failed is kept nowhere.
139
+ export interface LockfileStore {
140
+ listings: { read(commit: string): Promise<ListedLockfile[] | null>; write(commit: string, listed: ListedLockfile[]): Promise<void> }
141
+ lockfiles: { read(key: string): Promise<LockfileRead | null>; write(key: string, read: LockfileRead): Promise<void> }
142
+ }
143
+ // Set where GitHub was asked for what a read reads (`github`), not all of it
144
+ // held in this instance or kept beyond it.
145
+ export interface GithubAsked { github: boolean }
146
+
147
+ // A lockfile's read, by its blob where it is listed with its id (`sha`),
148
+ // which with its format alone tell how it reads; else by the commit and its
149
+ // path.
150
+ const readKey = (ref: string, { path, format, sha }: { path: string; format: Format; sha?: string }) =>
151
+ sha ? `blob\0${format}\0${sha}` : `commit\0${ref}\0${path}`
152
+
153
+ // The pull request's base's and head's commits, as GitHub has them now: its
154
+ // base's moving on as it does, its head's with each push, both kept once it
155
+ // is merged or closed. With the branches they are of, where told: its base's
156
+ // (`baseRef`), whose history holds its merge base, and its head's
157
+ // (`headRef`) where that is the repository's own, not a fork's; and that an
158
+ // open one's head is a fork's (`fork`), a commit of none of the repository's
159
+ // branches till it is merged, which Stasis builds nothing of.
160
+ export interface PullRefs { baseRef?: string; headRef?: string; fork?: true }
161
+ export interface PullCommits extends PullRefs { base: string; head: string }
162
+ // Those of `base` and `head` that are a branch's name, and `fork` where it is told.
163
+ export const pullRefs = (base: unknown, head: unknown, fork?: unknown): PullRefs =>
164
+ ({ ...branchName(base) ? { baseRef: base } : {}, ...branchName(head) ? { headRef: head } : {}, ...fork === true ? { fork } : {} })
165
+ async function pullCommits(fullName: string, token: string, number: number, fetchImpl: typeof fetch): Promise<PullCommits> {
166
+ const pull = await githubJson(`${repoApi(fullName)}/pulls/${number}`, token, fetchImpl) as
167
+ { number?: unknown; state?: unknown; base?: { sha?: unknown; ref?: unknown; repo?: { full_name?: unknown } | null }
168
+ head?: { sha?: unknown; ref?: unknown; repo?: { full_name?: unknown } | null } } | null
169
+ const base = pull?.base?.sha, head = pull?.head?.sha, repo = pull?.base?.repo?.full_name
170
+ if (pull?.number !== number || typeof base !== 'string' || !SHA.test(base) || typeof head !== 'string' || !SHA.test(head)
171
+ || typeof repo !== 'string' || repo.toLowerCase() !== fullName.toLowerCase()) throw new GithubApiError(502, 'github-malformed')
172
+ const from = pull.head?.repo?.full_name
173
+ const own = typeof from === 'string' && from.toLowerCase() === repo.toLowerCase()
174
+ return { base, head, ...pullRefs(pull.base?.ref, own ? pull.head?.ref : undefined, pull.state === 'open' && !own) }
175
+ }
176
+
177
+ // The pull request's merge base and the files it changes from it: as GitHub
178
+ // compares its base with its head, else, where that lists as many as it lists
179
+ // at most, from the pull request's own list, a page at a time; `cut` where
180
+ // that lists as many as it lists at most, too. That list is of its commits
181
+ // now: null where they are no longer `base` and `head` (`current`).
182
+ async function pullFiles(fullName: string, token: string, number: number, base: string, head: string, fetchImpl: typeof fetch,
183
+ current: () => Promise<boolean>) {
184
+ const compared = await githubJson(`${repoApi(fullName)}/compare/${base}...${head}?per_page=1`, token, fetchImpl) as { merge_base_commit?: { sha?: unknown } } | null
185
+ const mergeBase = compared?.merge_base_commit?.sha
186
+ if (typeof mergeBase !== 'string' || !SHA.test(mergeBase)) throw new GithubApiError(502, 'github-malformed')
187
+ const { files, more } = commitChanges(compared)
188
+ if (!more) return { mergeBase, files, cut: false }
189
+ if (!await current()) return null
190
+ const listed: ChangedFile[] = []
191
+ for (let page = 1; listed.length < PULL_FILES; page++) {
192
+ const data = await githubJson(`${repoApi(fullName)}/pulls/${number}/files?per_page=${FILES_PAGE}&page=${page}`, token, fetchImpl)
193
+ if (!Array.isArray(data)) throw new GithubApiError(502, 'github-malformed')
194
+ listed.push(...commitChanges({ files: data }).files)
195
+ if (data.length < FILES_PAGE) return { mergeBase, files: listed, cut: false }
196
+ }
197
+ return { mergeBase, files: listed, cut: true }
198
+ }
199
+
200
+ // The lockfiles read here a pull request changes (`files`), by directory:
201
+ // each as it was (`before`, one modified or removed, or a rename's path
202
+ // before) and as it is (`after`, one added or modified, or a rename's path
203
+ // now), and every path of them (`paths`), as many directories as
204
+ // MAX_DIRECTORIES.
205
+ function lockfilesChanged(files: ChangedFile[]) {
206
+ type Directory = { before: { path: string; format: Format }[]; after: { path: string; format: Format }[]; paths: Set<string> }
207
+ const directories = new Map<string, Directory>()
208
+ const take = (side: 'before' | 'after', path: string | undefined) => {
209
+ const format = path ? lockfileFormat(path) : null
210
+ if (!path || !format) return
211
+ const dir = path.slice(0, Math.max(path.lastIndexOf('/'), 0))
212
+ const directory = directories.get(dir) ?? directories.set(dir, { before: [], after: [], paths: new Set() }).get(dir)!
213
+ directory[side].push({ path, format })
214
+ directory.paths.add(path)
215
+ }
216
+ for (const [path, status, from] of files) {
217
+ take('before', status === 'R' ? from : status === 'A' ? undefined : path)
218
+ take('after', status === 'D' ? undefined : path)
219
+ }
220
+ const all = [...directories.entries()].toSorted(([a], [b]) => a < b ? -1 : a > b ? 1 : 0)
221
+ return { directories: all.slice(0, MAX_DIRECTORIES).map(([, directory]) => directory), cut: all.length > MAX_DIRECTORIES,
222
+ omitted: all.slice(MAX_DIRECTORIES).flatMap(([, directory]) => [...directory.paths]).toSorted() }
223
+ }
224
+
225
+ // The text of the file at `path` of repository `fullName` at `ref`; null
226
+ // where GitHub has none there.
227
+ export async function repositoryFile(fullName: string, token: string, path: string, ref: string): Promise<string | null> {
228
+ try { return await upstreamGithub(() => createClient({ token, userAgent: USER_AGENT }).getRepoFile({ repo: fullName, path, ref })) } catch (err) {
229
+ if (err instanceof GithubApiError && err.message === 'github-not-found') return null
230
+ throw err
231
+ }
232
+ }
233
+
234
+ // A lockfile's packages at `ref`, as read in this instance, else as kept
235
+ // beyond it (`kept`), else shared with a read of it with the same token still
236
+ // under way, else of GitHub, and kept; a lockfile its reader refuses, why,
237
+ // kept as well, its reader refusing it again; `asked` told where GitHub was.
238
+ // Any failure to read it of GitHub but its having none there is the whole
239
+ // answer's, as it would be every file's; neither is kept.
240
+ export async function readLockfile(fullName: string, token: string, ref: string, lockfile: { path: string; format: Format; sha?: string },
241
+ kept: LockfileStore | null = null, asked?: GithubAsked): Promise<LockfileRead> {
242
+ if (lockfile.format === 'bun') return { error: 'lockfile-unsupported' }
243
+ const key = readKey(ref, lockfile)
244
+ const known = lockfileReads.get(`${fullName}\0${key}`)
245
+ if (known) return known
246
+ const shared = `${token}\0${fullName}\0${key}`
247
+ const reading = lockfilesReading.get(shared) ?? readOf(fullName, token, ref, lockfile, key, kept).finally(() => lockfilesReading.delete(shared))
248
+ lockfilesReading.set(shared, reading)
249
+ // One failing was asked of GitHub too, though a caller swallows its
250
+ // failure, as a baseline's does: its access is asked again all the same.
251
+ let told
252
+ try { told = await reading } catch (err) {
253
+ if (asked) asked.github = true
254
+ throw err
255
+ }
256
+ if (told.github && asked) asked.github = true
257
+ return told.read
258
+ }
259
+ async function readOf(fullName: string, token: string, ref: string, { path, format }: { path: string; format: Format }, key: string,
260
+ kept: LockfileStore | null): Promise<{ read: LockfileRead; github: boolean }> {
261
+ const stored = await kept?.lockfiles.read(key)
262
+ if (stored) { lockfileReads.set(`${fullName}\0${key}`, stored); return { read: stored, github: false } }
263
+ const text = await repositoryFile(fullName, token, path, ref)
264
+ if (text === null) return { read: { error: 'github-not-found' }, github: true }
265
+ let read: LockfileRead
266
+ try { read = { packages: lockedPackages(format, text, { review: true }) } } catch (error) {
267
+ read = { error: 'lockfile-unreadable', ...error instanceof Error ? { detail: error.message.slice(0, 500) } : {} }
268
+ }
269
+ lockfileReads.set(`${fullName}\0${key}`, read)
270
+ await kept?.lockfiles.write(key, read)
271
+ return { read, github: true }
272
+ }
273
+
274
+ // Versions by semver, the highest first, any semver can't read after them.
275
+ function byVersion(a: string, b: string) {
276
+ const [exactA, exactB] = [isExactVersion(a), isExactVersion(b)]
277
+ if (exactA && exactB) return compareVersions(b, a)
278
+ if (exactA === exactB) return a < b ? -1 : a > b ? 1 : 0
279
+ return exactA ? -1 : 1
280
+ }
281
+ const byName = (a: AddedPackage, b: AddedPackage) => a.name < b.name ? -1 : a.name > b.name ? 1 : -byVersion(a.version ?? '', b.version ?? '')
282
+ // A package as it is installed: its name and version, where from, and its
283
+ // patch, a patched version's new where its patch is; and as it is locked,
284
+ // with what its reviews are held to too.
285
+ export const lockedAs = (pkg: LockedPackage) => `${pkg.source}\0${pkg.name}@${pkg.version ?? ''}\0${pkg.from ?? ''}\0${pkg.patchHash ?? ''}`
286
+ export const lockedWith = (pkg: LockedPackage) => `${lockedAs(pkg)}\0${pkg.integrity ?? ''}\0${pkg.shasum ?? ''}\0${pkg.lockfile ?? ''}`
287
+
288
+ // What a directory's lockfiles add, from each read before and after
289
+ // (addedBetween), each patch's file from the repository's root, and its
290
+ // lockfile's directory (patchedIn); or the first failure among them.
291
+ function addedIn(paths: string[], before: LockfileRead[], after: LockfileRead[]): DirectoryDependencies {
292
+ const failed = [...before, ...after].find(read => 'error' in read)
293
+ if (failed) return { paths, error: failed.error, ...failed.detail ? { detail: failed.detail } : {} }
294
+ const packages = (reads: LockfileRead[]) => reads.flatMap(read => 'packages' in read ? read.packages : [])
295
+ return addedBetween(paths, packages(before), packages(after).map(pkg => patchedIn(paths[0]!, pkg)))
296
+ }
297
+
298
+ // What the versions locked `after` add to those locked `before`, as a
299
+ // directory's lockfiles' at `paths`: the package versions after none before
300
+ // has, each once, by name and version, each with the versions of its name
301
+ // before, those past MAX_ADDED counted (`more`), not told but reviewed as
302
+ // they are; and every one after, each integrity it is locked with
303
+ // (`locked`), as many as MAX_LOCKED.
304
+ export function addedBetween(paths: string[], before: LockedPackage[], after: LockedPackage[]): DirectoryDependencies {
305
+ const known = new Set<string>()
306
+ const versions = new Map<string, Set<string>>()
307
+ for (const pkg of before) {
308
+ known.add(lockedAs(pkg))
309
+ const of = versions.get(pkg.name) ?? versions.set(pkg.name, new Set()).get(pkg.name)!
310
+ if (pkg.version) of.add(pkg.version)
311
+ }
312
+ const added = new Map<string, AddedPackage>()
313
+ const locked = new Map<string, LockedPackage>()
314
+ for (const pkg of after) {
315
+ const key = lockedAs(pkg)
316
+ const held = locked.get(lockedWith(pkg))
317
+ if (!held) locked.set(lockedWith(pkg), { ...pkg })
318
+ else if (held.dev && !pkg.dev) delete held.dev
319
+ if (known.has(key)) continue
320
+ const had = added.get(key)
321
+ const was = versions.get(pkg.name)
322
+ if (!had) added.set(key, { ...pkg, ...was ? { was: [...was].toSorted(byVersion) } : {} })
323
+ else if (had.dev && !pkg.dev) delete had.dev
324
+ }
325
+ const all = [...added.values()].toSorted(byName)
326
+ return { paths, added: all.slice(0, MAX_LOCKED), more: Math.max(0, all.length - MAX_ADDED),
327
+ locked: [...locked.values()].slice(0, MAX_LOCKED), moreLocked: Math.max(0, locked.size - MAX_LOCKED) }
328
+ }
329
+
330
+ // What pull request `number` adds to its lockfiles' packages (PullDependencies),
331
+ // kept by its base's and head's commits, else read of GitHub and kept; none
332
+ // where it changes no lockfile read here.
333
+ export async function pullDependencies(fullName: string, token: string, number: number, kept: PullDependencyStore,
334
+ fetchImpl: typeof fetch = globalThis.fetch): Promise<PullDependencies> {
335
+ return (await pullDependenciesAt(fullName, token, number, kept, fetchImpl)).told
336
+ }
337
+ // The same, with the commits it is kept by (`commits`), its base's and
338
+ // head's, by which `kept` reads it (pullKey): those `given`, as a page of its
339
+ // repository's open pull requests read them (repository-issues.ts), else as
340
+ // GitHub has them now; and the branches they are of, where told (PullRefs).
341
+ // Commits given that its own list of its files is no longer of are read as
342
+ // GitHub has them now. One into branch `baselessInto` is read without its
343
+ // merge base's lockfiles (`baseless`).
344
+ export async function pullDependenciesAt(fullName: string, token: string, number: number, kept: PullDependencyStore,
345
+ fetchImpl: typeof fetch = globalThis.fetch, given?: PullCommits, baselessInto: string | null = null): Promise<PullRefs & { commits: string; told: PullDependencies }> {
346
+ const { base, head, ...refs } = given ?? await pullCommits(fullName, token, number, fetchImpl)
347
+ const baseless = baselessInto !== null && refs.baseRef === baselessInto, commits = `${base}...${head}`, key = pullKey(commits, baseless)
348
+ const held = await kept.read(key)
349
+ if (held) return { ...refs, commits, told: held }
350
+ const current = async () => {
351
+ const now = given && await pullCommits(fullName, token, number, fetchImpl)
352
+ return !now || (now.base === base && now.head === head)
353
+ }
354
+ const pulled = await pullFiles(fullName, token, number, base, head, fetchImpl, current)
355
+ if (!pulled) return pullDependenciesAt(fullName, token, number, kept, fetchImpl, undefined, baselessInto)
356
+ const { mergeBase, files, cut: filesCut } = pulled
357
+ const { directories, cut, omitted } = lockfilesChanged(files)
358
+ const reads = directories.flatMap(({ before, after }) => [...baseless ? [] : before.map(lockfile => [mergeBase, lockfile] as const),
359
+ ...after.map(lockfile => [head, lockfile] as const)])
360
+ const read = await eachOf(reads, READ_PARALLEL, ([ref, lockfile]) => readLockfile(fullName, token, ref, lockfile))
361
+ let at = 0
362
+ const lockfiles = directories.map(({ before, after, paths }) => {
363
+ const readBefore = baseless ? [] : read.slice(at, at += before.length)
364
+ return addedIn([...paths].toSorted(), readBefore, read.slice(at, at += after.length))
365
+ })
366
+ const told = { base: mergeBase, head, lockfiles, cut: filesCut || cut, ...cut && !filesCut && omitted.length <= MAX_OMITTED ? { omitted } : {},
367
+ ...baseless ? { baseless: true as const } : {} }
368
+ await kept.write(key, told)
369
+ return { ...refs, commits, told }
370
+ }