@ref0/git 0.20.0 → 0.25.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 (378) hide show
  1. package/dist/access/private-refs.mjs +1 -1
  2. package/dist/auth/access-jwt.mjs +3 -3
  3. package/dist/auth/auth-namespace.d.mts +3 -3
  4. package/dist/auth/auth-namespace.mjs +3 -2
  5. package/dist/auth/auth.d.mts +3 -3
  6. package/dist/auth/auth.mjs +9 -8
  7. package/dist/auth/authorize.mjs +1 -1
  8. package/dist/auth/fences.d.mts +1 -1
  9. package/dist/auth/host-function.mjs +1 -1
  10. package/dist/auth/host-services.mjs +4 -6
  11. package/dist/auth/identify.d.mts +1 -1
  12. package/dist/auth/identify.mjs +6 -0
  13. package/dist/auth/token-cleanup.mjs +2 -2
  14. package/dist/auth/token-rows.mjs +6 -1
  15. package/dist/auth/token-text.mjs +1 -1
  16. package/dist/auth/tokens-base.d.mts +1 -1
  17. package/dist/auth/tokens.d.mts +1 -1
  18. package/dist/auth/tokens.mjs +1 -1
  19. package/dist/client/client.d.mts +15 -7
  20. package/dist/client/client.mjs +21 -12
  21. package/dist/client/git-http.mjs +1 -1
  22. package/dist/client/local.mjs +60 -24
  23. package/dist/client/negotiate.mjs +3 -3
  24. package/dist/client/push-upload.mjs +26 -10
  25. package/dist/client/remote.mjs +4 -3
  26. package/dist/client/run-remote-helper.d.mts +2 -2
  27. package/dist/client/run-remote-helper.mjs +6 -6
  28. package/dist/client/slice-push.d.mts +1 -1
  29. package/dist/client/transport.mjs +3 -3
  30. package/dist/contracts/blobs.d.mts +3 -3
  31. package/dist/contracts/blobs.mjs +1 -1
  32. package/dist/contracts/calls-spent.mjs +5 -33
  33. package/dist/contracts/client.d.mts +15 -14
  34. package/dist/contracts/commits.d.mts +4 -4
  35. package/dist/contracts/commits.mjs +1 -1
  36. package/dist/contracts/engine.d.mts +2 -2
  37. package/dist/contracts/events.d.mts +1 -1
  38. package/dist/contracts/events.mjs +1 -1
  39. package/dist/contracts/files.d.mts +4 -4
  40. package/dist/contracts/files.mjs +1 -1
  41. package/dist/contracts/forks.d.mts +4 -4
  42. package/dist/contracts/forks.mjs +1 -1
  43. package/dist/contracts/git-hooks.d.mts +1 -1
  44. package/dist/contracts/git.d.mts +9 -5
  45. package/dist/contracts/grants.d.mts +1 -1
  46. package/dist/contracts/merges.d.mts +1 -1
  47. package/dist/contracts/object-values.d.mts +1 -0
  48. package/dist/contracts/object-values.mjs +16 -1
  49. package/dist/contracts/objects.d.mts +20 -17
  50. package/dist/contracts/opaque.mjs +1 -1
  51. package/dist/contracts/operations.mjs +1 -1
  52. package/dist/contracts/queue.d.mts +208 -44
  53. package/dist/contracts/queue.mjs +5 -5
  54. package/dist/contracts/refs.d.mts +5 -5
  55. package/dist/contracts/refs.mjs +1 -1
  56. package/dist/contracts/remote.d.mts +3 -6
  57. package/dist/contracts/repos.d.mts +3 -3
  58. package/dist/contracts/repos.mjs +1 -1
  59. package/dist/contracts/result.d.mts +10 -7
  60. package/dist/contracts/result.mjs +8 -3
  61. package/dist/contracts/rules.d.mts +2 -2
  62. package/dist/contracts/server.d.mts +8 -10
  63. package/dist/contracts/services.d.mts +6 -9
  64. package/dist/contracts/services.mjs +1 -2
  65. package/dist/contracts/signin.d.mts +1 -1
  66. package/dist/contracts/store.d.mts +2 -2
  67. package/dist/contracts/sync.d.mts +63 -6
  68. package/dist/contracts/sync.mjs +3 -2
  69. package/dist/contracts/tags.d.mts +3 -3
  70. package/dist/contracts/tags.mjs +1 -1
  71. package/dist/contracts/tokens.d.mts +2 -2
  72. package/dist/contracts/tokens.mjs +1 -1
  73. package/dist/contracts/topics.d.mts +9 -9
  74. package/dist/contracts/trees.d.mts +4 -4
  75. package/dist/contracts/trees.mjs +1 -1
  76. package/dist/contracts/work.d.mts +4 -4
  77. package/dist/contracts/work.mjs +2 -2
  78. package/dist/core/access.d.mts +1 -1
  79. package/dist/core/ancestry.mjs +30 -34
  80. package/dist/core/{promise.mjs → call-groups.mjs} +7 -30
  81. package/dist/core/call-services.mjs +1 -1
  82. package/dist/core/events/deliver.d.mts +2 -2
  83. package/dist/core/events/deliver.mjs +3 -3
  84. package/dist/core/events/retired.mjs +1 -1
  85. package/dist/core/forks.mjs +5 -5
  86. package/dist/core/hooks/groups.mjs +2 -2
  87. package/dist/core/imports.mjs +101 -21
  88. package/dist/core/index-job.mjs +14 -9
  89. package/dist/core/index-lost.d.mts +1 -1
  90. package/dist/core/loose-tally.mjs +38 -15
  91. package/dist/core/merge-parts.d.mts +17 -4
  92. package/dist/core/merge-parts.mjs +7 -2
  93. package/dist/core/mirror-rows.mjs +31 -1
  94. package/dist/core/objects/blobs.mjs +8 -10
  95. package/dist/core/objects/files.mjs +20 -17
  96. package/dist/core/objects/objects-layer.mjs +1 -1
  97. package/dist/core/objects/peel.mjs +1 -7
  98. package/dist/core/objects/reading.mjs +19 -18
  99. package/dist/core/objects/tree-edits.mjs +1 -1
  100. package/dist/core/objects/trees.mjs +257 -58
  101. package/dist/core/objects/writing.mjs +3 -9
  102. package/dist/core/own-writes.mjs +1 -1
  103. package/dist/core/parts.d.mts +8 -1
  104. package/dist/core/parts.mjs +8 -4
  105. package/dist/core/purge.mjs +31 -18
  106. package/dist/core/push.d.mts +2 -2
  107. package/dist/core/push.mjs +125 -94
  108. package/dist/core/receipts.d.mts +2 -2
  109. package/dist/core/receipts.mjs +9 -2
  110. package/dist/core/ref-index-job.mjs +4 -4
  111. package/dist/core/ref-view.mjs +74 -31
  112. package/dist/core/refs.mjs +3 -3
  113. package/dist/core/repack.mjs +25 -30
  114. package/dist/core/repo-info.mjs +1 -1
  115. package/dist/core/repos.mjs +1 -1
  116. package/dist/core/rules/changes.mjs +18 -40
  117. package/dist/core/rules/check.mjs +6 -5
  118. package/dist/core/rules/commit-changes.mjs +3 -15
  119. package/dist/core/rules/context.d.mts +3 -3
  120. package/dist/core/rules/context.mjs +18 -14
  121. package/dist/core/rules/fetch.mjs +1 -1
  122. package/dist/core/rules/protect.mjs +30 -17
  123. package/dist/core/saved-caller-views.d.mts +1 -1
  124. package/dist/core/saved-caller-views.mjs +3 -3
  125. package/dist/core/saved-callers.d.mts +1 -1
  126. package/dist/core/saved-callers.mjs +1 -1
  127. package/dist/core/seam.d.mts +1 -2
  128. package/dist/core/view.d.mts +6 -3
  129. package/dist/core/view.mjs +11 -10
  130. package/dist/core/work.mjs +2 -2
  131. package/dist/engine/allotted-xdiff.mjs +3 -16
  132. package/dist/engine/combined.d.mts +3 -0
  133. package/dist/engine/combined.mjs +200 -185
  134. package/dist/engine/content.d.mts +2 -2
  135. package/dist/engine/content.mjs +1 -1
  136. package/dist/engine/merge.mjs +7 -9
  137. package/dist/engine/reads.d.mts +2 -2
  138. package/dist/engine/reads.mjs +22 -14
  139. package/dist/engine/xdiff.d.mts +1 -1
  140. package/dist/engine/xdiff.mjs +1 -1
  141. package/dist/event-streams/event-streams.d.mts +1 -1
  142. package/dist/event-streams/event-streams.mjs +1 -1
  143. package/dist/event-streams/stream.d.mts +2 -2
  144. package/dist/event-streams/stream.mjs +3 -3
  145. package/dist/extend.d.mts +2 -6
  146. package/dist/extend.mjs +1 -5
  147. package/dist/http/core-parts.mjs +83 -26
  148. package/dist/http/handler.mjs +54 -9
  149. package/dist/http/parts.d.mts +1 -0
  150. package/dist/http/push-upload-job.mjs +138 -24
  151. package/dist/http/push-uploads.mjs +2 -2
  152. package/dist/http/receive-pack.mjs +14 -53
  153. package/dist/http/request-snapshot.mjs +258 -0
  154. package/dist/http/upload-pack.mjs +23 -18
  155. package/dist/index.d.mts +29 -21
  156. package/dist/index.mjs +11 -2
  157. package/dist/lfs/base.d.mts +1 -1
  158. package/dist/lfs/copy.d.mts +49 -1
  159. package/dist/lfs/copy.mjs +135 -22
  160. package/dist/lfs/layer.d.mts +4 -3
  161. package/dist/lfs/layer.mjs +4 -5
  162. package/dist/lfs/locks.mjs +2 -2
  163. package/dist/lfs/objects.d.mts +1 -1
  164. package/dist/lfs/objects.mjs +3 -3
  165. package/dist/lfs/pointers.mjs +1 -1
  166. package/dist/lfs/rows.d.mts +1 -1
  167. package/dist/lfs/rows.mjs +11 -4
  168. package/dist/lfs/upkeep.mjs +40 -9
  169. package/dist/lfs/uploaded.mjs +1 -1
  170. package/dist/lfs/wire.mjs +1 -1
  171. package/dist/merges/merges.mjs +17 -2
  172. package/dist/protocol/bytes/buffers.d.mts +1 -1
  173. package/dist/protocol/bytes/buffers.mjs +1 -1
  174. package/dist/protocol/bytes/deflate.d.mts +1 -1
  175. package/dist/protocol/bytes/deflate.mjs +1 -1
  176. package/dist/protocol/bytes/inflate.d.mts +1 -1
  177. package/dist/protocol/bytes/inflate.mjs +1 -1
  178. package/dist/protocol/bytes/sha1.d.mts +1 -1
  179. package/dist/protocol/bytes/sha1.mjs +1 -1
  180. package/dist/protocol/diff/read.d.mts +2 -1
  181. package/dist/protocol/diff/read.mjs +102 -8
  182. package/dist/protocol/packs/graph.mjs +1 -1
  183. package/dist/protocol/packs/idx.d.mts +1 -1
  184. package/dist/protocol/packs/idx.mjs +1 -1
  185. package/dist/protocol/packs/parts.mjs +1 -1
  186. package/dist/protocol/packs/reader.d.mts +1 -1
  187. package/dist/protocol/packs/reader.mjs +1 -1
  188. package/dist/protocol/packs/write-error.d.mts +1 -1
  189. package/dist/protocol/packs/write-error.mjs +1 -1
  190. package/dist/protocol/packs/writer.mjs +3 -3
  191. package/dist/protocol/wire/advertisement.d.mts +1 -1
  192. package/dist/protocol/wire/advertisement.mjs +3 -2
  193. package/dist/protocol/wire/fetch.d.mts +1 -1
  194. package/dist/protocol/wire/fetch.mjs +1 -1
  195. package/dist/protocol/wire/lines.d.mts +9 -1
  196. package/dist/protocol/wire/lines.mjs +28 -1
  197. package/dist/protocol/wire/push-uploads.mjs +10 -7
  198. package/dist/protocol/wire/receive-pack.d.mts +1 -1
  199. package/dist/protocol/wire/receive-pack.mjs +1 -1
  200. package/dist/protocol/wire/report-status.d.mts +1 -1
  201. package/dist/protocol/wire/report-status.mjs +1 -1
  202. package/dist/protocol/wire/v2.d.mts +1 -1
  203. package/dist/protocol/wire/v2.mjs +1 -1
  204. package/dist/queue/advance.mjs +31 -24
  205. package/dist/queue/base.d.mts +5 -3
  206. package/dist/queue/calls.mjs +5 -5
  207. package/dist/queue/commit.mjs +1 -1
  208. package/dist/queue/host.d.mts +1 -1
  209. package/dist/queue/layer.d.mts +0 -1
  210. package/dist/queue/layer.mjs +9 -5
  211. package/dist/queue/schedule.mjs +1 -1
  212. package/dist/queue/search.mjs +1 -1
  213. package/dist/queue/state.mjs +1 -1
  214. package/dist/queue/trim.mjs +2 -2
  215. package/dist/rest/client.d.mts +1 -1
  216. package/dist/rest/client.mjs +6 -6
  217. package/dist/rest/errors.mjs +1 -1
  218. package/dist/rest/handler.mjs +2 -2
  219. package/dist/rest/handlers.mjs +16 -6
  220. package/dist/rest/layer.mjs +1 -1
  221. package/dist/rest/listen.mjs +2 -2
  222. package/dist/rest/refs.mjs +1 -1
  223. package/dist/server/edge.mjs +27 -3
  224. package/dist/server/git-layer.d.mts +1 -2
  225. package/dist/server/git-layer.mjs +4 -5
  226. package/dist/server/lifecycle.mjs +1 -1
  227. package/dist/server/registry.mjs +2 -8
  228. package/dist/server/server.mjs +62 -43
  229. package/dist/signin/context.d.mts +1 -1
  230. package/dist/signin/context.mjs +1 -1
  231. package/dist/signin/forms.mjs +1 -1
  232. package/dist/signin/grants.d.mts +2 -2
  233. package/dist/signin/grants.mjs +1 -1
  234. package/dist/signin/wire.mjs +1 -1
  235. package/dist/storage/allotted.mjs +4 -9
  236. package/dist/storage/batch-upkeep.mjs +31 -12
  237. package/dist/storage/batches.d.mts +2 -3
  238. package/dist/storage/batches.mjs +52 -49
  239. package/dist/storage/budget.mjs +23 -1
  240. package/dist/storage/calls.d.mts +1 -1
  241. package/dist/storage/calls.mjs +41 -43
  242. package/dist/storage/charged-cache.mjs +180 -0
  243. package/dist/storage/chunks.d.mts +3 -3
  244. package/dist/storage/chunks.mjs +121 -8
  245. package/dist/storage/counted-bucket.mjs +32 -10
  246. package/dist/storage/fetch-row-cache.d.mts +6 -0
  247. package/dist/storage/fetch-row-cache.mjs +211 -0
  248. package/dist/storage/fetch.d.mts +1 -0
  249. package/dist/storage/fetch.mjs +54 -242
  250. package/dist/storage/held-types.d.mts +0 -1
  251. package/dist/storage/host-bucket.mjs +9 -4
  252. package/dist/storage/index-bitmaps.mjs +77 -49
  253. package/dist/storage/index-build.d.mts +2 -3
  254. package/dist/storage/index-build.mjs +248 -48
  255. package/dist/storage/index-fetch.d.mts +3 -1
  256. package/dist/storage/index-fetch.mjs +60 -21
  257. package/dist/storage/index-graph.mjs +1 -1
  258. package/dist/storage/index-layers.mjs +55 -25
  259. package/dist/storage/index-reach.mjs +15 -22
  260. package/dist/storage/index-whole.d.mts +7 -0
  261. package/dist/storage/index-whole.mjs +145 -37
  262. package/dist/storage/largest-files.mjs +1 -7
  263. package/dist/storage/layout.mjs +17 -1
  264. package/dist/storage/lfs-pointers.mjs +1 -6
  265. package/dist/storage/link-join.mjs +55 -16
  266. package/dist/storage/list-source.d.mts +7 -0
  267. package/dist/storage/list-source.mjs +288 -0
  268. package/dist/storage/loose.d.mts +8 -8
  269. package/dist/storage/loose.mjs +157 -91
  270. package/dist/storage/memory-budget.mjs +226 -22
  271. package/dist/storage/merge-cut.mjs +9 -6
  272. package/dist/storage/merge-fence.mjs +1 -1
  273. package/dist/storage/merge-row.mjs +1 -1
  274. package/dist/storage/merge.d.mts +2 -3
  275. package/dist/storage/merge.mjs +2 -2
  276. package/dist/storage/object-rows.d.mts +3 -3
  277. package/dist/storage/object-rows.mjs +179 -38
  278. package/dist/storage/pack-order.mjs +97 -44
  279. package/dist/storage/pack-ranges.mjs +44 -16
  280. package/dist/storage/pack-reads.d.mts +5 -3
  281. package/dist/storage/pack-reads.mjs +236 -72
  282. package/dist/storage/pack-receive.d.mts +1 -2
  283. package/dist/storage/pack-receive.mjs +21 -17
  284. package/dist/storage/packs.d.mts +1 -1
  285. package/dist/storage/packs.mjs +477 -116
  286. package/dist/storage/placed-reads.mjs +33 -16
  287. package/dist/storage/prune-seen.mjs +1 -1
  288. package/dist/storage/prune-walk.mjs +1 -1
  289. package/dist/storage/prune.mjs +4 -31
  290. package/dist/storage/push-allotment.mjs +26 -14
  291. package/dist/storage/push-uploads.mjs +195 -57
  292. package/dist/storage/pushed-commits.mjs +20 -1
  293. package/dist/storage/quarantine.d.mts +2 -3
  294. package/dist/storage/range-cache.mjs +175 -40
  295. package/dist/storage/raw-ids.mjs +39 -10
  296. package/dist/storage/ready.d.mts +2 -3
  297. package/dist/storage/ready.mjs +114 -38
  298. package/dist/storage/receive-bounds.mjs +31 -9
  299. package/dist/storage/receive-cache.d.mts +7 -0
  300. package/dist/storage/receive-cache.mjs +147 -0
  301. package/dist/storage/receive-files.mjs +1 -1
  302. package/dist/storage/receive-links.mjs +1 -1
  303. package/dist/storage/receive-state.d.mts +2 -2
  304. package/dist/storage/receive-state.mjs +6 -8
  305. package/dist/storage/receive-steps.d.mts +20 -0
  306. package/dist/storage/receive-steps.mjs +298 -13
  307. package/dist/storage/repack-backlog.mjs +1 -6
  308. package/dist/storage/repack-contained.mjs +2 -2
  309. package/dist/storage/repack-job.mjs +1 -1
  310. package/dist/storage/repack.d.mts +2 -3
  311. package/dist/storage/repack.mjs +54 -9
  312. package/dist/storage/request-cache.mjs +57 -0
  313. package/dist/storage/roots.mjs +1 -24
  314. package/dist/storage/rows.d.mts +2 -2
  315. package/dist/storage/rows.mjs +1 -1
  316. package/dist/storage/runs.d.mts +2 -2
  317. package/dist/storage/runs.mjs +1 -1
  318. package/dist/storage/send-list.mjs +62 -25
  319. package/dist/storage/stream-whole.mjs +84 -63
  320. package/dist/storage/swap-walk.mjs +1 -1
  321. package/dist/storage/unpack.mjs +878 -450
  322. package/dist/storage/visible.mjs +110 -32
  323. package/dist/storage/walk.mjs +1 -0
  324. package/dist/storage/wants.mjs +22 -58
  325. package/dist/store/call-count.d.mts +2 -2
  326. package/dist/store/call-count.mjs +24 -11
  327. package/dist/store/catalogue.d.mts +1 -1
  328. package/dist/store/catalogue.mjs +19 -7
  329. package/dist/store/crossing.mjs +1 -7
  330. package/dist/store/cursor-seal.d.mts +1 -1
  331. package/dist/store/cursor-seal.mjs +1 -1
  332. package/dist/store/door.mjs +9 -4
  333. package/dist/store/errors.d.mts +2 -2
  334. package/dist/store/errors.mjs +107 -19
  335. package/dist/store/git-store.mjs +7 -2
  336. package/dist/store/job-try.mjs +90 -9
  337. package/dist/store/list-job.mjs +10 -34
  338. package/dist/store/outbox.d.mts +2 -2
  339. package/dist/store/outbox.mjs +2 -2
  340. package/dist/store/queue-jobs.mjs +6 -12
  341. package/dist/store/records.d.mts +2 -2
  342. package/dist/store/records.mjs +2 -2
  343. package/dist/store/ref-rows.d.mts +2 -2
  344. package/dist/store/ref-rows.mjs +2 -2
  345. package/dist/store/repo-record.d.mts +2 -2
  346. package/dist/store/repo-record.mjs +3 -3
  347. package/dist/store/request-snapshot.mjs +5 -0
  348. package/dist/store/reservations.mjs +2 -2
  349. package/dist/store/topic-jobs.mjs +5 -11
  350. package/dist/sync/bound.d.mts +3 -3
  351. package/dist/sync/bound.mjs +10 -7
  352. package/dist/sync/github.mjs +65 -67
  353. package/dist/sync/http.mjs +1 -1
  354. package/dist/sync/import.mjs +201 -66
  355. package/dist/sync/layer.d.mts +1 -1
  356. package/dist/sync/layer.mjs +6 -6
  357. package/dist/sync/lfs-batch.mjs +1 -1
  358. package/dist/sync/lfs-copy.mjs +175 -15
  359. package/dist/sync/mirror.mjs +5 -10
  360. package/dist/sync/said.mjs +1 -1
  361. package/dist/sync/step.mjs +268 -86
  362. package/dist/sync/tries.mjs +25 -6
  363. package/dist/sync.d.mts +2 -2
  364. package/dist/sync.mjs +2 -2
  365. package/dist/topics/advance.mjs +3 -3
  366. package/dist/topics/calls.mjs +1 -1
  367. package/dist/topics/layer.d.mts +15 -14
  368. package/dist/topics/members.mjs +1 -1
  369. package/dist/topics/topic.mjs +1 -1
  370. package/package.json +3 -13
  371. package/dist/auth/helpers.mjs +0 -17
  372. package/dist/auth.d.mts +0 -5
  373. package/dist/auth.mjs +0 -5
  374. package/dist/core/rules/commit-changes.d.mts +0 -12
  375. package/dist/effect.d.mts +0 -9
  376. package/dist/effect.mjs +0 -7
  377. package/dist/server/joined.d.mts +0 -70
  378. package/dist/server/joined.mjs +0 -41
