@frontmcp/uipack 0.12.1 → 1.0.0-beta.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 (298) hide show
  1. package/CLAUDE.md +56 -154
  2. package/README.md +367 -62
  3. package/adapters/base-template.d.ts +30 -0
  4. package/adapters/base-template.d.ts.map +1 -0
  5. package/adapters/cdn-info.d.ts +34 -0
  6. package/adapters/cdn-info.d.ts.map +1 -0
  7. package/adapters/constants.d.ts +18 -0
  8. package/adapters/constants.d.ts.map +1 -0
  9. package/adapters/content-detector.d.ts +19 -0
  10. package/adapters/content-detector.d.ts.map +1 -0
  11. package/adapters/content-renderers.d.ts +27 -0
  12. package/adapters/content-renderers.d.ts.map +1 -0
  13. package/adapters/index.d.ts +14 -7
  14. package/adapters/index.d.ts.map +1 -1
  15. package/adapters/index.js +2343 -426
  16. package/adapters/render-failure.d.ts +18 -0
  17. package/adapters/render-failure.d.ts.map +1 -0
  18. package/adapters/response-builder.d.ts +34 -104
  19. package/adapters/response-builder.d.ts.map +1 -1
  20. package/adapters/serving-mode.d.ts +28 -91
  21. package/adapters/serving-mode.d.ts.map +1 -1
  22. package/adapters/template-renderer.d.ts +50 -0
  23. package/adapters/template-renderer.d.ts.map +1 -0
  24. package/adapters/type-detector.d.ts +18 -0
  25. package/adapters/type-detector.d.ts.map +1 -0
  26. package/bridge-runtime/index.js +1 -1
  27. package/component/index.d.ts +14 -0
  28. package/component/index.d.ts.map +1 -0
  29. package/component/index.js +2043 -0
  30. package/component/loader.d.ts +36 -0
  31. package/component/loader.d.ts.map +1 -0
  32. package/component/renderer.d.ts +30 -0
  33. package/component/renderer.d.ts.map +1 -0
  34. package/component/transpiler.d.ts +49 -0
  35. package/component/transpiler.d.ts.map +1 -0
  36. package/component/types.d.ts +82 -0
  37. package/component/types.d.ts.map +1 -0
  38. package/esm/adapters/index.mjs +2337 -422
  39. package/esm/bridge-runtime/index.mjs +1 -1
  40. package/esm/component/index.mjs +2013 -0
  41. package/esm/index.mjs +3446 -13935
  42. package/esm/package.json +3 -12
  43. package/esm/resolver/index.mjs +661 -0
  44. package/esm/shell/index.mjs +1406 -0
  45. package/esm/types/index.mjs +11 -11
  46. package/esm/utils/index.mjs +53 -8
  47. package/index.d.ts +12 -40
  48. package/index.d.ts.map +1 -1
  49. package/index.js +3579 -14218
  50. package/package.json +3 -12
  51. package/resolver/cdn-registry.d.ts +39 -0
  52. package/resolver/cdn-registry.d.ts.map +1 -0
  53. package/resolver/esm-sh.resolver.d.ts +54 -0
  54. package/resolver/esm-sh.resolver.d.ts.map +1 -0
  55. package/resolver/import-map.d.ts +47 -0
  56. package/resolver/import-map.d.ts.map +1 -0
  57. package/resolver/import-parser.d.ts +28 -0
  58. package/resolver/import-parser.d.ts.map +1 -0
  59. package/resolver/import-rewriter.d.ts +29 -0
  60. package/resolver/import-rewriter.d.ts.map +1 -0
  61. package/resolver/index.d.ts +15 -0
  62. package/resolver/index.d.ts.map +1 -0
  63. package/resolver/index.js +708 -0
  64. package/resolver/types.d.ts +191 -0
  65. package/resolver/types.d.ts.map +1 -0
  66. package/shell/builder.d.ts +31 -0
  67. package/shell/builder.d.ts.map +1 -0
  68. package/shell/csp.d.ts +37 -0
  69. package/shell/csp.d.ts.map +1 -0
  70. package/shell/custom-shell-applier.d.ts +33 -0
  71. package/shell/custom-shell-applier.d.ts.map +1 -0
  72. package/shell/custom-shell-resolver.d.ts +47 -0
  73. package/shell/custom-shell-resolver.d.ts.map +1 -0
  74. package/shell/custom-shell-types.d.ts +75 -0
  75. package/shell/custom-shell-types.d.ts.map +1 -0
  76. package/shell/custom-shell-validator.d.ts +26 -0
  77. package/shell/custom-shell-validator.d.ts.map +1 -0
  78. package/shell/data-injector.d.ts +40 -0
  79. package/shell/data-injector.d.ts.map +1 -0
  80. package/shell/index.d.ts +19 -0
  81. package/shell/index.d.ts.map +1 -0
  82. package/shell/index.js +1453 -0
  83. package/shell/types.d.ts +54 -0
  84. package/shell/types.d.ts.map +1 -0
  85. package/types/index.d.ts +1 -3
  86. package/types/index.d.ts.map +1 -1
  87. package/types/index.js +11 -11
  88. package/types/ui-config.d.ts +50 -11
  89. package/types/ui-config.d.ts.map +1 -1
  90. package/types/ui-runtime.d.ts +8 -82
  91. package/types/ui-runtime.d.ts.map +1 -1
  92. package/utils/index.d.ts +9 -3
  93. package/utils/index.d.ts.map +1 -1
  94. package/utils/index.js +59 -7
  95. package/adapters/platform-meta.constants.d.ts +0 -26
  96. package/adapters/platform-meta.constants.d.ts.map +0 -1
  97. package/adapters/platform-meta.d.ts +0 -234
  98. package/adapters/platform-meta.d.ts.map +0 -1
  99. package/base-template/bridge.d.ts +0 -90
  100. package/base-template/bridge.d.ts.map +0 -1
  101. package/base-template/default-base-template.d.ts +0 -91
  102. package/base-template/default-base-template.d.ts.map +0 -1
  103. package/base-template/index.d.ts +0 -15
  104. package/base-template/index.d.ts.map +0 -1
  105. package/base-template/index.js +0 -1393
  106. package/base-template/polyfills.d.ts +0 -31
  107. package/base-template/polyfills.d.ts.map +0 -1
  108. package/base-template/theme-styles.d.ts +0 -74
  109. package/base-template/theme-styles.d.ts.map +0 -1
  110. package/build/builders/base-builder.d.ts +0 -124
  111. package/build/builders/base-builder.d.ts.map +0 -1
  112. package/build/builders/esbuild-config.d.ts +0 -94
  113. package/build/builders/esbuild-config.d.ts.map +0 -1
  114. package/build/builders/hybrid-builder.d.ts +0 -93
  115. package/build/builders/hybrid-builder.d.ts.map +0 -1
  116. package/build/builders/index.d.ts +0 -17
  117. package/build/builders/index.d.ts.map +0 -1
  118. package/build/builders/inline-builder.d.ts +0 -83
  119. package/build/builders/inline-builder.d.ts.map +0 -1
  120. package/build/builders/static-builder.d.ts +0 -78
  121. package/build/builders/static-builder.d.ts.map +0 -1
  122. package/build/builders/types.d.ts +0 -341
  123. package/build/builders/types.d.ts.map +0 -1
  124. package/build/cdn-resources.d.ts +0 -244
  125. package/build/cdn-resources.d.ts.map +0 -1
  126. package/build/hybrid-data.d.ts +0 -127
  127. package/build/hybrid-data.d.ts.map +0 -1
  128. package/build/index.d.ts +0 -299
  129. package/build/index.d.ts.map +0 -1
  130. package/build/index.js +0 -8699
  131. package/build/ui-components-browser.d.ts +0 -64
  132. package/build/ui-components-browser.d.ts.map +0 -1
  133. package/build/widget-manifest.d.ts +0 -362
  134. package/build/widget-manifest.d.ts.map +0 -1
  135. package/bundler/cache.d.ts +0 -173
  136. package/bundler/cache.d.ts.map +0 -1
  137. package/bundler/file-cache/component-builder.d.ts +0 -167
  138. package/bundler/file-cache/component-builder.d.ts.map +0 -1
  139. package/bundler/file-cache/hash-calculator.d.ts +0 -155
  140. package/bundler/file-cache/hash-calculator.d.ts.map +0 -1
  141. package/bundler/file-cache/index.d.ts +0 -12
  142. package/bundler/file-cache/index.d.ts.map +0 -1
  143. package/bundler/file-cache/storage/filesystem.d.ts +0 -149
  144. package/bundler/file-cache/storage/filesystem.d.ts.map +0 -1
  145. package/bundler/file-cache/storage/index.d.ts +0 -11
  146. package/bundler/file-cache/storage/index.d.ts.map +0 -1
  147. package/bundler/file-cache/storage/interface.d.ts +0 -152
  148. package/bundler/file-cache/storage/interface.d.ts.map +0 -1
  149. package/bundler/file-cache/storage/redis.d.ts +0 -139
  150. package/bundler/file-cache/storage/redis.d.ts.map +0 -1
  151. package/bundler/index.d.ts +0 -35
  152. package/bundler/index.d.ts.map +0 -1
  153. package/bundler/index.js +0 -2953
  154. package/bundler/sandbox/enclave-adapter.d.ts +0 -121
  155. package/bundler/sandbox/enclave-adapter.d.ts.map +0 -1
  156. package/bundler/sandbox/executor.d.ts +0 -14
  157. package/bundler/sandbox/executor.d.ts.map +0 -1
  158. package/bundler/sandbox/policy.d.ts +0 -62
  159. package/bundler/sandbox/policy.d.ts.map +0 -1
  160. package/bundler/types.d.ts +0 -702
  161. package/bundler/types.d.ts.map +0 -1
  162. package/dependency/cdn-registry.d.ts +0 -98
  163. package/dependency/cdn-registry.d.ts.map +0 -1
  164. package/dependency/import-map.d.ts +0 -186
  165. package/dependency/import-map.d.ts.map +0 -1
  166. package/dependency/import-parser.d.ts +0 -82
  167. package/dependency/import-parser.d.ts.map +0 -1
  168. package/dependency/index.d.ts +0 -17
  169. package/dependency/index.d.ts.map +0 -1
  170. package/dependency/index.js +0 -3180
  171. package/dependency/resolver.d.ts +0 -164
  172. package/dependency/resolver.d.ts.map +0 -1
  173. package/dependency/schemas.d.ts +0 -486
  174. package/dependency/schemas.d.ts.map +0 -1
  175. package/dependency/template-loader.d.ts +0 -204
  176. package/dependency/template-loader.d.ts.map +0 -1
  177. package/dependency/template-processor.d.ts +0 -118
  178. package/dependency/template-processor.d.ts.map +0 -1
  179. package/dependency/types.d.ts +0 -739
  180. package/dependency/types.d.ts.map +0 -1
  181. package/esm/base-template/index.mjs +0 -1359
  182. package/esm/build/index.mjs +0 -8601
  183. package/esm/bundler/index.mjs +0 -2895
  184. package/esm/dependency/index.mjs +0 -3068
  185. package/esm/handlebars/index.mjs +0 -587
  186. package/esm/registry/index.mjs +0 -6305
  187. package/esm/renderers/index.mjs +0 -1557
  188. package/esm/runtime/index.mjs +0 -5361
  189. package/esm/styles/index.mjs +0 -171
  190. package/esm/theme/index.mjs +0 -756
  191. package/esm/tool-template/index.mjs +0 -3652
  192. package/esm/validation/index.mjs +0 -542
  193. package/handlebars/expression-extractor.d.ts +0 -147
  194. package/handlebars/expression-extractor.d.ts.map +0 -1
  195. package/handlebars/helpers.d.ts +0 -339
  196. package/handlebars/helpers.d.ts.map +0 -1
  197. package/handlebars/index.d.ts +0 -195
  198. package/handlebars/index.d.ts.map +0 -1
  199. package/handlebars/index.js +0 -659
  200. package/preview/claude-preview.d.ts +0 -67
  201. package/preview/claude-preview.d.ts.map +0 -1
  202. package/preview/generic-preview.d.ts +0 -66
  203. package/preview/generic-preview.d.ts.map +0 -1
  204. package/preview/index.d.ts +0 -36
  205. package/preview/index.d.ts.map +0 -1
  206. package/preview/openai-preview.d.ts +0 -70
  207. package/preview/openai-preview.d.ts.map +0 -1
  208. package/preview/types.d.ts +0 -199
  209. package/preview/types.d.ts.map +0 -1
  210. package/registry/index.d.ts +0 -46
  211. package/registry/index.d.ts.map +0 -1
  212. package/registry/index.js +0 -6342
  213. package/registry/render-template.d.ts +0 -91
  214. package/registry/render-template.d.ts.map +0 -1
  215. package/registry/tool-ui.registry.d.ts +0 -294
  216. package/registry/tool-ui.registry.d.ts.map +0 -1
  217. package/registry/uri-utils.d.ts +0 -56
  218. package/registry/uri-utils.d.ts.map +0 -1
  219. package/renderers/cache.d.ts +0 -145
  220. package/renderers/cache.d.ts.map +0 -1
  221. package/renderers/html.renderer.d.ts +0 -123
  222. package/renderers/html.renderer.d.ts.map +0 -1
  223. package/renderers/index.d.ts +0 -36
  224. package/renderers/index.d.ts.map +0 -1
  225. package/renderers/index.js +0 -1603
  226. package/renderers/mdx-client.renderer.d.ts +0 -124
  227. package/renderers/mdx-client.renderer.d.ts.map +0 -1
  228. package/renderers/registry.d.ts +0 -133
  229. package/renderers/registry.d.ts.map +0 -1
  230. package/renderers/types.d.ts +0 -343
  231. package/renderers/types.d.ts.map +0 -1
  232. package/renderers/utils/detect.d.ts +0 -107
  233. package/renderers/utils/detect.d.ts.map +0 -1
  234. package/renderers/utils/hash.d.ts +0 -40
  235. package/renderers/utils/hash.d.ts.map +0 -1
  236. package/renderers/utils/index.d.ts +0 -9
  237. package/renderers/utils/index.d.ts.map +0 -1
  238. package/renderers/utils/transpiler.d.ts +0 -70
  239. package/renderers/utils/transpiler.d.ts.map +0 -1
  240. package/runtime/adapters/html.adapter.d.ts +0 -59
  241. package/runtime/adapters/html.adapter.d.ts.map +0 -1
  242. package/runtime/adapters/index.d.ts +0 -26
  243. package/runtime/adapters/index.d.ts.map +0 -1
  244. package/runtime/adapters/mdx.adapter.d.ts +0 -73
  245. package/runtime/adapters/mdx.adapter.d.ts.map +0 -1
  246. package/runtime/adapters/types.d.ts +0 -95
  247. package/runtime/adapters/types.d.ts.map +0 -1
  248. package/runtime/csp.d.ts +0 -48
  249. package/runtime/csp.d.ts.map +0 -1
  250. package/runtime/index.d.ts +0 -17
  251. package/runtime/index.d.ts.map +0 -1
  252. package/runtime/index.js +0 -5432
  253. package/runtime/mcp-bridge.d.ts +0 -101
  254. package/runtime/mcp-bridge.d.ts.map +0 -1
  255. package/runtime/renderer-runtime.d.ts +0 -133
  256. package/runtime/renderer-runtime.d.ts.map +0 -1
  257. package/runtime/sanitizer.d.ts +0 -180
  258. package/runtime/sanitizer.d.ts.map +0 -1
  259. package/runtime/types.d.ts +0 -415
  260. package/runtime/types.d.ts.map +0 -1
  261. package/runtime/wrapper.d.ts +0 -421
  262. package/runtime/wrapper.d.ts.map +0 -1
  263. package/styles/index.d.ts +0 -8
  264. package/styles/index.d.ts.map +0 -1
  265. package/styles/index.js +0 -222
  266. package/styles/variants.d.ts +0 -51
  267. package/styles/variants.d.ts.map +0 -1
  268. package/theme/cdn.d.ts +0 -195
  269. package/theme/cdn.d.ts.map +0 -1
  270. package/theme/css-to-theme.d.ts +0 -64
  271. package/theme/css-to-theme.d.ts.map +0 -1
  272. package/theme/index.d.ts +0 -19
  273. package/theme/index.d.ts.map +0 -1
  274. package/theme/index.js +0 -814
  275. package/theme/platforms.d.ts +0 -102
  276. package/theme/platforms.d.ts.map +0 -1
  277. package/theme/presets/github-openai.d.ts +0 -50
  278. package/theme/presets/github-openai.d.ts.map +0 -1
  279. package/theme/presets/index.d.ts +0 -11
  280. package/theme/presets/index.d.ts.map +0 -1
  281. package/theme/theme.d.ts +0 -396
  282. package/theme/theme.d.ts.map +0 -1
  283. package/tool-template/builder.d.ts +0 -213
  284. package/tool-template/builder.d.ts.map +0 -1
  285. package/tool-template/index.d.ts +0 -16
  286. package/tool-template/index.d.ts.map +0 -1
  287. package/tool-template/index.js +0 -3690
  288. package/validation/error-box.d.ts +0 -56
  289. package/validation/error-box.d.ts.map +0 -1
  290. package/validation/index.d.ts +0 -13
  291. package/validation/index.d.ts.map +0 -1
  292. package/validation/index.js +0 -576
  293. package/validation/schema-paths.d.ts +0 -118
  294. package/validation/schema-paths.d.ts.map +0 -1
  295. package/validation/template-validator.d.ts +0 -143
  296. package/validation/template-validator.d.ts.map +0 -1
  297. package/validation/wrapper.d.ts +0 -97
  298. package/validation/wrapper.d.ts.map +0 -1
