@formspec/build 0.1.0-alpha.20 → 0.1.0-alpha.21

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 (55) hide show
  1. package/dist/__tests__/fixtures/class-schema-regressions.d.ts +7 -8
  2. package/dist/__tests__/fixtures/class-schema-regressions.d.ts.map +1 -1
  3. package/dist/__tests__/fixtures/example-a-builtins.d.ts +5 -4
  4. package/dist/__tests__/fixtures/example-a-builtins.d.ts.map +1 -1
  5. package/dist/__tests__/fixtures/example-interface-types.d.ts +7 -2
  6. package/dist/__tests__/fixtures/example-interface-types.d.ts.map +1 -1
  7. package/dist/__tests__/fixtures/sample-forms.d.ts +1 -1
  8. package/dist/__tests__/parity/utils.d.ts +3 -2
  9. package/dist/__tests__/parity/utils.d.ts.map +1 -1
  10. package/dist/analyzer/class-analyzer.d.ts +1 -1
  11. package/dist/analyzer/class-analyzer.d.ts.map +1 -1
  12. package/dist/analyzer/tsdoc-parser.d.ts +8 -7
  13. package/dist/analyzer/tsdoc-parser.d.ts.map +1 -1
  14. package/dist/browser.cjs +6 -3
  15. package/dist/browser.cjs.map +1 -1
  16. package/dist/browser.js +4 -1
  17. package/dist/browser.js.map +1 -1
  18. package/dist/build.d.ts +150 -2
  19. package/dist/cli.cjs +44 -47
  20. package/dist/cli.cjs.map +1 -1
  21. package/dist/cli.js +25 -28
  22. package/dist/cli.js.map +1 -1
  23. package/dist/extensions/registry.d.ts +4 -0
  24. package/dist/extensions/registry.d.ts.map +1 -1
  25. package/dist/generators/class-schema.d.ts +12 -0
  26. package/dist/generators/class-schema.d.ts.map +1 -1
  27. package/dist/generators/mixed-authoring.d.ts +6 -0
  28. package/dist/generators/mixed-authoring.d.ts.map +1 -1
  29. package/dist/index.cjs +42 -45
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.ts +12 -0
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +25 -28
  34. package/dist/index.js.map +1 -1
  35. package/dist/internals.cjs +42 -45
  36. package/dist/internals.cjs.map +1 -1
  37. package/dist/internals.js +25 -28
  38. package/dist/internals.js.map +1 -1
  39. package/dist/json-schema/generator.d.ts +4 -0
  40. package/dist/json-schema/generator.d.ts.map +1 -1
  41. package/dist/json-schema/ir-generator.d.ts +6 -0
  42. package/dist/json-schema/ir-generator.d.ts.map +1 -1
  43. package/dist/json-schema/schema.d.ts +7 -0
  44. package/dist/json-schema/schema.d.ts.map +1 -1
  45. package/dist/json-schema/types.d.ts +18 -2
  46. package/dist/json-schema/types.d.ts.map +1 -1
  47. package/dist/ui-schema/generator.d.ts +2 -0
  48. package/dist/ui-schema/generator.d.ts.map +1 -1
  49. package/dist/ui-schema/schema.d.ts +77 -0
  50. package/dist/ui-schema/schema.d.ts.map +1 -1
  51. package/dist/ui-schema/types.d.ts +2 -0
  52. package/dist/ui-schema/types.d.ts.map +1 -1
  53. package/dist/validate/constraint-validator.d.ts +1 -1
  54. package/dist/validate/constraint-validator.d.ts.map +1 -1
  55. package/package.json +4 -4
package/dist/build.d.ts CHANGED
@@ -61,6 +61,8 @@ import { z } from 'zod';
61
61
  *
62
62
  * @param form - The FormSpec to build schemas from
63
63
  * @returns Object containing both jsonSchema and uiSchema
64
+ *
65
+ * @public
64
66
  */
65
67
  export declare function buildFormSchemas<E extends readonly FormElement[]>(form: FormSpec<E>, options?: BuildFormSchemasOptions): BuildResult;
66
68
 
