@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
@@ -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
 
@@ -224,16 +234,12 @@ export { EnumOptionValue }
224
234
  /**
225
235
  * JSON Schema with FormSpec extension properties for arbitrary `x-formspec-*` keys.
226
236
  *
227
- * @beta
237
+ * @public
228
238
  */
229
239
  export declare type ExtendedJSONSchema7 = JSONSchema7 & FormSpecSchemaExtensions;
230
240
 
231
- export { ExtensionApplicableType }
232
-
233
241
  export { ExtensionDefinition }
234
242
 
235
- export { ExtensionPayloadValue }
236
-
237
243
  /**
238
244
  * A registry of extensions that provides lookup by fully-qualified ID.
239
245
  *
@@ -293,8 +299,6 @@ export declare interface ExtensionRegistry {
293
299
  findAnnotation(annotationId: string): CustomAnnotationRegistration | undefined;
294
300
  }
295
301
 
296
- export { ExtensionTypeKind }
297
-
298
302
  export { FormElement }
299
303
 
300
304
  export { FormSpec }
@@ -302,7 +306,7 @@ export { FormSpec }
302
306
  /**
303
307
  * Extension properties for custom FormSpec constraint tags.
304
308
  *
305
- * @beta
309
+ * @public
306
310
  */
307
311
  export declare type FormSpecSchemaExtensions = Record<`x-formspec-${string}`, unknown>;
308
312
 
@@ -421,6 +425,34 @@ export declare function generateSchemas(options: GenerateSchemasOptions): Genera
421
425
  */
422
426
  export declare function generateSchemasFromClass(options: GenerateFromClassOptions): GenerateFromClassResult;
423
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
+
424
456
  /**
425
457
  * Options for generating schemas from a named type (class, interface, or type alias).
426
458
  *
@@ -489,11 +521,17 @@ export { Group }
489
521
  * @public
490
522
  */
491
523
  export declare interface GroupLayout {
524
+ /** Discriminator identifying a labeled group container. */
492
525
  readonly type: "Group";
526
+ /** Group label shown by compatible renderers. */
493
527
  readonly label: string;
528
+ /** Child elements rendered inside the group. */
494
529
  readonly elements: UISchemaElement[];
530
+ /** Optional rule controlling visibility or enablement. */
495
531
  readonly rule?: Rule | undefined;
532
+ /** Renderer-specific group options. */
496
533
  readonly options?: Record<string, unknown> | undefined;
534
+ /** Additional renderer-specific extension properties. */
497
535
  readonly [k: string]: unknown;
498
536
  }
499
537
 
