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,490 @@
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 fs from 'fs/promises';
16
+ import { ValidationError, ConfigurationError } from '../core/errors.js';
17
+ import { profileSchema, authInterceptorSchema } from '../generated-schemas.js';
18
+ import { shortenToolName, NamingStrategy, levenshteinDistance } from '../core/naming.js';
19
+ import { normalizeToolName } from '../tool-filter/utils.js';
20
+ // Schemas are now auto-generated from TypeScript types!
21
+ // See scripts/generate-schemas.js for details.
22
+ // Custom validations that can't be auto-generated
23
+ const enhancedAuthInterceptorSchema = authInterceptorSchema.refine((data) => {
24
+ if (data.type === 'query' && !data.query_param) {
25
+ return false;
26
+ }
27
+ if (data.type === 'custom-header' && !data.header_name) {
28
+ return false;
29
+ }
30
+ return true;
31
+ }, {
32
+ message: 'query type requires query_param, custom-header requires header_name',
33
+ });
34
+ // Use the basic profile schema - auth validation moved to validateLogic
35
+ const enhancedProfileSchema = profileSchema;
36
+ export class ProfileLoader {
37
+ async load(profilePath) {
38
+ const content = await fs.readFile(profilePath, 'utf-8');
39
+ const json = JSON.parse(content);
40
+ // Validate with Zod - throws detailed error if invalid
41
+ const profile = enhancedProfileSchema.parse(json);
42
+ ProfileLoader.normalizeToolNames(profile);
43
+ this.validateLogic(profile);
44
+ return profile;
45
+ }
46
+ /**
47
+ * Validate semantic rules beyond schema
48
+ *
49
+ * Why separate: Some rules can't be expressed in JSON Schema (e.g.,
50
+ * "if composite=true then steps must exist"). Fail fast with clear messages.
51
+ */
52
+ validateLogic(profile) {
53
+ // Validate auth interceptors
54
+ const auth = profile.interceptors?.auth;
55
+ if (auth) {
56
+ const validateAuthEntry = (entry, index) => {
57
+ const result = enhancedAuthInterceptorSchema.safeParse(entry);
58
+ if (!result.success) {
59
+ const path = index !== undefined ? `interceptors.auth[${index}]` : 'interceptors.auth';
60
+ throw new ValidationError(`Invalid auth interceptor at ${path}: ${result.error.issues.map(i => i.message).join(', ')}`, { path, issues: result.error.issues });
61
+ }
62
+ // Additional OAuth validation: must have issuer OR both endpoints
63
+ const authEntry = entry;
64
+ if (authEntry.type === 'oauth' && authEntry.oauth_config) {
65
+ const config = authEntry.oauth_config;
66
+ const hasIssuer = !!config.issuer;
67
+ const hasEndpoints = !!config.authorization_endpoint && !!config.token_endpoint;
68
+ if (!hasIssuer && !hasEndpoints) {
69
+ const path = index !== undefined ? `interceptors.auth[${index}].oauth_config` : 'interceptors.auth.oauth_config';
70
+ throw new ValidationError(`OAuth config at ${path} must provide either 'issuer' OR both 'authorization_endpoint' and 'token_endpoint'`, { path, hasIssuer, hasEndpoints });
71
+ }
72
+ }
73
+ };
74
+ if (Array.isArray(auth)) {
75
+ auth.forEach((entry, index) => validateAuthEntry(entry, index));
76
+ }
77
+ else {
78
+ validateAuthEntry(auth);
79
+ }
80
+ }
81
+ for (const tool of profile.tools) {
82
+ // Composite tools must have steps
83
+ if (tool.composite && (!tool.steps || tool.steps.length === 0)) {
84
+ throw new ValidationError(`Tool '${tool.name}' is marked as composite but has no steps`, { toolName: tool.name, composite: tool.composite });
85
+ }
86
+ // Non-composite tools must have operations
87
+ if (!tool.composite && !tool.operations) {
88
+ throw new ValidationError(`Tool '${tool.name}' must have either 'operations' or be marked as 'composite' with 'steps'`, { toolName: tool.name, composite: tool.composite });
89
+ }
90
+ // Validate required_for references existing enum values
91
+ for (const [paramName, paramDef] of Object.entries(tool.parameters)) {
92
+ const paramTypes = Array.isArray(paramDef.type) ? paramDef.type : [paramDef.type];
93
+ const hasType = (type) => paramTypes.includes(type);
94
+ // Validate array parameters have items
95
+ if (hasType('array') && !paramDef.items) {
96
+ throw new ValidationError(`Parameter '${paramName}' in tool '${tool.name}' is type 'array' but missing required 'items' property`, { toolName: tool.name, paramName, paramType: paramDef.type });
97
+ }
98
+ // Validate object parameters have properties
99
+ if (hasType('object') && paramDef.properties === undefined) {
100
+ throw new ValidationError(`Parameter '${paramName}' in tool '${tool.name}' is type 'object' but missing 'properties'. Use empty object {} for free-form objects.`, { toolName: tool.name, paramName, paramType: paramDef.type });
101
+ }
102
+ if (paramDef.required_for) {
103
+ const actionParam = tool.parameters['action'];
104
+ if (!actionParam?.enum) {
105
+ throw new ValidationError(`Parameter '${paramName}' in tool '${tool.name}' has 'required_for' but 'action' parameter has no enum`, { toolName: tool.name, paramName, hasActionParam: !!actionParam });
106
+ }
107
+ for (const action of paramDef.required_for) {
108
+ if (!actionParam.enum.includes(action)) {
109
+ throw new ValidationError(`Parameter '${paramName}' requires action '${action}' but it's not in action enum: ${actionParam.enum.join(', ')}`, { toolName: tool.name, paramName, requiredAction: action, availableActions: actionParam.enum });
110
+ }
111
+ }
112
+ }
113
+ }
114
+ // Validate operation keys match action enum or follow {action}_{resourceType} pattern
115
+ if (tool.operations && tool.parameters['action']?.enum) {
116
+ const actionEnum = tool.parameters['action'].enum;
117
+ const resourceTypeParam = tool.parameters['resource_type'];
118
+ const resourceTypeEnum = resourceTypeParam?.enum;
119
+ for (const operationKey of Object.keys(tool.operations)) {
120
+ // Check if operation key is directly in action enum
121
+ if (actionEnum.includes(operationKey)) {
122
+ continue;
123
+ }
124
+ // Check if operation key follows {action}_{resourceType} pattern
125
+ const parts = operationKey.split('_');
126
+ if (parts.length === 2) {
127
+ const [actionPart, resourceTypePart] = parts;
128
+ // Both parts must be valid
129
+ const actionValid = actionEnum.includes(actionPart);
130
+ const resourceTypeValid = resourceTypeEnum ? resourceTypeEnum.includes(resourceTypePart) : true;
131
+ if (actionValid && resourceTypeValid) {
132
+ continue;
133
+ }
134
+ }
135
+ // Generate helpful error message with suggestions
136
+ const suggestions = this.generateOperationKeySuggestions(operationKey, actionEnum, resourceTypeEnum);
137
+ const suggestionText = suggestions.length > 0
138
+ ? ` Did you mean one of: ${suggestions.join(', ')}?`
139
+ : '';
140
+ throw new ValidationError(`Invalid operation key '${operationKey}' in tool '${tool.name}'. ` +
141
+ `Must be an action from enum [${actionEnum.join(', ')}] or follow pattern {action}_{resourceType}.${suggestionText}`, {
142
+ toolName: tool.name,
143
+ operationKey,
144
+ availableActions: actionEnum,
145
+ availableResourceTypes: resourceTypeEnum,
146
+ suggestions
147
+ });
148
+ }
149
+ }
150
+ // Validate composite steps DAG (no circular dependencies)
151
+ if (tool.composite && tool.steps) {
152
+ this.validateCompositeStepsDAG(tool.name, tool.steps);
153
+ }
154
+ }
155
+ }
156
+ /**
157
+ * Generate helpful suggestions for invalid operation keys
158
+ */
159
+ generateOperationKeySuggestions(invalidKey, actionEnum, resourceTypeEnum) {
160
+ const suggestions = [];
161
+ // Direct action matches (case-insensitive)
162
+ for (const action of actionEnum) {
163
+ if (action.toLowerCase() === invalidKey.toLowerCase()) {
164
+ suggestions.push(action);
165
+ }
166
+ }
167
+ // Levenshtein distance suggestions for actions
168
+ const maxDistance = Math.min(2, invalidKey.length - 1);
169
+ for (const action of actionEnum) {
170
+ if (levenshteinDistance(invalidKey, action) <= maxDistance) {
171
+ suggestions.push(action);
172
+ }
173
+ }
174
+ // Check for {action}_{resourceType} patterns
175
+ if (resourceTypeEnum) {
176
+ for (const action of actionEnum) {
177
+ for (const resourceType of resourceTypeEnum) {
178
+ const compositeKey = `${action}_${resourceType}`;
179
+ if (levenshteinDistance(invalidKey, compositeKey) <= maxDistance) {
180
+ suggestions.push(compositeKey);
181
+ }
182
+ }
183
+ }
184
+ }
185
+ // Remove duplicates and return unique suggestions
186
+ return [...new Set(suggestions)];
187
+ }
188
+ /**
189
+ * Validate composite steps form a DAG (no circular dependencies)
190
+ *
191
+ * Why: Circular dependencies would cause infinite loops or deadlocks.
192
+ * We use DFS with color-coding to detect cycles.
193
+ */
194
+ validateCompositeStepsDAG(toolName, steps) {
195
+ // Build adjacency list: store_as -> list of steps that depend on it
196
+ const graph = new Map();
197
+ const allStoreAs = new Set();
198
+ // Initialize all nodes
199
+ for (const step of steps) {
200
+ allStoreAs.add(step.store_as);
201
+ if (!graph.has(step.store_as)) {
202
+ graph.set(step.store_as, []);
203
+ }
204
+ }
205
+ // Build dependency edges
206
+ for (const step of steps) {
207
+ if (step.depends_on) {
208
+ for (const dep of step.depends_on) {
209
+ // Validate dependency exists
210
+ if (!allStoreAs.has(dep)) {
211
+ throw new ValidationError(`Composite step '${step.store_as}' in tool '${toolName}' depends on '${dep}' but no step produces '${dep}'`, { toolName, stepStoreAs: step.store_as, dependency: dep, availableStoreAs: Array.from(allStoreAs) });
212
+ }
213
+ // Add edge: dep -> step.store_as (dep must complete before step)
214
+ if (!graph.has(dep)) {
215
+ graph.set(dep, []);
216
+ }
217
+ graph.get(dep).push(step.store_as);
218
+ }
219
+ }
220
+ }
221
+ // DFS cycle detection with color-coding
222
+ const visited = new Set(); // Fully processed nodes
223
+ const visiting = new Set(); // Currently being processed (in recursion stack)
224
+ const dfs = (node) => {
225
+ if (visiting.has(node)) {
226
+ throw new ValidationError(`Circular dependency detected in composite steps of tool '${toolName}': ${node} depends on itself`, { toolName, circularNode: node, visitingNodes: Array.from(visiting) });
227
+ }
228
+ if (visited.has(node)) {
229
+ return; // Already fully processed
230
+ }
231
+ visiting.add(node);
232
+ // Visit all neighbors
233
+ const neighbors = graph.get(node) || [];
234
+ for (const neighbor of neighbors) {
235
+ dfs(neighbor);
236
+ }
237
+ visiting.delete(node);
238
+ visited.add(node);
239
+ };
240
+ // Check all nodes for cycles
241
+ for (const node of allStoreAs) {
242
+ if (!visited.has(node)) {
243
+ dfs(node);
244
+ }
245
+ }
246
+ }
247
+ /**
248
+ * Create a default profile with auto-generated tools from OpenAPI spec
249
+ *
250
+ * Why: Allows running server without profile for quick exploration.
251
+ * Generates simple pass-through tools for all operations.
252
+ *
253
+ * Auth Strategy:
254
+ * 1. Parse security scheme from OpenAPI spec
255
+ * 2. If found, generate auth interceptor
256
+ * 3. Fallback to bearer token from MCP4_API_TOKEN env var
257
+ */
258
+ static createDefaultProfile(profileName, parser) {
259
+ const operations = parser.getAllOperations();
260
+ // Get configuration for name shortening
261
+ const maxLength = parseInt(process.env.MCP4_TOOLNAME_MAX || '45', 10);
262
+ const strategyStr = (process.env.MCP4_TOOLNAME_STRATEGY || 'none').toLowerCase();
263
+ const warnOnly = (process.env.MCP4_TOOLNAME_WARN_ONLY || 'true').toLowerCase() === 'true';
264
+ const minParts = parseInt(process.env.MCP4_TOOLNAME_MIN_PARTS || '3', 10);
265
+ const minLength = parseInt(process.env.MCP4_TOOLNAME_MIN_LENGTH || '20', 10);
266
+ const strategy = Object.values(NamingStrategy).includes(strategyStr)
267
+ ? strategyStr
268
+ : NamingStrategy.None;
269
+ const shouldShorten = strategy !== NamingStrategy.None && !warnOnly;
270
+ // Convert to OperationForNaming for shortening
271
+ const opsForNaming = operations.map(op => ({
272
+ operationId: op.operationId,
273
+ method: op.method,
274
+ path: op.path,
275
+ tags: op.tags,
276
+ }));
277
+ const tools = operations.map(op => this.generateToolFromOperation(op, shouldShorten ? strategy : NamingStrategy.None, maxLength, opsForNaming, { minParts, minLength }));
278
+ // Generate auth interceptor from OpenAPI security scheme
279
+ const interceptors = this.generateAuthInterceptor(parser);
280
+ const profile = {
281
+ profile_name: profileName,
282
+ description: `Auto-generated default profile with ${tools.length} tools from OpenAPI spec`,
283
+ tools,
284
+ interceptors,
285
+ };
286
+ this.normalizeToolNames(profile);
287
+ return profile;
288
+ }
289
+ /**
290
+ * Generate auth interceptor from OpenAPI security scheme
291
+ *
292
+ * Strategy:
293
+ * 1. Parse security scheme from OpenAPI spec
294
+ * 2. If not found, check for force auth override via env vars
295
+ * 3. Map to profile auth interceptor format
296
+ * 4. Use env var name from AUTH_ENV_VAR or default to MCP4_API_TOKEN
297
+ *
298
+ * Returns empty object if no security scheme found (public API) and no force override
299
+ */
300
+ static generateAuthInterceptor(parser) {
301
+ const securityScheme = parser.getSecurityScheme();
302
+ // Check for force auth override (for APIs with incomplete OpenAPI spec)
303
+ const forceAuth = process.env.MCP4_AUTH_FORCE === 'true';
304
+ if (!securityScheme && !forceAuth) {
305
+ return {}; // Public API, no auth required
306
+ }
307
+ // Get env var name from environment or use default
308
+ const envVarName = process.env.MCP4_AUTH_ENV_VAR || 'MCP4_API_TOKEN';
309
+ const interceptors = {};
310
+ // If force auth is enabled, use env config instead of OpenAPI spec
311
+ if (forceAuth && !securityScheme) {
312
+ const authType = (process.env.MCP4_AUTH_TYPE || 'bearer').toLowerCase();
313
+ switch (authType) {
314
+ case 'bearer':
315
+ interceptors.auth = {
316
+ type: 'bearer',
317
+ value_from_env: envVarName,
318
+ };
319
+ break;
320
+ case 'query':
321
+ const queryParam = process.env.MCP4_AUTH_QUERY_PARAM;
322
+ if (!queryParam) {
323
+ throw new ConfigurationError('MCP4_AUTH_QUERY_PARAM is required when MCP4_AUTH_TYPE=query', { authType });
324
+ }
325
+ interceptors.auth = {
326
+ type: 'query',
327
+ query_param: queryParam,
328
+ value_from_env: envVarName,
329
+ };
330
+ break;
331
+ case 'custom-header':
332
+ const headerName = process.env.MCP4_AUTH_HEADER_NAME;
333
+ if (!headerName) {
334
+ throw new ConfigurationError('MCP4_AUTH_HEADER_NAME is required when MCP4_AUTH_TYPE=custom-header', { authType });
335
+ }
336
+ interceptors.auth = {
337
+ type: 'custom-header',
338
+ header_name: headerName,
339
+ value_from_env: envVarName,
340
+ };
341
+ break;
342
+ default:
343
+ throw new ConfigurationError(`Invalid MCP4_AUTH_TYPE: ${authType}. Must be one of: bearer, query, custom-header`, { authType });
344
+ }
345
+ return interceptors;
346
+ }
347
+ // Use OpenAPI security scheme
348
+ if (!securityScheme) {
349
+ return {}; // Shouldn't happen, but TypeScript needs this
350
+ }
351
+ switch (securityScheme.type) {
352
+ case 'bearer':
353
+ // Bearer token in Authorization header
354
+ interceptors.auth = {
355
+ type: 'bearer',
356
+ value_from_env: envVarName,
357
+ };
358
+ break;
359
+ case 'apiKey':
360
+ // API key in header or query
361
+ if (securityScheme.in === 'query' && securityScheme.name) {
362
+ interceptors.auth = {
363
+ type: 'query',
364
+ query_param: securityScheme.name,
365
+ value_from_env: envVarName,
366
+ };
367
+ }
368
+ else if (securityScheme.in === 'header' && securityScheme.name) {
369
+ // Check if it's a standard Authorization header
370
+ if (securityScheme.name.toLowerCase() === 'authorization') {
371
+ interceptors.auth = {
372
+ type: 'bearer',
373
+ value_from_env: envVarName,
374
+ };
375
+ }
376
+ else {
377
+ interceptors.auth = {
378
+ type: 'custom-header',
379
+ header_name: securityScheme.name,
380
+ value_from_env: envVarName,
381
+ };
382
+ }
383
+ }
384
+ break;
385
+ default:
386
+ // Unknown security type, default to bearer
387
+ interceptors.auth = {
388
+ type: 'bearer',
389
+ value_from_env: envVarName,
390
+ };
391
+ }
392
+ return interceptors;
393
+ }
394
+ /**
395
+ * Generate a simple tool from an OpenAPI operation
396
+ *
397
+ * Creates a tool with parameters based on the operation's path/query/header parameters
398
+ * and request body. Uses operationId as tool name and summary/description for tool description.
399
+ */
400
+ static generateToolFromOperation(operation, strategy = NamingStrategy.None, maxLength = 45, allOperations = [], options) {
401
+ const parameters = {};
402
+ // Add path parameters
403
+ for (const param of operation.parameters) {
404
+ parameters[param.name] = {
405
+ type: this.mapOpenAPISchemaToParameterType(param.schema),
406
+ description: param.description || `Parameter ${param.name}`,
407
+ required: param.required,
408
+ minLength: param.schema.minLength,
409
+ maxLength: param.schema.maxLength,
410
+ pattern: param.schema.pattern,
411
+ };
412
+ }
413
+ // Add request body parameters if present
414
+ if (operation.requestBody?.content) {
415
+ // For simplicity, assume JSON content and flatten the schema
416
+ const jsonContent = operation.requestBody.content['application/json'];
417
+ if (jsonContent?.schema) {
418
+ this.flattenSchemaToParameters(jsonContent.schema, parameters, operation.requestBody.required);
419
+ }
420
+ }
421
+ // Warn if parameter inflation exceeds threshold
422
+ const paramCount = Object.keys(parameters).length;
423
+ if (paramCount > 60) {
424
+ // Using console.warn to avoid adding logger dependency here
425
+ console.warn(`[ProfileLoader] Generated tool has ${paramCount} parameters (>60). Operation: ${operation.operationId} ${operation.method.toUpperCase()} ${operation.path}`);
426
+ }
427
+ // Apply name shortening if strategy is specified
428
+ const opForNaming = {
429
+ operationId: operation.operationId,
430
+ method: operation.method,
431
+ path: operation.path,
432
+ tags: operation.tags,
433
+ };
434
+ const nameResult = shortenToolName(opForNaming, strategy, maxLength, allOperations.length > 0 ? allOperations : [opForNaming], options);
435
+ return {
436
+ name: nameResult.name,
437
+ description: operation.summary || operation.description || `Execute ${operation.method.toUpperCase()} ${operation.path}`,
438
+ operations: {
439
+ 'execute': operation.operationId,
440
+ },
441
+ parameters,
442
+ };
443
+ }
444
+ /**
445
+ * Map OpenAPI schema to parameter type
446
+ */
447
+ static mapOpenAPISchemaToParameterType(schema) {
448
+ switch (schema.type) {
449
+ case 'string':
450
+ return 'string';
451
+ case 'integer':
452
+ return 'integer';
453
+ case 'number':
454
+ return 'number';
455
+ case 'boolean':
456
+ return 'boolean';
457
+ case 'array':
458
+ return 'array';
459
+ case 'object':
460
+ return 'object';
461
+ default:
462
+ return 'string'; // fallback
463
+ }
464
+ }
465
+ /**
466
+ * Recursively flatten schema properties to parameters
467
+ */
468
+ static flattenSchemaToParameters(schema, parameters, required = false) {
469
+ if (schema.type === 'object' && schema.properties) {
470
+ for (const [propName, propSchema] of Object.entries(schema.properties)) {
471
+ const isRequired = schema.required?.includes(propName) || required;
472
+ const info = propSchema;
473
+ parameters[propName] = {
474
+ type: this.mapOpenAPISchemaToParameterType(info),
475
+ description: `Property ${propName}`,
476
+ required: isRequired,
477
+ minLength: info.minLength,
478
+ maxLength: info.maxLength,
479
+ pattern: info.pattern,
480
+ };
481
+ }
482
+ }
483
+ }
484
+ static normalizeToolNames(profile) {
485
+ for (const tool of profile.tools) {
486
+ tool.name = normalizeToolName(tool.name);
487
+ }
488
+ }
489
+ }
490
+ //# sourceMappingURL=profile-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile-loader.js","sourceRoot":"","sources":["../../../src/profile/profile-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,MAAM,aAAa,CAAC;AAE7B,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAExE,OAAO,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAG/E,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,mBAAmB,EAA+C,MAAM,mBAAmB,CAAC;AACtI,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D,wDAAwD;AACxD,+CAA+C;AAE/C,kDAAkD;AAClD,MAAM,6BAA6B,GAAG,qBAAqB,CAAC,MAAM,CAChE,CAAC,IAAI,EAAE,EAAE;IACP,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;QAC/C,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,IAAI,CAAC,IAAI,KAAK,eAAe,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;QACvD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,EACD;IACE,OAAO,EAAE,qEAAqE;CAC/E,CACF,CAAC;AAEF,wEAAwE;AACxE,MAAM,qBAAqB,GAAG,aAAa,CAAC;AAE5C,MAAM,OAAO,aAAa;IACxB,KAAK,CAAC,IAAI,CAAC,WAAmB;QAC5B,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;QACxD,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAEjC,uDAAuD;QACvD,MAAM,OAAO,GAAG,qBAAqB,CAAC,KAAK,CAAC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AEO,MAAM,CAAC,kBAAkB,CAAC,OAAgB;QAChD,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;YACjC,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC3C,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Profile registry for resolving profiles by ID or alias.
3
+ */
4
+ import { type ResolvedProfile, type ListedProfileDetails } from './profile-resolver.js';
5
+ export interface ProfileRegistryOptions {
6
+ profilesDir?: string;
7
+ defaultProfile?: ResolvedProfile;
8
+ specPathOverride?: string;
9
+ }
10
+ export declare class ProfileRegistry {
11
+ private profilesDir?;
12
+ private defaultProfile?;
13
+ private specPathOverride?;
14
+ constructor(options: ProfileRegistryOptions);
15
+ getDefaultProfile(): ResolvedProfile | undefined;
16
+ resolveProfile(profileId: string): Promise<ResolvedProfile>;
17
+ listProfilesForIndex(): Promise<ListedProfileDetails[]>;
18
+ }
19
+ //# sourceMappingURL=profile-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile-registry.d.ts","sourceRoot":"","sources":["../../../src/profile/profile-registry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAIL,KAAK,eAAe,EACpB,KAAK,oBAAoB,EAC1B,MAAM,uBAAuB,CAAC;AAE/B,MAAM,WAAW,sBAAsB;IACrC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,eAAe,CAAC;IACjC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,WAAW,CAAC,CAAS;IAC7B,OAAO,CAAC,cAAc,CAAC,CAAkB;IACzC,OAAO,CAAC,gBAAgB,CAAC,CAAS;gBAEtB,OAAO,EAAE,sBAAsB;IAM3C,iBAAiB,IAAI,eAAe,GAAG,SAAS;IAI1C,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC;IAa3D,oBAAoB,IAAI,OAAO,CAAC,oBAAoB,EAAE,CAAC;CAuB9D"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Profile registry for resolving profiles by ID or alias.
3
+ */
4
+ import { resolveProfileById, listProfilesDetailed, resolveProfileDetailsFromPath, } from './profile-resolver.js';
5
+ export class ProfileRegistry {
6
+ constructor(options) {
7
+ this.profilesDir = options.profilesDir;
8
+ this.defaultProfile = options.defaultProfile;
9
+ this.specPathOverride = options.specPathOverride;
10
+ }
11
+ getDefaultProfile() {
12
+ return this.defaultProfile;
13
+ }
14
+ async resolveProfile(profileId) {
15
+ if (this.defaultProfile) {
16
+ if (profileId === this.defaultProfile.profileId || profileId === this.defaultProfile.profileName) {
17
+ return this.defaultProfile;
18
+ }
19
+ if (this.defaultProfile.profileAliases?.includes(profileId)) {
20
+ return this.defaultProfile;
21
+ }
22
+ }
23
+ return resolveProfileById(profileId, this.profilesDir, { specPathOverride: this.specPathOverride });
24
+ }
25
+ async listProfilesForIndex() {
26
+ const profiles = await listProfilesDetailed(this.profilesDir);
27
+ if (!this.defaultProfile) {
28
+ return profiles;
29
+ }
30
+ const existing = profiles.find(profile => profile.profileId === this.defaultProfile.profileId ||
31
+ profile.profileName === this.defaultProfile.profileName ||
32
+ profile.profileAliases.includes(this.defaultProfile.profileId));
33
+ if (existing) {
34
+ return profiles;
35
+ }
36
+ const defaultDetails = await resolveProfileDetailsFromPath(this.defaultProfile.profilePath);
37
+ if (defaultDetails) {
38
+ return [defaultDetails, ...profiles];
39
+ }
40
+ return profiles;
41
+ }
42
+ }
43
+ //# sourceMappingURL=profile-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile-registry.js","sourceRoot":"","sources":["../../../src/profile/profile-registry.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,6BAA6B,GAG9B,MAAM,uBAAuB,CAAC;AAQ/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AC,cAAe,CAAC,SAAS,CAAC,CAChE,CAAC;QAEF,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,MAAM,cAAc,GAAG,MAAM,6BAA6B,CAAC,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QAC5F,IAAI,cAAc,EAAE,CAAC;YACnB,OAAO,CAAC,cAAc,EAAE,GAAG,QAAQ,CAAC,CAAC;QACvC,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Profile resolver
3
+ *
4
+ * Why: Allow selecting profiles by ID or alias without hardcoding paths.
5
+ */
6
+ export interface ResolvedProfile {
7
+ profileId: string;
8
+ profileName: string;
9
+ profileAliases?: string[];
10
+ profilePath: string;
11
+ specPath: string;
12
+ }
13
+ export interface ListedProfile {
14
+ profileId: string;
15
+ profileName: string;
16
+ profileAliases: string[];
17
+ }
18
+ export interface ListedProfileDetails {
19
+ profileId: string;
20
+ profileName: string;
21
+ profileAliases: string[];
22
+ description?: string;
23
+ envVars: string[];
24
+ authMethods: ProfileAuthMethod[];
25
+ }
26
+ export interface ProfileAuthMethod {
27
+ type: 'bearer' | 'query' | 'custom-header' | 'oauth';
28
+ headerName?: string;
29
+ queryParam?: string;
30
+ valueFromEnv?: string;
31
+ }
32
+ export declare function resolveProfileById(profileId: string, profilesDir?: string, options?: {
33
+ specPathOverride?: string;
34
+ }): Promise<ResolvedProfile>;
35
+ export declare function listProfiles(profilesDir?: string): Promise<ListedProfile[]>;
36
+ export declare function listProfilesDetailed(profilesDir?: string): Promise<ListedProfileDetails[]>;
37
+ export declare function resolveProfileDetailsFromPath(profilePath: string): Promise<ListedProfileDetails | null>;
38
+ export declare function resolveProfileFromPath(profilePath: string, options?: {
39
+ specPathOverride?: string;
40
+ }): Promise<ResolvedProfile>;
41
+ //# sourceMappingURL=profile-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,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