@formspec/build 0.1.0-alpha.31 → 0.1.0-alpha.32

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/README.md CHANGED
@@ -19,11 +19,11 @@ Most app code can use `formspec`, but use `@formspec/build` directly when you ne
19
19
 
20
20
  ## Public Entry Points
21
21
 
22
- | Entry point | Purpose |
23
- | --------------------------- | -------------------------------------- |
24
- | `@formspec/build` | Public build APIs |
25
- | `@formspec/build/browser` | Browser-safe chain-DSL and IR surface |
26
- | `@formspec/build/internals` | Unstable low-level IR/analyzer APIs |
22
+ | Entry point | Purpose |
23
+ | --------------------------- | ------------------------------------- |
24
+ | `@formspec/build` | Public build APIs |
25
+ | `@formspec/build/browser` | Browser-safe chain-DSL and IR surface |
26
+ | `@formspec/build/internals` | Unstable low-level IR/analyzer APIs |
27
27
 
28
28
  ## Chain DSL Generation
29
29
 
@@ -63,6 +63,83 @@ const result = generateSchemasFromClass({
63
63
  });
64
64
  ```
65
65
 
66
+ ### Static Build Context
67
+
68
+ Use the static build context APIs when you need to inspect exports, declarations,
69
+ or method signatures before deciding what schemas to generate.
70
+
71
+ Public helpers in this workflow:
72
+
73
+ - `createStaticBuildContext(filePath)` - Create a reusable compiler-backed context from a file.
74
+ - `createStaticBuildContextFromProgram(program, filePath)` - Reuse a host-owned `ts.Program`.
75
+ - `resolveModuleExport(context, exportName?)` - Resolve any exported symbol, including functions and other non-schema declarations.
76
+ - `resolveModuleExportDeclaration(context, exportName?)` - Resolve only schema-source declarations (`class`, `interface`, `type` alias).
77
+ - `generateSchemasFromDeclaration(...)` - Generate from a resolved schema-source declaration.
78
+ - `generateSchemasFromParameter(...)` - Generate from a method or function parameter declaration.
79
+ - `generateSchemasFromReturnType(...)` - Generate from a method or function return type.
80
+ - `generateSchemasFromType(...)` - Generate directly from a resolved `ts.Type`.
81
+
82
+ Use `resolveModuleExportDeclaration(...)` when your tooling wants to hand a resolved
83
+ declaration straight to `generateSchemasFromDeclaration(...)`. Use `resolveModuleExport(...)`
84
+ when you need lower-level TypeScript access first, for example to inspect a function
85
+ export and then generate schemas from one of its signature types.
86
+
87
+ ```ts
88
+ import * as ts from "typescript";
89
+ import {
90
+ createStaticBuildContext,
91
+ generateSchemasFromDeclaration,
92
+ generateSchemasFromParameter,
93
+ generateSchemasFromReturnType,
94
+ resolveModuleExport,
95
+ resolveModuleExportDeclaration,
96
+ } from "@formspec/build";
97
+
98
+ const context = createStaticBuildContext("./src/service.ts");
99
+ const serviceDeclaration = resolveModuleExportDeclaration(context, "PaymentService");
100
+
101
+ if (serviceDeclaration && ts.isClassDeclaration(serviceDeclaration)) {
102
+ const submitMethod = serviceDeclaration.members.find(
103
+ (member): member is ts.MethodDeclaration =>
104
+ ts.isMethodDeclaration(member) &&
105
+ ts.isIdentifier(member.name) &&
106
+ member.name.text === "submit"
107
+ );
108
+
109
+ if (submitMethod?.parameters[0]) {
110
+ const inputSchemas = generateSchemasFromParameter({
111
+ context,
112
+ parameter: submitMethod.parameters[0],
113
+ });
114
+ }
115
+ }
116
+
117
+ const inputDeclaration = resolveModuleExportDeclaration(context, "SubmitInput");
118
+ if (inputDeclaration) {
119
+ const inputSchemas = generateSchemasFromDeclaration({
120
+ context,
121
+ declaration: inputDeclaration,
122
+ });
123
+ }
124
+
125
+ const paymentSymbol = resolveModuleExport(context, "submitPayment");
126
+ const paymentDeclaration = paymentSymbol?.declarations?.find(ts.isFunctionDeclaration);
127
+ if (paymentDeclaration) {
128
+ const outputSchemas = generateSchemasFromReturnType({
129
+ context,
130
+ declaration: paymentDeclaration,
131
+ });
132
+ }
133
+ ```
134
+
135
+ If you already own a `ts.Program`, use `createStaticBuildContextFromProgram(program, filePath)`
136
+ instead of letting FormSpec create one. If your tool has already resolved a raw
137
+ `ts.Type` or signature declaration, use `generateSchemasFromType(...)` or
138
+ `generateSchemasFromReturnType(...)` directly.
139
+
140
+ This is the supported public path for build-time analysis workflows that used to
141
+ require `@formspec/build/internals`.
142
+
66
143
  ### Supported TSDoc Examples
67
144
 
68
145
  ```ts
