gitx.do 0.1.1 → 0.1.2

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 (356) hide show
  1. package/README.md +40 -353
  2. package/dist/do/logger.d.ts +50 -0
  3. package/dist/do/logger.d.ts.map +1 -0
  4. package/dist/do/logger.js +122 -0
  5. package/dist/do/logger.js.map +1 -0
  6. package/dist/{durable-object → do}/schema.d.ts +3 -3
  7. package/dist/do/schema.d.ts.map +1 -0
  8. package/dist/{durable-object → do}/schema.js +4 -3
  9. package/dist/do/schema.js.map +1 -0
  10. package/dist/do/types.d.ts +267 -0
  11. package/dist/do/types.d.ts.map +1 -0
  12. package/dist/do/types.js +62 -0
  13. package/dist/do/types.js.map +1 -0
  14. package/dist/index.d.ts +14 -469
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +31 -483
  17. package/dist/index.js.map +1 -1
  18. package/package.json +13 -21
  19. package/dist/cli/commands/add.d.ts +0 -176
  20. package/dist/cli/commands/add.d.ts.map +0 -1
  21. package/dist/cli/commands/add.js +0 -979
  22. package/dist/cli/commands/add.js.map +0 -1
  23. package/dist/cli/commands/blame.d.ts +0 -259
  24. package/dist/cli/commands/blame.d.ts.map +0 -1
  25. package/dist/cli/commands/blame.js +0 -609
  26. package/dist/cli/commands/blame.js.map +0 -1
  27. package/dist/cli/commands/branch.d.ts +0 -249
  28. package/dist/cli/commands/branch.d.ts.map +0 -1
  29. package/dist/cli/commands/branch.js +0 -693
  30. package/dist/cli/commands/branch.js.map +0 -1
  31. package/dist/cli/commands/checkout.d.ts +0 -73
  32. package/dist/cli/commands/checkout.d.ts.map +0 -1
  33. package/dist/cli/commands/checkout.js +0 -725
  34. package/dist/cli/commands/checkout.js.map +0 -1
  35. package/dist/cli/commands/commit.d.ts +0 -182
  36. package/dist/cli/commands/commit.d.ts.map +0 -1
  37. package/dist/cli/commands/commit.js +0 -457
  38. package/dist/cli/commands/commit.js.map +0 -1
  39. package/dist/cli/commands/diff.d.ts +0 -464
  40. package/dist/cli/commands/diff.d.ts.map +0 -1
  41. package/dist/cli/commands/diff.js +0 -959
  42. package/dist/cli/commands/diff.js.map +0 -1
  43. package/dist/cli/commands/log.d.ts +0 -239
  44. package/dist/cli/commands/log.d.ts.map +0 -1
  45. package/dist/cli/commands/log.js +0 -535
  46. package/dist/cli/commands/log.js.map +0 -1
  47. package/dist/cli/commands/merge.d.ts +0 -106
  48. package/dist/cli/commands/merge.d.ts.map +0 -1
  49. package/dist/cli/commands/merge.js +0 -852
  50. package/dist/cli/commands/merge.js.map +0 -1
  51. package/dist/cli/commands/review.d.ts +0 -457
  52. package/dist/cli/commands/review.d.ts.map +0 -1
  53. package/dist/cli/commands/review.js +0 -558
  54. package/dist/cli/commands/review.js.map +0 -1
  55. package/dist/cli/commands/stash.d.ts +0 -157
  56. package/dist/cli/commands/stash.d.ts.map +0 -1
  57. package/dist/cli/commands/stash.js +0 -655
  58. package/dist/cli/commands/stash.js.map +0 -1
  59. package/dist/cli/commands/status.d.ts +0 -269
  60. package/dist/cli/commands/status.d.ts.map +0 -1
  61. package/dist/cli/commands/status.js +0 -492
  62. package/dist/cli/commands/status.js.map +0 -1
  63. package/dist/cli/commands/web.d.ts +0 -199
  64. package/dist/cli/commands/web.d.ts.map +0 -1
  65. package/dist/cli/commands/web.js +0 -697
  66. package/dist/cli/commands/web.js.map +0 -1
  67. package/dist/cli/fs-adapter.d.ts +0 -656
  68. package/dist/cli/fs-adapter.d.ts.map +0 -1
  69. package/dist/cli/fs-adapter.js +0 -1177
  70. package/dist/cli/fs-adapter.js.map +0 -1
  71. package/dist/cli/fsx-cli-adapter.d.ts +0 -359
  72. package/dist/cli/fsx-cli-adapter.d.ts.map +0 -1
  73. package/dist/cli/fsx-cli-adapter.js +0 -619
  74. package/dist/cli/fsx-cli-adapter.js.map +0 -1
  75. package/dist/cli/index.d.ts +0 -387
  76. package/dist/cli/index.d.ts.map +0 -1
  77. package/dist/cli/index.js +0 -579
  78. package/dist/cli/index.js.map +0 -1
  79. package/dist/cli/ui/components/DiffView.d.ts +0 -12
  80. package/dist/cli/ui/components/DiffView.d.ts.map +0 -1
  81. package/dist/cli/ui/components/DiffView.js +0 -11
  82. package/dist/cli/ui/components/DiffView.js.map +0 -1
  83. package/dist/cli/ui/components/ErrorDisplay.d.ts +0 -10
  84. package/dist/cli/ui/components/ErrorDisplay.d.ts.map +0 -1
  85. package/dist/cli/ui/components/ErrorDisplay.js +0 -11
  86. package/dist/cli/ui/components/ErrorDisplay.js.map +0 -1
  87. package/dist/cli/ui/components/FuzzySearch.d.ts +0 -15
  88. package/dist/cli/ui/components/FuzzySearch.d.ts.map +0 -1
  89. package/dist/cli/ui/components/FuzzySearch.js +0 -12
  90. package/dist/cli/ui/components/FuzzySearch.js.map +0 -1
  91. package/dist/cli/ui/components/LoadingSpinner.d.ts +0 -10
  92. package/dist/cli/ui/components/LoadingSpinner.d.ts.map +0 -1
  93. package/dist/cli/ui/components/LoadingSpinner.js +0 -10
  94. package/dist/cli/ui/components/LoadingSpinner.js.map +0 -1
  95. package/dist/cli/ui/components/NavigationList.d.ts +0 -14
  96. package/dist/cli/ui/components/NavigationList.d.ts.map +0 -1
  97. package/dist/cli/ui/components/NavigationList.js +0 -11
  98. package/dist/cli/ui/components/NavigationList.js.map +0 -1
  99. package/dist/cli/ui/components/ScrollableContent.d.ts +0 -13
  100. package/dist/cli/ui/components/ScrollableContent.d.ts.map +0 -1
  101. package/dist/cli/ui/components/ScrollableContent.js +0 -11
  102. package/dist/cli/ui/components/ScrollableContent.js.map +0 -1
  103. package/dist/cli/ui/components/index.d.ts +0 -7
  104. package/dist/cli/ui/components/index.d.ts.map +0 -1
  105. package/dist/cli/ui/components/index.js +0 -9
  106. package/dist/cli/ui/components/index.js.map +0 -1
  107. package/dist/cli/ui/terminal-ui.d.ts +0 -85
  108. package/dist/cli/ui/terminal-ui.d.ts.map +0 -1
  109. package/dist/cli/ui/terminal-ui.js +0 -121
  110. package/dist/cli/ui/terminal-ui.js.map +0 -1
  111. package/dist/do/BashModule.d.ts +0 -871
  112. package/dist/do/BashModule.d.ts.map +0 -1
  113. package/dist/do/BashModule.js +0 -1143
  114. package/dist/do/BashModule.js.map +0 -1
  115. package/dist/do/FsModule.d.ts +0 -612
  116. package/dist/do/FsModule.d.ts.map +0 -1
  117. package/dist/do/FsModule.js +0 -1120
  118. package/dist/do/FsModule.js.map +0 -1
  119. package/dist/do/GitModule.d.ts +0 -635
  120. package/dist/do/GitModule.d.ts.map +0 -1
  121. package/dist/do/GitModule.js +0 -784
  122. package/dist/do/GitModule.js.map +0 -1
  123. package/dist/do/GitRepoDO.d.ts +0 -281
  124. package/dist/do/GitRepoDO.d.ts.map +0 -1
  125. package/dist/do/GitRepoDO.js +0 -479
  126. package/dist/do/GitRepoDO.js.map +0 -1
  127. package/dist/do/bash-ast.d.ts +0 -246
  128. package/dist/do/bash-ast.d.ts.map +0 -1
  129. package/dist/do/bash-ast.js +0 -888
  130. package/dist/do/bash-ast.js.map +0 -1
  131. package/dist/do/container-executor.d.ts +0 -491
  132. package/dist/do/container-executor.d.ts.map +0 -1
  133. package/dist/do/container-executor.js +0 -731
  134. package/dist/do/container-executor.js.map +0 -1
  135. package/dist/do/index.d.ts +0 -53
  136. package/dist/do/index.d.ts.map +0 -1
  137. package/dist/do/index.js +0 -91
  138. package/dist/do/index.js.map +0 -1
  139. package/dist/do/tiered-storage.d.ts +0 -403
  140. package/dist/do/tiered-storage.d.ts.map +0 -1
  141. package/dist/do/tiered-storage.js +0 -689
  142. package/dist/do/tiered-storage.js.map +0 -1
  143. package/dist/do/withBash.d.ts +0 -231
  144. package/dist/do/withBash.d.ts.map +0 -1
  145. package/dist/do/withBash.js +0 -244
  146. package/dist/do/withBash.js.map +0 -1
  147. package/dist/do/withFs.d.ts +0 -237
  148. package/dist/do/withFs.d.ts.map +0 -1
  149. package/dist/do/withFs.js +0 -387
  150. package/dist/do/withFs.js.map +0 -1
  151. package/dist/do/withGit.d.ts +0 -180
  152. package/dist/do/withGit.d.ts.map +0 -1
  153. package/dist/do/withGit.js +0 -271
  154. package/dist/do/withGit.js.map +0 -1
  155. package/dist/durable-object/object-store.d.ts +0 -633
  156. package/dist/durable-object/object-store.d.ts.map +0 -1
  157. package/dist/durable-object/object-store.js +0 -1164
  158. package/dist/durable-object/object-store.js.map +0 -1
  159. package/dist/durable-object/schema.d.ts.map +0 -1
  160. package/dist/durable-object/schema.js.map +0 -1
  161. package/dist/durable-object/wal.d.ts +0 -416
  162. package/dist/durable-object/wal.d.ts.map +0 -1
  163. package/dist/durable-object/wal.js +0 -445
  164. package/dist/durable-object/wal.js.map +0 -1
  165. package/dist/mcp/adapter.d.ts +0 -772
  166. package/dist/mcp/adapter.d.ts.map +0 -1
  167. package/dist/mcp/adapter.js +0 -895
  168. package/dist/mcp/adapter.js.map +0 -1
  169. package/dist/mcp/sandbox/miniflare-evaluator.d.ts +0 -22
  170. package/dist/mcp/sandbox/miniflare-evaluator.d.ts.map +0 -1
  171. package/dist/mcp/sandbox/miniflare-evaluator.js +0 -140
  172. package/dist/mcp/sandbox/miniflare-evaluator.js.map +0 -1
  173. package/dist/mcp/sandbox/object-store-proxy.d.ts +0 -32
  174. package/dist/mcp/sandbox/object-store-proxy.d.ts.map +0 -1
  175. package/dist/mcp/sandbox/object-store-proxy.js +0 -30
  176. package/dist/mcp/sandbox/object-store-proxy.js.map +0 -1
  177. package/dist/mcp/sandbox/template.d.ts +0 -17
  178. package/dist/mcp/sandbox/template.d.ts.map +0 -1
  179. package/dist/mcp/sandbox/template.js +0 -71
  180. package/dist/mcp/sandbox/template.js.map +0 -1
  181. package/dist/mcp/sandbox.d.ts +0 -764
  182. package/dist/mcp/sandbox.d.ts.map +0 -1
  183. package/dist/mcp/sandbox.js +0 -1362
  184. package/dist/mcp/sandbox.js.map +0 -1
  185. package/dist/mcp/sdk-adapter.d.ts +0 -835
  186. package/dist/mcp/sdk-adapter.d.ts.map +0 -1
  187. package/dist/mcp/sdk-adapter.js +0 -974
  188. package/dist/mcp/sdk-adapter.js.map +0 -1
  189. package/dist/mcp/tools/do.d.ts +0 -32
  190. package/dist/mcp/tools/do.d.ts.map +0 -1
  191. package/dist/mcp/tools/do.js +0 -117
  192. package/dist/mcp/tools/do.js.map +0 -1
  193. package/dist/mcp/tools.d.ts +0 -548
  194. package/dist/mcp/tools.d.ts.map +0 -1
  195. package/dist/mcp/tools.js +0 -3170
  196. package/dist/mcp/tools.js.map +0 -1
  197. package/dist/ops/blame.d.ts +0 -551
  198. package/dist/ops/blame.d.ts.map +0 -1
  199. package/dist/ops/blame.js +0 -1037
  200. package/dist/ops/blame.js.map +0 -1
  201. package/dist/ops/branch.d.ts +0 -766
  202. package/dist/ops/branch.d.ts.map +0 -1
  203. package/dist/ops/branch.js +0 -950
  204. package/dist/ops/branch.js.map +0 -1
  205. package/dist/ops/commit-traversal.d.ts +0 -349
  206. package/dist/ops/commit-traversal.d.ts.map +0 -1
  207. package/dist/ops/commit-traversal.js +0 -821
  208. package/dist/ops/commit-traversal.js.map +0 -1
  209. package/dist/ops/commit.d.ts +0 -555
  210. package/dist/ops/commit.d.ts.map +0 -1
  211. package/dist/ops/commit.js +0 -826
  212. package/dist/ops/commit.js.map +0 -1
  213. package/dist/ops/merge-base.d.ts +0 -397
  214. package/dist/ops/merge-base.d.ts.map +0 -1
  215. package/dist/ops/merge-base.js +0 -691
  216. package/dist/ops/merge-base.js.map +0 -1
  217. package/dist/ops/merge.d.ts +0 -855
  218. package/dist/ops/merge.d.ts.map +0 -1
  219. package/dist/ops/merge.js +0 -1551
  220. package/dist/ops/merge.js.map +0 -1
  221. package/dist/ops/tag.d.ts +0 -247
  222. package/dist/ops/tag.d.ts.map +0 -1
  223. package/dist/ops/tag.js +0 -649
  224. package/dist/ops/tag.js.map +0 -1
  225. package/dist/ops/tree-builder.d.ts +0 -178
  226. package/dist/ops/tree-builder.d.ts.map +0 -1
  227. package/dist/ops/tree-builder.js +0 -271
  228. package/dist/ops/tree-builder.js.map +0 -1
  229. package/dist/ops/tree-diff.d.ts +0 -291
  230. package/dist/ops/tree-diff.d.ts.map +0 -1
  231. package/dist/ops/tree-diff.js +0 -705
  232. package/dist/ops/tree-diff.js.map +0 -1
  233. package/dist/pack/delta.d.ts +0 -248
  234. package/dist/pack/delta.d.ts.map +0 -1
  235. package/dist/pack/delta.js +0 -740
  236. package/dist/pack/delta.js.map +0 -1
  237. package/dist/pack/format.d.ts +0 -446
  238. package/dist/pack/format.d.ts.map +0 -1
  239. package/dist/pack/format.js +0 -572
  240. package/dist/pack/format.js.map +0 -1
  241. package/dist/pack/full-generation.d.ts +0 -612
  242. package/dist/pack/full-generation.d.ts.map +0 -1
  243. package/dist/pack/full-generation.js +0 -1378
  244. package/dist/pack/full-generation.js.map +0 -1
  245. package/dist/pack/generation.d.ts +0 -441
  246. package/dist/pack/generation.d.ts.map +0 -1
  247. package/dist/pack/generation.js +0 -707
  248. package/dist/pack/generation.js.map +0 -1
  249. package/dist/pack/index.d.ts +0 -502
  250. package/dist/pack/index.d.ts.map +0 -1
  251. package/dist/pack/index.js +0 -833
  252. package/dist/pack/index.js.map +0 -1
  253. package/dist/refs/branch.d.ts +0 -683
  254. package/dist/refs/branch.d.ts.map +0 -1
  255. package/dist/refs/branch.js +0 -881
  256. package/dist/refs/branch.js.map +0 -1
  257. package/dist/refs/storage.d.ts +0 -833
  258. package/dist/refs/storage.d.ts.map +0 -1
  259. package/dist/refs/storage.js +0 -1023
  260. package/dist/refs/storage.js.map +0 -1
  261. package/dist/refs/tag.d.ts +0 -860
  262. package/dist/refs/tag.d.ts.map +0 -1
  263. package/dist/refs/tag.js +0 -996
  264. package/dist/refs/tag.js.map +0 -1
  265. package/dist/storage/backend.d.ts +0 -425
  266. package/dist/storage/backend.d.ts.map +0 -1
  267. package/dist/storage/backend.js +0 -41
  268. package/dist/storage/backend.js.map +0 -1
  269. package/dist/storage/fsx-adapter.d.ts +0 -204
  270. package/dist/storage/fsx-adapter.d.ts.map +0 -1
  271. package/dist/storage/fsx-adapter.js +0 -518
  272. package/dist/storage/fsx-adapter.js.map +0 -1
  273. package/dist/storage/lru-cache.d.ts +0 -691
  274. package/dist/storage/lru-cache.d.ts.map +0 -1
  275. package/dist/storage/lru-cache.js +0 -813
  276. package/dist/storage/lru-cache.js.map +0 -1
  277. package/dist/storage/object-index.d.ts +0 -585
  278. package/dist/storage/object-index.d.ts.map +0 -1
  279. package/dist/storage/object-index.js +0 -532
  280. package/dist/storage/object-index.js.map +0 -1
  281. package/dist/storage/r2-pack.d.ts +0 -1257
  282. package/dist/storage/r2-pack.d.ts.map +0 -1
  283. package/dist/storage/r2-pack.js +0 -1773
  284. package/dist/storage/r2-pack.js.map +0 -1
  285. package/dist/tiered/cdc-pipeline.d.ts +0 -1888
  286. package/dist/tiered/cdc-pipeline.d.ts.map +0 -1
  287. package/dist/tiered/cdc-pipeline.js +0 -1880
  288. package/dist/tiered/cdc-pipeline.js.map +0 -1
  289. package/dist/tiered/migration.d.ts +0 -1104
  290. package/dist/tiered/migration.d.ts.map +0 -1
  291. package/dist/tiered/migration.js +0 -1217
  292. package/dist/tiered/migration.js.map +0 -1
  293. package/dist/tiered/parquet-writer.d.ts +0 -1145
  294. package/dist/tiered/parquet-writer.d.ts.map +0 -1
  295. package/dist/tiered/parquet-writer.js +0 -1183
  296. package/dist/tiered/parquet-writer.js.map +0 -1
  297. package/dist/tiered/read-path.d.ts +0 -835
  298. package/dist/tiered/read-path.d.ts.map +0 -1
  299. package/dist/tiered/read-path.js +0 -487
  300. package/dist/tiered/read-path.js.map +0 -1
  301. package/dist/types/capability.d.ts +0 -1385
  302. package/dist/types/capability.d.ts.map +0 -1
  303. package/dist/types/capability.js +0 -36
  304. package/dist/types/capability.js.map +0 -1
  305. package/dist/types/index.d.ts +0 -13
  306. package/dist/types/index.d.ts.map +0 -1
  307. package/dist/types/index.js +0 -18
  308. package/dist/types/index.js.map +0 -1
  309. package/dist/types/interfaces.d.ts +0 -673
  310. package/dist/types/interfaces.d.ts.map +0 -1
  311. package/dist/types/interfaces.js +0 -26
  312. package/dist/types/interfaces.js.map +0 -1
  313. package/dist/types/objects.d.ts +0 -692
  314. package/dist/types/objects.d.ts.map +0 -1
  315. package/dist/types/objects.js +0 -837
  316. package/dist/types/objects.js.map +0 -1
  317. package/dist/types/storage.d.ts +0 -603
  318. package/dist/types/storage.d.ts.map +0 -1
  319. package/dist/types/storage.js +0 -191
  320. package/dist/types/storage.js.map +0 -1
  321. package/dist/types/worker-loader.d.ts +0 -60
  322. package/dist/types/worker-loader.d.ts.map +0 -1
  323. package/dist/types/worker-loader.js +0 -62
  324. package/dist/types/worker-loader.js.map +0 -1
  325. package/dist/utils/hash.d.ts +0 -198
  326. package/dist/utils/hash.d.ts.map +0 -1
  327. package/dist/utils/hash.js +0 -272
  328. package/dist/utils/hash.js.map +0 -1
  329. package/dist/utils/sha1.d.ts +0 -325
  330. package/dist/utils/sha1.d.ts.map +0 -1
  331. package/dist/utils/sha1.js +0 -635
  332. package/dist/utils/sha1.js.map +0 -1
  333. package/dist/wire/capabilities.d.ts +0 -1044
  334. package/dist/wire/capabilities.d.ts.map +0 -1
  335. package/dist/wire/capabilities.js +0 -941
  336. package/dist/wire/capabilities.js.map +0 -1
  337. package/dist/wire/path-security.d.ts +0 -157
  338. package/dist/wire/path-security.d.ts.map +0 -1
  339. package/dist/wire/path-security.js +0 -307
  340. package/dist/wire/path-security.js.map +0 -1
  341. package/dist/wire/pkt-line.d.ts +0 -345
  342. package/dist/wire/pkt-line.d.ts.map +0 -1
  343. package/dist/wire/pkt-line.js +0 -381
  344. package/dist/wire/pkt-line.js.map +0 -1
  345. package/dist/wire/receive-pack.d.ts +0 -1059
  346. package/dist/wire/receive-pack.d.ts.map +0 -1
  347. package/dist/wire/receive-pack.js +0 -1414
  348. package/dist/wire/receive-pack.js.map +0 -1
  349. package/dist/wire/smart-http.d.ts +0 -799
  350. package/dist/wire/smart-http.d.ts.map +0 -1
  351. package/dist/wire/smart-http.js +0 -945
  352. package/dist/wire/smart-http.js.map +0 -1
  353. package/dist/wire/upload-pack.d.ts +0 -727
  354. package/dist/wire/upload-pack.d.ts.map +0 -1
  355. package/dist/wire/upload-pack.js +0 -1141
  356. package/dist/wire/upload-pack.js.map +0 -1
