@ref0/git 0.6.0 → 0.8.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 (476) hide show
  1. package/dist/access/namespace.d.mts +2 -0
  2. package/dist/access/private-refs.d.mts +6 -29
  3. package/dist/access/private-refs.mjs +26 -13
  4. package/dist/access/public.d.mts +6 -0
  5. package/dist/access/public.mjs +9 -0
  6. package/dist/auth/access-jwt.d.mts +10 -6
  7. package/dist/auth/access-jwt.mjs +59 -40
  8. package/dist/auth/auth-namespace.d.mts +6 -0
  9. package/dist/auth/auth-namespace.mjs +12 -0
  10. package/dist/auth/auth.d.mts +3 -6
  11. package/dist/auth/auth.mjs +2 -9
  12. package/dist/auth/authorize.mjs +35 -29
  13. package/dist/auth/bridge.mjs +8 -8
  14. package/dist/auth/fences.d.mts +1 -2
  15. package/dist/auth/fences.mjs +1 -1
  16. package/dist/auth/grants.d.mts +0 -1
  17. package/dist/auth/grants.mjs +2 -2
  18. package/dist/auth/host-function.d.mts +1 -7
  19. package/dist/auth/host-function.mjs +51 -42
  20. package/dist/auth/identify.d.mts +0 -1
  21. package/dist/auth/identify.mjs +3 -2
  22. package/dist/auth/namespaces.d.mts +2 -2
  23. package/dist/auth/policy.d.mts +7 -4
  24. package/dist/auth/policy.mjs +13 -10
  25. package/dist/auth/token-rows.mjs +3 -6
  26. package/dist/auth/tokens-layer.d.mts +40 -0
  27. package/dist/auth/tokens-layer.mjs +29 -0
  28. package/dist/auth/tokens-namespace.d.mts +2 -0
  29. package/dist/auth/tokens-public.d.mts +6 -0
  30. package/dist/auth/tokens-public.mjs +31 -0
  31. package/dist/auth/tokens.d.mts +19 -7
  32. package/dist/auth/tokens.mjs +12 -6
  33. package/dist/auth.d.mts +2 -2
  34. package/dist/auth.mjs +2 -2
  35. package/dist/client/client.d.mts +22 -15
  36. package/dist/client/client.mjs +31 -27
  37. package/dist/client/git-http.mjs +23 -6
  38. package/dist/client/local.mjs +5 -4
  39. package/dist/client/namespace.d.mts +2 -0
  40. package/dist/client/push-upload.d.mts +1 -0
  41. package/dist/client/push-upload.mjs +169 -2
  42. package/dist/client/remote-helper.mjs +5 -12
  43. package/dist/client/remote.mjs +63 -22
  44. package/dist/client/run-remote-helper.d.mts +1 -1
  45. package/dist/client/run-remote-helper.mjs +6 -6
  46. package/dist/client/slice-push.d.mts +1 -1
  47. package/dist/client/transport.mjs +26 -19
  48. package/dist/contracts/access.d.mts +18 -10
  49. package/dist/contracts/access.mjs +17 -0
  50. package/dist/contracts/actors.d.mts +73 -28
  51. package/dist/contracts/actors.mjs +45 -2
  52. package/dist/contracts/authorize.d.mts +26 -17
  53. package/dist/contracts/blobs.d.mts +1 -1
  54. package/dist/contracts/blobs.mjs +1 -1
  55. package/dist/contracts/callers.mjs +40 -0
  56. package/dist/contracts/calls-spent.d.mts +6 -4
  57. package/dist/contracts/calls-spent.mjs +10 -8
  58. package/dist/contracts/client.d.mts +16 -9
  59. package/dist/contracts/commits.d.mts +2 -2
  60. package/dist/contracts/commits.mjs +1 -1
  61. package/dist/contracts/engine.d.mts +1 -1
  62. package/dist/contracts/events.d.mts +45 -32
  63. package/dist/contracts/events.mjs +21 -10
  64. package/dist/contracts/files.d.mts +44 -44
  65. package/dist/contracts/files.mjs +1 -1
  66. package/dist/contracts/forks.d.mts +34 -58
  67. package/dist/contracts/forks.mjs +1 -1
  68. package/dist/contracts/git-events.d.mts +50 -0
  69. package/dist/contracts/git-events.mjs +23 -0
  70. package/dist/contracts/git-hooks.d.mts +254 -0
  71. package/dist/contracts/git-hooks.mjs +12 -0
  72. package/dist/contracts/git.d.mts +93 -42
  73. package/dist/contracts/git.mjs +6 -5
  74. package/dist/contracts/grants.d.mts +46 -27
  75. package/dist/contracts/ids.d.mts +16 -0
  76. package/dist/contracts/ids.mjs +19 -4
  77. package/dist/contracts/lfs.d.mts +19 -4
  78. package/dist/contracts/merges.d.mts +7 -7
  79. package/dist/contracts/namespaces.d.mts +2 -2
  80. package/dist/contracts/objects.d.mts +21 -5
  81. package/dist/contracts/opaque.mjs +27 -0
  82. package/dist/contracts/operations.d.mts +301 -101
  83. package/dist/contracts/operations.mjs +209 -0
  84. package/dist/contracts/promises.d.mts +2 -0
  85. package/dist/contracts/push-uploads.d.mts +4 -1
  86. package/dist/contracts/push-uploads.mjs +9 -4
  87. package/dist/contracts/queue.d.mts +220 -49
  88. package/dist/contracts/queue.mjs +68 -6
  89. package/dist/contracts/refs.d.mts +30 -8
  90. package/dist/contracts/refs.mjs +1 -1
  91. package/dist/contracts/remote.d.mts +53 -23
  92. package/dist/contracts/remote.mjs +22 -0
  93. package/dist/contracts/repo-records.d.mts +2 -2
  94. package/dist/contracts/repos.d.mts +100 -82
  95. package/dist/contracts/repos.mjs +47 -8
  96. package/dist/contracts/result.d.mts +73 -41
  97. package/dist/contracts/result.mjs +74 -17
  98. package/dist/contracts/rules.d.mts +734 -68
  99. package/dist/contracts/rules.mjs +84 -1
  100. package/dist/contracts/server.d.mts +20 -206
  101. package/dist/contracts/services.d.mts +1 -10
  102. package/dist/contracts/services.mjs +1 -5
  103. package/dist/contracts/signin.d.mts +140 -43
  104. package/dist/contracts/signin.mjs +36 -3
  105. package/dist/contracts/store.d.mts +1 -1
  106. package/dist/contracts/sync.d.mts +109 -90
  107. package/dist/contracts/sync.mjs +34 -7
  108. package/dist/contracts/tags.d.mts +1 -1
  109. package/dist/contracts/tags.mjs +1 -1
  110. package/dist/contracts/tokens.d.mts +247 -60
  111. package/dist/contracts/tokens.mjs +93 -21
  112. package/dist/contracts/topics.d.mts +59 -20
  113. package/dist/contracts/topics.mjs +14 -5
  114. package/dist/contracts/trees.d.mts +2 -2
  115. package/dist/contracts/trees.mjs +1 -1
  116. package/dist/contracts/work.d.mts +2 -2
  117. package/dist/contracts/work.mjs +2 -2
  118. package/dist/core/access.d.mts +10 -12
  119. package/dist/core/access.mjs +45 -11
  120. package/dist/core/clock.mjs +1 -1
  121. package/dist/core/events/deliver.d.mts +3 -2
  122. package/dist/core/events/deliver.mjs +188 -92
  123. package/dist/core/forks.mjs +78 -34
  124. package/dist/core/hooks/groups.d.mts +26 -0
  125. package/dist/core/hooks/groups.mjs +73 -0
  126. package/dist/core/hooks/namespace.d.mts +2 -0
  127. package/dist/core/hooks/order.d.mts +2 -2
  128. package/dist/core/hooks/order.mjs +6 -6
  129. package/dist/core/hooks/public.d.mts +7 -0
  130. package/dist/core/hooks/public.mjs +5 -0
  131. package/dist/core/imports.mjs +94 -10
  132. package/dist/core/index-job.mjs +11 -8
  133. package/dist/core/loose-tally.mjs +46 -0
  134. package/dist/core/merge-parts.d.mts +1 -1
  135. package/dist/core/merge-parts.mjs +1 -1
  136. package/dist/core/mirror-rows.mjs +18 -0
  137. package/dist/core/names.mjs +1 -1
  138. package/dist/core/namespaces.d.mts +2 -1
  139. package/dist/core/objects/commit-writes.mjs +5 -5
  140. package/dist/core/objects/merges.mjs +1 -1
  141. package/dist/core/objects/objects-layer.mjs +1 -1
  142. package/dist/core/objects/reading.mjs +52 -7
  143. package/dist/core/objects/tree-edits.mjs +13 -28
  144. package/dist/core/objects/trees.mjs +4 -4
  145. package/dist/core/objects/writing.mjs +4 -3
  146. package/dist/core/own-writes.mjs +1 -1
  147. package/dist/core/parts.d.mts +22 -3
  148. package/dist/core/parts.mjs +5 -3
  149. package/dist/core/promise.mjs +23 -17
  150. package/dist/core/purge.d.mts +2 -2
  151. package/dist/core/purge.mjs +89 -34
  152. package/dist/core/push.mjs +67 -79
  153. package/dist/core/receipts.d.mts +2 -2
  154. package/dist/core/receipts.mjs +28 -4
  155. package/dist/core/ref-index-job.mjs +4 -4
  156. package/dist/core/ref-view.mjs +16 -8
  157. package/dist/core/refs.mjs +41 -10
  158. package/dist/core/registered-records.mjs +30 -0
  159. package/dist/core/{claim-rows.mjs → registered-rows.mjs} +6 -6
  160. package/dist/core/repack.d.mts +2 -2
  161. package/dist/core/repack.mjs +30 -23
  162. package/dist/core/repo-info.mjs +62 -26
  163. package/dist/core/repos.mjs +18 -11
  164. package/dist/core/rules/changes.mjs +2 -2
  165. package/dist/core/rules/check.mjs +10 -10
  166. package/dist/core/rules/commit-changes.mjs +1 -1
  167. package/dist/core/rules/context.d.mts +7 -6
  168. package/dist/core/rules/context.mjs +18 -16
  169. package/dist/core/rules/fetch.mjs +78 -31
  170. package/dist/core/saved-caller-views.d.mts +72 -0
  171. package/dist/core/saved-caller-views.mjs +123 -0
  172. package/dist/core/saved-callers-public.d.mts +5 -0
  173. package/dist/core/saved-callers-public.mjs +10 -0
  174. package/dist/core/saved-callers.mjs +95 -0
  175. package/dist/core/seam.d.mts +12 -1
  176. package/dist/core/seam.mjs +4 -2
  177. package/dist/core/tokens.mjs +7 -2
  178. package/dist/core/view.d.mts +1 -1
  179. package/dist/core/view.mjs +1 -1
  180. package/dist/core/work.mjs +6 -5
  181. package/dist/effect.d.mts +2 -4
  182. package/dist/effect.mjs +2 -4
  183. package/dist/engine/commits.mjs +19 -47
  184. package/dist/engine/content.d.mts +2 -2
  185. package/dist/engine/content.mjs +1 -1
  186. package/dist/engine/diff.mjs +2 -2
  187. package/dist/engine/failures.d.mts +1 -2
  188. package/dist/engine/failures.mjs +1 -3
  189. package/dist/engine/merge-base-walk.mjs +57 -142
  190. package/dist/engine/merge-bases.mjs +5 -5
  191. package/dist/engine/merge-renames.mjs +1 -1
  192. package/dist/engine/merge.mjs +16 -14
  193. package/dist/engine/reads.d.mts +2 -2
  194. package/dist/engine/reads.mjs +1 -1
  195. package/dist/engine/xdiff.d.mts +1 -1
  196. package/dist/engine/xdiff.mjs +2 -2
  197. package/dist/event-streams/event-streams.d.mts +6 -2
  198. package/dist/event-streams/event-streams.mjs +6 -2
  199. package/dist/event-streams/stream.mjs +5 -2
  200. package/dist/extend.d.mts +2 -3
  201. package/dist/extend.mjs +2 -2
  202. package/dist/http/answers.mjs +4 -3
  203. package/dist/http/core-parts.mjs +3 -4
  204. package/dist/http/handler.mjs +12 -32
  205. package/dist/http/parts.d.mts +1 -1
  206. package/dist/http/push-uploads.mjs +7 -5
  207. package/dist/http/receive-pack.mjs +3 -3
  208. package/dist/http/upload-pack.mjs +6 -5
  209. package/dist/index.d.mts +44 -24
  210. package/dist/index.mjs +17 -8
  211. package/dist/lfs/base.d.mts +8 -5
  212. package/dist/lfs/base.mjs +2 -1
  213. package/dist/lfs/calls.mjs +3 -2
  214. package/dist/lfs/layer.d.mts +9 -7
  215. package/dist/lfs/layer.mjs +37 -22
  216. package/dist/lfs/locks.mjs +3 -3
  217. package/dist/lfs/objects.d.mts +3 -2
  218. package/dist/lfs/objects.mjs +235 -71
  219. package/dist/lfs/pointers.mjs +70 -19
  220. package/dist/lfs/purge.mjs +7 -3
  221. package/dist/lfs/rows.mjs +25 -8
  222. package/dist/lfs/service.d.mts +6 -3
  223. package/dist/lfs/service.mjs +8 -2
  224. package/dist/lfs/upkeep.mjs +53 -31
  225. package/dist/lfs/upload-most.mjs +41 -0
  226. package/dist/lfs/uploaded.mjs +59 -0
  227. package/dist/lfs/wire.mjs +1 -1
  228. package/dist/protocol/bytes/buffers.d.mts +1 -1
  229. package/dist/protocol/bytes/buffers.mjs +1 -1
  230. package/dist/protocol/bytes/deflate.d.mts +1 -1
  231. package/dist/protocol/bytes/deflate.mjs +1 -1
  232. package/dist/protocol/bytes/hmac-sha256.mjs +3 -6
  233. package/dist/protocol/bytes/inflate.d.mts +1 -1
  234. package/dist/protocol/bytes/inflate.mjs +1 -1
  235. package/dist/protocol/bytes/sha1.d.mts +1 -1
  236. package/dist/protocol/bytes/sha1.mjs +2 -2
  237. package/dist/protocol/bytes/sha256-hasher.mjs +51 -0
  238. package/dist/protocol/bytes/text.mjs +6 -1
  239. package/dist/protocol/diff/read.d.mts +1 -1
  240. package/dist/protocol/diff/read.mjs +1 -1
  241. package/dist/protocol/diff/tree-diff.d.mts +1 -1
  242. package/dist/protocol/diff/tree-diff.mjs +11 -11
  243. package/dist/protocol/objects/fsck.mjs +6 -3
  244. package/dist/protocol/objects/lfs-pointer.mjs +6 -1
  245. package/dist/protocol/objects/tag.mjs +1 -1
  246. package/dist/protocol/objects/tree.mjs +1 -1
  247. package/dist/protocol/packs/graph.mjs +1 -1
  248. package/dist/protocol/packs/idx.d.mts +1 -1
  249. package/dist/protocol/packs/idx.mjs +1 -1
  250. package/dist/protocol/packs/parts.mjs +1 -1
  251. package/dist/protocol/packs/reader.d.mts +1 -1
  252. package/dist/protocol/packs/reader.mjs +2 -2
  253. package/dist/protocol/packs/write-error.d.mts +1 -1
  254. package/dist/protocol/packs/write-error.mjs +1 -1
  255. package/dist/protocol/packs/writer.mjs +4 -4
  256. package/dist/protocol/wire/advertisement.d.mts +1 -1
  257. package/dist/protocol/wire/advertisement.mjs +1 -1
  258. package/dist/protocol/wire/fetch.d.mts +1 -1
  259. package/dist/protocol/wire/fetch.mjs +1 -1
  260. package/dist/protocol/wire/lines.d.mts +1 -1
  261. package/dist/protocol/wire/lines.mjs +2 -2
  262. package/dist/protocol/wire/push-uploads.mjs +4 -2
  263. package/dist/protocol/wire/receive-pack.d.mts +1 -1
  264. package/dist/protocol/wire/receive-pack.mjs +1 -1
  265. package/dist/protocol/wire/report-status.d.mts +1 -1
  266. package/dist/protocol/wire/report-status.mjs +1 -1
  267. package/dist/protocol/wire/v2.d.mts +2 -2
  268. package/dist/protocol/wire/v2.mjs +2 -2
  269. package/dist/queue/advance.mjs +190 -68
  270. package/dist/queue/callers.mjs +56 -69
  271. package/dist/queue/calls.mjs +10 -11
  272. package/dist/queue/commit.mjs +28 -22
  273. package/dist/queue/host.d.mts +10 -11
  274. package/dist/queue/host.mjs +15 -7
  275. package/dist/queue/lanes.mjs +9 -18
  276. package/dist/queue/layer.d.mts +3 -3
  277. package/dist/queue/layer.mjs +11 -10
  278. package/dist/queue/limits.mjs +17 -5
  279. package/dist/queue/rows.mjs +13 -10
  280. package/dist/queue/schedule.mjs +7 -6
  281. package/dist/queue/search.mjs +11 -17
  282. package/dist/queue/state.mjs +7 -2
  283. package/dist/queue/trim.mjs +10 -5
  284. package/dist/rest/api.d.mts +1 -1
  285. package/dist/rest/blobs.d.mts +20 -20
  286. package/dist/rest/caller.d.mts +22 -20
  287. package/dist/rest/client-namespace.d.mts +2 -0
  288. package/dist/rest/client.d.mts +32 -8
  289. package/dist/rest/client.mjs +314 -388
  290. package/dist/rest/commits.d.mts +284 -284
  291. package/dist/rest/errors.d.mts +10 -10
  292. package/dist/rest/errors.mjs +1 -1
  293. package/dist/rest/events.d.mts +13 -11
  294. package/dist/rest/events.mjs +3 -1
  295. package/dist/rest/files.d.mts +48 -48
  296. package/dist/rest/forks.d.mts +131 -143
  297. package/dist/rest/handler.mjs +4 -3
  298. package/dist/rest/handlers.mjs +15 -8
  299. package/dist/rest/layer.d.mts +3 -3
  300. package/dist/rest/layer.mjs +8 -7
  301. package/dist/rest/listen.d.mts +8 -6
  302. package/dist/rest/listen.mjs +33 -77
  303. package/dist/rest/me.d.mts +18 -20
  304. package/dist/rest/me.mjs +1 -1
  305. package/dist/rest/merges.d.mts +17 -17
  306. package/dist/rest/queue.d.mts +140 -140
  307. package/dist/rest/queue.mjs +1 -1
  308. package/dist/rest/refs.d.mts +214 -214
  309. package/dist/rest/refs.mjs +1 -1
  310. package/dist/rest/repos.d.mts +123 -135
  311. package/dist/rest/tags.d.mts +30 -30
  312. package/dist/rest/tokens.d.mts +250 -260
  313. package/dist/rest/tokens.mjs +10 -42
  314. package/dist/rest/topics.d.mts +162 -162
  315. package/dist/rest/topics.mjs +1 -1
  316. package/dist/rest/trees.d.mts +117 -117
  317. package/dist/rest/wire.d.mts +7 -5
  318. package/dist/rest/wire.mjs +4 -3
  319. package/dist/rest/work.d.mts +69 -69
  320. package/dist/rest/work.mjs +1 -1
  321. package/dist/rest.d.mts +1 -7
  322. package/dist/rest.mjs +1 -5
  323. package/dist/server/check-fetch.mjs +9 -0
  324. package/dist/server/extension.mjs +3 -115
  325. package/dist/server/git-layer.d.mts +30 -5
  326. package/dist/server/git-layer.mjs +59 -29
  327. package/dist/server/git-namespace.d.mts +4 -4
  328. package/dist/server/git-namespace.mjs +6 -4
  329. package/dist/server/joined.d.mts +83 -0
  330. package/dist/server/joined.mjs +91 -0
  331. package/dist/server/registry.d.mts +7 -3
  332. package/dist/server/registry.mjs +135 -31
  333. package/dist/server/server.d.mts +9 -3
  334. package/dist/server/server.mjs +277 -208
  335. package/dist/signin/context.d.mts +2 -2
  336. package/dist/signin/context.mjs +28 -37
  337. package/dist/signin/device.mjs +5 -5
  338. package/dist/signin/forms.mjs +1 -1
  339. package/dist/signin/grants.d.mts +2 -3
  340. package/dist/signin/grants.mjs +5 -5
  341. package/dist/signin/layer.d.mts +9 -0
  342. package/dist/signin/layer.mjs +41 -0
  343. package/dist/signin/namespace.d.mts +2 -0
  344. package/dist/signin/public.d.mts +6 -0
  345. package/dist/signin/public.mjs +5 -0
  346. package/dist/signin/route.mjs +47 -21
  347. package/dist/signin/web.mjs +3 -3
  348. package/dist/signin/wire.mjs +1 -1
  349. package/dist/storage/calls.d.mts +1 -1
  350. package/dist/storage/calls.mjs +4 -4
  351. package/dist/storage/clean-up.mjs +15 -6
  352. package/dist/storage/counted-bucket.mjs +34 -51
  353. package/dist/storage/fetch.mjs +1 -1
  354. package/dist/storage/fsck.mjs +12 -2
  355. package/dist/storage/graph-rebuild.mjs +262 -0
  356. package/dist/storage/host-bucket.mjs +1 -1
  357. package/dist/storage/index-build.d.mts +2 -2
  358. package/dist/storage/index-build.mjs +103 -15
  359. package/dist/storage/index-fetch.mjs +10 -6
  360. package/dist/storage/index-graph.mjs +1 -1
  361. package/dist/storage/index-layers.mjs +1 -1
  362. package/dist/storage/index-visible.mjs +1 -1
  363. package/dist/storage/lfs-pointers.d.mts +5 -5
  364. package/dist/storage/lfs-pointers.mjs +37 -11
  365. package/dist/storage/loose.mjs +4 -1
  366. package/dist/storage/memory-budget.mjs +8 -2
  367. package/dist/storage/merge-cut.mjs +24 -1
  368. package/dist/storage/merge-fence.mjs +82 -20
  369. package/dist/storage/merge-most.mjs +1 -0
  370. package/dist/storage/merge-plan.mjs +5 -2
  371. package/dist/storage/merge-row.mjs +17 -5
  372. package/dist/storage/merge-stream.mjs +25 -13
  373. package/dist/storage/merge-write.mjs +1 -1
  374. package/dist/storage/merge.d.mts +2 -2
  375. package/dist/storage/merge.mjs +1 -1
  376. package/dist/storage/object-rows.d.mts +2 -2
  377. package/dist/storage/object-rows.mjs +20 -4
  378. package/dist/storage/pack-ranges.d.mts +3 -1
  379. package/dist/storage/pack-ranges.mjs +168 -69
  380. package/dist/storage/pack-reads.mjs +4 -4
  381. package/dist/storage/pack-receive.d.mts +1 -1
  382. package/dist/storage/pack-receive.mjs +17 -15
  383. package/dist/storage/packs.d.mts +1 -1
  384. package/dist/storage/packs.mjs +103 -79
  385. package/dist/storage/placed-reads.mjs +81 -15
  386. package/dist/storage/prune-seen.mjs +126 -0
  387. package/dist/storage/prune-walk.mjs +87 -99
  388. package/dist/storage/prune.mjs +113 -50
  389. package/dist/storage/push-uploads.mjs +4 -2
  390. package/dist/storage/quarantine.d.mts +2 -2
  391. package/dist/storage/ready.d.mts +2 -2
  392. package/dist/storage/ready.mjs +15 -6
  393. package/dist/storage/receive-files.mjs +1 -1
  394. package/dist/storage/receive-links.mjs +1 -1
  395. package/dist/storage/receive-state.d.mts +2 -2
  396. package/dist/storage/receive-state.mjs +2 -2
  397. package/dist/storage/receive-steps.mjs +1 -1
  398. package/dist/storage/repack-contained.mjs +24 -16
  399. package/dist/storage/repack-job.d.mts +2 -2
  400. package/dist/storage/repack-job.mjs +5 -4
  401. package/dist/storage/repack.d.mts +2 -2
  402. package/dist/storage/repack.mjs +12 -5
  403. package/dist/storage/rows.d.mts +2 -2
  404. package/dist/storage/rows.mjs +1 -1
  405. package/dist/storage/runs.d.mts +2 -2
  406. package/dist/storage/runs.mjs +15 -6
  407. package/dist/storage/send-list.mjs +6 -6
  408. package/dist/storage/single-flight.mjs +2 -2
  409. package/dist/storage/swap-walk.mjs +1 -1
  410. package/dist/storage/unpack.mjs +8 -1
  411. package/dist/store/call-count.d.mts +24 -4
  412. package/dist/store/call-count.mjs +158 -44
  413. package/dist/store/catalogue.d.mts +1 -1
  414. package/dist/store/catalogue.mjs +2 -2
  415. package/dist/store/crossing.mjs +2 -6
  416. package/dist/store/cursor-seal.mjs +1 -1
  417. package/dist/store/errors.d.mts +7 -3
  418. package/dist/store/errors.mjs +41 -13
  419. package/dist/store/job-try.mjs +119 -15
  420. package/dist/store/list-job.mjs +5 -5
  421. package/dist/store/outbox.d.mts +2 -2
  422. package/dist/store/outbox.mjs +75 -16
  423. package/dist/store/promises.d.mts +2 -2
  424. package/dist/store/promises.mjs +31 -6
  425. package/dist/store/queue-jobs.mjs +1 -1
  426. package/dist/store/records.d.mts +2 -2
  427. package/dist/store/records.mjs +22 -24
  428. package/dist/store/ref-rows.d.mts +2 -2
  429. package/dist/store/ref-rows.mjs +6 -6
  430. package/dist/store/repo-record.mjs +29 -12
  431. package/dist/store/reservations.mjs +35 -8
  432. package/dist/store/scopes.mjs +12 -5
  433. package/dist/store/topic-jobs.mjs +8 -8
  434. package/dist/sync/bound.d.mts +1 -3
  435. package/dist/sync/bound.mjs +30 -42
  436. package/dist/sync/github.d.mts +5 -6
  437. package/dist/sync/github.mjs +37 -42
  438. package/dist/sync/http.mjs +15 -0
  439. package/dist/sync/import.mjs +30 -19
  440. package/dist/sync/layer.d.mts +13 -0
  441. package/dist/sync/layer.mjs +73 -0
  442. package/dist/sync/mirror.mjs +137 -58
  443. package/dist/sync/publish.mjs +3 -6
  444. package/dist/sync/step.mjs +223 -85
  445. package/dist/sync/tries.mjs +22 -15
  446. package/dist/sync.d.mts +3 -6
  447. package/dist/sync.mjs +3 -6
  448. package/dist/topics/advance.mjs +210 -94
  449. package/dist/topics/calls.mjs +8 -8
  450. package/dist/topics/directory.mjs +35 -12
  451. package/dist/topics/host.d.mts +5 -8
  452. package/dist/topics/host.mjs +42 -19
  453. package/dist/topics/layer.d.mts +381 -0
  454. package/dist/topics/layer.mjs +62 -0
  455. package/dist/topics/members.mjs +39 -10
  456. package/dist/topics/namespace.d.mts +2 -0
  457. package/dist/topics/public.d.mts +6 -0
  458. package/dist/topics/public.mjs +13 -0
  459. package/dist/topics/rows.mjs +12 -3
  460. package/dist/topics/topic.mjs +11 -10
  461. package/package.json +8 -13
  462. package/dist/access.d.mts +0 -2
  463. package/dist/access.mjs +0 -1
  464. package/dist/core/hooks/post-receive.mjs +0 -216
  465. package/dist/core/hooks/pre-receive.d.mts +0 -12
  466. package/dist/core/hooks/pre-receive.mjs +0 -36
  467. package/dist/engine/merge-base-walk.d.mts +0 -3
  468. package/dist/server/extension.d.mts +0 -21
  469. package/dist/server/routes.d.mts +0 -32
  470. package/dist/server/routes.mjs +0 -69
  471. package/dist/sync/import.d.mts +0 -10
  472. package/dist/sync/jobs.d.mts +0 -9
  473. package/dist/sync/jobs.mjs +0 -75
  474. package/dist/sync/mirror.d.mts +0 -13
  475. package/dist/sync/publish.d.mts +0 -6
  476. /package/dist/core/{claim-rows.d.mts → registered-rows.d.mts} +0 -0
