@formspec/build 0.1.0-alpha.26 → 0.1.0-alpha.28

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.
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,8 +138,6 @@ 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
  *
@@ -186,8 +180,6 @@ export declare interface Category {
186
180
 
187
181
  export { Conditional }
188
182
 
189
- export { ConstraintSemanticRole }
190
-
191
183
  export { ConstraintTagRegistration }
192
184
 
193
185
  /**
@@ -239,13 +231,15 @@ export { EnumOption }
239
231
 
240
232
  export { EnumOptionValue }
241
233
 
242
- /* Excluded from this release type: ExtendedJSONSchema7 */
243
- 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;
244
240
 
245
241
  export { ExtensionDefinition }
246
242
 
247
- export { ExtensionPayloadValue }
248
-
249
243
  /**
250
244
  * A registry of extensions that provides lookup by fully-qualified ID.
251
245
  *
@@ -305,13 +299,16 @@ export declare interface ExtensionRegistry {
305
299
  findAnnotation(annotationId: string): CustomAnnotationRegistration | undefined;
306
300
  }
307
301
 
308
- export { ExtensionTypeKind }
309
-
310
302
  export { FormElement }
311
303
 
312
304
  export { FormSpec }
313
305
 
314
- /* 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>;
315
312
 
316
313
  /**
317
314
  * Options for generating schemas from a decorated class.
@@ -428,6 +425,34 @@ export declare function generateSchemas(options: GenerateSchemasOptions): Genera
428
425
  */
429
426
  export declare function generateSchemasFromClass(options: GenerateFromClassOptions): GenerateFromClassResult;
430
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
+
431
456
  /**
432
457
  * Options for generating schemas from a named type (class, interface, or type alias).
433
458
  *
@@ -599,9 +624,109 @@ export declare interface JsonSchema2020 {
599
624
  [key: `x-${string}`]: unknown;
600
625
  }
601
626
 
602
- /* 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
+ }
603
711
 
604
- /* Excluded from this release type: JSONSchemaType */
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
+
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";
605
730
 
606
731
  /**
607
732
  * A Label element for displaying static text.
@@ -769,6 +894,13 @@ export declare interface UISchemaElementBase {
769
894
  */
770
895
  export declare type UISchemaElementType = "Control" | "VerticalLayout" | "HorizontalLayout" | "Group" | "Categorization" | "Category" | "Label";
771
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
+
772
904
  /**
773
905
  * A vertical layout element.
774
906
  *
@@ -787,8 +919,6 @@ export declare interface VerticalLayout {
787
919
  readonly [k: string]: unknown;
788
920
  }
789
921
 
790
- export { VocabularyKeywordRegistration }
791
-
792
922
  /**
793
923
  * Builds and writes both JSON Schema and UI Schema files to disk.
794
924
  *