@ref0/git 0.12.0 → 0.20.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 (436) hide show
  1. package/dist/access/private-refs.mjs +3 -3
  2. package/dist/auth/access-jwt.mjs +2 -2
  3. package/dist/auth/auth.d.mts +2 -2
  4. package/dist/auth/auth.mjs +3 -6
  5. package/dist/auth/authorize.mjs +4 -20
  6. package/dist/auth/fences.d.mts +1 -2
  7. package/dist/auth/fences.mjs +3 -3
  8. package/dist/auth/grants.mjs +4 -4
  9. package/dist/auth/helpers.mjs +3 -11
  10. package/dist/auth/host-function.mjs +18 -1
  11. package/dist/auth/host-services.mjs +11 -0
  12. package/dist/auth/identify.d.mts +1 -1
  13. package/dist/auth/identify.mjs +3 -3
  14. package/dist/auth/policy.d.mts +27 -7
  15. package/dist/auth/policy.mjs +8 -4
  16. package/dist/auth/token-cleanup.mjs +67 -0
  17. package/dist/auth/token-rows.mjs +1 -1
  18. package/dist/auth/token-text.mjs +9 -1
  19. package/dist/auth/tokens-base.d.mts +35 -0
  20. package/dist/auth/tokens-base.mjs +13 -0
  21. package/dist/auth/tokens-layer.d.mts +2 -28
  22. package/dist/auth/tokens-layer.mjs +6 -12
  23. package/dist/auth/tokens-public.d.mts +3 -3
  24. package/dist/auth/tokens.d.mts +7 -17
  25. package/dist/auth/tokens.mjs +9 -87
  26. package/dist/auth.d.mts +1 -4
  27. package/dist/auth.mjs +1 -3
  28. package/dist/client/answer.mjs +21 -42
  29. package/dist/client/client.d.mts +2 -4
  30. package/dist/client/git-http.mjs +35 -11
  31. package/dist/client/local.mjs +14 -13
  32. package/dist/client/push-upload.mjs +39 -12
  33. package/dist/client/remote.mjs +95 -31
  34. package/dist/client/run-remote-helper.d.mts +1 -0
  35. package/dist/client/run-remote-helper.mjs +58 -24
  36. package/dist/client/slice-push.d.mts +1 -1
  37. package/dist/client/transport.mjs +105 -46
  38. package/dist/contracts/access.d.mts +8 -8
  39. package/dist/contracts/actors.d.mts +2 -34
  40. package/dist/contracts/blobs.d.mts +57 -10
  41. package/dist/contracts/blobs.mjs +16 -2
  42. package/dist/contracts/call-allowance.d.mts +13 -0
  43. package/dist/contracts/call-allowance.mjs +44 -0
  44. package/dist/contracts/calls-spent.mjs +8 -3
  45. package/dist/contracts/client.d.mts +23 -19
  46. package/dist/contracts/commits.d.mts +34 -26
  47. package/dist/contracts/commits.mjs +9 -1
  48. package/dist/contracts/engine.d.mts +6 -1
  49. package/dist/contracts/engine.mjs +10 -1
  50. package/dist/contracts/files.d.mts +12 -12
  51. package/dist/contracts/forks.d.mts +27 -17
  52. package/dist/contracts/git-events.d.mts +29 -1
  53. package/dist/contracts/git-hooks.d.mts +1 -1
  54. package/dist/contracts/git.d.mts +39 -7
  55. package/dist/contracts/git.mjs +3 -2
  56. package/dist/contracts/grants.d.mts +24 -4
  57. package/dist/contracts/handlers.d.mts +1 -1
  58. package/dist/contracts/lfs.d.mts +28 -9
  59. package/dist/contracts/merges.d.mts +3 -2
  60. package/dist/contracts/objects.d.mts +103 -35
  61. package/dist/contracts/operations.d.mts +3 -0
  62. package/dist/contracts/operations.mjs +12 -2
  63. package/dist/contracts/push-uploads.d.mts +44 -5
  64. package/dist/contracts/push-uploads.mjs +7 -3
  65. package/dist/contracts/queue.d.mts +40 -12
  66. package/dist/contracts/queue.mjs +3 -4
  67. package/dist/contracts/refs.d.mts +50 -25
  68. package/dist/contracts/remote.d.mts +6 -7
  69. package/dist/contracts/remote.mjs +5 -4
  70. package/dist/contracts/repo-records.d.mts +1 -0
  71. package/dist/contracts/repos.d.mts +106 -127
  72. package/dist/contracts/repos.mjs +33 -4
  73. package/dist/contracts/result.d.mts +49 -25
  74. package/dist/contracts/result.mjs +52 -11
  75. package/dist/contracts/rules.d.mts +22 -22
  76. package/dist/contracts/server.d.mts +37 -111
  77. package/dist/contracts/services.d.mts +1 -1
  78. package/dist/contracts/signin.d.mts +1 -1
  79. package/dist/contracts/store.d.mts +6 -5
  80. package/dist/contracts/sync.d.mts +90 -26
  81. package/dist/contracts/sync.mjs +45 -11
  82. package/dist/contracts/tags.d.mts +10 -10
  83. package/dist/contracts/time.d.mts +3 -0
  84. package/dist/contracts/{promises.mjs → time.mjs} +1 -1
  85. package/dist/contracts/tokens.d.mts +15 -22
  86. package/dist/contracts/tokens.mjs +3 -3
  87. package/dist/contracts/topics.d.mts +1 -6
  88. package/dist/contracts/trees.d.mts +12 -12
  89. package/dist/contracts/work.d.mts +87 -12
  90. package/dist/contracts/work.mjs +8 -1
  91. package/dist/core/access.d.mts +1 -2
  92. package/dist/core/access.mjs +46 -13
  93. package/dist/core/ancestry.d.mts +10 -0
  94. package/dist/core/ancestry.mjs +6 -6
  95. package/dist/core/asked.mjs +43 -5
  96. package/dist/core/call-names.mjs +7 -1
  97. package/dist/core/call-services.mjs +13 -4
  98. package/dist/core/events/deliver.d.mts +1 -2
  99. package/dist/core/events/deliver.mjs +48 -33
  100. package/dist/core/events/retired.mjs +119 -0
  101. package/dist/core/forks.mjs +931 -435
  102. package/dist/core/hooks/groups.mjs +1 -1
  103. package/dist/core/imports.mjs +159 -15
  104. package/dist/core/index-job.mjs +128 -37
  105. package/dist/core/index-lost.d.mts +1 -2
  106. package/dist/core/index-lost.mjs +2 -2
  107. package/dist/core/job-view.mjs +8 -9
  108. package/dist/core/loose-tally.mjs +1 -1
  109. package/dist/core/mirror-rows.mjs +19 -4
  110. package/dist/core/objects/blobs.mjs +129 -3
  111. package/dist/core/objects/commits.mjs +16 -6
  112. package/dist/core/objects/lines.mjs +2 -2
  113. package/dist/core/objects/merges.mjs +4 -1
  114. package/dist/core/objects/objects-layer.d.mts +1 -1
  115. package/dist/core/objects/objects-layer.mjs +3 -3
  116. package/dist/core/objects/reading.mjs +24 -13
  117. package/dist/core/objects/tags.mjs +4 -1
  118. package/dist/core/objects/trees.mjs +2 -2
  119. package/dist/core/objects/writing.mjs +2 -2
  120. package/dist/core/own-writes.mjs +1 -1
  121. package/dist/core/parts.d.mts +10 -6
  122. package/dist/core/parts.mjs +3 -11
  123. package/dist/core/promise.mjs +9 -12
  124. package/dist/core/purge.mjs +316 -42
  125. package/dist/core/push-decide.mjs +3 -1
  126. package/dist/core/push-files.d.mts +12 -0
  127. package/dist/core/push-files.mjs +225 -0
  128. package/dist/core/push-repo.d.mts +8 -0
  129. package/dist/core/push-repo.mjs +56 -0
  130. package/dist/core/push.d.mts +17 -0
  131. package/dist/core/push.mjs +153 -70
  132. package/dist/core/receipts.mjs +34 -13
  133. package/dist/core/ref-index-job.mjs +4 -4
  134. package/dist/core/ref-view.mjs +61 -7
  135. package/dist/core/refs.mjs +18 -13
  136. package/dist/core/registered-rows.mjs +2 -2
  137. package/dist/core/repack.mjs +46 -28
  138. package/dist/core/repo-info.mjs +19 -12
  139. package/dist/core/repos.mjs +50 -22
  140. package/dist/core/rules/commit-changes.d.mts +0 -1
  141. package/dist/core/saved-caller-views.d.mts +7 -2
  142. package/dist/core/saved-caller-views.mjs +2 -2
  143. package/dist/core/saved-callers.d.mts +19 -2
  144. package/dist/core/seam.d.mts +16 -26
  145. package/dist/core/seam.mjs +7 -28
  146. package/dist/core/tokens.mjs +1 -1
  147. package/dist/core/view.d.mts +6 -0
  148. package/dist/core/view.mjs +51 -26
  149. package/dist/core/work.mjs +105 -35
  150. package/dist/effect.d.mts +5 -12
  151. package/dist/effect.mjs +3 -10
  152. package/dist/engine/failures.mjs +2 -1
  153. package/dist/engine/reads.mjs +17 -10
  154. package/dist/engine/walk.mjs +4 -4
  155. package/dist/event-streams/event-streams.d.mts +1 -1
  156. package/dist/event-streams/event-streams.mjs +1 -1
  157. package/dist/event-streams/stream.d.mts +3 -3
  158. package/dist/event-streams/stream.mjs +38 -15
  159. package/dist/extend.d.mts +4 -5
  160. package/dist/extend.mjs +3 -2
  161. package/dist/http/answers.mjs +12 -7
  162. package/dist/http/core-parts.mjs +129 -64
  163. package/dist/http/handler.mjs +36 -9
  164. package/dist/http/node.d.mts +14 -1
  165. package/dist/http/node.mjs +61 -31
  166. package/dist/http/parts.d.mts +2 -0
  167. package/dist/http/push-upload-job.mjs +507 -0
  168. package/dist/http/push-uploads.d.mts +1 -0
  169. package/dist/http/push-uploads.mjs +142 -69
  170. package/dist/http/upload-pack.mjs +10 -9
  171. package/dist/index.d.mts +27 -28
  172. package/dist/index.mjs +5 -8
  173. package/dist/lfs/answer.mjs +37 -0
  174. package/dist/lfs/base.d.mts +9 -3
  175. package/dist/lfs/base.mjs +27 -2
  176. package/dist/lfs/copy.d.mts +60 -0
  177. package/dist/lfs/copy.mjs +109 -0
  178. package/dist/lfs/layer.d.mts +15 -1
  179. package/dist/lfs/layer.mjs +28 -13
  180. package/dist/lfs/locks.mjs +2 -2
  181. package/dist/lfs/objects.d.mts +7 -0
  182. package/dist/lfs/objects.mjs +152 -55
  183. package/dist/lfs/pointers.mjs +2 -2
  184. package/dist/lfs/rows.d.mts +13 -0
  185. package/dist/lfs/rows.mjs +42 -8
  186. package/dist/lfs/service.d.mts +1 -7
  187. package/dist/lfs/service.mjs +1 -9
  188. package/dist/lfs/upkeep.mjs +48 -14
  189. package/dist/lfs/upload-most.mjs +5 -5
  190. package/dist/lfs/wire.mjs +6 -31
  191. package/dist/merges/merges.mjs +2 -2
  192. package/dist/node.d.mts +3 -3
  193. package/dist/protocol/bytes/buffers.mjs +13 -5
  194. package/dist/protocol/bytes/reader.mjs +6 -1
  195. package/dist/protocol/bytes/sha256-hasher.d.mts +15 -0
  196. package/dist/protocol/bytes/sha256.d.mts +32 -0
  197. package/dist/protocol/bytes/sha256.mjs +105 -49
  198. package/dist/protocol/bytes/streams.mjs +27 -1
  199. package/dist/protocol/diff/read.d.mts +4 -3
  200. package/dist/protocol/diff/read.mjs +8 -3
  201. package/dist/protocol/objects/lfs-pointer.d.mts +14 -2
  202. package/dist/protocol/objects/lfs-pointer.mjs +1 -3
  203. package/dist/protocol/objects/links-raw.mjs +24 -10
  204. package/dist/protocol/objects/tag.d.mts +1 -1
  205. package/dist/protocol/objects/tree.mjs +23 -6
  206. package/dist/protocol/packs/delta.d.mts +6 -3
  207. package/dist/protocol/packs/delta.mjs +96 -32
  208. package/dist/protocol/packs/idx.d.mts +2 -1
  209. package/dist/protocol/packs/idx.mjs +22 -3
  210. package/dist/protocol/packs/parts.d.mts +4 -1
  211. package/dist/protocol/packs/parts.mjs +10 -7
  212. package/dist/protocol/packs/reader.d.mts +5 -0
  213. package/dist/protocol/packs/reader.mjs +3 -2
  214. package/dist/protocol/packs/writer.mjs +26 -8
  215. package/dist/protocol/wire/advertisement.mjs +9 -4
  216. package/dist/protocol/wire/lines.d.mts +4 -2
  217. package/dist/protocol/wire/lines.mjs +11 -5
  218. package/dist/protocol/wire/push-uploads.mjs +13 -1
  219. package/dist/protocol/wire/v2.mjs +2 -2
  220. package/dist/protocol.d.mts +3 -1
  221. package/dist/protocol.mjs +3 -1
  222. package/dist/queue/advance.mjs +22 -25
  223. package/dist/queue/base.d.mts +55 -0
  224. package/dist/queue/base.mjs +44 -0
  225. package/dist/queue/calls.mjs +51 -54
  226. package/dist/queue/commit.mjs +1 -1
  227. package/dist/queue/host.d.mts +2 -22
  228. package/dist/queue/host.mjs +2 -13
  229. package/dist/queue/layer.d.mts +2 -1
  230. package/dist/queue/layer.mjs +11 -4
  231. package/dist/queue/limits.mjs +2 -0
  232. package/dist/queue/push-option.mjs +9 -24
  233. package/dist/queue/schedule.mjs +1 -1
  234. package/dist/queue/state.mjs +2 -10
  235. package/dist/queue/trim.mjs +6 -4
  236. package/dist/rest/blobs.mjs +29 -5
  237. package/dist/rest/caller.d.mts +4 -4231
  238. package/dist/rest/caller.mjs +5 -1
  239. package/dist/rest/client.d.mts +15 -5
  240. package/dist/rest/client.mjs +23 -2
  241. package/dist/rest/events.mjs +1 -2
  242. package/dist/rest/handler.mjs +4 -57
  243. package/dist/rest/handlers.mjs +68 -9
  244. package/dist/rest/layer.d.mts +2 -2
  245. package/dist/rest/layer.mjs +7 -13
  246. package/dist/rest/me.d.mts +3 -428
  247. package/dist/rest/paths.mjs +1 -0
  248. package/dist/rest/work.mjs +8 -0
  249. package/dist/server/check-fetch.mjs +3 -3
  250. package/dist/server/edge-node.d.mts +14 -15
  251. package/dist/server/edge-node.mjs +12 -12
  252. package/dist/server/edge.d.mts +21 -7
  253. package/dist/server/edge.mjs +32 -11
  254. package/dist/server/extension.mjs +1 -1
  255. package/dist/server/git-layer.d.mts +6 -11
  256. package/dist/server/git-layer.mjs +29 -23
  257. package/dist/server/git-namespace.d.mts +5 -4
  258. package/dist/server/git-namespace.mjs +3 -2
  259. package/dist/server/joined.d.mts +21 -40
  260. package/dist/server/joined.mjs +11 -62
  261. package/dist/server/lifecycle.mjs +65 -69
  262. package/dist/server/registry.mjs +28 -3
  263. package/dist/server/server.mjs +245 -465
  264. package/dist/signin/context.d.mts +1 -2
  265. package/dist/signin/layer.d.mts +1 -1
  266. package/dist/signin/layer.mjs +1 -1
  267. package/dist/storage/allotted.mjs +18 -3
  268. package/dist/storage/batch-upkeep.mjs +274 -0
  269. package/dist/{core/purge.d.mts → storage/batches.d.mts} +4 -4
  270. package/dist/storage/batches.mjs +344 -0
  271. package/dist/storage/budget.mjs +2 -2
  272. package/dist/storage/calls.d.mts +1 -2
  273. package/dist/storage/calls.mjs +144 -158
  274. package/dist/storage/chunks.d.mts +9 -0
  275. package/dist/storage/chunks.mjs +297 -0
  276. package/dist/storage/clean-up.mjs +85 -19
  277. package/dist/storage/counted-bucket.mjs +4 -4
  278. package/dist/storage/fetch.d.mts +1 -0
  279. package/dist/storage/fetch.mjs +298 -216
  280. package/dist/storage/file-limits.mjs +24 -0
  281. package/dist/storage/host-bucket.mjs +1 -2
  282. package/dist/storage/id-mix.mjs +19 -5
  283. package/dist/storage/index-bitmaps.mjs +9 -2
  284. package/dist/storage/index-build.d.mts +1 -1
  285. package/dist/storage/index-build.mjs +185 -84
  286. package/dist/storage/index-fetch.mjs +128 -74
  287. package/dist/storage/index-files.d.mts +3 -0
  288. package/dist/storage/index-files.mjs +10 -5
  289. package/dist/storage/index-graph.mjs +72 -22
  290. package/dist/storage/index-reach.mjs +33 -5
  291. package/dist/storage/index-remap.mjs +208 -65
  292. package/dist/storage/index-shallow.mjs +5 -3
  293. package/dist/storage/index-whole.mjs +127 -0
  294. package/dist/storage/largest-files.mjs +48 -0
  295. package/dist/storage/layout.mjs +23 -0
  296. package/dist/storage/lfs-pointers.mjs +10 -1
  297. package/dist/storage/loose.d.mts +7 -4
  298. package/dist/storage/loose.mjs +214 -67
  299. package/dist/storage/memory-budget.mjs +44 -8
  300. package/dist/storage/merge-plan.mjs +3 -2
  301. package/dist/storage/merge-row.mjs +7 -1
  302. package/dist/storage/merge-stream.mjs +164 -25
  303. package/dist/storage/merge-walk.mjs +8 -4
  304. package/dist/storage/merge-write.mjs +1 -1
  305. package/dist/storage/merge.d.mts +1 -1
  306. package/dist/storage/merge.mjs +1 -1
  307. package/dist/storage/object-rows.d.mts +1 -0
  308. package/dist/storage/object-rows.mjs +385 -65
  309. package/dist/storage/oid-table.mjs +171 -0
  310. package/dist/storage/pack-order.mjs +8 -4
  311. package/dist/storage/pack-ranges.d.mts +1 -2
  312. package/dist/storage/pack-ranges.mjs +4 -5
  313. package/dist/storage/pack-reads.d.mts +2 -1
  314. package/dist/storage/pack-reads.mjs +165 -49
  315. package/dist/storage/pack-receive.d.mts +1 -1
  316. package/dist/storage/pack-receive.mjs +85 -27
  317. package/dist/storage/packs.d.mts +1 -1
  318. package/dist/storage/packs.mjs +172 -86
  319. package/dist/storage/placed-reads.mjs +1 -1
  320. package/dist/storage/plan-columns.d.mts +4 -0
  321. package/dist/storage/plan-columns.mjs +238 -0
  322. package/dist/storage/prune-keep.mjs +299 -37
  323. package/dist/storage/prune-walk.mjs +240 -62
  324. package/dist/storage/prune.mjs +749 -213
  325. package/dist/storage/push-allotment.mjs +91 -12
  326. package/dist/storage/push-uploads.mjs +40 -16
  327. package/dist/storage/pushed-commits.mjs +4 -2
  328. package/dist/storage/quarantine.d.mts +1 -1
  329. package/dist/storage/quarantine.mjs +9 -9
  330. package/dist/storage/range-cache.mjs +125 -8
  331. package/dist/storage/ready.d.mts +1 -1
  332. package/dist/storage/ready.mjs +55 -25
  333. package/dist/storage/receive-bounds.mjs +51 -15
  334. package/dist/storage/receive-state.mjs +8 -0
  335. package/dist/storage/receive-steps.mjs +71 -18
  336. package/dist/storage/repack-backlog.mjs +6 -3
  337. package/dist/storage/repack.d.mts +2 -2
  338. package/dist/storage/repack.mjs +1 -8
  339. package/dist/storage/rows.d.mts +1 -1
  340. package/dist/storage/rows.mjs +13 -2
  341. package/dist/storage/runs.mjs +195 -43
  342. package/dist/storage/send-list.d.mts +1 -0
  343. package/dist/storage/send-list.mjs +54 -10
  344. package/dist/storage/shallow.d.mts +1 -0
  345. package/dist/storage/shallow.mjs +26 -4
  346. package/dist/storage/single-flight.mjs +13 -7
  347. package/dist/storage/stream-whole.mjs +132 -28
  348. package/dist/storage/unpack.mjs +371 -79
  349. package/dist/storage/visible.mjs +31 -3
  350. package/dist/storage/walk.mjs +194 -39
  351. package/dist/storage/wants.mjs +5 -5
  352. package/dist/store/bodies.mjs +38 -0
  353. package/dist/store/call-count.d.mts +8 -12
  354. package/dist/store/call-count.mjs +34 -46
  355. package/dist/store/catalogue.d.mts +2 -2
  356. package/dist/store/catalogue.mjs +146 -35
  357. package/dist/store/crossing.mjs +1 -3
  358. package/dist/store/cursor-seal-namespace.d.mts +2 -0
  359. package/dist/store/cursor-seal-public.d.mts +5 -0
  360. package/dist/store/cursor-seal-public.mjs +5 -0
  361. package/dist/store/cursor-seal.d.mts +16 -3
  362. package/dist/store/cursor-seal.mjs +40 -18
  363. package/dist/store/door.mjs +183 -0
  364. package/dist/store/errors.d.mts +3 -4
  365. package/dist/store/errors.mjs +24 -34
  366. package/dist/store/git-store.mjs +25 -7
  367. package/dist/store/job-try.mjs +9 -32
  368. package/dist/store/list-job.mjs +44 -8
  369. package/dist/store/records.d.mts +5 -0
  370. package/dist/store/records.mjs +12 -6
  371. package/dist/store/repo-record.d.mts +10 -9
  372. package/dist/store/repo-record.mjs +123 -28
  373. package/dist/store/reservations.mjs +1 -1
  374. package/dist/store/scopes.mjs +21 -2
  375. package/dist/store/settle.mjs +4 -4
  376. package/dist/sync/bound.d.mts +2 -0
  377. package/dist/sync/bound.mjs +11 -2
  378. package/dist/sync/github.d.mts +6 -1
  379. package/dist/sync/github.mjs +56 -44
  380. package/dist/sync/http.mjs +36 -1
  381. package/dist/sync/import.mjs +32 -18
  382. package/dist/sync/layer.mjs +6 -2
  383. package/dist/sync/lfs-batch.mjs +118 -0
  384. package/dist/sync/lfs-copy.mjs +262 -0
  385. package/dist/sync/mirror.mjs +227 -151
  386. package/dist/sync/said.mjs +16 -37
  387. package/dist/sync/smart-http.mjs +4 -2
  388. package/dist/sync/step.mjs +58 -30
  389. package/dist/sync/tries.mjs +52 -21
  390. package/dist/sync.d.mts +2 -2
  391. package/dist/topics/advance.mjs +10 -11
  392. package/dist/topics/base.d.mts +15 -0
  393. package/dist/topics/base.mjs +8 -0
  394. package/dist/topics/host.mjs +2 -20
  395. package/dist/topics/layer.d.mts +4 -9
  396. package/dist/topics/layer.mjs +3 -4
  397. package/dist/topics/members.mjs +4 -4
  398. package/dist/topics/public.d.mts +2 -1
  399. package/dist/topics/topic.mjs +2 -2
  400. package/package.json +5 -9
  401. package/dist/auth/bridge.mjs +0 -30
  402. package/dist/auth/helpers.d.mts +0 -17
  403. package/dist/contracts/promises.d.mts +0 -39
  404. package/dist/core/call-names.d.mts +0 -3
  405. package/dist/core/clock.mjs +0 -18
  406. package/dist/core/registered-rows.d.mts +0 -5
  407. package/dist/core/repack.d.mts +0 -11
  408. package/dist/http/handler.d.mts +0 -2
  409. package/dist/lfs/calls.mjs +0 -26
  410. package/dist/rest/api.d.mts +0 -23
  411. package/dist/rest/blobs.d.mts +0 -825
  412. package/dist/rest/commits.d.mts +0 -3510
  413. package/dist/rest/errors.d.mts +0 -2104
  414. package/dist/rest/events.d.mts +0 -423
  415. package/dist/rest/files.d.mts +0 -1330
  416. package/dist/rest/forks.d.mts +0 -2136
  417. package/dist/rest/handler.d.mts +0 -21
  418. package/dist/rest/handlers.d.mts +0 -8
  419. package/dist/rest/merges.d.mts +0 -473
  420. package/dist/rest/queue.d.mts +0 -5861
  421. package/dist/rest/refs.d.mts +0 -2959
  422. package/dist/rest/repos.d.mts +0 -2539
  423. package/dist/rest/tags.d.mts +0 -1304
  424. package/dist/rest/tokens.d.mts +0 -2590
  425. package/dist/rest/topics.d.mts +0 -2204
  426. package/dist/rest/trees.d.mts +0 -1693
  427. package/dist/rest/work.d.mts +0 -1248
  428. package/dist/rest.d.mts +0 -2
  429. package/dist/rest.mjs +0 -1
  430. package/dist/server/lifecycle.d.mts +0 -2
  431. package/dist/server/registry.d.mts +0 -16
  432. package/dist/server/server.d.mts +0 -36
  433. package/dist/storage/repack-job.d.mts +0 -3
  434. package/dist/store/promises.d.mts +0 -11
  435. package/dist/store/promises.mjs +0 -327
  436. package/dist/topics/host.d.mts +0 -7