@@ -1,9 +1,92 @@
1
+ import { Actor, ActorId } from "./actors.mjs";
2
+ import { actingWith } from "./callers.mjs";
3
+ import "./engine.mjs";
4
+ import { Oid, RepoName } from "./ids.mjs";
5
+ import { FetchRequest } from "./object-values.mjs";
6
+ import { EffectValue, FunctionValue, RequestValue, StreamValue } from "./opaque.mjs";
7
+ import { RefSource, RefUpdate } from "./refs.mjs";
8
+ import { RepoStats } from "./repos.mjs";
9
+ import * as Schema from "effect/Schema";
1
10
  import * as Context from "effect/Context";
2
11
  // src/contracts/rules.ts
12
+ const PushFacts = /* @__PURE__ */ Schema.Struct({
13
+ bytes: Schema.Number,
14
+ objects: Schema.Number,
15
+ updates: Schema.mutable(Schema.Array(RefUpdate))
16
+ });
17
+ Schema.Boolean;
18
+ /**
19
+ * The Schema of a shape typed `PushContext & { …fields }`, with `PushContext`'s request, Effect
20
+ * and Stream held as themselves.
21
+ */
22
+ const pushContextWith = (fields) => actingWith({
23
+ repo: RepoName,
24
+ subject: Schema.optionalKey(ActorId),
25
+ source: RefSource,
26
+ push: PushFacts,
27
+ stats: RepoStats,
28
+ request: Schema.optionalKey(RequestValue),
29
+ pushOptions: Schema.optionalKey(Schema.Array(Schema.String)),
30
+ changes: EffectValue(),
31
+ commitChanges: StreamValue(),
32
+ ...fields
33
+ });
34
+ FunctionValue();
35
+ /** What every fetch rule's input names: the caller's actor and the repo. */
36
+ const FetchRuleOf = /* @__PURE__ */ Schema.Struct({
37
+ actor: Actor,
38
+ repo: RepoName
39
+ });
40
+ ({
41
+ ...FetchRuleOf.fields,
42
+ ...FetchRequest.fields
43
+ }), Schema.Literal("git");
44
+ const FetchRawTarget = /* @__PURE__ */ Schema.Struct({
45
+ kind: Schema.Literal("raw"),
46
+ oid: Oid
47
+ });
48
+ const FetchArchiveTarget = /* @__PURE__ */ Schema.Struct({
49
+ kind: Schema.Literal("archive"),
50
+ oid: Oid
51
+ });
52
+ const FetchLfsTarget = /* @__PURE__ */ Schema.Struct({
53
+ kind: Schema.Literal("lfs"),
54
+ oid: Schema.String,
55
+ size: Schema.Number
56
+ });
57
+ /**
58
+ * Bytes read outside Git's protocol, once Git found them visible to the caller: a blob's raw
59
+ * bytes, an archive of a commit, checked as it's linked and again as it's downloaded, or a Git
60
+ * LFS object, by its SHA-256 and size. A hidden or missing object never reaches a rule.
61
+ */
62
+ const FetchReadTarget = /* @__PURE__ */ Schema.Union([
63
+ FetchRawTarget,
64
+ FetchArchiveTarget,
65
+ FetchLfsTarget
66
+ ]);
67
+ const readRuleOf = {
68
+ ...FetchRuleOf.fields,
69
+ request: Schema.optionalKey(RequestValue)
70
+ };
71
+ Schema.Struct({
72
+ ...readRuleOf,
73
+ ...FetchRawTarget.fields
74
+ }), Schema.Struct({
75
+ ...readRuleOf,
76
+ ...FetchArchiveTarget.fields
77
+ }), Schema.Struct({
78
+ ...readRuleOf,
79
+ ...FetchLfsTarget.fields
80
+ });
81
+ Schema.optional(RequestValue);
82
+ /** A depth a fetch rule sets: a whole number above 0. */
83
+ const RuledDepth = /* @__PURE__ */ Schema.Int.check(Schema.isGreaterThan(0));
84
+ /** A depth is all a fetch rule may set: a client that asked for no filter is never given one. */
85
+ const FetchAdjustment = /* @__PURE__ */ Schema.Struct({ depth: Schema.optionalKey(RuledDepth) });
3
86
  /**
4
87
  * The host's push and fetch rules. Core reads it with `Effect.serviceOption` where it reads the
5
88
  * rules, after its own checks: a server with none runs none. Only core reads it, so it has no
6
89
  * accessors, as `Policy` has none.
7
90
  */
