mcp4openapi 0.2.8 → 0.3.1

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 (358) hide show
  1. package/README.md +143 -63
  2. package/dist/scripts/validate-profile.js +3 -3
  3. package/dist/scripts/validate-profile.js.map +1 -1
  4. package/dist/src/argument-normalizer.d.ts +5 -0
  5. package/dist/src/argument-normalizer.d.ts.map +1 -0
  6. package/dist/src/argument-normalizer.js +61 -0
  7. package/dist/src/argument-normalizer.js.map +1 -0
  8. package/dist/src/auth/oauth-provider.d.ts +131 -0
  9. package/dist/src/auth/oauth-provider.d.ts.map +1 -0
  10. package/dist/src/auth/oauth-provider.js +839 -0
  11. package/dist/src/auth/oauth-provider.js.map +1 -0
  12. package/dist/src/cli-config.d.ts +9 -0
  13. package/dist/src/cli-config.d.ts.map +1 -0
  14. package/dist/src/cli-config.js +111 -0
  15. package/dist/src/cli-config.js.map +1 -0
  16. package/dist/src/core/cli-config.d.ts +9 -0
  17. package/dist/src/core/cli-config.d.ts.map +1 -0
  18. package/dist/src/core/cli-config.js +125 -0
  19. package/dist/src/core/cli-config.js.map +1 -0
  20. package/dist/src/core/constants.d.ts +86 -0
  21. package/dist/src/core/constants.d.ts.map +1 -0
  22. package/dist/src/core/constants.js +86 -0
  23. package/dist/src/core/constants.js.map +1 -0
  24. package/dist/src/core/errors.d.ts +59 -0
  25. package/dist/src/core/errors.d.ts.map +1 -0
  26. package/dist/src/core/errors.js +119 -0
  27. package/dist/src/core/errors.js.map +1 -0
  28. package/dist/src/core/filtering.d.ts +19 -0
  29. package/dist/src/core/filtering.d.ts.map +1 -0
  30. package/dist/src/core/filtering.js +292 -0
  31. package/dist/src/core/filtering.js.map +1 -0
  32. package/dist/src/core/index.d.ts +26 -0
  33. package/dist/src/core/index.d.ts.map +1 -0
  34. package/dist/src/core/index.js +276 -0
  35. package/dist/src/core/index.js.map +1 -0
  36. package/dist/src/core/lib.d.ts +8 -0
  37. package/dist/src/core/lib.d.ts.map +1 -0
  38. package/dist/src/core/lib.js +7 -0
  39. package/dist/src/core/lib.js.map +1 -0
  40. package/dist/src/core/logger.d.ts +59 -0
  41. package/dist/src/core/logger.d.ts.map +1 -0
  42. package/dist/src/core/logger.js +197 -0
  43. package/dist/src/core/logger.js.map +1 -0
  44. package/dist/src/core/metrics.d.ts +97 -0
  45. package/dist/src/core/metrics.d.ts.map +1 -0
  46. package/dist/src/core/metrics.js +273 -0
  47. package/dist/src/core/metrics.js.map +1 -0
  48. package/dist/src/core/naming-warnings.d.ts +23 -0
  49. package/dist/src/core/naming-warnings.d.ts.map +1 -0
  50. package/dist/src/core/naming-warnings.js +83 -0
  51. package/dist/src/core/naming-warnings.js.map +1 -0
  52. package/dist/src/core/naming.d.ts +58 -0
  53. package/dist/src/core/naming.d.ts.map +1 -0
  54. package/dist/src/core/naming.js +510 -0
  55. package/dist/src/core/naming.js.map +1 -0
  56. package/dist/src/errors.d.ts +6 -0
  57. package/dist/src/errors.d.ts.map +1 -1
  58. package/dist/src/errors.js +15 -6
  59. package/dist/src/errors.js.map +1 -1
  60. package/dist/src/filtering.d.ts +19 -0
  61. package/dist/src/filtering.d.ts.map +1 -0
  62. package/dist/src/filtering.js +292 -0
  63. package/dist/src/filtering.js.map +1 -0
  64. package/dist/src/generated-schemas.d.ts +290 -79
  65. package/dist/src/generated-schemas.d.ts.map +1 -1
  66. package/dist/src/generated-schemas.js +17 -2
  67. package/dist/src/generated-schemas.js.map +1 -1
  68. package/dist/src/http-transport-config.d.ts +6 -0
  69. package/dist/src/http-transport-config.d.ts.map +1 -0
  70. package/dist/src/http-transport-config.js +47 -0
  71. package/dist/src/http-transport-config.js.map +1 -0
  72. package/dist/src/http-transport.d.ts +63 -13
  73. package/dist/src/http-transport.d.ts.map +1 -1
  74. package/dist/src/http-transport.js +1045 -482
  75. package/dist/src/http-transport.js.map +1 -1
  76. package/dist/src/index.d.ts +1 -6
  77. package/dist/src/index.d.ts.map +1 -1
  78. package/dist/src/index.js +1 -170
  79. package/dist/src/index.js.map +1 -1
  80. package/dist/src/interceptors.d.ts +1 -0
  81. package/dist/src/interceptors.d.ts.map +1 -1
  82. package/dist/src/interceptors.js +73 -63
  83. package/dist/src/interceptors.js.map +1 -1
  84. package/dist/src/lib.d.ts +1 -7
  85. package/dist/src/lib.d.ts.map +1 -1
  86. package/dist/src/lib.js +1 -6
  87. package/dist/src/lib.js.map +1 -1
  88. package/dist/src/logger.d.ts +5 -0
  89. package/dist/src/logger.d.ts.map +1 -1
  90. package/dist/src/logger.js +9 -1
  91. package/dist/src/logger.js.map +1 -1
  92. package/dist/src/mcp/mcp-server-manager.d.ts +20 -0
  93. package/dist/src/mcp/mcp-server-manager.d.ts.map +1 -0
  94. package/dist/src/mcp/mcp-server-manager.js +38 -0
  95. package/dist/src/mcp/mcp-server-manager.js.map +1 -0
  96. package/dist/src/mcp/mcp-server.d.ts +205 -0
  97. package/dist/src/mcp/mcp-server.d.ts.map +1 -0
  98. package/dist/src/mcp/mcp-server.js +1473 -0
  99. package/dist/src/mcp/mcp-server.js.map +1 -0
  100. package/dist/src/mcp-server-manager.d.ts +20 -0
  101. package/dist/src/mcp-server-manager.d.ts.map +1 -0
  102. package/dist/src/mcp-server-manager.js +38 -0
  103. package/dist/src/mcp-server-manager.js.map +1 -0
  104. package/dist/src/mcp-server.d.ts +28 -0
  105. package/dist/src/mcp-server.d.ts.map +1 -1
  106. package/dist/src/mcp-server.js +406 -109
  107. package/dist/src/mcp-server.js.map +1 -1
  108. package/dist/src/metrics.d.ts +11 -0
  109. package/dist/src/metrics.d.ts.map +1 -1
  110. package/dist/src/metrics.js +61 -0
  111. package/dist/src/metrics.js.map +1 -1
  112. package/dist/src/oauth-provider.d.ts +5 -0
  113. package/dist/src/oauth-provider.d.ts.map +1 -1
  114. package/dist/src/oauth-provider.js +29 -1
  115. package/dist/src/oauth-provider.js.map +1 -1
  116. package/dist/src/openapi/openapi-parser.d.ts +70 -0
  117. package/dist/src/openapi/openapi-parser.d.ts.map +1 -0
  118. package/dist/src/openapi/openapi-parser.js +458 -0
  119. package/dist/src/openapi/openapi-parser.js.map +1 -0
  120. package/dist/src/profile/profile-loader.d.ts +78 -0
  121. package/dist/src/profile/profile-loader.d.ts.map +1 -0
  122. package/dist/src/profile/profile-loader.js +490 -0
  123. package/dist/src/profile/profile-loader.js.map +1 -0
  124. package/dist/src/profile/profile-registry.d.ts +19 -0
  125. package/dist/src/profile/profile-registry.d.ts.map +1 -0
  126. package/dist/src/profile/profile-registry.js +43 -0
  127. package/dist/src/profile/profile-registry.js.map +1 -0
  128. package/dist/src/profile/profile-resolver.d.ts +41 -0
  129. package/dist/src/profile/profile-resolver.d.ts.map +1 -0
  130. package/dist/src/profile/profile-resolver.js +324 -0
  131. package/dist/src/profile/profile-resolver.js.map +1 -0
  132. package/dist/src/profile/startup-profile.d.ts +17 -0
  133. package/dist/src/profile/startup-profile.d.ts.map +1 -0
  134. package/dist/src/profile/startup-profile.js +30 -0
  135. package/dist/src/profile/startup-profile.js.map +1 -0
  136. package/dist/src/profile/startup-validation.d.ts +11 -0
  137. package/dist/src/profile/startup-validation.d.ts.map +1 -0
  138. package/dist/src/profile/startup-validation.js +21 -0
  139. package/dist/src/profile/startup-validation.js.map +1 -0
  140. package/dist/src/profile-loader.d.ts +1 -0
  141. package/dist/src/profile-loader.d.ts.map +1 -1
  142. package/dist/src/profile-loader.js +14 -3
  143. package/dist/src/profile-loader.js.map +1 -1
  144. package/dist/src/profile-registry.d.ts +18 -0
  145. package/dist/src/profile-registry.d.ts.map +1 -0
  146. package/dist/src/profile-registry.js +26 -0
  147. package/dist/src/profile-registry.js.map +1 -0
  148. package/dist/src/profile-resolver.d.ts +19 -0
  149. package/dist/src/profile-resolver.d.ts.map +1 -0
  150. package/dist/src/profile-resolver.js +167 -0
  151. package/dist/src/profile-resolver.js.map +1 -0
  152. package/dist/src/proxy-executor.d.ts.map +1 -1
  153. package/dist/src/proxy-executor.js +7 -0
  154. package/dist/src/proxy-executor.js.map +1 -1
  155. package/dist/src/startup-profile.d.ts +17 -0
  156. package/dist/src/startup-profile.d.ts.map +1 -0
  157. package/dist/src/startup-profile.js +30 -0
  158. package/dist/src/startup-profile.js.map +1 -0
  159. package/dist/src/startup-validation.d.ts +11 -0
  160. package/dist/src/startup-validation.d.ts.map +1 -0
  161. package/dist/src/startup-validation.js +21 -0
  162. package/dist/src/startup-validation.js.map +1 -0
  163. package/dist/src/testing/dynamic-mock-server.d.ts +24 -0
  164. package/dist/src/testing/dynamic-mock-server.d.ts.map +1 -0
  165. package/dist/src/testing/dynamic-mock-server.js +138 -0
  166. package/dist/src/testing/dynamic-mock-server.js.map +1 -0
  167. package/dist/src/testing/request-assertions.d.ts +5 -0
  168. package/dist/src/testing/request-assertions.d.ts.map +1 -0
  169. package/dist/src/testing/request-assertions.js +165 -0
  170. package/dist/src/testing/request-assertions.js.map +1 -0
  171. package/dist/src/testing/template-utils.d.ts +10 -0
  172. package/dist/src/testing/template-utils.d.ts.map +1 -0
  173. package/dist/src/testing/template-utils.js +72 -0
  174. package/dist/src/testing/template-utils.js.map +1 -0
  175. package/dist/src/testing/test-http-utils.d.ts +1 -1
  176. package/dist/src/testing/test-http-utils.d.ts.map +1 -1
  177. package/dist/src/testing/test-http-utils.js +1 -1
  178. package/dist/src/testing/test-http-utils.js.map +1 -1
  179. package/dist/src/testing/test-loader.d.ts +6 -0
  180. package/dist/src/testing/test-loader.d.ts.map +1 -0
  181. package/dist/src/testing/test-loader.js +212 -0
  182. package/dist/src/testing/test-loader.js.map +1 -0
  183. package/dist/src/testing/test-schema.d.ts +1270 -0
  184. package/dist/src/testing/test-schema.d.ts.map +1 -0
  185. package/dist/src/testing/test-schema.js +76 -0
  186. package/dist/src/testing/test-schema.js.map +1 -0
  187. package/dist/src/tool-filter/compat.d.ts +49 -0
  188. package/dist/src/tool-filter/compat.d.ts.map +1 -0
  189. package/dist/src/tool-filter/compat.js +72 -0
  190. package/dist/src/tool-filter/compat.js.map +1 -0
  191. package/dist/src/tool-filter/config/env-config-parser.d.ts +38 -0
  192. package/dist/src/tool-filter/config/env-config-parser.d.ts.map +1 -0
  193. package/dist/src/tool-filter/config/env-config-parser.js +103 -0
  194. package/dist/src/tool-filter/config/env-config-parser.js.map +1 -0
  195. package/dist/src/tool-filter/config/header-config-parser.d.ts +37 -0
  196. package/dist/src/tool-filter/config/header-config-parser.d.ts.map +1 -0
  197. package/dist/src/tool-filter/config/header-config-parser.js +118 -0
  198. package/dist/src/tool-filter/config/header-config-parser.js.map +1 -0
  199. package/dist/src/tool-filter/errors.d.ts +18 -0
  200. package/dist/src/tool-filter/errors.d.ts.map +1 -0
  201. package/dist/src/tool-filter/errors.js +21 -0
  202. package/dist/src/tool-filter/errors.js.map +1 -0
  203. package/dist/src/tool-filter/filter/filter-engine.d.ts +45 -0
  204. package/dist/src/tool-filter/filter/filter-engine.d.ts.map +1 -0
  205. package/dist/src/tool-filter/filter/filter-engine.js +94 -0
  206. package/dist/src/tool-filter/filter/filter-engine.js.map +1 -0
  207. package/dist/src/tool-filter/filter/filter-rules.d.ts +44 -0
  208. package/dist/src/tool-filter/filter/filter-rules.d.ts.map +1 -0
  209. package/dist/src/tool-filter/filter/filter-rules.js +72 -0
  210. package/dist/src/tool-filter/filter/filter-rules.js.map +1 -0
  211. package/dist/src/tool-filter/filter/global-tool-filter.d.ts +40 -0
  212. package/dist/src/tool-filter/filter/global-tool-filter.d.ts.map +1 -0
  213. package/dist/src/tool-filter/filter/global-tool-filter.js +92 -0
  214. package/dist/src/tool-filter/filter/global-tool-filter.js.map +1 -0
  215. package/dist/src/tool-filter/filter/session-tool-filter.d.ts +29 -0
  216. package/dist/src/tool-filter/filter/session-tool-filter.d.ts.map +1 -0
  217. package/dist/src/tool-filter/filter/session-tool-filter.js +69 -0
  218. package/dist/src/tool-filter/filter/session-tool-filter.js.map +1 -0
  219. package/dist/src/tool-filter/index.d.ts +25 -0
  220. package/dist/src/tool-filter/index.d.ts.map +1 -0
  221. package/dist/src/tool-filter/index.js +30 -0
  222. package/dist/src/tool-filter/index.js.map +1 -0
  223. package/dist/src/tool-filter/integration/tool-filter-service.d.ts +44 -0
  224. package/dist/src/tool-filter/integration/tool-filter-service.d.ts.map +1 -0
  225. package/dist/src/tool-filter/integration/tool-filter-service.js +68 -0
  226. package/dist/src/tool-filter/integration/tool-filter-service.js.map +1 -0
  227. package/dist/src/tool-filter/operation/operation-classifier.d.ts +20 -0
  228. package/dist/src/tool-filter/operation/operation-classifier.d.ts.map +1 -0
  229. package/dist/src/tool-filter/operation/operation-classifier.js +26 -0
  230. package/dist/src/tool-filter/operation/operation-classifier.js.map +1 -0
  231. package/dist/src/tool-filter/operation/operation-detector.d.ts +30 -0
  232. package/dist/src/tool-filter/operation/operation-detector.d.ts.map +1 -0
  233. package/dist/src/tool-filter/operation/operation-detector.js +96 -0
  234. package/dist/src/tool-filter/operation/operation-detector.js.map +1 -0
  235. package/dist/src/tool-filter/operation/operation-resolver.d.ts +22 -0
  236. package/dist/src/tool-filter/operation/operation-resolver.d.ts.map +1 -0
  237. package/dist/src/tool-filter/operation/operation-resolver.js +32 -0
  238. package/dist/src/tool-filter/operation/operation-resolver.js.map +1 -0
  239. package/dist/src/tool-filter/regex/regex-compiler.d.ts +22 -0
  240. package/dist/src/tool-filter/regex/regex-compiler.d.ts.map +1 -0
  241. package/dist/src/tool-filter/regex/regex-compiler.js +56 -0
  242. package/dist/src/tool-filter/regex/regex-compiler.js.map +1 -0
  243. package/dist/src/tool-filter/regex/regex-validator.d.ts +24 -0
  244. package/dist/src/tool-filter/regex/regex-validator.d.ts.map +1 -0
  245. package/dist/src/tool-filter/regex/regex-validator.js +58 -0
  246. package/dist/src/tool-filter/regex/regex-validator.js.map +1 -0
  247. package/dist/src/tool-filter/types.d.ts +92 -0
  248. package/dist/src/tool-filter/types.d.ts.map +1 -0
  249. package/dist/src/tool-filter/types.js +5 -0
  250. package/dist/src/tool-filter/types.js.map +1 -0
  251. package/dist/src/tool-filter/utils.d.ts +11 -0
  252. package/dist/src/tool-filter/utils.d.ts.map +1 -0
  253. package/dist/src/tool-filter/utils.js +13 -0
  254. package/dist/src/tool-filter/utils.js.map +1 -0
  255. package/dist/src/tool-filter.d.ts +65 -0
  256. package/dist/src/tool-filter.d.ts.map +1 -0
  257. package/dist/src/tool-filter.js +471 -0
  258. package/dist/src/tool-filter.js.map +1 -0
  259. package/dist/src/tool-generator.d.ts +1 -0
  260. package/dist/src/tool-generator.d.ts.map +1 -1
  261. package/dist/src/tool-generator.js +15 -6
  262. package/dist/src/tool-generator.js.map +1 -1
  263. package/dist/src/tooling/composite-executor.d.ts +77 -0
  264. package/dist/src/tooling/composite-executor.d.ts.map +1 -0
  265. package/dist/src/tooling/composite-executor.js +198 -0
  266. package/dist/src/tooling/composite-executor.js.map +1 -0
  267. package/dist/src/tooling/dag-executor.d.ts +49 -0
  268. package/dist/src/tooling/dag-executor.d.ts.map +1 -0
  269. package/dist/src/tooling/dag-executor.js +138 -0
  270. package/dist/src/tooling/dag-executor.js.map +1 -0
  271. package/dist/src/tooling/proxy-executor.d.ts +86 -0
  272. package/dist/src/tooling/proxy-executor.d.ts.map +1 -0
  273. package/dist/src/tooling/proxy-executor.js +501 -0
  274. package/dist/src/tooling/proxy-executor.js.map +1 -0
  275. package/dist/src/tooling/tool-generator.d.ts +67 -0
  276. package/dist/src/tooling/tool-generator.d.ts.map +1 -0
  277. package/dist/src/tooling/tool-generator.js +222 -0
  278. package/dist/src/tooling/tool-generator.js.map +1 -0
  279. package/dist/src/transport/http-client-factory.d.ts +65 -0
  280. package/dist/src/transport/http-client-factory.d.ts.map +1 -0
  281. package/dist/src/transport/http-client-factory.js +143 -0
  282. package/dist/src/transport/http-client-factory.js.map +1 -0
  283. package/dist/src/transport/http-transport-config.d.ts +6 -0
  284. package/dist/src/transport/http-transport-config.d.ts.map +1 -0
  285. package/dist/src/transport/http-transport-config.js +63 -0
  286. package/dist/src/transport/http-transport-config.js.map +1 -0
  287. package/dist/src/transport/http-transport.d.ts +329 -0
  288. package/dist/src/transport/http-transport.d.ts.map +1 -0
  289. package/dist/src/transport/http-transport.js +2584 -0
  290. package/dist/src/transport/http-transport.js.map +1 -0
  291. package/dist/src/transport/interceptors.d.ts +119 -0
  292. package/dist/src/transport/interceptors.d.ts.map +1 -0
  293. package/dist/src/transport/interceptors.js +413 -0
  294. package/dist/src/transport/interceptors.js.map +1 -0
  295. package/dist/src/transport/profile-index.d.ts +84 -0
  296. package/dist/src/transport/profile-index.d.ts.map +1 -0
  297. package/dist/src/transport/profile-index.js +405 -0
  298. package/dist/src/transport/profile-index.js.map +1 -0
  299. package/dist/src/types/http-transport.d.ts +26 -0
  300. package/dist/src/types/http-transport.d.ts.map +1 -1
  301. package/dist/src/types/openapi.d.ts +3 -0
  302. package/dist/src/types/openapi.d.ts.map +1 -1
  303. package/dist/src/types/profile.d.ts +16 -1
  304. package/dist/src/types/profile.d.ts.map +1 -1
  305. package/dist/src/validation/argument-normalizer.d.ts +6 -0
  306. package/dist/src/validation/argument-normalizer.d.ts.map +1 -0
  307. package/dist/src/validation/argument-normalizer.js +70 -0
  308. package/dist/src/validation/argument-normalizer.js.map +1 -0
  309. package/dist/src/validation/jsonrpc-validator.d.ts +27 -0
  310. package/dist/src/validation/jsonrpc-validator.d.ts.map +1 -0
  311. package/dist/src/validation/jsonrpc-validator.js +58 -0
  312. package/dist/src/validation/jsonrpc-validator.js.map +1 -0
  313. package/dist/src/validation/schema-validator.d.ts +30 -0
  314. package/dist/src/validation/schema-validator.d.ts.map +1 -0
  315. package/dist/src/validation/schema-validator.js +128 -0
  316. package/dist/src/validation/schema-validator.js.map +1 -0
  317. package/dist/src/validation/validation-utils.d.ts +49 -0
  318. package/dist/src/validation/validation-utils.d.ts.map +1 -0
  319. package/dist/src/validation/validation-utils.js +139 -0
  320. package/dist/src/validation/validation-utils.js.map +1 -0
  321. package/html/profile-index.html +386 -0
  322. package/package.json +10 -3
  323. package/profile-schema.json +77 -3
  324. package/profiles/gitlab/developer-profile-oauth.json +1520 -0
  325. package/profiles/gitlab/developer-profile-oauth.test.json +3432 -0
  326. package/profiles/gitlab/developer-profile.json +1508 -0
  327. package/profiles/gitlab/developer-profile.test.json +3432 -0
  328. package/profiles/gitlab/openapi.yaml +6891 -0
  329. package/profiles/n8n/openapi.yaml +2441 -0
  330. package/profiles/n8n/profile-optimized.json +965 -0
  331. package/profiles/n8n/profile-optimized.test.json +1078 -0
  332. package/profiles/n8n/profile.json +1033 -0
  333. package/profiles/n8n/profile.test.json +983 -0
  334. package/profiles/n8n-nodes/openapi.yaml +24 -0
  335. package/profiles/n8n-nodes/profile-nodes.json +44 -0
  336. package/profiles/n8n-nodes/profile-nodes.test.json +91 -0
  337. package/profiles/semgrep/openapi.yaml +4706 -0
  338. package/profiles/semgrep/profile.json +692 -0
  339. package/profiles/semgrep/profile.test.json +471 -0
  340. package/profiles/youtrack/openapi.json +16976 -0
  341. package/profiles/youtrack/profile.json +608 -0
  342. package/profiles/youtrack/profile.test.json +1926 -0
  343. package/dist/src/testing/fixtures.d.ts +0 -684
  344. package/dist/src/testing/fixtures.d.ts.map +0 -1
  345. package/dist/src/testing/fixtures.js +0 -528
  346. package/dist/src/testing/fixtures.js.map +0 -1
  347. package/dist/src/testing/mock-gitlab-server.d.ts +0 -43
  348. package/dist/src/testing/mock-gitlab-server.d.ts.map +0 -1
  349. package/dist/src/testing/mock-gitlab-server.js +0 -1026
  350. package/dist/src/testing/mock-gitlab-server.js.map +0 -1
  351. package/dist/src/testing/mock-semgrep-server.d.ts +0 -32
  352. package/dist/src/testing/mock-semgrep-server.d.ts.map +0 -1
  353. package/dist/src/testing/mock-semgrep-server.js +0 -213
  354. package/dist/src/testing/mock-semgrep-server.js.map +0 -1
  355. package/dist/src/testing/mock-youtrack-server.d.ts +0 -11
  356. package/dist/src/testing/mock-youtrack-server.d.ts.map +0 -1
  357. package/dist/src/testing/mock-youtrack-server.js +0 -152
  358. package/dist/src/testing/mock-youtrack-server.js.map +0 -1