@@ -1,799 +0,0 @@
1
- /**
2
- * @fileoverview Git Smart HTTP Protocol Implementation
3
- *
4
- * This module implements the Git Smart HTTP protocol for server-side handling of
5
- * Git fetch and push operations over HTTP. It provides handlers for:
6
- *
7
- * - **Ref Discovery** (`GET /info/refs?service=git-upload-pack|git-receive-pack`)
8
- * Advertises available refs and server capabilities to clients.
9
- *
10
- * - **Fetch Data Transfer** (`POST /git-upload-pack`)
11
- * Handles client fetch requests by processing wants/haves and returning packfiles.
12
- *
13
- * - **Push Data Transfer** (`POST /git-receive-pack`)
14
- * Handles client push requests by processing ref updates and incoming packfiles.
15
- *
16
- * @module wire/smart-http
17
- * @see {@link https://git-scm.com/docs/http-protocol} Git HTTP Protocol Documentation
18
- * @see {@link https://git-scm.com/docs/protocol-common} Git Protocol Common
19
- *
20
- * @example Basic server integration
21
- * ```typescript
22
- * import { handleInfoRefs, handleUploadPack, handleReceivePack } from './wire/smart-http'
23
- *
24
- * // Handle GET /repo.git/info/refs?service=git-upload-pack
25
- * app.get('/:repo/info/refs', async (req, res) => {
26
- * const request: SmartHTTPRequest = {
27
- * method: 'GET',
28
- * path: '/info/refs',
29
- * query: { service: req.query.service },
30
- * headers: req.headers,
31
- * repository: req.params.repo
32
- * }
33
- * const response = await handleInfoRefs(request, repositoryProvider, capabilities)
34
- * res.status(response.status).set(response.headers).send(response.body)
35
- * })
36
- * ```
37
- */
38
- /**
39
- * Supported Git Smart HTTP services.
40
- *
41
- * @description
42
- * Git Smart HTTP supports two services:
43
- * - `git-upload-pack`: Used by git-fetch to download objects
44
- * - `git-receive-pack`: Used by git-push to upload objects
45
- */
46
- export type GitService = 'git-upload-pack' | 'git-receive-pack';
47
- /**
48
- * HTTP methods supported by the Smart HTTP protocol.
49
- *
50
- * @description
51
- * - `GET`: Used for ref discovery (/info/refs)
52
- * - `POST`: Used for data transfer (upload-pack and receive-pack)
53
- */
54
- export type HTTPMethod = 'GET' | 'POST';
55
- /**
56
- * Represents a Git reference (branch, tag, etc.).
57
- *
58
- * @description
59
- * A Git reference is a named pointer to a specific commit or object.
60
- * Common ref types include:
61
- * - Branches: `refs/heads/main`, `refs/heads/feature`
62
- * - Tags: `refs/tags/v1.0.0`
63
- * - Remote tracking: `refs/remotes/origin/main`
64
- *
65
- * @example
66
- * ```typescript
67
- * const mainBranch: GitRef = {
68
- * sha: 'abc123def456...',
69
- * name: 'refs/heads/main'
70
- * }
71
- *
72
- * const annotatedTag: GitRef = {
73
- * sha: 'tag-object-sha...',
74
- * name: 'refs/tags/v1.0.0',
75
- * peeled: 'target-commit-sha...'
76
- * }
77
- * ```
78
- */
79
- export interface GitRef {
80
- /** SHA-1 hash of the object this ref points to (40 hex characters) */
81
- sha: string;
82
- /** Full ref name (e.g., 'refs/heads/main', 'refs/tags/v1.0.0') */
83
- name: string;
84
- /** Optional peeled SHA for annotated tags - the SHA of the target object */
85
- peeled?: string;
86
- }
87
- /**
88
- * Server capabilities advertised during ref discovery.
89
- *
90
- * @description
91
- * Capabilities determine what features the server supports. Clients select
92
- * which capabilities to use during the initial handshake. Common capability
93
- * categories include:
94
- *
95
- * - **Negotiation**: `multi_ack`, `multi_ack_detailed` - for efficient fetch negotiation
96
- * - **Transfer**: `thin-pack`, `ofs-delta` - for efficient packfile transfer
97
- * - **Communication**: `side-band`, `side-band-64k` - for multiplexed output
98
- * - **Features**: `shallow`, `filter`, `atomic` - for advanced operations
99
- *
100
- * @example
101
- * ```typescript
102
- * const capabilities: ServerCapabilities = {
103
- * multiAckDetailed: true,
104
- * sideBand64k: true,
105
- * thinPack: true,
106
- * ofsDelta: true,
107
- * shallow: true,
108
- * reportStatus: true,
109
- * deleteRefs: true,
110
- * agent: 'my-git-server/1.0'
111
- * }
112
- * ```
113
- *
114
- * @see {@link https://git-scm.com/docs/protocol-capabilities} Git Protocol Capabilities
115
- */
116
- export interface ServerCapabilities {
117
- /** Server supports multi_ack for negotiation optimization */
118
- multiAck?: boolean;
119
- /** Server supports multi_ack_detailed for finer-grained negotiation */
120
- multiAckDetailed?: boolean;
121
- /** Server supports thin-pack (deltas against objects not in pack) */
122
- thinPack?: boolean;
123
- /** Server supports side-band communication (multiplexed output) */
124
- sideBand?: boolean;
125
- /** Server supports side-band-64k communication (larger packets) */
126
- sideBand64k?: boolean;
127
- /** Server supports ofs-delta (offset-based delta encoding) */
128
- ofsDelta?: boolean;
129
- /** Server supports shallow clones (limited history) */
130
- shallow?: boolean;
131
- /** Server supports deepen-since (shallow by date) */
132
- deepenSince?: boolean;
133
- /** Server supports deepen-not (exclude refs from shallow) */
134
- deepenNot?: boolean;
135
- /** Server supports deepen-relative (deepen from current shallow) */
136
- deepenRelative?: boolean;
137
- /** Server supports no-progress (suppress progress output) */
138
- noProgress?: boolean;
139
- /** Server supports include-tag (auto-send annotated tags) */
140
- includeTag?: boolean;
141
- /** Server supports report-status (push status report) */
142
- reportStatus?: boolean;
143
- /** Server supports report-status-v2 (enhanced push status) */
144
- reportStatusV2?: boolean;
145
- /** Server supports delete-refs (ref deletion via push) */
146
- deleteRefs?: boolean;
147
- /** Server supports quiet mode (suppress output) */
148
- quiet?: boolean;
149
- /** Server supports atomic pushes (all-or-nothing ref updates) */
150
- atomic?: boolean;
151
- /** Server supports push-options (custom push metadata) */
152
- pushOptions?: boolean;
153
- /** Server allows fetching tip SHA-1 not in refs */
154
- allowTipSha1InWant?: boolean;
155
- /** Server allows fetching reachable SHA-1 not in refs */
156
- allowReachableSha1InWant?: boolean;
157
- /** Server's agent identification string */
158
- agent?: string;
159
- /** Server supports object-format (sha1/sha256 hash algorithm) */
160
- objectFormat?: string;
161
- /** Server supports filter capability (partial clone) */
162
- filter?: boolean;
163
- }
164
- /**
165
- * Incoming Smart HTTP request structure.
166
- *
167
- * @description
168
- * Encapsulates all information from an incoming HTTP request that is
169
- * relevant for Git Smart HTTP processing. This abstraction allows the
170
- * protocol handlers to be framework-agnostic.
171
- *
172
- * @example
173
- * ```typescript
174
- * // Converting from Express request
175
- * const smartRequest: SmartHTTPRequest = {
176
- * method: req.method as HTTPMethod,
177
- * path: req.path,
178
- * query: req.query as Record<string, string>,
179
- * headers: req.headers as Record<string, string>,
180
- * body: req.body, // Buffer/Uint8Array
181
- * repository: req.params.repo
182
- * }
183
- * ```
184
- */
185
- export interface SmartHTTPRequest {
186
- /** HTTP method (GET or POST) */
187
- method: HTTPMethod;
188
- /** Request path (e.g., '/info/refs' or '/git-upload-pack') */
189
- path: string;
190
- /** Query parameters as key-value pairs */
191
- query: Record<string, string>;
192
- /** HTTP headers as key-value pairs (lowercase keys recommended) */
193
- headers: Record<string, string>;
194
- /** Request body as Uint8Array (for POST requests) */
195
- body?: Uint8Array;
196
- /** Repository identifier/name extracted from the URL */
197
- repository: string;
198
- }
199
- /**
200
- * Outgoing Smart HTTP response structure.
201
- *
202
- * @description
203
- * Contains all information needed to send an HTTP response back to the
204
- * Git client. The body is always a Uint8Array to handle both text and
205
- * binary packfile data.
206
- *
207
- * @example
208
- * ```typescript
209
- * // Converting to Express response
210
- * const response = await handleInfoRefs(request, repo, caps)
211
- * res.status(response.status)
212
- * .set(response.headers)
213
- * .send(Buffer.from(response.body))
214
- * ```
215
- */
216
- export interface SmartHTTPResponse {
217
- /** HTTP status code (e.g., 200, 400, 403, 404) */
218
- status: number;
219
- /** HTTP status text (e.g., 'OK', 'Bad Request', 'Not Found') */
220
- statusText: string;
221
- /** Response headers to send */
222
- headers: Record<string, string>;
223
- /** Response body as Uint8Array */
224
- body: Uint8Array;
225
- }
226
- /**
227
- * Error response with specific HTTP status codes.
228
- *
229
- * @description
230
- * Extends the standard Error class with an HTTP status code for
231
- * proper error handling in HTTP responses.
232
- */
233
- export interface SmartHTTPError extends Error {
234
- /** HTTP status code for the error (e.g., 400, 403, 404, 500) */
235
- statusCode: number;
236
- }
237
- /**
238
- * Repository interface for Smart HTTP operations.
239
- *
240
- * @description
241
- * This interface defines the contract that a repository implementation must
242
- * fulfill to support Smart HTTP operations. Implementations typically wrap
243
- * a Git repository or object store.
244
- *
245
- * @example
246
- * ```typescript
247
- * class MyRepositoryProvider implements RepositoryProvider {
248
- * async getRefs(): Promise<GitRef[]> {
249
- * return this.store.listRefs()
250
- * }
251
- *
252
- * async exists(): Promise<boolean> {
253
- * return this.store.repositoryExists()
254
- * }
255
- *
256
- * async hasPermission(service: GitService): Promise<boolean> {
257
- * if (service === 'git-receive-pack') {
258
- * return this.user.canPush()
259
- * }
260
- * return this.user.canRead()
261
- * }
262
- *
263
- * async uploadPack(wants, haves, caps): Promise<Uint8Array> {
264
- * return this.packGenerator.generatePack(wants, haves)
265
- * }
266
- *
267
- * async receivePack(packData, commands): Promise<ReceivePackResult> {
268
- * return this.refUpdater.processUpdates(packData, commands)
269
- * }
270
- * }
271
- * ```
272
- */
273
- export interface RepositoryProvider {
274
- /**
275
- * Get all refs in the repository.
276
- * @returns Promise resolving to array of GitRef objects
277
- */
278
- getRefs(): Promise<GitRef[]>;
279
- /**
280
- * Check if the repository exists.
281
- * @returns Promise resolving to true if repository exists
282
- */
283
- exists(): Promise<boolean>;
284
- /**
285
- * Check if the client has permission for the specified service.
286
- * @param service - The Git service being requested
287
- * @returns Promise resolving to true if permission is granted
288
- */
289
- hasPermission(service: GitService): Promise<boolean>;
290
- /**
291
- * Handle upload-pack (fetch) - generates and returns packfile data.
292
- * @param wants - SHA-1 hashes of objects the client wants
293
- * @param haves - SHA-1 hashes of objects the client already has
294
- * @param capabilities - Client-requested capabilities
295
- * @returns Promise resolving to packfile data as Uint8Array
296
- */
297
- uploadPack(wants: string[], haves: string[], capabilities: string[]): Promise<Uint8Array>;
298
- /**
299
- * Handle receive-pack (push) - processes incoming packfile and ref updates.
300
- * @param packData - Incoming packfile data
301
- * @param commands - Ref update commands from the client
302
- * @returns Promise resolving to the result of the push operation
303
- */
304
- receivePack(packData: Uint8Array, commands: RefUpdateCommand[]): Promise<ReceivePackResult>;
305
- }
306
- /**
307
- * Command to update a reference during push.
308
- *
309
- * @description
310
- * Each command describes a single ref update operation:
311
- * - **Create**: oldSha is ZERO_SHA, newSha is the new commit
312
- * - **Update**: oldSha is current ref value, newSha is new value
313
- * - **Delete**: oldSha is current ref value, newSha is ZERO_SHA
314
- *
315
- * The oldSha is used for optimistic locking - the server verifies the ref
316
- * hasn't changed before applying the update.
317
- *
318
- * @example
319
- * ```typescript
320
- * // Create a new branch
321
- * const createBranch: RefUpdateCommand = {
322
- * oldSha: ZERO_SHA,
323
- * newSha: 'abc123...',
324
- * refName: 'refs/heads/feature'
325
- * }
326
- *
327
- * // Update existing branch
328
- * const updateBranch: RefUpdateCommand = {
329
- * oldSha: 'abc123...',
330
- * newSha: 'def456...',
331
- * refName: 'refs/heads/main'
332
- * }
333
- *
334
- * // Delete a branch
335
- * const deleteBranch: RefUpdateCommand = {
336
- * oldSha: 'abc123...',
337
- * newSha: ZERO_SHA,
338
- * refName: 'refs/heads/old-feature'
339
- * }
340
- * ```
341
- */
342
- export interface RefUpdateCommand {
343
- /** Old SHA (ZERO_SHA for create operations) */
344
- oldSha: string;
345
- /** New SHA (ZERO_SHA for delete operations) */
346
- newSha: string;
347
- /** Full ref name (e.g., 'refs/heads/main') */
348
- refName: string;
349
- }
350
- /**
351
- * Result of receive-pack operation.
352
- *
353
- * @description
354
- * Contains the overall success status and individual results for each
355
- * ref update that was requested. Used to generate the status report
356
- * sent back to the client.
357
- *
358
- * @example
359
- * ```typescript
360
- * const result: ReceivePackResult = {
361
- * success: true,
362
- * refResults: [
363
- * { refName: 'refs/heads/main', success: true },
364
- * { refName: 'refs/heads/feature', success: false, error: 'non-fast-forward' }
365
- * ]
366
- * }
367
- * ```
368
- */
369
- export interface ReceivePackResult {
370
- /** Whether the overall operation succeeded (all refs updated successfully) */
371
- success: boolean;
372
- /** Individual ref update results */
373
- refResults: Array<{
374
- /** The ref that was being updated */
375
- refName: string;
376
- /** Whether this specific ref update succeeded */
377
- success: boolean;
378
- /** Error message if the update failed */
379
- error?: string;
380
- }>;
381
- }
382
- /**
383
- * Content-Type for git-upload-pack advertisement response.
384
- * @see {@link https://git-scm.com/docs/http-protocol#_smart_server_response}
385
- */
386
- export declare const CONTENT_TYPE_UPLOAD_PACK_ADVERTISEMENT = "application/x-git-upload-pack-advertisement";
387
- /**
388
- * Content-Type for git-receive-pack advertisement response.
389
- * @see {@link https://git-scm.com/docs/http-protocol#_smart_server_response}
390
- */
391
- export declare const CONTENT_TYPE_RECEIVE_PACK_ADVERTISEMENT = "application/x-git-receive-pack-advertisement";
392
- /**
393
- * Content-Type for git-upload-pack request body.
394
- */
395
- export declare const CONTENT_TYPE_UPLOAD_PACK_REQUEST = "application/x-git-upload-pack-request";
396
- /**
397
- * Content-Type for git-upload-pack response body.
398
- */
399
- export declare const CONTENT_TYPE_UPLOAD_PACK_RESULT = "application/x-git-upload-pack-result";
400
- /**
401
- * Content-Type for git-receive-pack request body.
402
- */
403
- export declare const CONTENT_TYPE_RECEIVE_PACK_REQUEST = "application/x-git-receive-pack-request";
404
- /**
405
- * Content-Type for git-receive-pack response body.
406
- */
407
- export declare const CONTENT_TYPE_RECEIVE_PACK_RESULT = "application/x-git-receive-pack-result";
408
- /**
409
- * Zero SHA constant used for ref creation/deletion.
410
- *
411
- * @description
412
- * This 40-character string of zeros is used as a placeholder SHA:
413
- * - In oldSha: indicates a ref is being created (doesn't exist yet)
414
- * - In newSha: indicates a ref is being deleted
415
- *
416
- * @example
417
- * ```typescript
418
- * // Check if this is a create operation
419
- * const isCreate = command.oldSha === ZERO_SHA
420
- *
421
- * // Check if this is a delete operation
422
- * const isDelete = command.newSha === ZERO_SHA
423
- * ```
424
- */
425
- export declare const ZERO_SHA = "0000000000000000000000000000000000000000";
426
- /**
427
- * Handle GET /info/refs requests for ref discovery.
428
- *
429
- * @description
430
- * This is the first endpoint called by git clients when initiating a fetch
431
- * or push operation. It returns:
432
- * 1. The service being requested
433
- * 2. A list of all refs with their current SHA values
434
- * 3. Server capabilities on the first ref line
435
- *
436
- * The response format is pkt-line encoded for compatibility with Git's
437
- * smart HTTP protocol.
438
- *
439
- * @param request - The incoming HTTP request
440
- * @param repository - Repository provider for fetching refs
441
- * @param capabilities - Optional server capabilities to advertise
442
- * @returns Promise resolving to HTTP response with ref advertisement
443
- *
444
- * @throws {SmartHTTPError} 400 if service parameter is missing or invalid
445
- * @throws {SmartHTTPError} 403 if permission is denied
446
- * @throws {SmartHTTPError} 404 if repository does not exist
447
- *
448
- * @example
449
- * ```typescript
450
- * // Handle ref discovery request
451
- * const request: SmartHTTPRequest = {
452
- * method: 'GET',
453
- * path: '/info/refs',
454
- * query: { service: 'git-upload-pack' },
455
- * headers: {},
456
- * repository: 'my-repo'
457
- * }
458
- *
459
- * const capabilities: ServerCapabilities = {
460
- * sideBand64k: true,
461
- * thinPack: true
462
- * }
463
- *
464
- * const response = await handleInfoRefs(request, repoProvider, capabilities)
465
- * // response.status === 200
466
- * // response.headers['Content-Type'] === 'application/x-git-upload-pack-advertisement'
467
- * ```
468
- */
469
- export declare function handleInfoRefs(request: SmartHTTPRequest, repository: RepositoryProvider, capabilities?: ServerCapabilities): Promise<SmartHTTPResponse>;
470
- /**
471
- * Handle POST /git-upload-pack requests for fetch data transfer.
472
- *
473
- * @description
474
- * This endpoint processes fetch requests from git clients. It:
475
- * 1. Parses the client's wants (objects they need) and haves (objects they have)
476
- * 2. Negotiates which objects need to be sent
477
- * 3. Generates and returns a packfile containing the required objects
478
- *
479
- * The response includes ACK/NAK lines followed by the packfile data,
480
- * optionally wrapped in side-band format for progress reporting.
481
- *
482
- * @param request - The incoming HTTP request with wants/haves
483
- * @param repository - Repository provider for creating packfile
484
- * @returns Promise resolving to HTTP response with packfile data
485
- *
486
- * @throws {SmartHTTPError} 400 if request body is missing or malformed
487
- * @throws {SmartHTTPError} 403 if permission is denied
488
- * @throws {SmartHTTPError} 415 if content type is invalid
489
- *
490
- * @example
491
- * ```typescript
492
- * // Handle fetch request
493
- * const request: SmartHTTPRequest = {
494
- * method: 'POST',
495
- * path: '/git-upload-pack',
496
- * query: {},
497
- * headers: { 'Content-Type': 'application/x-git-upload-pack-request' },
498
- * body: requestBody, // pkt-line encoded wants/haves
499
- * repository: 'my-repo'
500
- * }
501
- *
502
- * const response = await handleUploadPack(request, repoProvider)
503
- * // response.body contains NAK + packfile data
504
- * ```
505
- */
506
- export declare function handleUploadPack(request: SmartHTTPRequest, repository: RepositoryProvider): Promise<SmartHTTPResponse>;
507
- /**
508
- * Handle POST /git-receive-pack requests for push data transfer.
509
- *
510
- * @description
511
- * This endpoint processes push requests from git clients. It:
512
- * 1. Parses ref update commands (create, update, delete)
513
- * 2. Extracts and validates the incoming packfile
514
- * 3. Applies ref updates (if packfile is valid)
515
- * 4. Returns a status report (if report-status capability was requested)
516
- *
517
- * The response includes unpack status and individual ref update results.
518
- *
519
- * @param request - The incoming HTTP request with commands and packfile
520
- * @param repository - Repository provider for processing push
521
- * @returns Promise resolving to HTTP response with status report
522
- *
523
- * @throws {SmartHTTPError} 400 if request body is missing or malformed
524
- * @throws {SmartHTTPError} 403 if permission is denied
525
- * @throws {SmartHTTPError} 415 if content type is invalid
526
- *
527
- * @example
528
- * ```typescript
529
- * // Handle push request
530
- * const request: SmartHTTPRequest = {
531
- * method: 'POST',
532
- * path: '/git-receive-pack',
533
- * query: {},
534
- * headers: { 'Content-Type': 'application/x-git-receive-pack-request' },
535
- * body: requestBody, // commands + packfile
536
- * repository: 'my-repo'
537
- * }
538
- *
539
- * const response = await handleReceivePack(request, repoProvider)
540
- * // response.body contains "unpack ok" + ref status lines
541
- * ```
542
- */
543
- export declare function handleReceivePack(request: SmartHTTPRequest, repository: RepositoryProvider): Promise<SmartHTTPResponse>;
544
- /**
545
- * Format ref advertisement for info/refs response.
546
- *
547
- * @description
548
- * Creates a pkt-line formatted ref advertisement that includes:
549
- * 1. Service announcement line (e.g., "# service=git-upload-pack")
550
- * 2. Flush packet
551
- * 3. First ref with capabilities (or zero SHA for empty repos)
552
- * 4. Remaining refs
553
- * 5. Peeled refs for annotated tags
554
- * 6. Final flush packet
555
- *
556
- * @param service - The git service (git-upload-pack or git-receive-pack)
557
- * @param refs - Array of refs to advertise
558
- * @param capabilities - Optional server capabilities to include
559
- * @returns Formatted ref advertisement as Uint8Array
560
- *
561
- * @example
562
- * ```typescript
563
- * const refs: GitRef[] = [
564
- * { sha: 'abc123...', name: 'refs/heads/main' },
565
- * { sha: 'def456...', name: 'refs/heads/feature' }
566
- * ]
567
- *
568
- * const advertisement = formatRefAdvertisement(
569
- * 'git-upload-pack',
570
- * refs,
571
- * { sideBand64k: true, thinPack: true }
572
- * )
573
- * ```
574
- */
575
- export declare function formatRefAdvertisement(service: GitService, refs: GitRef[], capabilities?: ServerCapabilities): Uint8Array;
576
- /**
577
- * Parse upload-pack request body.
578
- *
579
- * @description
580
- * Extracts wants, haves, and capabilities from the pkt-line formatted
581
- * request body sent by git fetch. The format is:
582
- * 1. Want lines: "want <sha> [capabilities]" (caps only on first)
583
- * 2. Shallow/filter commands (optional)
584
- * 3. Flush packet
585
- * 4. Have lines: "have <sha>"
586
- * 5. "done" line (or flush for multi_ack)
587
- *
588
- * @param body - Request body as Uint8Array
589
- * @returns Parsed wants, haves, capabilities, and done flag
590
- *
591
- * @throws {Error} If the request is malformed (invalid pkt-line format)
592
- *
593
- * @example
594
- * ```typescript
595
- * const body = encoder.encode(
596
- * '0032want abc123... side-band-64k\n' +
597
- * '0000' +
598
- * '0032have def456...\n' +
599
- * '0009done\n'
600
- * )
601
- *
602
- * const { wants, haves, capabilities, done } = parseUploadPackRequest(body)
603
- * // wants = ['abc123...']
604
- * // haves = ['def456...']
605
- * // capabilities = ['side-band-64k']
606
- * // done = true
607
- * ```
608
- */
609
- export declare function parseUploadPackRequest(body: Uint8Array): {
610
- wants: string[];
611
- haves: string[];
612
- capabilities: string[];
613
- done: boolean;
614
- };
615
- /**
616
- * Parse receive-pack request body.
617
- *
618
- * @description
619
- * Extracts ref update commands, capabilities, and packfile data from
620
- * the request body sent by git push. The format is:
621
- * 1. Command lines: "<old-sha> <new-sha> <refname>" (caps on first via NUL)
622
- * 2. Flush packet
623
- * 3. Push options (optional, if push-options capability)
624
- * 4. Flush packet (if push options present)
625
- * 5. PACK data (packfile)
626
- *
627
- * @param body - Request body as Uint8Array
628
- * @returns Parsed commands, capabilities, and packfile
629
- *
630
- * @throws {Error} If the request is malformed
631
- *
632
- * @example
633
- * ```typescript
634
- * const body = encoder.encode(
635
- * '0077' + ZERO_SHA + ' abc123... refs/heads/new\0report-status\n' +
636
- * '0000' +
637
- * 'PACK...' // packfile data
638
- * )
639
- *
640
- * const { commands, capabilities, packfile } = parseReceivePackRequest(body)
641
- * // commands = [{ oldSha: ZERO_SHA, newSha: 'abc123...', refName: 'refs/heads/new' }]
642
- * // capabilities = ['report-status']
643
- * ```
644
- */
645
- export declare function parseReceivePackRequest(body: Uint8Array): {
646
- commands: RefUpdateCommand[];
647
- capabilities: string[];
648
- packfile: Uint8Array;
649
- };
650
- /**
651
- * Format upload-pack response.
652
- *
653
- * @description
654
- * Creates the response body for git-upload-pack POST request,
655
- * including NAK/ACK responses and packfile data with optional sideband.
656
- * The response format is:
657
- * 1. NAK or ACK lines (based on negotiation)
658
- * 2. Packfile data (optionally wrapped in side-band)
659
- * 3. Flush packet
660
- *
661
- * @param packData - The packfile data to send
662
- * @param useSideBand - Whether to use side-band encoding (channel 1 for data)
663
- * @param hasCommonObjects - Whether there are common objects (for ACK vs NAK)
664
- * @param haves - The have SHAs from the client (first one is ACKed if common)
665
- * @returns Formatted response as Uint8Array
666
- *
667
- * @example
668
- * ```typescript
669
- * // Simple NAK response with packfile
670
- * const response = formatUploadPackResponse(packData, false, false, [])
671
- *
672
- * // Side-band response with ACK
673
- * const response = formatUploadPackResponse(
674
- * packData,
675
- * true,
676
- * true,
677
- * ['abc123...']
678
- * )
679
- * ```
680
- */
681
- export declare function formatUploadPackResponse(packData: Uint8Array, useSideBand?: boolean, hasCommonObjects?: boolean, haves?: string[]): Uint8Array;
682
- /**
683
- * Format receive-pack response.
684
- *
685
- * @description
686
- * Creates the response body for git-receive-pack POST request,
687
- * including unpack status and ref update results. The format is:
688
- * 1. Unpack status line: "unpack ok" or "unpack error"
689
- * 2. Ref status lines: "ok <refname>" or "ng <refname> <error>"
690
- * 3. Flush packet
691
- *
692
- * @param result - Result of the receive-pack operation
693
- * @returns Formatted response as Uint8Array
694
- *
695
- * @example
696
- * ```typescript
697
- * const result: ReceivePackResult = {
698
- * success: true,
699
- * refResults: [
700
- * { refName: 'refs/heads/main', success: true },
701
- * { refName: 'refs/heads/feature', success: false, error: 'non-fast-forward' }
702
- * ]
703
- * }
704
- *
705
- * const response = formatReceivePackResponse(result)
706
- * // "unpack ok\nok refs/heads/main\nng refs/heads/feature non-fast-forward\n0000"
707
- * ```
708
- */
709
- export declare function formatReceivePackResponse(result: ReceivePackResult): Uint8Array;
710
- /**
711
- * Convert ServerCapabilities to capability string list.
712
- *
713
- * @description
714
- * Converts the ServerCapabilities object into an array of capability
715
- * strings suitable for inclusion in ref advertisements. Boolean capabilities
716
- * become simple strings, while capabilities with values become "name=value".
717
- *
718
- * @param capabilities - Server capabilities object
719
- * @returns Array of capability strings
720
- *
721
- * @example
722
- * ```typescript
723
- * const caps: ServerCapabilities = {
724
- * sideBand64k: true,
725
- * thinPack: true,
726
- * agent: 'my-server/1.0'
727
- * }
728
- *
729
- * const strings = capabilitiesToStrings(caps)
730
- * // ['side-band-64k', 'thin-pack', 'agent=my-server/1.0']
731
- * ```
732
- */
733
- export declare function capabilitiesToStrings(capabilities: ServerCapabilities): string[];
734
- /**
735
- * Parse capability strings into ServerCapabilities object.
736
- *
737
- * @description
738
- * Converts an array of capability strings (as received from a client or
739
- * server) into a structured ServerCapabilities object for easier access.
740
- *
741
- * @param capStrings - Array of capability strings
742
- * @returns Parsed capabilities object
743
- *
744
- * @example
745
- * ```typescript
746
- * const strings = ['side-band-64k', 'thin-pack', 'agent=git/2.30.0']
747
- * const caps = parseCapabilities(strings)
748
- * // caps.sideBand64k === true
749
- * // caps.thinPack === true
750
- * // caps.agent === 'git/2.30.0'
751
- * ```
752
- */
753
- export declare function parseCapabilities(capStrings: string[]): ServerCapabilities;
754
- /**
755
- * Validate Content-Type header for a request.
756
- *
757
- * @description
758
- * Compares the provided Content-Type header against an expected value,
759
- * handling case-insensitivity and stripping charset or other parameters.
760
- *
761
- * @param contentType - The Content-Type header value from the request
762
- * @param expectedType - The expected Content-Type
763
- * @returns true if the content type matches, false otherwise
764
- *
765
- * @example
766
- * ```typescript
767
- * validateContentType(
768
- * 'application/x-git-upload-pack-request; charset=utf-8',
769
- * 'application/x-git-upload-pack-request'
770
- * )
771
- * // Returns true
772
- *
773
- * validateContentType('text/plain', 'application/x-git-upload-pack-request')
774
- * // Returns false
775
- * ```
776
- */
777
- export declare function validateContentType(contentType: string | undefined, expectedType: string): boolean;
778
- /**
779
- * Create an error response with appropriate status code and message.
780
- *
781
- * @description
782
- * Helper function to create a properly formatted error response with
783
- * the correct HTTP status code, status text, and plain text body.
784
- *
785
- * @param statusCode - HTTP status code (e.g., 400, 403, 404)
786
- * @param message - Error message to include in the response body
787
- * @returns SmartHTTPResponse with error information
788
- *
789
- * @example
790
- * ```typescript
791
- * const response = createErrorResponse(404, 'Repository not found')
792
- * // response.status === 404
793
- * // response.statusText === 'Not Found'
794
- * // response.headers['Content-Type'] === 'text/plain'
795
- * // response.body contains 'Repository not found'
796
- * ```
797
- */
798
- export declare function createErrorResponse(statusCode: number, message: string): SmartHTTPResponse;
799
- //# sourceMappingURL=smart-http.d.ts.map