gitx.do 0.1.0 → 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 (344) 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 +15 -415
  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 -174
  20. package/dist/cli/commands/add.d.ts.map +0 -1
  21. package/dist/cli/commands/add.js +0 -131
  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/commit.d.ts +0 -182
  32. package/dist/cli/commands/commit.d.ts.map +0 -1
  33. package/dist/cli/commands/commit.js +0 -437
  34. package/dist/cli/commands/commit.js.map +0 -1
  35. package/dist/cli/commands/diff.d.ts +0 -464
  36. package/dist/cli/commands/diff.d.ts.map +0 -1
  37. package/dist/cli/commands/diff.js +0 -958
  38. package/dist/cli/commands/diff.js.map +0 -1
  39. package/dist/cli/commands/log.d.ts +0 -239
  40. package/dist/cli/commands/log.d.ts.map +0 -1
  41. package/dist/cli/commands/log.js +0 -535
  42. package/dist/cli/commands/log.js.map +0 -1
  43. package/dist/cli/commands/merge.d.ts +0 -106
  44. package/dist/cli/commands/merge.d.ts.map +0 -1
  45. package/dist/cli/commands/merge.js +0 -55
  46. package/dist/cli/commands/merge.js.map +0 -1
  47. package/dist/cli/commands/review.d.ts +0 -457
  48. package/dist/cli/commands/review.d.ts.map +0 -1
  49. package/dist/cli/commands/review.js +0 -533
  50. package/dist/cli/commands/review.js.map +0 -1
  51. package/dist/cli/commands/status.d.ts +0 -269
  52. package/dist/cli/commands/status.d.ts.map +0 -1
  53. package/dist/cli/commands/status.js +0 -493
  54. package/dist/cli/commands/status.js.map +0 -1
  55. package/dist/cli/commands/web.d.ts +0 -199
  56. package/dist/cli/commands/web.d.ts.map +0 -1
  57. package/dist/cli/commands/web.js +0 -696
  58. package/dist/cli/commands/web.js.map +0 -1
  59. package/dist/cli/fs-adapter.d.ts +0 -656
  60. package/dist/cli/fs-adapter.d.ts.map +0 -1
  61. package/dist/cli/fs-adapter.js +0 -1179
  62. package/dist/cli/fs-adapter.js.map +0 -1
  63. package/dist/cli/fsx-cli-adapter.d.ts +0 -359
  64. package/dist/cli/fsx-cli-adapter.d.ts.map +0 -1
  65. package/dist/cli/fsx-cli-adapter.js +0 -619
  66. package/dist/cli/fsx-cli-adapter.js.map +0 -1
  67. package/dist/cli/index.d.ts +0 -387
  68. package/dist/cli/index.d.ts.map +0 -1
  69. package/dist/cli/index.js +0 -523
  70. package/dist/cli/index.js.map +0 -1
  71. package/dist/cli/ui/components/DiffView.d.ts +0 -7
  72. package/dist/cli/ui/components/DiffView.d.ts.map +0 -1
  73. package/dist/cli/ui/components/DiffView.js +0 -11
  74. package/dist/cli/ui/components/DiffView.js.map +0 -1
  75. package/dist/cli/ui/components/ErrorDisplay.d.ts +0 -6
  76. package/dist/cli/ui/components/ErrorDisplay.d.ts.map +0 -1
  77. package/dist/cli/ui/components/ErrorDisplay.js +0 -11
  78. package/dist/cli/ui/components/ErrorDisplay.js.map +0 -1
  79. package/dist/cli/ui/components/FuzzySearch.d.ts +0 -9
  80. package/dist/cli/ui/components/FuzzySearch.d.ts.map +0 -1
  81. package/dist/cli/ui/components/FuzzySearch.js +0 -12
  82. package/dist/cli/ui/components/FuzzySearch.js.map +0 -1
  83. package/dist/cli/ui/components/LoadingSpinner.d.ts +0 -6
  84. package/dist/cli/ui/components/LoadingSpinner.d.ts.map +0 -1
  85. package/dist/cli/ui/components/LoadingSpinner.js +0 -10
  86. package/dist/cli/ui/components/LoadingSpinner.js.map +0 -1
  87. package/dist/cli/ui/components/NavigationList.d.ts +0 -9
  88. package/dist/cli/ui/components/NavigationList.d.ts.map +0 -1
  89. package/dist/cli/ui/components/NavigationList.js +0 -11
  90. package/dist/cli/ui/components/NavigationList.js.map +0 -1
  91. package/dist/cli/ui/components/ScrollableContent.d.ts +0 -8
  92. package/dist/cli/ui/components/ScrollableContent.d.ts.map +0 -1
  93. package/dist/cli/ui/components/ScrollableContent.js +0 -11
  94. package/dist/cli/ui/components/ScrollableContent.js.map +0 -1
  95. package/dist/cli/ui/components/index.d.ts +0 -7
  96. package/dist/cli/ui/components/index.d.ts.map +0 -1
  97. package/dist/cli/ui/components/index.js +0 -9
  98. package/dist/cli/ui/components/index.js.map +0 -1
  99. package/dist/cli/ui/terminal-ui.d.ts +0 -52
  100. package/dist/cli/ui/terminal-ui.d.ts.map +0 -1
  101. package/dist/cli/ui/terminal-ui.js +0 -121
  102. package/dist/cli/ui/terminal-ui.js.map +0 -1
  103. package/dist/do/BashModule.d.ts +0 -871
  104. package/dist/do/BashModule.d.ts.map +0 -1
  105. package/dist/do/BashModule.js +0 -1143
  106. package/dist/do/BashModule.js.map +0 -1
  107. package/dist/do/FsModule.d.ts +0 -601
  108. package/dist/do/FsModule.d.ts.map +0 -1
  109. package/dist/do/FsModule.js +0 -1120
  110. package/dist/do/FsModule.js.map +0 -1
  111. package/dist/do/GitModule.d.ts +0 -635
  112. package/dist/do/GitModule.d.ts.map +0 -1
  113. package/dist/do/GitModule.js +0 -781
  114. package/dist/do/GitModule.js.map +0 -1
  115. package/dist/do/GitRepoDO.d.ts +0 -281
  116. package/dist/do/GitRepoDO.d.ts.map +0 -1
  117. package/dist/do/GitRepoDO.js +0 -479
  118. package/dist/do/GitRepoDO.js.map +0 -1
  119. package/dist/do/bash-ast.d.ts +0 -246
  120. package/dist/do/bash-ast.d.ts.map +0 -1
  121. package/dist/do/bash-ast.js +0 -888
  122. package/dist/do/bash-ast.js.map +0 -1
  123. package/dist/do/container-executor.d.ts +0 -491
  124. package/dist/do/container-executor.d.ts.map +0 -1
  125. package/dist/do/container-executor.js +0 -730
  126. package/dist/do/container-executor.js.map +0 -1
  127. package/dist/do/index.d.ts +0 -53
  128. package/dist/do/index.d.ts.map +0 -1
  129. package/dist/do/index.js +0 -91
  130. package/dist/do/index.js.map +0 -1
  131. package/dist/do/tiered-storage.d.ts +0 -403
  132. package/dist/do/tiered-storage.d.ts.map +0 -1
  133. package/dist/do/tiered-storage.js +0 -689
  134. package/dist/do/tiered-storage.js.map +0 -1
  135. package/dist/do/withBash.d.ts +0 -231
  136. package/dist/do/withBash.d.ts.map +0 -1
  137. package/dist/do/withBash.js +0 -244
  138. package/dist/do/withBash.js.map +0 -1
  139. package/dist/do/withFs.d.ts +0 -237
  140. package/dist/do/withFs.d.ts.map +0 -1
  141. package/dist/do/withFs.js +0 -387
  142. package/dist/do/withFs.js.map +0 -1
  143. package/dist/do/withGit.d.ts +0 -180
  144. package/dist/do/withGit.d.ts.map +0 -1
  145. package/dist/do/withGit.js +0 -271
  146. package/dist/do/withGit.js.map +0 -1
  147. package/dist/durable-object/object-store.d.ts +0 -633
  148. package/dist/durable-object/object-store.d.ts.map +0 -1
  149. package/dist/durable-object/object-store.js +0 -1161
  150. package/dist/durable-object/object-store.js.map +0 -1
  151. package/dist/durable-object/schema.d.ts.map +0 -1
  152. package/dist/durable-object/schema.js.map +0 -1
  153. package/dist/durable-object/wal.d.ts +0 -416
  154. package/dist/durable-object/wal.d.ts.map +0 -1
  155. package/dist/durable-object/wal.js +0 -445
  156. package/dist/durable-object/wal.js.map +0 -1
  157. package/dist/mcp/adapter.d.ts +0 -772
  158. package/dist/mcp/adapter.d.ts.map +0 -1
  159. package/dist/mcp/adapter.js +0 -895
  160. package/dist/mcp/adapter.js.map +0 -1
  161. package/dist/mcp/sandbox/miniflare-evaluator.d.ts +0 -22
  162. package/dist/mcp/sandbox/miniflare-evaluator.d.ts.map +0 -1
  163. package/dist/mcp/sandbox/miniflare-evaluator.js +0 -140
  164. package/dist/mcp/sandbox/miniflare-evaluator.js.map +0 -1
  165. package/dist/mcp/sandbox/object-store-proxy.d.ts +0 -32
  166. package/dist/mcp/sandbox/object-store-proxy.d.ts.map +0 -1
  167. package/dist/mcp/sandbox/object-store-proxy.js +0 -30
  168. package/dist/mcp/sandbox/object-store-proxy.js.map +0 -1
  169. package/dist/mcp/sandbox/template.d.ts +0 -17
  170. package/dist/mcp/sandbox/template.d.ts.map +0 -1
  171. package/dist/mcp/sandbox/template.js +0 -71
  172. package/dist/mcp/sandbox/template.js.map +0 -1
  173. package/dist/mcp/sandbox.d.ts +0 -764
  174. package/dist/mcp/sandbox.d.ts.map +0 -1
  175. package/dist/mcp/sandbox.js +0 -1362
  176. package/dist/mcp/sandbox.js.map +0 -1
  177. package/dist/mcp/sdk-adapter.d.ts +0 -835
  178. package/dist/mcp/sdk-adapter.d.ts.map +0 -1
  179. package/dist/mcp/sdk-adapter.js +0 -974
  180. package/dist/mcp/sdk-adapter.js.map +0 -1
  181. package/dist/mcp/tools/do.d.ts +0 -32
  182. package/dist/mcp/tools/do.d.ts.map +0 -1
  183. package/dist/mcp/tools/do.js +0 -115
  184. package/dist/mcp/tools/do.js.map +0 -1
  185. package/dist/mcp/tools.d.ts +0 -548
  186. package/dist/mcp/tools.d.ts.map +0 -1
  187. package/dist/mcp/tools.js +0 -1934
  188. package/dist/mcp/tools.js.map +0 -1
  189. package/dist/ops/blame.d.ts +0 -551
  190. package/dist/ops/blame.d.ts.map +0 -1
  191. package/dist/ops/blame.js +0 -1037
  192. package/dist/ops/blame.js.map +0 -1
  193. package/dist/ops/branch.d.ts +0 -766
  194. package/dist/ops/branch.d.ts.map +0 -1
  195. package/dist/ops/branch.js +0 -950
  196. package/dist/ops/branch.js.map +0 -1
  197. package/dist/ops/commit-traversal.d.ts +0 -349
  198. package/dist/ops/commit-traversal.d.ts.map +0 -1
  199. package/dist/ops/commit-traversal.js +0 -821
  200. package/dist/ops/commit-traversal.js.map +0 -1
  201. package/dist/ops/commit.d.ts +0 -555
  202. package/dist/ops/commit.d.ts.map +0 -1
  203. package/dist/ops/commit.js +0 -826
  204. package/dist/ops/commit.js.map +0 -1
  205. package/dist/ops/merge-base.d.ts +0 -397
  206. package/dist/ops/merge-base.d.ts.map +0 -1
  207. package/dist/ops/merge-base.js +0 -691
  208. package/dist/ops/merge-base.js.map +0 -1
  209. package/dist/ops/merge.d.ts +0 -855
  210. package/dist/ops/merge.d.ts.map +0 -1
  211. package/dist/ops/merge.js +0 -1551
  212. package/dist/ops/merge.js.map +0 -1
  213. package/dist/ops/tag.d.ts +0 -247
  214. package/dist/ops/tag.d.ts.map +0 -1
  215. package/dist/ops/tag.js +0 -649
  216. package/dist/ops/tag.js.map +0 -1
  217. package/dist/ops/tree-builder.d.ts +0 -178
  218. package/dist/ops/tree-builder.d.ts.map +0 -1
  219. package/dist/ops/tree-builder.js +0 -271
  220. package/dist/ops/tree-builder.js.map +0 -1
  221. package/dist/ops/tree-diff.d.ts +0 -291
  222. package/dist/ops/tree-diff.d.ts.map +0 -1
  223. package/dist/ops/tree-diff.js +0 -705
  224. package/dist/ops/tree-diff.js.map +0 -1
  225. package/dist/pack/delta.d.ts +0 -248
  226. package/dist/pack/delta.d.ts.map +0 -1
  227. package/dist/pack/delta.js +0 -736
  228. package/dist/pack/delta.js.map +0 -1
  229. package/dist/pack/format.d.ts +0 -446
  230. package/dist/pack/format.d.ts.map +0 -1
  231. package/dist/pack/format.js +0 -572
  232. package/dist/pack/format.js.map +0 -1
  233. package/dist/pack/full-generation.d.ts +0 -612
  234. package/dist/pack/full-generation.d.ts.map +0 -1
  235. package/dist/pack/full-generation.js +0 -1378
  236. package/dist/pack/full-generation.js.map +0 -1
  237. package/dist/pack/generation.d.ts +0 -441
  238. package/dist/pack/generation.d.ts.map +0 -1
  239. package/dist/pack/generation.js +0 -707
  240. package/dist/pack/generation.js.map +0 -1
  241. package/dist/pack/index.d.ts +0 -502
  242. package/dist/pack/index.d.ts.map +0 -1
  243. package/dist/pack/index.js +0 -833
  244. package/dist/pack/index.js.map +0 -1
  245. package/dist/refs/branch.d.ts +0 -668
  246. package/dist/refs/branch.d.ts.map +0 -1
  247. package/dist/refs/branch.js +0 -897
  248. package/dist/refs/branch.js.map +0 -1
  249. package/dist/refs/storage.d.ts +0 -833
  250. package/dist/refs/storage.d.ts.map +0 -1
  251. package/dist/refs/storage.js +0 -1023
  252. package/dist/refs/storage.js.map +0 -1
  253. package/dist/refs/tag.d.ts +0 -860
  254. package/dist/refs/tag.d.ts.map +0 -1
  255. package/dist/refs/tag.js +0 -996
  256. package/dist/refs/tag.js.map +0 -1
  257. package/dist/storage/backend.d.ts +0 -425
  258. package/dist/storage/backend.d.ts.map +0 -1
  259. package/dist/storage/backend.js +0 -41
  260. package/dist/storage/backend.js.map +0 -1
  261. package/dist/storage/fsx-adapter.d.ts +0 -204
  262. package/dist/storage/fsx-adapter.d.ts.map +0 -1
  263. package/dist/storage/fsx-adapter.js +0 -470
  264. package/dist/storage/fsx-adapter.js.map +0 -1
  265. package/dist/storage/lru-cache.d.ts +0 -691
  266. package/dist/storage/lru-cache.d.ts.map +0 -1
  267. package/dist/storage/lru-cache.js +0 -813
  268. package/dist/storage/lru-cache.js.map +0 -1
  269. package/dist/storage/object-index.d.ts +0 -585
  270. package/dist/storage/object-index.d.ts.map +0 -1
  271. package/dist/storage/object-index.js +0 -532
  272. package/dist/storage/object-index.js.map +0 -1
  273. package/dist/storage/r2-pack.d.ts +0 -1257
  274. package/dist/storage/r2-pack.d.ts.map +0 -1
  275. package/dist/storage/r2-pack.js +0 -1770
  276. package/dist/storage/r2-pack.js.map +0 -1
  277. package/dist/tiered/cdc-pipeline.d.ts +0 -1888
  278. package/dist/tiered/cdc-pipeline.d.ts.map +0 -1
  279. package/dist/tiered/cdc-pipeline.js +0 -1880
  280. package/dist/tiered/cdc-pipeline.js.map +0 -1
  281. package/dist/tiered/migration.d.ts +0 -1104
  282. package/dist/tiered/migration.d.ts.map +0 -1
  283. package/dist/tiered/migration.js +0 -1214
  284. package/dist/tiered/migration.js.map +0 -1
  285. package/dist/tiered/parquet-writer.d.ts +0 -1145
  286. package/dist/tiered/parquet-writer.d.ts.map +0 -1
  287. package/dist/tiered/parquet-writer.js +0 -1183
  288. package/dist/tiered/parquet-writer.js.map +0 -1
  289. package/dist/tiered/read-path.d.ts +0 -835
  290. package/dist/tiered/read-path.d.ts.map +0 -1
  291. package/dist/tiered/read-path.js +0 -487
  292. package/dist/tiered/read-path.js.map +0 -1
  293. package/dist/types/capability.d.ts +0 -1385
  294. package/dist/types/capability.d.ts.map +0 -1
  295. package/dist/types/capability.js +0 -36
  296. package/dist/types/capability.js.map +0 -1
  297. package/dist/types/index.d.ts +0 -13
  298. package/dist/types/index.d.ts.map +0 -1
  299. package/dist/types/index.js +0 -18
  300. package/dist/types/index.js.map +0 -1
  301. package/dist/types/objects.d.ts +0 -692
  302. package/dist/types/objects.d.ts.map +0 -1
  303. package/dist/types/objects.js +0 -837
  304. package/dist/types/objects.js.map +0 -1
  305. package/dist/types/storage.d.ts +0 -603
  306. package/dist/types/storage.d.ts.map +0 -1
  307. package/dist/types/storage.js +0 -191
  308. package/dist/types/storage.js.map +0 -1
  309. package/dist/types/worker-loader.d.ts +0 -60
  310. package/dist/types/worker-loader.d.ts.map +0 -1
  311. package/dist/types/worker-loader.js +0 -62
  312. package/dist/types/worker-loader.js.map +0 -1
  313. package/dist/utils/hash.d.ts +0 -197
  314. package/dist/utils/hash.d.ts.map +0 -1
  315. package/dist/utils/hash.js +0 -268
  316. package/dist/utils/hash.js.map +0 -1
  317. package/dist/utils/sha1.d.ts +0 -290
  318. package/dist/utils/sha1.d.ts.map +0 -1
  319. package/dist/utils/sha1.js +0 -582
  320. package/dist/utils/sha1.js.map +0 -1
  321. package/dist/wire/capabilities.d.ts +0 -1044
  322. package/dist/wire/capabilities.d.ts.map +0 -1
  323. package/dist/wire/capabilities.js +0 -941
  324. package/dist/wire/capabilities.js.map +0 -1
  325. package/dist/wire/path-security.d.ts +0 -157
  326. package/dist/wire/path-security.d.ts.map +0 -1
  327. package/dist/wire/path-security.js +0 -307
  328. package/dist/wire/path-security.js.map +0 -1
  329. package/dist/wire/pkt-line.d.ts +0 -345
  330. package/dist/wire/pkt-line.d.ts.map +0 -1
  331. package/dist/wire/pkt-line.js +0 -381
  332. package/dist/wire/pkt-line.js.map +0 -1
  333. package/dist/wire/receive-pack.d.ts +0 -1059
  334. package/dist/wire/receive-pack.d.ts.map +0 -1
  335. package/dist/wire/receive-pack.js +0 -1414
  336. package/dist/wire/receive-pack.js.map +0 -1
  337. package/dist/wire/smart-http.d.ts +0 -799
  338. package/dist/wire/smart-http.d.ts.map +0 -1
  339. package/dist/wire/smart-http.js +0 -945
  340. package/dist/wire/smart-http.js.map +0 -1
  341. package/dist/wire/upload-pack.d.ts +0 -727
  342. package/dist/wire/upload-pack.d.ts.map +0 -1
  343. package/dist/wire/upload-pack.js +0 -1138
  344. package/dist/wire/upload-pack.js.map +0 -1
