@formspec/build 0.1.0-alpha.1 → 0.1.0-alpha.11

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 (108) hide show
  1. package/README.md +138 -0
  2. package/dist/__tests__/analyzer-edge-cases.test.d.ts +13 -0
  3. package/dist/__tests__/analyzer-edge-cases.test.d.ts.map +1 -0
  4. package/dist/__tests__/analyzer.test.d.ts +5 -0
  5. package/dist/__tests__/analyzer.test.d.ts.map +1 -0
  6. package/dist/__tests__/codegen.test.d.ts +5 -0
  7. package/dist/__tests__/codegen.test.d.ts.map +1 -0
  8. package/dist/__tests__/decorator-pipeline.test.d.ts +11 -0
  9. package/dist/__tests__/decorator-pipeline.test.d.ts.map +1 -0
  10. package/dist/__tests__/fixtures/edge-cases.d.ts +110 -0
  11. package/dist/__tests__/fixtures/edge-cases.d.ts.map +1 -0
  12. package/dist/__tests__/fixtures/example-a-builtins.d.ts +12 -0
  13. package/dist/__tests__/fixtures/example-a-builtins.d.ts.map +1 -0
  14. package/dist/__tests__/fixtures/example-b-decorators.d.ts +5 -0
  15. package/dist/__tests__/fixtures/example-b-decorators.d.ts.map +1 -0
  16. package/dist/__tests__/fixtures/example-b-extended.d.ts +5 -0
  17. package/dist/__tests__/fixtures/example-b-extended.d.ts.map +1 -0
  18. package/dist/__tests__/fixtures/example-c-custom.d.ts +5 -0
  19. package/dist/__tests__/fixtures/example-c-custom.d.ts.map +1 -0
  20. package/dist/__tests__/fixtures/example-c-decorators.d.ts +5 -0
  21. package/dist/__tests__/fixtures/example-c-decorators.d.ts.map +1 -0
  22. package/dist/__tests__/fixtures/example-d-mixed-decorators.d.ts +6 -0
  23. package/dist/__tests__/fixtures/example-d-mixed-decorators.d.ts.map +1 -0
  24. package/dist/__tests__/fixtures/example-e-decorators.d.ts +11 -0
  25. package/dist/__tests__/fixtures/example-e-decorators.d.ts.map +1 -0
  26. package/dist/__tests__/fixtures/example-e-no-namespace.d.ts +5 -0
  27. package/dist/__tests__/fixtures/example-e-no-namespace.d.ts.map +1 -0
  28. package/dist/__tests__/fixtures/example-interface-types.d.ts +102 -0
  29. package/dist/__tests__/fixtures/example-interface-types.d.ts.map +1 -0
  30. package/dist/__tests__/fixtures/example-jsdoc-constraints.d.ts +16 -0
  31. package/dist/__tests__/fixtures/example-jsdoc-constraints.d.ts.map +1 -0
  32. package/dist/__tests__/fixtures/example-nested-class.d.ts +45 -0
  33. package/dist/__tests__/fixtures/example-nested-class.d.ts.map +1 -0
  34. package/dist/__tests__/fixtures/sample-forms.d.ts +55 -0
  35. package/dist/__tests__/fixtures/sample-forms.d.ts.map +1 -0
  36. package/dist/__tests__/interface-types.test.d.ts +11 -0
  37. package/dist/__tests__/interface-types.test.d.ts.map +1 -0
  38. package/dist/__tests__/jsdoc-constraints.test.d.ts +10 -0
  39. package/dist/__tests__/jsdoc-constraints.test.d.ts.map +1 -0
  40. package/dist/analyzer/class-analyzer.d.ts +139 -0
  41. package/dist/analyzer/class-analyzer.d.ts.map +1 -0
  42. package/dist/analyzer/decorator-extractor.d.ts +78 -0
  43. package/dist/analyzer/decorator-extractor.d.ts.map +1 -0
  44. package/dist/analyzer/jsdoc-constraints.d.ts +47 -0
  45. package/dist/analyzer/jsdoc-constraints.d.ts.map +1 -0
  46. package/dist/analyzer/program.d.ts +53 -0
  47. package/dist/analyzer/program.d.ts.map +1 -0
  48. package/dist/analyzer/type-converter.d.ts +75 -0
  49. package/dist/analyzer/type-converter.d.ts.map +1 -0
  50. package/dist/browser.cjs +549 -0
  51. package/dist/browser.cjs.map +1 -0
  52. package/dist/browser.d.ts +56 -0
  53. package/dist/browser.d.ts.map +1 -0
  54. package/dist/browser.js +501 -0
  55. package/dist/browser.js.map +1 -0
  56. package/dist/build.d.ts +890 -0
  57. package/dist/cli.cjs +2267 -0
  58. package/dist/cli.cjs.map +1 -0
  59. package/dist/cli.js +2204 -103
  60. package/dist/cli.js.map +1 -1
  61. package/dist/codegen/index.d.ts +75 -0
  62. package/dist/codegen/index.d.ts.map +1 -0
  63. package/dist/generators/class-schema.d.ts +114 -0
  64. package/dist/generators/class-schema.d.ts.map +1 -0
  65. package/dist/generators/method-schema.d.ts +67 -0
  66. package/dist/generators/method-schema.d.ts.map +1 -0
  67. package/dist/index.cjs +2093 -0
  68. package/dist/index.cjs.map +1 -0
  69. package/dist/index.d.ts +11 -3
  70. package/dist/index.d.ts.map +1 -1
  71. package/dist/index.js +2024 -104
  72. package/dist/index.js.map +1 -1
  73. package/dist/internals.cjs +1345 -0
  74. package/dist/internals.cjs.map +1 -0
  75. package/dist/internals.d.ts +21 -0
  76. package/dist/internals.d.ts.map +1 -0
  77. package/dist/internals.js +1298 -0
  78. package/dist/internals.js.map +1 -0
  79. package/dist/json-schema/generator.d.ts.map +1 -1
  80. package/dist/json-schema/schema.d.ts +16 -0
  81. package/dist/json-schema/schema.d.ts.map +1 -0
  82. package/dist/json-schema/types.d.ts +28 -0
  83. package/dist/json-schema/types.d.ts.map +1 -1
  84. package/dist/ui-schema/generator.d.ts +15 -0
  85. package/dist/ui-schema/generator.d.ts.map +1 -1
  86. package/dist/ui-schema/schema.d.ts +357 -0
  87. package/dist/ui-schema/schema.d.ts.map +1 -0
  88. package/dist/ui-schema/types.d.ts +8 -73
  89. package/dist/ui-schema/types.d.ts.map +1 -1
  90. package/package.json +25 -7
  91. package/dist/__tests__/cli.test.js +0 -178
  92. package/dist/__tests__/cli.test.js.map +0 -1
  93. package/dist/__tests__/edge-cases.test.js +0 -209
  94. package/dist/__tests__/edge-cases.test.js.map +0 -1
  95. package/dist/__tests__/generator.test.js +0 -208
  96. package/dist/__tests__/generator.test.js.map +0 -1
  97. package/dist/__tests__/integration.test.js +0 -163
  98. package/dist/__tests__/integration.test.js.map +0 -1
  99. package/dist/__tests__/write-schemas.test.js +0 -196
  100. package/dist/__tests__/write-schemas.test.js.map +0 -1
  101. package/dist/json-schema/generator.js +0 -146
  102. package/dist/json-schema/generator.js.map +0 -1
  103. package/dist/json-schema/types.js +0 -7
  104. package/dist/json-schema/types.js.map +0 -1
  105. package/dist/ui-schema/generator.js +0 -150
  106. package/dist/ui-schema/generator.js.map +0 -1
  107. package/dist/ui-schema/types.js +0 -8
  108. package/dist/ui-schema/types.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/json-schema/schema.ts","../src/json-schema/generator.ts","../src/ui-schema/schema.ts","../src/ui-schema/generator.ts","../src/json-schema/types.ts","../src/analyzer/decorator-extractor.ts","../src/analyzer/jsdoc-constraints.ts","../src/analyzer/class-analyzer.ts","../src/analyzer/type-converter.ts","../src/analyzer/program.ts","../src/generators/class-schema.ts","../src/codegen/index.ts","../src/index.ts","../src/cli.ts"],"sourcesContent":["/**\n * Zod schemas for JSON Schema draft-07 output validation.\n *\n * These schemas cover the subset of JSON Schema draft-07 that FormSpec generates,\n * plus the FormSpec-specific `x-formspec-*` extension properties.\n *\n * @see https://json-schema.org/draft-07/schema\n */\n\nimport { z } from \"zod\";\nimport type { JSONSchema7 } from \"./types.js\";\n\n// =============================================================================\n// JSON Schema type enum\n// =============================================================================\n\n/**\n * Zod schema for JSON Schema primitive type strings.\n */\nexport const jsonSchemaTypeSchema = z.enum([\n \"string\",\n \"number\",\n \"integer\",\n \"boolean\",\n \"object\",\n \"array\",\n \"null\",\n]);\n\n// =============================================================================\n// JSON Schema draft-07 schema (recursive)\n// =============================================================================\n\n// We annotate with z.ZodType<JSONSchema7> for the recursive self-reference.\n// The @ts-expect-error is required because exactOptionalPropertyTypes:true causes\n// Zod's inferred output type for optional fields (`T | undefined`) to be\n// incompatible with the JSONSchema7 interface's exact optional fields (`T?`).\n// The runtime behavior is correct: z.optional() will strip `undefined` values\n// during parsing and correctly handle absent keys.\n//\n// @ts-expect-error -- exactOptionalPropertyTypes: Zod optional infers `T | undefined`\n// but JSONSchema7 uses exact optional `?:` which disallows explicit undefined.\nexport const jsonSchema7Schema: z.ZodType<JSONSchema7> = z.lazy(() =>\n z\n .object({\n $schema: z.string().optional(),\n $id: z.string().optional(),\n $ref: z.string().optional(),\n\n // Metadata\n title: z.string().optional(),\n description: z.string().optional(),\n deprecated: z.boolean().optional(),\n\n // Type\n type: z.union([jsonSchemaTypeSchema, z.array(jsonSchemaTypeSchema)]).optional(),\n\n // String validation\n minLength: z.number().optional(),\n maxLength: z.number().optional(),\n pattern: z.string().optional(),\n\n // Number validation\n minimum: z.number().optional(),\n maximum: z.number().optional(),\n exclusiveMinimum: z.number().optional(),\n exclusiveMaximum: z.number().optional(),\n\n // Enum\n enum: z\n .array(z.union([z.string(), z.number(), z.boolean(), z.null()]))\n .readonly()\n .optional(),\n const: z.union([z.string(), z.number(), z.boolean(), z.null()]).optional(),\n\n // Object\n properties: z.record(z.string(), jsonSchema7Schema).optional(),\n required: z.array(z.string()).optional(),\n additionalProperties: z.union([z.boolean(), jsonSchema7Schema]).optional(),\n\n // Array\n items: z.union([jsonSchema7Schema, z.array(jsonSchema7Schema)]).optional(),\n minItems: z.number().optional(),\n maxItems: z.number().optional(),\n\n // Composition\n allOf: z.array(jsonSchema7Schema).optional(),\n anyOf: z.array(jsonSchema7Schema).optional(),\n oneOf: z.array(jsonSchema7Schema).optional(),\n not: jsonSchema7Schema.optional(),\n\n // Conditional\n if: jsonSchema7Schema.optional(),\n then: jsonSchema7Schema.optional(),\n else: jsonSchema7Schema.optional(),\n\n // Format\n format: z.string().optional(),\n\n // Default\n default: z.unknown().optional(),\n\n // FormSpec extensions\n \"x-formspec-source\": z.string().optional(),\n \"x-formspec-params\": z.array(z.string()).readonly().optional(),\n \"x-formspec-schemaSource\": z.string().optional(),\n })\n // passthrough preserves arbitrary x-formspec-* extension properties\n // added by custom decorators without causing validation failures\n .passthrough()\n);\n","/**\n * JSON Schema generator for FormSpec forms.\n */\n\nimport type {\n FormElement,\n FormSpec,\n AnyField,\n Group,\n Conditional,\n ArrayField,\n ObjectField,\n} from \"@formspec/core\";\nimport type { JSONSchema7 } from \"./types.js\";\nimport { jsonSchema7Schema } from \"./schema.js\";\nimport { z } from \"zod\";\n\n/**\n * Parses a value through a Zod schema, converting validation errors to a descriptive Error.\n */\nfunction parseOrThrow<T>(schema: z.ZodType<T>, value: unknown, label: string): T {\n try {\n return schema.parse(value);\n } catch (error) {\n if (error instanceof z.ZodError) {\n throw new Error(\n `Generated ${label} failed validation:\\n${error.issues.map((i) => ` ${i.path.join(\".\")}: ${i.message}`).join(\"\\n\")}`\n );\n }\n throw error;\n }\n}\n\n/**\n * Generates JSON Schema for nested elements (used for array items and object properties).\n */\nfunction generateNestedSchema(elements: readonly FormElement[]): JSONSchema7 {\n const properties: Record<string, JSONSchema7> = {};\n const required: string[] = [];\n\n collectFields(elements, properties, required);\n\n // Deduplicate required array (can have duplicates when the same field is defined\n // in multiple branches/containers, e.g., repeated in different conditional branches)\n const uniqueRequired = [...new Set(required)];\n\n return {\n type: \"object\",\n properties,\n ...(uniqueRequired.length > 0 && { required: uniqueRequired }),\n };\n}\n\n/**\n * Converts a single field to its JSON Schema representation.\n */\nfunction fieldToJsonSchema(field: AnyField): JSONSchema7 {\n const base: JSONSchema7 = {};\n\n if (field.label !== undefined) {\n base.title = field.label;\n }\n\n switch (field._field) {\n case \"text\":\n return { ...base, type: \"string\" };\n\n case \"number\":\n return {\n ...base,\n type: \"number\",\n ...(field.min !== undefined && { minimum: field.min }),\n ...(field.max !== undefined && { maximum: field.max }),\n };\n\n case \"boolean\":\n return { ...base, type: \"boolean\" };\n\n case \"enum\": {\n const opts = field.options;\n const isObjectOptions =\n opts.length > 0 &&\n opts.every(\n (opt): opt is { id: string; label: string } =>\n typeof opt === \"object\" && \"id\" in opt && \"label\" in opt\n );\n if (isObjectOptions) {\n // Object options with id/label: use oneOf with const/title\n return {\n ...base,\n type: \"string\",\n oneOf: opts.map((o) => ({\n const: o.id,\n title: o.label,\n })),\n };\n }\n return { ...base, type: \"string\", enum: opts as readonly string[] };\n }\n\n case \"dynamic_enum\":\n // Dynamic enums are strings at the schema level\n // The actual options are resolved at runtime\n // x-formspec-source indicates the data source key\n // x-formspec-params indicates dependent field names for fetching options\n return {\n ...base,\n type: \"string\",\n \"x-formspec-source\": field.source,\n ...(field.params !== undefined &&\n field.params.length > 0 && { \"x-formspec-params\": field.params }),\n };\n\n case \"dynamic_schema\":\n // Dynamic schemas are objects with unknown properties\n // x-formspec-schemaSource indicates where to load the schema from\n return {\n ...base,\n type: \"object\",\n additionalProperties: true,\n \"x-formspec-schemaSource\": field.schemaSource,\n };\n\n case \"array\": {\n const arrayField = field as ArrayField<string, readonly FormElement[]>;\n return {\n ...base,\n type: \"array\",\n items: generateNestedSchema(arrayField.items),\n ...(arrayField.minItems !== undefined && { minItems: arrayField.minItems }),\n ...(arrayField.maxItems !== undefined && { maxItems: arrayField.maxItems }),\n };\n }\n\n case \"object\": {\n const objectField = field as ObjectField<string, readonly FormElement[]>;\n const nestedSchema = generateNestedSchema(objectField.properties);\n return {\n ...base,\n ...nestedSchema,\n };\n }\n\n default: {\n // Exhaustiveness check\n const _exhaustive: never = field;\n return _exhaustive;\n }\n }\n}\n\n/**\n * Visits all elements in a form tree, collecting fields and required fields.\n */\nfunction collectFields(\n elements: readonly FormElement[],\n properties: Record<string, JSONSchema7>,\n required: string[]\n): void {\n for (const element of elements) {\n switch (element._type) {\n case \"field\":\n properties[element.name] = fieldToJsonSchema(element);\n if (element.required === true) {\n required.push(element.name);\n }\n break;\n\n case \"group\":\n // Groups don't affect schema structure, just collect their children\n collectFields((element as Group<readonly FormElement[]>).elements, properties, required);\n break;\n\n case \"conditional\":\n // Conditional fields are still part of the schema\n // They're just hidden/shown in the UI\n collectFields(\n (element as Conditional<string, unknown, readonly FormElement[]>).elements,\n properties,\n required\n );\n break;\n }\n }\n}\n\n/**\n * Generates a JSON Schema from a FormSpec.\n *\n * @example\n * ```typescript\n * const form = formspec(\n * field.text(\"name\", { label: \"Name\", required: true }),\n * field.number(\"age\", { min: 0 }),\n * );\n *\n * const schema = generateJsonSchema(form);\n * // {\n * // $schema: \"https://json-schema.org/draft-07/schema#\",\n * // type: \"object\",\n * // properties: {\n * // name: { type: \"string\", title: \"Name\" },\n * // age: { type: \"number\", minimum: 0 }\n * // },\n * // required: [\"name\"]\n * // }\n * ```\n *\n * @param form - The FormSpec to convert\n * @returns A JSON Schema object\n */\nexport function generateJsonSchema<E extends readonly FormElement[]>(\n form: FormSpec<E>\n): JSONSchema7 {\n const properties: Record<string, JSONSchema7> = {};\n const required: string[] = [];\n\n collectFields(form.elements, properties, required);\n\n // Deduplicate required array (can have duplicates when the same field is defined\n // in multiple branches/containers, e.g., repeated in different conditional branches)\n const uniqueRequired = [...new Set(required)];\n\n const result: JSONSchema7 = {\n $schema: \"https://json-schema.org/draft-07/schema#\",\n type: \"object\",\n properties,\n ...(uniqueRequired.length > 0 && { required: uniqueRequired }),\n };\n\n return parseOrThrow(jsonSchema7Schema, result, \"JSON Schema\");\n}\n","/**\n * Zod schemas for JSON Forms UI Schema.\n *\n * These schemas are the source of truth for UI Schema validation.\n * TypeScript types are derived from these schemas via `z.infer<>`.\n *\n * @see https://jsonforms.io/docs/uischema/\n */\n\nimport { z } from \"zod\";\n\n// =============================================================================\n// Primitive helpers\n// =============================================================================\n\n/** JSON Pointer string (e.g., \"#/properties/fieldName\") */\nconst jsonPointerSchema = z.string();\n\n// =============================================================================\n// Rule Effect and Element Type enums\n// =============================================================================\n\n/**\n * Zod schema for rule effect values.\n */\nexport const ruleEffectSchema = z.enum([\"SHOW\", \"HIDE\", \"ENABLE\", \"DISABLE\"]);\n\n/**\n * Rule effect types for conditional visibility.\n */\nexport type RuleEffect = z.infer<typeof ruleEffectSchema>;\n\n/**\n * Zod schema for UI Schema element type strings.\n */\nexport const uiSchemaElementTypeSchema = z.enum([\n \"Control\",\n \"VerticalLayout\",\n \"HorizontalLayout\",\n \"Group\",\n \"Categorization\",\n \"Category\",\n \"Label\",\n]);\n\n/**\n * UI Schema element types.\n */\nexport type UISchemaElementType = z.infer<typeof uiSchemaElementTypeSchema>;\n\n// =============================================================================\n// Rule Condition Schema (recursive)\n// =============================================================================\n\n// Forward-declare the recursive TypeScript type.\n// We use an interface here (rather than z.infer<>) because the recursive\n// z.lazy() type annotation requires us to pre-declare the shape.\n/**\n * JSON Schema subset used in rule conditions.\n */\nexport interface RuleConditionSchema {\n const?: unknown;\n enum?: readonly unknown[];\n type?: string;\n not?: RuleConditionSchema;\n minimum?: number;\n maximum?: number;\n exclusiveMinimum?: number;\n exclusiveMaximum?: number;\n minLength?: number;\n properties?: Record<string, RuleConditionSchema>;\n required?: string[];\n allOf?: RuleConditionSchema[];\n}\n\n// Build the Zod schema referencing the pre-declared interface.\n// We use z.ZodType<RuleConditionSchema> so the recursive reference works.\n// The interface uses `?` (exact optional), and z.ZodType checks output only,\n// so the optional fields (which Zod infers as `T | undefined`) are compatible\n// because `T | undefined` is assignable to the optional field slot.\n//\n// @ts-expect-error -- exactOptionalPropertyTypes: the Zod output type for optional\n// fields is `T | undefined`, but our interface uses `?` (exact optional, key may\n// be absent). This is a known mismatch when using z.ZodType<T> with\n// exactOptionalPropertyTypes:true; the runtime behavior is correct.\nexport const ruleConditionSchema: z.ZodType<RuleConditionSchema> = z.lazy(() =>\n z\n .object({\n const: z.unknown().optional(),\n enum: z.array(z.unknown()).readonly().optional(),\n type: z.string().optional(),\n not: ruleConditionSchema.optional(),\n minimum: z.number().optional(),\n maximum: z.number().optional(),\n exclusiveMinimum: z.number().optional(),\n exclusiveMaximum: z.number().optional(),\n minLength: z.number().optional(),\n properties: z.record(z.string(), ruleConditionSchema).optional(),\n required: z.array(z.string()).optional(),\n allOf: z.array(ruleConditionSchema).optional(),\n })\n .strict()\n);\n\n// =============================================================================\n// Schema-Based Condition and Rule\n// =============================================================================\n\n/**\n * Zod schema for a schema-based rule condition.\n */\nexport const schemaBasedConditionSchema = z\n .object({\n scope: jsonPointerSchema,\n schema: ruleConditionSchema,\n })\n .strict();\n\n/**\n * Condition for a rule.\n */\nexport type SchemaBasedCondition = z.infer<typeof schemaBasedConditionSchema>;\n\n/**\n * Zod schema for a UI Schema rule.\n */\nexport const ruleSchema = z\n .object({\n effect: ruleEffectSchema,\n condition: schemaBasedConditionSchema,\n })\n .strict();\n\n/**\n * Rule for conditional element visibility/enablement.\n */\nexport type Rule = z.infer<typeof ruleSchema>;\n\n// =============================================================================\n// UI Schema Element Schemas (recursive via z.lazy)\n// =============================================================================\n\n// Forward-declare UISchemaElement so layout schemas can reference it.\n// We declare the type up-front and wire the Zod schema below.\n/**\n * Union of all UI Schema element types.\n */\nexport type UISchemaElement =\n | ControlElement\n | VerticalLayout\n | HorizontalLayout\n | GroupLayout\n | Categorization\n | Category\n | LabelElement;\n\n// The Zod schema for UISchemaElement is defined as a const using z.lazy(),\n// which defers evaluation until first use. This allows all element schemas\n// below to be referenced even though they are declared after this line.\nexport const uiSchemaElementSchema: z.ZodType<UISchemaElement> = z.lazy(() =>\n z.union([\n controlSchema,\n verticalLayoutSchema,\n horizontalLayoutSchema,\n groupLayoutSchema,\n categorizationSchema,\n categorySchema,\n labelElementSchema,\n ])\n) as z.ZodType<UISchemaElement>;\n\n// -----------------------------------------------------------------------------\n// Control\n// -----------------------------------------------------------------------------\n\n/**\n * Zod schema for a Control element.\n */\nexport const controlSchema = z\n .object({\n type: z.literal(\"Control\"),\n scope: jsonPointerSchema,\n label: z.union([z.string(), z.literal(false)]).optional(),\n rule: ruleSchema.optional(),\n options: z.record(z.string(), z.unknown()).optional(),\n })\n .passthrough();\n\n/**\n * A Control element that binds to a JSON Schema property.\n */\nexport type ControlElement = z.infer<typeof controlSchema>;\n\n// -----------------------------------------------------------------------------\n// VerticalLayout\n// -----------------------------------------------------------------------------\n\n// Pre-declare the interface so the Zod schema can reference UISchemaElement.\n/**\n * A vertical layout element.\n */\nexport interface VerticalLayout {\n type: \"VerticalLayout\";\n elements: UISchemaElement[];\n rule?: Rule | undefined;\n options?: Record<string, unknown> | undefined;\n [k: string]: unknown;\n}\n\nexport const verticalLayoutSchema: z.ZodType<VerticalLayout> = z.lazy(() =>\n z\n .object({\n type: z.literal(\"VerticalLayout\"),\n elements: z.array(uiSchemaElementSchema),\n rule: ruleSchema.optional(),\n options: z.record(z.string(), z.unknown()).optional(),\n })\n .passthrough()\n);\n\n// -----------------------------------------------------------------------------\n// HorizontalLayout\n// -----------------------------------------------------------------------------\n\n/**\n * A horizontal layout element.\n */\nexport interface HorizontalLayout {\n type: \"HorizontalLayout\";\n elements: UISchemaElement[];\n rule?: Rule | undefined;\n options?: Record<string, unknown> | undefined;\n [k: string]: unknown;\n}\n\nexport const horizontalLayoutSchema: z.ZodType<HorizontalLayout> = z.lazy(() =>\n z\n .object({\n type: z.literal(\"HorizontalLayout\"),\n elements: z.array(uiSchemaElementSchema),\n rule: ruleSchema.optional(),\n options: z.record(z.string(), z.unknown()).optional(),\n })\n .passthrough()\n);\n\n// -----------------------------------------------------------------------------\n// GroupLayout\n// -----------------------------------------------------------------------------\n\n/**\n * A group element with a label.\n */\nexport interface GroupLayout {\n type: \"Group\";\n label: string;\n elements: UISchemaElement[];\n rule?: Rule | undefined;\n options?: Record<string, unknown> | undefined;\n [k: string]: unknown;\n}\n\nexport const groupLayoutSchema: z.ZodType<GroupLayout> = z.lazy(() =>\n z\n .object({\n type: z.literal(\"Group\"),\n label: z.string(),\n elements: z.array(uiSchemaElementSchema),\n rule: ruleSchema.optional(),\n options: z.record(z.string(), z.unknown()).optional(),\n })\n .passthrough()\n);\n\n// -----------------------------------------------------------------------------\n// Category\n// -----------------------------------------------------------------------------\n\n/**\n * A Category element, used inside a Categorization layout.\n */\nexport interface Category {\n type: \"Category\";\n label: string;\n elements: UISchemaElement[];\n rule?: Rule | undefined;\n options?: Record<string, unknown> | undefined;\n [k: string]: unknown;\n}\n\nexport const categorySchema: z.ZodType<Category> = z.lazy(() =>\n z\n .object({\n type: z.literal(\"Category\"),\n label: z.string(),\n elements: z.array(uiSchemaElementSchema),\n rule: ruleSchema.optional(),\n options: z.record(z.string(), z.unknown()).optional(),\n })\n .passthrough()\n);\n\n// -----------------------------------------------------------------------------\n// Categorization\n// -----------------------------------------------------------------------------\n\n/**\n * A Categorization element (tab-based layout).\n */\nexport interface Categorization {\n type: \"Categorization\";\n elements: Category[];\n label?: string | undefined;\n rule?: Rule | undefined;\n options?: Record<string, unknown> | undefined;\n [k: string]: unknown;\n}\n\nexport const categorizationSchema: z.ZodType<Categorization> = z.lazy(() =>\n z\n .object({\n type: z.literal(\"Categorization\"),\n elements: z.array(categorySchema),\n label: z.string().optional(),\n rule: ruleSchema.optional(),\n options: z.record(z.string(), z.unknown()).optional(),\n })\n .passthrough()\n);\n\n// -----------------------------------------------------------------------------\n// LabelElement\n// -----------------------------------------------------------------------------\n\n/**\n * Zod schema for a Label element.\n */\nexport const labelElementSchema = z\n .object({\n type: z.literal(\"Label\"),\n text: z.string(),\n rule: ruleSchema.optional(),\n options: z.record(z.string(), z.unknown()).optional(),\n })\n .passthrough();\n\n/**\n * A Label element for displaying static text.\n */\nexport type LabelElement = z.infer<typeof labelElementSchema>;\n\n// =============================================================================\n// Root UISchema\n// =============================================================================\n\n/**\n * Root UI Schema (always a layout — not a Control, Category, or Label).\n */\nexport type UISchema = VerticalLayout | HorizontalLayout | GroupLayout | Categorization;\n\n/**\n * Zod schema for the root UI Schema (layout types only).\n */\nexport const uiSchema: z.ZodType<UISchema> = z.lazy(() =>\n z.union([verticalLayoutSchema, horizontalLayoutSchema, groupLayoutSchema, categorizationSchema])\n) as z.ZodType<UISchema>;\n","/**\n * JSON Forms UI Schema generator for FormSpec forms.\n */\n\nimport type { FormElement, FormSpec, Group, Conditional } from \"@formspec/core\";\nimport type { UISchemaElement, UISchema, ControlElement, GroupLayout, Rule } from \"./types.js\";\nimport { uiSchema as uiSchemaValidator } from \"./schema.js\";\nimport type { FormSpecField } from \"../analyzer/type-converter.js\";\nimport { z } from \"zod\";\n\n/**\n * Parses a value through a Zod schema, converting validation errors to a descriptive Error.\n */\nfunction parseOrThrow<T>(schema: z.ZodType<T>, value: unknown, label: string): T {\n try {\n return schema.parse(value);\n } catch (error) {\n if (error instanceof z.ZodError) {\n throw new Error(\n `Generated ${label} failed validation:\\n${error.issues.map((i) => ` ${i.path.join(\".\")}: ${i.message}`).join(\"\\n\")}`\n );\n }\n throw error;\n }\n}\n\n/**\n * Converts a field name to a JSON Pointer scope.\n */\nfunction fieldToScope(fieldName: string): string {\n return `#/properties/${fieldName}`;\n}\n\n/**\n * Creates a rule for conditional visibility.\n */\nfunction createShowRule(fieldName: string, value: unknown): Rule {\n return {\n effect: \"SHOW\",\n condition: {\n scope: fieldToScope(fieldName),\n schema: { const: value },\n },\n };\n}\n\n/**\n * Combines two rules into one using allOf.\n *\n * When elements are nested inside multiple conditionals, all conditions\n * must be met for the element to be visible.\n */\nfunction combineRules(parentRule: Rule, childRule: Rule): Rule {\n // Both rules should have the same effect (SHOW)\n // Combine conditions using allOf\n const parentCondition = parentRule.condition;\n const childCondition = childRule.condition;\n\n return {\n effect: \"SHOW\",\n condition: {\n scope: \"#\",\n schema: {\n allOf: [\n {\n properties: {\n [parentCondition.scope.replace(\"#/properties/\", \"\")]: parentCondition.schema,\n },\n },\n {\n properties: {\n [childCondition.scope.replace(\"#/properties/\", \"\")]: childCondition.schema,\n },\n },\n ],\n },\n },\n };\n}\n\n/**\n * Converts form elements to UI Schema elements.\n *\n * @param elements - The form elements to convert\n * @param parentRule - Optional rule inherited from parent conditional\n * @returns Array of UI Schema elements\n */\nfunction elementsToUiSchema(\n elements: readonly FormElement[],\n parentRule?: Rule\n): UISchemaElement[] {\n const result: UISchemaElement[] = [];\n\n for (const element of elements) {\n switch (element._type) {\n case \"field\": {\n const control: ControlElement = {\n type: \"Control\",\n scope: fieldToScope(element.name),\n ...(element.label !== undefined && { label: element.label }),\n ...(parentRule !== undefined && { rule: parentRule }),\n };\n result.push(control);\n break;\n }\n\n case \"group\": {\n const groupElement = element as Group<readonly FormElement[]>;\n const group: GroupLayout = {\n type: \"Group\",\n label: groupElement.label,\n elements: elementsToUiSchema(groupElement.elements, parentRule),\n ...(parentRule !== undefined && { rule: parentRule }),\n };\n result.push(group);\n break;\n }\n\n case \"conditional\": {\n const conditionalElement = element as Conditional<string, unknown, readonly FormElement[]>;\n // Create a rule for this conditional\n const newRule = createShowRule(conditionalElement.field, conditionalElement.value);\n // Combine with parent rule if present (for nested conditionals)\n const combinedRule = parentRule !== undefined ? combineRules(parentRule, newRule) : newRule;\n // Apply the combined rule to all children\n const childElements = elementsToUiSchema(conditionalElement.elements, combinedRule);\n result.push(...childElements);\n break;\n }\n }\n }\n\n return result;\n}\n\n/**\n * Converts a single FormSpecField to a ControlElement, resolving showWhen into a rule.\n *\n * @param field - The FormSpecField to convert\n * @param scopePrefix - The JSON Pointer prefix for the field's scope\n * @returns A ControlElement\n */\nfunction formSpecFieldToElement(\n field: FormSpecField,\n scopePrefix = \"#/properties\"\n): ControlElement {\n const control: ControlElement = {\n type: \"Control\",\n scope: `${scopePrefix}/${field.id}`,\n };\n\n if (field.label !== undefined) {\n control.label = field.label;\n }\n\n if (\n field.showWhen !== undefined &&\n typeof field.showWhen === \"object\" &&\n \"field\" in field.showWhen &&\n \"value\" in field.showWhen\n ) {\n const sw = field.showWhen as { field: string; value: unknown };\n control.rule = {\n effect: \"SHOW\",\n condition: {\n scope: `#/properties/${sw.field}`,\n schema: { const: sw.value },\n },\n };\n }\n\n return control;\n}\n\n/**\n * Converts FormSpecField[] (from decorator/interface/type analysis) to a JSON Forms UISchema.\n *\n * Mapping:\n * - Each field → `{ type: \"Control\", scope: \"#/properties/{id}\", label? }`\n * - `showWhen: { field, value }` → rule with SHOW effect\n * - `group` property → Groups fields by group name, preserving insertion order\n * - `fields` (nested object) → single Control pointing to the object property\n * - Root wrapper → `{ type: \"VerticalLayout\", elements }`\n *\n * @param fields - The FormSpecField array to convert\n * @returns A JSON Forms UISchema\n */\nexport function generateUiSchemaFromFields(fields: FormSpecField[]): UISchema {\n // Collect elements, grouping by the `group` property.\n // Map preserves insertion order — first occurrence of a group name determines its position.\n const groupMap = new Map<string, ControlElement[]>();\n const orderedKeys: (string | null)[] = []; // null = ungrouped slot\n const ungrouped: ControlElement[] = [];\n\n for (const field of fields) {\n const element = formSpecFieldToElement(field);\n\n if (field.group !== undefined) {\n if (!groupMap.has(field.group)) {\n groupMap.set(field.group, []);\n orderedKeys.push(field.group);\n }\n // We know the key exists since we just set it above.\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n groupMap.get(field.group)!.push(element);\n } else {\n // Track position for ungrouped fields relative to grouped fields.\n // Use a sentinel to mark the slot for ungrouped elements inline.\n orderedKeys.push(null);\n ungrouped.push(element);\n }\n }\n\n // Build the flat elements list respecting insertion order.\n const elements: UISchemaElement[] = [];\n let ungroupedIndex = 0;\n\n for (const key of orderedKeys) {\n if (key === null) {\n // Ungrouped field — emit directly.\n const el = ungrouped[ungroupedIndex++];\n if (el !== undefined) {\n elements.push(el);\n }\n } else {\n // Each group key appears in orderedKeys exactly once (guarded by\n // `!groupMap.has()` above), so we emit the Group element directly.\n const groupElements = groupMap.get(key) ?? [];\n const groupLayout: GroupLayout = {\n type: \"Group\",\n label: key,\n elements: groupElements,\n };\n elements.push(groupLayout);\n }\n }\n\n const result: UISchema = {\n type: \"VerticalLayout\",\n elements,\n };\n\n return parseOrThrow(uiSchemaValidator, result, \"UI Schema\");\n}\n\n/**\n * Generates a JSON Forms UI Schema from a FormSpec.\n *\n * @example\n * ```typescript\n * const form = formspec(\n * group(\"Customer\",\n * field.text(\"name\", { label: \"Name\" }),\n * ),\n * when(\"status\", \"draft\",\n * field.text(\"notes\", { label: \"Notes\" }),\n * ),\n * );\n *\n * const uiSchema = generateUiSchema(form);\n * // {\n * // type: \"VerticalLayout\",\n * // elements: [\n * // {\n * // type: \"Group\",\n * // label: \"Customer\",\n * // elements: [\n * // { type: \"Control\", scope: \"#/properties/name\", label: \"Name\" }\n * // ]\n * // },\n * // {\n * // type: \"Control\",\n * // scope: \"#/properties/notes\",\n * // label: \"Notes\",\n * // rule: {\n * // effect: \"SHOW\",\n * // condition: { scope: \"#/properties/status\", schema: { const: \"draft\" } }\n * // }\n * // }\n * // ]\n * // }\n * ```\n *\n * @param form - The FormSpec to convert\n * @returns A JSON Forms UI Schema\n */\nexport function generateUiSchema<E extends readonly FormElement[]>(form: FormSpec<E>): UISchema {\n const result: UISchema = {\n type: \"VerticalLayout\",\n elements: elementsToUiSchema(form.elements),\n };\n\n return parseOrThrow(uiSchemaValidator, result, \"UI Schema\");\n}\n","/**\n * JSON Schema Draft-07 type definitions.\n *\n * These types are a subset of JSON Schema sufficient for form generation.\n */\n\n/**\n * JSON Schema primitive types.\n */\nexport type JSONSchemaType =\n | \"string\"\n | \"number\"\n | \"integer\"\n | \"boolean\"\n | \"object\"\n | \"array\"\n | \"null\";\n\n/**\n * A JSON Schema definition (draft-07 subset).\n */\nexport interface JSONSchema7 {\n $schema?: string;\n $id?: string;\n $ref?: string;\n\n // Metadata\n title?: string;\n description?: string;\n deprecated?: boolean;\n\n // Type\n type?: JSONSchemaType | JSONSchemaType[];\n\n // String validation\n minLength?: number;\n maxLength?: number;\n pattern?: string;\n\n // Number validation\n minimum?: number;\n maximum?: number;\n exclusiveMinimum?: number;\n exclusiveMaximum?: number;\n\n // Enum\n enum?: readonly (string | number | boolean | null)[];\n const?: string | number | boolean | null;\n\n // Object\n properties?: Record<string, JSONSchema7>;\n required?: string[];\n additionalProperties?: boolean | JSONSchema7;\n\n // Array\n items?: JSONSchema7 | JSONSchema7[];\n minItems?: number;\n maxItems?: number;\n\n // Composition\n allOf?: JSONSchema7[];\n anyOf?: JSONSchema7[];\n oneOf?: JSONSchema7[];\n not?: JSONSchema7;\n\n // Conditional\n if?: JSONSchema7;\n then?: JSONSchema7;\n else?: JSONSchema7;\n\n // Format\n format?: string;\n\n // Default\n default?: unknown;\n\n // =============================================================================\n // FormSpec Extensions (x- prefixed)\n // =============================================================================\n\n /**\n * Data source key for dynamic enum fields.\n * Indicates that options should be fetched from a registered resolver.\n */\n \"x-formspec-source\"?: string;\n\n /**\n * Field names whose values are needed to fetch dynamic enum options.\n * Used for dependent/cascading dropdowns.\n */\n \"x-formspec-params\"?: readonly string[];\n\n /**\n * Schema source identifier for dynamic schema fields.\n * Indicates that the schema should be loaded dynamically at runtime.\n */\n \"x-formspec-schemaSource\"?: string;\n}\n\n/** Extension properties for custom FormSpec decorators. */\nexport type FormSpecSchemaExtensions = Record<`x-formspec-${string}`, unknown>;\n\n/** JSON Schema with FormSpec extension properties for arbitrary x-formspec-* keys. */\nexport type ExtendedJSONSchema7 = JSONSchema7 & FormSpecSchemaExtensions;\n\n/**\n * Sets a FormSpec extension property on a JSON Schema node.\n *\n * Use this to safely add `x-formspec-*` properties to any schema,\n * including nested schemas typed as `JSONSchema7` (which don't carry\n * the extension index signature).\n *\n * @param schema - Any JSON Schema node\n * @param key - Extension key (must start with `x-formspec-`)\n * @param value - Extension value\n */\nexport function setSchemaExtension(\n schema: JSONSchema7,\n key: `x-formspec-${string}`,\n value: unknown\n): void {\n (schema as ExtendedJSONSchema7)[key] = value;\n}\n\n/**\n * Reads a FormSpec extension property from a JSON Schema node.\n *\n * Use this to safely read `x-formspec-*` properties from any schema,\n * including nested schemas typed as `JSONSchema7`.\n *\n * @param schema - Any JSON Schema node\n * @param key - Extension key (must start with `x-formspec-`)\n * @returns The extension value, or `undefined` if not present\n */\nexport function getSchemaExtension(schema: JSONSchema7, key: `x-formspec-${string}`): unknown {\n return (schema as ExtendedJSONSchema7)[key];\n}\n","/**\n * Decorator extractor for parsing decorator AST nodes.\n *\n * Extracts decorator names and arguments from class field decorators,\n * supporting the FormSpec decorator DSL (@Field, @Minimum, @Maximum, etc.).\n *\n * Also supports branded type resolution via the TypeScript type checker\n * to detect custom decorators created with `extendDecorator` and\n * `customDecorator` from `@formspec/decorators`.\n */\n\nimport * as ts from \"typescript\";\nimport { type FormSpecDecoratorName } from \"@formspec/core\";\n\n/**\n * Extracted decorator information.\n */\nexport interface DecoratorInfo {\n /** Decorator name (e.g., \"Field\", \"Minimum\") */\n name: string;\n /** Decorator arguments as literal values */\n args: DecoratorArg[];\n /** Raw AST node for the decorator (undefined for synthetic JSDoc constraint entries) */\n node: ts.Decorator | undefined;\n /** Resolved brand information from the type checker (populated by analyzeField) */\n resolved?: ResolvedDecorator;\n}\n\n/**\n * A decorator argument value.\n * Can be a primitive, array, or object literal.\n */\nexport type DecoratorArg =\n | string\n | number\n | boolean\n | null\n | DecoratorArg[]\n | { [key: string]: DecoratorArg };\n\n/**\n * Result of resolving a decorator via the type checker.\n */\nexport interface ResolvedDecorator {\n /** Decorator name as it appears in source */\n name: string;\n /** If this extends a built-in, the built-in name (e.g., \"Field\") */\n extendsBuiltin?: string;\n /** If this belongs to a CLI extension namespace, the namespace name */\n extensionName?: string;\n /** Whether this is a known FormSpec decorator (built-in or factory-created) */\n isFormSpec: boolean;\n /** Whether this is a marker (zero-arg) decorator */\n isMarker: boolean;\n}\n\n/**\n * Extracts decorators from a class member (property or method).\n *\n * @param member - The class member to extract decorators from\n * @returns Array of extracted decorator info\n */\nexport function extractDecorators(\n member: ts.PropertyDeclaration | ts.MethodDeclaration\n): DecoratorInfo[] {\n const decorators: DecoratorInfo[] = [];\n\n // TC39 decorators are in the modifiers array\n const modifiers = ts.canHaveDecorators(member) ? ts.getDecorators(member) : undefined;\n\n if (!modifiers) return decorators;\n\n for (const decorator of modifiers) {\n const info = parseDecorator(decorator);\n if (info) {\n decorators.push(info);\n }\n }\n\n return decorators;\n}\n\n/**\n * Parses a single decorator node.\n */\nfunction parseDecorator(decorator: ts.Decorator): DecoratorInfo | null {\n const expr = decorator.expression;\n\n // Simple decorator: @Decorator\n if (ts.isIdentifier(expr)) {\n return {\n name: expr.text,\n args: [],\n node: decorator,\n };\n }\n\n // Call expression: @Decorator(args)\n if (ts.isCallExpression(expr)) {\n const callee = expr.expression;\n\n // Get decorator name\n let name: string | null = null;\n if (ts.isIdentifier(callee)) {\n name = callee.text;\n } else if (ts.isPropertyAccessExpression(callee)) {\n // For namespaced decorators like @formspec.Field()\n name = callee.name.text;\n }\n\n if (!name) return null;\n\n // Extract arguments\n const args = expr.arguments.map(extractArgValue);\n\n return {\n name,\n args,\n node: decorator,\n };\n }\n\n return null;\n}\n\n/**\n * Extracts the value from an expression node.\n * Supports literals, arrays, object literals, and RegExp.\n */\nfunction extractArgValue(node: ts.Expression): DecoratorArg {\n // String literal\n if (ts.isStringLiteral(node)) {\n return node.text;\n }\n\n // Numeric literal\n if (ts.isNumericLiteral(node)) {\n return Number(node.text);\n }\n\n // Boolean literals (true/false are identifiers in TS AST)\n if (node.kind === ts.SyntaxKind.TrueKeyword) {\n return true;\n }\n if (node.kind === ts.SyntaxKind.FalseKeyword) {\n return false;\n }\n\n // Null literal\n if (node.kind === ts.SyntaxKind.NullKeyword) {\n return null;\n }\n\n // Prefix unary expression (for negative numbers)\n if (ts.isPrefixUnaryExpression(node)) {\n if (node.operator === ts.SyntaxKind.MinusToken && ts.isNumericLiteral(node.operand)) {\n return -Number(node.operand.text);\n }\n if (node.operator === ts.SyntaxKind.PlusToken && ts.isNumericLiteral(node.operand)) {\n return Number(node.operand.text);\n }\n }\n\n // Array literal\n if (ts.isArrayLiteralExpression(node)) {\n return node.elements.map((el) => {\n if (ts.isSpreadElement(el)) {\n // Can't evaluate spread at compile time\n return null;\n }\n return extractArgValue(el);\n });\n }\n\n // Object literal\n if (ts.isObjectLiteralExpression(node)) {\n const obj: Record<string, DecoratorArg> = {};\n for (const prop of node.properties) {\n if (ts.isPropertyAssignment(prop)) {\n const key = getPropertyName(prop.name);\n if (key) {\n obj[key] = extractArgValue(prop.initializer);\n }\n } else if (ts.isShorthandPropertyAssignment(prop)) {\n // { foo } shorthand - we can't resolve the value\n const key = prop.name.text;\n obj[key] = null;\n }\n }\n return obj;\n }\n\n // Template literal (simple case)\n if (ts.isNoSubstitutionTemplateLiteral(node)) {\n return node.text;\n }\n\n // RegExp literal: extract the source pattern string\n if (ts.isRegularExpressionLiteral(node)) {\n const regexText = node.text;\n // RegExp literal format is /pattern/flags\n const lastSlash = regexText.lastIndexOf(\"/\");\n if (lastSlash > 0) {\n return regexText.substring(1, lastSlash);\n }\n return regexText;\n }\n\n // new RegExp(\"pattern\") — extract pattern from constructor call\n if (ts.isNewExpression(node)) {\n if (\n ts.isIdentifier(node.expression) &&\n node.expression.text === \"RegExp\" &&\n node.arguments &&\n node.arguments.length > 0\n ) {\n const firstArg = node.arguments[0];\n if (firstArg && ts.isStringLiteral(firstArg)) {\n return firstArg.text;\n }\n }\n }\n\n // Identifier - could be an enum member or constant\n // We can't resolve it statically, return null\n if (ts.isIdentifier(node)) {\n return null;\n }\n\n // For other expressions, return null\n return null;\n}\n\n/**\n * Gets the property name from a property name node.\n */\nfunction getPropertyName(name: ts.PropertyName): string | null {\n if (ts.isIdentifier(name)) {\n return name.text;\n }\n if (ts.isStringLiteral(name)) {\n return name.text;\n }\n if (ts.isNumericLiteral(name)) {\n return name.text;\n }\n // Computed property names can't be resolved statically\n return null;\n}\n\n/**\n * Known FormSpec decorators and their expected argument types.\n *\n * This metadata object provides additional information about each decorator's\n * expected argument types. The keys are constrained to match FormSpecDecoratorName.\n */\nexport const FORMSPEC_DECORATORS: Record<FormSpecDecoratorName, { argTypes: readonly string[] }> = {\n // Display metadata\n Field: { argTypes: [\"object\"] },\n\n // Grouping\n Group: { argTypes: [\"string\"] },\n\n // Conditional display\n ShowWhen: { argTypes: [\"object\"] },\n\n // Enum options\n EnumOptions: { argTypes: [\"array\"] },\n\n // Numeric constraints\n Minimum: { argTypes: [\"number\"] },\n Maximum: { argTypes: [\"number\"] },\n ExclusiveMinimum: { argTypes: [\"number\"] },\n ExclusiveMaximum: { argTypes: [\"number\"] },\n\n // String constraints\n MinLength: { argTypes: [\"number\"] },\n MaxLength: { argTypes: [\"number\"] },\n Pattern: { argTypes: [\"string\"] },\n} as const;\n\n/**\n * Checks if a file path belongs to the @formspec/decorators package.\n *\n * Matches both installed node_modules paths and local monorepo paths.\n */\nfunction isFormSpecDecoratorsPath(fileName: string): boolean {\n // Normalize separators for cross-platform matching\n const normalized = fileName.replace(/\\\\/g, \"/\");\n return (\n normalized.includes(\"node_modules/@formspec/decorators\") ||\n normalized.includes(\"/packages/decorators/\")\n );\n}\n\n/**\n * Resolves a decorator via the TypeScript type checker to determine\n * if it is a FormSpec decorator (built-in, extended, or custom).\n *\n * This enables detection of:\n * 1. Direct imports of built-in decorators from `@formspec/decorators`\n * 2. Extended decorators created via `extendDecorator(...).as(...)`\n * 3. Custom decorators created via `customDecorator(...).as(...)` or `.marker(...)`\n *\n * @param decorator - The decorator AST node\n * @param checker - TypeScript type checker\n * @returns Resolved decorator information, or null if not resolvable\n */\nexport function resolveDecorator(\n decorator: ts.Decorator,\n checker: ts.TypeChecker\n): ResolvedDecorator | null {\n const expr = decorator.expression;\n\n // Get the identifier to resolve\n let targetNode: ts.Node;\n let name: string;\n\n if (ts.isIdentifier(expr)) {\n // Simple marker decorator: @Decorator\n targetNode = expr;\n name = expr.text;\n } else if (ts.isCallExpression(expr)) {\n // Parameterized decorator: @Decorator(args)\n if (ts.isIdentifier(expr.expression)) {\n targetNode = expr.expression;\n name = expr.expression.text;\n } else {\n return null;\n }\n } else {\n return null;\n }\n\n // Check if it's a known built-in by name\n if (name in FORMSPEC_DECORATORS) {\n // Verify it actually comes from @formspec/decorators by checking the symbol\n const symbol = checker.getSymbolAtLocation(targetNode);\n if (symbol) {\n const declarations = symbol.declarations;\n if (declarations && declarations.length > 0) {\n const decl = declarations[0];\n if (decl) {\n const sourceFile = decl.getSourceFile();\n const fileName = sourceFile.fileName;\n if (isFormSpecDecoratorsPath(fileName)) {\n return {\n name,\n isFormSpec: true,\n isMarker: !ts.isCallExpression(expr),\n };\n }\n }\n }\n }\n }\n\n // Try to resolve branded types for custom/extended decorators\n const resolvedSymbol = checker.getSymbolAtLocation(targetNode);\n if (!resolvedSymbol) return null;\n\n const type = checker.getTypeOfSymbol(resolvedSymbol);\n const props = type.getProperties();\n\n let extendsBuiltin: string | undefined;\n let extensionName: string | undefined;\n let isMarker = false;\n\n for (const prop of props) {\n // __String is a branded string type; cast is safe for read-only string operations\n const escapedName = prop.getEscapedName() as string;\n\n // TypeScript represents unique symbol properties as __@<name>@<uniqueId>\n // in escaped names. The <name> portion may be either the Symbol description\n // (e.g., \"formspec.extends\") or the const variable name (e.g., \"FORMSPEC_EXTENDS\"),\n // depending on how the symbol is declared and resolved by the type checker.\n // We check for both patterns to handle all cases.\n if (\n escapedName.startsWith(\"__@\") &&\n (escapedName.includes(\"formspec.extends\") || escapedName.includes(\"FORMSPEC_EXTENDS\"))\n ) {\n const propType = checker.getTypeOfSymbol(prop);\n if (propType.isStringLiteral()) {\n extendsBuiltin = propType.value;\n }\n }\n\n if (\n escapedName.startsWith(\"__@\") &&\n (escapedName.includes(\"formspec.extension\") || escapedName.includes(\"FORMSPEC_EXTENSION\"))\n ) {\n const propType = checker.getTypeOfSymbol(prop);\n if (propType.isStringLiteral()) {\n extensionName = propType.value;\n }\n }\n\n if (\n escapedName.startsWith(\"__@\") &&\n (escapedName.includes(\"formspec.marker\") || escapedName.includes(\"FORMSPEC_MARKER\"))\n ) {\n isMarker = true;\n }\n }\n\n if (extendsBuiltin) {\n return {\n name,\n extendsBuiltin,\n isFormSpec: true,\n isMarker: false,\n };\n }\n\n if (extensionName) {\n return {\n name,\n extensionName,\n isFormSpec: true,\n isMarker,\n };\n }\n\n if (isMarker) {\n return {\n name,\n isFormSpec: true,\n isMarker: true,\n };\n }\n\n return null;\n}\n","/**\n * JSDoc constraint tag extractor.\n *\n * Extracts constraint tags from JSDoc comments on class fields and returns\n * synthetic {@link DecoratorInfo} objects that integrate seamlessly with\n * the existing decorator-based constraint pipeline.\n *\n * Supported tags correspond to keys in {@link CONSTRAINT_TAG_DEFINITIONS}\n * from `@formspec/core` (e.g., `@Minimum`, `@Maximum`, `@Pattern`).\n */\n\nimport * as ts from \"typescript\";\nimport { CONSTRAINT_TAG_DEFINITIONS, type ConstraintTagName } from \"@formspec/core\";\nimport type { DecoratorArg, DecoratorInfo } from \"./decorator-extractor.js\";\n\n/**\n * Extracts JSDoc constraint tags from a TypeScript AST node and returns\n * synthetic {@link DecoratorInfo} objects.\n *\n * For each recognised tag (case-sensitive PascalCase match against\n * {@link CONSTRAINT_TAG_DEFINITIONS}), the comment text is parsed\n * according to the tag's declared value type:\n * - `\"number\"` tags: parsed via `Number()` — skipped when NaN\n * - `\"string\"` tags (`Pattern`): used as-is (trimmed)\n *\n * @param node - The AST node to inspect for JSDoc tags\n * @returns Synthetic decorator info objects for each valid constraint tag\n */\nexport function extractJSDocConstraints(node: ts.Node): DecoratorInfo[] {\n const results: DecoratorInfo[] = [];\n const jsDocTags = ts.getJSDocTags(node);\n\n for (const tag of jsDocTags) {\n const tagName = tag.tagName.text;\n\n // Case-sensitive check against known constraint tags\n if (!(tagName in CONSTRAINT_TAG_DEFINITIONS)) {\n continue;\n }\n\n const constraintName = tagName as ConstraintTagName;\n const expectedType = CONSTRAINT_TAG_DEFINITIONS[constraintName];\n\n // Extract comment text — can be string, NodeArray<JSDocComment>, or undefined\n const commentText = getTagCommentText(tag);\n if (commentText === undefined || commentText === \"\") {\n continue;\n }\n\n const trimmed = commentText.trim();\n if (trimmed === \"\") {\n continue;\n }\n\n if (expectedType === \"number\") {\n const value = Number(trimmed);\n if (Number.isNaN(value)) {\n continue;\n }\n results.push(createSyntheticDecorator(constraintName, value));\n } else if (expectedType === \"json\") {\n // JSON type (EnumOptions) — parse inline JSON array only.\n // Downstream UI schema generation expects an array of options.\n try {\n const parsed: unknown = JSON.parse(trimmed);\n if (!Array.isArray(parsed)) {\n continue;\n }\n results.push(createSyntheticDecorator(constraintName, parsed as DecoratorArg));\n } catch {\n // Skip malformed JSON\n continue;\n }\n } else {\n // \"string\" type (Pattern)\n results.push(createSyntheticDecorator(constraintName, trimmed));\n }\n }\n\n return results;\n}\n\n/**\n * Extracts `@Field_displayName` and `@Field_description` TSDoc tags from\n * a node and returns a synthetic `Field` {@link DecoratorInfo} if either\n * is present.\n *\n * This enables interface properties to carry display metadata via TSDoc\n * tags instead of the `@Field` decorator (which requires a class):\n *\n * ```typescript\n * interface Config {\n * // @Field_displayName Program Name\n * // @Field_description Internal identifier\n * programName: string;\n * }\n * ```\n *\n * @param node - The AST node to inspect for display metadata tags\n * @returns A synthetic `Field` decorator info, or null if no tags found\n */\nexport function extractJSDocFieldMetadata(node: ts.Node): DecoratorInfo | null {\n const jsDocTags = ts.getJSDocTags(node);\n\n let displayName: string | undefined;\n let description: string | undefined;\n\n for (const tag of jsDocTags) {\n const tagName = tag.tagName.text;\n const commentText = getTagCommentText(tag);\n if (commentText === undefined || commentText.trim() === \"\") {\n continue;\n }\n\n const trimmed = commentText.trim();\n\n if (tagName === \"Field_displayName\") {\n displayName = trimmed;\n } else if (tagName === \"Field_description\") {\n description = trimmed;\n }\n }\n\n if (displayName === undefined && description === undefined) {\n return null;\n }\n\n // Build the FieldOptions-shaped arg object\n const fieldOpts: Record<string, DecoratorArg> = {\n ...(displayName !== undefined ? { displayName } : {}),\n ...(description !== undefined ? { description } : {}),\n };\n\n return createSyntheticDecorator(\"Field\", fieldOpts);\n}\n\n/**\n * Extracts the text content from a JSDoc tag's comment.\n *\n * The `tag.comment` property can be a plain string, an array of\n * `JSDocComment` nodes, or undefined. This helper normalises all\n * three cases to a single `string | undefined`.\n */\nfunction getTagCommentText(tag: ts.JSDocTag): string | undefined {\n if (tag.comment === undefined) {\n return undefined;\n }\n if (typeof tag.comment === \"string\") {\n return tag.comment;\n }\n // NodeArray<JSDocComment> — concatenate text spans\n return ts.getTextOfJSDocComment(tag.comment);\n}\n\n/**\n * Creates a synthetic {@link DecoratorInfo} for a JSDoc constraint tag.\n *\n * The `node` field is `undefined` because JSDoc constraints have no\n * decorator AST node. Downstream constraint processing only uses\n * the `name` and `args` fields.\n */\nfunction createSyntheticDecorator(name: string, value: DecoratorArg): DecoratorInfo {\n return {\n name,\n args: [value],\n node: undefined,\n };\n}\n","/**\n * Class analyzer for extracting fields, types, and decorators.\n *\n * Analyzes a TypeScript class declaration to extract:\n * - Field names and TypeScript types\n * - Decorator metadata (Field, Minimum, Maximum, etc.)\n * - Field optionality\n * - TSDoc @deprecated tags\n * - Default values from property initializers\n */\n\nimport * as ts from \"typescript\";\nimport { extractDecorators, resolveDecorator, type DecoratorInfo } from \"./decorator-extractor.js\";\nimport { extractJSDocConstraints, extractJSDocFieldMetadata } from \"./jsdoc-constraints.js\";\n\n/**\n * Analyzed field information from a class.\n */\nexport interface FieldInfo {\n /** Field name */\n name: string;\n /** TypeScript type node for the field */\n typeNode: ts.TypeNode | undefined;\n /** Resolved type from the type checker */\n type: ts.Type;\n /** Whether the field is optional (has ? modifier) */\n optional: boolean;\n /** Decorators applied to the field */\n decorators: DecoratorInfo[];\n /** Whether the field has a TSDoc @deprecated tag */\n deprecated: boolean;\n /** Default value extracted from the property initializer (literal values only) */\n defaultValue: unknown;\n}\n\n/**\n * Result of analyzing a class declaration.\n */\nexport interface ClassAnalysis {\n /** Class name */\n name: string;\n /** Analyzed fields */\n fields: FieldInfo[];\n /** Instance methods */\n instanceMethods: MethodInfo[];\n /** Static methods */\n staticMethods: MethodInfo[];\n}\n\n/**\n * Analyzed method information.\n */\nexport interface MethodInfo {\n /** Method name */\n name: string;\n /** Method parameters */\n parameters: ParameterInfo[];\n /** Return type node */\n returnTypeNode: ts.TypeNode | undefined;\n /** Resolved return type */\n returnType: ts.Type;\n}\n\n/**\n * Analyzed parameter information.\n */\nexport interface ParameterInfo {\n /** Parameter name */\n name: string;\n /** TypeScript type node */\n typeNode: ts.TypeNode | undefined;\n /** Resolved type */\n type: ts.Type;\n /** If this is InferSchema<typeof X>, the export name X */\n formSpecExportName: string | null;\n /** Whether the parameter is optional (has ? or default value) */\n optional: boolean;\n}\n\n/**\n * Analyzes a class declaration to extract fields and methods.\n *\n * @param classDecl - The class declaration to analyze\n * @param checker - TypeScript type checker\n * @returns Analysis result with fields and methods\n */\nexport function analyzeClass(\n classDecl: ts.ClassDeclaration,\n checker: ts.TypeChecker\n): ClassAnalysis {\n const name = classDecl.name?.text ?? \"AnonymousClass\";\n const fields: FieldInfo[] = [];\n const instanceMethods: MethodInfo[] = [];\n const staticMethods: MethodInfo[] = [];\n\n for (const member of classDecl.members) {\n if (ts.isPropertyDeclaration(member)) {\n const fieldInfo = analyzeField(member, checker);\n if (fieldInfo) {\n fields.push(fieldInfo);\n }\n } else if (ts.isMethodDeclaration(member)) {\n const methodInfo = analyzeMethod(member, checker);\n if (methodInfo) {\n const isStatic = member.modifiers?.some((m) => m.kind === ts.SyntaxKind.StaticKeyword);\n if (isStatic) {\n staticMethods.push(methodInfo);\n } else {\n instanceMethods.push(methodInfo);\n }\n }\n }\n }\n\n return {\n name,\n fields,\n instanceMethods,\n staticMethods,\n };\n}\n\n/**\n * Analyzes a property declaration to extract field info.\n */\nexport function analyzeField(\n prop: ts.PropertyDeclaration,\n checker: ts.TypeChecker\n): FieldInfo | null {\n // Skip computed property names\n if (!ts.isIdentifier(prop.name)) {\n return null;\n }\n\n const name = prop.name.text;\n const typeNode = prop.type;\n const type = checker.getTypeAtLocation(prop);\n const optional = prop.questionToken !== undefined;\n const decorators = extractDecorators(prop);\n\n // Resolve each decorator via the type checker to detect extended/custom decorators\n for (const dec of decorators) {\n if (dec.node) {\n const resolved = resolveDecorator(dec.node, checker);\n if (resolved) {\n dec.resolved = resolved;\n }\n }\n }\n\n // Inherit constraints from type alias declarations first (as defaults).\n // Field-level decorators and JSDoc are applied after, so they take precedence.\n if (prop.type) {\n const aliasConstraints = extractTypeAliasConstraints(prop.type, checker);\n decorators.push(...aliasConstraints);\n }\n\n // Merge JSDoc constraint tags (e.g., /** @Minimum 0 @Maximum 100 */)\n const jsdocConstraints = extractJSDocConstraints(prop);\n decorators.push(...jsdocConstraints);\n\n const deprecated = hasDeprecatedTag(prop);\n const defaultValue = extractDefaultValue(prop.initializer);\n\n return {\n name,\n typeNode,\n type,\n optional,\n decorators,\n deprecated,\n defaultValue,\n };\n}\n\n/**\n * Given a type node, checks if it references a type alias and extracts\n * JSDoc constraint tags from the alias declaration.\n *\n * Only constraint tags (`@Minimum`, `@Maximum`, `@Pattern`, etc.) are\n * propagated — display metadata (`@Field_displayName`, `@Field_description`)\n * is intentionally excluded because display metadata is a field-level\n * concern, not a type-level one.\n *\n * This makes `type Percent = number` with `@Minimum 0 @Maximum 100`\n * propagate constraints to any field typed as `Percent`.\n */\nfunction extractTypeAliasConstraints(\n typeNode: ts.TypeNode,\n checker: ts.TypeChecker\n): DecoratorInfo[] {\n // Only handle type references (e.g., `Percent`, not `number` directly)\n if (!ts.isTypeReferenceNode(typeNode)) return [];\n\n const symbol = checker.getSymbolAtLocation(typeNode.typeName);\n if (!symbol?.declarations) return [];\n\n const aliasDecl = symbol.declarations.find(ts.isTypeAliasDeclaration);\n if (!aliasDecl) return [];\n\n // Don't extract from object type aliases — those are handled by\n // the nested object analysis pipeline in type-converter.ts\n if (ts.isTypeLiteralNode(aliasDecl.type)) return [];\n\n // Only propagate constraint tags, not display metadata (@Field_displayName,\n // @Field_description). Display metadata on the alias shouldn't override the\n // field's own title/description — those are field-level concerns.\n return extractJSDocConstraints(aliasDecl);\n}\n\n/**\n * Checks if a node has a TSDoc `@deprecated` tag.\n */\nfunction hasDeprecatedTag(node: ts.Node): boolean {\n const jsDocTags = ts.getJSDocTags(node);\n return jsDocTags.some((tag) => tag.tagName.text === \"deprecated\");\n}\n\n/**\n * Extracts a default value from a property initializer.\n *\n * Only extracts literal values (strings, numbers, booleans, null).\n * Non-literal initializers (function calls, expressions, etc.) return undefined.\n */\nfunction extractDefaultValue(initializer: ts.Expression | undefined): unknown {\n if (!initializer) return undefined;\n\n // String literal\n if (ts.isStringLiteral(initializer)) {\n return initializer.text;\n }\n\n // Numeric literal\n if (ts.isNumericLiteral(initializer)) {\n return Number(initializer.text);\n }\n\n // Boolean literals\n if (initializer.kind === ts.SyntaxKind.TrueKeyword) {\n return true;\n }\n if (initializer.kind === ts.SyntaxKind.FalseKeyword) {\n return false;\n }\n\n // Null literal\n if (initializer.kind === ts.SyntaxKind.NullKeyword) {\n return null;\n }\n\n // Negative number\n if (ts.isPrefixUnaryExpression(initializer)) {\n if (\n initializer.operator === ts.SyntaxKind.MinusToken &&\n ts.isNumericLiteral(initializer.operand)\n ) {\n return -Number(initializer.operand.text);\n }\n }\n\n // Non-literal initializer — can't extract statically\n return undefined;\n}\n\n/**\n * Analyzes a method declaration to extract method info.\n */\nfunction analyzeMethod(method: ts.MethodDeclaration, checker: ts.TypeChecker): MethodInfo | null {\n // Skip computed method names\n if (!ts.isIdentifier(method.name)) {\n return null;\n }\n\n const name = method.name.text;\n const parameters: ParameterInfo[] = [];\n\n for (const param of method.parameters) {\n if (ts.isIdentifier(param.name)) {\n const paramInfo = analyzeParameter(param, checker);\n parameters.push(paramInfo);\n }\n }\n\n const returnTypeNode = method.type;\n const signature = checker.getSignatureFromDeclaration(method);\n const returnType = signature\n ? checker.getReturnTypeOfSignature(signature)\n : checker.getTypeAtLocation(method);\n\n return {\n name,\n parameters,\n returnTypeNode,\n returnType,\n };\n}\n\n/**\n * Analyzes a parameter declaration.\n */\nfunction analyzeParameter(param: ts.ParameterDeclaration, checker: ts.TypeChecker): ParameterInfo {\n const name = ts.isIdentifier(param.name) ? param.name.text : \"param\";\n const typeNode = param.type;\n const type = checker.getTypeAtLocation(param);\n const formSpecExportName = detectFormSpecReference(typeNode);\n // Parameter is optional if it has a question token or a default value\n const optional = param.questionToken !== undefined || param.initializer !== undefined;\n\n return {\n name,\n typeNode,\n type,\n formSpecExportName,\n optional,\n };\n}\n\n/**\n * Detects if a type node is InferSchema<typeof X> or InferFormSchema<typeof X> and extracts X.\n *\n * @param typeNode - The type node to check\n * @returns The export name X, or null if not a FormSpec inference pattern\n */\nfunction detectFormSpecReference(typeNode: ts.TypeNode | undefined): string | null {\n if (!typeNode) return null;\n\n // Looking for: InferSchema<typeof X> or InferFormSchema<typeof X>\n if (!ts.isTypeReferenceNode(typeNode)) return null;\n\n // Get the type name - could be Identifier or QualifiedName\n const typeName = ts.isIdentifier(typeNode.typeName)\n ? typeNode.typeName.text\n : ts.isQualifiedName(typeNode.typeName)\n ? typeNode.typeName.right.text\n : null;\n\n // Support both InferSchema (for elements) and InferFormSchema (for FormSpec)\n if (typeName !== \"InferSchema\" && typeName !== \"InferFormSchema\") return null;\n\n const typeArg = typeNode.typeArguments?.[0];\n if (!typeArg || !ts.isTypeQueryNode(typeArg)) return null;\n\n // typeArg.exprName is the identifier (e.g., \"ActivateParams\")\n if (ts.isIdentifier(typeArg.exprName)) {\n return typeArg.exprName.text;\n }\n\n // Could be qualified name like Namespace.ActivateParams\n if (ts.isQualifiedName(typeArg.exprName)) {\n return typeArg.exprName.right.text;\n }\n\n return null;\n}\n\n/**\n * Analyzes an interface declaration to extract field information.\n *\n * Similar to {@link analyzeClass} but for interface declarations.\n * Extracts JSDoc constraint tags (`@Minimum`, `@MaxLength`, etc.) and\n * display metadata (`@Field_displayName`, `@Field_description`) from\n * property signatures, producing the same {@link ClassAnalysis}\n * structure for downstream schema generation.\n *\n * @param interfaceDecl - The interface declaration to analyze\n * @param checker - TypeScript type checker\n * @returns Analysis result with fields (no methods — interfaces have no implementations)\n */\nexport function analyzeInterface(\n interfaceDecl: ts.InterfaceDeclaration,\n checker: ts.TypeChecker\n): ClassAnalysis {\n const name = interfaceDecl.name.text;\n const fields: FieldInfo[] = [];\n\n for (const member of interfaceDecl.members) {\n if (ts.isPropertySignature(member)) {\n const fieldInfo = analyzeInterfaceProperty(member, checker);\n if (fieldInfo) {\n fields.push(fieldInfo);\n }\n }\n }\n\n return {\n name,\n fields,\n instanceMethods: [],\n staticMethods: [],\n };\n}\n\n/**\n * Result of analyzing a type alias — either a successful analysis or\n * an error describing why the alias can't be analyzed.\n */\nexport type AnalyzeTypeAliasResult =\n | { ok: true; analysis: ClassAnalysis }\n | { ok: false; error: string };\n\n/**\n * Analyzes a type alias declaration to extract field information.\n *\n * Supports type aliases whose body is a type literal (object type):\n *\n * ```typescript\n * type Config = {\n * // @Field_displayName Name @Minimum 1\n * name: string;\n * };\n * ```\n *\n * Returns an error result (not an exception) for non-object-literal aliases,\n * allowing callers to accumulate diagnostics across multiple types.\n *\n * @param typeAlias - The type alias declaration to analyze\n * @param checker - TypeScript type checker\n * @returns Success with analysis, or error with a diagnostic message including line number\n */\nexport function analyzeTypeAlias(\n typeAlias: ts.TypeAliasDeclaration,\n checker: ts.TypeChecker\n): AnalyzeTypeAliasResult {\n // Only handle type literals: type X = { ... }\n if (!ts.isTypeLiteralNode(typeAlias.type)) {\n const sourceFile = typeAlias.getSourceFile();\n const { line } = sourceFile.getLineAndCharacterOfPosition(typeAlias.getStart());\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- enum reverse mapping can be undefined for compiler-internal kinds\n const kindDesc = ts.SyntaxKind[typeAlias.type.kind] ?? \"unknown\";\n return {\n ok: false,\n error: `Type alias \"${typeAlias.name.text}\" at line ${String(line + 1)} is not an object type literal (found ${kindDesc})`,\n };\n }\n\n const name = typeAlias.name.text;\n const fields: FieldInfo[] = [];\n\n for (const member of typeAlias.type.members) {\n if (ts.isPropertySignature(member)) {\n const fieldInfo = analyzeInterfaceProperty(member, checker);\n if (fieldInfo) {\n fields.push(fieldInfo);\n }\n }\n }\n\n return {\n ok: true,\n analysis: {\n name,\n fields,\n instanceMethods: [],\n staticMethods: [],\n },\n };\n}\n\n/**\n * Analyzes an interface property signature to extract field info.\n *\n * Extracts JSDoc constraint tags (`@Minimum`, `@MaxLength`, etc.) and\n * display metadata (`@DisplayName`, `@Description`) from the property's\n * TSDoc comments. Also used by the type converter for nested interface/type\n * alias constraint propagation.\n */\nexport function analyzeInterfaceProperty(\n prop: ts.PropertySignature,\n checker: ts.TypeChecker\n): FieldInfo | null {\n if (!ts.isIdentifier(prop.name)) {\n return null;\n }\n\n const name = prop.name.text;\n const typeNode = prop.type;\n const type = checker.getTypeAtLocation(prop);\n const optional = prop.questionToken !== undefined;\n\n // Interface properties have no decorators — only JSDoc tags\n const decorators: DecoratorInfo[] = [];\n\n // Inherit constraints from type alias declarations first (as defaults).\n // Field-level tags are applied after, so they take precedence.\n if (typeNode) {\n const aliasConstraints = extractTypeAliasConstraints(typeNode, checker);\n decorators.push(...aliasConstraints);\n }\n\n // Extract display metadata (@Field_displayName, @Field_description) as synthetic Field decorator\n const fieldMetadata = extractJSDocFieldMetadata(prop);\n if (fieldMetadata) {\n decorators.push(fieldMetadata);\n }\n\n // Extract constraint tags (@Minimum, @MaxLength, @Pattern, etc.)\n const jsdocConstraints = extractJSDocConstraints(prop);\n decorators.push(...jsdocConstraints);\n\n const deprecated = hasDeprecatedTag(prop);\n\n return {\n name,\n typeNode,\n type,\n optional,\n decorators,\n deprecated,\n defaultValue: undefined,\n };\n}\n","/**\n * Type converter for transforming TypeScript types to JSON Schema and FormSpec.\n *\n * Converts TypeScript types (extracted via type checker) to:\n * - JSON Schema definitions\n * - FormSpec field definitions\n */\n\nimport * as ts from \"typescript\";\nimport type { DecoratorInfo } from \"./decorator-extractor.js\";\nimport { analyzeField, analyzeInterfaceProperty, type FieldInfo } from \"./class-analyzer.js\";\nimport { setSchemaExtension, type ExtendedJSONSchema7 } from \"../json-schema/types.js\";\n\n/**\n * FormSpec field definition (simplified for output).\n */\nexport interface FormSpecField {\n _field: string;\n id: string;\n label?: string;\n placeholder?: string;\n description?: string;\n required?: boolean;\n min?: number;\n max?: number;\n step?: number;\n minLength?: number;\n maxLength?: number;\n minItems?: number;\n maxItems?: number;\n pattern?: string;\n options?: (string | { id: string; label: string })[];\n showWhen?: object;\n group?: string;\n fields?: FormSpecField[]; // Nested fields for object types\n}\n\n/**\n * Result of converting a TypeScript type.\n */\nexport interface TypeConversionResult {\n /** JSON Schema representation */\n jsonSchema: ExtendedJSONSchema7;\n /** FormSpec field type */\n formSpecFieldType: string;\n}\n\n/**\n * Given a ts.Type for a named type (class, interface, or type alias with\n * a type literal body), navigates to its declaration and returns a Map\n * from property name to its fully analyzed FieldInfo.\n *\n * - **Classes**: uses `analyzeField` to extract decorators + JSDoc constraints\n * - **Interfaces**: extracts `@Field_displayName`, `@Field_description`, and constraint tags\n * - **Type aliases** (object literals): same as interfaces\n *\n * Returns null for unnamed types (inline objects, mapped types, etc.),\n * preserving existing structural-only behavior for those cases.\n */\nfunction getNamedTypeFieldInfoMap(\n type: ts.Type,\n checker: ts.TypeChecker\n): Map<string, FieldInfo> | null {\n // Check both direct symbol and alias symbol — type aliases resolve to\n // an anonymous __type symbol, with the original alias on type.aliasSymbol.\n const symbols = [type.getSymbol(), type.aliasSymbol].filter(\n (s): s is ts.Symbol => s?.declarations != null && s.declarations.length > 0\n );\n\n for (const symbol of symbols) {\n const declarations = symbol.declarations;\n if (!declarations) continue;\n\n // Try class declaration\n const classDecl = declarations.find(ts.isClassDeclaration);\n if (classDecl) {\n const map = new Map<string, FieldInfo>();\n for (const member of classDecl.members) {\n if (ts.isPropertyDeclaration(member) && ts.isIdentifier(member.name)) {\n const fieldInfo = analyzeField(member, checker);\n if (fieldInfo) map.set(fieldInfo.name, fieldInfo);\n }\n }\n return map;\n }\n\n // Try interface declaration\n const interfaceDecl = declarations.find(ts.isInterfaceDeclaration);\n if (interfaceDecl) {\n return buildFieldInfoMapFromSignatures(interfaceDecl.members, checker);\n }\n\n // Try type alias with type literal body: type X = { ... }\n const typeAliasDecl = declarations.find(ts.isTypeAliasDeclaration);\n if (typeAliasDecl && ts.isTypeLiteralNode(typeAliasDecl.type)) {\n return buildFieldInfoMapFromSignatures(typeAliasDecl.type.members, checker);\n }\n }\n\n return null;\n}\n\n/**\n * Builds a FieldInfo map from interface/type-literal property signatures,\n * delegating to {@link analyzeInterfaceProperty} for JSDoc extraction.\n */\nfunction buildFieldInfoMapFromSignatures(\n members: ts.NodeArray<ts.TypeElement>,\n checker: ts.TypeChecker\n): Map<string, FieldInfo> {\n const map = new Map<string, FieldInfo>();\n for (const member of members) {\n if (ts.isPropertySignature(member)) {\n const fieldInfo = analyzeInterfaceProperty(member, checker);\n if (fieldInfo) {\n map.set(fieldInfo.name, fieldInfo);\n }\n }\n }\n return map;\n}\n\n/**\n * Resolved information about a single property of an object type.\n *\n * Computed once by `getObjectPropertyInfos` and consumed by both the\n * JSON Schema path (`convertObjectType`) and the UI Schema path\n * (`createFormSpecField`), eliminating duplicated iteration logic.\n */\ninterface ObjectPropertyInfo {\n /** Property name */\n name: string;\n /** Resolved TypeScript type for the property */\n type: ts.Type;\n /** Whether the property is optional */\n optional: boolean;\n /** FieldInfo from the class declaration, if this is a class-typed object */\n fieldInfo: FieldInfo | undefined;\n}\n\n/**\n * Iterates the properties of an object type and resolves each property's\n * type, optionality, and class-level field info (decorators/JSDoc).\n *\n * This is the single source of truth for nested property analysis, used\n * by both the JSON Schema and FormSpec field generation paths.\n */\nfunction getObjectPropertyInfos(\n type: ts.ObjectType,\n checker: ts.TypeChecker\n): ObjectPropertyInfo[] {\n const fieldInfoMap = getNamedTypeFieldInfoMap(type, checker);\n const result: ObjectPropertyInfo[] = [];\n\n for (const prop of type.getProperties()) {\n const declaration = prop.valueDeclaration ?? prop.declarations?.[0];\n if (!declaration) continue;\n\n const propType = checker.getTypeOfSymbolAtLocation(prop, declaration);\n const optional = !!(prop.flags & ts.SymbolFlags.Optional);\n const fieldInfo = fieldInfoMap?.get(prop.name) ?? undefined;\n\n result.push({ name: prop.name, type: propType, optional, fieldInfo });\n }\n\n return result;\n}\n\n/**\n * Converts a TypeScript type to JSON Schema and FormSpec field type.\n *\n * @param type - The TypeScript type to convert\n * @param checker - TypeScript type checker\n * @returns Conversion result with JSON Schema and FormSpec type\n */\nexport function convertType(type: ts.Type, checker: ts.TypeChecker): TypeConversionResult {\n return convertTypeInternal(type, checker, new Set());\n}\n\nfunction convertTypeInternal(\n type: ts.Type,\n checker: ts.TypeChecker,\n visiting: Set<ts.Type>\n): TypeConversionResult {\n // Handle primitive types\n if (type.flags & ts.TypeFlags.String) {\n return { jsonSchema: { type: \"string\" }, formSpecFieldType: \"text\" };\n }\n\n if (type.flags & ts.TypeFlags.Number) {\n return { jsonSchema: { type: \"number\" }, formSpecFieldType: \"number\" };\n }\n\n if (type.flags & ts.TypeFlags.Boolean) {\n return { jsonSchema: { type: \"boolean\" }, formSpecFieldType: \"boolean\" };\n }\n\n if (type.flags & ts.TypeFlags.Null) {\n return { jsonSchema: { type: \"null\" }, formSpecFieldType: \"null\" };\n }\n\n if (type.flags & ts.TypeFlags.Undefined) {\n return { jsonSchema: {}, formSpecFieldType: \"undefined\" };\n }\n\n // Handle literal types\n if (type.isStringLiteral()) {\n return {\n jsonSchema: { const: type.value },\n formSpecFieldType: \"enum\",\n };\n }\n\n if (type.isNumberLiteral()) {\n return {\n jsonSchema: { const: type.value },\n formSpecFieldType: \"number\",\n };\n }\n\n // Handle union types (including string literal unions for enums)\n if (type.isUnion()) {\n return convertUnionType(type, checker, visiting);\n }\n\n // Handle array types\n if (checker.isArrayType(type)) {\n return convertArrayType(type, checker, visiting);\n }\n\n // Handle object types\n if (type.flags & ts.TypeFlags.Object) {\n return convertObjectType(type as ts.ObjectType, checker, visiting);\n }\n\n // Fallback\n return { jsonSchema: {}, formSpecFieldType: \"unknown\" };\n}\n\n/**\n * Converts a union type to JSON Schema.\n */\nfunction convertUnionType(\n type: ts.UnionType,\n checker: ts.TypeChecker,\n visiting: Set<ts.Type>\n): TypeConversionResult {\n const types = type.types;\n\n // Filter out null and undefined for analysis\n // Note: undefined is filtered out since JSON Schema doesn't have an undefined type\n // Optional fields are handled via the 'required' array, not the type\n const nonNullTypes = types.filter(\n (t) => !(t.flags & (ts.TypeFlags.Null | ts.TypeFlags.Undefined))\n );\n const hasNull = types.some((t) => t.flags & ts.TypeFlags.Null);\n\n // Check if this is a boolean type (true | false in TypeScript)\n // TypeScript represents `boolean` as a union of `true | false` literal types\n const isBooleanUnion =\n nonNullTypes.length === 2 && nonNullTypes.every((t) => t.flags & ts.TypeFlags.BooleanLiteral);\n\n if (isBooleanUnion) {\n const result: TypeConversionResult = {\n jsonSchema: { type: \"boolean\" },\n formSpecFieldType: \"boolean\",\n };\n if (hasNull) {\n result.jsonSchema = { oneOf: [{ type: \"boolean\" }, { type: \"null\" }] };\n }\n return result;\n }\n\n // Check if all types are string literals (enum pattern)\n const allStringLiterals = nonNullTypes.every((t) => t.isStringLiteral());\n if (allStringLiterals && nonNullTypes.length > 0) {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion -- TypeScript doesn't narrow array types from `every` predicate\n const enumValues = nonNullTypes.map((t) => (t as ts.StringLiteralType).value);\n const result: TypeConversionResult = {\n jsonSchema: { enum: enumValues },\n formSpecFieldType: \"enum\",\n };\n if (hasNull) {\n result.jsonSchema = { oneOf: [{ enum: enumValues }, { type: \"null\" }] };\n }\n return result;\n }\n\n // Check if all types are number literals\n const allNumberLiterals = nonNullTypes.every((t) => t.isNumberLiteral());\n if (allNumberLiterals && nonNullTypes.length > 0) {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion -- TypeScript doesn't narrow array types from `every` predicate\n const enumValues = nonNullTypes.map((t) => (t as ts.NumberLiteralType).value);\n const result: TypeConversionResult = {\n jsonSchema: { enum: enumValues },\n formSpecFieldType: \"enum\",\n };\n if (hasNull) {\n result.jsonSchema = { oneOf: [{ enum: enumValues }, { type: \"null\" }] };\n }\n return result;\n }\n\n // Handle nullable types (T | null or T | undefined) with single non-null type\n if (nonNullTypes.length === 1 && nonNullTypes[0]) {\n const result = convertTypeInternal(nonNullTypes[0], checker, visiting);\n // Make it nullable in JSON Schema\n if (hasNull) {\n result.jsonSchema = { oneOf: [result.jsonSchema, { type: \"null\" }] };\n }\n return result;\n }\n\n // General union - use oneOf (filter out undefined which isn't valid in JSON Schema)\n const schemas = nonNullTypes.map((t) => convertTypeInternal(t, checker, visiting).jsonSchema);\n if (hasNull) {\n schemas.push({ type: \"null\" });\n }\n return {\n jsonSchema: { oneOf: schemas },\n formSpecFieldType: \"union\",\n };\n}\n\n/**\n * Converts an array type to JSON Schema.\n */\nfunction convertArrayType(\n type: ts.Type,\n checker: ts.TypeChecker,\n visiting: Set<ts.Type>\n): TypeConversionResult {\n const typeArgs = (type as ts.TypeReference).typeArguments;\n const elementType = typeArgs?.[0];\n\n const itemSchema = elementType\n ? convertTypeInternal(elementType, checker, visiting).jsonSchema\n : {};\n\n return {\n jsonSchema: {\n type: \"array\",\n items: itemSchema,\n },\n formSpecFieldType: \"array\",\n };\n}\n\n/**\n * Converts an object type to JSON Schema.\n */\nfunction convertObjectType(\n type: ts.ObjectType,\n checker: ts.TypeChecker,\n visiting: Set<ts.Type>\n): TypeConversionResult {\n // Circular reference guard\n if (visiting.has(type)) {\n return { jsonSchema: { type: \"object\" }, formSpecFieldType: \"object\" };\n }\n visiting.add(type);\n\n const properties: Record<string, ExtendedJSONSchema7> = {};\n const required: string[] = [];\n\n for (const propInfo of getObjectPropertyInfos(type, checker)) {\n const propSchema = convertTypeInternal(propInfo.type, checker, visiting).jsonSchema;\n\n // Apply decorator/JSDoc constraints from the class declaration if available\n properties[propInfo.name] = propInfo.fieldInfo\n ? applyDecoratorsToSchema(propSchema, propInfo.fieldInfo.decorators, propInfo.fieldInfo)\n : propSchema;\n\n if (!propInfo.optional) {\n required.push(propInfo.name);\n }\n }\n\n visiting.delete(type);\n\n return {\n jsonSchema: {\n type: \"object\",\n properties,\n ...(required.length > 0 ? { required } : {}),\n },\n formSpecFieldType: \"object\",\n };\n}\n\n/**\n * Creates a FormSpec field definition from a field's type and decorators.\n *\n * @param fieldName - The field name\n * @param type - The TypeScript type\n * @param decorators - Decorators applied to the field\n * @param optional - Whether the field is optional\n * @param checker - TypeScript type checker\n * @returns FormSpec field definition\n */\nexport function createFormSpecField(\n fieldName: string,\n type: ts.Type,\n decorators: DecoratorInfo[],\n optional: boolean,\n checker: ts.TypeChecker,\n visitedTypes = new Set<ts.Type>()\n): FormSpecField {\n const { formSpecFieldType } = convertType(type, checker);\n\n const field: FormSpecField = {\n _field: formSpecFieldType,\n id: fieldName,\n };\n\n // Apply optionality\n if (!optional) {\n field.required = true;\n }\n\n // For object types, recursively add nested fields.\n // Note: visitedTypes guards against circular references independently from\n // the `visiting` set in convertTypeInternal — they protect different recursion\n // paths (FormSpec field generation vs JSON Schema generation).\n if (formSpecFieldType === \"object\" && type.flags & ts.TypeFlags.Object) {\n if (!visitedTypes.has(type)) {\n visitedTypes.add(type);\n\n const nestedFields: FormSpecField[] = [];\n for (const propInfo of getObjectPropertyInfos(type as ts.ObjectType, checker)) {\n nestedFields.push(\n createFormSpecField(\n propInfo.name,\n propInfo.type,\n propInfo.fieldInfo?.decorators ?? [],\n propInfo.optional,\n checker,\n visitedTypes\n )\n );\n }\n\n visitedTypes.delete(type);\n\n if (nestedFields.length > 0) {\n field.fields = nestedFields;\n }\n }\n }\n\n // Apply decorator values\n for (const dec of decorators) {\n applyDecoratorToField(field, dec);\n }\n\n return field;\n}\n\n/**\n * Applies a decorator's values to a FormSpec field.\n *\n * Note: Custom decorator extensions (x-formspec-*) are only emitted in JSON Schema\n * via `applyDecoratorsToSchema`, not here. The FormSpecField interface does not\n * carry extension data — extensions are a schema-level concern.\n *\n * @param field - The FormSpec field to modify\n * @param decorator - The decorator information to apply\n */\nfunction applyDecoratorToField(field: FormSpecField, decorator: DecoratorInfo): void {\n const { args } = decorator;\n const resolved = decorator.resolved;\n\n // If this is an extended decorator, map it to the built-in it extends\n const effectiveName = resolved?.extendsBuiltin ?? decorator.name;\n\n switch (effectiveName) {\n case \"Field\": {\n // Field takes an object with displayName, description, placeholder\n const opts = args[0];\n if (typeof opts === \"object\" && opts !== null && !Array.isArray(opts)) {\n if (typeof opts[\"displayName\"] === \"string\") {\n field.label = opts[\"displayName\"];\n }\n if (typeof opts[\"description\"] === \"string\") {\n field.description = opts[\"description\"];\n }\n if (typeof opts[\"placeholder\"] === \"string\") {\n field.placeholder = opts[\"placeholder\"];\n }\n }\n break;\n }\n\n case \"Minimum\":\n if (typeof args[0] === \"number\") {\n field.min = args[0];\n }\n break;\n\n case \"Maximum\":\n if (typeof args[0] === \"number\") {\n field.max = args[0];\n }\n break;\n\n case \"MinLength\":\n if (typeof args[0] === \"number\") {\n field.minLength = args[0];\n }\n break;\n\n case \"MaxLength\":\n if (typeof args[0] === \"number\") {\n field.maxLength = args[0];\n }\n break;\n\n case \"Pattern\":\n if (typeof args[0] === \"string\") {\n field.pattern = args[0];\n }\n break;\n\n case \"EnumOptions\":\n if (Array.isArray(args[0])) {\n field.options = args[0] as (string | { id: string; label: string })[];\n }\n break;\n\n case \"ShowWhen\":\n if (typeof args[0] === \"object\" && args[0] !== null) {\n field.showWhen = args[0] as object;\n }\n break;\n\n case \"Group\":\n if (typeof args[0] === \"string\") {\n field.group = args[0];\n }\n break;\n }\n}\n\n/**\n * Applies decorator constraints to a JSON Schema.\n *\n * @param schema - The base JSON Schema\n * @param decorators - Decorators to apply\n * @param fieldInfo - Optional field info for deprecated/default values\n * @returns Modified JSON Schema with constraints\n */\nexport function applyDecoratorsToSchema(\n schema: ExtendedJSONSchema7,\n decorators: DecoratorInfo[],\n fieldInfo?: FieldInfo\n): ExtendedJSONSchema7 {\n const result = { ...schema };\n\n for (const dec of decorators) {\n const { args } = dec;\n const resolved = dec.resolved;\n\n // If this is an extended decorator, map it to the built-in it extends\n const effectiveName = resolved?.extendsBuiltin ?? dec.name;\n\n switch (effectiveName) {\n case \"Field\": {\n // Field takes an object: { displayName, description?, placeholder? }\n const opts = args[0];\n if (typeof opts === \"object\" && opts !== null && !Array.isArray(opts)) {\n if (typeof opts[\"displayName\"] === \"string\") {\n result.title = opts[\"displayName\"];\n }\n if (typeof opts[\"description\"] === \"string\") {\n result.description = opts[\"description\"];\n }\n }\n break;\n }\n\n case \"Minimum\":\n if (typeof args[0] === \"number\") {\n result.minimum = args[0];\n }\n break;\n\n case \"Maximum\":\n if (typeof args[0] === \"number\") {\n result.maximum = args[0];\n }\n break;\n\n case \"ExclusiveMinimum\":\n if (typeof args[0] === \"number\") {\n result.exclusiveMinimum = args[0];\n }\n break;\n\n case \"ExclusiveMaximum\":\n if (typeof args[0] === \"number\") {\n result.exclusiveMaximum = args[0];\n }\n break;\n\n case \"MinLength\":\n if (typeof args[0] === \"number\") {\n result.minLength = args[0];\n }\n break;\n\n case \"MaxLength\":\n if (typeof args[0] === \"number\") {\n result.maxLength = args[0];\n }\n break;\n\n case \"Pattern\":\n if (typeof args[0] === \"string\") {\n result.pattern = args[0];\n }\n break;\n }\n\n // Emit x-formspec-* for custom decorators with a valid extensionName.\n // Extension names must be lowercase alphanumeric with hyphens (e.g., \"title-field\", \"priority\").\n if (resolved?.extensionName && /^[a-z][a-z0-9-]*$/.test(resolved.extensionName)) {\n const key = `x-formspec-${resolved.extensionName}` as const;\n if (resolved.isMarker) {\n setSchemaExtension(result, key, true);\n } else {\n // Parameterized: use first argument as value\n setSchemaExtension(result, key, args[0] ?? true);\n }\n }\n }\n\n // Apply deprecated and default from FieldInfo\n if (fieldInfo) {\n // eslint-disable-next-line @typescript-eslint/no-deprecated -- `deprecated` is a FieldInfo flag tracking @deprecated JSDoc, not itself deprecated\n if (fieldInfo.deprecated) {\n result.deprecated = true;\n }\n if (fieldInfo.defaultValue !== undefined) {\n result.default = fieldInfo.defaultValue;\n }\n }\n\n return result;\n}\n","/**\n * TypeScript program setup for static analysis.\n *\n * Creates a TypeScript program with type checker from a source file,\n * using the project's tsconfig.json for compiler options.\n */\n\nimport * as ts from \"typescript\";\nimport * as path from \"node:path\";\n\n/**\n * Result of creating a TypeScript program for analysis.\n */\nexport interface ProgramContext {\n /** The TypeScript program */\n program: ts.Program;\n /** Type checker for resolving types */\n checker: ts.TypeChecker;\n /** The source file being analyzed */\n sourceFile: ts.SourceFile;\n}\n\n/**\n * Creates a TypeScript program for analyzing a source file.\n *\n * Looks for tsconfig.json in the file's directory or parent directories.\n * Falls back to default compiler options if no config is found.\n *\n * @param filePath - Absolute path to the TypeScript source file\n * @returns Program context with checker and source file\n */\nexport function createProgramContext(filePath: string): ProgramContext {\n const absolutePath = path.resolve(filePath);\n const fileDir = path.dirname(absolutePath);\n\n // Find tsconfig.json - using ts.sys.fileExists which has `this: void` requirement\n const configPath = ts.findConfigFile(fileDir, ts.sys.fileExists.bind(ts.sys), \"tsconfig.json\");\n\n let compilerOptions: ts.CompilerOptions;\n let fileNames: string[];\n\n if (configPath) {\n const configFile = ts.readConfigFile(configPath, ts.sys.readFile.bind(ts.sys));\n if (configFile.error) {\n throw new Error(\n `Error reading tsconfig.json: ${ts.flattenDiagnosticMessageText(configFile.error.messageText, \"\\n\")}`\n );\n }\n\n const parsed = ts.parseJsonConfigFileContent(\n configFile.config,\n ts.sys,\n path.dirname(configPath)\n );\n\n if (parsed.errors.length > 0) {\n const errorMessages = parsed.errors\n .map((e) => ts.flattenDiagnosticMessageText(e.messageText, \"\\n\"))\n .join(\"\\n\");\n throw new Error(`Error parsing tsconfig.json: ${errorMessages}`);\n }\n\n compilerOptions = parsed.options;\n // Include the target file in the program\n fileNames = parsed.fileNames.includes(absolutePath)\n ? parsed.fileNames\n : [...parsed.fileNames, absolutePath];\n } else {\n // Fallback to default options\n compilerOptions = {\n target: ts.ScriptTarget.ES2022,\n module: ts.ModuleKind.NodeNext,\n moduleResolution: ts.ModuleResolutionKind.NodeNext,\n strict: true,\n skipLibCheck: true,\n declaration: true,\n };\n fileNames = [absolutePath];\n }\n\n const program = ts.createProgram(fileNames, compilerOptions);\n const sourceFile = program.getSourceFile(absolutePath);\n\n if (!sourceFile) {\n throw new Error(`Could not find source file: ${absolutePath}`);\n }\n\n return {\n program,\n checker: program.getTypeChecker(),\n sourceFile,\n };\n}\n\n/**\n * Generic AST node finder by name. Walks the source file tree and returns\n * the first node matching the predicate with the given name.\n */\nfunction findNodeByName<T extends ts.Node>(\n sourceFile: ts.SourceFile,\n name: string,\n predicate: (node: ts.Node) => node is T,\n getName: (node: T) => string | undefined\n): T | null {\n let result: T | null = null;\n\n function visit(node: ts.Node): void {\n if (result) return;\n\n if (predicate(node) && getName(node) === name) {\n result = node;\n return;\n }\n\n ts.forEachChild(node, visit);\n }\n\n visit(sourceFile);\n return result;\n}\n\n/**\n * Finds a class declaration by name in a source file.\n *\n * @param sourceFile - The source file to search\n * @param className - Name of the class to find\n * @returns The class declaration node, or null if not found\n */\nexport function findClassByName(\n sourceFile: ts.SourceFile,\n className: string\n): ts.ClassDeclaration | null {\n return findNodeByName(sourceFile, className, ts.isClassDeclaration, (n) => n.name?.text);\n}\n\n/**\n * Finds an interface declaration by name in a source file.\n *\n * @param sourceFile - The source file to search\n * @param interfaceName - Name of the interface to find\n * @returns The interface declaration node, or null if not found\n */\nexport function findInterfaceByName(\n sourceFile: ts.SourceFile,\n interfaceName: string\n): ts.InterfaceDeclaration | null {\n return findNodeByName(sourceFile, interfaceName, ts.isInterfaceDeclaration, (n) => n.name.text);\n}\n\n/**\n * Finds a type alias declaration by name in a source file.\n *\n * @param sourceFile - The source file to search\n * @param aliasName - Name of the type alias to find\n * @returns The type alias declaration node, or null if not found\n */\nexport function findTypeAliasByName(\n sourceFile: ts.SourceFile,\n aliasName: string\n): ts.TypeAliasDeclaration | null {\n return findNodeByName(sourceFile, aliasName, ts.isTypeAliasDeclaration, (n) => n.name.text);\n}\n","/**\n * Class schema generator.\n *\n * Generates JSON Schema and FormSpec/UI Schema from statically analyzed\n * class fields and decorators.\n */\n\nimport type * as ts from \"typescript\";\nimport type { ClassAnalysis, FieldInfo } from \"../analyzer/class-analyzer.js\";\nimport {\n convertType,\n applyDecoratorsToSchema,\n createFormSpecField,\n type FormSpecField,\n} from \"../analyzer/type-converter.js\";\nimport type { ExtendedJSONSchema7 } from \"../json-schema/types.js\";\nimport type { UISchema } from \"../ui-schema/types.js\";\nimport { generateUiSchemaFromFields } from \"../ui-schema/generator.js\";\nimport {\n createProgramContext,\n findClassByName,\n findInterfaceByName,\n findTypeAliasByName,\n} from \"../analyzer/program.js\";\nimport { analyzeClass, analyzeInterface, analyzeTypeAlias } from \"../analyzer/class-analyzer.js\";\n\n/**\n * Generated schemas for a class.\n */\nexport interface ClassSchemas {\n /** JSON Schema for validation */\n jsonSchema: ExtendedJSONSchema7;\n /** JSON Forms UI Schema for rendering */\n uiSchema: UISchema;\n}\n\n/**\n * Generates JSON Schema and FormSpec from a class analysis.\n *\n * Uses static type information and decorator metadata to build\n * complete schema definitions for a class's fields.\n *\n * @param analysis - The class analysis result\n * @param checker - TypeScript type checker\n * @returns Generated JSON Schema and FormSpec\n */\nexport function generateClassSchemas(\n analysis: ClassAnalysis,\n checker: ts.TypeChecker\n): ClassSchemas {\n const properties: Record<string, ExtendedJSONSchema7> = {};\n const required: string[] = [];\n const uiElements: FormSpecField[] = [];\n\n for (const field of analysis.fields) {\n // Generate JSON Schema for field\n const { jsonSchema: baseSchema } = convertType(field.type, checker);\n const fieldSchema = applyDecoratorsToSchema(baseSchema, field.decorators, field);\n properties[field.name] = fieldSchema;\n\n // Track required fields\n if (!field.optional) {\n required.push(field.name);\n }\n\n // Generate FormSpec field\n const formSpecField = createFormSpecField(\n field.name,\n field.type,\n field.decorators,\n field.optional,\n checker\n );\n uiElements.push(formSpecField);\n }\n\n // Build complete JSON Schema\n const jsonSchema: ExtendedJSONSchema7 = {\n type: \"object\",\n properties,\n ...(required.length > 0 ? { required } : {}),\n };\n\n // Convert FormSpecField[] to JSON Forms UISchema\n const uiSchema = generateUiSchemaFromFields(uiElements);\n\n return { jsonSchema, uiSchema };\n}\n\n/**\n * Generates JSON Schema for a single field.\n *\n * Useful for generating schemas for method return types\n * or individual field extraction.\n *\n * @param field - The field information\n * @param checker - TypeScript type checker\n * @returns JSON Schema for the field's type\n */\nexport function generateFieldSchema(\n field: FieldInfo,\n checker: ts.TypeChecker\n): ExtendedJSONSchema7 {\n const { jsonSchema: baseSchema } = convertType(field.type, checker);\n return applyDecoratorsToSchema(baseSchema, field.decorators, field);\n}\n\n/**\n * Options for generating schemas from a decorated class.\n */\nexport interface GenerateFromClassOptions {\n /** Path to the TypeScript source file */\n filePath: string;\n /** Class name to analyze */\n className: string;\n}\n\n/**\n * Result of generating schemas from a decorated class.\n */\nexport interface GenerateFromClassResult {\n /** JSON Schema for validation */\n jsonSchema: ExtendedJSONSchema7;\n /** JSON Forms UI Schema for rendering */\n uiSchema: UISchema;\n}\n\n/**\n * Generates JSON Schema and FormSpec/UI Schema from a decorated TypeScript class.\n *\n * This is a high-level entry point that handles the entire pipeline:\n * creating a TypeScript program, finding the class, analyzing it,\n * and generating schemas — all in one call.\n *\n * @example\n * ```typescript\n * const result = generateSchemasFromClass({\n * filePath: \"./src/forms.ts\",\n * className: \"UserForm\",\n * });\n * console.log(result.jsonSchema);\n * ```\n *\n * @param options - File path, class name, and optional compiler options\n * @returns Generated JSON Schema and FormSpec/UI Schema\n */\nexport function generateSchemasFromClass(\n options: GenerateFromClassOptions\n): GenerateFromClassResult {\n const ctx = createProgramContext(options.filePath);\n const classDecl = findClassByName(ctx.sourceFile, options.className);\n\n if (!classDecl) {\n throw new Error(`Class \"${options.className}\" not found in ${options.filePath}`);\n }\n\n const analysis = analyzeClass(classDecl, ctx.checker);\n return generateClassSchemas(analysis, ctx.checker);\n}\n\n/**\n * Options for generating schemas from a named type (class, interface, or type alias).\n */\nexport interface GenerateSchemasOptions {\n /** Path to the TypeScript source file */\n filePath: string;\n /** Name of the exported class, interface, or type alias to analyze */\n typeName: string;\n}\n\n/**\n * Generates JSON Schema and FormSpec/UI Schema from a named TypeScript\n * type — a decorated class, an interface with TSDoc tags, or a type alias.\n *\n * This is the recommended entry point. It automatically detects whether\n * the name resolves to a class, interface, or type alias and uses the\n * appropriate analysis pipeline:\n *\n * - **Classes**: extracts decorators and JSDoc constraints\n * - **Interfaces**: extracts TSDoc tags (`@Field_displayName`, `@Minimum`, etc.)\n * - **Type aliases**: object literal bodies analyzed like interfaces\n *\n * @example\n * ```typescript\n * // Works with both classes and interfaces — caller doesn't need to know\n * const result = generateSchemas({\n * filePath: \"./src/config.ts\",\n * typeName: \"DiscountConfig\",\n * });\n * ```\n *\n * @param options - File path and type name\n * @returns Generated JSON Schema and FormSpec/UI Schema\n */\nexport function generateSchemas(options: GenerateSchemasOptions): GenerateFromClassResult {\n const ctx = createProgramContext(options.filePath);\n\n // Try class first\n const classDecl = findClassByName(ctx.sourceFile, options.typeName);\n if (classDecl) {\n const analysis = analyzeClass(classDecl, ctx.checker);\n return generateClassSchemas(analysis, ctx.checker);\n }\n\n // Try interface\n const interfaceDecl = findInterfaceByName(ctx.sourceFile, options.typeName);\n if (interfaceDecl) {\n const analysis = analyzeInterface(interfaceDecl, ctx.checker);\n return generateClassSchemas(analysis, ctx.checker);\n }\n\n // Try type alias\n const typeAlias = findTypeAliasByName(ctx.sourceFile, options.typeName);\n if (typeAlias) {\n const result = analyzeTypeAlias(typeAlias, ctx.checker);\n if (result.ok) {\n return generateClassSchemas(result.analysis, ctx.checker);\n }\n throw new Error(result.error);\n }\n\n throw new Error(\n `Type \"${options.typeName}\" not found as a class, interface, or type alias in ${options.filePath}`\n );\n}\n","/**\n * Code generation for FormSpec type metadata.\n *\n * Generates a TypeScript file that patches decorated classes with\n * their extracted type metadata, enabling runtime schema generation\n * as an alternative to a TypeScript transformer.\n *\n * Usage:\n * formspec codegen ./src/forms.ts -o ./src/__formspec_types__.ts\n *\n * Then in your code:\n * import './__formspec_types__'; // Patches all decorated classes\n * import { UserFormSchema, getUserFormFormSpec } from './__formspec_types__';\n * const spec = getUserFormFormSpec();\n */\n\nimport * as ts from \"typescript\";\nimport * as path from \"node:path\";\nimport * as fs from \"node:fs\";\n\n/**\n * Type metadata format used by `@formspec/decorators`.\n *\n * Represents the runtime type information for a field that TypeScript\n * normally erases at compile time.\n */\nexport interface TypeMetadata {\n /** Base type: \"string\", \"number\", \"boolean\", \"enum\", \"array\", \"object\", \"unknown\" */\n type: string;\n /** For enum types, the possible literal values */\n values?: unknown[];\n /** For array types, metadata about the array element type */\n itemType?: TypeMetadata;\n /** For object types, metadata about each property */\n properties?: Record<string, TypeMetadata>;\n /** Whether the field accepts null */\n nullable?: boolean;\n /** Whether the field is optional (T | undefined or ?: modifier) */\n optional?: boolean;\n}\n\n/**\n * Information about a decorated class found during codegen analysis.\n *\n * Used to track which classes need type metadata patches and where\n * they are located in the source tree.\n */\nexport interface DecoratedClassInfo {\n /** Class name as it appears in the source file */\n name: string;\n /** Import path to the source file (relative to output, without extension) */\n sourcePath: string;\n /** Type metadata for all decorated properties in the class */\n typeMetadata: Record<string, TypeMetadata>;\n /** Whether the class is exported from its source file */\n isExported: boolean;\n}\n\n/**\n * Options for code generation.\n */\nexport interface CodegenOptions {\n /** Source files to analyze (glob patterns supported) */\n files: string[];\n /** Output file path */\n output: string;\n /** Base directory for relative imports */\n baseDir?: string;\n}\n\n/**\n * Finds all decorated classes in the given source files.\n */\nexport function findDecoratedClasses(files: string[], baseDir: string): DecoratedClassInfo[] {\n const program = ts.createProgram(files, {\n target: ts.ScriptTarget.ESNext,\n module: ts.ModuleKind.ESNext,\n moduleResolution: ts.ModuleResolutionKind.NodeNext,\n // TC39 Stage 3 decorators — do not use experimentalDecorators\n strict: true,\n });\n\n const checker = program.getTypeChecker();\n const results: DecoratedClassInfo[] = [];\n\n for (const sourceFile of program.getSourceFiles()) {\n if (sourceFile.isDeclarationFile) continue;\n if (!files.some((f) => path.resolve(f) === sourceFile.fileName)) continue;\n\n ts.forEachChild(sourceFile, (node) => {\n if (ts.isClassDeclaration(node) && hasDecoratedProperties(node)) {\n const className = node.name?.text;\n if (!className) return;\n\n const typeMetadata = extractTypeMetadata(node, checker);\n const relativePath = path.relative(baseDir, sourceFile.fileName);\n const exported = isClassExported(node, sourceFile);\n\n results.push({\n name: className,\n sourcePath: relativePath.replace(/\\.tsx?$/, \"\"),\n typeMetadata,\n isExported: exported,\n });\n }\n });\n }\n\n return results;\n}\n\n/**\n * Checks if a class has any decorated properties.\n */\nfunction hasDecoratedProperties(node: ts.ClassDeclaration): boolean {\n return node.members.some((member) => {\n if (!ts.isPropertyDeclaration(member)) return false;\n const decorators = ts.getDecorators(member);\n return decorators !== undefined && decorators.length > 0;\n });\n}\n\n/**\n * Checks if a class is exported from its source file.\n *\n * A class is considered exported if:\n * 1. It has the 'export' modifier directly (export class Foo {})\n * 2. It has 'export default' modifiers (export default class Foo {})\n * 3. It's referenced in a named export declaration (export { Foo })\n */\nfunction isClassExported(classNode: ts.ClassDeclaration, sourceFile: ts.SourceFile): boolean {\n const className = classNode.name?.text;\n if (!className) return false;\n\n // Check for direct export modifier (export class Foo or export default class Foo)\n const modifiers = ts.getModifiers(classNode);\n if (modifiers) {\n const hasExport = modifiers.some((mod) => mod.kind === ts.SyntaxKind.ExportKeyword);\n if (hasExport) return true;\n }\n\n // Check for named exports (export { Foo } or export { Foo as Bar })\n for (const statement of sourceFile.statements) {\n if (ts.isExportDeclaration(statement) && statement.exportClause) {\n if (ts.isNamedExports(statement.exportClause)) {\n for (const element of statement.exportClause.elements) {\n // Check if this export refers to our class\n // element.name is the exported name, element.propertyName is the local name (if renamed)\n const localName = element.propertyName?.text ?? element.name.text;\n if (localName === className) {\n return true;\n }\n }\n }\n }\n }\n\n return false;\n}\n\n/**\n * Extracts type metadata for all properties in a class.\n */\nfunction extractTypeMetadata(\n classNode: ts.ClassDeclaration,\n checker: ts.TypeChecker\n): Record<string, TypeMetadata> {\n const metadata: Record<string, TypeMetadata> = {};\n\n for (const member of classNode.members) {\n if (!ts.isPropertyDeclaration(member)) continue;\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- Both checks needed: name can be undefined OR not an identifier\n if (!member.name || !ts.isIdentifier(member.name)) continue;\n\n const symbol = checker.getSymbolAtLocation(member.name);\n // Skip properties without symbols - they don't have resolvable types\n if (!symbol) continue;\n\n const type = checker.getTypeOfSymbolAtLocation(symbol, member);\n const fieldName = member.name.text;\n const isOptional = !!(symbol.flags & ts.SymbolFlags.Optional);\n\n const typeInfo = convertTypeToMetadata(type, checker);\n if (isOptional) {\n typeInfo.optional = true;\n }\n metadata[fieldName] = typeInfo;\n }\n\n return metadata;\n}\n\n/**\n * Converts a TypeScript type to serializable metadata.\n */\nfunction convertTypeToMetadata(\n type: ts.Type,\n checker: ts.TypeChecker,\n visited = new Set<ts.Type>()\n): TypeMetadata {\n // Cycle detection for object types only\n const isObjectType = (type.flags & ts.TypeFlags.Object) !== 0;\n if (isObjectType) {\n if (visited.has(type)) {\n return { type: \"unknown\" };\n }\n visited.add(type);\n }\n\n // Handle union types\n if (type.isUnion()) {\n const types = type.types;\n const nonNullTypes = types.filter(\n (t) => !(t.flags & (ts.TypeFlags.Null | ts.TypeFlags.Undefined))\n );\n const hasNull = types.some((t) => t.flags & ts.TypeFlags.Null);\n\n // Boolean union (true | false)\n const isBooleanUnion =\n nonNullTypes.length === 2 && nonNullTypes.every((t) => t.flags & ts.TypeFlags.BooleanLiteral);\n\n if (isBooleanUnion) {\n const result: TypeMetadata = { type: \"boolean\" };\n if (hasNull) result.nullable = true;\n return result;\n }\n\n // String literal union = enum\n const allStringLiterals = nonNullTypes.every((t) => t.isStringLiteral());\n if (allStringLiterals && nonNullTypes.length > 0) {\n const result: TypeMetadata = {\n type: \"enum\",\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion -- TypeScript doesn't narrow array types from `every` predicate\n values: nonNullTypes.map((t) => (t as ts.StringLiteralType).value),\n };\n if (hasNull) result.nullable = true;\n return result;\n }\n\n // Number literal union = enum\n const allNumberLiterals = nonNullTypes.every((t) => t.isNumberLiteral());\n if (allNumberLiterals && nonNullTypes.length > 0) {\n const result: TypeMetadata = {\n type: \"enum\",\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion -- TypeScript doesn't narrow array types from `every` predicate\n values: nonNullTypes.map((t) => (t as ts.NumberLiteralType).value),\n };\n if (hasNull) result.nullable = true;\n return result;\n }\n\n // Nullable single type\n // Explicit undefined check needed for array element access\n if (nonNullTypes.length === 1) {\n const singleType = nonNullTypes[0];\n if (!singleType) return { type: \"unknown\" };\n const result = convertTypeToMetadata(singleType, checker, visited);\n if (hasNull) result.nullable = true;\n return result;\n }\n\n return { type: \"unknown\" };\n }\n\n // Primitives\n if (type.flags & ts.TypeFlags.String) return { type: \"string\" };\n if (type.flags & ts.TypeFlags.Number) return { type: \"number\" };\n if (type.flags & ts.TypeFlags.Boolean) return { type: \"boolean\" };\n\n // String literal\n if (type.isStringLiteral()) {\n return { type: \"enum\", values: [type.value] };\n }\n\n // Number literal\n if (type.isNumberLiteral()) {\n return { type: \"enum\", values: [type.value] };\n }\n\n // Arrays\n if (checker.isArrayType(type)) {\n const typeArgs = (type as ts.TypeReference).typeArguments;\n return {\n type: \"array\",\n itemType: typeArgs?.[0]\n ? convertTypeToMetadata(typeArgs[0], checker, visited)\n : { type: \"unknown\" },\n };\n }\n\n // Objects\n if (type.flags & ts.TypeFlags.Object) {\n const properties: Record<string, TypeMetadata> = {};\n for (const prop of type.getProperties()) {\n // Skip properties without declarations - undefined check needed because declarations array can be empty\n const declaration = prop.valueDeclaration ?? prop.declarations?.[0];\n if (!declaration) continue;\n\n const propType = checker.getTypeOfSymbolAtLocation(prop, declaration);\n const propOptional = !!(prop.flags & ts.SymbolFlags.Optional);\n const propMeta = convertTypeToMetadata(propType, checker, visited);\n if (propOptional) propMeta.optional = true;\n properties[prop.name] = propMeta;\n }\n\n if (Object.keys(properties).length > 0) {\n return { type: \"object\", properties };\n }\n return { type: \"object\" };\n }\n\n return { type: \"unknown\" };\n}\n\n/**\n * Generates the codegen output file content.\n */\nexport function generateCodegenOutput(\n classes: DecoratedClassInfo[],\n outputPath: string,\n baseDir: string\n): string {\n const outputDir = path.dirname(path.resolve(outputPath));\n const lines: string[] = [\n \"/**\",\n \" * Auto-generated by FormSpec CLI.\",\n \" * DO NOT EDIT - changes will be overwritten.\",\n \" *\",\n \" * This file provides:\",\n \" * - Type metadata patches for runtime schema generation\",\n \" * - Inferred schema types (e.g., UserFormSchema)\",\n \" * - Type-safe FormSpec accessors (e.g., getUserFormFormSpec())\",\n \" *\",\n \" * Usage:\",\n \" * import { UserFormSchema, getUserFormFormSpec } from './__formspec_types__';\",\n \" *\",\n \" * const data: UserFormSchema = { name: 'Alice', country: 'us' };\",\n \" * const spec = getUserFormFormSpec();\",\n \" */\",\n \"\",\n \"/* eslint-disable @typescript-eslint/no-explicit-any */\",\n \"\",\n ];\n\n // Generate imports\n for (const cls of classes) {\n // Compute absolute source path, then relative from output dir\n const absoluteSourcePath = path.resolve(baseDir, cls.sourcePath);\n const importPath = getRelativeImportPath(outputDir, absoluteSourcePath);\n lines.push(`import { ${cls.name} } from \"${importPath}\";`);\n }\n\n lines.push(\"\");\n lines.push(\"// =============================================================================\");\n lines.push(\"// Type Metadata Patches\");\n lines.push(\"// =============================================================================\");\n lines.push(\"\");\n\n // Generate patches\n for (const cls of classes) {\n const metadataJson = JSON.stringify(cls.typeMetadata, null, 2)\n .split(\"\\n\")\n .map((line, i) => (i === 0 ? line : \" \" + line))\n .join(\"\\n\");\n\n lines.push(`(${cls.name} as any).__formspec_types__ = ${metadataJson};`);\n lines.push(\"\");\n }\n\n lines.push(\"// =============================================================================\");\n lines.push(\"// Inferred Schema Types\");\n lines.push(\"// =============================================================================\");\n lines.push(\"\");\n\n // Generate schema types\n for (const cls of classes) {\n lines.push(generateSchemaType(cls));\n lines.push(\"\");\n }\n\n lines.push(\"// =============================================================================\");\n lines.push(\"// Type-Safe FormSpec Accessors\");\n lines.push(\"// =============================================================================\");\n lines.push(\"\");\n\n // Generate typed accessors\n for (const cls of classes) {\n lines.push(generateTypedAccessor(cls));\n lines.push(\"\");\n }\n\n return lines.join(\"\\n\");\n}\n\n/**\n * Converts TypeMetadata to a TypeScript type string.\n */\nfunction metadataToTypeString(metadata: TypeMetadata): string {\n const baseType = metadataToBaseTypeString(metadata);\n\n // Handle nullable and optional modifiers\n if (metadata.nullable && metadata.optional) {\n return `${baseType} | null | undefined`;\n }\n if (metadata.nullable) {\n return `${baseType} | null`;\n }\n if (metadata.optional) {\n return `${baseType} | undefined`;\n }\n return baseType;\n}\n\n/**\n * Checks if a property key needs to be quoted in TypeScript object types.\n *\n * Property keys need quoting if they:\n * - Contain characters invalid in JavaScript identifiers (spaces, hyphens, etc.)\n * - Are reserved JavaScript/TypeScript keywords (class, function, etc.)\n *\n * @param key - The property name to check\n * @returns true if the key requires quotes, false otherwise\n */\n// Valid JS identifier: starts with letter/underscore/$, followed by alphanumeric/_/$\nconst VALID_IDENTIFIER = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;\n\n// Reserved words that need quoting (comprehensive list including ES6+)\nconst RESERVED_WORDS = new Set([\n // Keywords\n \"break\",\n \"case\",\n \"catch\",\n \"continue\",\n \"debugger\",\n \"default\",\n \"delete\",\n \"do\",\n \"else\",\n \"finally\",\n \"for\",\n \"function\",\n \"if\",\n \"in\",\n \"instanceof\",\n \"new\",\n \"return\",\n \"switch\",\n \"this\",\n \"throw\",\n \"try\",\n \"typeof\",\n \"var\",\n \"void\",\n \"while\",\n \"with\",\n \"class\",\n \"const\",\n \"enum\",\n \"export\",\n \"extends\",\n \"import\",\n \"super\",\n \"implements\",\n \"interface\",\n \"let\",\n \"package\",\n \"private\",\n \"protected\",\n \"public\",\n \"static\",\n \"yield\",\n // ES6+ keywords\n \"async\",\n \"await\",\n // Literal values (not technically keywords but best to quote)\n \"null\",\n \"true\",\n \"false\",\n // Accessor keywords\n \"get\",\n \"set\",\n // Strict mode reserved\n \"arguments\",\n \"eval\",\n]);\n\nfunction needsPropertyQuoting(key: string): boolean {\n if (!VALID_IDENTIFIER.test(key)) {\n return true;\n }\n return RESERVED_WORDS.has(key);\n}\n\n/**\n * Escapes a property key for safe use in TypeScript type definitions.\n *\n * Wraps keys in double quotes if they need quoting, using JSON.stringify\n * for robust escaping of special characters.\n *\n * @param key - The property name to escape\n * @returns The escaped key, quoted if necessary\n */\nfunction escapePropertyKey(key: string): string {\n if (needsPropertyQuoting(key)) {\n return JSON.stringify(key);\n }\n return key;\n}\n\n/**\n * Converts TypeMetadata to base type string (without null/optional modifiers).\n */\nfunction metadataToBaseTypeString(metadata: TypeMetadata): string {\n switch (metadata.type) {\n case \"string\":\n return \"string\";\n case \"number\":\n return \"number\";\n case \"boolean\":\n return \"boolean\";\n case \"enum\":\n if (metadata.values && metadata.values.length > 0) {\n return metadata.values\n .map((v) => (typeof v === \"string\" ? JSON.stringify(v) : String(v)))\n .join(\" | \");\n }\n return \"string\";\n case \"array\":\n if (metadata.itemType) {\n const itemType = metadataToTypeString(metadata.itemType);\n // Wrap union types in parentheses for array\n if (itemType.includes(\"|\")) {\n return `(${itemType})[]`;\n }\n return `${itemType}[]`;\n }\n return \"unknown[]\";\n case \"object\":\n if (metadata.properties && Object.keys(metadata.properties).length > 0) {\n const props = Object.entries(metadata.properties)\n .map(([key, propMeta]) => {\n const optional = propMeta.optional ? \"?\" : \"\";\n return `${escapePropertyKey(key)}${optional}: ${metadataToTypeString(propMeta)}`;\n })\n .join(\"; \");\n return `{ ${props} }`;\n }\n return \"Record<string, unknown>\";\n default:\n return \"unknown\";\n }\n}\n\n/**\n * Generates a TypeScript schema type for a class.\n */\nfunction generateSchemaType(cls: DecoratedClassInfo): string {\n const props = Object.entries(cls.typeMetadata)\n .map(([fieldName, metadata]) => {\n const optional = metadata.optional ? \"?\" : \"\";\n const typeStr = metadataToTypeString(metadata);\n return ` ${escapePropertyKey(fieldName)}${optional}: ${typeStr};`;\n })\n .join(\"\\n\");\n\n return `export type ${cls.name}Schema = {\\n${props}\\n};`;\n}\n\n/**\n * Maps TypeMetadata type strings to FormSpec field type strings.\n *\n * TypeMetadata uses generic type names (string, number), while FormSpec\n * uses more specific field type names (text, number, enum).\n *\n * @param type - The TypeMetadata type string\n * @returns The corresponding FormSpec field type\n */\nfunction metadataTypeToFieldType(type: string): string {\n switch (type) {\n case \"string\":\n return \"text\";\n case \"number\":\n return \"number\";\n case \"boolean\":\n return \"boolean\";\n case \"enum\":\n return \"enum\";\n case \"array\":\n return \"array\";\n case \"object\":\n return \"object\";\n default:\n return \"text\";\n }\n}\n\n/**\n * Generates typed FormSpec accessor for a class.\n *\n * Creates three exports:\n * 1. Element tuple type (e.g., UserFormElements) - Exact readonly array type\n * representing each field with its literal types preserved\n * 2. FormSpec result type (e.g., UserFormFormSpec) - Type alias wrapping the elements\n * 3. Accessor function (e.g., getUserFormFormSpec()) - Returns FormSpec with full\n * type information for autocomplete and type checking\n *\n * These types enable the same level of type inference as the Chain DSL.\n *\n * @param cls - The decorated class information\n * @returns TypeScript code defining the accessor function and types\n */\nfunction generateTypedAccessor(cls: DecoratedClassInfo): string {\n const lines: string[] = [];\n\n // Generate the element type as a tuple\n const elementTypes = Object.entries(cls.typeMetadata).map(([fieldName, metadata]) => {\n const fieldType = metadataTypeToFieldType(metadata.type);\n const required = !metadata.optional;\n\n let elementType = `{ readonly _field: \"${fieldType}\"; readonly id: \"${fieldName}\"; readonly required: ${String(required)}`;\n\n // Add options for enum types\n if (metadata.type === \"enum\" && metadata.values) {\n const optionValues = metadata.values\n .map((v) => (typeof v === \"string\" ? JSON.stringify(v) : String(v)))\n .join(\", \");\n elementType += `; readonly options: readonly [${optionValues}]`;\n }\n\n elementType += \" }\";\n return elementType;\n });\n\n // Export element tuple type\n lines.push(`export type ${cls.name}Elements = readonly [\\n ${elementTypes.join(\",\\n \")}\\n];`);\n lines.push(\"\");\n\n // Export typed FormSpec result type\n lines.push(`export type ${cls.name}FormSpec = { readonly elements: ${cls.name}Elements };`);\n lines.push(\"\");\n\n // Export typed accessor function\n lines.push(`/**`);\n lines.push(` * Type-safe FormSpec accessor for ${cls.name}.`);\n lines.push(` * Reads the patched type metadata from the class.`);\n lines.push(` */`);\n lines.push(`export function get${cls.name}FormSpec(): ${cls.name}FormSpec {`);\n lines.push(\n ` const types = (${cls.name} as any).__formspec_types__ as Record<string, unknown>[];`\n );\n lines.push(` return { elements: types } as unknown as ${cls.name}FormSpec;`);\n lines.push(`}`);\n\n return lines.join(\"\\n\");\n}\n\n/**\n * Gets a relative import path from output to source.\n */\nfunction getRelativeImportPath(outputDir: string, sourcePath: string): string {\n // sourcePath is already relative to baseDir\n let relativePath = path.relative(outputDir, sourcePath);\n\n // Ensure it starts with ./ or ../\n if (!relativePath.startsWith(\".\")) {\n relativePath = \"./\" + relativePath;\n }\n\n // Use forward slashes for imports\n relativePath = relativePath.replace(/\\\\/g, \"/\");\n\n // Add .js extension for ESM compatibility\n return relativePath + \".js\";\n}\n\n/**\n * Runs the code generation.\n */\nexport function runCodegen(options: CodegenOptions): void {\n const baseDir = options.baseDir ?? path.dirname(options.output);\n const absoluteFiles = options.files.map((f) => path.resolve(f));\n\n console.log(`Scanning ${String(absoluteFiles.length)} file(s) for decorated classes...`);\n\n const classes = findDecoratedClasses(absoluteFiles, baseDir);\n\n if (classes.length === 0) {\n console.log(\"No decorated classes found.\");\n return;\n }\n\n console.log(`Found ${String(classes.length)} decorated class(es):`);\n for (const cls of classes) {\n const fieldCount = Object.keys(cls.typeMetadata).length;\n console.log(` - ${cls.name} (${String(fieldCount)} field(s))`);\n }\n\n // Check for unexported classes and warn\n const unexported = classes.filter((cls) => !cls.isExported);\n if (unexported.length > 0) {\n console.warn(\n `\\n⚠️ Warning: The following decorated classes are not exported from their source files:`\n );\n for (const cls of unexported) {\n console.warn(` - ${cls.name} (${cls.sourcePath})`);\n }\n console.warn(\n `\\n The generated code will fail to compile because it cannot import these classes.`\n );\n console.warn(` To fix this, add 'export' to the class declaration, for example:`);\n console.warn(` export class YourClassName { ... }\\n`);\n }\n\n const output = generateCodegenOutput(classes, options.output, baseDir);\n\n // Ensure output directory exists\n const outputDir = path.dirname(options.output);\n if (!fs.existsSync(outputDir)) {\n fs.mkdirSync(outputDir, { recursive: true });\n }\n\n fs.writeFileSync(options.output, output);\n console.log(`\\nGenerated: ${options.output}`);\n}\n","/**\n * `@formspec/build` - Build tools for FormSpec\n *\n * This package provides generators to compile FormSpec forms into:\n * - JSON Schema (for validation)\n * - JSON Forms UI Schema (for rendering)\n *\n * @example\n * ```typescript\n * import { buildFormSchemas } from \"@formspec/build\";\n * import { formspec, field, group } from \"@formspec/dsl\";\n *\n * const form = formspec(\n * group(\"Customer\",\n * field.text(\"name\", { label: \"Name\", required: true }),\n * field.text(\"email\", { label: \"Email\" }),\n * ),\n * );\n *\n * const { jsonSchema, uiSchema } = buildFormSchemas(form);\n * ```\n *\n * @packageDocumentation\n */\n\nimport type { FormElement, FormSpec } from \"@formspec/core\";\nimport { generateJsonSchema } from \"./json-schema/generator.js\";\nimport { generateUiSchema } from \"./ui-schema/generator.js\";\nimport type { JSONSchema7 } from \"./json-schema/types.js\";\nimport type { UISchema } from \"./ui-schema/types.js\";\nimport * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\n// =============================================================================\n// Type Exports\n// =============================================================================\n\nexport type {\n JSONSchema7,\n JSONSchemaType,\n ExtendedJSONSchema7,\n FormSpecSchemaExtensions,\n} from \"./json-schema/types.js\";\n\nexport { setSchemaExtension, getSchemaExtension } from \"./json-schema/types.js\";\n\nexport type {\n UISchema,\n UISchemaElement,\n UISchemaElementBase,\n UISchemaElementType,\n ControlElement,\n VerticalLayout,\n HorizontalLayout,\n GroupLayout,\n Categorization,\n Category,\n LabelElement,\n Rule,\n RuleEffect,\n RuleConditionSchema,\n SchemaBasedCondition,\n} from \"./ui-schema/types.js\";\n\nexport type { FormSpecField } from \"./analyzer/type-converter.js\";\n\nexport type {\n ClassSchemas,\n GenerateFromClassOptions,\n GenerateFromClassResult,\n GenerateSchemasOptions,\n} from \"./generators/class-schema.js\";\n\nexport type { TypeMetadata, DecoratedClassInfo, CodegenOptions } from \"./codegen/index.js\";\n\n// =============================================================================\n// Zod Validation Schemas\n// =============================================================================\n\nexport {\n ruleEffectSchema,\n uiSchemaElementTypeSchema,\n ruleConditionSchema,\n schemaBasedConditionSchema,\n ruleSchema,\n controlSchema,\n verticalLayoutSchema,\n horizontalLayoutSchema,\n groupLayoutSchema,\n categorizationSchema,\n categorySchema,\n labelElementSchema,\n uiSchemaElementSchema,\n uiSchema as uiSchemaSchema,\n} from \"./ui-schema/schema.js\";\n\nexport { jsonSchemaTypeSchema, jsonSchema7Schema } from \"./json-schema/schema.js\";\n\n// =============================================================================\n// Chain DSL Generators\n// =============================================================================\n\nexport { generateJsonSchema } from \"./json-schema/generator.js\";\nexport { generateUiSchema, generateUiSchemaFromFields } from \"./ui-schema/generator.js\";\n\n// =============================================================================\n// Decorator DSL: High-Level Entry Points\n// =============================================================================\n\nexport { generateSchemasFromClass, generateSchemas } from \"./generators/class-schema.js\";\n\n// generateSchemas is the recommended entry point — it auto-detects class/interface/type alias.\n// generateSchemasFromClass is retained for backwards compatibility.\n\nexport { findDecoratedClasses, generateCodegenOutput, runCodegen } from \"./codegen/index.js\";\n\n/**\n * Result of building form schemas.\n */\nexport interface BuildResult {\n /** JSON Schema for validation */\n readonly jsonSchema: JSONSchema7;\n /** JSON Forms UI Schema for rendering */\n readonly uiSchema: UISchema;\n}\n\n/**\n * Builds both JSON Schema and UI Schema from a FormSpec.\n *\n * This is a convenience function that combines `generateJsonSchema`\n * and `generateUiSchema`.\n *\n * @example\n * ```typescript\n * const form = formspec(\n * field.text(\"name\", { required: true }),\n * field.number(\"age\", { min: 0 }),\n * );\n *\n * const { jsonSchema, uiSchema } = buildFormSchemas(form);\n *\n * // Use with JSON Forms renderer\n * <JsonForms\n * schema={jsonSchema}\n * uischema={uiSchema}\n * data={formData}\n * renderers={materialRenderers}\n * />\n * ```\n *\n * @param form - The FormSpec to build schemas from\n * @returns Object containing both jsonSchema and uiSchema\n */\nexport function buildFormSchemas<E extends readonly FormElement[]>(form: FormSpec<E>): BuildResult {\n return {\n jsonSchema: generateJsonSchema(form),\n uiSchema: generateUiSchema(form),\n };\n}\n\n/**\n * Options for writing schemas to disk.\n */\nexport interface WriteSchemasOptions {\n /** Output directory for the schema files */\n readonly outDir: string;\n /** Base name for the output files (without extension). Defaults to \"schema\" */\n readonly name?: string;\n /** Number of spaces for JSON indentation. Defaults to 2 */\n readonly indent?: number;\n}\n\n/**\n * Result of writing schemas to disk.\n */\nexport interface WriteSchemasResult {\n /** Path to the generated JSON Schema file */\n readonly jsonSchemaPath: string;\n /** Path to the generated UI Schema file */\n readonly uiSchemaPath: string;\n}\n\n/**\n * Builds and writes both JSON Schema and UI Schema files to disk.\n *\n * This is a convenience function for build-time schema generation.\n * It creates the output directory if it doesn't exist.\n *\n * @example\n * ```typescript\n * import { formspec, field } from \"formspec\";\n * import { writeSchemas } from \"@formspec/build\";\n *\n * const ProductForm = formspec(\n * field.text(\"name\", { required: true }),\n * field.enum(\"status\", [\"draft\", \"active\"]),\n * );\n *\n * // Write schemas to ./generated/product-schema.json and ./generated/product-uischema.json\n * const { jsonSchemaPath, uiSchemaPath } = writeSchemas(ProductForm, {\n * outDir: \"./generated\",\n * name: \"product\",\n * });\n *\n * console.log(`Generated: ${jsonSchemaPath}, ${uiSchemaPath}`);\n * ```\n *\n * @param form - The FormSpec to build schemas from\n * @param options - Output options (directory, file name, indentation)\n * @returns Object containing paths to the generated files\n */\nexport function writeSchemas<E extends readonly FormElement[]>(\n form: FormSpec<E>,\n options: WriteSchemasOptions\n): WriteSchemasResult {\n const { outDir, name = \"schema\", indent = 2 } = options;\n\n // Build schemas\n const { jsonSchema, uiSchema } = buildFormSchemas(form);\n\n // Ensure output directory exists\n if (!fs.existsSync(outDir)) {\n fs.mkdirSync(outDir, { recursive: true });\n }\n\n // Write files\n const jsonSchemaPath = path.join(outDir, `${name}-schema.json`);\n const uiSchemaPath = path.join(outDir, `${name}-uischema.json`);\n\n fs.writeFileSync(jsonSchemaPath, JSON.stringify(jsonSchema, null, indent));\n fs.writeFileSync(uiSchemaPath, JSON.stringify(uiSchema, null, indent));\n\n return { jsonSchemaPath, uiSchemaPath };\n}\n","#!/usr/bin/env node\n/**\n * FormSpec CLI - Generate JSON Schema and UI Schema from form definitions\n *\n * Usage:\n * formspec-build <input-file> [options]\n *\n * Options:\n * -o, --out-dir <dir> Output directory (default: ./generated)\n * -n, --name <name> Base name for output files (default: derived from input)\n * -h, --help Show help\n *\n * Example:\n * formspec-build src/forms/product.ts -o ./schemas -n product\n */\n\nimport * as path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\ninterface CliOptions {\n inputFile: string;\n outDir: string;\n name: string;\n}\n\nfunction printHelp(): void {\n console.log(`\nFormSpec Build CLI - Generate JSON Schema and UI Schema\n\nUsage:\n formspec-build <input-file> [options]\n\nOptions:\n -o, --out-dir <dir> Output directory (default: ./generated)\n -n, --name <name> Base name for output files (default: derived from input)\n -h, --help Show this help message\n\nExample:\n formspec-build src/forms/product.ts -o ./schemas -n product\n\nThe input file should export a FormSpec as its default export or as 'form':\n // product-form.ts\n import { formspec, field } from \"formspec\";\n export default formspec(field.text(\"name\"));\n // or: export const form = formspec(field.text(\"name\"));\n`);\n}\n\nfunction parseArgs(args: string[]): CliOptions | null {\n const positional: string[] = [];\n let outDir = \"./generated\";\n let name = \"\";\n\n for (let i = 0; i < args.length; i++) {\n const arg = args[i];\n if (arg === undefined) continue;\n\n if (arg === \"-h\" || arg === \"--help\") {\n printHelp();\n process.exit(0);\n }\n\n if (arg === \"-o\" || arg === \"--out-dir\") {\n const nextArg = args[i + 1];\n if (!nextArg) {\n console.error(\"Error: --out-dir requires a value\");\n return null;\n }\n outDir = nextArg;\n i++;\n continue;\n }\n\n if (arg === \"-n\" || arg === \"--name\") {\n const nextArg = args[i + 1];\n if (!nextArg) {\n console.error(\"Error: --name requires a value\");\n return null;\n }\n name = nextArg;\n i++;\n continue;\n }\n\n if (arg.startsWith(\"-\")) {\n console.error(`Error: Unknown option: ${arg}`);\n return null;\n }\n\n positional.push(arg);\n }\n\n if (positional.length === 0) {\n console.error(\"Error: No input file specified\");\n printHelp();\n return null;\n }\n\n const inputFile = positional[0];\n if (!inputFile) {\n console.error(\"Error: No input file specified\");\n return null;\n }\n\n // Default name from input file\n if (!name) {\n name = path.basename(inputFile, path.extname(inputFile));\n }\n\n return { inputFile, outDir, name };\n}\n\nasync function main(): Promise<void> {\n const args = process.argv.slice(2);\n const options = parseArgs(args);\n\n if (!options) {\n process.exit(1);\n }\n\n const { inputFile, outDir, name } = options;\n\n // Resolve input file path\n const absoluteInput = path.resolve(process.cwd(), inputFile);\n\n try {\n // Dynamically import the input file\n // Use file URL for cross-platform compatibility (Windows paths need file:// URLs)\n const fileUrl = pathToFileURL(absoluteInput).href;\n const module = (await import(fileUrl)) as Record<string, unknown>;\n\n // Look for the form export\n const form = module[\"default\"] ?? module[\"form\"];\n\n if (!form || typeof form !== \"object\" || !(\"elements\" in form)) {\n console.error(\"Error: Input file must export a FormSpec as default export or as 'form'\");\n console.error(\"Example:\");\n console.error(' export default formspec(field.text(\"name\"));');\n console.error(\" // or\");\n console.error(' export const form = formspec(field.text(\"name\"));');\n process.exit(1);\n }\n\n // Import writeSchemas dynamically to avoid circular deps\n const { writeSchemas } = await import(\"./index.js\");\n\n const { jsonSchemaPath, uiSchemaPath } = writeSchemas(\n form as Parameters<typeof writeSchemas>[0],\n { outDir, name }\n );\n\n console.log(\"Generated:\");\n console.log(` ${jsonSchemaPath}`);\n console.log(` ${uiSchemaPath}`);\n } catch (error) {\n if (error instanceof Error) {\n console.error(`Error: ${error.message}`);\n } else {\n console.error(\"Error:\", error);\n }\n process.exit(1);\n }\n}\n\nvoid main();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IASA,YAUa,sBAuBA;AA1Cb;AAAA;AAAA;AASA,iBAAkB;AAUX,IAAM,uBAAuB,aAAE,KAAK;AAAA,MACzC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAeM,IAAM,oBAA4C,aAAE;AAAA,MAAK,MAC9D,aACG,OAAO;AAAA,QACN,SAAS,aAAE,OAAO,EAAE,SAAS;AAAA,QAC7B,KAAK,aAAE,OAAO,EAAE,SAAS;AAAA,QACzB,MAAM,aAAE,OAAO,EAAE,SAAS;AAAA;AAAA,QAG1B,OAAO,aAAE,OAAO,EAAE,SAAS;AAAA,QAC3B,aAAa,aAAE,OAAO,EAAE,SAAS;AAAA,QACjC,YAAY,aAAE,QAAQ,EAAE,SAAS;AAAA;AAAA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M,EAAE,WAAW,QAAQ,KAAK,IAAI;AAGpC,QAAM,gBAAqB,cAAQ,QAAQ,IAAI,GAAG,SAAS;AAE3D,MAAI;AAGF,UAAM,cAAU,+BAAc,aAAa,EAAE;AAC7C,UAAMC,UAAU,MAAM,OAAO;AAG7B,UAAM,OAAOA,QAAO,SAAS,KAAKA,QAAO,MAAM;AAE/C,QAAI,CAAC,QAAQ,OAAO,SAAS,YAAY,EAAE,cAAc,OAAO;AAC9D,cAAQ,MAAM,yEAAyE;AACvF,cAAQ,MAAM,UAAU;AACxB,cAAQ,MAAM,gDAAgD;AAC9D,cAAQ,MAAM,SAAS;AACvB,cAAQ,MAAM,qDAAqD;AACnE,cAAQ,KAAK,CAAC;AAAA,IAChB;AAGA,UAAM,EAAE,cAAAC,cAAa,IAAI,MAAM;AAE/B,UAAM,EAAE,gBAAgB,aAAa,IAAIA;AAAA,MACvC;AAAA,MACA,EAAE,QAAQ,KAAK;AAAA,IACjB;AAEA,YAAQ,IAAI,YAAY;AACxB,YAAQ,IAAI,KAAK,cAAc,EAAE;AACjC,YAAQ,IAAI,KAAK,YAAY,EAAE;AAAA,EACjC,SAAS,OAAO;AACd,QAAI,iBAAiB,OAAO;AAC1B,cAAQ,MAAM,UAAU,MAAM,OAAO,EAAE;AAAA,IACzC,OAAO;AACL,cAAQ,MAAM,UAAU,KAAK;AAAA,IAC/B;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;AAEA,KAAK,KAAK;","names":["import_zod","import_zod","init_schema","parseOrThrow","import_zod","init_generator","init_schema","ts","import_core","ts","ts","ts","uiSchema","init_generator","ts","path","uiSchema","fs","path","init_generator","init_schema","path","module","writeSchemas"]}