@formspec/build 0.1.0-alpha.11 → 0.1.0-alpha.13
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 +51 -15
- package/dist/__tests__/chain-dsl-canonicalizer.test.d.ts +2 -0
- package/dist/__tests__/chain-dsl-canonicalizer.test.d.ts.map +1 -0
- package/dist/__tests__/constraint-validator.test.d.ts +2 -0
- package/dist/__tests__/constraint-validator.test.d.ts.map +1 -0
- package/dist/__tests__/extension-api.test.d.ts +2 -0
- package/dist/__tests__/extension-api.test.d.ts.map +1 -0
- package/dist/__tests__/fixtures/example-a-builtins.d.ts +18 -0
- package/dist/__tests__/fixtures/example-a-builtins.d.ts.map +1 -1
- package/dist/__tests__/guards.test.d.ts +2 -0
- package/dist/__tests__/guards.test.d.ts.map +1 -0
- package/dist/__tests__/ir-analyzer.test.d.ts +11 -0
- package/dist/__tests__/ir-analyzer.test.d.ts.map +1 -0
- package/dist/__tests__/ir-jsdoc-constraints.test.d.ts +12 -0
- package/dist/__tests__/ir-jsdoc-constraints.test.d.ts.map +1 -0
- package/dist/__tests__/ir-json-schema-generator.test.d.ts +11 -0
- package/dist/__tests__/ir-json-schema-generator.test.d.ts.map +1 -0
- package/dist/__tests__/ir-ui-schema-generator.test.d.ts +2 -0
- package/dist/__tests__/ir-ui-schema-generator.test.d.ts.map +1 -0
- package/dist/__tests__/jsdoc-constraints.test.d.ts +4 -4
- package/dist/__tests__/parity/fixtures/address/chain-dsl.d.ts +9 -0
- package/dist/__tests__/parity/fixtures/address/chain-dsl.d.ts.map +1 -0
- package/dist/__tests__/parity/fixtures/address/expected-ir.d.ts +9 -0
- package/dist/__tests__/parity/fixtures/address/expected-ir.d.ts.map +1 -0
- package/dist/__tests__/parity/fixtures/address/tsdoc.d.ts +19 -0
- package/dist/__tests__/parity/fixtures/address/tsdoc.d.ts.map +1 -0
- package/dist/__tests__/parity/fixtures/product-config/chain-dsl.d.ts +13 -0
- package/dist/__tests__/parity/fixtures/product-config/chain-dsl.d.ts.map +1 -0
- package/dist/__tests__/parity/fixtures/product-config/expected-ir.d.ts +9 -0
- package/dist/__tests__/parity/fixtures/product-config/expected-ir.d.ts.map +1 -0
- package/dist/__tests__/parity/fixtures/product-config/tsdoc.d.ts +28 -0
- package/dist/__tests__/parity/fixtures/product-config/tsdoc.d.ts.map +1 -0
- package/dist/__tests__/parity/fixtures/user-registration/chain-dsl.d.ts +12 -0
- package/dist/__tests__/parity/fixtures/user-registration/chain-dsl.d.ts.map +1 -0
- package/dist/__tests__/parity/fixtures/user-registration/expected-ir.d.ts +9 -0
- package/dist/__tests__/parity/fixtures/user-registration/expected-ir.d.ts.map +1 -0
- package/dist/__tests__/parity/fixtures/user-registration/tsdoc.d.ts +19 -0
- package/dist/__tests__/parity/fixtures/user-registration/tsdoc.d.ts.map +1 -0
- package/dist/__tests__/parity/parity.test.d.ts +14 -0
- package/dist/__tests__/parity/parity.test.d.ts.map +1 -0
- package/dist/__tests__/parity/utils.d.ts +139 -0
- package/dist/__tests__/parity/utils.d.ts.map +1 -0
- package/dist/analyzer/class-analyzer.d.ts +54 -99
- package/dist/analyzer/class-analyzer.d.ts.map +1 -1
- package/dist/analyzer/jsdoc-constraints.d.ts +78 -30
- package/dist/analyzer/jsdoc-constraints.d.ts.map +1 -1
- package/dist/analyzer/tsdoc-parser.d.ts +61 -0
- package/dist/analyzer/tsdoc-parser.d.ts.map +1 -0
- package/dist/browser.cjs +998 -309
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.ts +10 -6
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +996 -308
- package/dist/browser.js.map +1 -1
- package/dist/build.d.ts +65 -150
- package/dist/canonicalize/chain-dsl-canonicalizer.d.ts +18 -0
- package/dist/canonicalize/chain-dsl-canonicalizer.d.ts.map +1 -0
- package/dist/canonicalize/index.d.ts +8 -0
- package/dist/canonicalize/index.d.ts.map +1 -0
- package/dist/canonicalize/tsdoc-canonicalizer.d.ts +34 -0
- package/dist/canonicalize/tsdoc-canonicalizer.d.ts.map +1 -0
- package/dist/cli.cjs +1455 -1656
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +1459 -1647
- package/dist/cli.js.map +1 -1
- package/dist/extensions/index.d.ts +8 -0
- package/dist/extensions/index.d.ts.map +1 -0
- package/dist/extensions/registry.d.ts +55 -0
- package/dist/extensions/registry.d.ts.map +1 -0
- package/dist/generators/class-schema.d.ts +23 -38
- package/dist/generators/class-schema.d.ts.map +1 -1
- package/dist/generators/method-schema.d.ts +6 -8
- package/dist/generators/method-schema.d.ts.map +1 -1
- package/dist/index.cjs +1391 -1614
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1403 -1610
- package/dist/index.js.map +1 -1
- package/dist/internals.cjs +1642 -824
- package/dist/internals.cjs.map +1 -1
- package/dist/internals.d.ts +12 -3
- package/dist/internals.d.ts.map +1 -1
- package/dist/internals.js +1645 -820
- package/dist/internals.js.map +1 -1
- package/dist/json-schema/generator.d.ts +10 -5
- package/dist/json-schema/generator.d.ts.map +1 -1
- package/dist/json-schema/ir-generator.d.ts +84 -0
- package/dist/json-schema/ir-generator.d.ts.map +1 -0
- package/dist/json-schema/schema.d.ts +3 -3
- package/dist/json-schema/types.d.ts +5 -6
- package/dist/json-schema/types.d.ts.map +1 -1
- package/dist/ui-schema/generator.d.ts +5 -15
- package/dist/ui-schema/generator.d.ts.map +1 -1
- package/dist/ui-schema/ir-generator.d.ts +53 -0
- package/dist/ui-schema/ir-generator.d.ts.map +1 -0
- package/dist/validate/constraint-validator.d.ts +66 -0
- package/dist/validate/constraint-validator.d.ts.map +1 -0
- package/dist/validate/index.d.ts +9 -0
- package/dist/validate/index.d.ts.map +1 -0
- package/package.json +5 -4
- package/dist/__tests__/analyzer-edge-cases.test.d.ts +0 -13
- package/dist/__tests__/analyzer-edge-cases.test.d.ts.map +0 -1
- package/dist/__tests__/analyzer.test.d.ts +0 -5
- package/dist/__tests__/analyzer.test.d.ts.map +0 -1
- package/dist/__tests__/codegen.test.d.ts +0 -5
- package/dist/__tests__/codegen.test.d.ts.map +0 -1
- package/dist/__tests__/decorator-pipeline.test.d.ts +0 -11
- package/dist/__tests__/decorator-pipeline.test.d.ts.map +0 -1
- package/dist/__tests__/fixtures/example-b-decorators.d.ts +0 -5
- package/dist/__tests__/fixtures/example-b-decorators.d.ts.map +0 -1
- package/dist/__tests__/fixtures/example-b-extended.d.ts +0 -5
- package/dist/__tests__/fixtures/example-b-extended.d.ts.map +0 -1
- package/dist/__tests__/fixtures/example-c-custom.d.ts +0 -5
- package/dist/__tests__/fixtures/example-c-custom.d.ts.map +0 -1
- package/dist/__tests__/fixtures/example-c-decorators.d.ts +0 -5
- package/dist/__tests__/fixtures/example-c-decorators.d.ts.map +0 -1
- package/dist/__tests__/fixtures/example-d-mixed-decorators.d.ts +0 -6
- package/dist/__tests__/fixtures/example-d-mixed-decorators.d.ts.map +0 -1
- package/dist/__tests__/fixtures/example-e-decorators.d.ts +0 -11
- package/dist/__tests__/fixtures/example-e-decorators.d.ts.map +0 -1
- package/dist/__tests__/fixtures/example-e-no-namespace.d.ts +0 -5
- package/dist/__tests__/fixtures/example-e-no-namespace.d.ts.map +0 -1
- package/dist/__tests__/fixtures/example-jsdoc-constraints.d.ts +0 -16
- package/dist/__tests__/fixtures/example-jsdoc-constraints.d.ts.map +0 -1
- package/dist/__tests__/fixtures/example-nested-class.d.ts +0 -45
- package/dist/__tests__/fixtures/example-nested-class.d.ts.map +0 -1
- package/dist/__tests__/interface-types.test.d.ts +0 -11
- package/dist/__tests__/interface-types.test.d.ts.map +0 -1
- package/dist/analyzer/decorator-extractor.d.ts +0 -78
- package/dist/analyzer/decorator-extractor.d.ts.map +0 -1
- package/dist/analyzer/type-converter.d.ts +0 -75
- package/dist/analyzer/type-converter.d.ts.map +0 -1
- package/dist/codegen/index.d.ts +0 -75
- package/dist/codegen/index.d.ts.map +0 -1
|
@@ -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,55 @@
|
|
|
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 } 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
|
+
export interface ExtensionRegistry {
|
|
19
|
+
/** The extensions registered in this registry (in registration order). */
|
|
20
|
+
readonly extensions: readonly ExtensionDefinition[];
|
|
21
|
+
/**
|
|
22
|
+
* Look up a custom type registration by its fully-qualified type ID.
|
|
23
|
+
*
|
|
24
|
+
* @param typeId - The fully-qualified type ID (e.g., "x-stripe/monetary/Decimal").
|
|
25
|
+
* @returns The registration if found, otherwise `undefined`.
|
|
26
|
+
*/
|
|
27
|
+
findType(typeId: string): CustomTypeRegistration | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Look up a custom constraint registration by its fully-qualified constraint ID.
|
|
30
|
+
*
|
|
31
|
+
* @param constraintId - The fully-qualified constraint ID.
|
|
32
|
+
* @returns The registration if found, otherwise `undefined`.
|
|
33
|
+
*/
|
|
34
|
+
findConstraint(constraintId: string): CustomConstraintRegistration | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Look up a custom annotation registration by its fully-qualified annotation ID.
|
|
37
|
+
*
|
|
38
|
+
* @param annotationId - The fully-qualified annotation ID.
|
|
39
|
+
* @returns The registration if found, otherwise `undefined`.
|
|
40
|
+
*/
|
|
41
|
+
findAnnotation(annotationId: string): CustomAnnotationRegistration | undefined;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Creates an extension registry from a list of extension definitions.
|
|
45
|
+
*
|
|
46
|
+
* The registry indexes all types, constraints, and annotations by their
|
|
47
|
+
* fully-qualified IDs (`<extensionId>/<name>`) for O(1) lookup during
|
|
48
|
+
* generation and validation.
|
|
49
|
+
*
|
|
50
|
+
* @param extensions - The extension definitions to register.
|
|
51
|
+
* @returns An {@link ExtensionRegistry} instance.
|
|
52
|
+
* @throws If duplicate type/constraint/annotation IDs are detected across extensions.
|
|
53
|
+
*/
|
|
54
|
+
export declare function createExtensionRegistry(extensions: readonly ExtensionDefinition[]): ExtensionRegistry;
|
|
55
|
+
//# 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,EAC7B,MAAM,gBAAgB,CAAC;AAMxB;;;;;;GAMG;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;IAE7D;;;;;OAKG;IACH,cAAc,CAAC,YAAY,EAAE,MAAM,GAAG,4BAA4B,GAAG,SAAS,CAAC;IAE/E;;;;;OAKG;IACH,cAAc,CAAC,YAAY,EAAE,MAAM,GAAG,4BAA4B,GAAG,SAAS,CAAC;CAChF;AAMD;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,SAAS,mBAAmB,EAAE,GACzC,iBAAiB,CA2CnB"}
|
|
@@ -1,44 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Class schema generator.
|
|
3
3
|
*
|
|
4
|
-
* Generates JSON Schema and
|
|
5
|
-
* class
|
|
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.
|
|
6
7
|
*/
|
|
7
|
-
import type * as ts from "typescript";
|
|
8
|
-
import type { ClassAnalysis, FieldInfo } from "../analyzer/class-analyzer.js";
|
|
9
|
-
import type { ExtendedJSONSchema7 } from "../json-schema/types.js";
|
|
10
8
|
import type { UISchema } from "../ui-schema/types.js";
|
|
9
|
+
import { type IRClassAnalysis } from "../analyzer/class-analyzer.js";
|
|
10
|
+
import { type TSDocSource } from "../canonicalize/index.js";
|
|
11
|
+
import { type JsonSchema2020 } from "../json-schema/ir-generator.js";
|
|
11
12
|
/**
|
|
12
13
|
* Generated schemas for a class.
|
|
13
14
|
*/
|
|
14
15
|
export interface ClassSchemas {
|
|
15
|
-
/** JSON Schema for validation */
|
|
16
|
-
jsonSchema:
|
|
16
|
+
/** JSON Schema 2020-12 for validation */
|
|
17
|
+
jsonSchema: JsonSchema2020;
|
|
17
18
|
/** JSON Forms UI Schema for rendering */
|
|
18
19
|
uiSchema: UISchema;
|
|
19
20
|
}
|
|
20
21
|
/**
|
|
21
|
-
* Generates JSON Schema and
|
|
22
|
+
* Generates JSON Schema 2020-12 and UI Schema from an IR class analysis.
|
|
22
23
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
24
|
+
* Routes through the canonical IR pipeline:
|
|
25
|
+
* IRClassAnalysis → canonicalizeTSDoc → FormIR → JSON Schema / UI Schema
|
|
25
26
|
*
|
|
26
|
-
* @param analysis - The
|
|
27
|
-
* @param
|
|
28
|
-
* @returns Generated JSON Schema and
|
|
27
|
+
* @param analysis - The IR analysis result (from analyzeClassToIR, analyzeInterfaceToIR, or analyzeTypeAliasToIR)
|
|
28
|
+
* @param source - Optional source file metadata for provenance
|
|
29
|
+
* @returns Generated JSON Schema and UI Schema
|
|
29
30
|
*/
|
|
30
|
-
export declare function generateClassSchemas(analysis:
|
|
31
|
-
/**
|
|
32
|
-
* Generates JSON Schema for a single field.
|
|
33
|
-
*
|
|
34
|
-
* Useful for generating schemas for method return types
|
|
35
|
-
* or individual field extraction.
|
|
36
|
-
*
|
|
37
|
-
* @param field - The field information
|
|
38
|
-
* @param checker - TypeScript type checker
|
|
39
|
-
* @returns JSON Schema for the field's type
|
|
40
|
-
*/
|
|
41
|
-
export declare function generateFieldSchema(field: FieldInfo, checker: ts.TypeChecker): ExtendedJSONSchema7;
|
|
31
|
+
export declare function generateClassSchemas(analysis: IRClassAnalysis, source?: TSDocSource): ClassSchemas;
|
|
42
32
|
/**
|
|
43
33
|
* Options for generating schemas from a decorated class.
|
|
44
34
|
*/
|
|
@@ -52,16 +42,16 @@ export interface GenerateFromClassOptions {
|
|
|
52
42
|
* Result of generating schemas from a decorated class.
|
|
53
43
|
*/
|
|
54
44
|
export interface GenerateFromClassResult {
|
|
55
|
-
/** JSON Schema for validation */
|
|
56
|
-
jsonSchema:
|
|
45
|
+
/** JSON Schema 2020-12 for validation */
|
|
46
|
+
jsonSchema: JsonSchema2020;
|
|
57
47
|
/** JSON Forms UI Schema for rendering */
|
|
58
48
|
uiSchema: UISchema;
|
|
59
49
|
}
|
|
60
50
|
/**
|
|
61
|
-
* Generates JSON Schema and
|
|
51
|
+
* Generates JSON Schema and UI Schema from a decorated TypeScript class.
|
|
62
52
|
*
|
|
63
53
|
* This is a high-level entry point that handles the entire pipeline:
|
|
64
|
-
* creating a TypeScript program, finding the class, analyzing it,
|
|
54
|
+
* creating a TypeScript program, finding the class, analyzing it to IR,
|
|
65
55
|
* and generating schemas — all in one call.
|
|
66
56
|
*
|
|
67
57
|
* @example
|
|
@@ -74,7 +64,7 @@ export interface GenerateFromClassResult {
|
|
|
74
64
|
* ```
|
|
75
65
|
*
|
|
76
66
|
* @param options - File path, class name, and optional compiler options
|
|
77
|
-
* @returns Generated JSON Schema and
|
|
67
|
+
* @returns Generated JSON Schema and UI Schema
|
|
78
68
|
*/
|
|
79
69
|
export declare function generateSchemasFromClass(options: GenerateFromClassOptions): GenerateFromClassResult;
|
|
80
70
|
/**
|
|
@@ -87,20 +77,15 @@ export interface GenerateSchemasOptions {
|
|
|
87
77
|
typeName: string;
|
|
88
78
|
}
|
|
89
79
|
/**
|
|
90
|
-
* Generates JSON Schema and
|
|
80
|
+
* Generates JSON Schema and UI Schema from a named TypeScript
|
|
91
81
|
* type — a decorated class, an interface with TSDoc tags, or a type alias.
|
|
92
82
|
*
|
|
93
83
|
* This is the recommended entry point. It automatically detects whether
|
|
94
84
|
* the name resolves to a class, interface, or type alias and uses the
|
|
95
|
-
* appropriate analysis pipeline
|
|
96
|
-
*
|
|
97
|
-
* - **Classes**: extracts decorators and JSDoc constraints
|
|
98
|
-
* - **Interfaces**: extracts TSDoc tags (`@Field_displayName`, `@Minimum`, etc.)
|
|
99
|
-
* - **Type aliases**: object literal bodies analyzed like interfaces
|
|
85
|
+
* appropriate IR analysis pipeline.
|
|
100
86
|
*
|
|
101
87
|
* @example
|
|
102
88
|
* ```typescript
|
|
103
|
-
* // Works with both classes and interfaces — caller doesn't need to know
|
|
104
89
|
* const result = generateSchemas({
|
|
105
90
|
* filePath: "./src/config.ts",
|
|
106
91
|
* typeName: "DiscountConfig",
|
|
@@ -108,7 +93,7 @@ export interface GenerateSchemasOptions {
|
|
|
108
93
|
* ```
|
|
109
94
|
*
|
|
110
95
|
* @param options - File path and type name
|
|
111
|
-
* @returns Generated JSON Schema and
|
|
96
|
+
* @returns Generated JSON Schema and UI Schema
|
|
112
97
|
*/
|
|
113
98
|
export declare function generateSchemas(options: GenerateSchemasOptions): GenerateFromClassResult;
|
|
114
99
|
//# sourceMappingURL=class-schema.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class-schema.d.ts","sourceRoot":"","sources":["../../src/generators/class-schema.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"class-schema.d.ts","sourceRoot":"","sources":["../../src/generators/class-schema.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAOtD,OAAO,EAIL,KAAK,eAAe,EACrB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAqB,KAAK,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC/E,OAAO,EAA4B,KAAK,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAG/F;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,yCAAyC;IACzC,UAAU,EAAE,cAAc,CAAC;IAC3B,yCAAyC;IACzC,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,eAAe,EACzB,MAAM,CAAC,EAAE,WAAW,GACnB,YAAY,CAMd;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,4BAA4B;IAC5B,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,yCAAyC;IACzC,UAAU,EAAE,cAAc,CAAC;IAC3B,yCAAyC;IACzC,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,wBAAwB,GAChC,uBAAuB,CAUzB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,yCAAyC;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,sEAAsE;IACtE,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,uBAAuB,CA+BxF"}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Method schema generator.
|
|
3
3
|
*
|
|
4
|
-
* Generates schemas for method parameters and return types
|
|
5
|
-
*
|
|
6
|
-
* - Parameters with regular types -> static type conversion
|
|
7
|
-
* - Return types -> static type conversion
|
|
4
|
+
* Generates schemas for method parameters and return types, routing through
|
|
5
|
+
* the canonical IR pipeline (TypeScript type → TypeNode → JSON Schema 2020-12).
|
|
8
6
|
*/
|
|
9
7
|
import type * as ts from "typescript";
|
|
10
8
|
import type { MethodInfo } from "../analyzer/class-analyzer.js";
|
|
11
|
-
import type
|
|
9
|
+
import { type JsonSchema2020 } from "../json-schema/ir-generator.js";
|
|
12
10
|
/**
|
|
13
11
|
* Runtime-loaded FormSpec schemas, compatible with the CLI's FormSpecSchemas type.
|
|
14
12
|
*/
|
|
@@ -29,14 +27,14 @@ export interface MethodSchemas {
|
|
|
29
27
|
/** Parameter schemas (from FormSpec or static analysis) */
|
|
30
28
|
params: MethodParamsSchemas | null;
|
|
31
29
|
/** Return type schema */
|
|
32
|
-
returnType:
|
|
30
|
+
returnType: JsonSchema2020;
|
|
33
31
|
}
|
|
34
32
|
/**
|
|
35
33
|
* Parameter schemas for a method.
|
|
36
34
|
*/
|
|
37
35
|
export interface MethodParamsSchemas {
|
|
38
36
|
/** JSON Schema for parameters */
|
|
39
|
-
jsonSchema:
|
|
37
|
+
jsonSchema: JsonSchema2020;
|
|
40
38
|
/** UI Schema / FormSpec for parameters (if available) */
|
|
41
39
|
uiSchema: object | null;
|
|
42
40
|
/** Name of the FormSpec export used (if any) */
|
|
@@ -47,7 +45,7 @@ export interface MethodParamsSchemas {
|
|
|
47
45
|
*
|
|
48
46
|
* If a parameter references a FormSpec via `InferSchema<typeof X>`,
|
|
49
47
|
* the schemas are taken from the loaded FormSpec at runtime.
|
|
50
|
-
* Otherwise, schemas are generated from static type analysis.
|
|
48
|
+
* Otherwise, schemas are generated from static type analysis via the IR.
|
|
51
49
|
*
|
|
52
50
|
* @param method - The method information from static analysis
|
|
53
51
|
* @param checker - TypeScript type checker
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"method-schema.d.ts","sourceRoot":"","sources":["../../src/generators/method-schema.ts"],"names":[],"mappings":"AAAA
|
|
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;AACtC,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;AA4CD;;;;;;;;;;;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"}
|