@@ -1,10 +1,12 @@
1
1
  import { keepsEvents } from "../contracts/events.mjs";
2
+ import { check } from "../contracts/authorize.mjs";
2
3
  import { badCursor } from "../engine/reads.mjs";
3
4
  import { utf8 } from "../protocol/bytes/text.mjs";
4
5
  import { afterCommit } from "../store/call-count.mjs";
5
6
  import { listBound } from "../store/cursor-seal.mjs";
6
- import { storeCall } from "../store/errors.mjs";
7
+ import { storeCall, storeCommit } from "../store/errors.mjs";
7
8
  import { keptKey } from "../store/records.mjs";
9
+ import { readRecord } from "../store/repo-record.mjs";
8
10
  import { newChangeId, repoScope } from "../store/scopes.mjs";
9
11
  import { callerFor, contended, openRepo, repoAccess } from "./access.mjs";
10
12
  import { isDeliverJob, skipFailed } from "./events/deliver.mjs";
@@ -13,7 +15,7 @@ import { refViewIn } from "./ref-view.mjs";
13
15
  import { heldReceipt, receiptAnswered, receiptReads, receiptWrites } from "./receipts.mjs";
14
16
  import { fail } from "../contracts/result.mjs";
15
17
  import { CoreParts, QueueParts } from "./parts.mjs";