8
91
  var Rules = class extends (/* @__PURE__ */ Context.Service()("@ref0/git/Rules")) {};
9
- export { Rules };
92
+ export { FetchAdjustment, FetchReadTarget, PushFacts, RuledDepth, Rules, pushContextWith };
@@ -1,35 +1,30 @@
1
- import { Clock, Duration, Store } from "./promises.mjs";
1
+ import { Duration } from "./promises.mjs";
2
2
  import { AccessOption } from "./access.mjs";
3
3
  import { Authorize } from "./authorize.mjs";
4
- import { Actor, ActorInput, Caller, GitAuth, GitAuthorize } from "./actors.mjs";
4
+ import { Caller, GitAuth, GitAuthorize } from "./actors.mjs";
5
5
  import { BlobCalls, Blobs } from "./blobs.mjs";
6
6
  import { CommitCalls, Commits } from "./commits.mjs";
7
- import { EventDelivery, Events, EventsHandler } from "./events.mjs";
7
+ import { Events } from "./events.mjs";
8
8
  import { FileCalls, Files } from "./files.mjs";
9
9
  import { ForkCalls, Forks } from "./forks.mjs";
10
- import { GrantAgainRequest, GrantResolver } from "./grants.mjs";
11
- import { InternalRepoId, RepoName } from "./ids.mjs";
12
10
  import { LfsCalls, LfsFeature } from "./lfs.mjs";