@@ -503,10 +541,15 @@ export declare interface GroupLayout {
503
541
  * @public
504
542
  */
505
543
  export declare interface HorizontalLayout {
544
+ /** Discriminator identifying a horizontal layout container. */
506
545
  readonly type: "HorizontalLayout";
546
+ /** Child elements rendered side by side. */
507
547
  readonly elements: UISchemaElement[];
548
+ /** Optional rule controlling visibility or enablement. */
508
549
  readonly rule?: Rule | undefined;
550
+ /** Renderer-specific layout options. */
509
551
  readonly options?: Record<string, unknown> | undefined;
552
+ /** Additional renderer-specific extension properties. */
510
553
  readonly [k: string]: unknown;
511
554
  }
512
555
 
@@ -519,74 +562,135 @@ export declare interface HorizontalLayout {
519
562
  * @public
520
563
  */
521
564
  export declare interface JsonSchema2020 {
565
+ /** Declared JSON Schema dialect URI for the document root. */
522
566
  $schema?: string;
567
+ /** Reference to another schema location. */
523
568
  $ref?: string;
569
+ /** Named reusable schema definitions keyed by definition name. */
524
570
  $defs?: Record<string, JsonSchema2020>;
571
+ /** JSON Schema type keyword for the current node. */
525
572
  type?: string;
573
+ /** Object properties keyed by property name. */
526
574
  properties?: Record<string, JsonSchema2020>;
575
+ /** Property names that must be present on object values. */
527
576
  required?: string[];
577
+ /** Item schema applied to array elements. */
528
578
  items?: JsonSchema2020;
579
+ /** Whether, or how, additional object properties are allowed. */
529
580
  additionalProperties?: boolean | JsonSchema2020;
581
+ /** Closed set of allowed scalar values. */
530
582
  enum?: readonly (string | number)[];
583
+ /** Literal value the instance must equal. */
531
584
  const?: unknown;
585
+ /** Schemas that must all validate successfully. */
532
586
  allOf?: readonly JsonSchema2020[];
587
+ /** Schemas of which exactly one should validate successfully. */
533
588
  oneOf?: readonly JsonSchema2020[];
589
+ /** Schemas of which at least one may validate successfully. */
534
590
  anyOf?: readonly JsonSchema2020[];
591
+ /** Inclusive numeric lower bound. */
535
592
  minimum?: number;
593
+ /** Inclusive numeric upper bound. */
536
594
  maximum?: number;
595
+ /** Exclusive numeric lower bound. */
537
596
  exclusiveMinimum?: number;
597
+ /** Exclusive numeric upper bound. */
538
598
  exclusiveMaximum?: number;
599
+ /** Required numeric step interval. */
539
600
  multipleOf?: number;
601
+ /** Inclusive minimum string length. */
540
602
  minLength?: number;
603
+ /** Inclusive maximum string length. */
541
604
  maxLength?: number;
605
+ /** Inclusive minimum array length. */
542
606
  minItems?: number;
607
+ /** Inclusive maximum array length. */
543
608
  maxItems?: number;
609
+ /** Regular expression pattern applied to string values. */
544
610
  pattern?: string;
611
+ /** Whether array elements must be unique. */
545
612
  uniqueItems?: boolean;
613
+ /** Format hint for downstream validators and tooling. */
546
614
  format?: string;
615
+ /** Human-readable title for the schema node. */
547
616
  title?: string;
617
+ /** Human-readable description for the schema node. */
548
618
  description?: string;
619
+ /** Default value suggested for the schema node. */
549
620
  default?: unknown;
621
+ /** Whether the schema node is deprecated. */
550
622
  deprecated?: boolean;
623
+ /** Additional vendor-prefixed extension keywords. */
551
624
  [key: `x-${string}`]: unknown;
552
625
  }
553
626
 
554
627
  /**
555
628
  * A JSON Schema definition (legacy subset used by Zod validator and types.ts).
556
629
  *
557
- * @beta
630
+ * @public
558
631
  */
559
632
  export declare interface JSONSchema7 {
633
+ /** Declared JSON Schema dialect URI for the document root. */
560
634
  $schema?: string;
635
+ /** Stable identifier for the schema document or sub-schema. */
561
636
  $id?: string;
637
+ /** Reference to another schema location. */
562
638
  $ref?: string;
639
+ /** Human-readable title for the schema node. */
563
640
  title?: string;
641
+ /** Human-readable description for the schema node. */
564
642
  description?: string;
643
+ /** Whether the schema node is deprecated. */
565
644
  deprecated?: boolean;
645
+ /** JSON Schema type keyword for the current node. */
566
646
  type?: JSONSchemaType | JSONSchemaType[];
647
+ /** Inclusive minimum string length. */
567
648
  minLength?: number;
649
+ /** Inclusive maximum string length. */
568
650
  maxLength?: number;
651
+ /** Regular expression pattern applied to string values. */
569
652
  pattern?: string;
653
+ /** Inclusive numeric lower bound. */
570
654
  minimum?: number;
655
+ /** Inclusive numeric upper bound. */
571
656
  maximum?: number;
657
+ /** Exclusive numeric lower bound. */
572
658
  exclusiveMinimum?: number;
659
+ /** Exclusive numeric upper bound. */
573
660
  exclusiveMaximum?: number;
661
+ /** Closed set of allowed scalar values. */
574
662
  enum?: readonly (string | number | boolean | null)[];
663
+ /** Literal value the instance must equal. */
575
664
  const?: string | number | boolean | null;
665
+ /** Object properties keyed by property name. */
576
666
  properties?: Record<string, JSONSchema7>;
667
+ /** Property names that must be present on object values. */
577
668
  required?: string[];
669
+ /** Whether, or how, additional object properties are allowed. */
578
670
  additionalProperties?: boolean | JSONSchema7;
671
+ /** Item schema or tuple schemas applied to array elements. */
579
672
  items?: JSONSchema7 | JSONSchema7[];
673
+ /** Inclusive minimum array length. */
580
674
  minItems?: number;
675
+ /** Inclusive maximum array length. */
581
676
  maxItems?: number;
677
+ /** Schemas that must all validate successfully. */
582
678
  allOf?: JSONSchema7[];
679
+ /** Schemas of which at least one may validate successfully. */
583
680
  anyOf?: JSONSchema7[];
681
+ /** Schemas of which exactly one should validate successfully. */
584
682
  oneOf?: JSONSchema7[];
683
+ /** Schema that must not validate successfully. */
585
684
  not?: JSONSchema7;
685
+ /** Conditional branch predicate schema. */
586
686
  if?: JSONSchema7;
687
+ /** Schema applied when the `if` branch matches. */
587
688
  then?: JSONSchema7;
689
+ /** Schema applied when the `if` branch does not match. */
588
690
  else?: JSONSchema7;
691
+ /** Format hint for downstream validators and tooling. */
589
692
  format?: string;
693
+ /** Default value suggested for the schema node. */
590
694
  default?: unknown;
591
695
  /**
592
696
  * Data source key for dynamic enum fields.
@@ -605,6 +709,13 @@ export declare interface JSONSchema7 {
605
709
  "x-formspec-schemaSource"?: string;
606
710
  }
607
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>;
718
+
608
719
  /**
609
720
  * JSON Schema type definitions.
610
721
  *
@@ -613,7 +724,7 @@ export declare interface JSONSchema7 {
613
724
  /**
614
725
  * JSON Schema primitive types.
615
726
  *
616
- * @beta
727
+ * @public
617
728
  */
618
729
  export declare type JSONSchemaType = "string" | "number" | "integer" | "boolean" | "object" | "array" | "null";
619
730
 
@@ -623,10 +734,15 @@ export declare type JSONSchemaType = "string" | "number" | "integer" | "boolean"
623
734
  * @public
624
735
  */
625
736
  export declare interface LabelElement {
737
+ /** Discriminator identifying a static text label element. */
626
738
  readonly type: "Label";
739
+ /** Static text content rendered by the label element. */
627
740
  readonly text: string;
741
+ /** Optional rule controlling visibility or enablement. */
628
742
  readonly rule?: Rule | undefined;
743
+ /** Renderer-specific label options. */
629
744
  readonly options?: Record<string, unknown> | undefined;
745
+ /** Additional renderer-specific extension properties. */
630
746
  readonly [k: string]: unknown;
631
747
  }
632
748
 
@@ -652,7 +768,9 @@ export { ObjectField }
652
768
  * @public
653
769
  */
654
770
  export declare interface Rule {
771
+ /** UI effect to apply when the rule condition matches. */
655
772
  readonly effect: RuleEffect;
773
+ /** Predicate that controls when the UI effect applies. */
656
774
  readonly condition: SchemaBasedCondition;
657
775
  }
658
776
 
@@ -662,17 +780,29 @@ export declare interface Rule {
662
780
  * @public
663
781
  */
664
782
  export declare interface RuleConditionSchema {
783
+ /** Literal value the condition schema must equal. */
665
784
  const?: unknown;
785
+ /** Allowed values for the condition schema. */
666
786
  enum?: readonly unknown[];
787
+ /** JSON Schema type required by the condition schema. */
667
788
  type?: string;
789
+ /** Negated branch of the condition schema. */
668
790
  not?: RuleConditionSchema;
791
+ /** Inclusive numeric lower bound in the condition schema. */
669
792
  minimum?: number;
793
+ /** Inclusive numeric upper bound in the condition schema. */
670
794
  maximum?: number;
795
+ /** Exclusive numeric lower bound in the condition schema. */
671
796
  exclusiveMinimum?: number;
797
+ /** Exclusive numeric upper bound in the condition schema. */
672
798
  exclusiveMaximum?: number;
799
+ /** Inclusive minimum string length in the condition schema. */
673
800
  minLength?: number;
801
+ /** Nested property conditions keyed by property name. */
674
802
  properties?: Record<string, RuleConditionSchema>;
803
+ /** Property names that must be present for the condition to match. */
675
804
  required?: string[];
805
+ /** Schemas that must all match for the condition to succeed. */
676
806
  allOf?: RuleConditionSchema[];
677
807
  }
678
808
 
@@ -697,7 +827,9 @@ export declare type RuleEffect = "SHOW" | "HIDE" | "ENABLE" | "DISABLE";
697
827
  * @public
698
828
  */
699
829
  export declare interface SchemaBasedCondition {
830
+ /** JSON Pointer scope the rule evaluates against. */
700
831
  readonly scope: string;
832
+ /** JSON Schema fragment evaluated at the scoped location. */
701
833
  readonly schema: RuleConditionSchema;
702
834
  }
703
835
 
@@ -747,8 +879,11 @@ export declare type UISchemaElement = ControlElement | VerticalLayout | Horizont
747
879
  * @public
748
880
  */
749
881
  export declare interface UISchemaElementBase {
882
+ /** Discriminator for the concrete JSON Forms element type. */
750
883
  type: UISchemaElementType;
884
+ /** Optional rule controlling visibility or enablement. */
751
885
  rule?: Rule;
886
+ /** Renderer-specific options shared by UI schema elements. */
752
887
  options?: Record<string, unknown>;
753
888
  }
754
889
 
@@ -759,21 +894,31 @@ export declare interface UISchemaElementBase {
759
894
  */
760
895
  export declare type UISchemaElementType = "Control" | "VerticalLayout" | "HorizontalLayout" | "Group" | "Categorization" | "Category" | "Label";
761
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
+
762
904
  /**
763
905
  * A vertical layout element.
764
906
  *
765
907
  * @public
766
908
  */
767
909
  export declare interface VerticalLayout {
910
+ /** Discriminator identifying a vertical layout container. */
768
911
  readonly type: "VerticalLayout";
912
+ /** Child elements rendered in vertical order. */
769
913
  readonly elements: UISchemaElement[];
914
+ /** Optional rule controlling visibility or enablement. */
770
915
  readonly rule?: Rule | undefined;
916
+ /** Renderer-specific layout options. */
771
917
  readonly options?: Record<string, unknown> | undefined;
918
+ /** Additional renderer-specific extension properties. */
772
919
  readonly [k: string]: unknown;
773
920
  }
774
921
 
775
- export { VocabularyKeywordRegistration }
776
-
777
922
  /**
778
923
  * Builds and writes both JSON Schema and UI Schema files to disk.
779
924
  *