16
- import * as Clock$1 from "effect/Clock";
18
+ import * as Clock from "effect/Clock";
17
19
  import * as Effect from "effect/Effect";
18
20
  import { limits } from "@ref0/infra";
19
21
  // src/core/work.ts
@@ -43,29 +45,29 @@ const storeCursor = (text) => {
43
45
  return text.slice(start, start + Number(length[1]));
44
46
  };
45
47
  /** Commits a work write's receipt, and `git.repack` due to sweep it, at the scope's `expect`. */
46
- const commitReceipt = (internalId, write) => Effect.flatMap(Effect.service(CoreParts), (core) => storeCall(() => {
48
+ const commitReceipt = (internalId, write) => Effect.flatMap(Effect.service(CoreParts), (core) => {
47
49
  const receipt = receiptWrites(write.kept, write.answer, core.repackJobRow);
48
50
  const change = {
49
51
  id: newChangeId(),
50
52
  expect: write.expect
51
53
  };
52
- return core.store.commit(repoScope(internalId), {
54
+ return storeCommit(core.store.commit(repoScope(internalId), {
53
55
  ...change,
54
56
  put: [...receipt.put],
55
57
  jobs: [...receipt.jobs]
56
- });
57
- }));
58
+ }));
59
+ });
58
60
  /**
59
61
  * Marks a work write's receipt answered once the queue took the write, so the write sent again
60
- * answers as it did. The queue's calls join no commit, so a write stopped before this answers as
61
- * the queue does when it's sent again (Q150).
62
+ * answers as it did. The queue's calls join no commit, so a write stopped before this is sent
63
+ * again to a `pending` receipt, which `ranBefore` reads (Q150).
62
64
  */