13
11
  import { MergeCalls } from "./merges.mjs";
14
- import { Bucket as Bucket$1, EffectiveLimits, IndexedObjectsFactory, ObjectsFactory } from "./objects.mjs";
15
- import { MergeQueueCalls, MergeQueueLayerOptions, QueueKeys } from "./queue.mjs";
16
- import { Operation } from "./operations.mjs";
12
+ import { EffectiveLimits, IndexedObjectsFactory, ObjectsFactory } from "./objects.mjs";
13
+ import { MergeQueueCalls, MergeQueueLayerOptions } from "./queue.mjs";
17
14
  import { PushOptions } from "./push-uploads.mjs";
18
15
  import { RefCalls, Refs } from "./refs.mjs";
19
- import { RepoCalls, RepoRecord, Repos } from "./repos.mjs";
16
+ import { RepoCalls, Repos } from "./repos.mjs";
20
17
  import { RepoRecords } from "./repo-records.mjs";
21
- import { EffectCalls } from "./services.mjs";
22
- import { ImportState } from "./sync.mjs";
23
18
  import { TagCalls, Tags } from "./tags.mjs";
24
19
  import { TreeCalls, Trees } from "./trees.mjs";
25
- import { Awaitable, GitError, GitErrorCode, HostFunctionName, Result } from "./result.mjs";
26
- import { FetchRule, GitHooks, PushRule, Rules } from "./rules.mjs";
27
- import { GitSignInOptions } from "./signin.mjs";
28
- import { TokenCalls, TokenScope, TokensFeature } from "./tokens.mjs";
20
+ import { GitError, Result } from "./result.mjs";
21
+ import { FetchRule, PushRule, Rules } from "./rules.mjs";
22
+ import { SignInLayerOptions } from "./signin.mjs";
23
+ import { TokenCalls, TokensFeature } from "./tokens.mjs";
29
24
  import { Work, WorkCalls } from "./work.mjs";