@@ -7,18 +7,20 @@ import { encodeAcknowledgments, encodeShallowInfo, encodeV0Acks, encodeV0Shallow
7
7
  import { encodeErr } from "../protocol/wire/lines.mjs";
8
8
  import { encodeV2Capabilities, lsRefsPages, readLsRefs, readV2Request, v2Capabilities } from "../protocol/wire/v2.mjs";
9
9
  import { advertisementType, gitAnswer, resultType } from "./answers.mjs";
10
+ import { withFetchCache } from "../storage/fetch-row-cache.mjs";
10
11
  import { brokenBody, negotiationLimit, plainBody, readWhole } from "./bodies.mjs";
11
12
  import { withRuledDepth } from "./fetch-depth.mjs";
13
+ import { HttpRequestSnapshot } from "./request-snapshot.mjs";
12
14
  import { requestSpent } from "../storage/fetch.mjs";
13
15
  import { RequestCalls, countedAs } from "../store/call-count.mjs";
14
16
  import { scopedReader } from "../protocol/bytes/reader.mjs";
15
- import * as Clock from "effect/Clock";
16
17
  import * as Effect from "effect/Effect";
18
+ import * as Predicate from "effect/Predicate";
19
+ import * as Stream from "effect/Stream";
17
20
  import * as Cause from "effect/Cause";
18
21
  import * as Exit from "effect/Exit";
19
22
  import * as Result from "effect/Result";
20
- import * as Predicate from "effect/Predicate";
21
- import * as Stream from "effect/Stream";
23
+ import * as Clock from "effect/Clock";
22
24
  // src/http/upload-pack.ts
23
25
  /**
24
26
  * `git-upload-pack` over smart HTTP, as `gitprotocol-http` and `gitprotocol-pack` say: `info/refs`
@@ -55,7 +57,7 @@ const errAnswer = (message) => Effect.map(Effect.orDie(encodeErr(errText(message
55
57
  */
56
58
  const countedRequest = (parts, refuse) => (effect) => Effect.suspend(() => {
57
59
  const calls = new RequestCalls(parts.fetchCalls);
58
- return catchSpent(countedAs(effect, calls), (spent) => refuse(spent.of === "request" ? requestSpent(spent, calls, false) : spentRefusal(spent)));
60
+ return withFetchCache(catchSpent(countedAs(effect, calls), (spent) => refuse(spent.of === "request" ? requestSpent(spent, calls, false) : spentRefusal(spent))));
59
61
  });
60
62
  /**
61
63
  * The line a client that goes away after its answer's status leaves once the platform cancels the
@@ -239,18 +241,21 @@ const reasonOf = (cause) => Predicate.hasProperty(cause, "message") && Predicate
239
241
  * A pack handed to its response as a Stream: its scope owns the reader until the body ends or
240
242
  * is cancelled. The prefix, progress, pack chunks and final flush stay in protocol order.
241
243
  */
242
- const packStream = (round, before, answer, deadline, left) => Stream.toReadableStreamEffect(Stream.unwrap(Effect.gen(function* () {
243
- const reader = yield* scopedReader(answer.pack);
244
- const progress = encoder.encode(`Enumerating objects: ${answer.objects}, done.\n`);
245
- const chunks = Stream.fromEffectRepeat(Effect.gen(function* () {
246
- const failed = (cause) => gitError("UNAVAILABLE", `the pack failed: ${stoppedBy(cause)}`);
247
- const read = catchSpent(tryUnlessSpent(() => reader.read(), failed), (spent) => Effect.fail(failed(spent)));
248
- const chunk = yield* byDeadline(read, deadline);
249
- if (chunk instanceof Late) return yield* Effect.fail(gitError("DEADLINE_EXCEEDED", chunk.reason));
250
- if (chunk.done) return yield* Cause.done();
251
- return onRoundBand(round, 1, chunk.value);
252
- }));
253
- const end = fetchAnswerEnd(round);
254
- return Stream.concat(Stream.make(joinedBytes([before, onRoundBand(round, 2, progress)])), Stream.concat(chunks, end.length === 0 ? Stream.empty : Stream.make(end))).pipe(Stream.catch((error) => round.sideBand === void 0 ? Stream.fail(error) : Stream.make(onRoundBand(round, 3, encoder.encode(`error: ${error.message}\n`)))));
255
- })).pipe(Stream.onExit((exit) => Exit.isFailure(exit) && Cause.hasInterrupts(exit.cause) ? left : Effect.void)), { strategy: { highWaterMark: 0 } });
244
+ const packStream = (round, before, answer, deadline, left) => Effect.flatMap(HttpRequestSnapshot, (httpSnapshot) => {
245
+ const closeSnapshot = httpSnapshot?.holdForStream() ?? Effect.void;
246
+ return Stream.toReadableStreamEffect(Stream.unwrap(Effect.gen(function* () {
247
+ const reader = yield* scopedReader(answer.pack);
248
+ const progress = encoder.encode(`Enumerating objects: ${answer.objects}, done.\n`);
249
+ const chunks = Stream.fromEffectRepeat(Effect.gen(function* () {
250
+ const failed = (cause) => gitError("UNAVAILABLE", `the pack failed: ${stoppedBy(cause)}`);
251
+ const read = catchSpent(tryUnlessSpent(() => reader.read(), failed), (spent) => Effect.fail(failed(spent)));
252
+ const chunk = yield* byDeadline(read, deadline);
253
+ if (chunk instanceof Late) return yield* Effect.fail(gitError("DEADLINE_EXCEEDED", chunk.reason));
254
+ if (chunk.done) return yield* Cause.done();
255
+ return onRoundBand(round, 1, chunk.value);
256
+ }));
257
+ const end = fetchAnswerEnd(round);
258
+ return Stream.concat(Stream.make(joinedBytes([before, onRoundBand(round, 2, progress)])), Stream.concat(chunks, end.length === 0 ? Stream.empty : Stream.make(end))).pipe(Stream.catch((error) => round.sideBand === void 0 ? Stream.fail(error) : Stream.make(onRoundBand(round, 3, encoder.encode(`error: ${error.message}\n`)))));
259
+ })).pipe(Stream.onExit((exit) => Exit.isFailure(exit) && Cause.hasInterrupts(exit.cause) ? left : Effect.void), Stream.ensuring(closeSnapshot)), { strategy: { highWaterMark: 0 } }).pipe(Effect.onError(() => closeSnapshot));
260
+ });
256
261
  export { asksV2, deadlineMargin, deadlineOf, pastDeadline, uploadPack, uploadPackRefs };
package/dist/index.d.mts CHANGED
@@ -13,13 +13,20 @@ import "./server/namespaces.mjs";
13
13
  import "./core/namespaces.mjs";
14
14
  import "./auth/namespaces.mjs";
15
15
  import "./event-streams/namespace.mjs";
16
- import { git_events_d_exports } from "./contracts/git-events.mjs";
17
16
  import "./rest/namespace.mjs";
18
17
  import "./merges/namespace.mjs";
19
18
  import "./queue/namespace.mjs";
20
19
  import "./lfs/namespace.mjs";
21
20
  import "./store/cursor-seal-namespace.mjs";
22
21
  import { QueueInternals } from "./queue/host.mjs";
22
+ import { git_events_d_exports } from "./contracts/git-events.mjs";
23
+ import { CallAllowance } from "./contracts/call-allowance.mjs";
24
+ import { CallBudget, CallBudgetOptions } from "./store/call-count.mjs";
25
+ import { commitCallsMost, storeCall } from "./store/errors.mjs";
26
+ import { bucketCall } from "./storage/calls.mjs";
27
+ import { isServerClosed } from "./store/closed.mjs";
28
+ import { client_d_exports } from "./client/client.mjs";
29
+ import { heldUntil, inTime } from "./store/repo-record.mjs";
23
30
  import { CommitCalls, CommitCreateInput, CommitDiffInput, Compare, CompareInput, ComparisonFile, LineCounts, LogInput, RefPublication, Revision, commits_d_exports, logEmailsMost } from "./contracts/commits.mjs";
24
31
  import { Commit, DiffListing, MergeBaseInput, MergeBases, MergeLabels, MergeTree, ObjectWrite, ObjectWrites, PathObject, ReadOptions, ReadPage, RenamesSkipped, Signature, Tag, TagFields, TreeChange, TreeChanges, TreeDiffInput, TreeMergeInput, WalkInput } from "./contracts/engine.mjs";
25
32
  import { BeforeAfter, CandidateClosed, CandidateClosedFields, CandidateOpened, CandidateReported, EntryAdded, EntryFailed, EntryMerged, EntryRemoved, EntryRetried, EventEnvelope, EventFeature, FeedItem, FenceReason, FencedPack, GitEvent, HoldEvent, HoldEventFields, IndexRefusal, QueueEvent, QueueRestarted, RefPush, RefUpdated, RepoCreated, RepoDeletedEvent, RepoEnvelope, RepoEvent, RepoIndexRefused, RepoJobFailed, RepoMaintained, RepoPruneRefused, RepoRenamed, RepoVisibilityChanged, RepoWorkFailed, TokenEvent, TokenEventFields, TopicAdded, TopicEnvelope, TopicEvent, TopicFailed, TopicMerged, TopicOpened, TopicRemoved, TopicReported, TopicWorkFailed, events_d_exports } from "./contracts/events.mjs";
@@ -27,53 +34,52 @@ import { File, FileCalls, FileDiff, FileReadInput, FilesDiffInput, FilesListInpu
27
34
  import { ForkCalls, ForkCreateInput, ForkFetched, ForkGetInput, ForkHolder, ForkListInput, forks_d_exports } from "./contracts/forks.mjs";
28
35
  import { LfsCalls, LfsGetInput, LfsGetManyInput, LfsObject, LfsObjects, LfsOptions } from "./contracts/lfs.mjs";
29
36
  import { MergeAnswer, MergeCalls, MergeCreateInput } from "./contracts/merges.mjs";
37
+ import { RepoStreamEvent } from "./rest/wire.mjs";
30
38
  import { HandlerOptions, SavedHandlerOptions } from "./contracts/handlers.mjs";
31
39
  import { Grant, GrantAgainInput, GrantAgainRequest, GrantInput, GrantReachInput, GrantResolver } from "./contracts/grants.mjs";
40
+ import { authorize_d_exports } from "./contracts/authorize.mjs";
32
41
  import { GitScope, InternalRepoId, Oid, RefName, RepoName, TopicId, isInternalId, maxActorIdLength, maxRefNameLength } from "./contracts/ids.mjs";
33
42
  import { Allotment, CopyRow, CopyRowsInput, CopyRowsPage, EffectiveLimits, FetchAnswer, GitObject, GitObjects, HoldingsInput, HoldingsWalked, IndexCalls, IndexReachInput, IndexReached, IndexStatus, IndexTip, IndexTry, IndexTryInput, LinkedObjects, MaintainInput, ObjectHeader, ObjectHeadersInput, ObjectReadInput, ObjectReadResult, ObjectReader, ObjectReaderInput, ObjectSizesInput, ObjectsChange, ObjectsFactory, ObjectsFetchInput, ObjectsOpenInput, ObjectsRead, ObjectsReadInput, ObjectsStarting, ObjectsStartingInput, ObjectsStep, PushedCommit, PushedCommitsInput, Quarantine, ReadObject, ReadObjects, ReceiveInput, RowsMoved, ShareInput, StageInput, Staged, StepAnswer, StepInput, WholeObject } from "./contracts/objects.mjs";
34
- import { authorize_d_exports } from "./contracts/authorize.mjs";
35
43
  import { BypassOperation, FilesAllowOperation, ForkOperation, MeOperation, Operation, OperationKind, PushOperation, QueueAddOperation, QueueCandidateOperation, QueueEntryOperation, QueueReleaseOperation, QueueTargetOperation, RefsPrivateOperation, RepoListOperation, RepoOperation, TokenCreateOperation, TokenOperation, TokenParties, TopicOperation, WorkOperation } from "./contracts/operations.mjs";
36
- import { client_d_exports } from "./client/client.mjs";
37
- import { AddResult, Added, BatchOptions, Bisect, Candidate, CandidateCloseReason, CandidateId, CandidateReportInput, CandidateResult, CandidateState, CandidatesResult, Entry, EntryFailureReason, EntryFields, EntryGroups, EntryHoldInput, EntryHoldsInput, EntryId, EntryResult, EntryState, Held, Hold, HoldFields, HoldId, HoldResult, HoldsResult, JoinInput, Judged, LanesInput, MergeInput, MergeMethod, MergePlan, MergeQueueCalls, MergeQueueLayerOptions, MergeQueueOptions, MetaValue, PreviousQueueSchedule, QueueAddInput, QueueFailureCounts, QueueKeys, QueueListInput, QueueListResult, QueueMeta, QueueOf, QueueRecent, QueueTargetInput, QueueView, ReleaseResult, Released, RemoveResult, Removed, Report, ReportDetails, ReportOptions, ReportResult, Reported, RestartResult, Restarted, Retried, RetryResult, ScheduleOption, TargetHoldInput } from "./contracts/queue.mjs";
38
- import { RepoStreamEvent } from "./rest/wire.mjs";
44
+ import { Added, BatchOptions, Bisect, Candidate, CandidateCloseReason, CandidateId, CandidateReportInput, CandidateState, Entry, EntryFailureReason, EntryFields, EntryGroups, EntryHoldInput, EntryHoldsInput, EntryId, EntryState, Held, Hold, HoldFields, HoldId, JoinInput, Judged, LanesInput, MergeInput, MergeMethod, MergePlan, MergeQueueCalls, MergeQueueLayerOptions, MergeQueueOptions, MetaValue, PreviousQueueSchedule, QueueAddInput, QueueFailureCounts, QueueKeys, QueueListInput, QueueMeta, QueueOf, QueueRecent, QueueTargetInput, QueueView, Released, Removed, Report, ReportDetails, ReportOptions, Reported, Restarted, Retried, ScheduleOption, TargetHoldInput } from "./contracts/queue.mjs";
39
45
  import { Ref, RefCalls, RefCount, RefCountInput, RefEdit, RefGetInput, RefInput, RefListInput, RefProtection, RefSource, RefUpdate, RefUpdateKind, RefsUpdateInput, RefsUpdated, maxSeenRefs, refs_d_exports } from "./contracts/refs.mjs";
46
+ import { repo_records_d_exports } from "./contracts/repo-records.mjs";
40
47
  import { BasicCredential, BearerCredential, ClientCredential, ClientCredentials, RemoteCalls, RemoteOptions, TransportFailure, TransportRetry, WithoutActor, WithoutSignal } from "./contracts/remote.mjs";
48
+ import { policy_d_exports } from "./auth/policy.mjs";
49
+ import { event_streams_d_exports } from "./event-streams/event-streams.mjs";
41
50
  import { PinnedRepo, RenamedRepo, RepoCatalogueEntry, RepoCreateInput, RepoDeleted, RepoGetInput, RepoIndexHold, RepoInfo, RepoInfoStats, RepoInput, RepoListInput, RepoListOrder, RepoRecord, RepoRenameInput, RepoStats, RepoUpdateInput, RepoWork, repos_d_exports } from "./contracts/repos.mjs";
42
51
  import { PeelInput, Peeled, TagCalls, TagCreateInput, peelMost, peelTagsMost, tags_d_exports } from "./contracts/tags.mjs";
43
- import { repo_records_d_exports } from "./contracts/repo-records.mjs";
44
52
  import { Prepare, PrepareInput, Topic, TopicAddInput, TopicCalls, TopicCandidate, TopicEntry, TopicEntryInput, TopicFailure, TopicFailureReason, TopicListInput, TopicMergedEntry, TopicReportInput, TopicReportOptions, TopicReportQuestion, TopicState, TopicTarget, TopicWait } from "./contracts/topics.mjs";
45
- import { policy_d_exports } from "./auth/policy.mjs";
46
- import { event_streams_d_exports } from "./event-streams/event-streams.mjs";
47
53
  import { TreeCalls, TreeCreateInput, TreeEdit, TreeEntry, TreeInput, trees_d_exports } from "./contracts/trees.mjs";
48
- import { BlobLimit, BlobNone, Bytes, FetchRequest, Filter, LfsPointers, ObjectType, ReadLimits, TreeFilter, allotmentWithin, objectsReadMost } from "./contracts/object-values.mjs";
49
- import { Accepted, Awaitable, ContextValue, DataLossContext, DataLossReason, DecisionAnswer, ErrorContext, ExistingContext, ExistingReason, FailureResult, GitError, GitErrorBody, GitErrorCode, GitErrorContexts, GitErrorFields, GitErrorInput, GitErrorTagged, HostErrorContext, HostFunctionName, InvalidInputContext, InvalidInputReason, MissingContext, MissingReason, NotAllowedContext, NotAllowedReason, PreconditionContext, PreconditionReason, RefusalReason, RejectInput, Rejected, ResourceContext, ResourceReason, Result, Success, UnavailableContext, UnavailableReason, Verdict, gitError, httpStatus, isGitError, isRefusalReason } from "./contracts/result.mjs";
50
54
  import { git_namespace_d_exports } from "./server/git-namespace.mjs";
55
+ import { BlobLimit, BlobNone, Bytes, FetchRequest, Filter, LfsPointers, ObjectType, ReadLimits, TreeFilter, allotmentWithin, objectsReadMost } from "./contracts/object-values.mjs";
56
+ import { Accepted, ContextValue, DataLossContext, DataLossReason, DecisionAnswer, ErrorContext, ExistingContext, ExistingReason, FailureResult, GitError, GitErrorBody, GitErrorCode, GitErrorContexts, GitErrorFields, GitErrorInput, GitErrorTagged, HostErrorContext, HostFunctionName, InvalidInputContext, InvalidInputReason, MissingContext, MissingReason, NotAllowedContext, NotAllowedReason, PreconditionContext, PreconditionReason, RefusalReason, RejectInput, Rejected, ResourceContext, ResourceReason, Result, Success, UnavailableContext, UnavailableReason, Verdict, gitError, httpStatus, isGitError, isRefusalReason } from "./contracts/result.mjs";
51
57
  import { SliceRefusal } from "./client/slice-push.mjs";
52
58
  import { gitPathOf } from "./http/paths.mjs";
53
59
  import { branchRef, shortTarget } from "./queue/ids.mjs";
60
+ import { objects_namespace_d_exports } from "./core/objects/objects-namespace.mjs";
61
+ import { saved_callers_public_d_exports } from "./core/saved-callers-public.mjs";
54
62
  import { LfsPointerTarget, lfsPointerOf, maxLfsPointerBytes } from "./protocol/objects/lfs-pointer.mjs";
63
+ import { auth_namespace_d_exports } from "./auth/auth-namespace.mjs";
55
64
  import { LfsPointersBuilder, lfsPointers } from "./storage/lfs-pointers.mjs";
56
65
  import { loose, looseLimits } from "./storage/loose.mjs";
57
- import { objects_namespace_d_exports } from "./core/objects/objects-namespace.mjs";
58
- import { saved_callers_public_d_exports } from "./core/saved-callers-public.mjs";
66
+ import { layer_d_exports } from "./rest/layer.mjs";
59
67
  import { PacksOptions, UnpackOptions, packs } from "./storage/packs.mjs";
60
- import { auth_namespace_d_exports } from "./auth/auth-namespace.mjs";
68
+ import { public_d_exports as public_d_exports$3 } from "./merges/public.mjs";
61
69
  import { PacksMemory, packsMemory } from "./storage/packs-memory.mjs";
70
+ import { public_d_exports as public_d_exports$2 } from "./queue/public.mjs";
62
71
  import { Option, RepackOptions } from "./storage/repack.mjs";
63
- import { layer_d_exports } from "./rest/layer.mjs";
72
+ import { public_d_exports as public_d_exports$1 } from "./lfs/public.mjs";
64
73
  import "./core/rules/namespace.mjs";
65
- import { public_d_exports as public_d_exports$3 } from "./merges/public.mjs";
74
+ import { cursor_seal_public_d_exports } from "./store/cursor-seal-public.mjs";
66
75
  import { FetchAdjustment, FetchReadInput, FetchReadTarget, FetchRule, FetchRuleInput, FileRuleOptions, ProtectOptions, PushContext, PushFacts, PushRule, PushRuleInput, RefPatterns, RuleOperation } from "./contracts/rules.mjs";
67
- import { public_d_exports as public_d_exports$2 } from "./queue/public.mjs";
68
76
  import { BeginPushUpload, FinishPushUpload, PushFileOptions, PushOptions, PushRepoOptions, PushUploadOptions, PushUploadPart, PushUploadReceiving, PushUploadStarted } from "./contracts/push-uploads.mjs";
69
- import { public_d_exports as public_d_exports$1 } from "./lfs/public.mjs";
70
77
  import { GitNeeds, ServerCalls } from "./contracts/server.mjs";
71
- import { cursor_seal_public_d_exports } from "./store/cursor-seal-public.mjs";
72
78
  import { ImportLfsMissed, ImportLfsReason, ImportState, ImportStatus } from "./contracts/sync.mjs";
73
- import { ApprovalBase, ApprovalDecision, ApprovalPageContext, ApprovalPageInput, ApprovalPrompt, ApprovedGrant, ConfirmApprovalPage, DeniedGrant, DeviceApproval, DeviceCodePage, DeviceCodeRequest, DeviceCodeResponse, DeviceExchange, OAuthClient, OAuthError, OAuthTokenResponse, WebApproval, WebAuthorize, WebExchange } from "./contracts/signin.mjs";
79
+ import { ApprovalBase, ApprovalDecision, ApprovalPageContext, ApprovalPageInput, ApprovalPrompt, ApprovedGrant, ConfirmApprovalPage, DeniedGrant, DeviceApproval, DeviceCodePage, DeviceCodeRequest, DeviceCodeResponse, DeviceExchange, OAuthClient, OAuthError, OAuthTokenResponse, WebApproval, WebAuthorize, WebExchange, ghWriteScope } from "./contracts/signin.mjs";
74
80
  import { GitStore, GitStoreAddInput, GitStoreCommitInput, GitStoreReadInput, HeldPack, Holding, Listed, ListedInput, Pack } from "./contracts/store.mjs";
75
- import { WorkCalls, WorkItem, WorkListInput, WorkWriteInput, work_d_exports } from "./contracts/work.mjs";
76
81
  import { rules_d_exports } from "./core/rules/rules.mjs";
82
+ import { WorkCalls, WorkItem, WorkListInput, WorkWriteInput, work_d_exports } from "./contracts/work.mjs";
77
83
  import "./access/namespace.mjs";
78
84
  import { public_d_exports as public_d_exports$4 } from "./access/public.mjs";
79
85
  import "./topics/namespace.mjs";
@@ -85,5 +91,7 @@ import { public_d_exports } from "./core/hooks/public.mjs";
85
91
  import { PushHookInput } from "./contracts/git-hooks.mjs";
86
92
  import { public_d_exports as public_d_exports$5 } from "./signin/public.mjs";
87
93
  import "./signin/namespace.mjs";
94
+ import { ghClientId } from "./signin/context.mjs";
95
+ import { AccessTokenAnswer, DeviceCodeAnswer, deviceGrant, readAccessTokenAnswer, readDeviceCodeAnswer, signInPaths } from "./signin/wire.mjs";
88
96
  import { jobStates } from "@ref0/infra";
89
- export { type Accepted, type AccessOption, type Acting, type Actor, type ActorId, type ActorInput, type AddResult, type Added, type Allotment, type AnonymousActor, type ApprovalBase, type ApprovalDecision, type ApprovalPageContext, type ApprovalPageInput, type ApprovalPrompt, type ApprovedGrant, auth_namespace_d_exports as Auth, type AuthInput, authorize_d_exports as Authorize, type AuthorizeAnswer, type AuthorizeInput, type Awaitable, type BasicCredential, type BatchOptions, type BearerCredential, type BeforeAfter, BeginPushUpload, type Bisect, type Blob, type BlobCalls, type BlobCreateInput, BlobLimit, BlobNone, blobs_d_exports as Blobs, type BlobsRead, type BypassOperation, type Bytes, type CallInput, type Caller, type CallerGrant, type Candidate, type CandidateCloseReason, type CandidateClosed, type CandidateClosedFields, type CandidateId, type CandidateOpened, type CandidateReportInput, type CandidateReported, type CandidateResult, type CandidateState, type CandidatesResult, type ClientAdapter, type ClientCredential, type ClientCredentials, type ClientFetchInput, type ClientFetchResult, type ClientPushInput, type Commit, type CommitCalls, type CommitCreateInput, type CommitDiffInput, commits_d_exports as Commits, type Compare, type CompareInput, type ComparisonFile, type ConfirmApprovalPage, ContextValue, type CopyRow, type CopyRowsInput, type CopyRowsPage, type CreatedObject, type CreatedToken, type Credentials, type CredentialsBasic, type CredentialsBearer, cursor_seal_public_d_exports as CursorSeal, DataLossContext, DataLossReason, type DecisionAnswer, type DeniedGrant, type DeviceApproval, type DeviceCodePage, type DeviceCodeRequest, type DeviceCodeResponse, type DeviceExchange, type DiffListing, type EffectiveLimits, type Entry, type EntryAdded, type EntryFailed, type EntryFailureReason, type EntryFields, type EntryGroups, type EntryHoldInput, type EntryHoldsInput, type EntryId, type EntryMerged, type EntryRemoved, type EntryResult, type EntryRetried, type EntryState, ErrorContext, type EventEnvelope, type EventFeature, event_streams_d_exports as EventStreams, events_d_exports as Events, ExistingContext, ExistingReason, type FailureResult, type FeedItem, type FenceReason, type FencedPack, type FetchAdjustment, type FetchAnswer, type FetchReadInput, type FetchReadTarget, FetchRequest, type FetchRule, type FetchRuleInput, type File, type FileCalls, type FileDiff, type FileReadInput, type FileRuleOptions, files_d_exports as Files, type FilesAllowOperation, type FilesDiffInput, type FilesListInput, type FilesRead, Filter, FinishPushUpload, type ForkCalls, type ForkCreateInput, type ForkFetched, type ForkGetInput, type ForkHolder, type ForkListInput, type ForkOperation, forks_d_exports as Forks, type GetManyInput, git_namespace_d_exports as Git, client_d_exports as GitClient, type GitClientCalls, type GitClientOptions, type GitError, GitErrorBody, type GitErrorCode, type GitErrorContexts, type GitErrorFields, type GitErrorInput, type GitErrorTagged, type GitEvent, git_events_d_exports as GitEvents, public_d_exports as GitHooks, type GitNeeds, type GitObject, type GitObjects, type GitScope, type GitStore, type GitStoreAddInput, type GitStoreCommitInput, type GitStoreReadInput, type Grant, type GrantAgainInput, type GrantAgainRequest, type GrantInput, type GrantReachInput, type GrantResolver, type GrantScope, type HandlerOptions, type Held, type HeldPack, type HiddenSpan, type Hold, type HoldEvent, type HoldEventFields, type HoldFields, type HoldId, type HoldResult, type Holding, type HoldingsInput, type HoldingsWalked, type HoldsResult, HostErrorContext, type HostFunctionName, type ImportLfsMissed, type ImportLfsReason, type ImportState, type ImportStatus, type IndexCalls, type IndexReachInput, type IndexReached, type IndexRefusal, type IndexStatus, type IndexTip, type IndexTry, type IndexTryInput, InternalRepoId, InvalidInputContext, InvalidInputReason, type JoinInput, type Judged, type LanesInput, public_d_exports$1 as Lfs, type LfsCalls, type LfsGetInput, type LfsGetManyInput, type LfsObject, type LfsObjects, type LfsOptions, type LfsPointerTarget, type LfsPointers, type LfsPointersBuilder, type LineCounts, type LinkedObjects, type Listed, type ListedInput, type ListenInput, type Localize, type LogInput, type MaintainInput, type Me, type MeOperation, type MergeAnswer, type MergeBaseInput, type MergeBases, type MergeCalls, type MergeCreateInput, type MergeInput, type MergeLabels, type MergeMethod, type MergePlan, public_d_exports$2 as MergeQueue, type MergeQueueCalls, type MergeQueueLayerOptions, type MergeQueueOptions, type MergeTree, public_d_exports$3 as Merges, type MetaValue, MissingContext, MissingReason, type NamedActor, NotAllowedContext, NotAllowedReason, type OAuthClient, type OAuthError, type OAuthTokenResponse, type ObjectHeader, type ObjectHeadersInput, type ObjectInput, type ObjectReadInput, type ObjectReadResult, type ObjectReader, type ObjectReaderInput, type ObjectSizesInput, type ObjectType, type ObjectWrite, type ObjectWrites, objects_namespace_d_exports as Objects, type ObjectsChange, type ObjectsFactory, type ObjectsFetchInput, type ObjectsOpenInput, type ObjectsRead, type ObjectsReadInput, type ObjectsStarting, type ObjectsStartingInput, type ObjectsStep, type Oid, type Operation, type OperationKind, type Option, type Pack, type PacksMemory, type PacksOptions, type PagedInput, type PathObject, type PeelInput, type Peeled, type PinnedRepo, policy_d_exports as Policy, PreconditionContext, PreconditionReason, type PrefixTarget, type Prepare, type PrepareInput, type PreviousQueueSchedule, public_d_exports$4 as PrivateRefs, type ProtectOptions, type PushContext, type PushFacts, type PushFileOptions, type PushHookInput, type PushOperation, type PushOptions, type PushRepoOptions, type PushRule, type PushRuleInput, type PushUploadOptions, PushUploadPart, PushUploadReceiving, PushUploadStarted, type PushedCommit, type PushedCommitsInput, type Quarantine, type QueueAddInput, type QueueAddOperation, type QueueCandidateOperation, type QueueEntryOperation, type QueueEvent, type QueueFailureCounts, type QueueInternals, type QueueKeys, type QueueListInput, type QueueListResult, type QueueMeta, type QueueOf, type QueueRecent, type QueueReleaseOperation, type QueueRestarted, type QueueTargetInput, type QueueTargetOperation, type QueueView, type ReadLimits, type ReadObject, type ReadObjects, type ReadOptions, type ReadPage, type ReceiveInput, type Ref, type RefAudience, type RefCalls, type RefCount, type RefCountInput, type RefEdit, type RefForced, type RefGetInput, type RefInput, type RefListInput, type RefName, type RefPatterns, type RefProtection, type RefPublication, type RefPush, type RefSource, type RefUpdate, type RefUpdateKind, type RefUpdated, type RefView, refs_d_exports as Refs, type RefsPrivateOperation, type RefsUpdateInput, type RefsUpdated, type RefusalReason, type RejectInput, type Rejected, type ReleaseResult, type Released, type RemoteCalls, type RemoteOptions, type RemoteRefsInput, type RemoveResult, type Removed, type RenamedRepo, type RenamesSkipped, type RepackOptions, type RepoAccess, type RepoCatalogueEntry, type RepoCreateInput, type RepoCreated, type RepoDeleted, type RepoDeletedEvent, type RepoEnvelope, type RepoEvent, type RepoGetInput, type RepoIndexHold, type RepoIndexRefused, type RepoInfo, type RepoInfoStats, type RepoInput, type RepoJobFailed, type RepoListInput, type RepoListOperation, type RepoListOrder, type RepoMaintained, type RepoName, type RepoOperation, type RepoPruneRefused, type RepoRecord, repo_records_d_exports as RepoRecords, type RepoRenameInput, type RepoRenamed, type RepoStats, type RepoStreamEvent, type RepoUpdateInput, type RepoVisibilityChanged, type RepoWork, type RepoWorkFailed, type Report, type ReportDetails, type ReportOptions, type ReportResult, type Reported, repos_d_exports as Repos, ResourceContext, ResourceReason, layer_d_exports as Rest, client_d_exports$1 as RestClient, type RestClientCalls, type RestEvents, type RestTokenCalls, type RestartResult, type Restarted, type Result, type Retried, type RetryResult, type Revision, type RowsMoved, type RuleOperation, rules_d_exports as Rules, saved_callers_public_d_exports as SavedCallers, type SavedHandlerOptions, type ScheduleOption, type ServerCalls, type ShareInput, public_d_exports$5 as SignIn, type Signature, type SliceRefusal, type StageInput, type Staged, type StepAnswer, type StepInput, type Success, type Tag, type TagCalls, type TagCreateInput, type TagFields, tags_d_exports as Tags, type TargetHoldInput, type TokenCoverage, type TokenCreateInput, type TokenCreateOperation, type TokenEvent, type TokenEventFields, type TokenFields, type TokenId, type TokenInfo, type TokenListInput, type TokenOperation, type TokenParties, type TokenRecord, type TokenScope, type TokenState, type TokenTarget, tokens_public_d_exports as Tokens, type Topic, type TopicAddInput, type TopicAdded, type TopicCalls, type TopicCandidate, type TopicEntry, type TopicEntryInput, type TopicEnvelope, type TopicEvent, type TopicFailed, type TopicFailure, type TopicFailureReason, type TopicId, type TopicListInput, type TopicMerged, type TopicMergedEntry, type TopicOpened, type TopicOperation, type TopicRemoved, type TopicReportInput, type TopicReportOptions, type TopicReportQuestion, type TopicReported, type TopicState, type TopicTarget, type TopicWait, type TopicWorkFailed, public_d_exports$6 as Topics, type TransportFailure, type TransportRetry, type TreeCalls, type TreeChange, type TreeChanges, type TreeCreateInput, type TreeDiffInput, type TreeEdit, type TreeEntry, TreeFilter, type TreeInput, type TreeMergeInput, trees_d_exports as Trees, type TrustedWriteInput, UnavailableContext, UnavailableReason, type UnpackOptions, Verdict, type VerifiedToken, type WalkInput, type WebApproval, type WebAuthorize, type WebExchange, type WholeObject, type WithoutActor, type WithoutSignal, work_d_exports as Work, type WorkCalls, type WorkItem, type WorkListInput, type WorkOperation, type WorkWriteInput, type WriteInput, allotmentWithin, branchRef, gitError, gitPathOf, grantScopes, httpStatus, isGitError, isInternalId, isRefusalReason, jobStates, lfsPointerOf, lfsPointers, logEmailsMost, loose, looseLimits, maxActorIdLength, maxLfsPointerBytes, maxRefNameLength, maxSeenRefs, objectsReadMost, packs, packsMemory, peelMost, peelTagsMost, shortTarget, tokenScopes, tokenStates };
97
+ export { type Accepted, type AccessOption, type AccessTokenAnswer, type Acting, Actor, type ActorId, type ActorInput, type Added, type Allotment, type AnonymousActor, type ApprovalBase, type ApprovalDecision, type ApprovalPageContext, type ApprovalPageInput, type ApprovalPrompt, type ApprovedGrant, auth_namespace_d_exports as Auth, type AuthInput, authorize_d_exports as Authorize, type AuthorizeAnswer, type AuthorizeInput, type BasicCredential, type BatchOptions, type BearerCredential, type BeforeAfter, BeginPushUpload, type Bisect, type Blob, type BlobCalls, type BlobCreateInput, BlobLimit, BlobNone, blobs_d_exports as Blobs, type BlobsRead, type BypassOperation, type Bytes, type CallAllowance, CallBudget, type CallBudgetOptions, type CallInput, type Caller, type CallerGrant, type Candidate, type CandidateCloseReason, type CandidateClosed, type CandidateClosedFields, type CandidateId, type CandidateOpened, type CandidateReportInput, type CandidateReported, type CandidateState, type ClientAdapter, type ClientCredential, type ClientCredentials, type ClientFetchInput, type ClientFetchResult, type ClientPushInput, type Commit, type CommitCalls, type CommitCreateInput, type CommitDiffInput, commits_d_exports as Commits, type Compare, type CompareInput, type ComparisonFile, type ConfirmApprovalPage, ContextValue, type CopyRow, type CopyRowsInput, type CopyRowsPage, type CreatedObject, type CreatedToken, type Credentials, type CredentialsBasic, type CredentialsBearer, cursor_seal_public_d_exports as CursorSeal, DataLossContext, DataLossReason, type DecisionAnswer, type DeniedGrant, type DeviceApproval, type DeviceCodeAnswer, type DeviceCodePage, type DeviceCodeRequest, type DeviceCodeResponse, type DeviceExchange, type DiffListing, type EffectiveLimits, type Entry, type EntryAdded, type EntryFailed, type EntryFailureReason, type EntryFields, type EntryGroups, type EntryHoldInput, type EntryHoldsInput, type EntryId, type EntryMerged, type EntryRemoved, type EntryRetried, type EntryState, ErrorContext, type EventEnvelope, type EventFeature, event_streams_d_exports as EventStreams, events_d_exports as Events, ExistingContext, ExistingReason, type FailureResult, type FeedItem, type FenceReason, type FencedPack, type FetchAdjustment, type FetchAnswer, type FetchReadInput, type FetchReadTarget, FetchRequest, type FetchRule, type FetchRuleInput, type File, type FileCalls, type FileDiff, type FileReadInput, type FileRuleOptions, files_d_exports as Files, type FilesAllowOperation, type FilesDiffInput, type FilesListInput, type FilesRead, Filter, FinishPushUpload, type ForkCalls, type ForkCreateInput, type ForkFetched, type ForkGetInput, type ForkHolder, type ForkListInput, type ForkOperation, forks_d_exports as Forks, type GetManyInput, git_namespace_d_exports as Git, client_d_exports as GitClient, type GitClientCalls, type GitClientOptions, type GitError, GitErrorBody, type GitErrorCode, type GitErrorContexts, type GitErrorFields, type GitErrorInput, type GitErrorTagged, type GitEvent, git_events_d_exports as GitEvents, public_d_exports as GitHooks, type GitNeeds, type GitObject, type GitObjects, type GitScope, type GitStore, type GitStoreAddInput, type GitStoreCommitInput, type GitStoreReadInput, type Grant, type GrantAgainInput, type GrantAgainRequest, type GrantInput, type GrantReachInput, type GrantResolver, type GrantScope, type HandlerOptions, type Held, type HeldPack, type HiddenSpan, type Hold, type HoldEvent, type HoldEventFields, type HoldFields, type HoldId, type Holding, type HoldingsInput, type HoldingsWalked, HostErrorContext, type HostFunctionName, type ImportLfsMissed, type ImportLfsReason, type ImportState, type ImportStatus, type IndexCalls, type IndexReachInput, type IndexReached, type IndexRefusal, type IndexStatus, type IndexTip, type IndexTry, type IndexTryInput, InternalRepoId, InvalidInputContext, InvalidInputReason, type JoinInput, type Judged, type LanesInput, public_d_exports$1 as Lfs, type LfsCalls, type LfsGetInput, type LfsGetManyInput, type LfsObject, type LfsObjects, type LfsOptions, type LfsPointerTarget, type LfsPointers, type LfsPointersBuilder, type LineCounts, type LinkedObjects, type Listed, type ListedInput, type ListenInput, type Localize, type LogInput, type MaintainInput, type Me, type MeOperation, type MergeAnswer, type MergeBaseInput, type MergeBases, type MergeCalls, type MergeCreateInput, type MergeInput, type MergeLabels, type MergeMethod, type MergePlan, public_d_exports$2 as MergeQueue, type MergeQueueCalls, type MergeQueueLayerOptions, type MergeQueueOptions, type MergeTree, public_d_exports$3 as Merges, type MetaValue, MissingContext, MissingReason, type NamedActor, NotAllowedContext, NotAllowedReason, type OAuthClient, type OAuthError, type OAuthTokenResponse, type ObjectHeader, type ObjectHeadersInput, type ObjectInput, type ObjectReadInput, type ObjectReadResult, type ObjectReader, type ObjectReaderInput, type ObjectSizesInput, type ObjectType, type ObjectWrite, type ObjectWrites, objects_namespace_d_exports as Objects, type ObjectsChange, type ObjectsFactory, type ObjectsFetchInput, type ObjectsOpenInput, type ObjectsRead, type ObjectsReadInput, type ObjectsStarting, type ObjectsStartingInput, type ObjectsStep, type Oid, type Operation, type OperationKind, type Option, type Pack, type PacksMemory, type PacksOptions, type PagedInput, type PathObject, type PeelInput, type Peeled, type PinnedRepo, policy_d_exports as Policy, PreconditionContext, PreconditionReason, type PrefixTarget, type Prepare, type PrepareInput, type PreviousQueueSchedule, public_d_exports$4 as PrivateRefs, type ProtectOptions, type PushContext, type PushFacts, type PushFileOptions, type PushHookInput, type PushOperation, type PushOptions, type PushRepoOptions, type PushRule, type PushRuleInput, type PushUploadOptions, PushUploadPart, PushUploadReceiving, PushUploadStarted, type PushedCommit, type PushedCommitsInput, type Quarantine, type QueueAddInput, type QueueAddOperation, type QueueCandidateOperation, type QueueEntryOperation, type QueueEvent, type QueueFailureCounts, type QueueInternals, type QueueKeys, type QueueListInput, type QueueMeta, type QueueOf, type QueueRecent, type QueueReleaseOperation, type QueueRestarted, type QueueTargetInput, type QueueTargetOperation, type QueueView, type ReadLimits, type ReadObject, type ReadObjects, type ReadOptions, type ReadPage, type ReceiveInput, type Ref, type RefAudience, type RefCalls, type RefCount, type RefCountInput, type RefEdit, type RefForced, type RefGetInput, type RefInput, type RefListInput, type RefName, type RefPatterns, type RefProtection, type RefPublication, type RefPush, type RefSource, type RefUpdate, type RefUpdateKind, type RefUpdated, type RefView, refs_d_exports as Refs, type RefsPrivateOperation, type RefsUpdateInput, type RefsUpdated, type RefusalReason, type RejectInput, type Rejected, type Released, type RemoteCalls, type RemoteOptions, type RemoteRefsInput, type Removed, type RenamedRepo, type RenamesSkipped, type RepackOptions, type RepoAccess, type RepoCatalogueEntry, type RepoCreateInput, type RepoCreated, type RepoDeleted, type RepoDeletedEvent, type RepoEnvelope, type RepoEvent, type RepoGetInput, type RepoIndexHold, type RepoIndexRefused, type RepoInfo, type RepoInfoStats, type RepoInput, type RepoJobFailed, type RepoListInput, type RepoListOperation, type RepoListOrder, type RepoMaintained, RepoName, type RepoOperation, type RepoPruneRefused, type RepoRecord, repo_records_d_exports as RepoRecords, type RepoRenameInput, type RepoRenamed, type RepoStats, type RepoStreamEvent, type RepoUpdateInput, type RepoVisibilityChanged, type RepoWork, type RepoWorkFailed, type Report, type ReportDetails, type ReportOptions, type Reported, repos_d_exports as Repos, ResourceContext, ResourceReason, layer_d_exports as Rest, client_d_exports$1 as RestClient, type RestClientCalls, type RestEvents, type RestTokenCalls, type Restarted, type Result, type Retried, type Revision, type RowsMoved, type RuleOperation, rules_d_exports as Rules, saved_callers_public_d_exports as SavedCallers, type SavedHandlerOptions, type ScheduleOption, type ServerCalls, type ShareInput, public_d_exports$5 as SignIn, type Signature, type SliceRefusal, type StageInput, type Staged, type StepAnswer, type StepInput, type Success, type Tag, type TagCalls, type TagCreateInput, type TagFields, tags_d_exports as Tags, type TargetHoldInput, type TokenCoverage, type TokenCreateInput, type TokenCreateOperation, type TokenEvent, type TokenEventFields, type TokenFields, type TokenId, type TokenInfo, type TokenListInput, type TokenOperation, type TokenParties, type TokenRecord, type TokenScope, type TokenState, type TokenTarget, tokens_public_d_exports as Tokens, type Topic, type TopicAddInput, type TopicAdded, type TopicCalls, type TopicCandidate, type TopicEntry, type TopicEntryInput, type TopicEnvelope, type TopicEvent, type TopicFailed, type TopicFailure, type TopicFailureReason, type TopicId, type TopicListInput, type TopicMerged, type TopicMergedEntry, type TopicOpened, type TopicOperation, type TopicRemoved, type TopicReportInput, type TopicReportOptions, type TopicReportQuestion, type TopicReported, type TopicState, type TopicTarget, type TopicWait, type TopicWorkFailed, public_d_exports$6 as Topics, type TransportFailure, type TransportRetry, type TreeCalls, type TreeChange, type TreeChanges, type TreeCreateInput, type TreeDiffInput, type TreeEdit, type TreeEntry, TreeFilter, type TreeInput, type TreeMergeInput, trees_d_exports as Trees, type TrustedWriteInput, UnavailableContext, UnavailableReason, type UnpackOptions, Verdict, type VerifiedToken, type WalkInput, type WebApproval, type WebAuthorize, type WebExchange, type WholeObject, type WithoutActor, type WithoutSignal, work_d_exports as Work, type WorkCalls, type WorkItem, type WorkListInput, type WorkOperation, type WorkWriteInput, type WriteInput, allotmentWithin, branchRef, bucketCall, commitCallsMost, deviceGrant, ghClientId, ghWriteScope, gitError, gitPathOf, grantScopes, heldUntil, httpStatus, inTime, isGitError, isInternalId, isRefusalReason, isServerClosed, jobStates, lfsPointerOf, lfsPointers, logEmailsMost, loose, looseLimits, maxActorIdLength, maxLfsPointerBytes, maxRefNameLength, maxSeenRefs, objectsReadMost, packs, packsMemory, peelMost, peelTagsMost, readAccessTokenAnswer, readDeviceCodeAnswer, shortTarget, signInPaths, storeCall, tokenScopes, tokenStates };
package/dist/index.mjs CHANGED
@@ -1,3 +1,4 @@
1
+ import { Actor } from "./contracts/actors.mjs";
1
2
  import { client_exports } from "./client/client.mjs";
2
3
  import { client_exports as client_exports$1 } from "./rest/client.mjs";
3
4
  import { grantScopes, tokenScopes, tokenStates } from "./contracts/tokens.mjs";
@@ -25,7 +26,12 @@ import { public_exports as public_exports$3 } from "./merges/public.mjs";
25
26
  import { public_exports as public_exports$2 } from "./queue/public.mjs";
26
27
  import { public_exports as public_exports$1 } from "./lfs/public.mjs";
27
28
  import { cursor_seal_public_exports } from "./store/cursor-seal-public.mjs";
28
- import { InternalRepoId, isInternalId, maxActorIdLength, maxRefNameLength } from "./contracts/ids.mjs";
29
+ import { CallBudget } from "./store/call-count.mjs";
30
+ import { commitCallsMost, storeCall } from "./store/errors.mjs";
31
+ import { bucketCall } from "./storage/calls.mjs";
32
+ import { isServerClosed } from "./store/closed.mjs";
33
+ import { heldUntil, inTime } from "./store/repo-record.mjs";
34
+ import { InternalRepoId, RepoName, isInternalId, maxActorIdLength, maxRefNameLength } from "./contracts/ids.mjs";
29
35
  import { BlobLimit, BlobNone, FetchRequest, Filter, TreeFilter, allotmentWithin, objectsReadMost } from "./contracts/object-values.mjs";
30
36
  import { ContextValue, DataLossContext, DataLossReason, ErrorContext, ExistingContext, ExistingReason, GitErrorBody, HostErrorContext, InvalidInputContext, InvalidInputReason, MissingContext, MissingReason, NotAllowedContext, NotAllowedReason, PreconditionContext, PreconditionReason, ResourceContext, ResourceReason, UnavailableContext, UnavailableReason, Verdict, gitError, httpStatus, isGitError, isRefusalReason } from "./contracts/result.mjs";
31
37
  import { gitPathOf } from "./http/paths.mjs";
@@ -42,5 +48,8 @@ import { public_exports as public_exports$6 } from "./topics/public.mjs";
42
48
  import { tokens_public_exports } from "./auth/tokens-public.mjs";
43
49
  import { public_exports } from "./core/hooks/public.mjs";
44
50
  import { public_exports as public_exports$5 } from "./signin/public.mjs";
51
+ import { ghClientId } from "./signin/context.mjs";
52
+ import { ghWriteScope } from "./contracts/signin.mjs";
53
+ import { deviceGrant, readAccessTokenAnswer, readDeviceCodeAnswer, signInPaths } from "./signin/wire.mjs";
45
54
  import { jobStates } from "@ref0/infra";
46
- export { auth_namespace_exports as Auth, authorize_exports as Authorize, BeginPushUpload, BlobLimit, BlobNone, blobs_exports as Blobs, commits_exports as Commits, ContextValue, cursor_seal_public_exports as CursorSeal, DataLossContext, DataLossReason, ErrorContext, event_streams_exports as EventStreams, events_exports as Events, ExistingContext, ExistingReason, FetchRequest, files_exports as Files, Filter, FinishPushUpload, forks_exports as Forks, git_namespace_exports as Git, client_exports as GitClient, GitErrorBody, git_events_exports as GitEvents, public_exports as GitHooks, HostErrorContext, InternalRepoId, InvalidInputContext, InvalidInputReason, public_exports$1 as Lfs, public_exports$2 as MergeQueue, public_exports$3 as Merges, MissingContext, MissingReason, NotAllowedContext, NotAllowedReason, objects_namespace_exports as Objects, policy_exports as Policy, PreconditionContext, PreconditionReason, public_exports$4 as PrivateRefs, PushUploadPart, PushUploadReceiving, PushUploadStarted, refs_exports as Refs, repo_records_exports as RepoRecords, repos_exports as Repos, ResourceContext, ResourceReason, layer_exports as Rest, client_exports$1 as RestClient, rules_exports as Rules, saved_callers_public_exports as SavedCallers, public_exports$5 as SignIn, tags_exports as Tags, tokens_public_exports as Tokens, public_exports$6 as Topics, TreeFilter, trees_exports as Trees, UnavailableContext, UnavailableReason, Verdict, work_exports as Work, allotmentWithin, branchRef, gitError, gitPathOf, grantScopes, httpStatus, isGitError, isInternalId, isRefusalReason, jobStates, lfsPointerOf, lfsPointers, logEmailsMost, loose, looseLimits, maxActorIdLength, maxLfsPointerBytes, maxRefNameLength, maxSeenRefs, objectsReadMost, packs, packsMemory, peelMost, peelTagsMost, shortTarget, tokenScopes, tokenStates };
55
+ export { Actor, auth_namespace_exports as Auth, authorize_exports as Authorize, BeginPushUpload, BlobLimit, BlobNone, blobs_exports as Blobs, CallBudget, commits_exports as Commits, ContextValue, cursor_seal_public_exports as CursorSeal, DataLossContext, DataLossReason, ErrorContext, event_streams_exports as EventStreams, events_exports as Events, ExistingContext, ExistingReason, FetchRequest, files_exports as Files, Filter, FinishPushUpload, forks_exports as Forks, git_namespace_exports as Git, client_exports as GitClient, GitErrorBody, git_events_exports as GitEvents, public_exports as GitHooks, HostErrorContext, InternalRepoId, InvalidInputContext, InvalidInputReason, public_exports$1 as Lfs, public_exports$2 as MergeQueue, public_exports$3 as Merges, MissingContext, MissingReason, NotAllowedContext, NotAllowedReason, objects_namespace_exports as Objects, policy_exports as Policy, PreconditionContext, PreconditionReason, public_exports$4 as PrivateRefs, PushUploadPart, PushUploadReceiving, PushUploadStarted, refs_exports as Refs, RepoName, repo_records_exports as RepoRecords, repos_exports as Repos, ResourceContext, ResourceReason, layer_exports as Rest, client_exports$1 as RestClient, rules_exports as Rules, saved_callers_public_exports as SavedCallers, public_exports$5 as SignIn, tags_exports as Tags, tokens_public_exports as Tokens, public_exports$6 as Topics, TreeFilter, trees_exports as Trees, UnavailableContext, UnavailableReason, Verdict, work_exports as Work, allotmentWithin, branchRef, bucketCall, commitCallsMost, deviceGrant, ghClientId, ghWriteScope, gitError, gitPathOf, grantScopes, heldUntil, httpStatus, inTime, isGitError, isInternalId, isRefusalReason, isServerClosed, jobStates, lfsPointerOf, lfsPointers, logEmailsMost, loose, looseLimits, maxActorIdLength, maxLfsPointerBytes, maxRefNameLength, maxSeenRefs, objectsReadMost, packs, packsMemory, peelMost, peelTagsMost, readAccessTokenAnswer, readDeviceCodeAnswer, shortTarget, signInPaths, storeCall, tokenScopes, tokenStates };
@@ -8,8 +8,8 @@ import { CoreNeeds } from "../core/parts.mjs";
8
8
  import { LfsCopy } from "./copy.mjs";
9
9
  import { ObjectRead } from "./objects.mjs";
10
10
  import { LfsService } from "./service.mjs";
11
- import * as Effect from "effect/Effect";
12
11
  import { RequestLimits } from "@ref0/infra";
12
+ import * as Effect from "effect/Effect";
13
13
  import * as Context from "effect/Context";
14
14
  /** A listed object's bytes, as `objectOf` reads them over LFS's parts. */
15
15
  export type LfsRead = (read: ObjectRead) => Effect.Effect<LfsObject, GitError, CoreNeeds>;
@@ -2,10 +2,12 @@ import "../contracts/git.mjs";
2
2
  import { InternalRepoId } from "../contracts/ids.mjs";
3
3
  import "../contracts/objects.mjs";
4
4
  import { GitError } from "../contracts/result.mjs";
5
+ import { Sha256State } from "../protocol/bytes/sha256.mjs";
6
+ import { StagePart } from "../storage/receive-steps.mjs";
5
7
  import { LfsStaging } from "./objects.mjs";
6
8
  import { ListedRow } from "./rows.mjs";
7
- import * as Effect from "effect/Effect";
8
9
  import { Key, Row } from "@ref0/infra";
10
+ import * as Effect from "effect/Effect";
9
11
  import * as Stream from "effect/Stream";
10
12
  /**
11
13
  * What import's copy of a source's Git LFS objects goes through, once `Lfs.layer` attached
@@ -42,6 +44,52 @@ export interface LfsCopy {
42
44
  readonly put: readonly Row[];
43
45
  readonly delete: readonly Key[];
44
46
  };
47
+ /**
48
+ * A multipart upload begun for `oid` at a key of a new generation, and its staging row naming
49
+ * the token, added with upkeep's wake at its `removeAt`, `uploadGrace` from now: an upload no
50
+ * commit lists by then is aborted, and its key deleted. With it, SHA-256's state over no bytes.
51
+ */
52
+ readonly upload: (repo: InternalRepoId, oid: string) => Effect.Effect<{
53
+ readonly staging: LfsStaging;
54
+ readonly token: string;
55
+ readonly sha256: Sha256State;
56
+ }, GitError>;
57
+ /**
58
+ * Whether the upload `staging` names may go on: its staging row is there, and more than
59
+ * `streamMost` from its `removeAt`, so a try's parts and complete land before upkeep ends the
60
+ * stage. One that may not is left to upkeep, which aborts it. `UNAVAILABLE` once the repo's rows
61
+ * moved past `version`, the caller's read.
62
+ */
63
+ readonly resumable: (repo: InternalRepoId, staging: LfsStaging, version: number) => Effect.Effect<boolean, GitError>;
64
+ /**
65
+ * `body`, the bytes of `object` from `progress`'s offset, put as parts of `partBytes` of the
66
+ * upload `token`, each hashed as it goes on from `progress`, then handed to `saved`, as many
67
+ * whole parts as `bytes` holds, and at least one: `step` once those are put, `whole` once every byte is in and its SHA-256 is the
68
+ * oid, and `other` for bytes past the size, a body that ends short of it, or a digest of another
69
+ * oid. A part's `NOT_FOUND` is an upload the bucket no longer holds.
70
+ */
71
+ readonly putParts: (input: {
72
+ readonly staging: LfsStaging;
73
+ readonly token: string;
74
+ readonly object: CopiedObject;
75
+ readonly progress: PartsProgress;
76
+ readonly body: Stream.Stream<Uint8Array, GitError>;
77
+ readonly bytes: number;
78
+ readonly saved: (progress: PartsProgress) => Effect.Effect<void, GitError>;
79
+ }) => Effect.Effect<'step' | 'whole' | 'other', GitError>;
80
+ /**
81
+ * The upload `token` ended in `parts`, `size` bytes at `staging`'s key. Only a caller that checked
82
+ * the bytes against their oid completes it: no bucket checks a SHA-256 of parts.
83
+ */
84
+ readonly complete: (staging: LfsStaging, token: string, parts: readonly StagePart[], size: number) => Effect.Effect<void, GitError>;
85
+ /** The upload `token` dropped, with its parts. */
86
+ readonly abort: (staging: LfsStaging, token: string) => Effect.Effect<void, GitError>;
87
+ }
88
+ /** How far an upload in parts got: its parts, the bytes they hold, and SHA-256's state over them. */
89
+ export interface PartsProgress {
90
+ readonly offset: number;
91
+ readonly parts: readonly StagePart[];
92
+ readonly sha256: Sha256State;
45
93
  }
46
94
  /** An object the copy asks for: its oid, and its size as its pointer names it. */
47
95
  export interface CopiedObject {
package/dist/lfs/copy.mjs CHANGED
@@ -1,12 +1,21 @@
1
- import { bucketDo } from "../storage/calls.mjs";
1
+ import { gitError } from "../contracts/result.mjs";
2
+ import { Sha256 } from "../protocol/bytes/sha256.mjs";
3
+ import { bucketDo, joined } from "../storage/calls.mjs";
2
4
  import { decodeRow } from "../store/errors.mjs";
3
5
  import { randomText } from "../store/random.mjs";
4
6
  import { listedOf } from "./objects.mjs";
5
- import { CopyRow, copyKey, copyRead, copyRowKey, lfsCollections, listedKey, stagingId, streamMost, uploadGrace } from "./rows.mjs";
6
- import * as Clock from "effect/Clock";
7
+ import { CopyRow, StagingRow, copyKey, copyRead, copyRowKey, lfsCollections, listedKey, stagingId, stagingRead, streamMost, uploadGrace } from "./rows.mjs";
7
8
  import * as Effect from "effect/Effect";
9
+ import * as Stream from "effect/Stream";
10
+ import * as Clock from "effect/Clock";
8
11
  // src/lfs/copy.ts
9
12
  /**
13
+ * The fewest bytes of each part, and each part's where the bucket sets none, as disk's and
14
+ * memory's don't: R2's and Blob's own size, which a part held in memory as it's sent keeps well
15
+ * inside a Worker's, and at which the import record's cursor names at most 640 parts.
16
+ */
17
+ const copyPartDefault = 8 * 1024 ** 2;
18
+ /**
10
19
  * What `key` holds: `size` bytes, other bytes, or none. One `list` at the key itself, limit 1,
11
20
  * which every bucket has: a `head` would be one call too, but a public API of its own. Only the
12
21
  * copy puts at a copy key, and the bucket checks each put against the oid's SHA-256 and keeps all
@@ -87,23 +96,127 @@ const copyStages = /* @__PURE__ */ Effect.fnUntraced(function* (rows, bucket, re
87
96
  });
88
97
  return stages;
89
98
  });