63
65
  const keepAnswer = /* @__PURE__ */ Effect.fnUntraced(function* (internalId, kept) {
64
66
  const core = yield* CoreParts;
65
67
  for (let attempt = 0; attempt < 5; attempt += 1) {
66
68
  const scope = repoScope(internalId);
67
69
  const write = {
68
- expect: (yield* storeCall(() => core.store.read(scope, []))).version,
70
+ expect: (yield* storeCall(core.store.read(scope, []))).version,
69
71
  kept,
70
72
  answer: { kind: "done" }
71
73
  };
@@ -77,6 +79,75 @@ const keepAnswer = /* @__PURE__ */ Effect.fnUntraced(function* (internalId, kept
77
79
  tries: 5
78
80
  }));
79
81
  });
82
+ const unread = { kind: "unread" };
83
+ /** `job`'s failure, from the queue's failed jobs of its name, `failedFindPages` at most. */
84
+ const failureOf = /* @__PURE__ */ Effect.fnUntraced(function* (scope, job) {
85
+ const { jobs } = yield* QueueParts;
86
+ let after;
87
+ for (let page = 0; page < 10; page += 1) {
88
+ const request = {
89
+ state: "failed",
90
+ name: job.name
91
+ };
92
+ if (after !== void 0) request.page = { after };
93
+ const listed = yield* storeCall(jobs.list(scope, request));
94
+ const failed = listed.items.find((item) => item.key === job.key);
95
+ if (failed?.claim !== void 0) return {
96
+ kind: "failed",
97
+ claim: failed.claim
98
+ };
99
+ if (failed !== void 0) return unread;
100
+ if (listed.next === void 0) return { kind: "none" };
101
+ after = listed.next;
102
+ }
103
+ return unread;
104
+ });
105
+ /**
106
+ * Whether a work write sent again to its `pending` receipt finds the first send's queue call ran:
107
+ * the receipt names the claim its job had failed under, and the job is no longer failed under it,
108
+ * retried, discarded, or failed again since. Claims are numbered afresh in a scope, never reused,
109
+ * so a failure under the same claim is the one the first send found. A receipt that names none,
110
+ * or a failure past `failedFindPages`, can't tell, and the write calls the queue again.
111
+ */
112
+ const ranBefore = (held, now) => {
113
+ if (held.failed === void 0) return false;
114
+ switch (now.kind) {
115
+ case "failed": return now.claim !== held.failed;
116
+ case "none": return true;
117
+ case "unread": return false;
118
+ }
119
+ };
120
+ /**
121
+ * A page of the jobs in `internalId`'s scope, as `list` and `listById` answer them, those `shown`
122
+ * keeps. With `access`, a cursor is sealed for `list`'s page of the repo in its state: the store's
123
+ * names the job its page ends on, which may be one the caller doesn't see. A page is left short
124
+ * rather than read on, so its length is the store's page less the jobs the caller can't see;
125
+ * `next` still goes on where the store's page ended.
126
+ */
127
+ const jobsPage = /* @__PURE__ */ Effect.fnUntraced(function* (internalId, list, input, shown) {
128
+ const core = yield* CoreParts;
129
+ const sealed = core.access !== void 0;
130
+ const bound = listBound(list, internalId, input.state ?? "");
131
+ const sent = input.page?.after;
132
+ const opens = sent === void 0 || !sealed ? sent : yield* core.cursors.open(bound, sent);
133
+ const after = sealed && opens !== void 0 ? storeCursor(opens) : opens;
134
+ if (sent !== void 0 && after === void 0) return yield* badCursor();
135
+ const request = {};
136
+ if (input.state !== void 0) request.state = input.state;
137
+ if (input.page !== void 0) {
138
+ const page = { ...input.page };
139
+ if (after !== void 0) page.after = after;
140
+ request.page = page;
141
+ }
142
+ const { jobs } = yield* QueueParts;
143
+ const listed = yield* storeCall(jobs.list(repoScope(internalId), request));
144
+ const items = listed.items.filter(shown);
145
+ if (listed.next === void 0) return { items };
146
+ return {
147
+ items,
148
+ next: sealed ? yield* core.cursors.seal(bound, yield* workCursorText(listed.next)) : listed.next
149
+ };
150
+ });
80
151
  /** `work`: a repo's jobs, over the queue's own calls, once `authorize` lets the caller. */
81
152
  const workCalls = (bound) => {
82
153
  const callerOf = callerFor(bound);
@@ -97,7 +168,7 @@ const workCalls = (bound) => {
97
168
  kind,
98
169
  job.name,
99
170
  job.key
100
- ], yield* Clock$1.currentTimeMillis, "requestKey");
171
+ ], yield* Clock.currentTimeMillis, "requestKey");
101
172
  for (let attempt = 0; attempt < 5; attempt += 1) {
102
173
  const opened = yield* openRepo(caller, operation, receiptReads(kept), input.internalId, "skip");
103
174
  const { internalId, snapshot } = opened;
@@ -105,18 +176,25 @@ const workCalls = (bound) => {
105
176
  const seen = seesJob(yield* refViewIn(caller, repoOf), job);
106
177
  const held = yield* heldReceipt(snapshot.results.slice(1), kept);
107
178
  if (held !== void 0 && receiptAnswered(held)) return;
179
+ const scope = repoScope(internalId);
180
+ const failure = kept !== void 0 && seen ? yield* failureOf(scope, job) : unread;
181
+ if (kept !== void 0 && held !== void 0 && ranBefore(held, failure)) {
182
+ yield* afterCommit(keepAnswer(internalId, kept));
183
+ return;
184
+ }
108
185
  if (kept !== void 0 && held === void 0) {
186
+ const answer = { kind: "pending" };
187
+ if (failure.kind === "failed") answer.failed = failure.claim;
109
188
  const write = {
110
189
  expect: snapshot.version,
111
190
  kept,
112
- answer: "pending"
191
+ answer
113
192
  };
114
193
  if (!(yield* commitReceipt(internalId, write)).ok) continue;
115
194
  }
116
- const scope = repoScope(internalId);
117
195
  if (!seen && kind === "work.retry") return yield* fail("NOT_FOUND", `No job '${job.name}' '${job.key}'`);
118
196
  if (!seen) {} else if (kind === "work.discard" && isDeliverJob(job) && keepsEvents(core.events)) yield* skipFailed(core.store, jobs, scope, job, core.events.deliveries);
119
- else yield* storeCall(() => kind === "work.retry" ? jobs.retry(scope, job) : jobs.discard(scope, job));
197
+ else yield* storeCall(kind === "work.retry" ? jobs.retry(scope, job) : jobs.discard(scope, job));
120
198
  if (kept !== void 0) yield* afterCommit(keepAnswer(internalId, kept));
121
199
  return;
122
200
  }
@@ -129,31 +207,23 @@ const workCalls = (bound) => {
129
207
  kind: "work.list",
130
208
  repo
131
209
  }, [], input.internalId);