30
25
  import { TopicCalls, TopicsFactory } from "./topics.mjs";
31
- import { Bucket, CallLimits, JobDefinition, JobQueue, Records } from "@ref0/infra";
32
26
  import * as Effect from "effect/Effect";
27
+ import { Bucket, CallLimits, JobQueue, Records } from "@ref0/infra";
33
28
  import * as Layer from "effect/Layer";
34
29
  import * as ManagedRuntime from "effect/ManagedRuntime";
35
30
  /** The call modules' services, which a server's runtime holds, each deciding for its `by`. */
@@ -47,29 +42,6 @@ export type GitNeeds = Records.Records | JobQueue.JobQueue | CallLimits.CallLimi
47
42
  export type GitAdapter = Layer.Layer<never, Error> | readonly Layer.Layer<never, Error>[];
48
43
  /** What `adapter` gives. */
49
44
  export type ProvidedBy<A extends GitAdapter> = A extends readonly (infer L extends Layer.Any)[] ? Layer.Success<L> : A extends Layer.Any ? Layer.Success<A> : never;
50
- export interface ResolveInput extends ActorInput {
51
- readonly url: URL;
52
- readonly path: string;
53
- readonly signal: AbortSignal;
54
- }
55
- /** Names the repo an HTTP request means, after identification. Direct calls name it already. */
56
- export type Resolve = (input: ResolveInput) => Awaitable<RepoName | undefined>;
57
- export interface HostFunctionFailure {
58
- /** Also returned to the caller, in the error's context. */
59
- readonly id: string;
60
- readonly function: HostFunctionName;
61
- readonly timedOut: boolean;
62
- readonly repo?: RepoName;
63
- readonly operation?: Operation;
64
- }
65
- export interface Refusal {
66
- readonly code: GitErrorCode;
67
- readonly message: string;
68
- readonly function?: HostFunctionName;
69
- readonly repo?: RepoName;
70
- readonly operation?: Operation;
71
- readonly actor?: Actor;
72
- }
73
45
  /** Each piece adds its own options: C's are these. */
