@frontmcp/uipack 0.6.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 (417) hide show
  1. package/CLAUDE.md +246 -0
  2. package/LICENSE +201 -0
  3. package/README.md +150 -0
  4. package/adapters/index.d.ts +13 -0
  5. package/adapters/index.d.ts.map +1 -0
  6. package/adapters/index.js +462 -0
  7. package/adapters/platform-meta.d.ts +166 -0
  8. package/adapters/platform-meta.d.ts.map +1 -0
  9. package/adapters/response-builder.d.ts +108 -0
  10. package/adapters/response-builder.d.ts.map +1 -0
  11. package/adapters/serving-mode.d.ts +107 -0
  12. package/adapters/serving-mode.d.ts.map +1 -0
  13. package/base-template/bridge.d.ts +90 -0
  14. package/base-template/bridge.d.ts.map +1 -0
  15. package/base-template/default-base-template.d.ts +92 -0
  16. package/base-template/default-base-template.d.ts.map +1 -0
  17. package/base-template/index.d.ts +15 -0
  18. package/base-template/index.d.ts.map +1 -0
  19. package/base-template/index.js +1398 -0
  20. package/base-template/polyfills.d.ts +31 -0
  21. package/base-template/polyfills.d.ts.map +1 -0
  22. package/base-template/theme-styles.d.ts +74 -0
  23. package/base-template/theme-styles.d.ts.map +1 -0
  24. package/bridge-runtime/iife-generator.d.ts +62 -0
  25. package/bridge-runtime/iife-generator.d.ts.map +1 -0
  26. package/bridge-runtime/index.d.ts +10 -0
  27. package/bridge-runtime/index.d.ts.map +1 -0
  28. package/bridge-runtime/index.js +883 -0
  29. package/build/cdn-resources.d.ts +243 -0
  30. package/build/cdn-resources.d.ts.map +1 -0
  31. package/build/index.d.ts +295 -0
  32. package/build/index.d.ts.map +1 -0
  33. package/build/index.js +6861 -0
  34. package/build/widget-manifest.d.ts +362 -0
  35. package/build/widget-manifest.d.ts.map +1 -0
  36. package/bundler/cache.d.ts +173 -0
  37. package/bundler/cache.d.ts.map +1 -0
  38. package/bundler/file-cache/component-builder.d.ts +167 -0
  39. package/bundler/file-cache/component-builder.d.ts.map +1 -0
  40. package/bundler/file-cache/hash-calculator.d.ts +155 -0
  41. package/bundler/file-cache/hash-calculator.d.ts.map +1 -0
  42. package/bundler/file-cache/index.d.ts +12 -0
  43. package/bundler/file-cache/index.d.ts.map +1 -0
  44. package/bundler/file-cache/storage/filesystem.d.ts +149 -0
  45. package/bundler/file-cache/storage/filesystem.d.ts.map +1 -0
  46. package/bundler/file-cache/storage/index.d.ts +11 -0
  47. package/bundler/file-cache/storage/index.d.ts.map +1 -0
  48. package/bundler/file-cache/storage/interface.d.ts +152 -0
  49. package/bundler/file-cache/storage/interface.d.ts.map +1 -0
  50. package/bundler/file-cache/storage/redis.d.ts +139 -0
  51. package/bundler/file-cache/storage/redis.d.ts.map +1 -0
  52. package/bundler/index.d.ts +35 -0
  53. package/bundler/index.d.ts.map +1 -0
  54. package/bundler/index.js +2947 -0
  55. package/bundler/sandbox/enclave-adapter.d.ts +121 -0
  56. package/bundler/sandbox/enclave-adapter.d.ts.map +1 -0
  57. package/bundler/sandbox/executor.d.ts +14 -0
  58. package/bundler/sandbox/executor.d.ts.map +1 -0
  59. package/bundler/sandbox/policy.d.ts +62 -0
  60. package/bundler/sandbox/policy.d.ts.map +1 -0
  61. package/bundler/types.d.ts +702 -0
  62. package/bundler/types.d.ts.map +1 -0
  63. package/dependency/cdn-registry.d.ts +98 -0
  64. package/dependency/cdn-registry.d.ts.map +1 -0
  65. package/dependency/import-map.d.ts +186 -0
  66. package/dependency/import-map.d.ts.map +1 -0
  67. package/dependency/import-parser.d.ts +82 -0
  68. package/dependency/import-parser.d.ts.map +1 -0
  69. package/dependency/index.d.ts +17 -0
  70. package/dependency/index.d.ts.map +1 -0
  71. package/dependency/index.js +3215 -0
  72. package/dependency/resolver.d.ts +164 -0
  73. package/dependency/resolver.d.ts.map +1 -0
  74. package/dependency/schemas.d.ts +486 -0
  75. package/dependency/schemas.d.ts.map +1 -0
  76. package/dependency/template-loader.d.ts +204 -0
  77. package/dependency/template-loader.d.ts.map +1 -0
  78. package/dependency/template-processor.d.ts +118 -0
  79. package/dependency/template-processor.d.ts.map +1 -0
  80. package/dependency/types.d.ts +739 -0
  81. package/dependency/types.d.ts.map +1 -0
  82. package/esm/adapters/index.d.ts +13 -0
  83. package/esm/adapters/index.d.ts.map +1 -0
  84. package/esm/adapters/index.js +427 -0
  85. package/esm/adapters/platform-meta.d.ts +166 -0
  86. package/esm/adapters/platform-meta.d.ts.map +1 -0
  87. package/esm/adapters/response-builder.d.ts +108 -0
  88. package/esm/adapters/response-builder.d.ts.map +1 -0
  89. package/esm/adapters/serving-mode.d.ts +107 -0
  90. package/esm/adapters/serving-mode.d.ts.map +1 -0
  91. package/esm/base-template/bridge.d.ts +90 -0
  92. package/esm/base-template/bridge.d.ts.map +1 -0
  93. package/esm/base-template/default-base-template.d.ts +92 -0
  94. package/esm/base-template/default-base-template.d.ts.map +1 -0
  95. package/esm/base-template/index.d.ts +15 -0
  96. package/esm/base-template/index.d.ts.map +1 -0
  97. package/esm/base-template/index.js +1364 -0
  98. package/esm/base-template/polyfills.d.ts +31 -0
  99. package/esm/base-template/polyfills.d.ts.map +1 -0
  100. package/esm/base-template/theme-styles.d.ts +74 -0
  101. package/esm/base-template/theme-styles.d.ts.map +1 -0
  102. package/esm/bridge-runtime/iife-generator.d.ts +62 -0
  103. package/esm/bridge-runtime/iife-generator.d.ts.map +1 -0
  104. package/esm/bridge-runtime/index.d.ts +10 -0
  105. package/esm/bridge-runtime/index.d.ts.map +1 -0
  106. package/esm/bridge-runtime/index.js +853 -0
  107. package/esm/build/cdn-resources.d.ts +243 -0
  108. package/esm/build/cdn-resources.d.ts.map +1 -0
  109. package/esm/build/index.d.ts +295 -0
  110. package/esm/build/index.d.ts.map +1 -0
  111. package/esm/build/index.js +6786 -0
  112. package/esm/build/widget-manifest.d.ts +362 -0
  113. package/esm/build/widget-manifest.d.ts.map +1 -0
  114. package/esm/bundler/cache.d.ts +173 -0
  115. package/esm/bundler/cache.d.ts.map +1 -0
  116. package/esm/bundler/file-cache/component-builder.d.ts +167 -0
  117. package/esm/bundler/file-cache/component-builder.d.ts.map +1 -0
  118. package/esm/bundler/file-cache/hash-calculator.d.ts +155 -0
  119. package/esm/bundler/file-cache/hash-calculator.d.ts.map +1 -0
  120. package/esm/bundler/file-cache/index.d.ts +12 -0
  121. package/esm/bundler/file-cache/index.d.ts.map +1 -0
  122. package/esm/bundler/file-cache/storage/filesystem.d.ts +149 -0
  123. package/esm/bundler/file-cache/storage/filesystem.d.ts.map +1 -0
  124. package/esm/bundler/file-cache/storage/index.d.ts +11 -0
  125. package/esm/bundler/file-cache/storage/index.d.ts.map +1 -0
  126. package/esm/bundler/file-cache/storage/interface.d.ts +152 -0
  127. package/esm/bundler/file-cache/storage/interface.d.ts.map +1 -0
  128. package/esm/bundler/file-cache/storage/redis.d.ts +139 -0
  129. package/esm/bundler/file-cache/storage/redis.d.ts.map +1 -0
  130. package/esm/bundler/index.d.ts +35 -0
  131. package/esm/bundler/index.d.ts.map +1 -0
  132. package/esm/bundler/index.js +2882 -0
  133. package/esm/bundler/sandbox/enclave-adapter.d.ts +121 -0
  134. package/esm/bundler/sandbox/enclave-adapter.d.ts.map +1 -0
  135. package/esm/bundler/sandbox/executor.d.ts +14 -0
  136. package/esm/bundler/sandbox/executor.d.ts.map +1 -0
  137. package/esm/bundler/sandbox/policy.d.ts +62 -0
  138. package/esm/bundler/sandbox/policy.d.ts.map +1 -0
  139. package/esm/bundler/types.d.ts +702 -0
  140. package/esm/bundler/types.d.ts.map +1 -0
  141. package/esm/dependency/cdn-registry.d.ts +98 -0
  142. package/esm/dependency/cdn-registry.d.ts.map +1 -0
  143. package/esm/dependency/import-map.d.ts +186 -0
  144. package/esm/dependency/import-map.d.ts.map +1 -0
  145. package/esm/dependency/import-parser.d.ts +82 -0
  146. package/esm/dependency/import-parser.d.ts.map +1 -0
  147. package/esm/dependency/index.d.ts +17 -0
  148. package/esm/dependency/index.d.ts.map +1 -0
  149. package/esm/dependency/index.js +3096 -0
  150. package/esm/dependency/resolver.d.ts +164 -0
  151. package/esm/dependency/resolver.d.ts.map +1 -0
  152. package/esm/dependency/schemas.d.ts +486 -0
  153. package/esm/dependency/schemas.d.ts.map +1 -0
  154. package/esm/dependency/template-loader.d.ts +204 -0
  155. package/esm/dependency/template-loader.d.ts.map +1 -0
  156. package/esm/dependency/template-processor.d.ts +118 -0
  157. package/esm/dependency/template-processor.d.ts.map +1 -0
  158. package/esm/dependency/types.d.ts +739 -0
  159. package/esm/dependency/types.d.ts.map +1 -0
  160. package/esm/handlebars/expression-extractor.d.ts +147 -0
  161. package/esm/handlebars/expression-extractor.d.ts.map +1 -0
  162. package/esm/handlebars/helpers.d.ts +339 -0
  163. package/esm/handlebars/helpers.d.ts.map +1 -0
  164. package/esm/handlebars/index.d.ts +195 -0
  165. package/esm/handlebars/index.d.ts.map +1 -0
  166. package/esm/handlebars/index.js +587 -0
  167. package/esm/index.d.ts +50 -0
  168. package/esm/index.d.ts.map +1 -0
  169. package/esm/index.js +12434 -0
  170. package/esm/package.json +68 -0
  171. package/esm/registry/index.d.ts +46 -0
  172. package/esm/registry/index.d.ts.map +1 -0
  173. package/esm/registry/index.js +6237 -0
  174. package/esm/registry/render-template.d.ts +91 -0
  175. package/esm/registry/render-template.d.ts.map +1 -0
  176. package/esm/registry/tool-ui.registry.d.ts +294 -0
  177. package/esm/registry/tool-ui.registry.d.ts.map +1 -0
  178. package/esm/registry/uri-utils.d.ts +56 -0
  179. package/esm/registry/uri-utils.d.ts.map +1 -0
  180. package/esm/renderers/cache.d.ts +145 -0
  181. package/esm/renderers/cache.d.ts.map +1 -0
  182. package/esm/renderers/html.renderer.d.ts +123 -0
  183. package/esm/renderers/html.renderer.d.ts.map +1 -0
  184. package/esm/renderers/index.d.ts +36 -0
  185. package/esm/renderers/index.d.ts.map +1 -0
  186. package/esm/renderers/index.js +1654 -0
  187. package/esm/renderers/mdx.renderer.d.ts +120 -0
  188. package/esm/renderers/mdx.renderer.d.ts.map +1 -0
  189. package/esm/renderers/registry.d.ts +133 -0
  190. package/esm/renderers/registry.d.ts.map +1 -0
  191. package/esm/renderers/types.d.ts +342 -0
  192. package/esm/renderers/types.d.ts.map +1 -0
  193. package/esm/renderers/utils/detect.d.ts +107 -0
  194. package/esm/renderers/utils/detect.d.ts.map +1 -0
  195. package/esm/renderers/utils/hash.d.ts +40 -0
  196. package/esm/renderers/utils/hash.d.ts.map +1 -0
  197. package/esm/renderers/utils/index.d.ts +9 -0
  198. package/esm/renderers/utils/index.d.ts.map +1 -0
  199. package/esm/renderers/utils/transpiler.d.ts +89 -0
  200. package/esm/renderers/utils/transpiler.d.ts.map +1 -0
  201. package/esm/runtime/adapters/html.adapter.d.ts +59 -0
  202. package/esm/runtime/adapters/html.adapter.d.ts.map +1 -0
  203. package/esm/runtime/adapters/index.d.ts +26 -0
  204. package/esm/runtime/adapters/index.d.ts.map +1 -0
  205. package/esm/runtime/adapters/mdx.adapter.d.ts +73 -0
  206. package/esm/runtime/adapters/mdx.adapter.d.ts.map +1 -0
  207. package/esm/runtime/adapters/types.d.ts +95 -0
  208. package/esm/runtime/adapters/types.d.ts.map +1 -0
  209. package/esm/runtime/csp.d.ts +48 -0
  210. package/esm/runtime/csp.d.ts.map +1 -0
  211. package/esm/runtime/index.d.ts +17 -0
  212. package/esm/runtime/index.d.ts.map +1 -0
  213. package/esm/runtime/index.js +4976 -0
  214. package/esm/runtime/mcp-bridge.d.ts +101 -0
  215. package/esm/runtime/mcp-bridge.d.ts.map +1 -0
  216. package/esm/runtime/renderer-runtime.d.ts +133 -0
  217. package/esm/runtime/renderer-runtime.d.ts.map +1 -0
  218. package/esm/runtime/sanitizer.d.ts +172 -0
  219. package/esm/runtime/sanitizer.d.ts.map +1 -0
  220. package/esm/runtime/types.d.ts +415 -0
  221. package/esm/runtime/types.d.ts.map +1 -0
  222. package/esm/runtime/wrapper.d.ts +421 -0
  223. package/esm/runtime/wrapper.d.ts.map +1 -0
  224. package/esm/styles/index.d.ts +8 -0
  225. package/esm/styles/index.d.ts.map +1 -0
  226. package/esm/styles/index.js +171 -0
  227. package/esm/styles/variants.d.ts +51 -0
  228. package/esm/styles/variants.d.ts.map +1 -0
  229. package/esm/theme/cdn.d.ts +195 -0
  230. package/esm/theme/cdn.d.ts.map +1 -0
  231. package/esm/theme/index.d.ts +18 -0
  232. package/esm/theme/index.d.ts.map +1 -0
  233. package/esm/theme/index.js +700 -0
  234. package/esm/theme/platforms.d.ts +107 -0
  235. package/esm/theme/platforms.d.ts.map +1 -0
  236. package/esm/theme/presets/github-openai.d.ts +50 -0
  237. package/esm/theme/presets/github-openai.d.ts.map +1 -0
  238. package/esm/theme/presets/index.d.ts +11 -0
  239. package/esm/theme/presets/index.d.ts.map +1 -0
  240. package/esm/theme/theme.d.ts +396 -0
  241. package/esm/theme/theme.d.ts.map +1 -0
  242. package/esm/tool-template/builder.d.ts +213 -0
  243. package/esm/tool-template/builder.d.ts.map +1 -0
  244. package/esm/tool-template/index.d.ts +16 -0
  245. package/esm/tool-template/index.d.ts.map +1 -0
  246. package/esm/tool-template/index.js +3518 -0
  247. package/esm/types/index.d.ts +14 -0
  248. package/esm/types/index.d.ts.map +1 -0
  249. package/esm/types/index.js +75 -0
  250. package/esm/types/ui-config.d.ts +641 -0
  251. package/esm/types/ui-config.d.ts.map +1 -0
  252. package/esm/types/ui-runtime.d.ts +1008 -0
  253. package/esm/types/ui-runtime.d.ts.map +1 -0
  254. package/esm/typings/cache/cache-adapter.d.ts +125 -0
  255. package/esm/typings/cache/cache-adapter.d.ts.map +1 -0
  256. package/esm/typings/cache/index.d.ts +10 -0
  257. package/esm/typings/cache/index.d.ts.map +1 -0
  258. package/esm/typings/cache/memory-cache.d.ts +92 -0
  259. package/esm/typings/cache/memory-cache.d.ts.map +1 -0
  260. package/esm/typings/dts-parser.d.ts +90 -0
  261. package/esm/typings/dts-parser.d.ts.map +1 -0
  262. package/esm/typings/index.d.ts +48 -0
  263. package/esm/typings/index.d.ts.map +1 -0
  264. package/esm/typings/index.js +812 -0
  265. package/esm/typings/schemas.d.ts +232 -0
  266. package/esm/typings/schemas.d.ts.map +1 -0
  267. package/esm/typings/type-fetcher.d.ts +89 -0
  268. package/esm/typings/type-fetcher.d.ts.map +1 -0
  269. package/esm/typings/types.d.ts +320 -0
  270. package/esm/typings/types.d.ts.map +1 -0
  271. package/esm/utils/escape-html.d.ts +58 -0
  272. package/esm/utils/escape-html.d.ts.map +1 -0
  273. package/esm/utils/index.d.ts +10 -0
  274. package/esm/utils/index.d.ts.map +1 -0
  275. package/esm/utils/index.js +40 -0
  276. package/esm/utils/safe-stringify.d.ts +30 -0
  277. package/esm/utils/safe-stringify.d.ts.map +1 -0
  278. package/esm/validation/error-box.d.ts +56 -0
  279. package/esm/validation/error-box.d.ts.map +1 -0
  280. package/esm/validation/index.d.ts +13 -0
  281. package/esm/validation/index.d.ts.map +1 -0
  282. package/esm/validation/index.js +542 -0
  283. package/esm/validation/schema-paths.d.ts +118 -0
  284. package/esm/validation/schema-paths.d.ts.map +1 -0
  285. package/esm/validation/template-validator.d.ts +143 -0
  286. package/esm/validation/template-validator.d.ts.map +1 -0
  287. package/esm/validation/wrapper.d.ts +97 -0
  288. package/esm/validation/wrapper.d.ts.map +1 -0
  289. package/handlebars/expression-extractor.d.ts +147 -0
  290. package/handlebars/expression-extractor.d.ts.map +1 -0
  291. package/handlebars/helpers.d.ts +339 -0
  292. package/handlebars/helpers.d.ts.map +1 -0
  293. package/handlebars/index.d.ts +195 -0
  294. package/handlebars/index.d.ts.map +1 -0
  295. package/handlebars/index.js +666 -0
  296. package/index.d.ts +50 -0
  297. package/index.d.ts.map +1 -0
  298. package/index.js +12683 -0
  299. package/package.json +66 -0
  300. package/registry/index.d.ts +46 -0
  301. package/registry/index.d.ts.map +1 -0
  302. package/registry/index.js +6280 -0
  303. package/registry/render-template.d.ts +91 -0
  304. package/registry/render-template.d.ts.map +1 -0
  305. package/registry/tool-ui.registry.d.ts +294 -0
  306. package/registry/tool-ui.registry.d.ts.map +1 -0
  307. package/registry/uri-utils.d.ts +56 -0
  308. package/registry/uri-utils.d.ts.map +1 -0
  309. package/renderers/cache.d.ts +145 -0
  310. package/renderers/cache.d.ts.map +1 -0
  311. package/renderers/html.renderer.d.ts +123 -0
  312. package/renderers/html.renderer.d.ts.map +1 -0
  313. package/renderers/index.d.ts +36 -0
  314. package/renderers/index.d.ts.map +1 -0
  315. package/renderers/index.js +1706 -0
  316. package/renderers/mdx.renderer.d.ts +120 -0
  317. package/renderers/mdx.renderer.d.ts.map +1 -0
  318. package/renderers/registry.d.ts +133 -0
  319. package/renderers/registry.d.ts.map +1 -0
  320. package/renderers/types.d.ts +342 -0
  321. package/renderers/types.d.ts.map +1 -0
  322. package/renderers/utils/detect.d.ts +107 -0
  323. package/renderers/utils/detect.d.ts.map +1 -0
  324. package/renderers/utils/hash.d.ts +40 -0
  325. package/renderers/utils/hash.d.ts.map +1 -0
  326. package/renderers/utils/index.d.ts +9 -0
  327. package/renderers/utils/index.d.ts.map +1 -0
  328. package/renderers/utils/transpiler.d.ts +89 -0
  329. package/renderers/utils/transpiler.d.ts.map +1 -0
  330. package/runtime/adapters/html.adapter.d.ts +59 -0
  331. package/runtime/adapters/html.adapter.d.ts.map +1 -0
  332. package/runtime/adapters/index.d.ts +26 -0
  333. package/runtime/adapters/index.d.ts.map +1 -0
  334. package/runtime/adapters/mdx.adapter.d.ts +73 -0
  335. package/runtime/adapters/mdx.adapter.d.ts.map +1 -0
  336. package/runtime/adapters/types.d.ts +95 -0
  337. package/runtime/adapters/types.d.ts.map +1 -0
  338. package/runtime/csp.d.ts +48 -0
  339. package/runtime/csp.d.ts.map +1 -0
  340. package/runtime/index.d.ts +17 -0
  341. package/runtime/index.d.ts.map +1 -0
  342. package/runtime/index.js +5052 -0
  343. package/runtime/mcp-bridge.d.ts +101 -0
  344. package/runtime/mcp-bridge.d.ts.map +1 -0
  345. package/runtime/renderer-runtime.d.ts +133 -0
  346. package/runtime/renderer-runtime.d.ts.map +1 -0
  347. package/runtime/sanitizer.d.ts +172 -0
  348. package/runtime/sanitizer.d.ts.map +1 -0
  349. package/runtime/types.d.ts +415 -0
  350. package/runtime/types.d.ts.map +1 -0
  351. package/runtime/wrapper.d.ts +421 -0
  352. package/runtime/wrapper.d.ts.map +1 -0
  353. package/styles/index.d.ts +8 -0
  354. package/styles/index.d.ts.map +1 -0
  355. package/styles/index.js +222 -0
  356. package/styles/variants.d.ts +51 -0
  357. package/styles/variants.d.ts.map +1 -0
  358. package/theme/cdn.d.ts +195 -0
  359. package/theme/cdn.d.ts.map +1 -0
  360. package/theme/index.d.ts +18 -0
  361. package/theme/index.d.ts.map +1 -0
  362. package/theme/index.js +757 -0
  363. package/theme/platforms.d.ts +107 -0
  364. package/theme/platforms.d.ts.map +1 -0
  365. package/theme/presets/github-openai.d.ts +50 -0
  366. package/theme/presets/github-openai.d.ts.map +1 -0
  367. package/theme/presets/index.d.ts +11 -0
  368. package/theme/presets/index.d.ts.map +1 -0
  369. package/theme/theme.d.ts +396 -0
  370. package/theme/theme.d.ts.map +1 -0
  371. package/tool-template/builder.d.ts +213 -0
  372. package/tool-template/builder.d.ts.map +1 -0
  373. package/tool-template/index.d.ts +16 -0
  374. package/tool-template/index.d.ts.map +1 -0
  375. package/tool-template/index.js +3562 -0
  376. package/types/index.d.ts +14 -0
  377. package/types/index.d.ts.map +1 -0
  378. package/types/index.js +108 -0
  379. package/types/ui-config.d.ts +641 -0
  380. package/types/ui-config.d.ts.map +1 -0
  381. package/types/ui-runtime.d.ts +1008 -0
  382. package/types/ui-runtime.d.ts.map +1 -0
  383. package/typings/cache/cache-adapter.d.ts +125 -0
  384. package/typings/cache/cache-adapter.d.ts.map +1 -0
  385. package/typings/cache/index.d.ts +10 -0
  386. package/typings/cache/index.d.ts.map +1 -0
  387. package/typings/cache/memory-cache.d.ts +92 -0
  388. package/typings/cache/memory-cache.d.ts.map +1 -0
  389. package/typings/dts-parser.d.ts +90 -0
  390. package/typings/dts-parser.d.ts.map +1 -0
  391. package/typings/index.d.ts +48 -0
  392. package/typings/index.d.ts.map +1 -0
  393. package/typings/index.js +868 -0
  394. package/typings/schemas.d.ts +232 -0
  395. package/typings/schemas.d.ts.map +1 -0
  396. package/typings/type-fetcher.d.ts +89 -0
  397. package/typings/type-fetcher.d.ts.map +1 -0
  398. package/typings/types.d.ts +320 -0
  399. package/typings/types.d.ts.map +1 -0
  400. package/utils/escape-html.d.ts +58 -0
  401. package/utils/escape-html.d.ts.map +1 -0
  402. package/utils/index.d.ts +10 -0
  403. package/utils/index.d.ts.map +1 -0
  404. package/utils/index.js +70 -0
  405. package/utils/safe-stringify.d.ts +30 -0
  406. package/utils/safe-stringify.d.ts.map +1 -0
  407. package/validation/error-box.d.ts +56 -0
  408. package/validation/error-box.d.ts.map +1 -0
  409. package/validation/index.d.ts +13 -0
  410. package/validation/index.d.ts.map +1 -0
  411. package/validation/index.js +583 -0
  412. package/validation/schema-paths.d.ts +118 -0
  413. package/validation/schema-paths.d.ts.map +1 -0
  414. package/validation/template-validator.d.ts +143 -0
  415. package/validation/template-validator.d.ts.map +1 -0
  416. package/validation/wrapper.d.ts +97 -0
  417. package/validation/wrapper.d.ts.map +1 -0
