@formspec/build 0.1.0-alpha.4 → 0.1.0-alpha.40

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 (113) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +238 -93
  3. package/dist/analyzer/class-analyzer.d.ts +135 -0
  4. package/dist/analyzer/class-analyzer.d.ts.map +1 -0
  5. package/dist/analyzer/jsdoc-constraints.d.ts +53 -0
  6. package/dist/analyzer/jsdoc-constraints.d.ts.map +1 -0
  7. package/dist/analyzer/program.d.ts +94 -0
  8. package/dist/analyzer/program.d.ts.map +1 -0
  9. package/dist/analyzer/tsdoc-parser.d.ts +126 -0
  10. package/dist/analyzer/tsdoc-parser.d.ts.map +1 -0
  11. package/dist/browser.cjs +1904 -0
  12. package/dist/browser.cjs.map +1 -0
  13. package/dist/browser.d.ts +74 -0
  14. package/dist/browser.d.ts.map +1 -0
  15. package/dist/browser.js +1861 -0
  16. package/dist/browser.js.map +1 -0
  17. package/dist/build-alpha.d.ts +1491 -0
  18. package/dist/build-beta.d.ts +1491 -0
  19. package/dist/build-internal.d.ts +1491 -0
  20. package/dist/build.d.ts +1184 -43
  21. package/dist/canonicalize/chain-dsl-canonicalizer.d.ts +22 -0
  22. package/dist/canonicalize/chain-dsl-canonicalizer.d.ts.map +1 -0
  23. package/dist/canonicalize/index.d.ts +8 -0
  24. package/dist/canonicalize/index.d.ts.map +1 -0
  25. package/dist/canonicalize/tsdoc-canonicalizer.d.ts +38 -0
  26. package/dist/canonicalize/tsdoc-canonicalizer.d.ts.map +1 -0
  27. package/dist/cli.cjs +6579 -0
  28. package/dist/cli.cjs.map +1 -0
  29. package/dist/cli.js +6551 -103
  30. package/dist/cli.js.map +1 -1
  31. package/dist/extensions/index.d.ts +8 -0
  32. package/dist/extensions/index.d.ts.map +1 -0
  33. package/dist/extensions/registry.d.ts +83 -0
  34. package/dist/extensions/registry.d.ts.map +1 -0
  35. package/dist/generators/class-schema.d.ts +342 -0
  36. package/dist/generators/class-schema.d.ts.map +1 -0
  37. package/dist/generators/discovered-schema.d.ts +152 -0
  38. package/dist/generators/discovered-schema.d.ts.map +1 -0
  39. package/dist/generators/method-schema.d.ts +65 -0
  40. package/dist/generators/method-schema.d.ts.map +1 -0
  41. package/dist/generators/mixed-authoring.d.ts +52 -0
  42. package/dist/generators/mixed-authoring.d.ts.map +1 -0
  43. package/dist/index.cjs +6293 -0
  44. package/dist/index.cjs.map +1 -0
  45. package/dist/index.d.ts +50 -8
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +6268 -107
  48. package/dist/index.js.map +1 -1
  49. package/dist/internals.cjs +5480 -0
  50. package/dist/internals.cjs.map +1 -0
  51. package/dist/internals.d.ts +32 -0
  52. package/dist/internals.d.ts.map +1 -0
  53. package/dist/internals.js +5461 -0
  54. package/dist/internals.js.map +1 -0
  55. package/dist/json-schema/generator.d.ts +27 -6
  56. package/dist/json-schema/generator.d.ts.map +1 -1
  57. package/dist/json-schema/ir-generator.d.ts +144 -0
  58. package/dist/json-schema/ir-generator.d.ts.map +1 -0
  59. package/dist/json-schema/schema.d.ts +23 -0
  60. package/dist/json-schema/schema.d.ts.map +1 -0
  61. package/dist/json-schema/types.d.ts +76 -2
  62. package/dist/json-schema/types.d.ts.map +1 -1
  63. package/dist/metadata/collision-guards.d.ts +3 -0
  64. package/dist/metadata/collision-guards.d.ts.map +1 -0
  65. package/dist/metadata/index.d.ts +7 -0
  66. package/dist/metadata/index.d.ts.map +1 -0
  67. package/dist/metadata/policy.d.ts +11 -0
  68. package/dist/metadata/policy.d.ts.map +1 -0
  69. package/dist/metadata/resolve.d.ts +20 -0
  70. package/dist/metadata/resolve.d.ts.map +1 -0
  71. package/dist/static-build.d.ts +61 -0
  72. package/dist/static-build.d.ts.map +1 -0
  73. package/dist/ui-schema/generator.d.ts +18 -2
  74. package/dist/ui-schema/generator.d.ts.map +1 -1
  75. package/dist/ui-schema/ir-generator.d.ts +54 -0
  76. package/dist/ui-schema/ir-generator.d.ts.map +1 -0
  77. package/dist/ui-schema/schema.d.ts +429 -0
  78. package/dist/ui-schema/schema.d.ts.map +1 -0
  79. package/dist/ui-schema/types.d.ts +179 -35
  80. package/dist/ui-schema/types.d.ts.map +1 -1
  81. package/dist/validate/constraint-validator.d.ts +85 -0
  82. package/dist/validate/constraint-validator.d.ts.map +1 -0
  83. package/dist/validate/index.d.ts +9 -0
  84. package/dist/validate/index.d.ts.map +1 -0
  85. package/package.json +31 -11
  86. package/dist/__tests__/cli.test.d.ts +0 -2
  87. package/dist/__tests__/cli.test.d.ts.map +0 -1
  88. package/dist/__tests__/cli.test.js +0 -178
  89. package/dist/__tests__/cli.test.js.map +0 -1
  90. package/dist/__tests__/edge-cases.test.d.ts +0 -7
  91. package/dist/__tests__/edge-cases.test.d.ts.map +0 -1
  92. package/dist/__tests__/edge-cases.test.js +0 -217
  93. package/dist/__tests__/edge-cases.test.js.map +0 -1
  94. package/dist/__tests__/generator.test.d.ts +0 -2
  95. package/dist/__tests__/generator.test.d.ts.map +0 -1
  96. package/dist/__tests__/generator.test.js +0 -225
  97. package/dist/__tests__/generator.test.js.map +0 -1
  98. package/dist/__tests__/integration.test.d.ts +0 -8
  99. package/dist/__tests__/integration.test.d.ts.map +0 -1
  100. package/dist/__tests__/integration.test.js +0 -163
  101. package/dist/__tests__/integration.test.js.map +0 -1
  102. package/dist/__tests__/write-schemas.test.d.ts +0 -2
  103. package/dist/__tests__/write-schemas.test.d.ts.map +0 -1
  104. package/dist/__tests__/write-schemas.test.js +0 -196
  105. package/dist/__tests__/write-schemas.test.js.map +0 -1
  106. package/dist/json-schema/generator.js +0 -161
  107. package/dist/json-schema/generator.js.map +0 -1
  108. package/dist/json-schema/types.js +0 -7
  109. package/dist/json-schema/types.js.map +0 -1
  110. package/dist/ui-schema/generator.js +0 -150
  111. package/dist/ui-schema/generator.js.map +0 -1
  112. package/dist/ui-schema/types.js +0 -8
  113. package/dist/ui-schema/types.js.map +0 -1
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Extension registry for `@formspec/build`.
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+ export { createExtensionRegistry } from "./registry.js";
7
+ export type { ExtensionRegistry } from "./registry.js";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/extensions/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,YAAY,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Extension registry for resolving custom types, constraints, and annotations
3
+ * during JSON Schema generation and IR validation.
4
+ *
5
+ * The registry is created from a list of {@link ExtensionDefinition} objects
6
+ * and provides O(1) lookup by fully-qualified ID (extensionId + "/" + name).
7
+ *
8
+ * @packageDocumentation
9
+ */
10
+ import type { ExtensionDefinition, CustomTypeRegistration, CustomConstraintRegistration, CustomAnnotationRegistration, ConstraintTagRegistration, BuiltinConstraintBroadeningRegistration } from "@formspec/core";
11
+ /**
12
+ * A registry of extensions that provides lookup by fully-qualified ID.
13
+ *
14
+ * Type IDs follow the format: `<extensionId>/<typeName>`
15
+ * Constraint IDs follow the format: `<extensionId>/<constraintName>`
16
+ * Annotation IDs follow the format: `<extensionId>/<annotationName>`
17
+ *
18
+ * @public
19
+ */
20
+ export interface ExtensionRegistry {
21
+ /** The extensions registered in this registry (in registration order). */
22
+ readonly extensions: readonly ExtensionDefinition[];
23
+ /**
24
+ * Look up a custom type registration by its fully-qualified type ID.
25
+ *
26
+ * @param typeId - The fully-qualified type ID (e.g., "x-stripe/monetary/Decimal").
27
+ * @returns The registration if found, otherwise `undefined`.
28
+ */
29
+ findType(typeId: string): CustomTypeRegistration | undefined;
30
+ /**
31
+ * Look up a custom type registration by a TypeScript-facing type name.
32
+ *
33
+ * This is used during TSDoc/class analysis to resolve extension-defined
34
+ * custom types from source-level declarations.
35
+ */
36
+ findTypeByName(typeName: string): {
37
+ readonly extensionId: string;
38
+ readonly registration: CustomTypeRegistration;
39
+ } | undefined;
40
+ /**
41
+ * Look up a custom constraint registration by its fully-qualified constraint ID.
42
+ *
43
+ * @param constraintId - The fully-qualified constraint ID.
44
+ * @returns The registration if found, otherwise `undefined`.
45
+ */
46
+ findConstraint(constraintId: string): CustomConstraintRegistration | undefined;
47
+ /**
48
+ * Look up a TSDoc custom constraint-tag registration by tag name.
49
+ */
50
+ findConstraintTag(tagName: string): {
51
+ readonly extensionId: string;
52
+ readonly registration: ConstraintTagRegistration;
53
+ } | undefined;
54
+ /**
55
+ * Look up built-in tag broadening for a given custom type ID.
56
+ */
57
+ findBuiltinConstraintBroadening(typeId: string, tagName: string): {
58
+ readonly extensionId: string;
59
+ readonly registration: BuiltinConstraintBroadeningRegistration;
60
+ } | undefined;
61
+ /**
62
+ * Look up a custom annotation registration by its fully-qualified annotation ID.
63
+ *
64
+ * @param annotationId - The fully-qualified annotation ID.
65
+ * @returns The registration if found, otherwise `undefined`.
66
+ */
67
+ findAnnotation(annotationId: string): CustomAnnotationRegistration | undefined;
68
+ }
69
+ /**
70
+ * Creates an extension registry from a list of extension definitions.
71
+ *
72
+ * The registry indexes all types, constraints, and annotations by their
73
+ * fully-qualified IDs (`<extensionId>/<name>`) for O(1) lookup during
74
+ * generation and validation.
75
+ *
76
+ * @param extensions - The extension definitions to register.
77
+ * @returns An {@link ExtensionRegistry} instance.
78
+ * @throws If duplicate type/constraint/annotation IDs are detected across extensions.
79
+ *
80
+ * @public
81
+ */
82
+ export declare function createExtensionRegistry(extensions: readonly ExtensionDefinition[]): ExtensionRegistry;
83
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/extensions/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EACV,mBAAmB,EACnB,sBAAsB,EACtB,4BAA4B,EAC5B,4BAA4B,EAC5B,yBAAyB,EACzB,uCAAuC,EACxC,MAAM,gBAAgB,CAAC;AAexB;;;;;;;;GAQG;AACH,MAAM,WAAW,iBAAiB;IAChC,0EAA0E;IAC1E,QAAQ,CAAC,UAAU,EAAE,SAAS,mBAAmB,EAAE,CAAC;IAEpD;;;;;OAKG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,sBAAsB,GAAG,SAAS,CAAC;IAC7D;;;;;OAKG;IACH,cAAc,CACZ,QAAQ,EAAE,MAAM,GACf;QAAE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,YAAY,EAAE,sBAAsB,CAAA;KAAE,GAAG,SAAS,CAAC;IAE/F;;;;;OAKG;IACH,cAAc,CAAC,YAAY,EAAE,MAAM,GAAG,4BAA4B,GAAG,SAAS,CAAC;IAC/E;;OAEG;IACH,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAC7B;QACE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;QAC7B,QAAQ,CAAC,YAAY,EAAE,yBAAyB,CAAC;KAClD,GACD,SAAS,CAAC;IACd;;OAEG;IACH,+BAA+B,CAC7B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GAEb;QACE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;QAC7B,QAAQ,CAAC,YAAY,EAAE,uCAAuC,CAAC;KAChE,GACD,SAAS,CAAC;IAEd;;;;;OAKG;IACH,cAAc,CAAC,YAAY,EAAE,MAAM,GAAG,4BAA4B,GAAG,SAAS,CAAC;CAChF;AAuBD;;;;;;;;;;;;GAYG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,SAAS,mBAAmB,EAAE,GACzC,iBAAiB,CAkJnB"}
@@ -0,0 +1,342 @@
1
+ /**
2
+ * Class schema generator.
3
+ *
4
+ * Generates JSON Schema 2020-12 and JSON Forms UI Schema from statically
5
+ * analyzed class/interface/type alias declarations, routing through the
6
+ * canonical FormIR pipeline.
7
+ */
8
+ import * as ts from "typescript";
9
+ import type { UISchema } from "../ui-schema/types.js";
10
+ import type { MetadataPolicyInput } from "@formspec/core";
11
+ import { type DiscriminatorResolutionOptions, type IRClassAnalysis } from "../analyzer/class-analyzer.js";
12
+ import { type TSDocSource } from "../canonicalize/index.js";
13
+ import { type GenerateJsonSchemaFromIROptions, type JsonSchema2020 } from "../json-schema/ir-generator.js";
14
+ import type { ExtensionRegistry } from "../extensions/index.js";
15
+ import { type ValidationDiagnostic } from "../validate/index.js";
16
+ export type { DiscriminatorResolutionOptions } from "../analyzer/class-analyzer.js";
17
+ /**
18
+ * Generated schemas for a class.
19
+ *
20
+ * @beta
21
+ */
22
+ export interface ClassSchemas {
23
+ /** JSON Schema 2020-12 for validation */
24
+ jsonSchema: JsonSchema2020;
25
+ /** JSON Forms UI Schema for rendering */
26
+ uiSchema: UISchema;
27
+ }
28
+ /**
29
+ * Non-throwing schema generation result with structured diagnostics.
30
+ *
31
+ * @public
32
+ */
33
+ export interface DetailedClassSchemasResult {
34
+ /** Whether schema generation completed without error-severity diagnostics. */
35
+ readonly ok: boolean;
36
+ /** Collected analysis and validation diagnostics for this target. */
37
+ readonly diagnostics: readonly ValidationDiagnostic[];
38
+ /** JSON Schema 2020-12 for validation, when generation succeeds. */
39
+ readonly jsonSchema?: JsonSchema2020 | undefined;
40
+ /** JSON Forms UI Schema for rendering, when generation succeeds. */
41
+ readonly uiSchema?: UISchema | undefined;
42
+ }
43
+ /**
44
+ * A batch target for non-throwing schema generation.
45
+ *
46
+ * @public
47
+ */
48
+ export interface SchemaGenerationTarget {
49
+ /** Path to the TypeScript source file. */
50
+ readonly filePath: string;
51
+ /** Name of the exported class, interface, or type alias to analyze. */
52
+ readonly typeName: string;
53
+ }
54
+ /**
55
+ * Batch options for non-throwing schema generation.
56
+ *
57
+ * @public
58
+ */
59
+ export interface GenerateSchemasBatchOptions extends StaticSchemaGenerationOptions {
60
+ /** Targets to analyze and generate. */
61
+ readonly targets: readonly SchemaGenerationTarget[];
62
+ }
63
+ /**
64
+ * Batch options for non-throwing schema generation using an existing program.
65
+ *
66
+ * @public
67
+ */
68
+ export interface GenerateSchemasBatchFromProgramOptions extends StaticSchemaGenerationOptions {
69
+ /** Existing TypeScript program supplied by the caller. */
70
+ readonly program: ts.Program;
71
+ /** Targets to analyze and generate. */
72
+ readonly targets: readonly SchemaGenerationTarget[];
73
+ }
74
+ /**
75
+ * Result for a single target in a batch generation request.
76
+ *
77
+ * @public
78
+ */
79
+ export interface DetailedSchemaGenerationTargetResult extends DetailedClassSchemasResult {
80
+ /** Path to the TypeScript source file. */
81
+ readonly filePath: string;
82
+ /** Name of the exported class, interface, or type alias that was analyzed. */
83
+ readonly typeName: string;
84
+ }
85
+ /**
86
+ * Generates JSON Schema 2020-12 and UI Schema from an IR class analysis.
87
+ *
88
+ * Routes through the canonical IR pipeline:
89
+ * IRClassAnalysis → canonicalizeTSDoc → FormIR → JSON Schema / UI Schema
90
+ *
91
+ * @param analysis - The IR analysis result (from analyzeClassToIR, analyzeInterfaceToIR, or analyzeTypeAliasToIR)
92
+ * @param source - Optional source file metadata for provenance
93
+ * @returns Generated JSON Schema and UI Schema
94
+ */
95
+ export declare function generateClassSchemas(analysis: IRClassAnalysis, source?: TSDocSource, options?: GenerateJsonSchemaFromIROptions & {
96
+ metadata?: MetadataPolicyInput | undefined;
97
+ }): ClassSchemas;
98
+ /**
99
+ * Generates JSON Schema 2020-12 and UI Schema from an IR class analysis
100
+ * without throwing on validation diagnostics.
101
+ *
102
+ * @public
103
+ */
104
+ export declare function generateClassSchemasDetailed(analysis: IRClassAnalysis, source?: TSDocSource, options?: GenerateJsonSchemaFromIROptions & {
105
+ metadata?: MetadataPolicyInput | undefined;
106
+ }): DetailedClassSchemasResult;
107
+ /**
108
+ * Shared options for schema generation flows that support custom extensions.
109
+ *
110
+ * @public
111
+ */
112
+ export interface StaticSchemaGenerationOptions {
113
+ /**
114
+ * Registry used to resolve custom types, constraints, and annotations.
115
+ */
116
+ readonly extensionRegistry?: ExtensionRegistry | undefined;
117
+ /**
118
+ * Vendor prefix for emitted extension keywords.
119
+ * @defaultValue "x-formspec"
120
+ */
121
+ readonly vendorPrefix?: string | undefined;
122
+ /** Metadata resolution policy for static schema generation. */
123
+ readonly metadata?: MetadataPolicyInput | undefined;
124
+ /** Discriminator-specific schema generation behavior. */
125
+ readonly discriminator?: DiscriminatorResolutionOptions | undefined;
126
+ }
127
+ /**
128
+ * Options for generating schemas from a decorated class.
129
+ *
130
+ * @public
131
+ */
132
+ export interface GenerateFromClassOptions extends StaticSchemaGenerationOptions {
133
+ /** Path to the TypeScript source file */
134
+ filePath: string;
135
+ /** Class name to analyze */
136
+ className: string;
137
+ }
138
+ /**
139
+ * Result of generating schemas from a decorated class.
140
+ *
141
+ * @public
142
+ */
143
+ export interface GenerateFromClassResult {
144
+ /** JSON Schema 2020-12 for validation */
145
+ jsonSchema: JsonSchema2020;
146
+ /** JSON Forms UI Schema for rendering */
147
+ uiSchema: UISchema;
148
+ }
149
+ /**
150
+ * Options for generating schemas from a named type inside an existing TypeScript program.
151
+ *
152
+ * @public
153
+ */
154
+ export interface GenerateSchemasFromProgramOptions extends StaticSchemaGenerationOptions {
155
+ /** Existing TypeScript program supplied by the caller. */
156
+ readonly program: ts.Program;
157
+ /** Path to the TypeScript source file */
158
+ readonly filePath: string;
159
+ /** Name of the exported class, interface, or type alias to analyze */
160
+ readonly typeName: string;
161
+ /**
162
+ * Controls whether error-severity diagnostics throw or are returned in the result.
163
+ */
164
+ readonly errorReporting: "throw" | "diagnostics";
165
+ }
166
+ /**
167
+ * Generates JSON Schema and UI Schema from a decorated TypeScript class.
168
+ *
169
+ * This is a high-level entry point that handles the entire pipeline:
170
+ * creating a TypeScript program, finding the class, analyzing it to IR,
171
+ * and generating schemas — all in one call.
172
+ *
173
+ * @example
174
+ * ```typescript
175
+ * const result = generateSchemasFromClass({
176
+ * filePath: "./src/forms.ts",
177
+ * className: "UserForm",
178
+ * });
179
+ * console.log(result.jsonSchema);
180
+ * ```
181
+ *
182
+ * @param options - File path, class name, and optional compiler options
183
+ * @returns Generated JSON Schema and UI Schema
184
+ *
185
+ * @public
186
+ */
187
+ export declare function generateSchemasFromClass(options: GenerateFromClassOptions): GenerateFromClassResult;
188
+ /**
189
+ * Options for generating schemas from a named type (class, interface, or type alias).
190
+ *
191
+ * @public
192
+ */
193
+ export interface GenerateSchemasOptions extends StaticSchemaGenerationOptions {
194
+ /** Path to the TypeScript source file */
195
+ readonly filePath: string;
196
+ /** Name of the exported class, interface, or type alias to analyze */
197
+ readonly typeName: string;
198
+ /**
199
+ * Controls whether error-severity diagnostics throw or are returned in the result.
200
+ */
201
+ readonly errorReporting: "throw" | "diagnostics";
202
+ }
203
+ /**
204
+ * Generates JSON Schema and UI Schema from a named TypeScript
205
+ * type — a decorated class, an interface with TSDoc tags, or a type alias.
206
+ *
207
+ * This is the recommended entry point. It automatically detects whether
208
+ * the name resolves to a class, interface, or type alias and uses the
209
+ * appropriate IR analysis pipeline.
210
+ *
211
+ * @example
212
+ * ```typescript
213
+ * const result = generateSchemas({
214
+ * filePath: "./src/config.ts",
215
+ * typeName: "DiscountConfig",
216
+ * errorReporting: "throw",
217
+ * });
218
+ * ```
219
+ */
220
+ /**
221
+ * Generates JSON Schema and UI Schema from a named type and throws when
222
+ * generation reports error-severity diagnostics.
223
+ *
224
+ * @param options - File path, type name, and explicit throw-on-error reporting
225
+ * @returns Generated JSON Schema and UI Schema
226
+ *
227
+ * @public
228
+ */
229
+ export declare function generateSchemas(options: GenerateSchemasOptions & {
230
+ readonly errorReporting: "throw";
231
+ }): GenerateFromClassResult;
232
+ /**
233
+ * Generates JSON Schema and UI Schema from a named type and returns structured
234
+ * diagnostics instead of throwing on validation or analysis failures.
235
+ *
236
+ * @param options - File path, type name, and explicit diagnostics reporting
237
+ * @returns Structured generation result with diagnostics
238
+ *
239
+ * @public
240
+ */
241
+ export declare function generateSchemas(options: GenerateSchemasOptions & {
242
+ readonly errorReporting: "diagnostics";
243
+ }): DetailedClassSchemasResult;
244
+ /**
245
+ * Generates JSON Schema and UI Schema from a named type.
246
+ *
247
+ * @deprecated Pass `errorReporting` explicitly. Omitting it defaults to `"throw"` only for backward compatibility.
248
+ * @param options - File path and type name
249
+ * @returns Generated JSON Schema and UI Schema
250
+ *
251
+ * @public
252
+ */
253
+ export declare function generateSchemas(options: StaticSchemaGenerationOptions & {
254
+ readonly filePath: string;
255
+ readonly typeName: string;
256
+ }): GenerateFromClassResult;
257
+ /**
258
+ * Generates JSON Schema and UI Schema from a named type within an existing
259
+ * TypeScript program supplied by the caller.
260
+ *
261
+ * This low-level entry point lets downstream tooling reuse a host-owned
262
+ * `Program` for both FormSpec extraction and other TypeScript analysis.
263
+ */
264
+ /**
265
+ * Generates JSON Schema and UI Schema from a named type within an existing
266
+ * TypeScript program and throws when generation reports error-severity diagnostics.
267
+ *
268
+ * @param options - Host program, file path, type name, and explicit throw-on-error reporting
269
+ * @returns Generated JSON Schema and UI Schema
270
+ *
271
+ * @public
272
+ */
273
+ export declare function generateSchemasFromProgram(options: GenerateSchemasFromProgramOptions & {
274
+ readonly errorReporting: "throw";
275
+ }): GenerateFromClassResult;
276
+ /**
277
+ * Generates JSON Schema and UI Schema from a named type within an existing
278
+ * TypeScript program and returns structured diagnostics instead of throwing on
279
+ * validation or analysis failures.
280
+ *
281
+ * @param options - Host program, file path, type name, and explicit diagnostics reporting
282
+ * @returns Structured generation result with diagnostics
283
+ *
284
+ * @public
285
+ */
286
+ export declare function generateSchemasFromProgram(options: GenerateSchemasFromProgramOptions & {
287
+ readonly errorReporting: "diagnostics";
288
+ }): DetailedClassSchemasResult;
289
+ /**
290
+ * Generates JSON Schema and UI Schema from a named type within an existing
291
+ * TypeScript program.
292
+ *
293
+ * @deprecated Pass `errorReporting` explicitly. Omitting it defaults to `"throw"` only for backward compatibility.
294
+ * @param options - Host program, file path, and type name
295
+ * @returns Generated JSON Schema and UI Schema
296
+ *
297
+ * @public
298
+ */
299
+ export declare function generateSchemasFromProgram(options: StaticSchemaGenerationOptions & {
300
+ readonly program: ts.Program;
301
+ readonly filePath: string;
302
+ readonly typeName: string;
303
+ }): GenerateFromClassResult;
304
+ /**
305
+ * Generates JSON Schema and UI Schema from a named type and returns structured
306
+ * diagnostics instead of throwing on validation or analysis failures.
307
+ * @deprecated Use `generateSchemas({ ...options, errorReporting: "diagnostics" })` instead.
308
+ *
309
+ * @public
310
+ */
311
+ export declare function generateSchemasDetailed(options: StaticSchemaGenerationOptions & {
312
+ readonly filePath: string;
313
+ readonly typeName: string;
314
+ }): DetailedClassSchemasResult;
315
+ /**
316
+ * Generates JSON Schema and UI Schema from a named type within an existing
317
+ * TypeScript program and returns structured diagnostics instead of throwing on
318
+ * validation or analysis failures.
319
+ * @deprecated Use `generateSchemasFromProgram({ ...options, errorReporting: "diagnostics" })` instead.
320
+ *
321
+ * @public
322
+ */
323
+ export declare function generateSchemasFromProgramDetailed(options: StaticSchemaGenerationOptions & {
324
+ readonly program: ts.Program;
325
+ readonly filePath: string;
326
+ readonly typeName: string;
327
+ }): DetailedClassSchemasResult;
328
+ /**
329
+ * Generates schemas for many targets and returns per-target diagnostics instead
330
+ * of failing on the first problem.
331
+ *
332
+ * @public
333
+ */
334
+ export declare function generateSchemasBatch(options: GenerateSchemasBatchOptions): readonly DetailedSchemaGenerationTargetResult[];
335
+ /**
336
+ * Generates schemas for many targets from an existing TypeScript program and
337
+ * returns per-target diagnostics instead of failing on the first problem.
338
+ *
339
+ * @public
340
+ */
341
+ export declare function generateSchemasBatchFromProgram(options: GenerateSchemasBatchFromProgramOptions): readonly DetailedSchemaGenerationTargetResult[];
342
+ //# sourceMappingURL=class-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class-schema.d.ts","sourceRoot":"","sources":["../../src/generators/class-schema.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAC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AK5B;AAkBD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,2BAA2B,GACnC,SAAS,oCAAoC,EAAE,CA4BjD;AAED;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,sCAAsC,GAC9C,SAAS,oCAAoC,EAAE,CAiBjD"}
@@ -0,0 +1,152 @@
1
+ import * as ts from "typescript";
2
+ import type { ResolvedMetadata } from "@formspec/core";
3
+ import type { UISchema } from "../ui-schema/types.js";
4
+ import type { StaticBuildContext } from "../static-build.js";
5
+ import { type StaticSchemaGenerationOptions } from "./class-schema.js";
6
+ import { type JsonSchema2020 } from "../json-schema/ir-generator.js";
7
+ /**
8
+ * Generated schemas for a discovered declaration or signature type.
9
+ *
10
+ * `uiSchema` is `null` when the discovered type does not have an object-shaped
11
+ * root that can be represented as a JSON Forms layout.
12
+ *
13
+ * @public
14
+ */
15
+ export interface DiscoveredTypeSchemas {
16
+ /** JSON Schema 2020-12 for the resolved type. */
17
+ readonly jsonSchema: JsonSchema2020;
18
+ /** UI Schema for object-shaped roots, or `null` when not applicable. */
19
+ readonly uiSchema: UISchema | null;
20
+ /**
21
+ * Resolved type-level metadata used during generation, when available.
22
+ *
23
+ * This preserves explicit and inferred naming metadata such as singular and
24
+ * plural API/display names for consumers that need the resolved values in
25
+ * addition to the emitted schema artifacts.
26
+ */
27
+ readonly resolvedMetadata?: ResolvedMetadata | undefined;
28
+ }
29
+ /**
30
+ * Supported declaration kinds for declaration-driven schema generation.
31
+ *
32
+ * @public
33
+ */
34
+ export type SchemaSourceDeclaration = ts.ClassDeclaration | ts.InterfaceDeclaration | ts.TypeAliasDeclaration;
35
+ /**
36
+ * Supported declaration kinds for standalone metadata resolution.
37
+ *
38
+ * This helper is intentionally limited to named type declarations,
39
+ * methods/functions, and object-like properties. It does not currently expose
40
+ * parameter or variable metadata resolution on the public build surface.
41
+ *
42
+ * @public
43
+ */
44
+ export type MetadataSourceDeclaration = SchemaSourceDeclaration | ts.MethodDeclaration | ts.FunctionDeclaration | ts.PropertyDeclaration | ts.PropertySignature;
45
+ /**
46
+ * Options for generating schemas from a resolved declaration.
47
+ *
48
+ * @public
49
+ */
50
+ export interface GenerateSchemasFromDeclarationOptions extends StaticSchemaGenerationOptions {
51
+ /** Supported build context used for checker access and related analysis. */
52
+ readonly context: StaticBuildContext;
53
+ /** Declaration to turn into schemas. */
54
+ readonly declaration: SchemaSourceDeclaration;
55
+ }
56
+ /**
57
+ * Options for generating schemas from a resolved TypeScript type.
58
+ *
59
+ * @public
60
+ */
61
+ export interface GenerateSchemasFromTypeOptions extends StaticSchemaGenerationOptions {
62
+ /** Supported build context used for checker access and related analysis. */
63
+ readonly context: StaticBuildContext;
64
+ /** TypeScript type to turn into schemas. */
65
+ readonly type: ts.Type;
66
+ /**
67
+ * Optional source node associated with the type.
68
+ *
69
+ * When provided, FormSpec uses it as the source location for provenance and
70
+ * inline-type analysis.
71
+ */
72
+ readonly sourceNode?: ts.Node | undefined;
73
+ /** Optional logical name used for anonymous roots. */
74
+ readonly name?: string | undefined;
75
+ }
76
+ /**
77
+ * Options for generating schemas from a method or function parameter type.
78
+ *
79
+ * @public
80
+ */
81
+ export interface GenerateSchemasFromParameterOptions extends StaticSchemaGenerationOptions {
82
+ /** Supported build context used for checker access and related analysis. */
83
+ readonly context: StaticBuildContext;
84
+ /** Parameter declaration whose type should be converted into schemas. */
85
+ readonly parameter: ts.ParameterDeclaration;
86
+ }
87
+ /**
88
+ * Options for generating schemas from a method or function return type.
89
+ *
90
+ * @public
91
+ */
92
+ export interface GenerateSchemasFromReturnTypeOptions extends StaticSchemaGenerationOptions {
93
+ /** Supported build context used for checker access and related analysis. */
94
+ readonly context: StaticBuildContext;
95
+ /** Signature declaration whose return type should be converted into schemas. */
96
+ readonly declaration: ts.SignatureDeclaration;
97
+ }
98
+ /**
99
+ * Options for resolving metadata from a declaration against the active
100
+ * metadata policy.
101
+ *
102
+ * @public
103
+ */
104
+ export interface ResolveDeclarationMetadataOptions extends StaticSchemaGenerationOptions {
105
+ /** Supported build context used for checker access and related analysis. */
106
+ readonly context: StaticBuildContext;
107
+ /** Declaration whose metadata should be resolved. */
108
+ readonly declaration: MetadataSourceDeclaration;
109
+ }
110
+ /**
111
+ * Generates schemas from a resolved declaration using the supported public
112
+ * static-build workflow.
113
+ *
114
+ * Named declarations reuse the same analyzer semantics as FormSpec's existing
115
+ * top-level generation APIs. Non-object type aliases fall back to the generic
116
+ * resolved-type entry point.
117
+ *
118
+ * @public
119
+ */
120
+ export declare function generateSchemasFromDeclaration(options: GenerateSchemasFromDeclarationOptions): DiscoveredTypeSchemas;
121
+ /**
122
+ * Generates schemas from a resolved TypeScript type.
123
+ *
124
+ * This is the advanced public entry point for build tooling that already uses
125
+ * the TypeScript compiler API to discover types before handing them to
126
+ * FormSpec.
127
+ *
128
+ * @public
129
+ */
130
+ export declare function generateSchemasFromType(options: GenerateSchemasFromTypeOptions): DiscoveredTypeSchemas;
131
+ /**
132
+ * Generates schemas for a method or function parameter type.
133
+ *
134
+ * @public
135
+ */
136
+ export declare function generateSchemasFromParameter(options: GenerateSchemasFromParameterOptions): DiscoveredTypeSchemas;
137
+ /**
138
+ * Generates schemas for a method or function return type.
139
+ *
140
+ * Awaited `Promise<T>`-style return types are unwrapped before generation.
141
+ *
142
+ * @public
143
+ */
144
+ export declare function generateSchemasFromReturnType(options: GenerateSchemasFromReturnTypeOptions): DiscoveredTypeSchemas;
145
+ /**
146
+ * Resolves metadata from a declaration using FormSpec's configured metadata
147
+ * policy for the matching declaration kind.
148
+ *
149
+ * @public
150
+ */
151
+ export declare function resolveDeclarationMetadata(options: ResolveDeclarationMetadataOptions): ResolvedMetadata | undefined;
152
+ //# sourceMappingURL=discovered-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"discovered-schema.d.ts","sourceRoot":"","sources":["../../src/generators/discovered-schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAQ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
+ /**
2
+ * Method schema generator.
3
+ *
4
+ * Generates schemas for method parameters and return types, routing through
5
+ * the canonical IR pipeline (TypeScript type → TypeNode → JSON Schema 2020-12).
6
+ */
7
+ import type * as ts from "typescript";
8
+ import type { MethodInfo } from "../analyzer/class-analyzer.js";
9
+ import { type JsonSchema2020 } from "../json-schema/ir-generator.js";
10
+ /**
11
+ * Runtime-loaded FormSpec schemas, compatible with the CLI's FormSpecSchemas type.
12
+ */
13
+ export interface LoadedFormSpecSchemas {
14
+ /** The FormSpec export name */
15
+ name: string;
16
+ /** Generated JSON Schema */
17
+ jsonSchema: unknown;
18
+ /** Generated UI Schema (FormSpec/JSON Forms) */
19
+ uiSchema: unknown;
20
+ }
21
+ /**
22
+ * Generated schemas for a method.
23
+ */
24
+ export interface MethodSchemas {
25
+ /** Method name */
26
+ name: string;
27
+ /** Parameter schemas (from FormSpec or static analysis) */
28
+ params: MethodParamsSchemas | null;
29
+ /** Return type schema */
30
+ returnType: JsonSchema2020;
31
+ }
32
+ /**
33
+ * Parameter schemas for a method.
34
+ */
35
+ export interface MethodParamsSchemas {
36
+ /** JSON Schema for parameters */
37
+ jsonSchema: JsonSchema2020;
38
+ /** UI Schema / FormSpec for parameters (if available) */
39
+ uiSchema: object | null;
40
+ /** Name of the FormSpec export used (if any) */
41
+ formSpecExport: string | null;
42
+ }
43
+ /**
44
+ * Generates schemas for a method's parameters and return type.
45
+ *
46
+ * If a parameter references a FormSpec via `InferSchema<typeof X>`,
47
+ * the schemas are taken from the loaded FormSpec at runtime.
48
+ * Otherwise, schemas are generated from static type analysis via the IR.
49
+ *
50
+ * @param method - The method information from static analysis
51
+ * @param checker - TypeScript type checker
52
+ * @param loadedFormSpecs - Map of FormSpec export names to their schemas
53
+ * @returns Generated method schemas
54
+ */
55
+ export declare function generateMethodSchemas(method: MethodInfo, checker: ts.TypeChecker, loadedFormSpecs: Map<string, LoadedFormSpecSchemas>): MethodSchemas;
56
+ /**
57
+ * Collects all FormSpec export names referenced by methods.
58
+ *
59
+ * Use this to determine which exports to load at runtime.
60
+ *
61
+ * @param methods - Array of method infos
62
+ * @returns Set of FormSpec export names
63
+ */
64
+ export declare function collectFormSpecReferences(methods: MethodInfo[]): Set<string>;
65
+ //# sourceMappingURL=method-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"method-schema.d.ts","sourceRoot":"","sources":["../../src/generators/method-schema.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,KAAK,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,KAAK,EAAE,UAAU,EAAiB,MAAM,+BAA+B,CAAC;AAG/E,OAAO,EAA4B,KAAK,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAG/F;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,4BAA4B;IAC5B,UAAU,EAAE,OAAO,CAAC;IACpB,gDAAgD;IAChD,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,kBAAkB;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,2DAA2D;IAC3D,MAAM,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACnC,yBAAyB;IACzB,UAAU,EAAE,cAAc,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,iCAAiC;IACjC,UAAU,EAAE,cAAc,CAAC;IAC3B,yDAAyD;IACzD,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,gDAAgD;IAChD,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAgED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,EAAE,CAAC,WAAW,EACvB,eAAe,EAAE,GAAG,CAAC,MAAM,EAAE,qBAAqB,CAAC,GAClD,aAAa,CAYf;AAmED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,UAAU,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAY5E"}