90
- /** The copy over LFS's registration's rows and its bucket. */
91
- const lfsCopy = (rows, bucket) => ({
92
- listed: (repo, oids) => listedOf(rows, repo, oids),
93
- stage: (repo, objects) => copyStages(rows, bucket, repo, objects),
94
- put: (staging, body, size, oid) => Effect.asVoid(Effect.uninterruptible(bucketDo(bucket.put(staging.key, body, {
95
- size,
96
- sha256: oid
97
- })))),
98
- listing: (landed) => ({
99
- put: landed.map(({ oid, size, staging }) => ({
100
- ...listedKey(oid),
101
- value: {
102
- size,
103
- key: staging.key
104
- }
105
- })),
106
- delete: landed.flatMap(({ oid, staging }) => [staging.row, copyRowKey(oid)])
107
- })
99
+ /** `upload`, over `rows` and `bucket`: the token first, so the row that names it names an upload that is. */
100
+ const copyUpload = /* @__PURE__ */ Effect.fnUntraced(function* (rows, bucket, repo, oid) {
101
+ const removeAt = (yield* Clock.currentTimeMillis) + uploadGrace;
102
+ const generation = randomText(16);
103
+ const key = copyKey(repo, oid, generation);
104
+ const row = {
105
+ collection: lfsCollections.staging,
106
+ id: stagingId(removeAt, generation)
107
+ };
108
+ const token = yield* bucketDo(bucket.beginPut(key));
109
+ const value = {
110
+ key,
111
+ removeAt,
112
+ oid,
113
+ upload: token
114
+ };
115
+ yield* rows.add(repo, {
116
+ put: [{
117
+ ...row,
118
+ value
119
+ }],
120
+ wake: removeAt
121
+ });
122
+ return {
123
+ staging: {
124
+ key,
125
+ row
126
+ },
127
+ token,
128
+ sha256: new Sha256().state()
129
+ };
108
130
  });
109
- export { heldAt, lfsCopy };
131
+ const rowsMoved = /* @__PURE__ */ gitError("UNAVAILABLE", "Another write moved the repo's LFS rows while an upload's stage was read", { hint: "The job tries again" });
132
+ /** `resumable`, over `rows`. */
133
+ const uploadResumable = /* @__PURE__ */ Effect.fnUntraced(function* (rows, repo, staging, version) {
134
+ const now = yield* Clock.currentTimeMillis;
135
+ const snapshot = yield* rows.read(repo, [stagingRead(staging.row.id)]);
136
+ if (snapshot.version !== version) return yield* Effect.fail(rowsMoved);
137
+ const found = snapshot.results[0]?.[0];
138
+ if (found === void 0) return false;
139
+ return (yield* decodeRow(StagingRow, found, `LFS staging ${staging.row.id}`)).removeAt - streamMost > now;
140
+ });
141
+ /** The first `count` bytes of `held`'s chunks as one part, and the chunks left after them. */
142
+ const partOf = (held, count) => {
143
+ const bytes = joined(held);
144
+ return {
145
+ part: bytes.subarray(0, count),
146
+ rest: bytes.length > count ? [bytes.subarray(count)] : []
147
+ };
148
+ };
149
+ /** `putParts`, over `bucket`, in parts of `partBytes`. */
150
+ const partsPut = /* @__PURE__ */ Effect.fnUntraced(function* (bucket, partBytes, input) {
151
+ const { staging, token, object, saved } = input;
152
+ const most = Math.max(1, Math.floor(input.bytes / partBytes));
153
+ const hash = new Sha256(input.progress.sha256);
154
+ let progress = input.progress;
155
+ let held = [];
156
+ let heldBytes = 0;
157
+ let sent = 0;
158
+ let ending = "other";
159
+ const stop = (why) => {
160
+ ending = why;
161
+ return false;
162
+ };
163
+ const took = Effect.fnUntraced(function* (chunk) {
164
+ held.push(chunk);
165
+ heldBytes += chunk.byteLength;
166
+ if (progress.offset + heldBytes > object.size) return stop("other");
167
+ while (heldBytes >= partBytes || heldBytes > 0 && progress.offset + heldBytes === object.size) {
168
+ const { part, rest } = partOf(held, Math.min(heldBytes, partBytes));
169
+ held = rest;
170
+ heldBytes -= part.byteLength;
171
+ hash.update(part);
172
+ const number = progress.parts.length + 1;
173
+ const { etag, size } = yield* bucketDo(bucket.putPart(staging.key, token, number, part));
174
+ progress = {
175
+ offset: progress.offset + size,
176
+ parts: [...progress.parts, {
177
+ part: number,
178
+ etag,
179
+ size
180
+ }],
181
+ sha256: hash.state()
182
+ };
183
+ sent += 1;
184
+ const whole = progress.offset === object.size;
185
+ if (whole && hash.hex() !== object.oid) return stop("other");
186
+ yield* saved(progress);
187
+ if (whole) return stop("whole");
188
+ if (sent === most) return stop("step");
189
+ }
190
+ return true;
191
+ });
192
+ yield* Stream.runForEachWhile(input.body, took);
193
+ return ending;
194
+ });
195
+ /** The copy over LFS's registration's rows and its bucket. */
196
+ const lfsCopy = (rows, bucket) => {
197
+ const partBytes = Math.max(Number.isFinite(bucket.multipart.partSize) ? bucket.multipart.partSize : 0, copyPartDefault);
198
+ return {
199
+ listed: (repo, oids) => listedOf(rows, repo, oids),
200
+ stage: (repo, objects) => copyStages(rows, bucket, repo, objects),
201
+ put: (staging, body, size, oid) => Effect.asVoid(Effect.uninterruptible(bucketDo(bucket.put(staging.key, body, {
202
+ size,
203
+ sha256: oid
204
+ })))),
205
+ listing: (landed) => ({
206
+ put: landed.map(({ oid, size, staging }) => ({
207
+ ...listedKey(oid),
208
+ value: {
209
+ size,
210
+ key: staging.key
211
+ }
212
+ })),
213
+ delete: landed.flatMap(({ oid, staging }) => [staging.row, copyRowKey(oid)])
214
+ }),
215
+ upload: (repo, oid) => copyUpload(rows, bucket, repo, oid),
216
+ resumable: (repo, staging, version) => uploadResumable(rows, repo, staging, version),
217
+ putParts: (input) => partsPut(bucket, partBytes, input),
218
+ complete: (staging, token, parts, size) => Effect.asVoid(bucketDo(bucket.completePut(staging.key, token, parts, { size }))),
219
+ abort: (staging, token) => bucketDo(bucket.abortPut(staging.key, token))
220
+ };
221
+ };
222
+ export { copyPartDefault, heldAt, lfsCopy };
@@ -4,8 +4,8 @@ import { LfsGetInput, LfsGetManyInput, LfsObject, LfsObjects, LfsOptions } from
4
4
  import { RepoName } from "../contracts/ids.mjs";
5
5
  import { GitError } from "../contracts/result.mjs";
6
6
  import { LfsBase } from "./base.mjs";
7
- import * as Effect from "effect/Effect";
8
7
  import { Bucket } from "@ref0/infra";
8
+ import * as Effect from "effect/Effect";
9
9
  import * as Context from "effect/Context";
10
10
  import * as Layer from "effect/Layer";
11
11
  declare const Lfs_base: Context.ServiceClass<Lfs, "@ref0/git/Lfs", {
@@ -14,9 +14,10 @@ declare const Lfs_base: Context.ServiceClass<Lfs, "@ref0/git/Lfs", {
14
14
  * the repo: the read refusal for any other. `NOT_FOUND` for an object none lists or of
15
15
  * another `size`, and, under `access`, for one no ref the caller sees points at, as
16
16
  * `privateRefs` says; `DATA_LOSS` for a listed object whose bytes are gone. `signal`
17
- * aborted cancels the bucket's stream.
17
+ * aborted cancels the bucket's stream. It decides for `by` when given, as `getMany` does,
18
+ * its token's or grant's ceiling with it; else for the actor `input` names.
18
19
  */
19
- readonly get: (repo: RepoName, input: LfsGetInput) => Effect.Effect<LfsObject, GitError>;
20
+ readonly get: (repo: RepoName, input: LfsGetInput, by?: Caller) => Effect.Effect<LfsObject, GitError>;
20
21
  /**
21
22
  * Many objects at once, every read made but each one's bytes: `readable`, each object the
22
23
  * caller may read, by its oid and size, in the order asked, each once, as `get` would read
@@ -9,8 +9,8 @@ import { lfsPurge } from "./purge.mjs";
9
9
  import { lfsService } from "./service.mjs";
10
10
  import { lfsUpkeep } from "./upkeep.mjs";
11
11
  import { capsRefusal, uploadMostOf } from "./upload-most.mjs";
12
- import * as Effect from "effect/Effect";
13
12
  import { Bucket } from "@ref0/infra";
13
+ import * as Effect from "effect/Effect";
14
14
  import * as Context from "effect/Context";
15
15
  import * as Layer from "effect/Layer";
16
16
  // src/lfs/layer.ts
@@ -39,7 +39,6 @@ const lfsRegistration = /* @__PURE__ */ Effect.fnUntraced(function* (registratio
39
39
  uploadMost: uploadMostOf(caps)
40
40
  };
41
41
  const read = (one) => objectOf(parts, one);
42
- const callerOf = callerFor(void 0);
43
42
  yield* base.attach({
44
43
  service: lfsService(needs, parts),
45
44
  check: {
@@ -58,15 +57,15 @@ const lfsRegistration = /* @__PURE__ */ Effect.fnUntraced(function* (registratio
58
57
  yield* registration.addUpkeep(lfsUpkeep(registration.rows, bucket, links !== void 0));
59
58
  yield* registration.addPurge(lfsPurge(registration.rows, bucket));
60
59
  return Lfs.of({
61
- get: (repo, { oid, size, signal, internalId, request, ...input }) => Effect.provideContext(read({
62
- caller: callerOf(input),
60
+ get: (repo, { oid, size, signal, internalId, request, ...input }, by) => Effect.provideContext(acting(by, read({
61
+ caller: callerFor(by)(input),
63
62
  repo,
64
63
  oid,
65
64
  size,
66
65
  signal,
67
66
  internalId,
68
67
  request
69
- }), needs),
68
+ })), needs),
70
69
  getMany: (repo, { objects, signal, internalId, request, ...input }, by) => Effect.provideContext(Effect.map(acting(by, objectsOf(parts, {
71
70
  caller: callerFor(by)(input),
72
71
  repo,
@@ -6,9 +6,9 @@ import { decodeRow } from "../store/errors.mjs";
6
6
  import { randomText } from "../store/random.mjs";
7
7
  import { LockRow, lfsCollections, lockKey, lockRead } from "./rows.mjs";
8
8
  import { LockCreate, LockQuery, LockVerify, Unlock, bodyOf, lfsAnswer } from "./wire.mjs";
9
- import * as Clock from "effect/Clock";
10
- import * as Effect from "effect/Effect";
11
9
  import * as Schema from "effect/Schema";
10
+ import * as Effect from "effect/Effect";
11
+ import * as Clock from "effect/Clock";
12
12
  import * as DateTime from "effect/DateTime";
13
13
  // src/lfs/locks.ts
14
14
  /**
@@ -5,8 +5,8 @@ import "../contracts/lfs.mjs";
5
5
  import "../contracts/git.mjs";
6
6
  import { InternalRepoId, RepoName } from "../contracts/ids.mjs";
7
7
  import "../contracts/result.mjs";
8
- import "effect/Effect";
9
8
  import { Key } from "@ref0/infra";
9
+ import "effect/Effect";
10
10
  /** One request to a repo's `info/lfs/`, from a caller `identify` answered. */
11
11
  export interface LfsCall {
12
12
  readonly caller: Caller;
@@ -18,12 +18,12 @@ import { BatchRequest, VerifyRequest, batchMost, bodyOf, lfsAnswer } from "./wir
18
18
  import { uploadedRow } from "./uploaded.mjs";
19
19
  import { pastMost, uploadPieceBytes } from "./upload-most.mjs";
20
20
  import { fail, gitError, httpStatus } from "../contracts/result.mjs";
21
- import * as Clock from "effect/Clock";
21
+ import { Unavailable } from "@ref0/infra";
22
22
  import * as Effect from "effect/Effect";
23
+ import * as Stream from "effect/Stream";
23
24
  import * as Option from "effect/Option";
24
25
  import * as Result from "effect/Result";
25
- import { Unavailable } from "@ref0/infra";
26
- import * as Stream from "effect/Stream";
26
+ import * as Clock from "effect/Clock";
27
27
  import * as DateTime from "effect/DateTime";
28
28
  // src/lfs/objects.ts
29
29
  /**