@@ -1,191 +0,0 @@
1
- /**
2
- * @fileoverview Storage Interface Types
3
- *
4
- * This module defines the canonical interfaces for object storage and commit providers.
5
- * All storage-related interfaces are defined here as the single source of truth.
6
- *
7
- * The interfaces follow a layered design:
8
- * - {@link BasicObjectStore} - Core object CRUD operations
9
- * - {@link RefObjectStore} - Adds ref management capabilities
10
- * - {@link TreeDiffObjectStore} - Specialized for tree diff operations
11
- * - {@link ObjectStore} - Full-featured store combining all capabilities
12
- *
13
- * Similarly for commit providers:
14
- * - {@link BasicCommitProvider} - Core commit retrieval
15
- * - {@link CommitProvider} - Extended with path filtering and tree access
16
- *
17
- * @module types/storage
18
- *
19
- * @example
20
- * ```typescript
21
- * import type { ObjectStore, CommitProvider } from './types/storage'
22
- *
23
- * // Implement a storage backend
24
- * class MyObjectStore implements ObjectStore {
25
- * async getObject(sha: string) { ... }
26
- * async storeObject(type: string, data: Uint8Array) { ... }
27
- * // ... other methods
28
- * }
29
- * ```
30
- */
31
- import { isValidSha, isValidObjectType } from './objects';
32
- /**
33
- * Validate a ref name.
34
- *
35
- * @description
36
- * Checks if a ref name follows Git ref naming conventions:
37
- * - Cannot start with '.' or end with '/'
38
- * - Cannot contain '..' or '//'
39
- * - Cannot contain control characters, spaces, or special chars
40
- * - Cannot end with '.lock'
41
- *
42
- * @param refName - The ref name to validate
43
- * @returns Validation result
44
- *
45
- * @example
46
- * ```typescript
47
- * validateRefName('refs/heads/main') // { isValid: true }
48
- * validateRefName('refs/heads/../foo') // { isValid: false, error: '...' }
49
- * ```
50
- */
51
- export function validateRefName(refName) {
52
- if (!refName || typeof refName !== 'string') {
53
- return { isValid: false, error: 'Ref name is required and must be a string' };
54
- }
55
- if (refName.startsWith('.') || refName.startsWith('/')) {
56
- return { isValid: false, error: 'Ref name cannot start with "." or "/"' };
57
- }
58
- if (refName.endsWith('/') || refName.endsWith('.')) {
59
- return { isValid: false, error: 'Ref name cannot end with "/" or "."' };
60
- }
61
- if (refName.includes('..')) {
62
- return { isValid: false, error: 'Ref name cannot contain ".."' };
63
- }
64
- if (refName.includes('//')) {
65
- return { isValid: false, error: 'Ref name cannot contain "//"' };
66
- }
67
- if (refName.endsWith('.lock')) {
68
- return { isValid: false, error: 'Ref name cannot end with ".lock"' };
69
- }
70
- // Check for control characters and special chars
71
- if (/[\x00-\x1f\x7f ~^:?*\[\\]/.test(refName)) {
72
- return { isValid: false, error: 'Ref name contains invalid characters (control chars, space, ~, ^, :, ?, *, [, or \\)' };
73
- }
74
- return { isValid: true };
75
- }
76
- /**
77
- * Validate a ref update operation.
78
- *
79
- * @description
80
- * Validates a reference update operation including:
81
- * - Ref name format
82
- * - Old and new SHA validity (or zero SHA for create/delete)
83
- *
84
- * @param refName - The ref name to update
85
- * @param oldSha - The expected current SHA (or zero SHA if creating)
86
- * @param newSha - The new SHA to set (or zero SHA if deleting)
87
- * @returns Validation result
88
- *
89
- * @example
90
- * ```typescript
91
- * // Creating a new ref
92
- * validateRefUpdate('refs/heads/feature', ZERO_SHA, 'abc123...')
93
- *
94
- * // Updating a ref
95
- * validateRefUpdate('refs/heads/main', 'old123...', 'new456...')
96
- *
97
- * // Deleting a ref
98
- * validateRefUpdate('refs/heads/old', 'abc123...', ZERO_SHA)
99
- * ```
100
- */
101
- export function validateRefUpdate(refName, oldSha, newSha) {
102
- const refResult = validateRefName(refName);
103
- if (!refResult.isValid) {
104
- return refResult;
105
- }
106
- const ZERO_SHA = '0000000000000000000000000000000000000000';
107
- if (oldSha !== ZERO_SHA && !isValidSha(oldSha)) {
108
- return { isValid: false, error: `Invalid old SHA: ${oldSha}. Must be 40 hex chars or zero SHA` };
109
- }
110
- if (newSha !== ZERO_SHA && !isValidSha(newSha)) {
111
- return { isValid: false, error: `Invalid new SHA: ${newSha}. Must be 40 hex chars or zero SHA` };
112
- }
113
- if (oldSha === ZERO_SHA && newSha === ZERO_SHA) {
114
- return { isValid: false, error: 'Cannot have both old and new SHA as zero (no-op)' };
115
- }
116
- return { isValid: true };
117
- }
118
- /**
119
- * Validate object storage parameters.
120
- *
121
- * @description
122
- * Validates parameters for storeObject operations:
123
- * - Object type must be valid
124
- * - Data must be a Uint8Array
125
- *
126
- * @param type - The object type
127
- * @param data - The object data
128
- * @returns Validation result
129
- *
130
- * @example
131
- * ```typescript
132
- * const result = validateStoreParams('blob', new Uint8Array([1, 2, 3]))
133
- * if (!result.isValid) {
134
- * throw new Error(result.error)
135
- * }
136
- * ```
137
- */
138
- export function validateStoreParams(type, data) {
139
- if (!isValidObjectType(type)) {
140
- return { isValid: false, error: `Invalid object type: ${type}. Must be blob, tree, commit, or tag` };
141
- }
142
- if (!(data instanceof Uint8Array)) {
143
- return { isValid: false, error: 'Data must be a Uint8Array' };
144
- }
145
- return { isValid: true };
146
- }
147
- /**
148
- * Assert that a SHA is valid, throwing if not.
149
- *
150
- * @description
151
- * Throws a descriptive error if the SHA is invalid.
152
- * Use this for input validation in API boundaries.
153
- *
154
- * @param sha - The SHA to validate
155
- * @param context - Optional context for the error message (e.g., 'tree', 'parent')
156
- * @throws Error if SHA is invalid
157
- *
158
- * @example
159
- * ```typescript
160
- * assertValidSha(treeSha, 'tree') // Throws: "Invalid tree SHA: ..."
161
- * ```
162
- */
163
- export function assertValidSha(sha, context) {
164
- if (!isValidSha(sha)) {
165
- const prefix = context ? `Invalid ${context} SHA` : 'Invalid SHA';
166
- throw new Error(`${prefix}: ${sha}. Must be 40 lowercase hexadecimal characters`);
167
- }
168
- }
169
- /**
170
- * Assert that a ref name is valid, throwing if not.
171
- *
172
- * @description
173
- * Throws a descriptive error if the ref name is invalid.
174
- * Use this for input validation in API boundaries.
175
- *
176
- * @param refName - The ref name to validate
177
- * @throws Error if ref name is invalid
178
- *
179
- * @example
180
- * ```typescript
181
- * assertValidRefName('refs/heads/main') // OK
182
- * assertValidRefName('refs/../bad') // Throws
183
- * ```
184
- */
185
- export function assertValidRefName(refName) {
186
- const result = validateRefName(refName);
187
- if (!result.isValid) {
188
- throw new Error(result.error);
189
- }
190
- }
191
- //# sourceMappingURL=storage.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/types/storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAoBzD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K,EAAE,KAAK,EAAE,2BAA2B,EAAE,CAAA;IAC/D,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;AAC1B,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,OAAgB;IAC1D,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACrB,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,WAAW,OAAO,MAAM,CAAC,CAAC,CAAC,aAAa,CAAA;QACjE,MAAM,IAAI,KAAK,CAAC,GAAG,MAAM,KAAK,GAAG,+CAA+C,CAAC,CAAA;IACnF,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAAe;IAChD,MAAM,MAAM,GAAG,eAAe,CAAC,OAAO,CAAC,CAAA;IACvC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IAC/B,CAAC;AACH,CAAC"}
@@ -1,60 +0,0 @@
1
- /**
2
- * @fileoverview Worker Loader Types
3
- *
4
- * This module defines types for loading and interacting with Cloudflare Workers
5
- * in the gitdo environment. Based on patterns from mongo.do research.
6
- *
7
- * @module types/worker-loader
8
- */
9
- /**
10
- * WorkerLoader interface for managing worker instances.
11
- */
12
- export interface WorkerLoader {
13
- get(id: string, getCode: () => Promise<WorkerCode>): WorkerStub;
14
- }
15
- /**
16
- * WorkerCode defines the configuration and modules for a worker.
17
- */
18
- export interface WorkerCode {
19
- compatibilityDate: string;
20
- compatibilityFlags?: string[];
21
- mainModule: string;
22
- modules: Record<string, string | {
23
- js: string;
24
- } | {
25
- text: string;
26
- }>;
27
- globalOutbound?: null;
28
- env?: Record<string, unknown>;
29
- }
30
- /**
31
- * WorkerStub provides methods to interact with a worker instance.
32
- */
33
- export interface WorkerStub {
34
- fetch?(request: Request): Promise<Response>;
35
- getEntrypoint?(name?: string): WorkerEntrypoint;
36
- }
37
- /**
38
- * WorkerEntrypoint represents a worker's entrypoint.
39
- */
40
- export interface WorkerEntrypoint {
41
- fetch(request: Request): Promise<Response>;
42
- }
43
- /**
44
- * MockWorkerLoader provides a mock implementation of the WorkerLoader interface
45
- * for testing purposes. It caches WorkerStubs by ID.
46
- */
47
- export declare class MockWorkerLoader implements WorkerLoader {
48
- private cache;
49
- get(id: string, getCode: () => Promise<WorkerCode>): WorkerStub;
50
- }
51
- /**
52
- * Type guard to check if a loader is a real Cloudflare worker loader.
53
- * Returns false for MockWorkerLoader instances, null, undefined, or non-WorkerLoader objects.
54
- * Returns true only for real Cloudflare worker_loaders that have the internal marker.
55
- *
56
- * @param loader - The loader to check
57
- * @returns true if the loader is a real Cloudflare worker loader
58
- */
59
- export declare function isRealWorkerLoader(loader: unknown): loader is WorkerLoader;
60
- //# sourceMappingURL=worker-loader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"worker-loader.d.ts","sourceRoot":"","sources":["../../src/types/worker-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU,CAAA;CAChE;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,iBAAiB,EAAE,MAAM,CAAA;IACzB,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC7B,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IACnE,cAAc,CAAC,EAAE,IAAI,CAAA;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;IAC3C,aAAa,CAAC,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAAA;CAChD;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;CAC3C;AAOD;;;GAGG;AACH,qBAAa,gBAAiB,YAAW,YAAY;IACnD,OAAO,CAAC,KAAK,CAAgC;IAE7C,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU;CAsBhE;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,YAAY,CAgB1E"}
@@ -1,62 +0,0 @@
1
- /**
2
- * @fileoverview Worker Loader Types
3
- *
4
- * This module defines types for loading and interacting with Cloudflare Workers
5
- * in the gitdo environment. Based on patterns from mongo.do research.
6
- *
7
- * @module types/worker-loader
8
- */
9
- /**
10
- * Internal marker symbol for identifying real Cloudflare worker loaders.
11
- */
12
- const REAL_WORKER_LOADER_MARKER = Symbol.for('cloudflare.worker_loader');
13
- /**
14
- * MockWorkerLoader provides a mock implementation of the WorkerLoader interface
15
- * for testing purposes. It caches WorkerStubs by ID.
16
- */
17
- export class MockWorkerLoader {
18
- cache = new Map();
19
- get(id, getCode) {
20
- const cached = this.cache.get(id);
21
- if (cached) {
22
- return cached;
23
- }
24
- const stub = {
25
- fetch: async (request) => {
26
- return new Response('MockWorkerLoader response');
27
- },
28
- getEntrypoint: (name) => {
29
- return {
30
- fetch: async (request) => {
31
- return new Response('MockWorkerLoader entrypoint response');
32
- }
33
- };
34
- }
35
- };
36
- this.cache.set(id, stub);
37
- return stub;
38
- }
39
- }
40
- /**
41
- * Type guard to check if a loader is a real Cloudflare worker loader.
42
- * Returns false for MockWorkerLoader instances, null, undefined, or non-WorkerLoader objects.
43
- * Returns true only for real Cloudflare worker_loaders that have the internal marker.
44
- *
45
- * @param loader - The loader to check
46
- * @returns true if the loader is a real Cloudflare worker loader
47
- */
48
- export function isRealWorkerLoader(loader) {
49
- if (loader === null || loader === undefined) {
50
- return false;
51
- }
52
- if (loader instanceof MockWorkerLoader) {
53
- return false;
54
- }
55
- if (typeof loader !== 'object') {
56
- return false;
57
- }
58
- // Check for the internal marker that real Cloudflare worker loaders would have
59
- const obj = loader;
60
- return obj[REAL_WORKER_LOADER_MARKER] === true;
61
- }
62
- //# sourceMappingURL=worker-loader.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"worker-loader.js","sourceRoot":"","sources":["../../src/types/worker-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAoCH;;GAEG;AACH,MAAM,yBAAyB,GAAG,MAAM,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAA;AAExE;;;GAGG;AACH,MAAM,OAAO,gBAAgB;IACnB,KAAK,GAAG,IAAI,GAAG,EAAsB,CAAA;IAE7C,GAAG,CAAC,EAAU,EAAE,OAAkC;QAChD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QACjC,IAAI,MAAM,EAAE,CAAC;YACX,OAAO,MAAM,CAAA;QACf,CAAC;QAED,MAAM,IAAI,GAAe;YACvB,KAAK,EAAE,KAAK,EAAE,OAAgB,EAAqB,EAAE;gBACnD,OAAO,IAAI,QAAQ,CAAC,2BAA2B,CAAC,CAAA;YAClD,CAAC;YACD,aAAa,EAAE,CAAC,IAAa,EAAoB,EAAE;gBACjD,OAAO;oBACL,KAAK,EAAE,KAAK,EAAE,OAAgB,EAAqB,EAAE;wBACnD,OAAO,IAAI,QAAQ,CAAC,sCAAsC,CAAC,CAAA;oBAC7D,CAAC;iBACF,CAAA;YACH,CAAC;SACF,CAAA;QAED,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,CAAA;QACxB,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAe;IAChD,IAAI,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QAC5C,OAAO,KAAK,CAAA;IACd,CAAC;IAED,IAAI,MAAM,YAAY,gBAAgB,EAAE,CAAC;QACvC,OAAO,KAAK,CAAA;IACd,CAAC;IAED,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,OAAO,KAAK,CAAA;IACd,CAAC;IAED,+EAA+E;IAC/E,MAAM,GAAG,GAAG,MAA0C,CAAA;IACtD,OAAO,GAAG,CAAC,yBAAyB,CAAC,KAAK,IAAI,CAAA;AAChD,CAAC"}
@@ -1,197 +0,0 @@
1
- /**
2
- * @fileoverview SHA Hashing Utilities for Git Objects
3
- *
4
- * This module provides cryptographic hashing functions used for Git object
5
- * identification and verification. Git uses SHA-1 as its primary hash algorithm,
6
- * with SHA-256 available as an optional newer algorithm (Git v2.29+).
7
- *
8
- * Core hash primitives are re-exported from fsx.do, with gitx-specific
9
- * utilities like HashCache and hashObject defined here.
10
- *
11
- * @module utils/hash
12
- *
13
- * @example
14
- * ```typescript
15
- * import { sha1, hashObject, hexToBytes, bytesToHex } from './utils/hash'
16
- *
17
- * // Hash raw data
18
- * const hash = await sha1('Hello, World!')
19
- *
20
- * // Hash as a Git object (includes type header)
21
- * const content = new TextEncoder().encode('file content')
22
- * const blobSha = await hashObject('blob', content)
23
- * console.log(`blob ${blobSha}`)
24
- * ```
25
- */
26
- export { sha1, sha256, hexToBytes, bytesToHex } from '../../../fsx/src/cas/hash';
27
- /**
28
- * Hash a Git object with its type header.
29
- *
30
- * @description
31
- * Computes the SHA-1 hash of a Git object including its header.
32
- * The header format is: "{type} {size}\0" followed by the content.
33
- *
34
- * This matches the output of `git hash-object` command and is the
35
- * standard way Git computes object identifiers.
36
- *
37
- * @param type - Object type ('blob', 'tree', 'commit', 'tag')
38
- * @param data - Object content as binary data (without header)
39
- * @returns 40-character lowercase hexadecimal SHA-1 hash
40
- *
41
- * @example
42
- * ```typescript
43
- * // Hash a blob (equivalent to `echo -n "hello" | git hash-object --stdin`)
44
- * const content = new TextEncoder().encode('hello')
45
- * const sha = await hashObject('blob', content)
46
- * console.log(sha) // 'b6fc4c620b67d95f953a5c1c1230aaab5db5a1b0'
47
- *
48
- * // Verify with git:
49
- * // $ echo -n "hello" | git hash-object --stdin
50
- * // b6fc4c620b67d95f953a5c1c1230aaab5db5a1b0
51
- * ```
52
- */
53
- export declare function hashObject(type: string, data: Uint8Array): Promise<string>;
54
- /**
55
- * LRU cache for storing computed hashes.
56
- *
57
- * @description
58
- * A Least Recently Used (LRU) cache implementation for caching SHA-1 hashes.
59
- * This is useful when the same data is hashed multiple times, such as during
60
- * pack file operations or object store lookups.
61
- *
62
- * **Key Strategy**: The cache key is derived from the first few bytes of the
63
- * data combined with its length, which provides a fast key generation while
64
- * avoiding collisions for different data.
65
- *
66
- * **Thread Safety**: This implementation is NOT thread-safe. In multi-threaded
67
- * environments, external synchronization is required.
68
- *
69
- * @class HashCache
70
- *
71
- * @example
72
- * ```typescript
73
- * const cache = new HashCache(1000) // Cache up to 1000 hashes
74
- *
75
- * // Use with getOrCompute for automatic caching
76
- * const hash1 = await cache.getOrCompute(data, async () => sha1(data))
77
- * const hash2 = await cache.getOrCompute(data, async () => sha1(data)) // Returns cached
78
- *
79
- * // Check stats
80
- * console.log(`Hit rate: ${cache.hitRate}%`)
81
- * ```
82
- */
83
- export declare class HashCache {
84
- private cache;
85
- private maxSize;
86
- private hits;
87
- private misses;
88
- /**
89
- * Creates a new HashCache with the specified maximum size.
90
- *
91
- * @param {number} maxSize - Maximum number of hashes to cache (default: 10000)
92
- */
93
- constructor(maxSize?: number);
94
- /**
95
- * Generates a cache key for the given data.
96
- *
97
- * @description Uses length + first 32 bytes (if available) to create a unique key.
98
- * This is fast while providing good collision resistance.
99
- *
100
- * @param {Uint8Array} data - Data to generate key for
101
- * @returns {string} Cache key
102
- * @internal
103
- */
104
- private generateKey;
105
- /**
106
- * Gets a cached hash if available.
107
- *
108
- * @param {Uint8Array} data - Data to look up
109
- * @returns {string | undefined} Cached hash or undefined if not cached
110
- */
111
- get(data: Uint8Array): string | undefined;
112
- /**
113
- * Stores a hash in the cache.
114
- *
115
- * @param {Uint8Array} data - Original data
116
- * @param {string} hash - Computed hash to cache
117
- */
118
- set(data: Uint8Array, hash: string): void;
119
- /**
120
- * Gets a hash from cache or computes and caches it.
121
- *
122
- * @description This is the recommended way to use the cache. It automatically
123
- * handles cache lookup, computation, and storage.
124
- *
125
- * @param {Uint8Array} data - Data to hash
126
- * @param {() => Promise<string> | string} compute - Function to compute hash if not cached
127
- * @returns {Promise<string>} The hash (from cache or newly computed)
128
- *
129
- * @example
130
- * ```typescript
131
- * const hash = await cache.getOrCompute(data, () => sha1(data))
132
- * ```
133
- */
134
- getOrCompute(data: Uint8Array, compute: () => Promise<string> | string): Promise<string>;
135
- /**
136
- * Synchronous version of getOrCompute for use with synchronous hash functions.
137
- *
138
- * @param {Uint8Array} data - Data to hash
139
- * @param {() => string} compute - Function to compute hash if not cached
140
- * @returns {string} The hash (from cache or newly computed)
141
- *
142
- * @example
143
- * ```typescript
144
- * import { sha1Hex } from './sha1'
145
- * const hash = cache.getOrComputeSync(data, () => sha1Hex(data))
146
- * ```
147
- */
148
- getOrComputeSync(data: Uint8Array, compute: () => string): string;
149
- /**
150
- * Clears all entries from the cache.
151
- */
152
- clear(): void;
153
- /**
154
- * Gets the current number of cached entries.
155
- */
156
- get size(): number;
157
- /**
158
- * Gets the cache hit rate as a percentage.
159
- */
160
- get hitRate(): number;
161
- /**
162
- * Gets cache statistics.
163
- *
164
- * @returns {{ hits: number; misses: number; size: number; hitRate: number }}
165
- */
166
- getStats(): {
167
- hits: number;
168
- misses: number;
169
- size: number;
170
- hitRate: number;
171
- };
172
- }
173
- /**
174
- * Global hash cache instance for common use cases.
175
- *
176
- * @description
177
- * A shared cache instance that can be used across the application for
178
- * caching object hashes. This is particularly useful for pack file
179
- * operations where the same objects are hashed multiple times.
180
- *
181
- * **Memory Management**: The cache has a default limit of 10,000 entries.
182
- * For applications with different requirements, create a custom HashCache
183
- * instance with appropriate size.
184
- *
185
- * @example
186
- * ```typescript
187
- * import { globalHashCache, sha1 } from './utils/hash'
188
- *
189
- * // Use the global cache
190
- * const hash = await globalHashCache.getOrCompute(data, () => sha1(data))
191
- *
192
- * // Check cache stats
193
- * console.log(globalHashCache.getStats())
194
- * ```
195
- */
196
- export declare const globalHashCache: HashCache;
197
- //# sourceMappingURL=hash.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hash.d.ts","sourceRoot":"","sources":["../../src/utils/hash.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAKhF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAsB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAOhF;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,KAAK,CAAqB;IAClC,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,IAAI,CAAY;IACxB,OAAO,CAAC,MAAM,CAAY;IAE1B;;;;OAIG;gBACS,OAAO,GAAE,MAAc;IAKnC;;;;;;;;;OASG;IACH,OAAO,CAAC,WAAW;IAQnB;;;;;OAKG;IACH,GAAG,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS;IAgBzC;;;;;O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