@leed-ai/git-gateway-contract 0.0.0-stage → 0.1.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 (286) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +50 -2
  3. package/dist/behaviour/assertions.d.ts +23 -0
  4. package/dist/behaviour/assertions.js +56 -0
  5. package/dist/behaviour/assertions.js.map +1 -0
  6. package/dist/behaviour/behaviour-case.d.ts +19 -0
  7. package/dist/behaviour/behaviour-case.js +12 -0
  8. package/dist/behaviour/behaviour-case.js.map +1 -0
  9. package/dist/behaviour/behaviour-suite.d.ts +30 -0
  10. package/dist/behaviour/behaviour-suite.js +50 -0
  11. package/dist/behaviour/behaviour-suite.js.map +1 -0
  12. package/dist/behaviour/commit-action-cases.d.ts +4 -0
  13. package/dist/behaviour/commit-action-cases.js +342 -0
  14. package/dist/behaviour/commit-action-cases.js.map +1 -0
  15. package/dist/behaviour/commit-write-cases.d.ts +4 -0
  16. package/dist/behaviour/commit-write-cases.js +234 -0
  17. package/dist/behaviour/commit-write-cases.js.map +1 -0
  18. package/dist/behaviour/fixtures.d.ts +29 -0
  19. package/dist/behaviour/fixtures.js +83 -0
  20. package/dist/behaviour/fixtures.js.map +1 -0
  21. package/dist/behaviour/lifecycle-cases.d.ts +4 -0
  22. package/dist/behaviour/lifecycle-cases.js +158 -0
  23. package/dist/behaviour/lifecycle-cases.js.map +1 -0
  24. package/dist/behaviour/promote-cases.d.ts +4 -0
  25. package/dist/behaviour/promote-cases.js +122 -0
  26. package/dist/behaviour/promote-cases.js.map +1 -0
  27. package/dist/behaviour/read-cases.d.ts +4 -0
  28. package/dist/behaviour/read-cases.js +248 -0
  29. package/dist/behaviour/read-cases.js.map +1 -0
  30. package/dist/behaviour/sync-cases.d.ts +4 -0
  31. package/dist/behaviour/sync-cases.js +205 -0
  32. package/dist/behaviour/sync-cases.js.map +1 -0
  33. package/dist/clock-B3MlpmVY.d.ts +10 -0
  34. package/dist/commit-BEZmeAOl.d.ts +23 -0
  35. package/dist/file-map-CxUveLWz.d.ts +18 -0
  36. package/dist/gateway-config-oVsdTEeK.d.ts +39 -0
  37. package/dist/gateway-error-body-BWzZFAQI.d.ts +214 -0
  38. package/dist/gateway-error.d.ts +30 -0
  39. package/dist/gateway-error.js +63 -0
  40. package/dist/gateway-error.js.map +1 -0
  41. package/dist/git-gateway-VA9Tc5tn.d.ts +358 -0
  42. package/dist/git-gateway.d.ts +2 -0
  43. package/dist/git-gateway.js +65 -0
  44. package/dist/git-gateway.js.map +1 -0
  45. package/dist/health.d.ts +9 -0
  46. package/dist/health.js +18 -0
  47. package/dist/health.js.map +1 -0
  48. package/dist/history-CqvHaUE-.d.ts +20 -0
  49. package/dist/package-name.d.ts +3 -0
  50. package/dist/package-name.js +6 -0
  51. package/dist/package-name.js.map +1 -0
  52. package/dist/proxy/audit-event.d.ts +61 -0
  53. package/dist/proxy/audit-event.js +97 -0
  54. package/dist/proxy/audit-event.js.map +1 -0
  55. package/dist/proxy/branch-rule.d.ts +72 -0
  56. package/dist/proxy/branch-rule.js +106 -0
  57. package/dist/proxy/branch-rule.js.map +1 -0
  58. package/dist/proxy/gateway-hooks.d.ts +58 -0
  59. package/dist/proxy/gateway-hooks.js +0 -0
  60. package/dist/proxy/git-operation.d.ts +17 -0
  61. package/dist/proxy/git-operation.js +32 -0
  62. package/dist/proxy/git-operation.js.map +1 -0
  63. package/dist/proxy/policy-result.d.ts +51 -0
  64. package/dist/proxy/policy-result.js +90 -0
  65. package/dist/proxy/policy-result.js.map +1 -0
  66. package/dist/proxy/principal.d.ts +18 -0
  67. package/dist/proxy/principal.js +32 -0
  68. package/dist/proxy/principal.js.map +1 -0
  69. package/dist/proxy/push-policy-result.d.ts +34 -0
  70. package/dist/proxy/push-policy-result.js +48 -0
  71. package/dist/proxy/push-policy-result.js.map +1 -0
  72. package/dist/proxy/push-policy.d.ts +146 -0
  73. package/dist/proxy/push-policy.js +112 -0
  74. package/dist/proxy/push-policy.js.map +1 -0
  75. package/dist/proxy/request-credential.d.ts +22 -0
  76. package/dist/proxy/request-credential.js +46 -0
  77. package/dist/proxy/request-credential.js.map +1 -0
  78. package/dist/proxy/smart-http-config.d.ts +22 -0
  79. package/dist/proxy/smart-http-config.js +40 -0
  80. package/dist/proxy/smart-http-config.js.map +1 -0
  81. package/dist/reference/apply-actions.d.ts +9 -0
  82. package/dist/reference/apply-actions.js +84 -0
  83. package/dist/reference/apply-actions.js.map +1 -0
  84. package/dist/reference/branch-methods.d.ts +7 -0
  85. package/dist/reference/branch-methods.js +105 -0
  86. package/dist/reference/branch-methods.js.map +1 -0
  87. package/dist/reference/bytes.d.ts +22 -0
  88. package/dist/reference/bytes.js +62 -0
  89. package/dist/reference/bytes.js.map +1 -0
  90. package/dist/reference/clock.d.ts +2 -0
  91. package/dist/reference/clock.js +18 -0
  92. package/dist/reference/clock.js.map +1 -0
  93. package/dist/reference/commit-method.d.ts +5 -0
  94. package/dist/reference/commit-method.js +83 -0
  95. package/dist/reference/commit-method.js.map +1 -0
  96. package/dist/reference/file-map.d.ts +2 -0
  97. package/dist/reference/file-map.js +24 -0
  98. package/dist/reference/file-map.js.map +1 -0
  99. package/dist/reference/hash.d.ts +10 -0
  100. package/dist/reference/hash.js +25 -0
  101. package/dist/reference/hash.js.map +1 -0
  102. package/dist/reference/history.d.ts +2 -0
  103. package/dist/reference/history.js +65 -0
  104. package/dist/reference/history.js.map +1 -0
  105. package/dist/reference/lifecycle-methods.d.ts +9 -0
  106. package/dist/reference/lifecycle-methods.js +48 -0
  107. package/dist/reference/lifecycle-methods.js.map +1 -0
  108. package/dist/reference/read-methods.d.ts +13 -0
  109. package/dist/reference/read-methods.js +68 -0
  110. package/dist/reference/read-methods.js.map +1 -0
  111. package/dist/reference/reference-gateway.d.ts +18 -0
  112. package/dist/reference/reference-gateway.js +35 -0
  113. package/dist/reference/reference-gateway.js.map +1 -0
  114. package/dist/reference/repo-state.d.ts +43 -0
  115. package/dist/reference/repo-state.js +45 -0
  116. package/dist/reference/repo-state.js.map +1 -0
  117. package/dist/reference/run-method.d.ts +13 -0
  118. package/dist/reference/run-method.js +15 -0
  119. package/dist/reference/run-method.js.map +1 -0
  120. package/dist/reference/three-way-merge.d.ts +16 -0
  121. package/dist/reference/three-way-merge.js +45 -0
  122. package/dist/reference/three-way-merge.js.map +1 -0
  123. package/dist/reference/trailer.d.ts +7 -0
  124. package/dist/reference/trailer.js +16 -0
  125. package/dist/reference/trailer.js.map +1 -0
  126. package/dist/reference/tree-index.d.ts +2 -0
  127. package/dist/reference/tree-index.js +66 -0
  128. package/dist/reference/tree-index.js.map +1 -0
  129. package/dist/reference/write-commit.d.ts +15 -0
  130. package/dist/reference/write-commit.js +44 -0
  131. package/dist/reference/write-commit.js.map +1 -0
  132. package/dist/rpc/commit-exists.d.ts +16 -0
  133. package/dist/rpc/commit-exists.js +30 -0
  134. package/dist/rpc/commit-exists.js.map +1 -0
  135. package/dist/rpc/commit.d.ts +172 -0
  136. package/dist/rpc/commit.js +115 -0
  137. package/dist/rpc/commit.js.map +1 -0
  138. package/dist/rpc/list-tree.d.ts +59 -0
  139. package/dist/rpc/list-tree.js +54 -0
  140. package/dist/rpc/list-tree.js.map +1 -0
  141. package/dist/rpc/log.d.ts +35 -0
  142. package/dist/rpc/log.js +41 -0
  143. package/dist/rpc/log.js.map +1 -0
  144. package/dist/rpc/mint-read-token.d.ts +17 -0
  145. package/dist/rpc/mint-read-token.js +36 -0
  146. package/dist/rpc/mint-read-token.js.map +1 -0
  147. package/dist/rpc/promote.d.ts +39 -0
  148. package/dist/rpc/promote.js +69 -0
  149. package/dist/rpc/promote.js.map +1 -0
  150. package/dist/rpc/read-file.d.ts +44 -0
  151. package/dist/rpc/read-file.js +56 -0
  152. package/dist/rpc/read-file.js.map +1 -0
  153. package/dist/rpc/repo-lifecycle.d.ts +39 -0
  154. package/dist/rpc/repo-lifecycle.js +64 -0
  155. package/dist/rpc/repo-lifecycle.js.map +1 -0
  156. package/dist/rpc/resolve-ref.d.ts +15 -0
  157. package/dist/rpc/resolve-ref.js +28 -0
  158. package/dist/rpc/resolve-ref.js.map +1 -0
  159. package/dist/rpc/sync-branch.d.ts +107 -0
  160. package/dist/rpc/sync-branch.js +114 -0
  161. package/dist/rpc/sync-branch.js.map +1 -0
  162. package/dist/schemas/commit-action.d.ts +100 -0
  163. package/dist/schemas/commit-action.js +138 -0
  164. package/dist/schemas/commit-action.js.map +1 -0
  165. package/dist/schemas/commit.d.ts +2 -0
  166. package/dist/schemas/commit.js +24 -0
  167. package/dist/schemas/commit.js.map +1 -0
  168. package/dist/schemas/content-encoding.d.ts +24 -0
  169. package/dist/schemas/content-encoding.js +41 -0
  170. package/dist/schemas/content-encoding.js.map +1 -0
  171. package/dist/schemas/examples.d.ts +38 -0
  172. package/dist/schemas/examples.js +32 -0
  173. package/dist/schemas/examples.js.map +1 -0
  174. package/dist/schemas/gateway-config.d.ts +2 -0
  175. package/dist/schemas/gateway-config.js +72 -0
  176. package/dist/schemas/gateway-config.js.map +1 -0
  177. package/dist/schemas/gateway-error-body.d.ts +2 -0
  178. package/dist/schemas/gateway-error-body.js +188 -0
  179. package/dist/schemas/gateway-error-body.js.map +1 -0
  180. package/dist/schemas/identity.d.ts +21 -0
  181. package/dist/schemas/identity.js +40 -0
  182. package/dist/schemas/identity.js.map +1 -0
  183. package/dist/schemas/names.d.ts +26 -0
  184. package/dist/schemas/names.js +58 -0
  185. package/dist/schemas/names.js.map +1 -0
  186. package/dist/schemas/ref-update.d.ts +10 -0
  187. package/dist/schemas/ref-update.js +25 -0
  188. package/dist/schemas/ref-update.js.map +1 -0
  189. package/dist/schemas/sha.d.ts +8 -0
  190. package/dist/schemas/sha.js +14 -0
  191. package/dist/schemas/sha.js.map +1 -0
  192. package/dist/schemas/tree-entry.d.ts +2 -0
  193. package/dist/schemas/tree-entry.js +62 -0
  194. package/dist/schemas/tree-entry.js.map +1 -0
  195. package/dist/storage/git-remote.d.ts +17 -0
  196. package/dist/storage/git-remote.js +31 -0
  197. package/dist/storage/git-remote.js.map +1 -0
  198. package/dist/storage/storage-backend.d.ts +61 -0
  199. package/dist/storage/storage-backend.js +0 -0
  200. package/dist/storage/storage-errors.d.ts +12 -0
  201. package/dist/storage/storage-errors.js +22 -0
  202. package/dist/storage/storage-errors.js.map +1 -0
  203. package/dist/storage/storage-input.d.ts +7 -0
  204. package/dist/storage/storage-input.js +14 -0
  205. package/dist/storage/storage-input.js.map +1 -0
  206. package/dist/storage/storage-read.d.ts +13 -0
  207. package/dist/storage/storage-read.js +30 -0
  208. package/dist/storage/storage-read.js.map +1 -0
  209. package/dist/storage/storage-repo-info.d.ts +16 -0
  210. package/dist/storage/storage-repo-info.js +30 -0
  211. package/dist/storage/storage-repo-info.js.map +1 -0
  212. package/dist/storage/storage-tree-entry.d.ts +21 -0
  213. package/dist/storage/storage-tree-entry.js +17 -0
  214. package/dist/storage/storage-tree-entry.js.map +1 -0
  215. package/dist/tree-entry-BM_1gou1.d.ts +41 -0
  216. package/dist/tree-index-Bk721Phv.d.ts +14 -0
  217. package/package.json +401 -4
  218. package/src/behaviour/assertions.ts +75 -0
  219. package/src/behaviour/behaviour-case.ts +28 -0
  220. package/src/behaviour/behaviour-suite.ts +76 -0
  221. package/src/behaviour/commit-action-cases.ts +253 -0
  222. package/src/behaviour/commit-write-cases.ts +205 -0
  223. package/src/behaviour/fixtures.ts +103 -0
  224. package/src/behaviour/lifecycle-cases.ts +104 -0
  225. package/src/behaviour/promote-cases.ts +78 -0
  226. package/src/behaviour/read-cases.ts +176 -0
  227. package/src/behaviour/sync-cases.ts +156 -0
  228. package/src/gateway-error.ts +72 -0
  229. package/src/git-gateway.ts +76 -0
  230. package/src/health.ts +26 -0
  231. package/src/package-name.ts +4 -0
  232. package/src/proxy/audit-event.ts +135 -0
  233. package/src/proxy/branch-rule.ts +190 -0
  234. package/src/proxy/gateway-hooks.ts +67 -0
  235. package/src/proxy/git-operation.ts +36 -0
  236. package/src/proxy/policy-result.ts +127 -0
  237. package/src/proxy/principal.ts +81 -0
  238. package/src/proxy/push-policy-result.ts +86 -0
  239. package/src/proxy/push-policy.ts +158 -0
  240. package/src/proxy/request-credential.ts +47 -0
  241. package/src/proxy/smart-http-config.ts +158 -0
  242. package/src/reference/apply-actions.ts +96 -0
  243. package/src/reference/branch-methods.ts +105 -0
  244. package/src/reference/bytes.ts +66 -0
  245. package/src/reference/clock.ts +19 -0
  246. package/src/reference/commit-method.ts +97 -0
  247. package/src/reference/file-map.ts +35 -0
  248. package/src/reference/hash.ts +25 -0
  249. package/src/reference/history.ts +78 -0
  250. package/src/reference/lifecycle-methods.ts +52 -0
  251. package/src/reference/read-methods.ts +87 -0
  252. package/src/reference/reference-gateway.ts +50 -0
  253. package/src/reference/repo-state.ts +83 -0
  254. package/src/reference/run-method.ts +25 -0
  255. package/src/reference/three-way-merge.ts +42 -0
  256. package/src/reference/trailer.ts +18 -0
  257. package/src/reference/tree-index.ts +65 -0
  258. package/src/reference/write-commit.ts +44 -0
  259. package/src/rpc/commit-exists.ts +46 -0
  260. package/src/rpc/commit.ts +156 -0
  261. package/src/rpc/list-tree.ts +78 -0
  262. package/src/rpc/log.ts +51 -0
  263. package/src/rpc/mint-read-token.ts +59 -0
  264. package/src/rpc/promote.ts +72 -0
  265. package/src/rpc/read-file.ts +75 -0
  266. package/src/rpc/repo-lifecycle.ts +103 -0
  267. package/src/rpc/resolve-ref.ts +41 -0
  268. package/src/rpc/sync-branch.ts +149 -0
  269. package/src/schemas/commit-action.ts +157 -0
  270. package/src/schemas/commit.ts +43 -0
  271. package/src/schemas/content-encoding.ts +58 -0
  272. package/src/schemas/examples.ts +24 -0
  273. package/src/schemas/gateway-config.ts +116 -0
  274. package/src/schemas/gateway-error-body.ts +230 -0
  275. package/src/schemas/identity.ts +57 -0
  276. package/src/schemas/names.ts +126 -0
  277. package/src/schemas/ref-update.ts +38 -0
  278. package/src/schemas/sha.ts +20 -0
  279. package/src/schemas/tree-entry.ts +72 -0
  280. package/src/storage/git-remote.ts +58 -0
  281. package/src/storage/storage-backend.ts +65 -0
  282. package/src/storage/storage-errors.ts +24 -0
  283. package/src/storage/storage-input.ts +14 -0
  284. package/src/storage/storage-read.ts +45 -0
  285. package/src/storage/storage-repo-info.ts +46 -0
  286. package/src/storage/storage-tree-entry.ts +20 -0
