@formspec/build 0.1.0-alpha.24 → 0.1.0-alpha.27

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 (39) hide show
  1. package/dist/analyzer/program.d.ts +12 -0
  2. package/dist/analyzer/program.d.ts.map +1 -1
  3. package/dist/browser.cjs.map +1 -1
  4. package/dist/browser.d.ts +1 -0
  5. package/dist/browser.d.ts.map +1 -1
  6. package/dist/browser.js.map +1 -1
  7. package/dist/build-alpha.d.ts +167 -22
  8. package/dist/build-beta.d.ts +167 -22
  9. package/dist/build-internal.d.ts +167 -22
  10. package/dist/build.d.ts +239 -21
  11. package/dist/cli.cjs +118 -6
  12. package/dist/cli.cjs.map +1 -1
  13. package/dist/cli.js +117 -6
  14. package/dist/cli.js.map +1 -1
  15. package/dist/generators/class-schema.d.ts +27 -0
  16. package/dist/generators/class-schema.d.ts.map +1 -1
  17. package/dist/generators/mixed-authoring.d.ts.map +1 -1
  18. package/dist/index.cjs +114 -6
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.ts +5 -3
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +111 -6
  23. package/dist/index.js.map +1 -1
  24. package/dist/internals.cjs +46 -0
  25. package/dist/internals.cjs.map +1 -1
  26. package/dist/internals.d.ts +1 -1
  27. package/dist/internals.d.ts.map +1 -1
  28. package/dist/internals.js +44 -0
  29. package/dist/internals.js.map +1 -1
  30. package/dist/json-schema/ir-generator.d.ts +30 -0
  31. package/dist/json-schema/ir-generator.d.ts.map +1 -1
  32. package/dist/json-schema/schema.d.ts +2 -2
  33. package/dist/json-schema/types.d.ts +35 -4
  34. package/dist/json-schema/types.d.ts.map +1 -1
  35. package/dist/ui-schema/schema.d.ts +2 -7
  36. package/dist/ui-schema/schema.d.ts.map +1 -1
  37. package/dist/ui-schema/types.d.ts +58 -0
  38. package/dist/ui-schema/types.d.ts.map +1 -1
  39. package/package.json +4 -4
package/dist/build.d.ts CHANGED
@@ -27,9 +27,7 @@ import { AnyField } from '@formspec/core';
27
27
  import { ArrayField } from '@formspec/core';
28
28
  import { BooleanField } from '@formspec/core';
29
29
  import { BuiltinConstraintBroadeningRegistration } from '@formspec/core';
30
- import { BuiltinConstraintName } from '@formspec/core';
31
30
  import { Conditional } from '@formspec/core';
32
- import { ConstraintSemanticRole } from '@formspec/core';
33
31
  import { ConstraintTagRegistration } from '@formspec/core';
34
32
  import { CustomAnnotationRegistration } from '@formspec/core';
35
33
  import { CustomConstraintRegistration } from '@formspec/core';
@@ -38,10 +36,7 @@ import { DynamicEnumField } from '@formspec/core';
38
36
  import { DynamicSchemaField } from '@formspec/core';
39
37
  import { EnumOption } from '@formspec/core';
40
38
  import { EnumOptionValue } from '@formspec/core';
41
- import { ExtensionApplicableType } from '@formspec/core';
42
39
  import { ExtensionDefinition } from '@formspec/core';
43
- import { ExtensionPayloadValue } from '@formspec/core';
44
- import { ExtensionTypeKind } from '@formspec/core';
45
40
  import { FormElement } from '@formspec/core';
46
41
  import { FormSpec } from '@formspec/core';
47
42
  import { Group } from '@formspec/core';
@@ -49,7 +44,8 @@ import { NumberField } from '@formspec/core';
49
44
  import { ObjectField } from '@formspec/core';
50
45
  import { StaticEnumField } from '@formspec/core';
51
46
  import { TextField } from '@formspec/core';
52
- import { VocabularyKeywordRegistration } from '@formspec/core';
47
+ import * as ts from 'typescript';
48
+ import { z } from 'zod';
53
49
 
54
50
  export { AnyField }
55
51
 