@@ -69,6 +71,8 @@ export declare function buildFormSchemas<E extends readonly FormElement[]>(form:
69
71
  *
70
72
  * Currently identical to `GenerateJsonSchemaOptions`. Defined separately so the
71
73
  * Chain DSL surface can grow independently in the future if needed.
74
+ *
75
+ * @public
72
76
  */
73
77
  export declare type BuildFormSchemasOptions = GenerateJsonSchemaOptions;
74
78
 
@@ -80,6 +84,8 @@ export declare type BuildFormSchemasOptions = GenerateJsonSchemaOptions;
80
84
  * ordering, and constraints; ChainDSL overlays may contribute dynamic runtime
81
85
  * field metadata such as dynamic enum or dynamic schema keywords, and may fill
82
86
  * in missing annotations.
87
+ *
88
+ * @public
83
89
  */
84
90
  export declare function buildMixedAuthoringSchemas(options: BuildMixedAuthoringSchemasOptions): MixedAuthoringSchemas;
85
91
 
@@ -88,6 +94,8 @@ export declare function buildMixedAuthoringSchemas(options: BuildMixedAuthoringS
88
94
  *
89
95
  * The `typeName` can resolve to a class, interface, or object type alias, just
90
96
  * like `generateSchemas()`.
97
+ *
98
+ * @public
91
99
  */
92
100
  export declare interface BuildMixedAuthoringSchemasOptions extends GenerateJsonSchemaFromIROptions {
93
101
  /** Path to the TypeScript source file. */
@@ -100,6 +108,8 @@ export declare interface BuildMixedAuthoringSchemasOptions extends GenerateJsonS
100
108
 
101
109
  /**
102
110
  * Result of building form schemas.
111
+ *
112
+ * @public
103
113
  */
104
114
  export declare interface BuildResult {
105
115
  /** JSON Schema 2020-12 for validation */
@@ -110,6 +120,8 @@ export declare interface BuildResult {
110
120
 
111
121
  /**
112
122
  * A Categorization element (tab-based layout).
123
+ *
124
+ * @public
113
125
  */
114
126
  export declare interface Categorization {
115
127
  type: "Categorization";
@@ -120,10 +132,17 @@ export declare interface Categorization {
120
132
  [k: string]: unknown;
121
133
  }
122
134
 
135
+ /**
136
+ * Zod schema for a categorization element.
137
+ *
138
+ * @public
139
+ */
123
140
  export declare const categorizationSchema: z.ZodType<Categorization>;
124
141
 
125
142
  /**
126
143
  * A Category element, used inside a Categorization layout.
144
+ *
145
+ * @public
127
146
  */
128
147
  export declare interface Category {
129
148
  type: "Category";
@@ -134,10 +153,17 @@ export declare interface Category {
134
153
  [k: string]: unknown;
135
154
  }
136
155
 
156
+ /**
157
+ * Zod schema for a category element.
158
+ *
159
+ * @public
160
+ */
137
161
  export declare const categorySchema: z.ZodType<Category>;
138
162
 
139
163
  /**
140
164
  * Generated schemas for a class.
165
+ *
166
+ * @public
141
167
  */
142
168
  export declare interface ClassSchemas {
143
169
  /** JSON Schema 2020-12 for validation */
@@ -148,11 +174,15 @@ export declare interface ClassSchemas {
148
174
 
149
175
  /**
150
176
  * A Control element that binds to a JSON Schema property.
177
+ *
178
+ * @public
151
179
  */
152
180
  export declare type ControlElement = z.infer<typeof controlSchema>;
153
181
 
154
182
  /**
155
183
  * Zod schema for a Control element.
184
+ *
185
+ * @public
156
186
  */
157
187
  export declare const controlSchema: z.ZodObject<{
158
188
  type: z.ZodLiteral<"Control">;
@@ -256,10 +286,16 @@ export declare const controlSchema: z.ZodObject<{
256
286
  * @param extensions - The extension definitions to register.
257
287
  * @returns An {@link ExtensionRegistry} instance.
258
288
  * @throws If duplicate type/constraint/annotation IDs are detected across extensions.
289
+ *
290
+ * @public
259
291
  */
260
292
  export declare function createExtensionRegistry(extensions: readonly ExtensionDefinition[]): ExtensionRegistry;
261
293
 
262
- /** JSON Schema with FormSpec extension properties for arbitrary x-formspec-* keys. */
294
+ /**
295
+ * JSON Schema with FormSpec extension properties for arbitrary `x-formspec-*` keys.
296
+ *
297
+ * @public
298
+ */
263
299
  export declare type ExtendedJSONSchema7 = JSONSchema7 & FormSpecSchemaExtensions;
264
300
 
265
301
  /**
@@ -268,6 +304,8 @@ export declare type ExtendedJSONSchema7 = JSONSchema7 & FormSpecSchemaExtensions
268
304
  * Type IDs follow the format: `<extensionId>/<typeName>`
269
305
  * Constraint IDs follow the format: `<extensionId>/<constraintName>`
270
306
  * Annotation IDs follow the format: `<extensionId>/<annotationName>`
307
+ *
308
+ * @public
271
309
  */
272
310
  export declare interface ExtensionRegistry {
273
311
  /** The extensions registered in this registry (in registration order). */
@@ -319,11 +357,17 @@ export declare interface ExtensionRegistry {
319
357
  findAnnotation(annotationId: string): CustomAnnotationRegistration | undefined;
320
358
  }
321
359
 
322
- /** Extension properties for custom FormSpec constraint tags. */
360
+ /**
361
+ * Extension properties for custom FormSpec constraint tags.
362
+ *
363
+ * @public
364
+ */
323
365
  export declare type FormSpecSchemaExtensions = Record<`x-formspec-${string}`, unknown>;
324
366
 
325
367
  /**
326
368
  * Options for generating schemas from a decorated class.
369
+ *
370
+ * @public
327
371
  */
328
372
  export declare interface GenerateFromClassOptions extends GenerateJsonSchemaFromIROptions {
329
373
  /** Path to the TypeScript source file */
@@ -334,6 +378,8 @@ export declare interface GenerateFromClassOptions extends GenerateJsonSchemaFrom
334
378
 
335
379
  /**
336
380
  * Result of generating schemas from a decorated class.
381
+ *
382
+ * @public
337
383
  */
338
384
  export declare interface GenerateFromClassResult {
339
385
  /** JSON Schema 2020-12 for validation */
@@ -369,6 +415,8 @@ export declare interface GenerateFromClassResult {
369
415
  *
370
416
  * @param form - The FormSpec to convert
371
417
  * @returns A JSON Schema 2020-12 object
418
+ *
419
+ * @public
372
420
  */
373
421
  export declare function generateJsonSchema<E extends readonly FormElement[]>(form: FormSpec<E>, options?: GenerateJsonSchemaOptions): JsonSchema2020;
374
422
 
@@ -411,11 +459,15 @@ export declare function generateJsonSchema<E extends readonly FormElement[]>(for
411
459
  *
412
460
  * @param ir - The canonical FormIR produced by a canonicalizer
413
461
  * @returns A plain JSON-serializable JSON Schema 2020-12 object
462
+ *
463
+ * @public
414
464
  */
415
465
  export declare function generateJsonSchemaFromIR(ir: FormIR, options?: GenerateJsonSchemaFromIROptions): JsonSchema2020;
416
466
 
417
467
  /**
418
468
  * Options for generating JSON Schema from a canonical FormIR.
469
+ *
470
+ * @public
419
471
  */
420
472
  export declare interface GenerateJsonSchemaFromIROptions {
421
473
  /**
@@ -436,6 +488,8 @@ export declare interface GenerateJsonSchemaFromIROptions {
436
488
  * Options for generating JSON Schema from a Chain DSL form.
437
489
  *
438
490
  * These options are forwarded to the IR-based JSON Schema generator.
491
+ *
492
+ * @public
439
493
  */
440
494
  export declare type GenerateJsonSchemaOptions = GenerateJsonSchemaFromIROptions;
441
495
 
@@ -457,6 +511,8 @@ export declare type GenerateJsonSchemaOptions = GenerateJsonSchemaFromIROptions;
457
511
  *
458
512
  * @param options - File path and type name
459
513
  * @returns Generated JSON Schema and UI Schema
514
+ *
515
+ * @public
460
516
  */
461
517
  export declare function generateSchemas(options: GenerateSchemasOptions): GenerateFromClassResult;
462
518
 
@@ -478,11 +534,15 @@ export declare function generateSchemas(options: GenerateSchemasOptions): Genera
478
534
  *
479
535
  * @param options - File path, class name, and optional compiler options
480
536
  * @returns Generated JSON Schema and UI Schema
537
+ *
538
+ * @public
481
539
  */
482
540
  export declare function generateSchemasFromClass(options: GenerateFromClassOptions): GenerateFromClassResult;
483
541
 
484
542
  /**
485
543
  * Options for generating schemas from a named type (class, interface, or type alias).
544
+ *
545
+ * @public
486
546
  */
487
547
  export declare interface GenerateSchemasOptions extends GenerateJsonSchemaFromIROptions {
488
548
  /** Path to the TypeScript source file */
@@ -534,6 +594,8 @@ export declare interface GenerateSchemasOptions extends GenerateJsonSchemaFromIR
534
594
  *
535
595
  * @param form - The FormSpec to convert
536
596
  * @returns A JSON Forms UI Schema
597
+ *
598
+ * @public
537
599
  */
538
600
  export declare function generateUiSchema<E extends readonly FormElement[]>(form: FormSpec<E>): UISchema;
539
601
 
@@ -545,11 +607,15 @@ export declare function generateUiSchema<E extends readonly FormElement[]>(form:
545
607
  * @param schema - Any JSON Schema node
546
608
  * @param key - Extension key (must start with `x-formspec-`)
547
609
  * @returns The extension value, or `undefined` if not present
610
+ *
611
+ * @public
548
612
  */
549
613
  export declare function getSchemaExtension(schema: object, key: `x-formspec-${string}`): unknown;
550
614
 
551
615
  /**
552
616
  * A group element with a label.
617
+ *
618
+ * @public
553
619
  */
554
620
  export declare interface GroupLayout {
555
621
  type: "Group";
@@ -560,10 +626,17 @@ export declare interface GroupLayout {
560
626
  [k: string]: unknown;
561
627
  }
562
628
 
629
+ /**
630
+ * Zod schema for a group layout element.
631
+ *
632
+ * @public
633
+ */
563
634
  export declare const groupLayoutSchema: z.ZodType<GroupLayout>;
564
635
 
565
636
  /**
566
637
  * A horizontal layout element.
638
+ *
639
+ * @public
567
640
  */
568
641
  export declare interface HorizontalLayout {
569
642
  type: "HorizontalLayout";
@@ -573,6 +646,11 @@ export declare interface HorizontalLayout {
573
646
  [k: string]: unknown;
574
647
  }
575
648
 
649
+ /**
650
+ * Zod schema for a horizontal layout element.
651
+ *
652
+ * @public
653
+ */
576
654
  export declare const horizontalLayoutSchema: z.ZodType<HorizontalLayout>;
577
655
 
578
656
  /**
@@ -580,6 +658,8 @@ export declare const horizontalLayoutSchema: z.ZodType<HorizontalLayout>;
580
658
  *
581
659
  * This interface covers the subset of JSON Schema 2020-12 that this generator
582
660
  * emits, plus an index signature for custom `x-formspec-*` extension keywords.
661
+ *
662
+ * @public
583
663
  */
584
664
  export declare interface JsonSchema2020 {
585
665
  $schema?: string;
@@ -616,6 +696,8 @@ export declare interface JsonSchema2020 {
616
696
 
617
697
  /**
618
698
  * A JSON Schema definition (legacy subset used by Zod validator and types.ts).
699
+ *
700
+ * @public
619
701
  */
620
702
  export declare interface JSONSchema7 {
621
703
  $schema?: string;
@@ -666,6 +748,11 @@ export declare interface JSONSchema7 {
666
748
  "x-formspec-schemaSource"?: string;
667
749
  }
668
750
 
751
+ /**
752
+ * Zod schema for the legacy JSON Schema 7 subset used by `@formspec/build`.
753
+ *
754
+ * @public
755
+ */
669
756
  export declare const jsonSchema7Schema: z.ZodType<JSONSchema7>;
670
757
 
671
758
  /**
@@ -675,21 +762,29 @@ export declare const jsonSchema7Schema: z.ZodType<JSONSchema7>;
675
762
  */
676
763
  /**
677
764
  * JSON Schema primitive types.
765
+ *
766
+ * @public
678
767
  */
679
768
  export declare type JSONSchemaType = "string" | "number" | "integer" | "boolean" | "object" | "array" | "null";
680
769
 
681
770
  /**
682
771
  * Zod schema for JSON Schema primitive type strings.
772
+ *
773
+ * @public
683
774
  */
684
775
  export declare const jsonSchemaTypeSchema: z.ZodEnum<["string", "number", "integer", "boolean", "object", "array", "null"]>;
685
776
 
686
777
  /**
687
778
  * A Label element for displaying static text.
779
+ *
780
+ * @public
688
781
  */
689
782
  export declare type LabelElement = z.infer<typeof labelElementSchema>;
690
783
 
691
784
  /**
692
785
  * Zod schema for a Label element.
786
+ *
787
+ * @public
693
788
  */
694
789
  export declare const labelElementSchema: z.ZodObject<{
695
790
  type: z.ZodLiteral<"Label">;
@@ -782,6 +877,8 @@ export declare const labelElementSchema: z.ZodObject<{
782
877
 
783
878
  /**
784
879
  * Result of generating schemas from a mixed-authoring composition.
880
+ *
881
+ * @public
785
882
  */
786
883
  export declare interface MixedAuthoringSchemas {
787
884
  /** JSON Schema 2020-12 for validation. */
@@ -792,11 +889,15 @@ export declare interface MixedAuthoringSchemas {
792
889
 
793
890
  /**
794
891
  * Rule for conditional element visibility/enablement.
892
+ *
893
+ * @public
795
894
  */
796
895
  export declare type Rule = z.infer<typeof ruleSchema>;
797
896
 
798
897
  /**
799
898
  * JSON Schema subset used in rule conditions.
899
+ *
900
+ * @public
800
901
  */
801
902
  export declare interface RuleConditionSchema {
802
903
  const?: unknown;
@@ -813,20 +914,31 @@ export declare interface RuleConditionSchema {
813
914
  allOf?: RuleConditionSchema[];
814
915
  }
815
916
 
917
+ /**
918
+ * Zod schema for the rule-condition JSON Schema subset.
919
+ *
920
+ * @public
921
+ */
816
922
  export declare const ruleConditionSchema: z.ZodType<RuleConditionSchema>;
817
923
 
818
924
  /**
819
925
  * Rule effect types for conditional visibility.
926
+ *
927
+ * @public
820
928
  */
821
929
  export declare type RuleEffect = z.infer<typeof ruleEffectSchema>;
822
930
 
823
931
  /**
824
932
  * Zod schema for rule effect values.
933
+ *
934
+ * @public
825
935
  */
826
936
  export declare const ruleEffectSchema: z.ZodEnum<["SHOW", "HIDE", "ENABLE", "DISABLE"]>;
827
937
 
828
938
  /**
829
939
  * Zod schema for a UI Schema rule.
940
+ *
941
+ * @public
830
942
  */
831
943
  export declare const ruleSchema: z.ZodObject<{
832
944
  effect: z.ZodEnum<["SHOW", "HIDE", "ENABLE", "DISABLE"]>;
@@ -856,11 +968,15 @@ export declare const ruleSchema: z.ZodObject<{
856
968
 
857
969
  /**
858
970
  * Condition for a rule.
971
+ *
972
+ * @public
859
973
  */
860
974
  export declare type SchemaBasedCondition = z.infer<typeof schemaBasedConditionSchema>;
861
975
 
862
976
  /**
863
977
  * Zod schema for a schema-based rule condition.
978
+ *
979
+ * @public
864
980
  */
865
981
  export declare const schemaBasedConditionSchema: z.ZodObject<{
866
982
  scope: z.ZodString;
@@ -883,16 +999,22 @@ export declare const schemaBasedConditionSchema: z.ZodObject<{
883
999
  * @param schema - Any JSON Schema node
884
1000
  * @param key - Extension key (must start with `x-formspec-`)
885
1001
  * @param value - Extension value
1002
+ *
1003
+ * @public
886
1004
  */
887
1005
  export declare function setSchemaExtension(schema: object, key: `x-formspec-${string}`, value: unknown): void;
888
1006
 
889
1007
  /**
890
1008
  * Root UI Schema (always a layout — not a Control, Category, or Label).
1009
+ *
1010
+ * @public
891
1011
  */
892
1012
  export declare type UISchema = VerticalLayout | HorizontalLayout | GroupLayout | Categorization;
893
1013
 
894
1014
  /**
895
1015
  * Union of all UI Schema element types.
1016
+ *
1017
+ * @public
896
1018
  */
897
1019
  export declare type UISchemaElement = ControlElement | VerticalLayout | HorizontalLayout | GroupLayout | Categorization | Category | LabelElement;
898
1020
 
@@ -903,6 +1025,8 @@ export declare type UISchemaElement = ControlElement | VerticalLayout | Horizont
903
1025
  * shared by all element types. It is kept as an interface (rather than
904
1026
  * derived from Zod) because it is the base of a discriminated union, not
905
1027
  * a union member itself.
1028
+ *
1029
+ * @public
906
1030
  */
907
1031
  export declare interface UISchemaElementBase {
908
1032
  type: UISchemaElementType;
@@ -910,25 +1034,38 @@ export declare interface UISchemaElementBase {
910
1034
  options?: Record<string, unknown>;
911
1035
  }
912
1036
 
1037
+ /**
1038
+ * Zod schema for any UI Schema element.
1039
+ *
1040
+ * @public
1041
+ */
913
1042
  export declare const uiSchemaElementSchema: z.ZodType<UISchemaElement>;
914
1043
 
915
1044
  /**
916
1045
  * UI Schema element types.
1046
+ *
1047
+ * @public
917
1048
  */
918
1049
  export declare type UISchemaElementType = z.infer<typeof uiSchemaElementTypeSchema>;
919
1050
 
920
1051
  /**
921
1052
  * Zod schema for UI Schema element type strings.
1053
+ *
1054
+ * @public
922
1055
  */
923
1056
  export declare const uiSchemaElementTypeSchema: z.ZodEnum<["Control", "VerticalLayout", "HorizontalLayout", "Group", "Categorization", "Category", "Label"]>;
924
1057
 
925
1058
  /**
926
1059
  * Zod schema for the root UI Schema (layout types only).
1060
+ *
1061
+ * @public
927
1062
  */
928
1063
  export declare const uiSchemaSchema: z.ZodType<UISchema>;
929
1064
 
930
1065
  /**
931
1066
  * A vertical layout element.
1067
+ *
1068
+ * @public
932
1069
  */
933
1070
  export declare interface VerticalLayout {
934
1071
  type: "VerticalLayout";
@@ -938,6 +1075,11 @@ export declare interface VerticalLayout {
938
1075
  [k: string]: unknown;
939
1076
  }
940
1077
 
1078
+ /**
1079
+ * Zod schema for a vertical layout element.
1080
+ *
1081
+ * @public
1082
+ */
941
1083
  export declare const verticalLayoutSchema: z.ZodType<VerticalLayout>;
942
1084
 
943
1085
  /**
@@ -968,11 +1110,15 @@ export declare const verticalLayoutSchema: z.ZodType<VerticalLayout>;
968
1110
  * @param form - The FormSpec to build schemas from
969
1111
  * @param options - Output options (directory, file name, indentation)
970
1112
  * @returns Object containing paths to the generated files
1113
+ *
1114
+ * @public
971
1115
  */
972
1116
  export declare function writeSchemas<E extends readonly FormElement[]>(form: FormSpec<E>, options: WriteSchemasOptions): WriteSchemasResult;
973
1117
 
974
1118
  /**
975
1119
  * Options for writing schemas to disk.
1120
+ *
1121
+ * @public
976
1122
  */
977
1123
  export declare interface WriteSchemasOptions extends GenerateJsonSchemaFromIROptions {
978
1124
  /** Output directory for the schema files */
@@ -985,6 +1131,8 @@ export declare interface WriteSchemasOptions extends GenerateJsonSchemaFromIROpt
985
1131
 
986
1132
  /**
987
1133
  * Result of writing schemas to disk.
1134
+ *
1135
+ * @public
988
1136
  */
989
1137
  export declare interface WriteSchemasResult {
990
1138
  /** Path to the generated JSON Schema file */