@@ -1,118 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema-paths.d.ts","sourceRoot":"","sources":["../../src/validation/schema-paths.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB;;GAEG;AACH,MAAM,WAAW,UAAU;IAC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CAQhE;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAK7E"}
@@ -1,143 +0,0 @@
1
- /**
2
- * Template Validator
3
- *
4
- * Validates Handlebars templates against Zod schemas to catch
5
- * references to non-existent fields.
6
- *
7
- * @packageDocumentation
8
- */
9
- import { z } from 'zod';
10
- /**
11
- * Validation error types.
12
- */
13
- export type ValidationErrorType = 'missing_field' | 'invalid_path' | 'type_mismatch';
14
- /**
15
- * Validation warning types.
16
- */
17
- export type ValidationWarningType = 'optional_field' | 'array_access' | 'deep_path' | 'dynamic_path';
18
- /**
19
- * A validation error for a missing or invalid field.
20
- */
21
- export interface TemplateValidationError {
22
- /** Error type */
23
- type: ValidationErrorType;
24
- /** The invalid path (e.g., "output.city") */
25
- path: string;
26
- /** The full Handlebars expression */
27
- expression: string;
28
- /** Line number in template */
29
- line: number;
30
- /** Column position */
31
- column: number;
32
- /** Human-readable error message */
33
- message: string;
34
- /** Suggested similar paths */
35
- suggestions: string[];
36
- }
37
- /**
38
- * A validation warning (non-blocking).
39
- */
40
- export interface TemplateValidationWarning {
41
- /** Warning type */
42
- type: ValidationWarningType;
43
- /** The path that triggered the warning */
44
- path: string;
45
- /** The full Handlebars expression */
46
- expression: string;
47
- /** Line number in template */
48
- line: number;
49
- /** Human-readable warning message */
50
- message: string;
51
- }
52
- /**
53
- * Result of template validation.
54
- */
55
- export interface TemplateValidationResult {
56
- /** Whether the template is valid (no errors) */
57
- valid: boolean;
58
- /** Validation errors (missing fields, etc.) */
59
- errors: TemplateValidationError[];
60
- /** Validation warnings (optional fields, etc.) */
61
- warnings: TemplateValidationWarning[];
62
- /** All paths found in the template */
63
- templatePaths: string[];
64
- /** All valid paths from the schema */
65
- schemaPaths: string[];
66
- }
67
- /**
68
- * Options for template validation.
69
- */
70
- export interface ValidateTemplateOptions {
71
- /** Schema for input.* paths (optional) */
72
- inputSchema?: z.ZodTypeAny;
73
- /** Warn when accessing optional fields without {{#if}} guard */
74
- warnOnOptional?: boolean;
75
- /** Suggest similar paths for typos */
76
- suggestSimilar?: boolean;
77
- /** Maximum Levenshtein distance for suggestions */
78
- maxSuggestionDistance?: number;
79
- /** Tool name for error messages */
80
- toolName?: string;
81
- }
82
- /**
83
- * Validate a Handlebars template against an output schema.
84
- *
85
- * @param template - The Handlebars template string
86
- * @param outputSchema - Zod schema for the output
87
- * @param options - Validation options
88
- * @returns Validation result with errors and warnings
89
- *
90
- * @example
91
- * ```typescript
92
- * const result = validateTemplate(
93
- * '<div>{{output.temperature}} in {{output.city}}</div>',
94
- * z.object({ temperature: z.number() })
95
- * );
96
- *
97
- * if (!result.valid) {
98
- * console.warn('Template has issues:', result.errors);
99
- * }
100
- * ```
101
- */
102
- export declare function validateTemplate(template: string, outputSchema: z.ZodTypeAny, options?: ValidateTemplateOptions): TemplateValidationResult;
103
- /**
104
- * Format validation result as console warnings.
105
- *
106
- * @param result - Validation result
107
- * @param toolName - Tool name for context
108
- * @returns Formatted warning string
109
- */
110
- export declare function formatValidationWarnings(result: TemplateValidationResult, toolName: string): string;
111
- /**
112
- * Log validation warnings to console in development mode.
113
- *
114
- * @param result - Validation result
115
- * @param toolName - Tool name for context
116
- */
117
- export declare function logValidationWarnings(result: TemplateValidationResult, toolName: string): void;
118
- /**
119
- * Validate template and throw if invalid.
120
- *
121
- * @param template - The template to validate
122
- * @param outputSchema - Output schema
123
- * @param toolName - Tool name for error message
124
- * @throws Error if template has validation errors
125
- */
126
- export declare function assertTemplateValid(template: string, outputSchema: z.ZodTypeAny, toolName: string): void;
127
- /**
128
- * Quickly check if a template is valid against a schema.
129
- *
130
- * @param template - The template to validate
131
- * @param outputSchema - Output schema
132
- * @returns true if valid, false otherwise
133
- */
134
- export declare function isTemplateValid(template: string, outputSchema: z.ZodTypeAny): boolean;
135
- /**
136
- * Get missing fields from a template.
137
- *
138
- * @param template - The template to check
139
- * @param outputSchema - Output schema
140
- * @returns Array of missing field paths
141
- */
142
- export declare function getMissingFields(template: string, outputSchema: z.ZodTypeAny): string[];
143
- //# sourceMappingURL=template-validator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"template-validator.d.ts","sourceRoot":"","sources":["../../src/validation/template-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,eAAe,GAAG,cAAc,GAAG,eAAe,CAAC;AAErF;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG,gBAAgB,GAAG,cAAc,GAAG,WAAW,GAAG,cAAc,CAAC;AAErG;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,iBAAiB;IACjB,IAAI,EAAE,mBAAmB,CAAC;IAC1B,6CAA6C;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,sBAAsB;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,mCAAmC;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,8BAA8B;IAC9B,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,mBAAmB;IACnB,IAAI,EAAE,qBAAqB,CAAC;IAC5B,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,gDAAgD;IAChD,KAAK,EAAE,OAAO,CAAC;IACf,+CAA+C;IAC/C,MAAM,EAAE,uBAAuB,EAAE,CAAC;IAClC,kDAAkD;IAClD,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GvF"}
@@ -1,97 +0,0 @@
1
- /**
2
- * @file wrapper.ts
3
- * @description Validation wrapper utilities for component input validation.
4
- *
5
- * Provides functions to validate component options against Zod schemas
6
- * and return either the validated data or an error box HTML string.
7
- *
8
- * @example
9
- * ```typescript
10
- * import { validateOptions } from '@frontmcp/ui';
11
- * import { z } from 'zod';
12
- *
13
- * const schema = z.object({ variant: z.enum(['primary', 'secondary']) });
14
- *
15
- * const result = validateOptions(options, {
16
- * componentName: 'Button',
17
- * schema,
18
- * });
19
- *
20
- * if (!result.success) return result.error; // Returns error box HTML
21
- *
22
- * // Use result.data safely
23
- * ```
24
- *
25
- * @module @frontmcp/ui/validation/wrapper
26
- */
27
- import { type ZodSchema } from 'zod';
28
- /**
29
- * Configuration for validation
30
- */
31
- export interface ValidationConfig {
32
- /** Name of the component being validated */
33
- componentName: string;
34
- /** Zod schema to validate against */
35
- schema: ZodSchema;
36
- }
37
- /**
38
- * Result of validation - either success with data or failure with error HTML
39
- */
40
- export type ValidationResult<T> = {
41
- success: true;
42
- data: T;
43
- } | {
44
- success: false;
45
- error: string;
46
- };
47
- /**
48
- * Validates input against a Zod schema
49
- *
50
- * Returns either:
51
- * - `{ success: true, data: T }` with validated/parsed data
52
- * - `{ success: false, error: string }` with error box HTML
53
- *
54
- * @param options - The options object to validate
55
- * @param config - Validation configuration (component name and schema)
56
- * @returns ValidationResult with either data or error HTML
57
- *
58
- * @example
59
- * ```typescript
60
- * const result = validateOptions({ variant: 'invalid' }, {
61
- * componentName: 'Button',
62
- * schema: ButtonOptionsSchema,
63
- * });
64
- *
65
- * if (!result.success) {
66
- * return result.error; // Error box HTML
67
- * }
68
- *
69
- * // result.data is typed and validated
70
- * ```
71
- */
72
- export declare function validateOptions<T>(options: unknown, config: ValidationConfig): ValidationResult<T>;
73
- /**
74
- * Higher-order function to wrap a component function with validation
75
- *
76
- * Creates a new function that validates the options before calling the
77
- * original component. If validation fails, returns the error box HTML
78
- * instead of calling the component.
79
- *
80
- * @param componentFn - The original component function
81
- * @param config - Validation configuration
82
- * @returns Wrapped function that validates before calling
83
- *
84
- * @example
85
- * ```typescript
86
- * const buttonImpl = (text: string, opts: ButtonOptions) => `<button>...</button>`;
87
- *
88
- * const button = withValidation(buttonImpl, {
89
- * componentName: 'Button',
90
- * schema: ButtonOptionsSchema,
91
- * });
92
- *
93
- * // button() now validates options before rendering
94
- * ```
95
- */
96
- export declare function withValidation<TInput, TOptions>(componentFn: (input: TInput, options: TOptions) => string, config: ValidationConfig): (input: TInput, options: unknown) => string;
97
- //# sourceMappingURL=wrapper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wrapper.d.ts","sourceRoot":"","sources":["../../src/validation/wrapper.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,KAAK,CAAC;AAOrC;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,4CAA4C;IAC5C,aAAa,EAAE,MAAM,CAAC;IACtB,qCAAqC;IACrC,MAAM,EAAE,SAAS,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAiBjG;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,gBAAgB,GAAG,gBAAgB,CAAC,CAAC,CAAC,CAiBlG;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,QAAQ,EAC7C,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,KAAK,MAAM,EACzD,MAAM,EAAE,gBAAgB,GACvB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,MAAM,CAU7C"}