@@ -0,0 +1,583 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // libs/uipack/src/validation/index.ts
21
+ var validation_exports = {};
22
+ __export(validation_exports, {
23
+ assertTemplateValid: () => assertTemplateValid,
24
+ extractSchemaPaths: () => extractSchemaPaths,
25
+ formatValidationWarnings: () => formatValidationWarnings,
26
+ getMissingFields: () => getMissingFields,
27
+ getPathInfo: () => getPathInfo,
28
+ getRootFieldNames: () => getRootFieldNames,
29
+ getSchemaPathStrings: () => getSchemaPathStrings,
30
+ getTypeAtPath: () => getTypeAtPath,
31
+ getTypeDescription: () => getTypeDescription,
32
+ isTemplateValid: () => isTemplateValid,
33
+ isValidSchemaPath: () => isValidSchemaPath,
34
+ logValidationWarnings: () => logValidationWarnings,
35
+ validateOptions: () => validateOptions,
36
+ validateTemplate: () => validateTemplate,
37
+ validationErrorBox: () => validationErrorBox
38
+ });
39
+ module.exports = __toCommonJS(validation_exports);
40
+
41
+ // libs/uipack/src/utils/escape-html.ts
42
+ function escapeHtml(str) {
43
+ if (str === null || str === void 0) {
44
+ return "";
45
+ }
46
+ const s = String(str);
47
+ return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
48
+ }
49
+
50
+ // libs/uipack/src/validation/error-box.ts
51
+ var errorIcon = `<svg class="w-5 h-5 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24" aria-hidden="true">
52
+ <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"/>
53
+ </svg>`;
54
+ function validationErrorBox(options) {
55
+ const { componentName, invalidParam } = options;
56
+ return `<div
57
+ class="validation-error flex items-start gap-3 p-4 bg-red-50 border border-red-200 text-red-800 rounded-lg"
58
+ role="alert"
59
+ data-testid="validation-error"
60
+ data-component="${escapeHtml(componentName)}"
61
+ data-param="${escapeHtml(invalidParam)}"
62
+ >
63
+ ${errorIcon}
64
+ <div class="min-w-0">
65
+ <p class="font-semibold text-sm">${escapeHtml(componentName)}: Invalid Configuration</p>
66
+ <p class="text-sm opacity-90 mt-0.5">The "${escapeHtml(invalidParam)}" parameter is invalid.</p>
67
+ </div>
68
+ </div>`;
69
+ }
70
+
71
+ // libs/uipack/src/validation/wrapper.ts
72
+ function getFirstInvalidPath(error) {
73
+ const firstError = error.issues[0];
74
+ if (!firstError || firstError.path.length === 0) {
75
+ return "options";
76
+ }
77
+ return firstError.path.map(String).join(".");
78
+ }
79
+ function validateOptions(options, config) {
80
+ const result = config.schema.safeParse(options);
81
+ if (result.success) {
82
+ return { success: true, data: result.data };
83
+ }
84
+ const invalidParam = getFirstInvalidPath(result.error);
85
+ return {
86
+ success: false,
87
+ error: validationErrorBox({
88
+ componentName: config.componentName,
89
+ invalidParam
90
+ })
91
+ };
92
+ }
93
+
94
+ // libs/uipack/src/validation/schema-paths.ts
95
+ var import_zod = require("zod");
96
+ function extractSchemaPaths(schema, prefix = "output", options = {}) {
97
+ const { maxDepth = 10, includeArrayItems = true } = options;
98
+ const paths = [];
99
+ const visited = /* @__PURE__ */ new Set();
100
+ function recurse(currentSchema, currentPath, depth, isOptional, isNullable, isArrayItem) {
101
+ if (depth > maxDepth) return;
102
+ const pathKey = `${currentPath}:${depth}`;
103
+ if (visited.has(pathKey)) return;
104
+ visited.add(pathKey);
105
+ const description = currentSchema.description;
106
+ const innerType = unwrapType(currentSchema);
107
+ paths.push({
108
+ path: currentPath,
109
+ zodType: currentSchema,
110
+ optional: isOptional,
111
+ nullable: isNullable,
112
+ isArrayItem,
113
+ description
114
+ });
115
+ if (innerType instanceof import_zod.z.ZodObject) {
116
+ const shape = innerType.shape;
117
+ for (const [key, value] of Object.entries(shape)) {
118
+ const childSchema = value;
119
+ const childOptional = isOptional || isOptionalType(childSchema);
120
+ const childNullable = isNullable || isNullableType(childSchema);
121
+ recurse(childSchema, `${currentPath}.${key}`, depth + 1, childOptional, childNullable, false);
122
+ }
123
+ } else if (innerType instanceof import_zod.z.ZodArray && includeArrayItems) {
124
+ const itemSchema = innerType.element;
125
+ recurse(itemSchema, `${currentPath}.[]`, depth + 1, isOptional, isNullable, true);
126
+ } else if (innerType instanceof import_zod.z.ZodUnion || innerType instanceof import_zod.z.ZodDiscriminatedUnion) {
127
+ const options2 = "options" in innerType ? innerType.options : [];
128
+ for (const option of options2) {
129
+ recurse(option, currentPath, depth, isOptional, isNullable, isArrayItem);
130
+ }
131
+ } else if (innerType instanceof import_zod.z.ZodIntersection) {
132
+ recurse(innerType._def.left, currentPath, depth, isOptional, isNullable, isArrayItem);
133
+ recurse(innerType._def.right, currentPath, depth, isOptional, isNullable, isArrayItem);
134
+ } else if (innerType instanceof import_zod.z.ZodRecord) {
135
+ const valueSchema = innerType._def.valueType;
136
+ recurse(valueSchema, `${currentPath}.[]`, depth + 1, isOptional, isNullable, true);
137
+ } else if (innerType instanceof import_zod.z.ZodTuple) {
138
+ const items = innerType._def.items;
139
+ items.forEach((item, index) => {
140
+ recurse(item, `${currentPath}.${index}`, depth + 1, isOptional, isNullable, true);
141
+ });
142
+ }
143
+ }
144
+ recurse(schema, prefix, 0, false, false, false);
145
+ const seen = /* @__PURE__ */ new Set();
146
+ return paths.filter((p) => {
147
+ if (seen.has(p.path)) return false;
148
+ seen.add(p.path);
149
+ return true;
150
+ });
151
+ }
152
+ function unwrapType(schema) {
153
+ if (schema instanceof import_zod.z.ZodOptional) {
154
+ return unwrapType(schema.unwrap());
155
+ }
156
+ if (schema instanceof import_zod.z.ZodNullable) {
157
+ return unwrapType(schema.unwrap());
158
+ }
159
+ if (schema instanceof import_zod.z.ZodDefault) {
160
+ return unwrapType(schema._def.innerType);
161
+ }
162
+ if (schema instanceof import_zod.z.ZodCatch && "innerType" in schema._def) {
163
+ return unwrapType(schema._def.innerType);
164
+ }
165
+ return schema;
166
+ }
167
+ function isOptionalType(schema) {
168
+ if (schema instanceof import_zod.z.ZodOptional) return true;
169
+ if (schema instanceof import_zod.z.ZodDefault) return true;
170
+ if (schema instanceof import_zod.z.ZodNullable) return isOptionalType(schema.unwrap());
171
+ return false;
172
+ }
173
+ function isNullableType(schema) {
174
+ if (schema instanceof import_zod.z.ZodNullable) return true;
175
+ if (schema instanceof import_zod.z.ZodOptional) return isNullableType(schema.unwrap());
176
+ return false;
177
+ }
178
+ function getSchemaPathStrings(schema, prefix = "output") {
179
+ const paths = extractSchemaPaths(schema, prefix);
180
+ return new Set(paths.map((p) => p.path));
181
+ }
182
+ function isValidSchemaPath(schema, path) {
183
+ const prefix = path.split(".")[0];
184
+ const paths = getSchemaPathStrings(schema, prefix);
185
+ if (paths.has(path)) return true;
186
+ const normalizedPath = normalizePath(path);
187
+ if (paths.has(normalizedPath)) return true;
188
+ const pathParts = path.split(".");
189
+ for (let i = pathParts.length - 1; i >= 0; i--) {
190
+ const part = pathParts[i];
191
+ if (/^\d+$/.test(part)) {
192
+ const parentPath = pathParts.slice(0, i).join(".");
193
+ const wildcardPath = `${parentPath}.[]`;
194
+ if (paths.has(wildcardPath)) {
195
+ const restPath = pathParts.slice(i + 1).join(".");
196
+ if (restPath) {
197
+ const fullWildcardPath = `${wildcardPath}.${restPath}`;
198
+ const normalizedFullPath = normalizePath(fullWildcardPath);
199
+ if (paths.has(normalizedFullPath)) return true;
200
+ } else {
201
+ return true;
202
+ }
203
+ }
204
+ }
205
+ }
206
+ return false;
207
+ }
208
+ function normalizePath(path) {
209
+ return path.replace(/\.\d+\./g, ".[].").replace(/\.\d+$/g, ".[]").replace(/\[\d+\]/g, ".[]");
210
+ }
211
+ function getTypeAtPath(schema, path) {
212
+ const prefix = path.split(".")[0];
213
+ const paths = extractSchemaPaths(schema, prefix);
214
+ let schemaPath = paths.find((p) => p.path === path);
215
+ if (!schemaPath) {
216
+ const normalizedPath = normalizePath(path);
217
+ schemaPath = paths.find((p) => p.path === normalizedPath);
218
+ }
219
+ return schemaPath?.zodType;
220
+ }
221
+ function getPathInfo(schema, path) {
222
+ const prefix = path.split(".")[0];
223
+ const paths = extractSchemaPaths(schema, prefix);
224
+ let schemaPath = paths.find((p) => p.path === path);
225
+ if (!schemaPath) {
226
+ const normalizedPath = normalizePath(path);
227
+ schemaPath = paths.find((p) => p.path === normalizedPath);
228
+ }
229
+ return schemaPath;
230
+ }
231
+ function getRootFieldNames(schema) {
232
+ const unwrapped = unwrapType(schema);
233
+ if (unwrapped instanceof import_zod.z.ZodObject) {
234
+ return Object.keys(unwrapped.shape);
235
+ }
236
+ return [];
237
+ }
238
+ function getTypeDescription(schema, path) {
239
+ const zodType = getTypeAtPath(schema, path);
240
+ if (!zodType) return "unknown";
241
+ return describeZodType(zodType);
242
+ }
243
+ function describeZodType(schema) {
244
+ const inner = unwrapType(schema);
245
+ if (inner instanceof import_zod.z.ZodString) return "string";
246
+ if (inner instanceof import_zod.z.ZodNumber) return "number";
247
+ if (inner instanceof import_zod.z.ZodBoolean) return "boolean";
248
+ if (inner instanceof import_zod.z.ZodDate) return "Date";
249
+ if (inner instanceof import_zod.z.ZodBigInt) return "bigint";
250
+ if (inner instanceof import_zod.z.ZodSymbol) return "symbol";
251
+ if (inner instanceof import_zod.z.ZodUndefined) return "undefined";
252
+ if (inner instanceof import_zod.z.ZodNull) return "null";
253
+ if (inner instanceof import_zod.z.ZodVoid) return "void";
254
+ if (inner instanceof import_zod.z.ZodAny) return "any";
255
+ if (inner instanceof import_zod.z.ZodUnknown) return "unknown";
256
+ if (inner instanceof import_zod.z.ZodNever) return "never";
257
+ if (inner instanceof import_zod.z.ZodLiteral) return `literal(${JSON.stringify(inner.value)})`;
258
+ if (inner instanceof import_zod.z.ZodEnum) return `enum(${inner.options.join(" | ")})`;
259
+ if (inner instanceof import_zod.z.ZodArray) return `${describeZodType(inner.element)}[]`;
260
+ if (inner instanceof import_zod.z.ZodObject) return "object";
261
+ if (inner instanceof import_zod.z.ZodUnion) return "union";
262
+ if (inner instanceof import_zod.z.ZodDiscriminatedUnion) return "discriminatedUnion";
263
+ if (inner instanceof import_zod.z.ZodIntersection) return "intersection";
264
+ if (inner instanceof import_zod.z.ZodTuple) return "tuple";
265
+ if (inner instanceof import_zod.z.ZodRecord) return `Record<string, ${describeZodType(inner._def.valueType)}>`;
266
+ if (inner instanceof import_zod.z.ZodMap) return "Map";
267
+ if (inner instanceof import_zod.z.ZodSet) return "Set";
268
+ if (inner instanceof import_zod.z.ZodFunction) return "function";
269
+ if (inner instanceof import_zod.z.ZodPromise) return "Promise";
270
+ if (schema instanceof import_zod.z.ZodOptional) {
271
+ return `${describeZodType(schema.unwrap())}?`;
272
+ }
273
+ if (schema instanceof import_zod.z.ZodNullable) {
274
+ return `${describeZodType(schema.unwrap())} | null`;
275
+ }
276
+ return "unknown";
277
+ }
278
+
279
+ // libs/uipack/src/handlebars/expression-extractor.ts
280
+ var EXPRESSION_REGEX = /\{\{\{?(?!!)(#|\/)?([^}]+?)\}?\}\}/g;
281
+ var PATH_REGEX = /\b(output|input|structuredContent)(\.[a-zA-Z_$][a-zA-Z0-9_$]*|\.\[[^\]]+\])+/g;
282
+ var KEYWORDS = /* @__PURE__ */ new Set(["this", "else", "@index", "@key", "@first", "@last", "@root"]);
283
+ function extractExpressions(template) {
284
+ const expressions = [];
285
+ const lines = template.split("\n");
286
+ const positionMap = buildPositionMap(template);
287
+ let match;
288
+ EXPRESSION_REGEX.lastIndex = 0;
289
+ while ((match = EXPRESSION_REGEX.exec(template)) !== null) {
290
+ const fullExpression = match[0];
291
+ const prefix = match[1];
292
+ const content = match[2].trim();
293
+ const position = positionMap.get(match.index) ?? { line: 1, column: 1 };
294
+ let type = "variable";
295
+ let helperName;
296
+ if (prefix === "/") {
297
+ type = "block-close";
298
+ helperName = content;
299
+ } else if (prefix === "#") {
300
+ type = "block";
301
+ const parts = content.split(/\s+/);
302
+ helperName = parts[0];
303
+ } else {
304
+ const parts = content.split(/\s+/);
305
+ if (parts.length > 1 && !content.startsWith("(")) {
306
+ const firstToken = parts[0];
307
+ if (!firstToken.includes(".") && !KEYWORDS.has(firstToken)) {
308
+ type = "helper";
309
+ helperName = firstToken;
310
+ }
311
+ }
312
+ }
313
+ const paths = extractPathsFromContent(content);
314
+ for (const path of paths) {
315
+ expressions.push({
316
+ path,
317
+ fullExpression,
318
+ line: position.line,
319
+ column: position.column,
320
+ type,
321
+ helperName
322
+ });
323
+ }
324
+ if (paths.length === 0 && type === "variable") {
325
+ const cleanContent = content.trim();
326
+ if (!KEYWORDS.has(cleanContent) && !cleanContent.includes(" ") && !cleanContent.startsWith("(")) {
327
+ }
328
+ }
329
+ }
330
+ return expressions;
331
+ }
332
+ function extractPathsFromContent(content) {
333
+ const paths = [];
334
+ let match;
335
+ const regex = new RegExp(PATH_REGEX.source, "g");
336
+ while ((match = regex.exec(content)) !== null) {
337
+ paths.push(match[0]);
338
+ }
339
+ return paths;
340
+ }
341
+ function buildPositionMap(template) {
342
+ const map = /* @__PURE__ */ new Map();
343
+ let line = 1;
344
+ let column = 1;
345
+ for (let i = 0; i < template.length; i++) {
346
+ map.set(i, { line, column });
347
+ if (template[i] === "\n") {
348
+ line++;
349
+ column = 1;
350
+ } else {
351
+ column++;
352
+ }
353
+ }
354
+ return map;
355
+ }
356
+ function extractAll(template) {
357
+ const expressions = extractExpressions(template);
358
+ const paths = [...new Set(expressions.map((e) => e.path))];
359
+ return {
360
+ expressions,
361
+ paths,
362
+ outputPaths: paths.filter((p) => p.startsWith("output.")),
363
+ inputPaths: paths.filter((p) => p.startsWith("input.")),
364
+ structuredContentPaths: paths.filter((p) => p.startsWith("structuredContent."))
365
+ };
366
+ }
367
+ function normalizePath2(path) {
368
+ return path.replace(/\.\d+\./g, ".[].").replace(/\.\d+$/g, ".[]").replace(/\[\d+\]/g, ".[]");
369
+ }
370
+
371
+ // libs/uipack/src/validation/template-validator.ts
372
+ function validateTemplate(template, outputSchema, options = {}) {
373
+ const { inputSchema, warnOnOptional = true, suggestSimilar = true, maxSuggestionDistance = 3 } = options;
374
+ const errors = [];
375
+ const warnings = [];
376
+ const extraction = extractAll(template);
377
+ const expressions = extractExpressions(template);
378
+ const outputPaths = getSchemaPathStrings(outputSchema, "output");
379
+ const inputPaths = inputSchema ? getSchemaPathStrings(inputSchema, "input") : /* @__PURE__ */ new Set();
380
+ const outputPathInfos = extractSchemaPaths(outputSchema, "output");
381
+ const inputPathInfos = inputSchema ? extractSchemaPaths(inputSchema, "input") : [];
382
+ const pathInfoMap = /* @__PURE__ */ new Map();
383
+ for (const info of [...outputPathInfos, ...inputPathInfos]) {
384
+ pathInfoMap.set(info.path, info);
385
+ }
386
+ for (const expr of expressions) {
387
+ const { path, fullExpression, line, column } = expr;
388
+ let validPaths;
389
+ let allPaths;
390
+ if (path.startsWith("output.")) {
391
+ validPaths = outputPaths;
392
+ allPaths = Array.from(outputPaths);
393
+ } else if (path.startsWith("input.")) {
394
+ if (!inputSchema) {
395
+ continue;
396
+ }
397
+ validPaths = inputPaths;
398
+ allPaths = Array.from(inputPaths);
399
+ } else if (path.startsWith("structuredContent.")) {
400
+ continue;
401
+ } else {
402
+ continue;
403
+ }
404
+ const normalizedPath = normalizePath2(path);
405
+ const isValid = validPaths.has(path) || validPaths.has(normalizedPath);
406
+ if (!isValid) {
407
+ const isArrayAccess = checkArrayAccess(path, validPaths);
408
+ if (!isArrayAccess) {
409
+ const suggestions = suggestSimilar ? findSimilarPaths(path, allPaths, maxSuggestionDistance) : [];
410
+ errors.push({
411
+ type: "missing_field",
412
+ path,
413
+ expression: fullExpression,
414
+ line,
415
+ column,
416
+ message: `Field '${getFieldName(path)}' does not exist in ${getSchemaName(path)} schema`,
417
+ suggestions
418
+ });
419
+ }
420
+ } else {
421
+ const pathInfo = pathInfoMap.get(path) ?? pathInfoMap.get(normalizedPath);
422
+ if (pathInfo && warnOnOptional) {
423
+ if (pathInfo.optional && expr.type === "variable") {
424
+ const hasGuard = hasConditionalGuard(template, path);
425
+ if (!hasGuard) {
426
+ warnings.push({
427
+ type: "optional_field",
428
+ path,
429
+ expression: fullExpression,
430
+ line,
431
+ message: `Accessing optional field '${getFieldName(path)}' without {{#if}} guard`
432
+ });
433
+ }
434
+ }
435
+ }
436
+ }
437
+ }
438
+ return {
439
+ valid: errors.length === 0,
440
+ errors,
441
+ warnings,
442
+ templatePaths: extraction.paths,
443
+ schemaPaths: [...outputPaths, ...inputPaths]
444
+ };
445
+ }
446
+ function checkArrayAccess(path, validPaths) {
447
+ const parts = path.split(".");
448
+ for (let i = 0; i < parts.length; i++) {
449
+ if (/^\d+$/.test(parts[i])) {
450
+ const wildcardParts = [...parts];
451
+ wildcardParts[i] = "[]";
452
+ const wildcardPath = wildcardParts.join(".");
453
+ if (validPaths.has(wildcardPath)) {
454
+ return true;
455
+ }
456
+ }
457
+ }
458
+ return false;
459
+ }
460
+ function getFieldName(path) {
461
+ const parts = path.split(".");
462
+ return parts[parts.length - 1];
463
+ }
464
+ function getSchemaName(path) {
465
+ if (path.startsWith("output.")) return "output";
466
+ if (path.startsWith("input.")) return "input";
467
+ if (path.startsWith("structuredContent.")) return "structuredContent";
468
+ return "unknown";
469
+ }
470
+ function hasConditionalGuard(template, path) {
471
+ const guardPattern = new RegExp(`\\{\\{#if\\s+${escapeRegex(path)}`, "i");
472
+ return guardPattern.test(template);
473
+ }
474
+ function escapeRegex(str) {
475
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
476
+ }
477
+ function findSimilarPaths(path, validPaths, maxDistance) {
478
+ const fieldName = getFieldName(path);
479
+ const prefix = path.substring(0, path.lastIndexOf(".") + 1);
480
+ const suggestions = [];
481
+ for (const validPath of validPaths) {
482
+ if (!validPath.startsWith(prefix)) continue;
483
+ const validFieldName = getFieldName(validPath);
484
+ const distance = levenshteinDistance(fieldName, validFieldName);
485
+ if (distance <= maxDistance && distance > 0) {
486
+ suggestions.push({ path: validPath, distance });
487
+ }
488
+ }
489
+ return suggestions.sort((a, b) => a.distance - b.distance).slice(0, 3).map((s) => s.path);
490
+ }
491
+ function levenshteinDistance(a, b) {
492
+ const matrix = [];
493
+ for (let i = 0; i <= a.length; i++) {
494
+ matrix[i] = [i];
495
+ }
496
+ for (let j = 0; j <= b.length; j++) {
497
+ matrix[0][j] = j;
498
+ }
499
+ for (let i = 1; i <= a.length; i++) {
500
+ for (let j = 1; j <= b.length; j++) {
501
+ const cost = a[i - 1] === b[j - 1] ? 0 : 1;
502
+ matrix[i][j] = Math.min(
503
+ matrix[i - 1][j] + 1,
504
+ // deletion
505
+ matrix[i][j - 1] + 1,
506
+ // insertion
507
+ matrix[i - 1][j - 1] + cost
508
+ // substitution
509
+ );
510
+ }
511
+ }
512
+ return matrix[a.length][b.length];
513
+ }
514
+ function formatValidationWarnings(result, toolName) {
515
+ if (result.valid && result.warnings.length === 0) {
516
+ return "";
517
+ }
518
+ const lines = [];
519
+ if (result.errors.length > 0) {
520
+ lines.push(`[FrontMCP] Template validation warnings for tool "${toolName}":`);
521
+ lines.push("");
522
+ for (const error of result.errors) {
523
+ lines.push(` Line ${error.line}: ${error.expression}`);
524
+ lines.push(` ${error.message}`);
525
+ if (error.suggestions.length > 0) {
526
+ lines.push(` Did you mean: ${error.suggestions.join(", ")}?`);
527
+ }
528
+ lines.push("");
529
+ }
530
+ const outputFields = result.schemaPaths.filter((p) => p.startsWith("output.") && p.split(".").length === 2).map((p) => p.replace("output.", ""));
531
+ if (outputFields.length > 0) {
532
+ lines.push(` Available output fields: ${outputFields.join(", ")}`);
533
+ }
534
+ }
535
+ if (result.warnings.length > 0) {
536
+ if (lines.length > 0) lines.push("");
537
+ lines.push(` Warnings:`);
538
+ for (const warning of result.warnings) {
539
+ lines.push(` Line ${warning.line}: ${warning.message}`);
540
+ }
541
+ }
542
+ return lines.join("\n");
543
+ }
544
+ function logValidationWarnings(result, toolName) {
545
+ const formatted = formatValidationWarnings(result, toolName);
546
+ if (formatted) {
547
+ console.warn(formatted);
548
+ }
549
+ }
550
+ function assertTemplateValid(template, outputSchema, toolName) {
551
+ const result = validateTemplate(template, outputSchema);
552
+ if (!result.valid) {
553
+ const formatted = formatValidationWarnings(result, toolName);
554
+ throw new Error(`Template validation failed for tool "${toolName}":
555
+ ${formatted}`);
556
+ }
557
+ }
558
+ function isTemplateValid(template, outputSchema) {
559
+ const result = validateTemplate(template, outputSchema);
560
+ return result.valid;
561
+ }
562
+ function getMissingFields(template, outputSchema) {
563
+ const result = validateTemplate(template, outputSchema);
564
+ return result.errors.map((e) => e.path);
565
+ }
566
+ // Annotate the CommonJS export names for ESM import in node:
567
+ 0 && (module.exports = {
568
+ assertTemplateValid,
569
+ extractSchemaPaths,
570
+ formatValidationWarnings,
571
+ getMissingFields,
572
+ getPathInfo,
573
+ getRootFieldNames,
574
+ getSchemaPathStrings,
575
+ getTypeAtPath,
576
+ getTypeDescription,
577
+ isTemplateValid,
578
+ isValidSchemaPath,
579
+ logValidationWarnings,
580
+ validateOptions,
581
+ validateTemplate,
582
+ validationErrorBox
583
+ });
@@ -0,0 +1,118 @@
1
+ /**
2
+ * Schema Path Extractor
3
+ *
4
+ * Extracts valid paths from Zod schemas for template validation.
5
+ *
6
+ * @packageDocumentation
7
+ */
8
+ import { z } from 'zod';
9
+ /**
10
+ * Information about a path in a schema.
11
+ */
12
+ export interface SchemaPath {
13
+ /** The full path (e.g., "output.user.name") */
14
+ path: string;
15
+ /** The Zod type at this path */
16
+ zodType: z.ZodTypeAny;
17
+ /** Whether this path is optional */
18
+ optional: boolean;
19
+ /** Whether this path is nullable */
20
+ nullable: boolean;
21
+ /** Whether this is an array item path (contains []) */
22
+ isArrayItem: boolean;
23
+ /** Description from .describe() if present */
24
+ description?: string;
25
+ }
26
+ /**
27
+ * Options for path extraction.
28
+ */
29
+ export interface ExtractPathsOptions {
30
+ /** Maximum depth to recurse (default: 10) */
31
+ maxDepth?: number;
32
+ /** Include array item paths with [] notation */
33
+ includeArrayItems?: boolean;
34
+ }
35
+ /**
36
+ * Extract all valid paths from a Zod schema.
37
+ *
38
+ * @param schema - The Zod schema to extract paths from
39
+ * @param prefix - Path prefix (default: "output")
40
+ * @param options - Extraction options
41
+ * @returns Array of schema paths with metadata
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * const schema = z.object({
46
+ * temperature: z.number(),
47
+ * user: z.object({
48
+ * name: z.string(),
49
+ * email: z.string().optional(),
50
+ * }),
51
+ * });
52
+ *
53
+ * const paths = extractSchemaPaths(schema, 'output');
54
+ * // [
55
+ * // { path: 'output', ... },
56
+ * // { path: 'output.temperature', ... },
57
+ * // { path: 'output.user', ... },
58
+ * // { path: 'output.user.name', ... },
59
+ * // { path: 'output.user.email', optional: true, ... },
60
+ * // ]
61
+ * ```
62
+ */
63
+ export declare function extractSchemaPaths(schema: z.ZodTypeAny, prefix?: string, options?: ExtractPathsOptions): SchemaPath[];
64
+ /**
65
+ * Get just the path strings from a schema.
66
+ *
67
+ * @param schema - The Zod schema
68
+ * @param prefix - Path prefix (default: "output")
69
+ * @returns Set of valid path strings
70
+ */
71
+ export declare function getSchemaPathStrings(schema: z.ZodTypeAny, prefix?: string): Set<string>;
72
+ /**
73
+ * Check if a path exists in a schema.
74
+ *
75
+ * @param schema - The Zod schema
76
+ * @param path - The path to check
77
+ * @returns true if the path exists
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * const schema = z.object({ name: z.string() });
82
+ * isValidSchemaPath(schema, 'output.name'); // true
83
+ * isValidSchemaPath(schema, 'output.age'); // false
84
+ * ```
85
+ */
86
+ export declare function isValidSchemaPath(schema: z.ZodTypeAny, path: string): boolean;
87
+ /**
88
+ * Get the Zod type at a specific path.
89
+ *
90
+ * @param schema - The Zod schema
91
+ * @param path - The path to look up
92
+ * @returns The Zod type or undefined if not found
93
+ */
94
+ export declare function getTypeAtPath(schema: z.ZodTypeAny, path: string): z.ZodTypeAny | undefined;
95
+ /**
96
+ * Get schema path info at a specific path.
97
+ *
98
+ * @param schema - The Zod schema
99
+ * @param path - The path to look up
100
+ * @returns SchemaPath info or undefined if not found
101
+ */
102
+ export declare function getPathInfo(schema: z.ZodTypeAny, path: string): SchemaPath | undefined;
103
+ /**
104
+ * Get all field names at the root level of a schema.
105
+ *
106
+ * @param schema - The Zod schema (should be ZodObject)
107
+ * @returns Array of field names
108
+ */
109
+ export declare function getRootFieldNames(schema: z.ZodTypeAny): string[];
110
+ /**
111
+ * Get a human-readable type description for a path.
112
+ *
113
+ * @param schema - The Zod schema
114
+ * @param path - The path to describe
115
+ * @returns Human-readable type string
116
+ */
117
+ export declare function getTypeDescription(schema: z.ZodTypeAny, path: string): string;
118
+ //# sourceMappingURL=schema-paths.d.ts.map