@@ -0,0 +1,458 @@
1
+ /**
2
+ * OpenAPI specification parser and indexer
3
+ *
4
+ * Why indexing: Large OpenAPI specs (GitLab has ~200 operations) need fast lookup.
5
+ * Pre-indexing by operationId and path avoids linear search on every tool call.
6
+ */
7
+ import fs from 'fs/promises';
8
+ import { parse as parseYaml } from 'yaml';
9
+ import { ConfigurationError } from '../core/errors.js';
10
+ import { isSafePropertyName } from '../validation/validation-utils.js';
11
+ export class OpenAPIParser {
12
+ constructor() {
13
+ this.schemaCache = new Map();
14
+ }
15
+ async load(specPath) {
16
+ let content;
17
+ let contentType = null;
18
+ // Detect if specPath is a URL using URL parser
19
+ let isUrl = false;
20
+ try {
21
+ const url = new URL(specPath);
22
+ isUrl = url.protocol === 'http:' || url.protocol === 'https:';
23
+ }
24
+ catch {
25
+ // Not a valid URL, treat as file path
26
+ isUrl = false;
27
+ }
28
+ if (isUrl) {
29
+ // Load from HTTP/HTTPS URL
30
+ try {
31
+ const response = await fetch(specPath, {
32
+ signal: AbortSignal.timeout(30000), // 30 second timeout
33
+ headers: {
34
+ 'Accept': 'application/json, application/yaml, text/yaml, application/x-yaml, */*',
35
+ },
36
+ });
37
+ if (!response.ok) {
38
+ throw new ConfigurationError(`Failed to load OpenAPI spec from URL: ${specPath}. HTTP ${response.status}: ${response.statusText}`);
39
+ }
40
+ content = await response.text();
41
+ contentType = response.headers.get('content-type');
42
+ }
43
+ catch (error) {
44
+ if (error instanceof Error) {
45
+ if (error.name === 'AbortError' || error.name === 'TimeoutError') {
46
+ throw new ConfigurationError(`Timeout while loading OpenAPI spec from URL: ${specPath}. Request exceeded 30 seconds.`);
47
+ }
48
+ if (error instanceof ConfigurationError) {
49
+ throw error;
50
+ }
51
+ throw new ConfigurationError(`Failed to load OpenAPI spec from URL: ${specPath}. ${error.message}`);
52
+ }
53
+ throw error;
54
+ }
55
+ }
56
+ else {
57
+ // Load from local file
58
+ content = await fs.readFile(specPath, 'utf-8');
59
+ }
60
+ // Determine format: Content-Type > URL extension > JSON/YAML fallback
61
+ const isYaml = this.detectYamlFormat(specPath, contentType, content);
62
+ if (isYaml) {
63
+ this.spec = parseYaml(content);
64
+ }
65
+ else {
66
+ this.spec = JSON.parse(content);
67
+ }
68
+ this.schemaCache.clear();
69
+ this.buildIndex();
70
+ }
71
+ /**
72
+ * Detect if content is YAML format
73
+ * Priority: Content-Type header > URL extension > JSON/YAML fallback
74
+ */
75
+ detectYamlFormat(specPath, contentType, content) {
76
+ // 1. Check Content-Type header (for HTTP requests)
77
+ if (contentType) {
78
+ const normalizedContentType = contentType.toLowerCase().split(';')[0].trim();
79
+ if (normalizedContentType === 'application/yaml' ||
80
+ normalizedContentType === 'text/yaml' ||
81
+ normalizedContentType === 'application/x-yaml' ||
82
+ normalizedContentType === 'text/x-yaml') {
83
+ return true;
84
+ }
85
+ if (normalizedContentType === 'application/json') {
86
+ return false;
87
+ }
88
+ }
89
+ // 2. Check URL extension
90
+ if (specPath.endsWith('.yaml') || specPath.endsWith('.yml')) {
91
+ return true;
92
+ }
93
+ if (specPath.endsWith('.json')) {
94
+ return false;
95
+ }
96
+ // 3. Fallback: Try to parse as JSON, if it fails, assume YAML
97
+ try {
98
+ JSON.parse(content);
99
+ return false; // Valid JSON
100
+ }
101
+ catch {
102
+ return true; // Not valid JSON, assume YAML
103
+ }
104
+ }
105
+ /**
106
+ * Build search index from OpenAPI spec
107
+ *
108
+ * Why upfront: Trading startup time for runtime performance. Index creation
109
+ * happens once; lookups happen on every tool call.
110
+ */
111
+ buildIndex() {
112
+ if (!this.spec)
113
+ throw new ConfigurationError('OpenAPI spec not loaded. Call loadSpec() first.');
114
+ this.schemaCache.clear();
115
+ const operations = new Map();
116
+ const paths = new Map();
117
+ for (const [path, pathItem] of Object.entries(this.spec.paths || {})) {
118
+ if (!pathItem)
119
+ continue;
120
+ const pathOperations = {};
121
+ for (const method of ['get', 'post', 'put', 'patch', 'delete', 'head', 'options']) {
122
+ const operation = pathItem[method];
123
+ if (!operation)
124
+ continue;
125
+ const operationInfo = this.extractOperationInfo(path, method, operation);
126
+ if (operationInfo.operationId) {
127
+ operations.set(operationInfo.operationId, operationInfo);
128
+ }
129
+ pathOperations[method] = operationInfo;
130
+ }
131
+ paths.set(path, { path, operations: pathOperations });
132
+ }
133
+ this.index = {
134
+ spec: this.spec,
135
+ operations,
136
+ paths,
137
+ };
138
+ }
139
+ extractOperationInfo(path, method, operation) {
140
+ return {
141
+ operationId: operation.operationId || `${method}_${path}`,
142
+ method: method.toUpperCase(),
143
+ path,
144
+ summary: operation.summary,
145
+ description: operation.description,
146
+ parameters: this.extractParameters(operation),
147
+ requestBody: this.extractRequestBody(operation),
148
+ tags: operation.tags,
149
+ };
150
+ }
151
+ extractParameters(operation) {
152
+ if (!operation.parameters)
153
+ return [];
154
+ return operation.parameters
155
+ .map(p => {
156
+ // Resolve $ref to parameter definition
157
+ if ('$ref' in p) {
158
+ return this.resolveParameter(p.$ref);
159
+ }
160
+ return p;
161
+ })
162
+ .filter((p) => p !== null)
163
+ .map(param => ({
164
+ name: param.name,
165
+ in: param.in,
166
+ required: param.required ?? false,
167
+ schema: this.extractSchema(param.schema),
168
+ description: param.description,
169
+ }));
170
+ }
171
+ /**
172
+ * Resolve $ref to parameter definition
173
+ *
174
+ * Why: GitLab spec uses shared parameter definitions (e.g., ProjectIdOrPath).
175
+ * Need to resolve these refs to get actual parameter details.
176
+ */
177
+ resolveParameter(ref) {
178
+ if (!this.spec)
179
+ return null;
180
+ // Extract ref path: #/components/parameters/ProjectIdOrPath => ProjectIdOrPath
181
+ const refName = ref.split('/').pop();
182
+ if (!refName)
183
+ return null;
184
+ const param = this.spec.components?.parameters?.[refName];
185
+ if (!param || '$ref' in param)
186
+ return null;
187
+ return param;
188
+ }
189
+ extractRequestBody(operation) {
190
+ if (!operation.requestBody || '$ref' in operation.requestBody)
191
+ return undefined;
192
+ const body = operation.requestBody;
193
+ const content = {};
194
+ for (const [mediaType, mediaTypeObj] of Object.entries(body.content || {})) {
195
+ if (mediaTypeObj.schema) {
196
+ content[mediaType] = {
197
+ schema: this.extractSchema(mediaTypeObj.schema),
198
+ };
199
+ }
200
+ }
201
+ return {
202
+ required: body.required ?? false,
203
+ content,
204
+ };
205
+ }
206
+ extractSchema(schema, visited = new Set()) {
207
+ if (!schema)
208
+ return {};
209
+ if ('$ref' in schema) {
210
+ const resolved = this.resolveSchema(schema.$ref, visited);
211
+ return resolved ?? { ref: schema.$ref };
212
+ }
213
+ const result = {
214
+ type: schema.type,
215
+ format: schema.format,
216
+ enum: schema.enum,
217
+ default: schema.default,
218
+ minLength: schema.minLength,
219
+ maxLength: schema.maxLength,
220
+ pattern: schema.pattern,
221
+ };
222
+ if (schema.allOf && schema.allOf.length > 0) {
223
+ result.allOf = schema.allOf.map(subSchema => this.extractSchema(subSchema, new Set(visited)));
224
+ for (const sub of result.allOf) {
225
+ this.mergeSchemaInfo(result, sub);
226
+ }
227
+ }
228
+ if (schema.anyOf && schema.anyOf.length > 0) {
229
+ result.anyOf = schema.anyOf.map(subSchema => this.extractSchema(subSchema, new Set(visited)));
230
+ for (const sub of result.anyOf) {
231
+ this.mergeSchemaInfo(result, sub);
232
+ }
233
+ }
234
+ if (schema.oneOf && schema.oneOf.length > 0) {
235
+ result.oneOf = schema.oneOf.map(subSchema => this.extractSchema(subSchema, new Set(visited)));
236
+ for (const sub of result.oneOf) {
237
+ this.mergeSchemaInfo(result, sub);
238
+ }
239
+ }
240
+ if (schema.type === 'array' && schema.items) {
241
+ result.items = this.extractSchema(schema.items, new Set(visited));
242
+ }
243
+ if (schema.type === 'object' && schema.properties) {
244
+ result.properties = {};
245
+ for (const [key, propSchema] of Object.entries(schema.properties)) {
246
+ result.properties[key] = this.extractSchema(propSchema, new Set(visited));
247
+ }
248
+ result.required = schema.required;
249
+ }
250
+ return result;
251
+ }
252
+ resolveSchema(ref, visited = new Set()) {
253
+ if (!this.spec)
254
+ return undefined;
255
+ const refPath = ref.replace(/^#\//, '');
256
+ if (visited.has(refPath)) {
257
+ return { ref, circular: true };
258
+ }
259
+ const cached = this.schemaCache.get(refPath);
260
+ if (cached) {
261
+ return this.cloneSchemaInfo(cached);
262
+ }
263
+ const segments = refPath.split('/');
264
+ let current = this.spec;
265
+ for (const segment of segments) {
266
+ if (typeof current !== 'object' || current === null) {
267
+ current = undefined;
268
+ break;
269
+ }
270
+ // Prevent prototype pollution via malicious $ref paths
271
+ if (!isSafePropertyName(segment)) {
272
+ current = undefined;
273
+ break;
274
+ }
275
+ // nosemgrep: javascript.lang.security.audit.prototype-pollution.prototype-pollution-loop.prototype-pollution-loop
276
+ current = current[segment];
277
+ }
278
+ if (!current)
279
+ return undefined;
280
+ visited.add(refPath);
281
+ let resolved;
282
+ if (typeof current === 'object' && current !== null && '$ref' in current) {
283
+ resolved = this.resolveSchema(current.$ref, new Set(visited));
284
+ }
285
+ else {
286
+ resolved = this.extractSchema(current, new Set(visited));
287
+ }
288
+ visited.delete(refPath);
289
+ if (!resolved)
290
+ return undefined;
291
+ const canonical = this.cloneSchemaInfo({ ...resolved, ref });
292
+ this.schemaCache.set(refPath, canonical);
293
+ return this.cloneSchemaInfo(canonical);
294
+ }
295
+ mergeSchemaInfo(target, source) {
296
+ if (!target.type && source.type)
297
+ target.type = source.type;
298
+ if (!target.format && source.format)
299
+ target.format = source.format;
300
+ if (!target.enum && source.enum)
301
+ target.enum = source.enum;
302
+ if (target.default === undefined && source.default !== undefined)
303
+ target.default = source.default;
304
+ // Merge constraints strictly (strictest applies)
305
+ if (source.minLength !== undefined) {
306
+ target.minLength = Math.max(target.minLength ?? 0, source.minLength);
307
+ }
308
+ if (source.maxLength !== undefined) {
309
+ target.maxLength = Math.min(target.maxLength ?? Number.POSITIVE_INFINITY, source.maxLength);
310
+ }
311
+ if (source.pattern) {
312
+ if (!target.pattern) {
313
+ target.pattern = source.pattern;
314
+ }
315
+ else if (target.pattern !== source.pattern) {
316
+ // Combine patterns using lookaheads to enforce both anywhere in the string.
317
+ target.pattern = `^(?=[\\s\\S]*${target.pattern})(?=[\\s\\S]*${source.pattern})[\\s\\S]*$`;
318
+ }
319
+ }
320
+ if (source.required) {
321
+ target.required = Array.from(new Set([...(target.required ?? []), ...source.required]));
322
+ }
323
+ if (source.properties) {
324
+ target.properties = target.properties ?? {};
325
+ for (const [key, value] of Object.entries(source.properties)) {
326
+ if (target.properties[key]) {
327
+ if (target.properties[key] !== value) {
328
+ this.mergeSchemaInfo(target.properties[key], value);
329
+ }
330
+ }
331
+ else {
332
+ target.properties[key] = value;
333
+ }
334
+ }
335
+ }
336
+ if (source.items) {
337
+ target.items = target.items ?? source.items;
338
+ }
339
+ }
340
+ cloneSchemaInfo(schema) {
341
+ const cloned = {
342
+ type: schema.type,
343
+ format: schema.format,
344
+ enum: schema.enum ? [...schema.enum] : undefined,
345
+ default: schema.default,
346
+ minLength: schema.minLength,
347
+ maxLength: schema.maxLength,
348
+ pattern: schema.pattern,
349
+ ref: schema.ref,
350
+ circular: schema.circular,
351
+ };
352
+ if (schema.required) {
353
+ cloned.required = [...schema.required];
354
+ }
355
+ if (schema.items) {
356
+ cloned.items = this.cloneSchemaInfo(schema.items);
357
+ }
358
+ if (schema.properties) {
359
+ cloned.properties = {};
360
+ for (const [key, value] of Object.entries(schema.properties)) {
361
+ cloned.properties[key] = this.cloneSchemaInfo(value);
362
+ }
363
+ }
364
+ if (schema.allOf) {
365
+ cloned.allOf = schema.allOf.map(member => this.cloneSchemaInfo(member));
366
+ }
367
+ if (schema.anyOf) {
368
+ cloned.anyOf = schema.anyOf.map(member => this.cloneSchemaInfo(member));
369
+ }
370
+ if (schema.oneOf) {
371
+ cloned.oneOf = schema.oneOf.map(member => this.cloneSchemaInfo(member));
372
+ }
373
+ return cloned;
374
+ }
375
+ getOperation(operationId) {
376
+ return this.index?.operations.get(operationId);
377
+ }
378
+ getPath(path) {
379
+ return this.index?.paths.get(path);
380
+ }
381
+ getBaseUrl() {
382
+ const servers = this.spec?.servers;
383
+ return servers?.[0]?.url || '';
384
+ }
385
+ /**
386
+ * Get resource metadata from OpenAPI spec
387
+ *
388
+ * Why: Used for OAuth 2.0 Protected Resource Metadata (RFC 8707)
389
+ * to provide human-readable name and documentation URL for the API.
390
+ *
391
+ * Returns undefined for fields not present in spec.
392
+ */
393
+ getResourceMetadata() {
394
+ return {
395
+ name: this.spec?.info?.title,
396
+ documentation: this.spec?.externalDocs?.url
397
+ };
398
+ }
399
+ getAllOperations() {
400
+ return Array.from(this.index?.operations.values() || []);
401
+ }
402
+ /**
403
+ * Get first security scheme from OpenAPI spec
404
+ *
405
+ * Why: When no profile is provided, we need to infer auth configuration from OpenAPI spec.
406
+ * Returns the first security scheme defined in spec.security or components.securitySchemes.
407
+ *
408
+ * Returns undefined if no security is defined (public API).
409
+ */
410
+ getSecurityScheme() {
411
+ if (!this.spec)
412
+ return undefined;
413
+ // Check if security is required at spec level
414
+ const globalSecurity = this.spec.security;
415
+ if (!globalSecurity || globalSecurity.length === 0) {
416
+ return undefined; // No security required
417
+ }
418
+ // Get first security requirement
419
+ const firstSecurityReq = globalSecurity[0];
420
+ const securitySchemeName = Object.keys(firstSecurityReq)[0];
421
+ if (!securitySchemeName)
422
+ return undefined;
423
+ // Resolve security scheme definition
424
+ const securitySchemes = this.spec.components?.securitySchemes;
425
+ if (!securitySchemes)
426
+ return undefined;
427
+ const scheme = securitySchemes[securitySchemeName];
428
+ if (!scheme || '$ref' in scheme)
429
+ return undefined;
430
+ // Map OpenAPI security scheme to our auth config format
431
+ const schemeObj = scheme;
432
+ switch (schemeObj.type) {
433
+ case 'http':
434
+ // http: bearer, basic, etc.
435
+ return {
436
+ type: schemeObj.scheme || 'bearer',
437
+ scheme: schemeObj.scheme,
438
+ };
439
+ case 'apiKey':
440
+ // apiKey: in header, query, or cookie
441
+ return {
442
+ type: 'apiKey',
443
+ name: schemeObj.name,
444
+ in: schemeObj.in,
445
+ };
446
+ case 'oauth2':
447
+ case 'openIdConnect':
448
+ // OAuth2/OIDC typically use bearer tokens
449
+ return {
450
+ type: 'bearer',
451
+ scheme: 'bearer',
452
+ };
453
+ default:
454
+ return undefined;
455
+ }
456
+ }
457
+ }
458
+ //# sourceMappingURL=openapi-parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openapi-parser.js","sourceRoot":"","sources":["../../../src/openapi/openapi-parser.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,MAAM,CAAC;AAE1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AAGvE,MAAM,OAAO,aAAa;IAA1B;QAGU,gBAAW,GAAG,IAAI,GAAG,EAAsB,CAAC;IA4ftD,CAAC;IA1fC,KAAK,CAAC,IAAI,CAAC,QAAgB;QACzB,IAAI,OAAe,CAAC;QACpB,IAAI,WAAW,GAAkB,IAAI,CAAC;QAEtC,+CAA+C;QAC/C,IAAI,KAAK,GAAG,KAAK,CAAC;QAClB,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;YAC9B,KAAK,GAAG,GAAG,CAAC,QAAQ,KAAK,OAAO,IAAI,GAAG,CAAC,QAAQ,KAAK,QAAQ,CAAC;QAChE,CAAC;QAAC,MAAM,CAAC;YACP,sCAAsC;YACtC,KAAK,GAAG,KAAK,CAAC;QAChB,CAAC;QAED,IAAI,KAAK,EAAE,CAAC;YACV,2BAA2B;YAC3B,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,QAAQ,EAAE;oBACrC,MAAM,EAAE,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,oBAAoB;oBACxD,OAAO,EAAE;wBACP,QAAQ,EAAE,wEAAwE;qBACnF;iBACF,CAAC,CAAC;gBAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;oBACjB,MAAM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78 @@
1
+ /**
2
+ * Profile configuration loader and validator
3
+ *
4
+ * Why validation: Profile config comes from user files. Invalid config would
5
+ * cause runtime errors. Validate upfront with clear error messages.
6
+ *
7
+ * ✅ Schemas are now auto-generated from TypeScript types!
8
+ * When adding fields to src/types/profile.ts:
9
+ * 1. Update TypeScript interface (compile-time checking)
10
+ * 2. Run `npm run generate-schemas` (auto-generates JSON + Zod schemas)
11
+ * 3. That's it! No manual sync needed.
12
+ *
13
+ * See IMPLEMENTATION.md for details.
14
+ */
15
+ import type { Profile } from '../types/profile.js';
16
+ import type { OpenAPIParser } from '../openapi/openapi-parser.js';
17
+ export declare class ProfileLoader {
18
+ load(profilePath: string): Promise<Profile>;
19
+ /**
20
+ * Validate semantic rules beyond schema
21
+ *
22
+ * Why separate: Some rules can't be expressed in JSON Schema (e.g.,
23
+ * "if composite=true then steps must exist"). Fail fast with clear messages.
24
+ */
25
+ private validateLogic;
26
+ /**
27
+ * Generate helpful suggestions for invalid operation keys
28
+ */
29
+ private generateOperationKeySuggestions;
30
+ /**
31
+ * Validate composite steps form a DAG (no circular dependencies)
32
+ *
33
+ * Why: Circular dependencies would cause infinite loops or deadlocks.
34
+ * We use DFS with color-coding to detect cycles.
35
+ */
36
+ private validateCompositeStepsDAG;
37
+ /**
38
+ * Create a default profile with auto-generated tools from OpenAPI spec
39
+ *
40
+ * Why: Allows running server without profile for quick exploration.
41
+ * Generates simple pass-through tools for all operations.
42
+ *
43
+ * Auth Strategy:
44
+ * 1. Parse security scheme from OpenAPI spec
45
+ * 2. If found, generate auth interceptor
46
+ * 3. Fallback to bearer token from MCP4_API_TOKEN env var
47
+ */
48
+ static createDefaultProfile(profileName: string, parser: OpenAPIParser): Profile;
49
+ /**
50
+ * Generate auth interceptor from OpenAPI security scheme
51
+ *
52
+ * Strategy:
53
+ * 1. Parse security scheme from OpenAPI spec
54
+ * 2. If not found, check for force auth override via env vars
55
+ * 3. Map to profile auth interceptor format
56
+ * 4. Use env var name from AUTH_ENV_VAR or default to MCP4_API_TOKEN
57
+ *
58
+ * Returns empty object if no security scheme found (public API) and no force override
59
+ */
60
+ private static generateAuthInterceptor;
61
+ /**
62
+ * Generate a simple tool from an OpenAPI operation
63
+ *
64
+ * Creates a tool with parameters based on the operation's path/query/header parameters
65
+ * and request body. Uses operationId as tool name and summary/description for tool description.
66
+ */
67
+ private static generateToolFromOperation;
68
+ /**
69
+ * Map OpenAPI schema to parameter type
70
+ */
71
+ private static mapOpenAPISchemaToParameterType;
72
+ /**
73
+ * Recursively flatten schema properties to parameters
74
+ */
75
+ private static flattenSchemaToParameters;
76
+ private static normalizeToolNames;
77
+ }
78
+ //# sourceMappingURL=profile-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile-loader.d.ts","sourceRoot":"","sources":["../../../src/profile/profile-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAiB,MAAM,qBAAqB,CAAC;AAIlE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AA2BlE,qBAAa,aAAa;IAClB,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAajD;;;;;OAKG;IACH,OAAO,CAAC,aAAa;IAqJrB;;OAEG;IACH,OAAO,CAAC,+BAA+B;IAsCvC;;;;;OAKG;IACH,OAAO,CAAC,yBAAyB;IAsEjC;;;;;;;;;;OAUG;IACH,MAAM,CAAC,oBAAoB,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,GAAG,OAAO;IAiDhF;;;;;;;;;;OAUG;IACH,OAAO,CAAC,MAAM,CAAC,uBAAuB;IAqHtC;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,yBAAyB;IAiExC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,+BAA+B;IAmB9C;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,yBAAyB;IAqBxC,OAAO,CAAC,MAAM,CAAC,kBAAkB;CAKlC"}