74
46
  export interface GitServerOptions<A extends GitAdapter = GitAdapter> {
75
47
  readonly adapter: A;
@@ -99,9 +71,7 @@ export interface GitServerOptions<A extends GitAdapter = GitAdapter> {
99
71
  /** `topics()`: `git.topics`, their jobs and their events, across the repos a `queue` has. */
100
72
  readonly topics?: TopicsFactory;
101
73
  /** Serves GitHub's device flow and the web flow at `/login/...`; needs `tokens`. */
102
- readonly signIn?: GitSignInOptions;
103
- /** Where each scope's events go, a batch at a time, in `seq` order: Git writes none without it. */
104
- readonly events?: EventsHandler | EventDelivery;
74
+ readonly signIn?: SignInLayerOptions;
105
75
  readonly auth?: GitAuth;
106
76
  readonly authorize?: GitAuthorize;
107
77
  /**
@@ -111,16 +81,14 @@ export interface GitServerOptions<A extends GitAdapter = GitAdapter> {
111
81
  * Until 2a's `Git.layer`, and gone in 2c.
112
82
  */
113
83
  readonly rules?: readonly (PushRule | FetchRule | Effect.Effect<PushRule | FetchRule, GitError>)[];
114
- readonly hooks?: GitHooks;
115
84
  readonly basePath?: string;
116
- readonly resolve?: Resolve;
117
- readonly onError?: (cause: unknown, failed: HostFunctionFailure) => void;
118
- readonly onRefused?: (refusal: Refusal) => void;
119
85
  /**
120
86
  * The most one fetch may send and how long it may stream: Git's HTTP limits each fetch by them,
121
87
  * and a fetch whose own `limits` pass them is refused. A deleted repo's packs stay readable for
122
- * their time, so no clone is cut by clean-up. By default 2,000,000 objects, 4 GiB and an hour;
123
- * the time is never under an hour, which streams about 3.6 GB at 1 MB/s.
88
+ * their time, so no clone is cut by clean-up. By default 2,000,000 objects, 4 GiB and an hour,
89
+ * which streams about 3.6 GB at 1 MB/s. The time guards every reader of a pack: a request's
90
+ * fetch, and the jobs and forks that read under their own leases, which a platform's request cap
91
+ * doesn't bound. A host may lower it as far as `pruneFloor`, an hour, never below.
124
92
  */
125
93
  readonly fetchLimits?: EffectiveLimits;
126
94
  /** A large push's pack straight to the bucket: off unless set, and a bucket that signs parts. */
@@ -133,7 +101,7 @@ export interface GitServerOptions<A extends GitAdapter = GitAdapter> {
133
101
  readonly maxDuration?: Duration;
134
102
  }
135
103
  /**
136
- * `access`, private branches from `@ref0/git/access`, only over objects that keep the
104
+ * `access`, private branches from `PrivateRefs.layer`, only over objects that keep the
137
105
  * reachability index, `packs()`: a caller's view of a repo's objects is read from it.
138
106
  */
139
107
  type AccessSetup = {
@@ -174,17 +142,12 @@ export interface GitServer<R = never> extends ServerCalls {
174
142
  readonly fetch: (request: Request) => Promise<Response>;
175
143
  /** `undefined` only for a URL Git doesn't own. */
176
144
  readonly route: (request: Request) => Promise<Response | undefined>;
177
- /**
178
- * Who `request` is, its calls counted into `counted` when one is handed: a stream's check of who
179
- * its request is now counts into the count of the request that opened it, so a revoke still
180
- * reaches the stream and its every call is bounded (Q855 (5), Q915).
181
- */
182
- readonly identify: (request: Request, counted?: GitRequest) => Promise<Result<Caller>>;
145
+ /** Who `request` is, as `authorize` sees it: its token's, its grant's, or the host's session's. */
146
+ readonly identify: (request: Request) => Promise<Result<Caller>>;
183
147
  /**
184
148
  * The isolate's runtime, over the adapter's Layers and Git's own wiring, which registers Git's
185
149
  * jobs on the adapter's queue: built at most once, starting as the tick that made the server
186
- * ends, so `extendGit` and `syncJobs` join in that tick, and a module that only runs jobs has
187
- * them. A failed build stays failed: every call answers `UNAVAILABLE`, and `fetch` a 503. It
150
+ * ends, so a joined Layer joins in that tick, and a module that only runs jobs has them. A failed build stays failed: every call answers `UNAVAILABLE`, and `fetch` a 503. It
188
151
  * holds `RepoRecords`, `Authorize`, `Refs`, `Rules`, `Events` and the call modules' services beside
189
152
  * `R`, the adapter's services, and `Tokens` with `tokens`, for an Effect host to read. Named here, so a host's inferred server type names only
190
153
  * its adapter's services. The bridge until SV's step 2c.
@@ -193,153 +156,4 @@ export interface GitServer<R = never> extends ServerCalls {
193
156
  /** Disposes `runtime`. */
194
157
  readonly close: () => Promise<void>;
195
158
  }
196
- /** What a package built on Git, such as `@ref0/github`, adds to one server. */
197
- export interface GitExtension {
198
- /** Named other than `git.…`, as Git's own jobs are. */
199
- readonly jobs?: readonly JobDefinition[];
200
- readonly pushRules?: readonly PushRule[];
201
- readonly grants?: readonly GrantResolver[];
202
- /**
203
- * Runs in the server's build, after Git's own wiring and before the extension's jobs are
204
- * registered, with the adapter as promises: the bridge until SV's step 2b-1 deletes it with
205
- * `extendGit` (Q1030).
206
- */
207
- readonly bind?: (adapter: BoundAdapter) => void;
208
- }
209
- /**
210
- * The adapter as `GitExtension.bind` takes it: the store and clock as the bridge's promise shapes,
211
- * and the bucket as infra's `Bucket` service, through the server's door, each call charged by the
212
- * `bucketCall` that makes it (Q1114).
213
- */
214
- export interface BoundAdapter {
215
- readonly store: Store;
216
- readonly bucket: Bucket$1 | undefined;
217
- readonly clock: Clock;
218
- }
219
- /**
220
- * One request's count of the calls Git makes for it, which only `ExtendedGit.request` makes, with
221
- * nothing a package reads: one built by hand counts nothing. A bridge, as `ExtendedGit` is (#725):
222
- * SV's step 2b-1 deletes it with `ExtendedGit` (Q1030).
223
- */
224
- export interface GitRequest {
225
- readonly kind: 'git-request';
226
- }
227
- export interface ExtendedGit {
228
- /**
229
- * Where the server serves Git's URLs, as it routes by them: `''` at the host's root, else one
230
- * leading slash and no trailing one, as `/git`. A package builds its links to Git's routes on it.
231
- */
232
- readonly basePath: string;
233
- /**
234
- * The `keys` of the one queue the server was made with, which every repo's queue has:
235
- * `undefined` for a function of the repo, whose repos may each have another, or no queue.
236
- * A bridge, as `ExtendedGit` is: SV's step 2b-1 deletes it with `extendGit` (Q1030).
237
- */
238
- readonly queueKeys: QueueKeys | undefined;
239
- readonly internalId: (repo: RepoName) => Promise<InternalRepoId>;
240
- /**
241
- * Once the server's build has ended: success when it's built, `UNAVAILABLE` naming its failure
242
- * when it failed, as every call then answers. It rejects once the server is closed, as its calls
243
- * do. A package that serves over what its `bind` was handed waits on it first, since a step
244
- * after that bind can still fail the build. Like a call, it starts the build, which closes
245
- * joins: ask it as a call is handled, never while extensions still join. The bridge until SV's
246
- * step 2b-1 deletes it with `ExtendedGit` (Q1030).
247
- */
248
- readonly ready: () => Promise<Result<void>>;
249
- /**
250
- * A new count of one request's calls, bounded as a push's is, by the adapter's `callLimits`: a
251
- * package makes one as it serves each request and hands it to `callsFor`, `effectCallsFor`,
252
- * `access`, `effectAccess` and the server's `identify`, so every store and bucket call they make counts into one
253
- * count beside any `CallBudget` provided, and is refused past the bound, `RESOURCE_EXHAUSTED`,
254
- * "The N subrequests allowed are spent", as a Git fetch is (#725). A bridge, as Q787 names one:
255
- * SV's step 2b-1 deletes it with `ExtendedGit`, and the count rides the request's context
256
- * (Q783, Q1030).
257
- */
258
- readonly request: () => GitRequest;
259
- /**
260
- * `internalId` as an Effect, its refusal Git's error, not an `Error`'s cause. These Effect twins,
261
- * `effectRepo`, `effectAccess`, `effectGrantAgain` and `effectHostCalls` beside it, each go
262
- * through the server's door as their Promise twins do, so one the closing outlives dies closed,
263
- * count their store calls into the `CallBudget` provided around them, and answer one spent as its
264
- * refusal, as `effectCallsFor`'s calls do (Q830). Their names are a bridge's (Q787): SV's step
265
- * 2b-1 deletes them with `ExtendedGit` (Q783, Q1030).
266
- */
267
- readonly effectInternalId: (repo: RepoName) => Effect.Effect<InternalRepoId, GitError>;
268
- /**
269
- * The server's calls, each deciding for `caller`, the one `identify` answered: its token's scope
270
- * or its grant caps every call, whatever actor an input names (Q106). A bridge, as Q787 names
271
- * one: the Promise face of `effectCallsFor`'s calls, which no `CallBudget` reaches, since
272
- * Effect's context stops at a Promise. Given `request`, each call counts into it, as `request`
273
- * says. SV's step 2b-1 deletes it, with `hostCalls` and `ExtendedGit` (Q783, Q1030).
274
- */
275
- readonly callsFor: (caller: Caller, request?: GitRequest) => ServerCalls;
276
- /**
277
- * `callsFor`'s calls as Effects: the same calls, under the same guards, deciding for `caller`
278
- * alike. Each store and bucket call one makes counts into the `CallBudget` provided around it,
279
- * and is refused once that budget is spent (Q825). Given `request`, each counts into it too, as
280
- * the Promise `callsFor`'s do. With neither, nothing bounds its calls. Its name is a bridge's
281
- * (Q787): SV's step 2b-1 deletes it with `ExtendedGit` (Q783, Q1030).
282
- */
283
- readonly effectCallsFor: (caller: Caller, request?: GitRequest) => EffectCalls<ServerCalls>;
284
- /** The repo's record now, or `undefined` once it's deleted: the reverse of `internalId`. */
285
- readonly repo: (internalId: InternalRepoId) => Promise<RepoRecord | undefined>;
286
- /** `repo` as an Effect, as `effectInternalId` is `internalId`'s. */
287
- readonly effectRepo: (internalId: InternalRepoId) => Effect.Effect<RepoRecord | undefined, GitError>;
288
- /**
289
- * The server's calls with no caller, for host code such as a job: they skip `authorize`, but for
290
- * a push rule's `protect.bypass` or `lock.bypass`, which they never get. Limits, push rules and
291
- * write keys apply as for a caller. A host's own calls never lift a rule, so a host that needs
292
- * to lift one makes the call as a caller its `authorize` accepts. No input's `actor` is read, as
293
- * with `callsFor`, and their events carry no actor (Q223). A bridge, as Q787 names one: SV's
294
- * step 2b-1 deletes it, with the Promise `callsFor` and `ExtendedGit` (Q783, Q1030).
295
- */
296
- readonly hostCalls: () => ServerCalls;
297
- /** `hostCalls`' calls as Effects, as `effectCallsFor`'s are `callsFor`'s. */
298
- readonly effectHostCalls: () => EffectCalls<ServerCalls>;
299
- /**
300
- * The ceiling Git's own calls apply to `caller` on `repo` (Q251): its token's scope when the
301
- * token covers the repo, its grant's when the grant reaches it, `undefined` when either doesn't.
302
- * A caller with neither, such as a host's session, answers `'write'`: Git sets it no ceiling, so
303
- * the host's `authorize` alone decides. A drop-in's own writes check it beside `authorize`.
304
- * Given `request`, its calls count into it, as `callsFor`'s do.
305
- */
306
- readonly access: (caller: Caller, repo: RepoName, request?: GitRequest) => Promise<TokenScope | undefined>;
307
- /**
308
- * `access` as an Effect, as `effectInternalId` is `internalId`'s. Given `internalId`, the repo
309
- * the caller holds `repo` to, the ceiling is on that repo, and no catalogue read finds it.
310
- */
311
- readonly effectAccess: (caller: Caller, repo: RepoName, request?: GitRequest, internalId?: InternalRepoId) => Effect.Effect<TokenScope | undefined, GitError>;
312
- /**
313
- * Where the repo's `git.sync.import` stands, `undefined` for a repo no import made, read as
314
- * `effectRepo` reads, through the door and into a provided `CallBudget`, with no caller: the
315
- * extension has decided who may ask. A drop-in that lands records over a repo's history asks it
316
- * first, since only `done` holds that history (Q882).
317
- */
318
- readonly importState: (internalId: InternalRepoId) => Effect.Effect<ImportState | undefined, GitError>;
319
- /**
320
- * The caller the extensions' resolver named `resolver` gives back for `input.id` now, through its
321
- * `again`, acting for `input.actor` and, if given, `input.subject`, its grant attached as
322
- * `identify` attaches one: `callsFor` holds it to the grant's scope ceiling and `reaches` on
323
- * every call, as on any request, whatever `authorize` says. `undefined` when no resolver has that
324
- * name, or its grant ended, acts for someone else or has another `id`: a refusal and nothing
325
- * else, so a host or extension never falls back to a broader caller on it. `input.signal` is
326
- * optional, and joined with Git's own: a caller's signal that aborts, such as a download that
327
- * ends, stops the resolver's read.
328
- */
329
- readonly grantAgain: (resolver: string, input: GrantAgainRequest) => Promise<Caller | undefined>;
330
- /** `grantAgain` as an Effect, as `effectInternalId` is `internalId`'s. */
331
- readonly effectGrantAgain: (resolver: string, input: GrantAgainRequest) => Effect.Effect<Caller | undefined, GitError>;
332
- /**
333
- * Which grant made `caller`: the resolver's name and the grant's `id`, as Git attached them when
334
- * `identify` or `grantAgain` made it, or `undefined` for any caller no resolver made. It's Git's
335
- * own word, and the only one to trust: a caller's `grant` field is whatever its builder wrote, so
336
- * a caller built by hand, or one whose `grant` was rewritten, answers its real grant or none.
337
- * Work that keeps a caller's grant, such as a link or a queued entry, keeps this, and asks
338
- * `grantAgain` with it later.
339
- */
340
- readonly grantOf: (caller: Caller) => {
341
- readonly resolver: string;
342
- readonly id: string;
343
- } | undefined;
344
- }
345
159
  export {};
@@ -1,7 +1,4 @@
1
1
  import { Caller } from "./actors.mjs";
2
- import { GitClient as GitClient$1 } from "./client.mjs";
3
- import { EventDelivery, EventsInput } from "./events.mjs";
4
- import { SavedHandlerOptions } from "./handlers.mjs";
5
2
  import { GitError, Result } from "./result.mjs";
6
3
  import { GitStore as GitStore$1 } from "./store.mjs";
7
4
  import * as Effect from "effect/Effect";
@@ -17,11 +14,5 @@ export type EffectCalls<T, R = never> = { readonly [K in keyof T]: NonNullable<T
17
14
  * direct calls do. A call module's service holds these, and its accessors pass `by` on.
18
15
  */
19
16
  export type ByCalls<T, R = never> = EffectCalls<{ readonly [K in keyof T]: T[K] extends ((...args: infer Args) => infer Answer) ? (...args: [...Args, by?: Caller]) => Answer : never; }, R>;
20
- /** `events` as an Effect: a failure, a defect or an interruption sends the whole batch again. */
21
- export interface EffectGitEvents extends SavedHandlerOptions<(input: EventsInput) => Effect.Effect<void, unknown>> {}
22
- /** A client of one remote, as `effectGitClient` makes it. */
23
- export declare const GitClient: Context.Service<EffectCalls<GitClient$1, never>, EffectCalls<GitClient$1, never>>;
24
17
  export declare const GitStore: Context.Service<EffectCalls<GitStore$1, never>, EffectCalls<GitStore$1, never>>;
25
- export declare const GitCaller: Context.Service<Caller<unknown>, Caller<unknown>>;
26
- /** The host's `events`, for a server made with Effect: `EventDelivery` on the Promise surface. */
27
- export declare const GitEvents: Context.Service<EventDelivery, EffectGitEvents>;
18
+ export declare const GitCaller: Context.Service<Caller<unknown>, Caller<unknown>>;
@@ -1,9 +1,5 @@
1
1
  import * as Context from "effect/Context";
2
2
  // src/contracts/services.ts
3
- /** A client of one remote, as `effectGitClient` makes it. */
4
- const GitClient = /* @__PURE__ */ Context.Service("@ref0/git/GitClient");
5
3
  const GitStore = /* @__PURE__ */ Context.Service("@ref0/git/GitStore");
6
4
  const GitCaller = /* @__PURE__ */ Context.Service("@ref0/git/GitCaller");
7
- /** The host's `events`, for a server made with Effect: `EventDelivery` on the Promise surface. */
8
- const GitEvents = /* @__PURE__ */ Context.Service("@ref0/git/GitEvents");
9
- export { GitCaller, GitClient, GitEvents, GitStore };
5
+ export { GitCaller, GitStore };
@@ -1,5 +1,5 @@
1
- import { Moment } from "./repos.mjs";
2
- import { Awaitable } from "./result.mjs";
1
+ import { GitError } from "./result.mjs";
2
+ import * as Effect from "effect/Effect";
3
3
  import * as Schema from "effect/Schema";
4
4
  /**
5
5
  * The GitHub scope a device asks for so its token can push, as gh does: Git's refusal of a push
@@ -8,69 +8,166 @@ import * as Schema from "effect/Schema";
8
8
  */
9
9
  export declare const ghWriteScope = "repo";
10
10
  /** A browser app registered for the web flow: its callbacks, and a secret if it's confidential. */
11
- export interface OAuthClient {
12
- readonly id: string;
11
+ export declare const OAuthClient: Schema.Struct<{
12
+ readonly id: Schema.String;
13
13
  /** Each callback the client may name, matched exactly. The first is the default. */
14
- readonly redirectUris: readonly string[];
14
+ readonly redirectUris: Schema.$Array<Schema.String>;
15
15
  /** Sent at the exchange by a confidential client; a public client proves itself with PKCE. */
16
- readonly secret?: string;
17
- }
16
+ readonly secret: Schema.optionalKey<Schema.String>;
17
+ }>;
18
+ export type OAuthClient = typeof OAuthClient.Type;
18
19
  /**
19
20
  * Turns on sign-in: GitHub's device flow, which also accepts `gh`'s client ID, and the web flow for
20
21
  * `clients`, both approved on the host's `approvalPage`. Needs `tokens()`, which mints the token.
21
22
  */
22
- export interface GitSignInOptions {
23
+ export interface SignInLayerOptions {
23
24
  readonly clients?: readonly OAuthClient[];
24
- readonly approvalPage: (input: ApprovalPageInput) => Awaitable<Response>;
25
+ readonly approvalPage: (input: ApprovalPageInput) => Effect.Effect<Response, GitError>;
25
26
  }
27
+ export declare const ApprovalBase: Schema.Struct<{
28
+ /** The requesting OAuth client's ID. */
29
+ readonly clientId: Schema.String;
30
+ /** The scopes the client asked for, which the host may show and narrow. */
31
+ readonly scopes: Schema.$Array<Schema.String>;
32
+ /** When the request can no longer be approved. */
33
+ readonly expiresAt: Schema.Number;
34
+ }>;
35
+ export type ApprovalBase = typeof ApprovalBase.Type;
36
+ export declare const DeviceApproval: Schema.Struct<{
37
+ /** The requesting OAuth client's ID. */
38
+ readonly clientId: Schema.String;
39
+ /** The scopes the client asked for, which the host may show and narrow. */
40
+ readonly scopes: Schema.$Array<Schema.String>;
41
+ /** When the request can no longer be approved. */
42
+ readonly expiresAt: Schema.Number;
43
+ readonly kind: Schema.Literal<"device">;
44
+ /** As the device shows it: `XXXX-XXXX`. */
45
+ readonly userCode: Schema.String;
46
+ }>;
47
+ export type DeviceApproval = typeof DeviceApproval.Type;
48
+ export declare const WebApproval: Schema.Struct<{
49
+ /** The requesting OAuth client's ID. */
50
+ readonly clientId: Schema.String;
51
+ /** The scopes the client asked for, which the host may show and narrow. */
52
+ readonly scopes: Schema.$Array<Schema.String>;
53
+ /** When the request can no longer be approved. */
54
+ readonly expiresAt: Schema.Number;
55
+ readonly kind: Schema.Literal<"web">;
56
+ /** Where the browser goes with the code once approved. */
57
+ readonly redirectUri: Schema.String;
58
+ }>;
59
+ export type WebApproval = typeof WebApproval.Type;
60
+ export declare const ApprovalPrompt: Schema.Union<readonly [Schema.Struct<{
61
+ /** The requesting OAuth client's ID. */
62
+ readonly clientId: Schema.String;
63
+ /** The scopes the client asked for, which the host may show and narrow. */
64
+ readonly scopes: Schema.$Array<Schema.String>;
65
+ /** When the request can no longer be approved. */
66
+ readonly expiresAt: Schema.Number;
67
+ readonly kind: Schema.Literal<"device">;
68
+ /** As the device shows it: `XXXX-XXXX`. */
69
+ readonly userCode: Schema.String;
70
+ }>, Schema.Struct<{
71
+ /** The requesting OAuth client's ID. */
72
+ readonly clientId: Schema.String;
73
+ /** The scopes the client asked for, which the host may show and narrow. */
74
+ readonly scopes: Schema.$Array<Schema.String>;
75
+ /** When the request can no longer be approved. */
76
+ readonly expiresAt: Schema.Number;
77
+ readonly kind: Schema.Literal<"web">;
78
+ /** Where the browser goes with the code once approved. */
79
+ readonly redirectUri: Schema.String;
80
+ }>]>;
81
+ export type ApprovalPrompt = typeof ApprovalPrompt.Type;
26
82
  /**
27
83
  * `request` is a copy of the one the browser sent, with its body unread, so the host reads its own
28
84
  * fields. Each page gets its own, the one `decide` answers with too.
29
85
  */
30
- export interface ApprovalPageContext {
31
- readonly request: Request;
32
- readonly signal: AbortSignal;
33
- }
86
+ export declare const ApprovalPageContext: Schema.Struct<{
87
+ readonly request: Schema.declare<Request, Request>;
88
+ readonly signal: Schema.declare<AbortSignal, AbortSignal>;
89
+ }>;
90
+ export type ApprovalPageContext = typeof ApprovalPageContext.Type;
34
91
  /**
35
92
  * Asks the person for the user code their device shows, submitted as `user_code` to `action`.
36
93
  * `invalid-code`: no code is pending under what they typed. `expired-code`: it was, and can't be
37
94
  * used any more, since it expired or was decided: they start again on their device.
38
95
  */
39
- export interface DeviceCodePage extends ApprovalPageContext {
40
- readonly kind: 'enter-code';
41
- readonly action: '/login/device';
42
- readonly error?: 'invalid-code' | 'expired-code';
43
- }
96
+ export declare const DeviceCodePage: Schema.Struct<{
97
+ readonly request: Schema.declare<Request, Request>;
98
+ readonly signal: Schema.declare<AbortSignal, AbortSignal>;
99
+ readonly kind: Schema.Literal<"enter-code">;
100
+ readonly action: Schema.Literal<"/login/device">;
101
+ readonly error: Schema.optionalKey<Schema.Literals<readonly ["invalid-code", "expired-code"]>>;
102
+ }>;
103
+ export type DeviceCodePage = typeof DeviceCodePage.Type;
44
104
  /**
45
105
  * A validated request for the person to approve or deny. The host authenticates the person and
46
106
  * checks the submission belongs to the page's browser session before it calls `decide`, which
47
107
  * settles this request alone and answers the response to send back.
48
108
  */
49
- export interface ConfirmApprovalPage extends ApprovalPageContext {
50
- readonly kind: 'confirm';
51
- readonly prompt: ApprovalPrompt;
52
- readonly decide: (decision: ApprovalDecision) => Promise<Response>;
53
- }
54
- export type ApprovalPageInput = DeviceCodePage | ConfirmApprovalPage;
55
- export interface ApprovalBase {
56
- /** The requesting OAuth client's ID. */
57
- readonly clientId: string;
58
- /** The scopes the client asked for, which the host may show and narrow. */
59
- readonly scopes: readonly string[];
60
- /** When the request can no longer be approved. */
61
- readonly expiresAt: Moment;
62
- }
63
- export interface DeviceApproval extends ApprovalBase {
64
- readonly kind: 'device';
65
- /** As the device shows it: `XXXX-XXXX`. */
66
- readonly userCode: string;
67
- }
68
- export interface WebApproval extends ApprovalBase {
69
- readonly kind: 'web';
70
- /** Where the browser goes with the code once approved. */
71
- readonly redirectUri: string;
72
- }
73
- export type ApprovalPrompt = DeviceApproval | WebApproval;
109
+ export declare const ConfirmApprovalPage: Schema.Struct<{
110
+ readonly request: Schema.declare<Request, Request>;
111
+ readonly signal: Schema.declare<AbortSignal, AbortSignal>;
112
+ readonly kind: Schema.Literal<"confirm">;
113
+ readonly prompt: Schema.Union<readonly [Schema.Struct<{
114
+ /** The requesting OAuth client's ID. */
115
+ readonly clientId: Schema.String;
116
+ /** The scopes the client asked for, which the host may show and narrow. */
117
+ readonly scopes: Schema.$Array<Schema.String>;
118
+ /** When the request can no longer be approved. */
119
+ readonly expiresAt: Schema.Number;
120
+ readonly kind: Schema.Literal<"device">;
121
+ /** As the device shows it: `XXXX-XXXX`. */
122
+ readonly userCode: Schema.String;
123
+ }>, Schema.Struct<{
124
+ /** The requesting OAuth client's ID. */
125
+ readonly clientId: Schema.String;
126
+ /** The scopes the client asked for, which the host may show and narrow. */
127
+ readonly scopes: Schema.$Array<Schema.String>;
128
+ /** When the request can no longer be approved. */
129
+ readonly expiresAt: Schema.Number;
130
+ readonly kind: Schema.Literal<"web">;
131
+ /** Where the browser goes with the code once approved. */
132
+ readonly redirectUri: Schema.String;
133
+ }>]>;
134
+ readonly decide: Schema.declare<(decision: ApprovalDecision) => Effect.Effect<Response, GitError>, (decision: ApprovalDecision) => Effect.Effect<Response, GitError>>;
135
+ }>;
136
+ export type ConfirmApprovalPage = typeof ConfirmApprovalPage.Type;
137
+ export declare const ApprovalPageInput: Schema.Union<readonly [Schema.Struct<{
138
+ readonly request: Schema.declare<Request, Request>;
139
+ readonly signal: Schema.declare<AbortSignal, AbortSignal>;
140
+ readonly kind: Schema.Literal<"enter-code">;
141
+ readonly action: Schema.Literal<"/login/device">;
142
+ readonly error: Schema.optionalKey<Schema.Literals<readonly ["invalid-code", "expired-code"]>>;
143
+ }>, Schema.Struct<{
144
+ readonly request: Schema.declare<Request, Request>;
145
+ readonly signal: Schema.declare<AbortSignal, AbortSignal>;
146
+ readonly kind: Schema.Literal<"confirm">;
147
+ readonly prompt: Schema.Union<readonly [Schema.Struct<{
148
+ /** The requesting OAuth client's ID. */
149
+ readonly clientId: Schema.String;
150
+ /** The scopes the client asked for, which the host may show and narrow. */
151
+ readonly scopes: Schema.$Array<Schema.String>;
152
+ /** When the request can no longer be approved. */
153
+ readonly expiresAt: Schema.Number;
154
+ readonly kind: Schema.Literal<"device">;
155
+ /** As the device shows it: `XXXX-XXXX`. */
156
+ readonly userCode: Schema.String;
157
+ }>, Schema.Struct<{
158
+ /** The requesting OAuth client's ID. */
159
+ readonly clientId: Schema.String;
160
+ /** The scopes the client asked for, which the host may show and narrow. */
161
+ readonly scopes: Schema.$Array<Schema.String>;
162
+ /** When the request can no longer be approved. */
163
+ readonly expiresAt: Schema.Number;
164
+ readonly kind: Schema.Literal<"web">;
165
+ /** Where the browser goes with the code once approved. */
166
+ readonly redirectUri: Schema.String;
167
+ }>]>;
168
+ readonly decide: Schema.declare<(decision: ApprovalDecision) => Effect.Effect<Response, GitError>, (decision: ApprovalDecision) => Effect.Effect<Response, GitError>>;
169
+ }>]>;
170
+ export type ApprovalPageInput = typeof ApprovalPageInput.Type;
74
171
  /** The person's token, for the repo or prefix, scope and expiry the host chose. */
75
172
  export declare const ApprovedGrant: Schema.Struct<{
76
173
  readonly kind: Schema.Literal<"approve">;