132
- const { internalId } = opened;
133
210
  const repoOf = repoAccess(opened);
134
211
  const refView = yield* refViewIn(caller, repoOf);
212
+ return yield* jobsPage(opened.internalId, "work.list", input, (item) => seesJob(refView, item));
213
+ }),
214
+ listById: Effect.fnUntraced(function* (internalId, input) {
215
+ const caller = callerOf(input);
216
+ yield* check({
217
+ caller,
218
+ operation: {
219
+ kind: "work.listById",
220
+ internalId
221
+ }
222
+ });
135
223
  const core = yield* CoreParts;
136
- const sealed = core.access !== void 0;
137
- const bound = listBound("work.list", internalId, input.state ?? "");
138
- const sent = input.page?.after;
139
- const opens = sent === void 0 || !sealed ? sent : yield* core.cursors.open(bound, sent);
140
- const after = sealed && opens !== void 0 ? storeCursor(opens) : opens;
141
- if (sent !== void 0 && after === void 0) return yield* badCursor();
142
- const request = {};
143
- if (input.state !== void 0) request.state = input.state;
144
- if (input.page !== void 0) {
145
- const page = { ...input.page };
146
- if (after !== void 0) page.after = after;
147
- request.page = page;
148
- }
149
- const { jobs } = yield* QueueParts;
150
- const listed = yield* storeCall(() => jobs.list(repoScope(internalId), request));
151
- const items = listed.items.filter((item) => seesJob(refView, item));
152
- if (listed.next === void 0) return { items };
153
- return {
154
- items,
155
- next: sealed ? yield* core.cursors.seal(bound, yield* workCursorText(listed.next)) : listed.next
156
- };
224
+ const { record } = yield* readRecord(core.store, internalId);
225
+ if (record === void 0) return yield* fail("NOT_FOUND", `No repo '${internalId}'`);
226
+ return yield* jobsPage(internalId, "work.listById", input, () => true);
157
227
  }),
158
228
  retry: write("work.retry"),
159
229
  discard: write("work.discard")
package/dist/effect.d.mts CHANGED
@@ -1,16 +1,9 @@
1
1
  import { EffectCalls, GitCaller, GitStore } from "./contracts/services.mjs";
2
2
  import { IndexCalls, IndexReachInput, IndexReached, IndexStatus, IndexTip, IndexTry, IndexTryInput } from "./contracts/objects.mjs";
3
- import { CallAllowance, CallBudget, CallBudgetOptions } from "./store/call-count.mjs";
3
+ import { Actor } from "./contracts/actors.mjs";
4
+ import { RepoName } from "./contracts/ids.mjs";
5
+ import { CallAllowance } from "./contracts/call-allowance.mjs";
6
+ import { CallBudget, CallBudgetOptions } from "./store/call-count.mjs";
4
7
  import { commitCallsMost, storeCall } from "./store/errors.mjs";
5
8
  import { bucketCall } from "./storage/calls.mjs";
6
- import { GitRestApi } from "./rest/api.mjs";
7
- import { GitCallerMiddleware, GitRestServices, RestServerSeam } from "./rest/caller.mjs";
8
- import { GitErrors } from "./rest/errors.mjs";
9
- import { GitRestHandlers } from "./rest/handlers.mjs";
10
- import { MeApiGroup } from "./rest/me.mjs";
11
- import { RefsApiGroup } from "./rest/refs.mjs";
12
- import { ReposApiGroup } from "./rest/repos.mjs";
13
- import { TokensApiGroup } from "./rest/tokens.mjs";
14
- import { WorkApiGroup } from "./rest/work.mjs";
15
- import { SeamAuthorizeInput, TokenRevokeCheck } from "./core/seam.mjs";
16
- export { type CallAllowance, CallBudget, type CallBudgetOptions, type EffectCalls, GitCaller, GitCallerMiddleware, GitErrors, GitRestApi, GitRestHandlers, GitRestServices, GitStore, type IndexCalls, type IndexReachInput, type IndexReached, type IndexStatus, type IndexTip, type IndexTry, type IndexTryInput, MeApiGroup, RefsApiGroup, ReposApiGroup, type RestServerSeam, type SeamAuthorizeInput, type TokenRevokeCheck, TokensApiGroup, WorkApiGroup, bucketCall, commitCallsMost, storeCall };
9
+ export { Actor, type CallAllowance, CallBudget, type CallBudgetOptions, type EffectCalls, GitCaller, GitStore, type IndexCalls, type IndexReachInput, type IndexReached, type IndexStatus, type IndexTip, type IndexTry, type IndexTryInput, RepoName, bucketCall, commitCallsMost, storeCall };
package/dist/effect.mjs CHANGED
@@ -1,14 +1,7 @@
1
1
  import { GitCaller, GitStore } from "./contracts/services.mjs";
2
+ import { Actor } from "./contracts/actors.mjs";
3
+ import { RepoName } from "./contracts/ids.mjs";
2
4
  import { CallBudget } from "./store/call-count.mjs";
3
5
  import { commitCallsMost, storeCall } from "./store/errors.mjs";
4
6
  import { bucketCall } from "./storage/calls.mjs";
5
- import { GitRestApi } from "./rest/api.mjs";
6
- import { GitCallerMiddleware, GitRestServices } from "./rest/caller.mjs";
7
- import { GitErrors } from "./rest/errors.mjs";
8
- import { GitRestHandlers } from "./rest/handlers.mjs";
9
- import { MeApiGroup } from "./rest/me.mjs";
10
- import { RefsApiGroup } from "./rest/refs.mjs";
11
- import { ReposApiGroup } from "./rest/repos.mjs";
12
- import { TokensApiGroup } from "./rest/tokens.mjs";
13
- import { WorkApiGroup } from "./rest/work.mjs";
14
- export { CallBudget, GitCaller, GitCallerMiddleware, GitErrors, GitRestApi, GitRestHandlers, GitRestServices, GitStore, MeApiGroup, RefsApiGroup, ReposApiGroup, TokensApiGroup, WorkApiGroup, bucketCall, commitCallsMost, storeCall };
7
+ export { Actor, CallBudget, GitCaller, GitStore, RepoName, bucketCall, commitCallsMost, storeCall };
@@ -1,10 +1,11 @@
1
- import { gitError, isGitError } from "../contracts/result.mjs";
1
+ import { gitError, isGitError, pastRoots } from "../contracts/result.mjs";
2
2
  // src/engine/failures.ts
3
3
  /** A diff's failure as Git's error: the read's own, or the reader's, a limit as `limit`. */
4
4
  const fromDiff = (limit) => (error) => {
5
5
  if (isGitError(error)) return error;
6
6
  switch (error.reason) {
7
7
  case "missing": return gitError("NOT_FOUND", error.message);
8
+ case "past-roots": return pastRoots(error.message, error.oid ?? "");
8
9
  case "malformed":
9
10
  case "unreadable": return gitError("DATA_LOSS", error.message);
10
11
  case "diff-limit": return gitError("RESOURCE_EXHAUSTED", error.message, { context: { reason: limit } });
@@ -3,7 +3,7 @@ import { sha1Of } from "../protocol/bytes/sha1.mjs";
3
3
  import { utf8 } from "../protocol/bytes/text.mjs";
4
4
  import { defaultDiffLimits } from "../protocol/diff/read.mjs";
5
5
  import { fromAnswer } from "../contracts/calls-spent.mjs";
6
- import * as Clock$1 from "effect/Clock";
6
+ import * as Clock from "effect/Clock";
7
7
  import * as Effect from "effect/Effect";
8
8
  import * as Hex from "effect/encoding/Hex";
9
9
  // src/engine/reads.ts
@@ -37,7 +37,7 @@ const limitsOf = (limits = {}) => {
37
37
  });
38
38
  };
39
39
  /** A call's deadline, `milliseconds` from now. */