@@ -142,19 +138,23 @@ export declare interface BuildResult {
142
138
 
143
139
  export { BuiltinConstraintBroadeningRegistration }
144
140
 
145
- export { BuiltinConstraintName }
146
-
147
141
  /**
148
142
  * A Categorization element (tab-based layout).
149
143
  *
150
144
  * @public
151
145
  */
152
146
  export declare interface Categorization {
147
+ /** Discriminator identifying a categorization layout. */
153
148
  readonly type: "Categorization";
149
+ /** Categories rendered as tabs or steps. */
154
150
  readonly elements: Category[];
151
+ /** Optional label for the overall categorization container. */
155
152
  readonly label?: string | undefined;
153
+ /** Optional rule controlling visibility or enablement. */
156
154
  readonly rule?: Rule | undefined;
155
+ /** Renderer-specific categorization options. */
157
156
  readonly options?: Record<string, unknown> | undefined;
157
+ /** Additional renderer-specific extension properties. */
158
158
  readonly [k: string]: unknown;
159
159
  }
160
160
 
@@ -164,18 +164,22 @@ export declare interface Categorization {
164
164
  * @public
165
165
  */
166
166
  export declare interface Category {
167
+ /** Discriminator identifying a category inside a categorization layout. */
167
168
  readonly type: "Category";
169
+ /** Category label shown in tabs or step navigation. */
168
170
  readonly label: string;
171
+ /** Child elements rendered inside the category. */
169
172
  readonly elements: UISchemaElement[];
173
+ /** Optional rule controlling visibility or enablement. */
170
174
  readonly rule?: Rule | undefined;
175
+ /** Renderer-specific category options. */
171
176
  readonly options?: Record<string, unknown> | undefined;
177
+ /** Additional renderer-specific extension properties. */
172
178
  readonly [k: string]: unknown;
173
179
  }
174
180
 
175
181
  export { Conditional }
176
182
 
177
- export { ConstraintSemanticRole }
178
-
179
183
  export { ConstraintTagRegistration }
180
184
 
181
185
  /**
@@ -184,11 +188,17 @@ export { ConstraintTagRegistration }
184
188
  * @public
185
189
  */
186
190
  export declare interface ControlElement {
191
+ /** Discriminator identifying a JSON Forms control element. */
187
192
  readonly type: "Control";
193
+ /** JSON Pointer scope that this control binds to. */
188
194
  readonly scope: string;
195
+ /** Optional label override, or `false` to suppress the label. */
189
196
  readonly label?: string | false | undefined;
197
+ /** Optional rule controlling visibility or enablement. */
190
198
  readonly rule?: Rule | undefined;
199
+ /** Renderer-specific control options. */
191
200
  readonly options?: Record<string, unknown> | undefined;
201
+ /** Additional renderer-specific extension properties. */
192
202
  readonly [k: string]: unknown;
193
203
  }
194
204
 
@@ -221,13 +231,15 @@ export { EnumOption }
221
231
 
222
232
  export { EnumOptionValue }
223
233
 
224
- /* Excluded from this release type: ExtendedJSONSchema7 */
225
- export { ExtensionApplicableType }
234
+ /**
235
+ * JSON Schema with FormSpec extension properties for arbitrary `x-formspec-*` keys.
236
+ *
237
+ * @public
238
+ */
239
+ export declare type ExtendedJSONSchema7 = JSONSchema7 & FormSpecSchemaExtensions;
226
240
 
227
241
  export { ExtensionDefinition }
228
242
 
229
- export { ExtensionPayloadValue }
230
-
231
243
  /**
232
244
  * A registry of extensions that provides lookup by fully-qualified ID.
233
245
  *
@@ -287,13 +299,16 @@ export declare interface ExtensionRegistry {
287
299
  findAnnotation(annotationId: string): CustomAnnotationRegistration | undefined;
288
300
  }
289
301
 
290
- export { ExtensionTypeKind }
291
-
292
302
  export { FormElement }
293
303
 
294
304
  export { FormSpec }
295
305
 
296
- /* Excluded from this release type: FormSpecSchemaExtensions */
306
+ /**
307
+ * Extension properties for custom FormSpec constraint tags.
308
+ *
309
+ * @public
310
+ */
311
+ export declare type FormSpecSchemaExtensions = Record<`x-formspec-${string}`, unknown>;
297
312
 
298
313
  /**
299
314
  * Options for generating schemas from a decorated class.
@@ -410,6 +425,34 @@ export declare function generateSchemas(options: GenerateSchemasOptions): Genera
410
425
  */
411
426
  export declare function generateSchemasFromClass(options: GenerateFromClassOptions): GenerateFromClassResult;
412
427
 
428
+ /**
429
+ * Generates JSON Schema and UI Schema from a named type within an existing
430
+ * TypeScript program supplied by the caller.
431
+ *
432
+ * This low-level entry point lets downstream tooling reuse a host-owned
433
+ * `Program` for both FormSpec extraction and other TypeScript analysis.
434
+ *
435
+ * @param options - Host program, file path, type name, and optional schema generation options
436
+ * @returns Generated JSON Schema and UI Schema
437
+ *
438
+ * @public
439
+ */
440
+ export declare function generateSchemasFromProgram(options: GenerateSchemasFromProgramOptions): GenerateFromClassResult;
441
+
442
+ /**
443
+ * Options for generating schemas from a named type inside an existing TypeScript program.
444
+ *
445
+ * @public
446
+ */
447
+ export declare interface GenerateSchemasFromProgramOptions extends StaticSchemaGenerationOptions {
448
+ /** Existing TypeScript program supplied by the caller. */
449
+ readonly program: ts.Program;
450
+ /** Path to the TypeScript source file */
451
+ readonly filePath: string;
452
+ /** Name of the exported class, interface, or type alias to analyze */
453
+ readonly typeName: string;
454
+ }
455
+
413
456
  /**
414
457
  * Options for generating schemas from a named type (class, interface, or type alias).
415
458
  *
@@ -478,11 +521,17 @@ export { Group }
478
521
  * @public
479
522
  */
480
523
  export declare interface GroupLayout {
524
+ /** Discriminator identifying a labeled group container. */
481
525
  readonly type: "Group";
526
+ /** Group label shown by compatible renderers. */
482
527
  readonly label: string;
528
+ /** Child elements rendered inside the group. */
483
529
  readonly elements: UISchemaElement[];
530
+ /** Optional rule controlling visibility or enablement. */
484
531
  readonly rule?: Rule | undefined;
532
+ /** Renderer-specific group options. */
485
533
  readonly options?: Record<string, unknown> | undefined;
534
+ /** Additional renderer-specific extension properties. */
486
535
  readonly [k: string]: unknown;
487
536
  }
488
537
 
@@ -492,10 +541,15 @@ export declare interface GroupLayout {
492
541
  * @public
493
542
  */
494
543
  export declare interface HorizontalLayout {
544
+ /** Discriminator identifying a horizontal layout container. */
495
545
  readonly type: "HorizontalLayout";
546
+ /** Child elements rendered side by side. */
496
547
  readonly elements: UISchemaElement[];
548
+ /** Optional rule controlling visibility or enablement. */
497
549
  readonly rule?: Rule | undefined;
550
+ /** Renderer-specific layout options. */
498
551
  readonly options?: Record<string, unknown> | undefined;
552
+ /** Additional renderer-specific extension properties. */
499
553
  readonly [k: string]: unknown;
500
554
  }
501
555
 
@@ -508,41 +562,171 @@ export declare interface HorizontalLayout {
508
562
  * @public
509
563
  */
510
564
  export declare interface JsonSchema2020 {
565
+ /** Declared JSON Schema dialect URI for the document root. */
511
566
  $schema?: string;
567
+ /** Reference to another schema location. */
512
568
  $ref?: string;
569
+ /** Named reusable schema definitions keyed by definition name. */
513
570
  $defs?: Record<string, JsonSchema2020>;
571
+ /** JSON Schema type keyword for the current node. */
514
572
  type?: string;
573
+ /** Object properties keyed by property name. */
515
574
  properties?: Record<string, JsonSchema2020>;
575
+ /** Property names that must be present on object values. */
516
576
  required?: string[];
577
+ /** Item schema applied to array elements. */
517
578
  items?: JsonSchema2020;
579
+ /** Whether, or how, additional object properties are allowed. */
518
580
  additionalProperties?: boolean | JsonSchema2020;
581
+ /** Closed set of allowed scalar values. */
519
582
  enum?: readonly (string | number)[];
583
+ /** Literal value the instance must equal. */
520
584
  const?: unknown;
585
+ /** Schemas that must all validate successfully. */
521
586
  allOf?: readonly JsonSchema2020[];
587
+ /** Schemas of which exactly one should validate successfully. */
522
588
  oneOf?: readonly JsonSchema2020[];
589
+ /** Schemas of which at least one may validate successfully. */
523
590
  anyOf?: readonly JsonSchema2020[];
591
+ /** Inclusive numeric lower bound. */
524
592
  minimum?: number;
593
+ /** Inclusive numeric upper bound. */
525
594
  maximum?: number;
595
+ /** Exclusive numeric lower bound. */
526
596
  exclusiveMinimum?: number;
597
+ /** Exclusive numeric upper bound. */
527
598
  exclusiveMaximum?: number;
599
+ /** Required numeric step interval. */
528
600
  multipleOf?: number;
601
+ /** Inclusive minimum string length. */
529
602
  minLength?: number;
603
+ /** Inclusive maximum string length. */
530
604
  maxLength?: number;
605
+ /** Inclusive minimum array length. */
531
606
  minItems?: number;
607
+ /** Inclusive maximum array length. */
532
608
  maxItems?: number;
609
+ /** Regular expression pattern applied to string values. */
533
610
  pattern?: string;
611
+ /** Whether array elements must be unique. */
534
612
  uniqueItems?: boolean;
613
+ /** Format hint for downstream validators and tooling. */
535
614
  format?: string;
615
+ /** Human-readable title for the schema node. */
536
616
  title?: string;
617
+ /** Human-readable description for the schema node. */
537
618
  description?: string;
619
+ /** Default value suggested for the schema node. */
538
620
  default?: unknown;
621
+ /** Whether the schema node is deprecated. */
539
622
  deprecated?: boolean;
623
+ /** Additional vendor-prefixed extension keywords. */
540
624
  [key: `x-${string}`]: unknown;
541
625
  }
542
626
 
543
- /* Excluded from this release type: JSONSchema7 */
627
+ /**
628
+ * A JSON Schema definition (legacy subset used by Zod validator and types.ts).
629
+ *
630
+ * @public
631
+ */
632
+ export declare interface JSONSchema7 {
633
+ /** Declared JSON Schema dialect URI for the document root. */
634
+ $schema?: string;
635
+ /** Stable identifier for the schema document or sub-schema. */
636
+ $id?: string;
637
+ /** Reference to another schema location. */
638
+ $ref?: string;
639
+ /** Human-readable title for the schema node. */
640
+ title?: string;
641
+ /** Human-readable description for the schema node. */
642
+ description?: string;
643
+ /** Whether the schema node is deprecated. */
644
+ deprecated?: boolean;
645
+ /** JSON Schema type keyword for the current node. */
646
+ type?: JSONSchemaType | JSONSchemaType[];
647
+ /** Inclusive minimum string length. */
648
+ minLength?: number;
649
+ /** Inclusive maximum string length. */
650
+ maxLength?: number;
651
+ /** Regular expression pattern applied to string values. */
652
+ pattern?: string;
653
+ /** Inclusive numeric lower bound. */
654
+ minimum?: number;
655
+ /** Inclusive numeric upper bound. */
656
+ maximum?: number;
657
+ /** Exclusive numeric lower bound. */
658
+ exclusiveMinimum?: number;
659
+ /** Exclusive numeric upper bound. */
660
+ exclusiveMaximum?: number;
661
+ /** Closed set of allowed scalar values. */
662
+ enum?: readonly (string | number | boolean | null)[];
663
+ /** Literal value the instance must equal. */
664
+ const?: string | number | boolean | null;
665
+ /** Object properties keyed by property name. */
666
+ properties?: Record<string, JSONSchema7>;
667
+ /** Property names that must be present on object values. */
668
+ required?: string[];
669
+ /** Whether, or how, additional object properties are allowed. */
670
+ additionalProperties?: boolean | JSONSchema7;
671
+ /** Item schema or tuple schemas applied to array elements. */
672
+ items?: JSONSchema7 | JSONSchema7[];
673
+ /** Inclusive minimum array length. */
674
+ minItems?: number;
675
+ /** Inclusive maximum array length. */
676
+ maxItems?: number;
677
+ /** Schemas that must all validate successfully. */
678
+ allOf?: JSONSchema7[];
679
+ /** Schemas of which at least one may validate successfully. */
680
+ anyOf?: JSONSchema7[];
681
+ /** Schemas of which exactly one should validate successfully. */
682
+ oneOf?: JSONSchema7[];
683
+ /** Schema that must not validate successfully. */
684
+ not?: JSONSchema7;
685
+ /** Conditional branch predicate schema. */
686
+ if?: JSONSchema7;
687
+ /** Schema applied when the `if` branch matches. */
688
+ then?: JSONSchema7;
689
+ /** Schema applied when the `if` branch does not match. */
690
+ else?: JSONSchema7;
691
+ /** Format hint for downstream validators and tooling. */
692
+ format?: string;
693
+ /** Default value suggested for the schema node. */
694
+ default?: unknown;
695
+ /**
696
+ * Data source key for dynamic enum fields.
697
+ * Indicates that options should be fetched from a registered resolver.
698
+ */
699
+ "x-formspec-source"?: string;
700
+ /**
701
+ * Field names whose values are needed to fetch dynamic enum options.
702
+ * Used for dependent/cascading dropdowns.
703
+ */
704
+ "x-formspec-params"?: readonly string[];
705
+ /**
706
+ * Schema source identifier for dynamic schema fields.
707
+ * Indicates that the schema should be loaded dynamically at runtime.
708
+ */
709
+ "x-formspec-schemaSource"?: string;
710
+ }
711
+
712
+ /**
713
+ * Zod schema for the legacy JSON Schema 7 subset used by `@formspec/build`.
714
+ *
715
+ * @public
716
+ */
717
+ export declare const jsonSchema7Schema: z.ZodType<JSONSchema7>;
544
718
 
545
- /* Excluded from this release type: JSONSchemaType */
719
+ /**
720
+ * JSON Schema type definitions.
721
+ *
722
+ * These types are a subset of JSON Schema sufficient for form generation.
723
+ */
724
+ /**
725
+ * JSON Schema primitive types.
726
+ *
727
+ * @public
728
+ */
729
+ export declare type JSONSchemaType = "string" | "number" | "integer" | "boolean" | "object" | "array" | "null";
546
730
 
547
731
  /**
548
732
  * A Label element for displaying static text.
@@ -550,10 +734,15 @@ export declare interface JsonSchema2020 {
550
734
  * @public
551
735
  */
552
736
  export declare interface LabelElement {
737
+ /** Discriminator identifying a static text label element. */
553
738
  readonly type: "Label";
739
+ /** Static text content rendered by the label element. */
554
740
  readonly text: string;
741
+ /** Optional rule controlling visibility or enablement. */
555
742
  readonly rule?: Rule | undefined;
743
+ /** Renderer-specific label options. */
556
744
  readonly options?: Record<string, unknown> | undefined;
745
+ /** Additional renderer-specific extension properties. */
557
746
  readonly [k: string]: unknown;
558
747
  }
559
748
 
@@ -579,7 +768,9 @@ export { ObjectField }
579
768
  * @public
580
769
  */
581
770
  export declare interface Rule {
771
+ /** UI effect to apply when the rule condition matches. */
582
772
  readonly effect: RuleEffect;
773
+ /** Predicate that controls when the UI effect applies. */
583
774
  readonly condition: SchemaBasedCondition;
584
775
  }
585
776
 
@@ -589,17 +780,29 @@ export declare interface Rule {
589
780
  * @public
590
781
  */
591
782
  export declare interface RuleConditionSchema {
783
+ /** Literal value the condition schema must equal. */
592
784
  const?: unknown;
785
+ /** Allowed values for the condition schema. */
593
786
  enum?: readonly unknown[];
787
+ /** JSON Schema type required by the condition schema. */
594
788
  type?: string;
789
+ /** Negated branch of the condition schema. */
595
790
  not?: RuleConditionSchema;
791
+ /** Inclusive numeric lower bound in the condition schema. */
596
792
  minimum?: number;
793
+ /** Inclusive numeric upper bound in the condition schema. */
597
794
  maximum?: number;
795
+ /** Exclusive numeric lower bound in the condition schema. */
598
796
  exclusiveMinimum?: number;
797
+ /** Exclusive numeric upper bound in the condition schema. */
599
798
  exclusiveMaximum?: number;
799
+ /** Inclusive minimum string length in the condition schema. */
600
800
  minLength?: number;
801
+ /** Nested property conditions keyed by property name. */
601
802
  properties?: Record<string, RuleConditionSchema>;
803
+ /** Property names that must be present for the condition to match. */
602
804
  required?: string[];
805
+ /** Schemas that must all match for the condition to succeed. */
603
806
  allOf?: RuleConditionSchema[];
604
807
  }
605
808
 
@@ -624,7 +827,9 @@ export declare type RuleEffect = "SHOW" | "HIDE" | "ENABLE" | "DISABLE";
624
827
  * @public
625
828
  */
626
829
  export declare interface SchemaBasedCondition {
830
+ /** JSON Pointer scope the rule evaluates against. */
627
831
  readonly scope: string;
832
+ /** JSON Schema fragment evaluated at the scoped location. */
628
833
  readonly schema: RuleConditionSchema;
629
834
  }
630
835
 
@@ -674,8 +879,11 @@ export declare type UISchemaElement = ControlElement | VerticalLayout | Horizont
674
879
  * @public
675
880
  */
676
881
  export declare interface UISchemaElementBase {
882
+ /** Discriminator for the concrete JSON Forms element type. */
677
883
  type: UISchemaElementType;
884
+ /** Optional rule controlling visibility or enablement. */
678
885
  rule?: Rule;
886
+ /** Renderer-specific options shared by UI schema elements. */
679
887
  options?: Record<string, unknown>;
680
888
  }
681
889
 
@@ -686,21 +894,31 @@ export declare interface UISchemaElementBase {
686
894
  */
687
895
  export declare type UISchemaElementType = "Control" | "VerticalLayout" | "HorizontalLayout" | "Group" | "Categorization" | "Category" | "Label";
688
896
 
897
+ /**
898
+ * Zod schema for the root UI Schema (layout types only).
899
+ *
900
+ * @public
901
+ */
902
+ export declare const uiSchemaSchema: z.ZodType<UISchema>;
903
+
689
904
  /**
690
905
  * A vertical layout element.
691
906
  *
692
907
  * @public
693
908
  */
694
909
  export declare interface VerticalLayout {
910
+ /** Discriminator identifying a vertical layout container. */
695
911
  readonly type: "VerticalLayout";
912
+ /** Child elements rendered in vertical order. */
696
913
  readonly elements: UISchemaElement[];
914
+ /** Optional rule controlling visibility or enablement. */
697
915
  readonly rule?: Rule | undefined;
916
+ /** Renderer-specific layout options. */
698
917
  readonly options?: Record<string, unknown> | undefined;
918
+ /** Additional renderer-specific extension properties. */
699
919
  readonly [k: string]: unknown;
700
920
  }
701
921
 
702
- export { VocabularyKeywordRegistration }
703
-
704
922
  /**
705
923
  * Builds and writes both JSON Schema and UI Schema files to disk.
706
924
  *
package/dist/cli.cjs CHANGED
@@ -1235,6 +1235,74 @@ var init_extensions = __esm({
1235
1235
  }
1236
1236
  });
1237
1237
 
1238
+ // src/json-schema/schema.ts
1239
+ var import_zod3, jsonSchemaTypeSchema, jsonSchema7Schema;
1240
+ var init_schema2 = __esm({
1241
+ "src/json-schema/schema.ts"() {
1242
+ "use strict";
1243
+ import_zod3 = require("zod");
1244
+ jsonSchemaTypeSchema = import_zod3.z.enum([
1245
+ "string",
1246
+ "number",
1247
+ "integer",
1248
+ "boolean",
1249
+ "object",
1250
+ "array",
1251
+ "null"
1252
+ ]);
1253
+ jsonSchema7Schema = import_zod3.z.lazy(
1254
+ () => import_zod3.z.object({
1255
+ $schema: import_zod3.z.string().optional(),
1256
+ $id: import_zod3.z.string().optional(),
1257
+ $ref: import_zod3.z.string().optional(),
1258
+ // Metadata
1259
+ title: import_zod3.z.string().optional(),
1260
+ description: import_zod3.z.string().optional(),
1261
+ deprecated: import_zod3.z.boolean().optional(),
1262
+ // Type
1263
+ type: import_zod3.z.union([jsonSchemaTypeSchema, import_zod3.z.array(jsonSchemaTypeSchema)]).optional(),
1264
+ // String validation
1265
+ minLength: import_zod3.z.number().optional(),
1266
+ maxLength: import_zod3.z.number().optional(),
1267
+ pattern: import_zod3.z.string().optional(),
1268
+ // Number validation
1269
+ minimum: import_zod3.z.number().optional(),
1270
+ maximum: import_zod3.z.number().optional(),
1271
+ exclusiveMinimum: import_zod3.z.number().optional(),
1272
+ exclusiveMaximum: import_zod3.z.number().optional(),
1273
+ // Enum
1274
+ enum: import_zod3.z.array(import_zod3.z.union([import_zod3.z.string(), import_zod3.z.number(), import_zod3.z.boolean(), import_zod3.z.null()])).readonly().optional(),
1275
+ const: import_zod3.z.union([import_zod3.z.string(), import_zod3.z.number(), import_zod3.z.boolean(), import_zod3.z.null()]).optional(),
1276
+ // Object
1277
+ properties: import_zod3.z.record(import_zod3.z.string(), jsonSchema7Schema).optional(),
1278
+ required: import_zod3.z.array(import_zod3.z.string()).optional(),
1279
+ additionalProperties: import_zod3.z.union([import_zod3.z.boolean(), jsonSchema7Schema]).optional(),
1280
+ // Array
1281
+ items: import_zod3.z.union([jsonSchema7Schema, import_zod3.z.array(jsonSchema7Schema)]).optional(),
1282
+ minItems: import_zod3.z.number().optional(),
1283
+ maxItems: import_zod3.z.number().optional(),
1284
+ // Composition
1285
+ allOf: import_zod3.z.array(jsonSchema7Schema).optional(),
1286
+ anyOf: import_zod3.z.array(jsonSchema7Schema).optional(),
1287
+ oneOf: import_zod3.z.array(jsonSchema7Schema).optional(),
1288
+ not: jsonSchema7Schema.optional(),
1289
+ // Conditional
1290
+ if: jsonSchema7Schema.optional(),
1291
+ then: jsonSchema7Schema.optional(),
1292
+ else: jsonSchema7Schema.optional(),
1293
+ // Format
1294
+ format: import_zod3.z.string().optional(),
1295
+ // Default
1296
+ default: import_zod3.z.unknown().optional(),
1297
+ // FormSpec extensions
1298
+ "x-formspec-source": import_zod3.z.string().optional(),
1299
+ "x-formspec-params": import_zod3.z.array(import_zod3.z.string()).readonly().optional(),
1300
+ "x-formspec-schemaSource": import_zod3.z.string().optional()
1301
+ }).passthrough()
1302
+ );
1303
+ }
1304
+ });
1305
+
1238
1306
  // src/analyzer/tsdoc-parser.ts
1239
1307
  function createFormSpecTSDocConfig(extensionTagNames = []) {
1240
1308
  const config = new import_tsdoc.TSDocConfiguration();
@@ -3204,6 +3272,18 @@ var init_class_analyzer = __esm({
3204
3272
  });
3205
3273
 
3206
3274
  // src/analyzer/program.ts
3275
+ function createProgramContextFromProgram(program, filePath) {
3276
+ const absolutePath = path.resolve(filePath);
3277
+ const sourceFile = program.getSourceFile(absolutePath) ?? program.getSourceFile(filePath);
3278
+ if (!sourceFile) {
3279
+ throw new Error(`Could not find source file in provided program: ${absolutePath}`);
3280
+ }
3281
+ return {
3282
+ program,
3283
+ checker: program.getTypeChecker(),
3284
+ sourceFile
3285
+ };
3286
+ }
3207
3287
  function createProgramContext(filePath) {
3208
3288
  const absolutePath = path.resolve(filePath);
3209
3289
  const fileDir = path.dirname(absolutePath);
@@ -3274,24 +3354,33 @@ function findTypeAliasByName(sourceFile, aliasName) {
3274
3354
  }
3275
3355
  function analyzeNamedTypeToIR(filePath, typeName, extensionRegistry) {
3276
3356
  const ctx = createProgramContext(filePath);
3357
+ return analyzeNamedTypeToIRFromProgramContext(ctx, filePath, typeName, extensionRegistry);
3358
+ }
3359
+ function analyzeNamedTypeToIRFromProgramContext(ctx, filePath, typeName, extensionRegistry) {
3360
+ const analysisFilePath = path.resolve(filePath);
3277
3361
  const classDecl = findClassByName(ctx.sourceFile, typeName);
3278
3362
  if (classDecl !== null) {
3279
- return analyzeClassToIR(classDecl, ctx.checker, filePath, extensionRegistry);
3363
+ return analyzeClassToIR(classDecl, ctx.checker, analysisFilePath, extensionRegistry);
3280
3364
  }
3281
3365
  const interfaceDecl = findInterfaceByName(ctx.sourceFile, typeName);
3282
3366
  if (interfaceDecl !== null) {
3283
- return analyzeInterfaceToIR(interfaceDecl, ctx.checker, filePath, extensionRegistry);
3367
+ return analyzeInterfaceToIR(interfaceDecl, ctx.checker, analysisFilePath, extensionRegistry);
3284
3368
  }
3285
3369
  const typeAlias = findTypeAliasByName(ctx.sourceFile, typeName);
3286
3370
  if (typeAlias !== null) {
3287
- const result = analyzeTypeAliasToIR(typeAlias, ctx.checker, filePath, extensionRegistry);
3371
+ const result = analyzeTypeAliasToIR(
3372
+ typeAlias,
3373
+ ctx.checker,
3374
+ analysisFilePath,
3375
+ extensionRegistry
3376
+ );
3288
3377
  if (result.ok) {
3289
3378
  return result.analysis;
3290
3379
  }
3291
3380
  throw new Error(result.error);
3292
3381
  }
3293
3382
  throw new Error(
3294
- `Type "${typeName}" not found as a class, interface, or type alias in ${filePath}`
3383
+ `Type "${typeName}" not found as a class, interface, or type alias in ${analysisFilePath}`
3295
3384
  );
3296
3385
  }
3297
3386
  var ts4, path;
@@ -3448,16 +3537,34 @@ function generateSchemasFromClass(options) {
3448
3537
  );
3449
3538
  }
3450
3539
  function generateSchemas(options) {
3451
- const analysis = analyzeNamedTypeToIR(
3540
+ const ctx = createProgramContext(options.filePath);
3541
+ return generateSchemasFromProgram({
3542
+ ...options,
3543
+ program: ctx.program
3544
+ });
3545
+ }
3546
+ function generateSchemasFromProgram(options) {
3547
+ const ctx = createProgramContextFromProgram(options.program, options.filePath);
3548
+ const analysis = analyzeNamedTypeToIRFromProgramContext(
3549
+ ctx,
3452
3550
  options.filePath,
3453
3551
  options.typeName,
3454
3552
  options.extensionRegistry
3455
3553
  );
3456
- return generateClassSchemas(analysis, { file: options.filePath }, options);
3554
+ return generateClassSchemas(
3555
+ analysis,
3556
+ { file: options.filePath },
3557
+ {
3558
+ extensionRegistry: options.extensionRegistry,
3559
+ vendorPrefix: options.vendorPrefix
3560
+ }
3561
+ );
3457
3562
  }
3563
+ var ts5;
3458
3564
  var init_class_schema = __esm({
3459
3565
  "src/generators/class-schema.ts"() {
3460
3566
  "use strict";
3567
+ ts5 = require("typescript");
3461
3568
  init_program();
3462
3569
  init_class_analyzer();
3463
3570
  init_canonicalize();
@@ -3661,7 +3768,10 @@ __export(index_exports, {
3661
3768
  generateJsonSchema: () => generateJsonSchema,
3662
3769
  generateSchemas: () => generateSchemas,
3663
3770
  generateSchemasFromClass: () => generateSchemasFromClass,
3771
+ generateSchemasFromProgram: () => generateSchemasFromProgram,
3664
3772
  generateUiSchema: () => generateUiSchema,
3773
+ jsonSchema7Schema: () => jsonSchema7Schema,
3774
+ uiSchemaSchema: () => uiSchema,
3665
3775
  writeSchemas: () => writeSchemas
3666
3776
  });
3667
3777
  function buildFormSchemas(form, options) {
@@ -3693,6 +3803,8 @@ var init_index = __esm({
3693
3803
  fs = __toESM(require("fs"), 1);
3694
3804
  path2 = __toESM(require("path"), 1);
3695
3805
  init_extensions();
3806
+ init_schema2();
3807
+ init_schema();
3696
3808
  init_generator();
3697
3809
  init_generator2();
3698
3810
  init_class_schema();