@@ -57,7 +57,13 @@ export type AnalyzeTypeAliasToIRResult = {
57
57
  readonly ok: false;
58
58
  readonly error: string;
59
59
  };
60
+ export interface DeclarationRootInfo {
61
+ readonly metadata?: ResolvedMetadata;
62
+ readonly annotations: readonly AnnotationNode[];
63
+ readonly diagnostics: readonly ConstraintSemanticDiagnostic[];
64
+ }
60
65
  type AnalyzerMetadataPolicy = ReturnType<typeof normalizeMetadataPolicy>;
66
+ export declare function analyzeDeclarationRootInfo(declaration: ts.ClassDeclaration | ts.InterfaceDeclaration | ts.TypeAliasDeclaration, checker: ts.TypeChecker, file?: string, extensionRegistry?: ExtensionRegistry, metadataPolicy?: MetadataPolicyInput): DeclarationRootInfo;
61
67
  /**
62
68
  * Analyzes a class declaration and produces canonical IR FieldNodes.
63
69
  */
@@ -1 +1 @@
1
- {"version":3,"file":"class-analyzer.d.ts","sourceRoot":"","sources":["../../src/analyzer/class-analyzer.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,EAEL,KAAK,4BAA4B,EAElC,MAAM,6BAA6B,CAAC;AACrC,OAAO,KAAK,EACV,SAAS,EACT,QAAQ,EAIR,cAAc,EAId,cAAc,EACd,SAAS,EACT,gBAAgB,EAEjB,MAAM,0BAA0B,CAAC;AAQlC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAGL,uBAAuB,EAExB,MAAM,sBAAsB,CAAC;AAoE9B;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,qEAAqE;IACrE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,6FAA6F;IAC7F,QAAQ,CAAC,QAAQ,CAAC,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,M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E,CAAC,QAAQ,GAAG,SAAS,CAAC;IACxC,2BAA2B;IAC3B,UAAU,EAAE,EAAE,CAAC,IAAI,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,qBAAqB;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,2BAA2B;IAC3B,QAAQ,EAAE,EAAE,CAAC,QAAQ,GAAG,SAAS,CAAC;IAClC,oBAAoB;IACpB,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;IACd,0DAA0D;IAC1D,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,iEAAiE;IACjE,QAAQ,EAAE,OAAO,CAAC;CACnB"}
@@ -219,12 +219,48 @@ export declare interface ControlElement {
219
219
  */
220
220
  export declare function createExtensionRegistry(extensions: readonly ExtensionDefinition[]): ExtensionRegistry;
221
221
 
222
+ /**
223
+ * Creates a supported static build context for a source file.
224
+ *
225
+ * @param filePath - Entry TypeScript source file used for export resolution
226
+ * @returns Reusable build context containing the program, checker, and source file
227
+ *
228
+ * @public
229
+ */
230
+ export declare function createStaticBuildContext(filePath: string): StaticBuildContext;
231
+
232
+ /**
233
+ * Creates a supported static build context from an existing host-owned program.
234
+ *
235
+ * @param program - Existing TypeScript program supplied by the caller
236
+ * @param filePath - Entry TypeScript source file used for export resolution
237
+ * @returns Reusable build context containing the program, checker, and source file
238
+ *
239
+ * @public
240
+ */
241
+ export declare function createStaticBuildContextFromProgram(program: ts.Program, filePath: string): StaticBuildContext;
242
+
222
243
  export { CustomAnnotationRegistration }
223
244
 
224
245
  export { CustomConstraintRegistration }
225
246
 
226
247
  export { CustomTypeRegistration }
227
248
 
249
+ /**
250
+ * Generated schemas for a discovered declaration or signature type.
251
+ *
252
+ * `uiSchema` is `null` when the discovered type does not have an object-shaped
253
+ * root that can be represented as a JSON Forms layout.
254
+ *
255
+ * @public
256
+ */
257
+ export declare interface DiscoveredTypeSchemas {
258
+ /** JSON Schema 2020-12 for the resolved type. */
259
+ readonly jsonSchema: JsonSchema2020;
260
+ /** UI Schema for object-shaped roots, or `null` when not applicable. */
261
+ readonly uiSchema: UISchema | null;
262
+ }
263
+
228
264
  export { DynamicEnumField }
229
265
 
230
266
  export { DynamicSchemaField }
@@ -429,6 +465,49 @@ export declare function generateSchemas(options: GenerateSchemasOptions): Genera
429
465
  */
430
466
  export declare function generateSchemasFromClass(options: GenerateFromClassOptions): GenerateFromClassResult;
431
467
 
468
+ /**
469
+ * Generates schemas from a resolved declaration using the supported public
470
+ * static-build workflow.
471
+ *
472
+ * Named declarations reuse the same analyzer semantics as FormSpec's existing
473
+ * top-level generation APIs. Non-object type aliases fall back to the generic
474
+ * resolved-type entry point.
475
+ *
476
+ * @public
477
+ */
478
+ export declare function generateSchemasFromDeclaration(options: GenerateSchemasFromDeclarationOptions): DiscoveredTypeSchemas;
479
+
480
+ /**
481
+ * Options for generating schemas from a resolved declaration.
482
+ *
483
+ * @public
484
+ */
485
+ export declare interface GenerateSchemasFromDeclarationOptions extends StaticSchemaGenerationOptions {
486
+ /** Supported build context used for checker access and related analysis. */
487
+ readonly context: StaticBuildContext;
488
+ /** Declaration to turn into schemas. */
489
+ readonly declaration: SchemaSourceDeclaration;
490
+ }
491
+
492
+ /**
493
+ * Generates schemas for a method or function parameter type.
494
+ *
495
+ * @public
496
+ */
497
+ export declare function generateSchemasFromParameter(options: GenerateSchemasFromParameterOptions): DiscoveredTypeSchemas;
498
+
499
+ /**
500
+ * Options for generating schemas from a method or function parameter type.
501
+ *
502
+ * @public
503
+ */
504
+ export declare interface GenerateSchemasFromParameterOptions extends StaticSchemaGenerationOptions {
505
+ /** Supported build context used for checker access and related analysis. */
506
+ readonly context: StaticBuildContext;
507
+ /** Parameter declaration whose type should be converted into schemas. */
508
+ readonly parameter: ts.ParameterDeclaration;
509
+ }
510
+
432
511
  /**
433
512
  * Generates JSON Schema and UI Schema from a named type within an existing
434
513
  * TypeScript program supplied by the caller.
@@ -457,6 +536,57 @@ export declare interface GenerateSchemasFromProgramOptions extends StaticSchemaG
457
536
  readonly typeName: string;
458
537
  }
459
538
 
539
+ /**
540
+ * Generates schemas for a method or function return type.
541
+ *
542
+ * @public
543
+ */
544
+ export declare function generateSchemasFromReturnType(options: GenerateSchemasFromReturnTypeOptions): DiscoveredTypeSchemas;
545
+
546
+ /**
547
+ * Options for generating schemas from a method or function return type.
548
+ *
549
+ * @public
550
+ */
551
+ export declare interface GenerateSchemasFromReturnTypeOptions extends StaticSchemaGenerationOptions {
552
+ /** Supported build context used for checker access and related analysis. */
553
+ readonly context: StaticBuildContext;
554
+ /** Signature declaration whose return type should be converted into schemas. */
555
+ readonly declaration: ts.SignatureDeclaration;
556
+ }
557
+
558
+ /**
559
+ * Generates schemas from a resolved TypeScript type.
560
+ *
561
+ * This is the advanced public entry point for build tooling that already uses
562
+ * the TypeScript compiler API to discover types before handing them to
563
+ * FormSpec.
564
+ *
565
+ * @public
566
+ */
567
+ export declare function generateSchemasFromType(options: GenerateSchemasFromTypeOptions): DiscoveredTypeSchemas;
568
+
569
+ /**
570
+ * Options for generating schemas from a resolved TypeScript type.
571
+ *
572
+ * @public
573
+ */
574
+ export declare interface GenerateSchemasFromTypeOptions extends StaticSchemaGenerationOptions {
575
+ /** Supported build context used for checker access and related analysis. */
576
+ readonly context: StaticBuildContext;
577
+ /** TypeScript type to turn into schemas. */
578
+ readonly type: ts.Type;
579
+ /**
580
+ * Optional source node associated with the type.
581
+ *
582
+ * When provided, FormSpec uses it as the source location for provenance and
583
+ * inline-type analysis.
584
+ */
585
+ readonly sourceNode?: ts.Node | undefined;
586
+ /** Optional logical name used for anonymous roots. */
587
+ readonly name?: string | undefined;
588
+ }
589
+
460
590
  /**
461
591
  * Options for generating schemas from a named type (class, interface, or type alias).
462
592
  *
@@ -776,6 +906,31 @@ export { NumberField }
776
906
 
777
907
  export { ObjectField }
778
908
 
909
+ /**
910
+ * Resolves an export from the context source file, following aliases and re-exports.
911
+ *
912
+ * @param context - Static build context created for the entry source file
913
+ * @param exportName - Export name to resolve. Defaults to `"default"`.
914
+ * @returns Resolved symbol for the export, or `null` when it cannot be found
915
+ *
916
+ * @public
917
+ */
918
+ export declare function resolveModuleExport(context: StaticBuildContext, exportName?: string): ts.Symbol | null;
919
+
920
+ /**
921
+ * Resolves the declaration behind an export from the context source file,
922
+ * following aliases and re-exports. This helper is intentionally limited to
923
+ * declaration kinds accepted by declaration-driven schema generation.
924
+ *
925
+ * @param context - Static build context created for the entry source file
926
+ * @param exportName - Export name to resolve. Defaults to `"default"`.
927
+ * @returns Resolved class, interface, or type-alias declaration for the export,
928
+ * or `null` when the export does not resolve to one of those schema-source kinds
929
+ *
930
+ * @public
931
+ */
932
+ export declare function resolveModuleExportDeclaration(context: StaticBuildContext, exportName?: string): ts.ClassDeclaration | ts.InterfaceDeclaration | ts.TypeAliasDeclaration | null;
933
+
779
934
  /**
780
935
  * Rule for conditional element visibility/enablement.
781
936
  *
@@ -847,6 +1002,31 @@ export declare interface SchemaBasedCondition {
847
1002
  readonly schema: RuleConditionSchema;
848
1003
  }
849
1004
 
1005
+ /**
1006
+ * Supported declaration kinds for declaration-driven schema generation.
1007
+ *
1008
+ * @public
1009
+ */
1010
+ export declare type SchemaSourceDeclaration = ts.ClassDeclaration | ts.InterfaceDeclaration | ts.TypeAliasDeclaration;
1011
+
1012
+ /**
1013
+ * Supported compiler context for static build-time analysis workflows.
1014
+ *
1015
+ * This context gives consumers access to the TypeScript program, checker, and
1016
+ * source file used to discover declarations before invoking FormSpec schema
1017
+ * generation helpers.
1018
+ *
1019
+ * @public
1020
+ */
1021
+ export declare interface StaticBuildContext {
1022
+ /** Host-owned or FormSpec-created TypeScript program. */
1023
+ readonly program: ts.Program;
1024
+ /** TypeScript checker for symbol and type analysis. */
1025
+ readonly checker: ts.TypeChecker;
1026
+ /** Source file used as the entry module for export resolution. */
1027
+ readonly sourceFile: ts.SourceFile;
1028
+ }
1029
+
850
1030
  export { StaticEnumField }
851
1031
 
852
1032
  /**
@@ -219,12 +219,48 @@ export declare interface ControlElement {
219
219
  */
220
220
  export declare function createExtensionRegistry(extensions: readonly ExtensionDefinition[]): ExtensionRegistry;
221
221
 
222
+ /**
223
+ * Creates a supported static build context for a source file.
224
+ *
225
+ * @param filePath - Entry TypeScript source file used for export resolution
226
+ * @returns Reusable build context containing the program, checker, and source file
227
+ *
228
+ * @public
229
+ */
230
+ export declare function createStaticBuildContext(filePath: string): StaticBuildContext;
231
+
232
+ /**
233
+ * Creates a supported static build context from an existing host-owned program.
234
+ *
235
+ * @param program - Existing TypeScript program supplied by the caller
236
+ * @param filePath - Entry TypeScript source file used for export resolution
237
+ * @returns Reusable build context containing the program, checker, and source file
238
+ *
239
+ * @public
240
+ */
241
+ export declare function createStaticBuildContextFromProgram(program: ts.Program, filePath: string): StaticBuildContext;
242
+
222
243
  export { CustomAnnotationRegistration }
223
244
 
224
245
  export { CustomConstraintRegistration }
225
246
 
226
247
  export { CustomTypeRegistration }
227
248
 
249
+ /**
250
+ * Generated schemas for a discovered declaration or signature type.
251
+ *
252
+ * `uiSchema` is `null` when the discovered type does not have an object-shaped
253
+ * root that can be represented as a JSON Forms layout.
254
+ *
255
+ * @public
256
+ */
257
+ export declare interface DiscoveredTypeSchemas {
258
+ /** JSON Schema 2020-12 for the resolved type. */
259
+ readonly jsonSchema: JsonSchema2020;
260
+ /** UI Schema for object-shaped roots, or `null` when not applicable. */
261
+ readonly uiSchema: UISchema | null;
262
+ }
263
+
228
264
  export { DynamicEnumField }
229
265
 
230
266
  export { DynamicSchemaField }
@@ -429,6 +465,49 @@ export declare function generateSchemas(options: GenerateSchemasOptions): Genera
429
465
  */
430
466
  export declare function generateSchemasFromClass(options: GenerateFromClassOptions): GenerateFromClassResult;
431
467
 
468
+ /**
469
+ * Generates schemas from a resolved declaration using the supported public
470
+ * static-build workflow.
471
+ *
472
+ * Named declarations reuse the same analyzer semantics as FormSpec's existing
473
+ * top-level generation APIs. Non-object type aliases fall back to the generic
474
+ * resolved-type entry point.
475
+ *
476
+ * @public
477
+ */
478
+ export declare function generateSchemasFromDeclaration(options: GenerateSchemasFromDeclarationOptions): DiscoveredTypeSchemas;
479
+
480
+ /**
481
+ * Options for generating schemas from a resolved declaration.
482
+ *
483
+ * @public
484
+ */
485
+ export declare interface GenerateSchemasFromDeclarationOptions extends StaticSchemaGenerationOptions {
486
+ /** Supported build context used for checker access and related analysis. */
487
+ readonly context: StaticBuildContext;
488
+ /** Declaration to turn into schemas. */
489
+ readonly declaration: SchemaSourceDeclaration;
490
+ }
491
+
492
+ /**
493
+ * Generates schemas for a method or function parameter type.
494
+ *
495
+ * @public
496
+ */
497
+ export declare function generateSchemasFromParameter(options: GenerateSchemasFromParameterOptions): DiscoveredTypeSchemas;
498
+
499
+ /**
500
+ * Options for generating schemas from a method or function parameter type.
501
+ *
502
+ * @public
503
+ */
504
+ export declare interface GenerateSchemasFromParameterOptions extends StaticSchemaGenerationOptions {
505
+ /** Supported build context used for checker access and related analysis. */
506
+ readonly context: StaticBuildContext;
507
+ /** Parameter declaration whose type should be converted into schemas. */
508
+ readonly parameter: ts.ParameterDeclaration;
509
+ }
510
+
432
511
  /**
433
512
  * Generates JSON Schema and UI Schema from a named type within an existing
434
513
  * TypeScript program supplied by the caller.
@@ -457,6 +536,57 @@ export declare interface GenerateSchemasFromProgramOptions extends StaticSchemaG
457
536
  readonly typeName: string;
458
537
  }
459
538
 
539
+ /**
540
+ * Generates schemas for a method or function return type.
541
+ *
542
+ * @public
543
+ */
544
+ export declare function generateSchemasFromReturnType(options: GenerateSchemasFromReturnTypeOptions): DiscoveredTypeSchemas;
545
+
546
+ /**
547
+ * Options for generating schemas from a method or function return type.
548
+ *
549
+ * @public
550
+ */
551
+ export declare interface GenerateSchemasFromReturnTypeOptions extends StaticSchemaGenerationOptions {
552
+ /** Supported build context used for checker access and related analysis. */
553
+ readonly context: StaticBuildContext;
554
+ /** Signature declaration whose return type should be converted into schemas. */
555
+ readonly declaration: ts.SignatureDeclaration;
556
+ }
557
+
558
+ /**
559
+ * Generates schemas from a resolved TypeScript type.
560
+ *
561
+ * This is the advanced public entry point for build tooling that already uses
562
+ * the TypeScript compiler API to discover types before handing them to
563
+ * FormSpec.
564
+ *
565
+ * @public
566
+ */
567
+ export declare function generateSchemasFromType(options: GenerateSchemasFromTypeOptions): DiscoveredTypeSchemas;
568
+
569
+ /**
570
+ * Options for generating schemas from a resolved TypeScript type.
571
+ *
572
+ * @public
573
+ */
574
+ export declare interface GenerateSchemasFromTypeOptions extends StaticSchemaGenerationOptions {
575
+ /** Supported build context used for checker access and related analysis. */
576
+ readonly context: StaticBuildContext;
577
+ /** TypeScript type to turn into schemas. */
578
+ readonly type: ts.Type;
579
+ /**
580
+ * Optional source node associated with the type.
581
+ *
582
+ * When provided, FormSpec uses it as the source location for provenance and
583
+ * inline-type analysis.
584
+ */
585
+ readonly sourceNode?: ts.Node | undefined;
586
+ /** Optional logical name used for anonymous roots. */
587
+ readonly name?: string | undefined;
588
+ }
589
+
460
590
  /**
461
591
  * Options for generating schemas from a named type (class, interface, or type alias).
462
592
  *
@@ -776,6 +906,31 @@ export { NumberField }
776
906
 
777
907
  export { ObjectField }
778
908
 
909
+ /**
910
+ * Resolves an export from the context source file, following aliases and re-exports.
911
+ *
912
+ * @param context - Static build context created for the entry source file
913
+ * @param exportName - Export name to resolve. Defaults to `"default"`.
914
+ * @returns Resolved symbol for the export, or `null` when it cannot be found
915
+ *
916
+ * @public
917
+ */
918
+ export declare function resolveModuleExport(context: StaticBuildContext, exportName?: string): ts.Symbol | null;
919
+
920
+ /**
921
+ * Resolves the declaration behind an export from the context source file,
922
+ * following aliases and re-exports. This helper is intentionally limited to
923
+ * declaration kinds accepted by declaration-driven schema generation.
924
+ *
925
+ * @param context - Static build context created for the entry source file
926
+ * @param exportName - Export name to resolve. Defaults to `"default"`.
927
+ * @returns Resolved class, interface, or type-alias declaration for the export,
928
+ * or `null` when the export does not resolve to one of those schema-source kinds
929
+ *
930
+ * @public
931
+ */
932
+ export declare function resolveModuleExportDeclaration(context: StaticBuildContext, exportName?: string): ts.ClassDeclaration | ts.InterfaceDeclaration | ts.TypeAliasDeclaration | null;
933
+
779
934
  /**
780
935
  * Rule for conditional element visibility/enablement.
781
936
  *
@@ -847,6 +1002,31 @@ export declare interface SchemaBasedCondition {
847
1002
  readonly schema: RuleConditionSchema;
848
1003
  }
849
1004
 
1005
+ /**
1006
+ * Supported declaration kinds for declaration-driven schema generation.
1007
+ *
1008
+ * @public
1009
+ */
1010
+ export declare type SchemaSourceDeclaration = ts.ClassDeclaration | ts.InterfaceDeclaration | ts.TypeAliasDeclaration;
1011
+
1012
+ /**
1013
+ * Supported compiler context for static build-time analysis workflows.
1014
+ *
1015
+ * This context gives consumers access to the TypeScript program, checker, and
1016
+ * source file used to discover declarations before invoking FormSpec schema
1017
+ * generation helpers.
1018
+ *
1019
+ * @public
1020
+ */
1021
+ export declare interface StaticBuildContext {
1022
+ /** Host-owned or FormSpec-created TypeScript program. */
1023
+ readonly program: ts.Program;
1024
+ /** TypeScript checker for symbol and type analysis. */
1025
+ readonly checker: ts.TypeChecker;
1026
+ /** Source file used as the entry module for export resolution. */
1027
+ readonly sourceFile: ts.SourceFile;
1028
+ }
1029
+
850
1030
  export { StaticEnumField }
851
1031
 
852
1032
  /**