40
- const deadlineOf = (milliseconds, reason) => Effect.map(Clock$1.currentTimeMillis, (now) => ({
40
+ const deadlineOf = (milliseconds, reason) => Effect.map(Clock.currentTimeMillis, (now) => ({
41
41
  at: now + milliseconds,
42
42
  milliseconds,
43
43
  reason
@@ -52,7 +52,7 @@ const stepDeadline = (milliseconds, reason, call) => call === void 0 ? deadlineO
52
52
  });
53
53
  const ranPast = (deadline) => fail("RESOURCE_EXHAUSTED", `The call ran past ${deadline.milliseconds} ms`, { context: { reason: deadline.reason } });
54
54
  /** Fails once `deadline` has passed: a check between steps no timer can interrupt. */
55
- const within = (deadline) => Effect.flatMap(Clock$1.currentTimeMillis, (now) => now > deadline.at ? ranPast(deadline) : Effect.void);
55
+ const within = (deadline) => Effect.flatMap(Clock.currentTimeMillis, (now) => now > deadline.at ? ranPast(deadline) : Effect.void);
56
56
  /**
57
57
  * `objects` as the diff's reader batches through it, as `readThrough` reads: the call's deadline
58
58
  * checked first, its signal passed on, its error result a failure.
@@ -76,18 +76,25 @@ const readThrough = (read, deadline) => (oid) => Effect.andThen(within(deadline)
76
76
  * that can't fire meanwhile. A step of a longer call takes the call's deadline with its own
77
77
  * `reason`.
78
78
  */
79
- const timed = (effect, deadline) => Effect.flatMap(Clock$1.currentTimeMillis, (now) => Effect.timeoutOrElse(effect, {
79
+ const timed = (effect, deadline) => Effect.flatMap(Clock.currentTimeMillis, (now) => Effect.timeoutOrElse(effect, {
80
80
  duration: Math.max(0, deadline.at - now),
81
81
  orElse: () => ranPast(deadline)
82
82
  })).pipe(Effect.catch((error) => Effect.andThen(within(deadline), Effect.fail(error))), Effect.tap(() => within(deadline)));
83
83
  /**
84
- * A page's size: the caller's whole number, held to 1 through `maxPageLimit` as the store's lists
85
- * hold it. A limit that isn't a whole number is refused, since no page holds part of an item.
84
+ * The most a page of `commits.list` holds when called in process: a caller that reads a range
85
+ * whole, such as a release's notes past 1,000 commits, lists it in one walk, where each page of
86
+ * `maxPageLimit` would walk it again. The REST API holds its pages to `maxPageLimit`.
86
87
  */
87
- const limitOf = (page = {}) => {
88
+ const logLimitMost = 1001;
89
+ /**
90
+ * A page's size: the caller's whole number, held to 1 through `most`, `maxPageLimit` as the
91
+ * store's lists hold it unless a call names more. A limit that isn't a whole number is refused,
92
+ * since no page holds part of an item.
93
+ */
94
+ const limitOf = (page = {}, most = 200) => {
88
95
  const limit = page.limit ?? 50;
89
- if (!Number.isSafeInteger(limit)) return fail("INVALID_ARGUMENT", "A page limit is a whole number", { hint: `Leave it out for 50, or pass 1 through 200` });
90
- return Effect.succeed(Math.min(Math.max(limit, 1), 200));
96
+ if (!Number.isSafeInteger(limit)) return fail("INVALID_ARGUMENT", "A page limit is a whole number", { hint: `Leave it out for 50, or pass 1 through ${most}` });
97
+ return Effect.succeed(Math.min(Math.max(limit, 1), most));
91
98
  };
92
99
  /** What binds a cursor to its call's input: the SHA-1 of each part, NUL-joined. */
93
100
  const inputDigest = (parts) => Effect.map(sha1Of(utf8(parts.join("\0"))), (digest) => Hex.encode(digest).slice(0, 16));
@@ -102,4 +109,4 @@ const indexOf = (after, digest) => {
102
109
  if (held !== digest || rest.length > 0 || !/^[1-9]\d*$/.test(index ?? "")) return badCursor();
103
110
  return Effect.succeed(Number(index));
104
111
  };
105
- export { badCursor, deadlineOf, defaultMilliseconds, indexCursor, indexOf, inputDigest, limitOf, limitsOf, readThrough, readsThrough, stepDeadline, timed, within };
112
+ export { badCursor, deadlineOf, defaultMilliseconds, indexCursor, indexOf, inputDigest, limitOf, limitsOf, logLimitMost, readThrough, readsThrough, stepDeadline, timed, within };
@@ -218,7 +218,7 @@ const started = /* @__PURE__ */ Effect.fnUntraced(function* (reader, wants, have
218
218
  * `--author`, `--committer`, `--max-age` and `--min-age` do. Each walk here sees each of `roots`
219
219
  * as having no parents, as Git's shallow grafts make a repo's roots.
220
220
  */
221
- const walkHistory = /* @__PURE__ */ Effect.fnUntraced(function* (read, input, call, roots = noRepoRoots) {
221
+ const walkHistory = /* @__PURE__ */ Effect.fnUntraced(function* (read, input, call, roots = noRepoRoots, most = 200) {
222
222
  const haves = input.haves ?? [];
223
223
  if (input.wants.length === 0) return yield* fail("INVALID_ARGUMENT", "A walk needs a want");
224
224
  const digest = yield* inputDigest([
@@ -229,7 +229,7 @@ const walkHistory = /* @__PURE__ */ Effect.fnUntraced(function* (read, input, ca
229
229
  filterKey(input)
230
230
  ]);
231
231
  const stale = staleOf(input);
232
- return yield* paged(read, input, digest, (walk, take) => haves.length > 0 ? limited(walk, take, input) : unlimited(walk, take, stale), call, roots);
232
+ return yield* paged(read, input, digest, (walk, take) => haves.length > 0 ? limited(walk, take, input) : unlimited(walk, take, stale), call, roots, most);
233
233
  });
234
234
  /** `rev-list --count <wants> ^<haves>`: how many commits the walk lists, within its limits. */
235
235
  const countHistory = /* @__PURE__ */ Effect.fnUntraced(function* (read, input, call, roots = noRepoRoots) {
@@ -325,9 +325,9 @@ const simplified = /* @__PURE__ */ Effect.fnUntraced(function* (walk, parts, tak
325
325
  * walk runs again from the start each page, within the call's limits, and lists after its
326
326
  * cursor's commit, so a cursor holds the input's digest and that commit.
327
327
  */
328
- const paged = /* @__PURE__ */ Effect.fnUntraced(function* (read, input, digest, run, call, roots) {
328
+ const paged = /* @__PURE__ */ Effect.fnUntraced(function* (read, input, digest, run, call, roots, most = 200) {
329
329
  const limits = yield* limitsOf(input.limits);
330
- const limit = yield* limitOf(input.page);
330
+ const limit = yield* limitOf(input.page, most);
331
331
  const after = yield* afterOf(input.page?.after, digest);
332
332
  const items = [];
333
333
  const keeps = keeperOf(input);
@@ -17,7 +17,7 @@ export interface EventStreamCalls {
17
17
  readonly feed: (input: FeedInput) => Stream.Stream<FeedItem, GitError>;
18
18
  }
19
19
  declare const EventStreams_base: Context.ServiceClass<EventStreams, "@ref0/git/EventStreams", EventStreamCalls>;
20
- /** A server's event feeds: every server's context holds it, `createGitServer`'s and `Git.layer`'s. */
20
+ /** A server's event feeds: every server's context holds it. */
21
21
  export declare class EventStreams extends /* @__PURE__ */ EventStreams_base {}
22
22
  export declare const feed: (input: FeedInput) => Stream.Stream<FeedItem, GitError, EventStreams>;
23
23
  /**
@@ -10,7 +10,7 @@ var event_streams_exports = /* @__PURE__ */ __exportAll({
10
10
  feed: () => feed,
11
11
  layer: () => layer
12
12
  });
13
- /** A server's event feeds: every server's context holds it, `createGitServer`'s and `Git.layer`'s. */
13
+ /** A server's event feeds: every server's context holds it. */
14
14
  var EventStreams = class extends (/* @__PURE__ */ Context.Service()("@ref0/git/EventStreams")) {};
15
15
  const feed = (input) => Stream.unwrap(Effect.map(Effect.service(EventStreams), (streams) => streams.feed(input)));
16
16
  /**
@@ -1,16 +1,16 @@
1
- import { Clock } from "../contracts/promises.mjs";
2
1
  import { Caller } from "../contracts/actors.mjs";
3
2
  import "../contracts/events.mjs";
4
3
  import { RepoName } from "../contracts/ids.mjs";
5
4
  import { GitError } from "../contracts/result.mjs";
6
5
  import { Authorize } from "../contracts/authorize.mjs";
7
6
  import { CoreParts } from "../core/parts.mjs";
7
+ import * as EffectClock from "effect/Clock";
8
8
  import * as Effect from "effect/Effect";
9
9
  import * as Context from "effect/Context";
10
10
  import "effect/Stream";
11
11
  /** What a stream reads beside the server's core: the adapter's clock, and the server's guard. */
12
12
  export interface FeedFields {
13
- readonly clock: Clock;
13
+ readonly clock: EffectClock.Clock;
14
14
  /** Fails once the server is closed. */
15
15
  readonly guard: Effect.Effect<void, GitError>;
16
16
  /** Aborts as the server closes: it ends the stream, which errors with the closed rejection. */
@@ -24,7 +24,7 @@ export interface FeedFields {
24
24
  declare const FeedParts_base: Context.ServiceClass<FeedParts, "@ref0/git/event-streams/FeedParts", FeedFields>;
25
25
  /**
26
26
  * The server's `FeedFields`, which `EventStreams.layer()` builds over beside core's needs.
27
- * Internal: until 2c, only `createGitServer` provides it.
27
+ * Internal: only `Git.layer`'s core provides it.
28
28
  */
29
29
  export declare class FeedParts extends /* @__PURE__ */ FeedParts_base {}
30
30
  /** What `EventStreams.feed` is asked: whose events, from which repo, and after which `seq`. */
@@ -8,18 +8,19 @@ import { repoScope } from "../store/scopes.mjs";
8
8
  import { openRepo, repoAccess } from "../core/access.mjs";
9
9
  import { refViewAgain } from "../core/ref-view.mjs";
10
10
  import { knownParts, partsToRead, seenEvents } from "../core/events/seen.mjs";
11
- import { noCall, runIn } from "../store/crossing.mjs";
11
+ import { noCall, readableIn, runIn } from "../store/crossing.mjs";
12
12
  import { Authorize } from "../contracts/authorize.mjs";
13
13
  import { CoreParts } from "../core/parts.mjs";
14
- import { Clock } from "effect/Clock";
14
+ import * as EffectClock from "effect/Clock";
15
15
  import * as Effect from "effect/Effect";
16
16
  import { isInfraError } from "@ref0/infra";
17
17
  import * as Context from "effect/Context";
18
18
  import * as Stream from "effect/Stream";
19
+ import * as EffectDuration from "effect/Duration";
19
20
  // src/event-streams/stream.ts
20
21
  /**
21
22
  * The server's `FeedFields`, which `EventStreams.layer()` builds over beside core's needs.
22
- * Internal: until 2c, only `createGitServer` provides it.
23
+ * Internal: only `Git.layer`'s core provides it.
23
24
  */
24
25
  var FeedParts = class extends (/* @__PURE__ */ Context.Service()("@ref0/git/event-streams/FeedParts")) {};
25
26
  /** The `FeedNeeds` a feed opened over, with its clock, which each later step runs over. */
@@ -27,7 +28,7 @@ const feedContext = Effect.gen(function* () {
27
28
  const parts = yield* CoreParts;
28
29
  const authorize = yield* Authorize;
29
30
  const clock = yield* Effect.clockWith(Effect.succeed);
30
- return Context.make(CoreParts, parts).pipe(Context.add(Authorize, authorize), Context.add(Clock, clock));
31
+ return Context.make(CoreParts, parts).pipe(Context.add(Authorize, authorize), Context.add(EffectClock.Clock, clock));
31
32
  });
32
33
  /** How long a stream goes without a word before it sends a heartbeat, checking access first. */
33
34
  const heartbeatMs = 9e3;
@@ -37,6 +38,28 @@ const batchSize = 100;
37
38
  const firstHold = 100;
38
39
  /** Only a create's and a rename's events are ever dropped and their `seq` written again. */
39
40
  const droppable = (event) => event.type === "repo.created" || event.type === "repo.renamed";
41
+ /** The longest one timer waits: a longer sleep is taken in turns. */
42
+ const longestTimer = 2 ** 31 - 1;
43
+ /** Sleeps on `clock` until `until`, in turns of at most `longestTimer`. */
44
+ const turnsUntil = /* @__PURE__ */ Effect.fnUntraced(function* (clock, until) {
45
+ for (let left = until - clock.currentTimeMillisUnsafe(); left > 0;) {
46
+ const slept = Math.min(left, longestTimer);
47
+ yield* clock.sleep(EffectDuration.millis(slept));
48
+ left -= slept;
49
+ }
50
+ });
51
+ /** Ends once `signal` aborts, at once for one already aborted. */
52
+ const abortOf = (signal) => Effect.callback((resume) => {
53
+ const end = () => resume(Effect.void);
54
+ if (signal.aborted) return end();
55
+ signal.addEventListener("abort", end, { once: true });
56
+ return Effect.sync(() => signal.removeEventListener("abort", end));
57
+ });
58
+ /**
59
+ * Sleeps until `until` on `clock`, or until `signal` aborts: one run, whose abort interrupts the
60
+ * turn it's in, so no timer is left behind.
61
+ */
62
+ const sleepUntil = (clock, until, signal) => runIn(Effect.raceFirst(turnsUntil(clock, until), abortOf(signal)), noCall);
40
63
  /** A turn of the event loop: what's already written arrives before it ends. */
41
64
  const tick = () => runIn(Effect.as(Effect.sleep(0), "tick"), noCall);
42
65
  /** The watch a stream opens: after the row of `after`, from position 0, or the oldest retained. */
@@ -69,7 +92,7 @@ const settled = /* @__PURE__ */ Effect.fnUntraced(function* (scope, candidates)
69
92
  collection: outboxCollections.events,
70
93
  id: eventId(event.seq)
71
94
  }))];
72
- const snapshot = yield* storeCall(() => core.store.read(scope, reads));
95
+ const snapshot = yield* storeCall(core.store.read(scope, reads));
73
96
  const { head } = yield* decodeOutbox([snapshot.results[0] ?? [], []]);
74
97
  const rows = snapshot.results.slice(1).flat();
75
98
  const reread = new Map((yield* decodeEvents(rows)).map((event) => [event.seq, event]));
@@ -97,7 +120,7 @@ const partsFor = /* @__PURE__ */ Effect.fnUntraced(function* (scope, events, kno
97
120
  collection: outboxCollections.events,
98
121
  id: eventId(seq)
99
122
  }));
100
- const snapshot = yield* storeCall(() => core.store.read(scope, reads));
123
+ const snapshot = yield* storeCall(core.store.read(scope, reads));
101
124
  const found = knownParts(yield* decodeEvents(snapshot.results.flat()), here);
102
125
  for (const id of asked.values()) if (!found.has(id)) found.set(id, void 0);
103
126
  return found;
@@ -169,7 +192,7 @@ const feedStream = (parts, core, needs, caller, internalId, after, counted) => {
169
192
  let known = /* @__PURE__ */ new Map();
170
193
  let hold = firstHold;
171
194
  let holdUntil;
172
- let beatAt = clock.now() + heartbeatMs;
195
+ let beatAt = clock.currentTimeMillisUnsafe() + heartbeatMs;
173
196
  const end = () => {
174
197
  parts.closing.removeEventListener("abort", end);
175
198
  ending.abort();
@@ -184,7 +207,7 @@ const feedStream = (parts, core, needs, caller, internalId, after, counted) => {
184
207
  * life, which marks it `landed` and wakes the wait then, so an idle stream's waits add none.
185
208
  */
186
209
  const next = () => {
187
- reader ??= core.store.watch(scope, watchOf(after)).getReader();
210
+ reader ??= readableIn(core.store.watch(scope, watchOf(after)), needs).getReader();
188
211
  if (pending !== void 0) return pending;
189
212
  const read = reader.read();
190
213
  const land = () => {
@@ -206,7 +229,7 @@ const feedStream = (parts, core, needs, caller, internalId, after, counted) => {
206
229
  ending.signal.addEventListener("abort", onEnd, { once: true });
207
230
  const woke = new Promise((resolve) => woken = () => resolve());
208
231
  try {
209
- await Promise.race([woke, clock.sleep(Math.min(beatAt, holdUntil ?? beatAt), waking.signal)]);
232
+ await Promise.race([woke, sleepUntil(clock, Math.min(beatAt, holdUntil ?? beatAt), waking.signal)]);
210
233
  } finally {
211
234
  woken = () => void 0;
212
235
  waking.abort();
@@ -256,7 +279,7 @@ const feedStream = (parts, core, needs, caller, internalId, after, counted) => {
256
279
  return [];
257
280
  }
258
281
  held = waiting.held;
259
- holdUntil = held.length === 0 ? void 0 : clock.now() + hold;
282
+ holdUntil = held.length === 0 ? void 0 : clock.currentTimeMillisUnsafe() + hold;
260
283
  hold = held.length === 0 ? firstHold : Math.min(hold * 2, heartbeatMs);
261
284
  const deleted = ready.findIndex((event) => event.type === "repo.deleted");
262
285
  return deleted === -1 ? ready : ready.slice(0, deleted + 1);
@@ -277,9 +300,9 @@ const feedStream = (parts, core, needs, caller, internalId, after, counted) => {
277
300
  if (ending.signal.aborted) return;
278
301
  const woke = await wait();
279
302
  if (parts.closing.aborted) throw closedError();
280
- if (woke === "slept" && clock.now() >= beatAt) {
303
+ if (woke === "slept" && clock.currentTimeMillisUnsafe() >= beatAt) {
281
304
  await run(recheck(parts, caller, internalId));
282
- beatAt = clock.now() + heartbeatMs;
305
+ beatAt = clock.currentTimeMillisUnsafe() + heartbeatMs;
283
306
  controller.enqueue({ kind: "heartbeat" });
284
307
  return;
285
308
  }
@@ -303,12 +326,12 @@ const feedStream = (parts, core, needs, caller, internalId, after, counted) => {
303
326
  known = lastWrite(events, writes);
304
327
  last = events.at(-1)?.seq;
305
328
  if (seen.length === 0) {
306
- if (clock.now() < beatAt) continue;
307
- beatAt = clock.now() + heartbeatMs;
329
+ if (clock.currentTimeMillisUnsafe() < beatAt) continue;
330
+ beatAt = clock.currentTimeMillisUnsafe() + heartbeatMs;
308
331
  controller.enqueue({ kind: "heartbeat" });
309
332
  return;
310
333
  }
311
- beatAt = clock.now() + heartbeatMs;
334
+ beatAt = clock.currentTimeMillisUnsafe() + heartbeatMs;
312
335
  controller.enqueue({
313
336
  kind: "events",
314
337
  events: seen
package/dist/extend.d.mts CHANGED
@@ -1,7 +1,6 @@
1
1
  import { isServerClosed } from "./store/closed.mjs";
2
- import { Joined, JoinedAdapter, JoinedCalls, Joining, joinLayer } from "./server/joined.mjs";
3
- import { Bucket } from "./contracts/objects.mjs";
4
- import { Clock, RecordStore, Store } from "./contracts/promises.mjs";
5
- import { ImportState } from "./contracts/sync.mjs";
2
+ import { Joined, JoinedAdapter, JoinedCalls } from "./server/joined.mjs";
3
+ import { ImportLfsMissed, ImportLfsReason, ImportState, ImportStatus } from "./contracts/sync.mjs";
6
4
  import { heldUntil, inTime } from "./store/repo-record.mjs";
7
- export { type Bucket, type Clock, type ImportState, type Joined, type JoinedAdapter, JoinedCalls, type Joining, type RecordStore, type Store, heldUntil, inTime, isServerClosed, joinLayer };
5
+ import { Addition, AlreadyExists, Behind, Bucket, BucketLinks, BucketUploads, CallLimit, CallLimits, Change, Claim, ClaimLost, ClaimRequest, ClaimResult, Committed, Compacted, Count, Duration, Expired, InfraFailure, Internal, InvalidArgument, JobCounts, JobInput, JobItem, JobListRequest, JobProgress, JobQueue, JobRef, JobState, Key, Late, Listing, Moment, NotFailed, NotFound, Outcome, ProgressSample, ProgressStored, ProgressWrite, Read, Records, RetryInput, Row, Scope, Settled, Setup, Snapshot, TooLarge, Unavailable, Wake, Watch, WatchedRow, WorkMeasure, checkWrites } from "@ref0/infra";
6
+ export { type Addition, AlreadyExists, Behind, Bucket, BucketLinks, BucketUploads, CallLimit, CallLimits, type Change, type Claim, ClaimLost, type ClaimRequest, type ClaimResult, type Committed, Compacted, type Count, type Duration, Expired, type ImportLfsMissed, type ImportLfsReason, type ImportState, type ImportStatus, type InfraFailure, Internal, InvalidArgument, type JobCounts, type JobInput, type JobItem, type JobListRequest, type JobProgress, JobQueue, type JobRef, type JobState, type Joined, type JoinedAdapter, JoinedCalls, type Key, Late, type Listing, type Moment, NotFailed, NotFound, type Outcome, type ProgressSample, type ProgressStored, type ProgressWrite, type Read, Records, type RetryInput, type Row, type Scope, type Settled, Setup, type Snapshot, TooLarge, Unavailable, Wake, type Watch, type WatchedRow, type WorkMeasure, checkWrites, heldUntil, inTime, isServerClosed };
package/dist/extend.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import { isServerClosed } from "./store/closed.mjs";
2
- import { JoinedCalls, joinLayer } from "./server/joined.mjs";
2
+ import { JoinedCalls } from "./server/joined.mjs";
3
3
  import { heldUntil, inTime } from "./store/repo-record.mjs";
4
- export { JoinedCalls, heldUntil, inTime, isServerClosed, joinLayer };
4
+ import { AlreadyExists, Behind, Bucket, BucketLinks, BucketUploads, CallLimit, CallLimits, ClaimLost, Compacted, Expired, Internal, InvalidArgument, JobQueue, Late, NotFailed, NotFound, Records, Setup, TooLarge, Unavailable, Wake, checkWrites } from "@ref0/infra";
5
+ export { AlreadyExists, Behind, Bucket, BucketLinks, BucketUploads, CallLimit, CallLimits, ClaimLost, Compacted, Expired, Internal, InvalidArgument, JobQueue, JoinedCalls, Late, NotFailed, NotFound, Records, Setup, TooLarge, Unavailable, Wake, checkWrites, heldUntil, inTime, isServerClosed };
@@ -2,7 +2,7 @@ import { httpStatus, refusalCodeHeader } from "../contracts/result.mjs";
2
2
  // src/http/answers.ts
3
3
  /**
4
4
  * Smart HTTP's answers outside the protocol's own bytes: a refusal's status and code, the
5
- * challenges a 401 carries, and the headers `gitprotocol-http` asks of every answer, which no cache may keep.
5
+ * challenge a 401 carries, and the headers `gitprotocol-http` asks of every answer, which no cache may keep.
6
6
  */
7
7
  /** `gitprotocol-http`'s headers for a dynamic answer: never cached. */
8
8
  const noCache = {
@@ -10,8 +10,11 @@ const noCache = {
10
10
  pragma: "no-cache",
11
11
  "cache-control": "no-cache, max-age=0, must-revalidate"
12
12
  };
13
- /** The two schemes a 401 offers, in the order Git's credential helpers try them. */
14
- const challenges = ["Basic realm=\"Git\"", "Bearer realm=\"Git\""];
13
+ /**
14
+ * The scheme a 401 offers: Basic alone, as GitHub's does. Advertising Bearer beside it makes
15
+ * libcurl see multi-scheme auth and send a second anonymous GET before retrying with Basic (#2524).
16
+ */
17
+ const challenges = ["Basic realm=\"Git\""];
15
18
  /** A refusal's hint as Git prints it, on band 2 or in a refusal's body: a `hint:` line for each. */
16
19
  const hintLines = (hint) => hint?.split(/\r?\n/).map((line) => `hint: ${line}`) ?? [];
17
20
  /** A plain-text answer, uncached: `message`, then a newline. */
@@ -30,7 +33,7 @@ const refused = (status, code, message, headers) => {
30
33
  answer.set(refusalCodeHeader, code);
31
34
  return told(status, message, answer);
32
35
  };
33
- /** A 401 that asks for `Basic`, then `Bearer`. */
36
+ /** A 401 that asks for `Basic`. */
34
37
  const signIn = (message) => {
35
38
  const headers = new Headers();
36
39
  for (const challenge of challenges) headers.append("www-authenticate", challenge);
@@ -39,18 +42,20 @@ const signIn = (message) => {
39
42
  /** The answer for a repo a caller can't find, whether it's missing or hidden from them. */
40
43
  const notFound = () => refused(404, "NOT_FOUND", "Repository not found");
41
44
  /**
42
- * A refusal before any protocol bytes: a caller to sign in gets the challenges; one refused a
45
+ * A refusal before any protocol bytes: a caller to sign in gets the challenge; one refused a
43
46
  * read gets the 404 a missing repo gets, so the repo's existence stays hidden. Pass `true` for an
44
47
  * answer that isn't a repo read, such as a push, a feature route or an approval page, so
45
48
  * `NOT_ALLOWED` keeps its 403. Any other refusal's body is its message, then its `hintLines`, which
46
- * Git prints as `remote:` lines.
49
+ * Git prints as `remote:` lines, and an `UNAVAILABLE` naming its `retryAfter` sets `Retry-After`.
47
50
  */
48
51
  const refusal = (error, pushing = false) => {
49
52
  if (error.code === "UNAUTHENTICATED") return signIn(error.message);
50
53
  if (error.code === "NOT_FOUND" || error.code === "NOT_ALLOWED" && !pushing) return notFound();
51
54
  const rateLimited = error.code === "RESOURCE_EXHAUSTED" && error.context?.reason === "rate-limited";
52
55
  const body = [error.message, ...hintLines(error.hint)].join("\n");
53
- return refused(rateLimited ? 429 : httpStatus[error.code], error.code, body);
56
+ const retryAfter = error.code === "UNAVAILABLE" ? error.context?.retryAfter : void 0;
57
+ const headers = retryAfter === void 0 ? void 0 : { "retry-after": `${retryAfter}` };
58
+ return refused(rateLimited ? 429 : httpStatus[error.code], error.code, body, headers);
54
59
  };
55
60
  /** A 301 to `location`, as a renamed repo's old `info/refs` answers. */
56
61
  const moved = (location) => {