package/package.json CHANGED
@@ -1,6 +1,403 @@
1
1
  {
2
2
  "name": "@leed-ai/git-gateway-contract",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Zod schemas and the RPC interface of git-gateway (the API contract), with an in-memory reference implementation.",
5
+ "keywords": [
6
+ "cloudflare-workers",
7
+ "contract",
8
+ "git",
9
+ "git-gateway",
10
+ "rpc",
11
+ "zod"
12
+ ],
13
+ "homepage": "https://github.com/leed-ai/git-gateway/tree/main/packages/contract#readme",
14
+ "bugs": {
15
+ "url": "https://github.com/leed-ai/git-gateway/issues"
16
+ },
17
+ "license": "Apache-2.0",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/leed-ai/git-gateway.git",
21
+ "directory": "packages/contract"
22
+ },
23
+ "files": [
24
+ "dist",
25
+ "src"
26
+ ],
27
+ "type": "module",
28
+ "sideEffects": false,
29
+ "exports": {
30
+ "./behaviour/assertions": {
31
+ "source": "./src/behaviour/assertions.ts",
32
+ "types": "./dist/behaviour/assertions.d.ts",
33
+ "default": "./dist/behaviour/assertions.js"
34
+ },
35
+ "./behaviour/behaviour-case": {
36
+ "source": "./src/behaviour/behaviour-case.ts",
37
+ "types": "./dist/behaviour/behaviour-case.d.ts",
38
+ "default": "./dist/behaviour/behaviour-case.js"
39
+ },
40
+ "./behaviour/behaviour-suite": {
41
+ "source": "./src/behaviour/behaviour-suite.ts",
42
+ "types": "./dist/behaviour/behaviour-suite.d.ts",
43
+ "default": "./dist/behaviour/behaviour-suite.js"
44
+ },
45
+ "./behaviour/commit-action-cases": {
46
+ "source": "./src/behaviour/commit-action-cases.ts",
47
+ "types": "./dist/behaviour/commit-action-cases.d.ts",
48
+ "default": "./dist/behaviour/commit-action-cases.js"
49
+ },
50
+ "./behaviour/commit-write-cases": {
51
+ "source": "./src/behaviour/commit-write-cases.ts",
52
+ "types": "./dist/behaviour/commit-write-cases.d.ts",
53
+ "default": "./dist/behaviour/commit-write-cases.js"
54
+ },
55
+ "./behaviour/fixtures": {
56
+ "source": "./src/behaviour/fixtures.ts",
57
+ "types": "./dist/behaviour/fixtures.d.ts",
58
+ "default": "./dist/behaviour/fixtures.js"
59
+ },
60
+ "./behaviour/lifecycle-cases": {
61
+ "source": "./src/behaviour/lifecycle-cases.ts",
62
+ "types": "./dist/behaviour/lifecycle-cases.d.ts",
63
+ "default": "./dist/behaviour/lifecycle-cases.js"
64
+ },
65
+ "./behaviour/promote-cases": {
66
+ "source": "./src/behaviour/promote-cases.ts",
67
+ "types": "./dist/behaviour/promote-cases.d.ts",
68
+ "default": "./dist/behaviour/promote-cases.js"
69
+ },
70
+ "./behaviour/read-cases": {
71
+ "source": "./src/behaviour/read-cases.ts",
72
+ "types": "./dist/behaviour/read-cases.d.ts",
73
+ "default": "./dist/behaviour/read-cases.js"
74
+ },
75
+ "./behaviour/sync-cases": {
76
+ "source": "./src/behaviour/sync-cases.ts",
77
+ "types": "./dist/behaviour/sync-cases.d.ts",
78
+ "default": "./dist/behaviour/sync-cases.js"
79
+ },
80
+ "./gateway-error": {
81
+ "source": "./src/gateway-error.ts",
82
+ "types": "./dist/gateway-error.d.ts",
83
+ "default": "./dist/gateway-error.js"
84
+ },
85
+ "./git-gateway": {
86
+ "source": "./src/git-gateway.ts",
87
+ "types": "./dist/git-gateway.d.ts",
88
+ "default": "./dist/git-gateway.js"
89
+ },
90
+ "./health": {
91
+ "source": "./src/health.ts",
92
+ "types": "./dist/health.d.ts",
93
+ "default": "./dist/health.js"
94
+ },
95
+ "./package-name": {
96
+ "source": "./src/package-name.ts",
97
+ "types": "./dist/package-name.d.ts",
98
+ "default": "./dist/package-name.js"
99
+ },
100
+ "./proxy/audit-event": {
101
+ "source": "./src/proxy/audit-event.ts",
102
+ "types": "./dist/proxy/audit-event.d.ts",
103
+ "default": "./dist/proxy/audit-event.js"
104
+ },
105
+ "./proxy/branch-rule": {
106
+ "source": "./src/proxy/branch-rule.ts",
107
+ "types": "./dist/proxy/branch-rule.d.ts",
108
+ "default": "./dist/proxy/branch-rule.js"
109
+ },
110
+ "./proxy/gateway-hooks": {
111
+ "source": "./src/proxy/gateway-hooks.ts",
112
+ "types": "./dist/proxy/gateway-hooks.d.ts",
113
+ "default": "./dist/proxy/gateway-hooks.js"
114
+ },
115
+ "./proxy/git-operation": {
116
+ "source": "./src/proxy/git-operation.ts",
117
+ "types": "./dist/proxy/git-operation.d.ts",
118
+ "default": "./dist/proxy/git-operation.js"
119
+ },
120
+ "./proxy/policy-result": {
121
+ "source": "./src/proxy/policy-result.ts",
122
+ "types": "./dist/proxy/policy-result.d.ts",
123
+ "default": "./dist/proxy/policy-result.js"
124
+ },
125
+ "./proxy/push-policy": {
126
+ "source": "./src/proxy/push-policy.ts",
127
+ "types": "./dist/proxy/push-policy.d.ts",
128
+ "default": "./dist/proxy/push-policy.js"
129
+ },
130
+ "./proxy/push-policy-result": {
131
+ "source": "./src/proxy/push-policy-result.ts",
132
+ "types": "./dist/proxy/push-policy-result.d.ts",
133
+ "default": "./dist/proxy/push-policy-result.js"
134
+ },
135
+ "./proxy/principal": {
136
+ "source": "./src/proxy/principal.ts",
137
+ "types": "./dist/proxy/principal.d.ts",
138
+ "default": "./dist/proxy/principal.js"
139
+ },
140
+ "./proxy/request-credential": {
141
+ "source": "./src/proxy/request-credential.ts",
142
+ "types": "./dist/proxy/request-credential.d.ts",
143
+ "default": "./dist/proxy/request-credential.js"
144
+ },
145
+ "./proxy/smart-http-config": {
146
+ "source": "./src/proxy/smart-http-config.ts",
147
+ "types": "./dist/proxy/smart-http-config.d.ts",
148
+ "default": "./dist/proxy/smart-http-config.js"
149
+ },
150
+ "./reference/apply-actions": {
151
+ "source": "./src/reference/apply-actions.ts",
152
+ "types": "./dist/reference/apply-actions.d.ts",
153
+ "default": "./dist/reference/apply-actions.js"
154
+ },
155
+ "./reference/branch-methods": {
156
+ "source": "./src/reference/branch-methods.ts",
157
+ "types": "./dist/reference/branch-methods.d.ts",
158
+ "default": "./dist/reference/branch-methods.js"
159
+ },
160
+ "./reference/bytes": {
161
+ "source": "./src/reference/bytes.ts",
162
+ "types": "./dist/reference/bytes.d.ts",
163
+ "default": "./dist/reference/bytes.js"
164
+ },
165
+ "./reference/clock": {
166
+ "source": "./src/reference/clock.ts",
167
+ "types": "./dist/reference/clock.d.ts",
168
+ "default": "./dist/reference/clock.js"
169
+ },
170
+ "./reference/commit-method": {
171
+ "source": "./src/reference/commit-method.ts",
172
+ "types": "./dist/reference/commit-method.d.ts",
173
+ "default": "./dist/reference/commit-method.js"
174
+ },
175
+ "./reference/file-map": {
176
+ "source": "./src/reference/file-map.ts",
177
+ "types": "./dist/reference/file-map.d.ts",
178
+ "default": "./dist/reference/file-map.js"
179
+ },
180
+ "./reference/hash": {
181
+ "source": "./src/reference/hash.ts",
182
+ "types": "./dist/reference/hash.d.ts",
183
+ "default": "./dist/reference/hash.js"
184
+ },
185
+ "./reference/history": {
186
+ "source": "./src/reference/history.ts",
187
+ "types": "./dist/reference/history.d.ts",
188
+ "default": "./dist/reference/history.js"
189
+ },
190
+ "./reference/lifecycle-methods": {
191
+ "source": "./src/reference/lifecycle-methods.ts",
192
+ "types": "./dist/reference/lifecycle-methods.d.ts",
193
+ "default": "./dist/reference/lifecycle-methods.js"
194
+ },
195
+ "./reference/read-methods": {
196
+ "source": "./src/reference/read-methods.ts",
197
+ "types": "./dist/reference/read-methods.d.ts",
198
+ "default": "./dist/reference/read-methods.js"
199
+ },
200
+ "./reference/reference-gateway": {
201
+ "source": "./src/reference/reference-gateway.ts",
202
+ "types": "./dist/reference/reference-gateway.d.ts",
203
+ "default": "./dist/reference/reference-gateway.js"
204
+ },
205
+ "./reference/repo-state": {
206
+ "source": "./src/reference/repo-state.ts",
207
+ "types": "./dist/reference/repo-state.d.ts",
208
+ "default": "./dist/reference/repo-state.js"
209
+ },
210
+ "./reference/run-method": {
211
+ "source": "./src/reference/run-method.ts",
212
+ "types": "./dist/reference/run-method.d.ts",
213
+ "default": "./dist/reference/run-method.js"
214
+ },
215
+ "./reference/three-way-merge": {
216
+ "source": "./src/reference/three-way-merge.ts",
217
+ "types": "./dist/reference/three-way-merge.d.ts",
218
+ "default": "./dist/reference/three-way-merge.js"
219
+ },
220
+ "./reference/trailer": {
221
+ "source": "./src/reference/trailer.ts",
222
+ "types": "./dist/reference/trailer.d.ts",
223
+ "default": "./dist/reference/trailer.js"
224
+ },
225
+ "./reference/tree-index": {
226
+ "source": "./src/reference/tree-index.ts",
227
+ "types": "./dist/reference/tree-index.d.ts",
228
+ "default": "./dist/reference/tree-index.js"
229
+ },
230
+ "./reference/write-commit": {
231
+ "source": "./src/reference/write-commit.ts",
232
+ "types": "./dist/reference/write-commit.d.ts",
233
+ "default": "./dist/reference/write-commit.js"
234
+ },
235
+ "./rpc/commit": {
236
+ "source": "./src/rpc/commit.ts",
237
+ "types": "./dist/rpc/commit.d.ts",
238
+ "default": "./dist/rpc/commit.js"
239
+ },
240
+ "./rpc/commit-exists": {
241
+ "source": "./src/rpc/commit-exists.ts",
242
+ "types": "./dist/rpc/commit-exists.d.ts",
243
+ "default": "./dist/rpc/commit-exists.js"
244
+ },
245
+ "./rpc/list-tree": {
246
+ "source": "./src/rpc/list-tree.ts",
247
+ "types": "./dist/rpc/list-tree.d.ts",
248
+ "default": "./dist/rpc/list-tree.js"
249
+ },
250
+ "./rpc/log": {
251
+ "source": "./src/rpc/log.ts",
252
+ "types": "./dist/rpc/log.d.ts",
253
+ "default": "./dist/rpc/log.js"
254
+ },
255
+ "./rpc/mint-read-token": {
256
+ "source": "./src/rpc/mint-read-token.ts",
257
+ "types": "./dist/rpc/mint-read-token.d.ts",
258
+ "default": "./dist/rpc/mint-read-token.js"
259
+ },
260
+ "./rpc/promote": {
261
+ "source": "./src/rpc/promote.ts",
262
+ "types": "./dist/rpc/promote.d.ts",
263
+ "default": "./dist/rpc/promote.js"
264
+ },
265
+ "./rpc/read-file": {
266
+ "source": "./src/rpc/read-file.ts",
267
+ "types": "./dist/rpc/read-file.d.ts",
268
+ "default": "./dist/rpc/read-file.js"
269
+ },
270
+ "./rpc/repo-lifecycle": {
271
+ "source": "./src/rpc/repo-lifecycle.ts",
272
+ "types": "./dist/rpc/repo-lifecycle.d.ts",
273
+ "default": "./dist/rpc/repo-lifecycle.js"
274
+ },
275
+ "./rpc/resolve-ref": {
276
+ "source": "./src/rpc/resolve-ref.ts",
277
+ "types": "./dist/rpc/resolve-ref.d.ts",
278
+ "default": "./dist/rpc/resolve-ref.js"
279
+ },
280
+ "./rpc/sync-branch": {
281
+ "source": "./src/rpc/sync-branch.ts",
282
+ "types": "./dist/rpc/sync-branch.d.ts",
283
+ "default": "./dist/rpc/sync-branch.js"
284
+ },
285
+ "./schemas/commit": {
286
+ "source": "./src/schemas/commit.ts",
287
+ "types": "./dist/schemas/commit.d.ts",
288
+ "default": "./dist/schemas/commit.js"
289
+ },
290
+ "./schemas/commit-action": {
291
+ "source": "./src/schemas/commit-action.ts",
292
+ "types": "./dist/schemas/commit-action.d.ts",
293
+ "default": "./dist/schemas/commit-action.js"
294
+ },
295
+ "./schemas/content-encoding": {
296
+ "source": "./src/schemas/content-encoding.ts",
297
+ "types": "./dist/schemas/content-encoding.d.ts",
298
+ "default": "./dist/schemas/content-encoding.js"
299
+ },
300
+ "./schemas/examples": {
301
+ "source": "./src/schemas/examples.ts",
302
+ "types": "./dist/schemas/examples.d.ts",
303
+ "default": "./dist/schemas/examples.js"
304
+ },
305
+ "./schemas/gateway-config": {
306
+ "source": "./src/schemas/gateway-config.ts",
307
+ "types": "./dist/schemas/gateway-config.d.ts",
308
+ "default": "./dist/schemas/gateway-config.js"
309
+ },
310
+ "./schemas/gateway-error-body": {
311
+ "source": "./src/schemas/gateway-error-body.ts",
312
+ "types": "./dist/schemas/gateway-error-body.d.ts",
313
+ "default": "./dist/schemas/gateway-error-body.js"
314
+ },
315
+ "./schemas/identity": {
316
+ "source": "./src/schemas/identity.ts",
317
+ "types": "./dist/schemas/identity.d.ts",
318
+ "default": "./dist/schemas/identity.js"
319
+ },
320
+ "./schemas/names": {
321
+ "source": "./src/schemas/names.ts",
322
+ "types": "./dist/schemas/names.d.ts",
323
+ "default": "./dist/schemas/names.js"
324
+ },
325
+ "./schemas/ref-update": {
326
+ "source": "./src/schemas/ref-update.ts",
327
+ "types": "./dist/schemas/ref-update.d.ts",
328
+ "default": "./dist/schemas/ref-update.js"
329
+ },
330
+ "./schemas/sha": {
331
+ "source": "./src/schemas/sha.ts",
332
+ "types": "./dist/schemas/sha.d.ts",
333
+ "default": "./dist/schemas/sha.js"
334
+ },
335
+ "./schemas/tree-entry": {
336
+ "source": "./src/schemas/tree-entry.ts",
337
+ "types": "./dist/schemas/tree-entry.d.ts",
338
+ "default": "./dist/schemas/tree-entry.js"
339
+ },
340
+ "./storage/git-remote": {
341
+ "source": "./src/storage/git-remote.ts",
342
+ "types": "./dist/storage/git-remote.d.ts",
343
+ "default": "./dist/storage/git-remote.js"
344
+ },
345
+ "./storage/storage-backend": {
346
+ "source": "./src/storage/storage-backend.ts",
347
+ "types": "./dist/storage/storage-backend.d.ts",
348
+ "default": "./dist/storage/storage-backend.js"
349
+ },
350
+ "./storage/storage-errors": {
351
+ "source": "./src/storage/storage-errors.ts",
352
+ "types": "./dist/storage/storage-errors.d.ts",
353
+ "default": "./dist/storage/storage-errors.js"
354
+ },
355
+ "./storage/storage-input": {
356
+ "source": "./src/storage/storage-input.ts",
357
+ "types": "./dist/storage/storage-input.d.ts",
358
+ "default": "./dist/storage/storage-input.js"
359
+ },
360
+ "./storage/storage-read": {
361
+ "source": "./src/storage/storage-read.ts",
362
+ "types": "./dist/storage/storage-read.d.ts",
363
+ "default": "./dist/storage/storage-read.js"
364
+ },
365
+ "./storage/storage-repo-info": {
366
+ "source": "./src/storage/storage-repo-info.ts",
367
+ "types": "./dist/storage/storage-repo-info.d.ts",
368
+ "default": "./dist/storage/storage-repo-info.js"
369
+ },
370
+ "./storage/storage-tree-entry": {
371
+ "source": "./src/storage/storage-tree-entry.ts",
372
+ "types": "./dist/storage/storage-tree-entry.d.ts",
373
+ "default": "./dist/storage/storage-tree-entry.js"
374
+ },
375
+ "./package.json": "./package.json"
376
+ },
377
+ "publishConfig": {
378
+ "access": "public",
379
+ "provenance": true
380
+ },
381
+ "scripts": {
382
+ "build": "vp pack",
383
+ "check": "vp check",
384
+ "test": "vp test --exclude 'test/**/*.conformance.test.ts'",
385
+ "test:contract": "vp test test/contract/",
386
+ "test:conformance": "vp test conformance"
387
+ },
388
+ "devDependencies": {
389
+ "@leed-ai/git-gateway-repo-tools": "0.0.0",
390
+ "@leed-ai/git-gateway-schema-docs": "0.0.0",
391
+ "@types/node": "^24.19.2",
392
+ "fast-check": "^4.10.3",
393
+ "typescript": "^7.0.2",
394
+ "vite-plus": "^1.7.0",
395
+ "zod": "^4.6.7"
396
+ },
397
+ "peerDependencies": {
398
+ "zod": "^4"
399
+ },
400
+ "engines": {
401
+ "node": ">=22.18.0"
402
+ }
403
+ }
@@ -0,0 +1,75 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ import { readGatewayError, type GatewayErrorOf } from '../gateway-error.ts';
3
+ import type { GatewayErrorBody, GatewayErrorCode } from '../schemas/gateway-error-body.ts';
4
+
5
+ /** The error a behaviour case throws when the implementation under test breaks a rule. */
6
+ export class BehaviourFailure extends Error {
7
+ override readonly name = 'BehaviourFailure';
8
+ }
9
+
10
+ const show = (value: unknown): string => JSON.stringify(value, null, 2) ?? String(value);
11
+
12
+ /** True when two values are structurally equal (plain objects, arrays and primitives). */
13
+ export function deepEqual(a: unknown, b: unknown): boolean {
14
+ if (Object.is(a, b)) return true;
15
+ if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) return false;
16
+ if (Array.isArray(a) !== Array.isArray(b)) return false;
17
+ const keysA = Object.keys(a).filter((key) => Reflect.get(a, key) !== undefined);
18
+ const keysB = Object.keys(b).filter((key) => Reflect.get(b, key) !== undefined);
19
+ if (keysA.length !== keysB.length) return false;
20
+ return keysA.every((key) => deepEqual(Reflect.get(a, key), Reflect.get(b, key)));
21
+ }
22
+
23
+ /** Fails unless `condition` holds. */
24
+ export function assertTrue(condition: boolean, message: string): asserts condition {
25
+ if (!condition) throw new BehaviourFailure(message);
26
+ }
27
+
28
+ /** Fails unless `actual` structurally equals `expected`. */
29
+ export function assertEqual(actual: unknown, expected: unknown, message: string): void {
30
+ if (!deepEqual(actual, expected)) {
31
+ throw new BehaviourFailure(`${message}\nexpected: ${show(expected)}\nactual: ${show(actual)}`);
32
+ }
33
+ }
34
+
35
+ function hasCode<C extends GatewayErrorCode>(body: GatewayErrorBody, code: C): body is GatewayErrorOf<C> {
36
+ return body.code === code;
37
+ }
38
+
39
+ /** Awaits `call`, fails unless it rejects with a gateway error of `code`, and returns that error's body. */
40
+ export async function expectGatewayError<C extends GatewayErrorCode>(
41
+ call: Promise<unknown>,
42
+ code: C,
43
+ ): Promise<GatewayErrorOf<C>> {
44
+ let outcome: unknown;
45
+ try {
46
+ outcome = await call;
47
+ } catch (thrown) {
48
+ const body = readGatewayError(thrown);
49
+ if (body !== null && hasCode(body, code)) return body;
50
+ throw new BehaviourFailure(`expected a ${code} gateway error, got: ${show(body ?? String(thrown))}`);
51
+ }
52
+ throw new BehaviourFailure(`expected a ${code} gateway error, but the call resolved to ${show(outcome)}`);
53
+ }
54
+
55
+ function hasStatus<T extends { status: string }, S extends T['status']>(
56
+ output: T,
57
+ status: S,
58
+ ): output is Extract<T, { status: S }> {
59
+ return output.status === status;
60
+ }
61
+
62
+ /** Fails unless the output has `status`, and returns it narrowed to that branch. */
63
+ export function expectStatus<T extends { status: string }, S extends T['status']>(
64
+ output: T,
65
+ status: S,
66
+ ): Extract<T, { status: S }> {
67
+ if (hasStatus(output, status)) return output;
68
+ throw new BehaviourFailure(`expected status "${status}", got ${show(output)}`);
69
+ }
70
+
71
+ /** Fails when the value is null or undefined, and returns it otherwise. */
72
+ export function present<T>(value: T | null | undefined, message: string): T {
73
+ if (value === null || value === undefined) throw new BehaviourFailure(message);
74
+ return value;
75
+ }
@@ -0,0 +1,28 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ import type { GitGateway } from '../git-gateway.ts';
3
+
4
+ /** What a behaviour case runs against: the gateway under test and a repository name of its own. */
5
+ export interface BehaviourContext {
6
+ readonly gateway: GitGateway;
7
+ /** A repository name no other case uses; the case creates the repository itself. */
8
+ readonly repo: string;
9
+ }
10
+
11
+ /** One rule of the contract, checked through the {@link GitGateway} interface alone. */
12
+ export interface BehaviourCase {
13
+ /** The area of the contract, e.g. "commit actions". */
14
+ readonly group: string;
15
+ /** What the case checks, phrased as the rule. */
16
+ readonly name: string;
17
+ /** Resolves when the implementation follows the rule; rejects with a BehaviourFailure otherwise. */
18
+ readonly run: (context: BehaviourContext) => Promise<void>;
19
+ }
20
+
21
+ /** Declares a behaviour case. */
22
+ export function behaviourCase(
23
+ group: string,
24
+ name: string,
25
+ run: (context: BehaviourContext) => Promise<void>,
26
+ ): BehaviourCase {
27
+ return { group, name, run };
28
+ }
@@ -0,0 +1,76 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ import type { GitGateway } from '../git-gateway.ts';
3
+ import type { BehaviourCase } from './behaviour-case.ts';
4
+ import { commitActionCases } from './commit-action-cases.ts';
5
+ import { commitWriteCases } from './commit-write-cases.ts';
6
+ import { lifecycleCases } from './lifecycle-cases.ts';
7
+ import { promoteCases } from './promote-cases.ts';
8
+ import { readCases } from './read-cases.ts';
9
+ import { syncCases } from './sync-cases.ts';
10
+
11
+ /** Every behaviour case, grouped by area of the contract. */
12
+ export const BEHAVIOUR_CASES: readonly BehaviourCase[] = [
13
+ ...lifecycleCases,
14
+ ...commitActionCases,
15
+ ...commitWriteCases,
16
+ ...readCases,
17
+ ...syncCases,
18
+ ...promoteCases,
19
+ ];
20
+
21
+ /** The two functions of a test framework the suite registers through (Vitest, Jest, bun:test, node:test…). */
22
+ export interface TestRegistrar {
23
+ describe(name: string, body: () => void): void;
24
+ it(name: string, body: () => Promise<void>): void;
25
+ }
26
+
27
+ /** How to run the suite against one implementation. */
28
+ export interface BehaviourSuiteOptions {
29
+ /** Suite title; default "GitGateway behaviour". */
30
+ readonly name?: string;
31
+ /** Returns the implementation under test; called once per case. */
32
+ readonly createGateway: () => GitGateway | Promise<GitGateway>;
33
+ /** Prefix of every repository name the cases create; default "behaviour". Keep it short. */
34
+ readonly repoPrefix?: string;
35
+ /** Delete each case's repository when the case ends (for shared, long-lived gateways); default false. */
36
+ readonly cleanup?: boolean;
37
+ }
38
+
39
+ const slug = (text: string): string =>
40
+ text
41
+ .toLowerCase()
42
+ .replace(/[^a-z0-9]+/g, '-')
43
+ .replace(/^-|-$/g, '')
44
+ .slice(0, 40);
45
+
46
+ let runCounter = 0;
47
+
48
+ /** Runs one case against a fresh gateway and a repository name no other case uses. */
49
+ export async function runBehaviourCase(entry: BehaviourCase, options: BehaviourSuiteOptions): Promise<void> {
50
+ runCounter += 1;
51
+ const gateway = await options.createGateway();
52
+ const unique = `${runCounter}-${crypto.randomUUID().slice(0, 8)}`;
53
+ const repo = `${options.repoPrefix ?? 'behaviour'}-${slug(entry.name)}-${unique}`.slice(0, 100);
54
+ try {
55
+ await entry.run({ gateway, repo });
56
+ } finally {
57
+ if (options.cleanup === true) await gateway.deleteRepo({ repo });
58
+ }
59
+ }
60
+
61
+ /**
62
+ * Registers the behaviour suite of the {@link GitGateway} contract with a test framework: one test
63
+ * per case, grouped by area. The in-memory reference passes it; the real gateway must pass it too.
64
+ *
65
+ * registerBehaviourSuite({ describe, it }, { createGateway: () => createReferenceGateway() });
66
+ */
67
+ export function registerBehaviourSuite(test: TestRegistrar, options: BehaviourSuiteOptions): void {
68
+ const groups = Map.groupBy(BEHAVIOUR_CASES, (entry) => entry.group);
69
+ test.describe(options.name ?? 'GitGateway behaviour', () => {
70
+ for (const [group, cases] of groups) {
71
+ test.describe(group, () => {
72
+ for (const entry of cases) test.it(entry.name, () => runBehaviourCase(entry, options));
73
+ });
74
+ }
75
+ });
76
+ }