@formspec/build 0.1.0-alpha.10 → 0.1.0-alpha.12
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__/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 +1200 -0
- package/dist/browser.cjs.map +1 -0
- package/dist/browser.d.ts +12 -6
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +1147 -44
- package/dist/browser.js.map +1 -1
- package/dist/build.d.ts +385 -160
- 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 +2028 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.js +1978 -101
- 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 +28 -47
- 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 +1832 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +8 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1779 -114
- package/dist/index.js.map +1 -1
- package/dist/internals.cjs +2125 -0
- package/dist/internals.cjs.map +1 -0
- package/dist/internals.d.ts +12 -2
- package/dist/internals.d.ts.map +1 -1
- package/dist/internals.js +2084 -21
- 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 +16 -0
- package/dist/json-schema/schema.d.ts.map +1 -0
- 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 -0
- 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/ui-schema/schema.d.ts +357 -0
- package/dist/ui-schema/schema.d.ts.map +1 -0
- package/dist/ui-schema/types.d.ts +8 -73
- package/dist/ui-schema/types.d.ts.map +1 -1
- 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 +15 -9
- 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-edge-cases.test.js +0 -376
- package/dist/__tests__/analyzer-edge-cases.test.js.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__/analyzer.test.js +0 -190
- package/dist/__tests__/analyzer.test.js.map +0 -1
- package/dist/__tests__/cli.test.js +0 -178
- package/dist/__tests__/cli.test.js.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__/codegen.test.js +0 -506
- package/dist/__tests__/codegen.test.js.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__/decorator-pipeline.test.js +0 -460
- package/dist/__tests__/decorator-pipeline.test.js.map +0 -1
- package/dist/__tests__/edge-cases.test.js +0 -215
- package/dist/__tests__/edge-cases.test.js.map +0 -1
- package/dist/__tests__/fixtures/edge-cases.js +0 -137
- package/dist/__tests__/fixtures/edge-cases.js.map +0 -1
- package/dist/__tests__/fixtures/example-a-builtins.js +0 -100
- package/dist/__tests__/fixtures/example-a-builtins.js.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-decorators.js +0 -5
- package/dist/__tests__/fixtures/example-b-decorators.js.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-b-extended.js +0 -60
- package/dist/__tests__/fixtures/example-b-extended.js.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-custom.js +0 -61
- package/dist/__tests__/fixtures/example-c-custom.js.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-c-decorators.js +0 -4
- package/dist/__tests__/fixtures/example-c-decorators.js.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-d-mixed-decorators.js +0 -75
- package/dist/__tests__/fixtures/example-d-mixed-decorators.js.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-decorators.js +0 -10
- package/dist/__tests__/fixtures/example-e-decorators.js.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-e-no-namespace.js +0 -61
- package/dist/__tests__/fixtures/example-e-no-namespace.js.map +0 -1
- package/dist/__tests__/fixtures/example-interface-types.js +0 -8
- package/dist/__tests__/fixtures/example-interface-types.js.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-jsdoc-constraints.js +0 -98
- package/dist/__tests__/fixtures/example-jsdoc-constraints.js.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__/fixtures/example-nested-class.js +0 -248
- package/dist/__tests__/fixtures/example-nested-class.js.map +0 -1
- package/dist/__tests__/fixtures/sample-forms.js +0 -78
- package/dist/__tests__/fixtures/sample-forms.js.map +0 -1
- package/dist/__tests__/generator.test.js +0 -234
- package/dist/__tests__/generator.test.js.map +0 -1
- package/dist/__tests__/integration.test.js +0 -161
- package/dist/__tests__/integration.test.js.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/__tests__/interface-types.test.js +0 -404
- package/dist/__tests__/interface-types.test.js.map +0 -1
- package/dist/__tests__/jsdoc-constraints.test.js +0 -465
- package/dist/__tests__/jsdoc-constraints.test.js.map +0 -1
- package/dist/__tests__/write-schemas.test.js +0 -198
- package/dist/__tests__/write-schemas.test.js.map +0 -1
- package/dist/analyzer/class-analyzer.js +0 -377
- package/dist/analyzer/class-analyzer.js.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/decorator-extractor.js +0 -336
- package/dist/analyzer/decorator-extractor.js.map +0 -1
- package/dist/analyzer/jsdoc-constraints.js +0 -153
- package/dist/analyzer/jsdoc-constraints.js.map +0 -1
- package/dist/analyzer/program.js +0 -114
- package/dist/analyzer/program.js.map +0 -1
- package/dist/analyzer/type-converter.d.ts +0 -75
- package/dist/analyzer/type-converter.d.ts.map +0 -1
- package/dist/analyzer/type-converter.js +0 -474
- package/dist/analyzer/type-converter.js.map +0 -1
- package/dist/codegen/index.d.ts +0 -75
- package/dist/codegen/index.d.ts.map +0 -1
- package/dist/codegen/index.js +0 -597
- package/dist/codegen/index.js.map +0 -1
- package/dist/generators/class-schema.js +0 -140
- package/dist/generators/class-schema.js.map +0 -1
- package/dist/generators/method-schema.js +0 -108
- package/dist/generators/method-schema.js.map +0 -1
- package/dist/json-schema/generator.js +0 -166
- package/dist/json-schema/generator.js.map +0 -1
- package/dist/json-schema/types.js +0 -33
- package/dist/json-schema/types.js.map +0 -1
- package/dist/ui-schema/generator.js +0 -148
- package/dist/ui-schema/generator.js.map +0 -1
- package/dist/ui-schema/types.js +0 -8
- package/dist/ui-schema/types.js.map +0 -1
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type converter for transforming TypeScript types to JSON Schema and FormSpec.
|
|
3
|
-
*
|
|
4
|
-
* Converts TypeScript types (extracted via type checker) to:
|
|
5
|
-
* - JSON Schema definitions
|
|
6
|
-
* - FormSpec field definitions
|
|
7
|
-
*/
|
|
8
|
-
import * as ts from "typescript";
|
|
9
|
-
import type { DecoratorInfo } from "./decorator-extractor.js";
|
|
10
|
-
import { type FieldInfo } from "./class-analyzer.js";
|
|
11
|
-
import { type ExtendedJSONSchema7 } from "../json-schema/types.js";
|
|
12
|
-
/**
|
|
13
|
-
* FormSpec field definition (simplified for output).
|
|
14
|
-
*/
|
|
15
|
-
export interface FormSpecField {
|
|
16
|
-
_field: string;
|
|
17
|
-
id: string;
|
|
18
|
-
label?: string;
|
|
19
|
-
placeholder?: string;
|
|
20
|
-
description?: string;
|
|
21
|
-
required?: boolean;
|
|
22
|
-
min?: number;
|
|
23
|
-
max?: number;
|
|
24
|
-
step?: number;
|
|
25
|
-
minLength?: number;
|
|
26
|
-
maxLength?: number;
|
|
27
|
-
minItems?: number;
|
|
28
|
-
maxItems?: number;
|
|
29
|
-
pattern?: string;
|
|
30
|
-
options?: (string | {
|
|
31
|
-
id: string;
|
|
32
|
-
label: string;
|
|
33
|
-
})[];
|
|
34
|
-
showWhen?: object;
|
|
35
|
-
group?: string;
|
|
36
|
-
fields?: FormSpecField[];
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Result of converting a TypeScript type.
|
|
40
|
-
*/
|
|
41
|
-
export interface TypeConversionResult {
|
|
42
|
-
/** JSON Schema representation */
|
|
43
|
-
jsonSchema: ExtendedJSONSchema7;
|
|
44
|
-
/** FormSpec field type */
|
|
45
|
-
formSpecFieldType: string;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Converts a TypeScript type to JSON Schema and FormSpec field type.
|
|
49
|
-
*
|
|
50
|
-
* @param type - The TypeScript type to convert
|
|
51
|
-
* @param checker - TypeScript type checker
|
|
52
|
-
* @returns Conversion result with JSON Schema and FormSpec type
|
|
53
|
-
*/
|
|
54
|
-
export declare function convertType(type: ts.Type, checker: ts.TypeChecker): TypeConversionResult;
|
|
55
|
-
/**
|
|
56
|
-
* Creates a FormSpec field definition from a field's type and decorators.
|
|
57
|
-
*
|
|
58
|
-
* @param fieldName - The field name
|
|
59
|
-
* @param type - The TypeScript type
|
|
60
|
-
* @param decorators - Decorators applied to the field
|
|
61
|
-
* @param optional - Whether the field is optional
|
|
62
|
-
* @param checker - TypeScript type checker
|
|
63
|
-
* @returns FormSpec field definition
|
|
64
|
-
*/
|
|
65
|
-
export declare function createFormSpecField(fieldName: string, type: ts.Type, decorators: DecoratorInfo[], optional: boolean, checker: ts.TypeChecker, visitedTypes?: Set<ts.Type>): FormSpecField;
|
|
66
|
-
/**
|
|
67
|
-
* Applies decorator constraints to a JSON Schema.
|
|
68
|
-
*
|
|
69
|
-
* @param schema - The base JSON Schema
|
|
70
|
-
* @param decorators - Decorators to apply
|
|
71
|
-
* @param fieldInfo - Optional field info for deprecated/default values
|
|
72
|
-
* @returns Modified JSON Schema with constraints
|
|
73
|
-
*/
|
|
74
|
-
export declare function applyDecoratorsToSchema(schema: ExtendedJSONSchema7, decorators: DecoratorInfo[], fieldInfo?: FieldInfo): ExtendedJSONSchema7;
|
|
75
|
-
//# sourceMappingURL=type-converter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"type-converter.d.ts","sourceRoot":"","sources":["../../src/analyzer/type-converter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AACjC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAA0C,KAAK,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC7F,OAAO,EAAsB,KAAK,mBAAmB,EAAE,MAAM,yBAA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EAAE,CAAC,WAAW,EACvB,YAAY,eAAqB,GAChC,aAAa,CAiDf;AAuFD;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,mBAAmB,EAC3B,UAAU,EAAE,aAAa,EAAE,EAC3B,SAAS,CAAC,EAAE,SAAS,GACpB,mBAAmB,CA6FrB"}
|
|
@@ -1,474 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Type converter for transforming TypeScript types to JSON Schema and FormSpec.
|
|
3
|
-
*
|
|
4
|
-
* Converts TypeScript types (extracted via type checker) to:
|
|
5
|
-
* - JSON Schema definitions
|
|
6
|
-
* - FormSpec field definitions
|
|
7
|
-
*/
|
|
8
|
-
import * as ts from "typescript";
|
|
9
|
-
import { analyzeField, analyzeInterfaceProperty } from "./class-analyzer.js";
|
|
10
|
-
import { setSchemaExtension } from "../json-schema/types.js";
|
|
11
|
-
/**
|
|
12
|
-
* Given a ts.Type for a named type (class, interface, or type alias with
|
|
13
|
-
* a type literal body), navigates to its declaration and returns a Map
|
|
14
|
-
* from property name to its fully analyzed FieldInfo.
|
|
15
|
-
*
|
|
16
|
-
* - **Classes**: uses `analyzeField` to extract decorators + JSDoc constraints
|
|
17
|
-
* - **Interfaces**: extracts `@Field_displayName`, `@Field_description`, and constraint tags
|
|
18
|
-
* - **Type aliases** (object literals): same as interfaces
|
|
19
|
-
*
|
|
20
|
-
* Returns null for unnamed types (inline objects, mapped types, etc.),
|
|
21
|
-
* preserving existing structural-only behavior for those cases.
|
|
22
|
-
*/
|
|
23
|
-
function getNamedTypeFieldInfoMap(type, checker) {
|
|
24
|
-
// Check both direct symbol and alias symbol — type aliases resolve to
|
|
25
|
-
// an anonymous __type symbol, with the original alias on type.aliasSymbol.
|
|
26
|
-
const symbols = [type.getSymbol(), type.aliasSymbol].filter((s) => s?.declarations != null && s.declarations.length > 0);
|
|
27
|
-
for (const symbol of symbols) {
|
|
28
|
-
const declarations = symbol.declarations;
|
|
29
|
-
if (!declarations)
|
|
30
|
-
continue;
|
|
31
|
-
// Try class declaration
|
|
32
|
-
const classDecl = declarations.find(ts.isClassDeclaration);
|
|
33
|
-
if (classDecl) {
|
|
34
|
-
const map = new Map();
|
|
35
|
-
for (const member of classDecl.members) {
|
|
36
|
-
if (ts.isPropertyDeclaration(member) && ts.isIdentifier(member.name)) {
|
|
37
|
-
const fieldInfo = analyzeField(member, checker);
|
|
38
|
-
if (fieldInfo)
|
|
39
|
-
map.set(fieldInfo.name, fieldInfo);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return map;
|
|
43
|
-
}
|
|
44
|
-
// Try interface declaration
|
|
45
|
-
const interfaceDecl = declarations.find(ts.isInterfaceDeclaration);
|
|
46
|
-
if (interfaceDecl) {
|
|
47
|
-
return buildFieldInfoMapFromSignatures(interfaceDecl.members, checker);
|
|
48
|
-
}
|
|
49
|
-
// Try type alias with type literal body: type X = { ... }
|
|
50
|
-
const typeAliasDecl = declarations.find(ts.isTypeAliasDeclaration);
|
|
51
|
-
if (typeAliasDecl && ts.isTypeLiteralNode(typeAliasDecl.type)) {
|
|
52
|
-
return buildFieldInfoMapFromSignatures(typeAliasDecl.type.members, checker);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Builds a FieldInfo map from interface/type-literal property signatures,
|
|
59
|
-
* delegating to {@link analyzeInterfaceProperty} for JSDoc extraction.
|
|
60
|
-
*/
|
|
61
|
-
function buildFieldInfoMapFromSignatures(members, checker) {
|
|
62
|
-
const map = new Map();
|
|
63
|
-
for (const member of members) {
|
|
64
|
-
if (ts.isPropertySignature(member)) {
|
|
65
|
-
const fieldInfo = analyzeInterfaceProperty(member, checker);
|
|
66
|
-
if (fieldInfo) {
|
|
67
|
-
map.set(fieldInfo.name, fieldInfo);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return map;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Iterates the properties of an object type and resolves each property's
|
|
75
|
-
* type, optionality, and class-level field info (decorators/JSDoc).
|
|
76
|
-
*
|
|
77
|
-
* This is the single source of truth for nested property analysis, used
|
|
78
|
-
* by both the JSON Schema and FormSpec field generation paths.
|
|
79
|
-
*/
|
|
80
|
-
function getObjectPropertyInfos(type, checker) {
|
|
81
|
-
const fieldInfoMap = getNamedTypeFieldInfoMap(type, checker);
|
|
82
|
-
const result = [];
|
|
83
|
-
for (const prop of type.getProperties()) {
|
|
84
|
-
const declaration = prop.valueDeclaration ?? prop.declarations?.[0];
|
|
85
|
-
if (!declaration)
|
|
86
|
-
continue;
|
|
87
|
-
const propType = checker.getTypeOfSymbolAtLocation(prop, declaration);
|
|
88
|
-
const optional = !!(prop.flags & ts.SymbolFlags.Optional);
|
|
89
|
-
const fieldInfo = fieldInfoMap?.get(prop.name) ?? undefined;
|
|
90
|
-
result.push({ name: prop.name, type: propType, optional, fieldInfo });
|
|
91
|
-
}
|
|
92
|
-
return result;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Converts a TypeScript type to JSON Schema and FormSpec field type.
|
|
96
|
-
*
|
|
97
|
-
* @param type - The TypeScript type to convert
|
|
98
|
-
* @param checker - TypeScript type checker
|
|
99
|
-
* @returns Conversion result with JSON Schema and FormSpec type
|
|
100
|
-
*/
|
|
101
|
-
export function convertType(type, checker) {
|
|
102
|
-
return convertTypeInternal(type, checker, new Set());
|
|
103
|
-
}
|
|
104
|
-
function convertTypeInternal(type, checker, visiting) {
|
|
105
|
-
// Handle primitive types
|
|
106
|
-
if (type.flags & ts.TypeFlags.String) {
|
|
107
|
-
return { jsonSchema: { type: "string" }, formSpecFieldType: "text" };
|
|
108
|
-
}
|
|
109
|
-
if (type.flags & ts.TypeFlags.Number) {
|
|
110
|
-
return { jsonSchema: { type: "number" }, formSpecFieldType: "number" };
|
|
111
|
-
}
|
|
112
|
-
if (type.flags & ts.TypeFlags.Boolean) {
|
|
113
|
-
return { jsonSchema: { type: "boolean" }, formSpecFieldType: "boolean" };
|
|
114
|
-
}
|
|
115
|
-
if (type.flags & ts.TypeFlags.Null) {
|
|
116
|
-
return { jsonSchema: { type: "null" }, formSpecFieldType: "null" };
|
|
117
|
-
}
|
|
118
|
-
if (type.flags & ts.TypeFlags.Undefined) {
|
|
119
|
-
return { jsonSchema: {}, formSpecFieldType: "undefined" };
|
|
120
|
-
}
|
|
121
|
-
// Handle literal types
|
|
122
|
-
if (type.isStringLiteral()) {
|
|
123
|
-
return {
|
|
124
|
-
jsonSchema: { const: type.value },
|
|
125
|
-
formSpecFieldType: "enum",
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
if (type.isNumberLiteral()) {
|
|
129
|
-
return {
|
|
130
|
-
jsonSchema: { const: type.value },
|
|
131
|
-
formSpecFieldType: "number",
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
// Handle union types (including string literal unions for enums)
|
|
135
|
-
if (type.isUnion()) {
|
|
136
|
-
return convertUnionType(type, checker, visiting);
|
|
137
|
-
}
|
|
138
|
-
// Handle array types
|
|
139
|
-
if (checker.isArrayType(type)) {
|
|
140
|
-
return convertArrayType(type, checker, visiting);
|
|
141
|
-
}
|
|
142
|
-
// Handle object types
|
|
143
|
-
if (type.flags & ts.TypeFlags.Object) {
|
|
144
|
-
return convertObjectType(type, checker, visiting);
|
|
145
|
-
}
|
|
146
|
-
// Fallback
|
|
147
|
-
return { jsonSchema: {}, formSpecFieldType: "unknown" };
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Converts a union type to JSON Schema.
|
|
151
|
-
*/
|
|
152
|
-
function convertUnionType(type, checker, visiting) {
|
|
153
|
-
const types = type.types;
|
|
154
|
-
// Filter out null and undefined for analysis
|
|
155
|
-
// Note: undefined is filtered out since JSON Schema doesn't have an undefined type
|
|
156
|
-
// Optional fields are handled via the 'required' array, not the type
|
|
157
|
-
const nonNullTypes = types.filter((t) => !(t.flags & (ts.TypeFlags.Null | ts.TypeFlags.Undefined)));
|
|
158
|
-
const hasNull = types.some((t) => t.flags & ts.TypeFlags.Null);
|
|
159
|
-
// Check if this is a boolean type (true | false in TypeScript)
|
|
160
|
-
// TypeScript represents `boolean` as a union of `true | false` literal types
|
|
161
|
-
const isBooleanUnion = nonNullTypes.length === 2 && nonNullTypes.every((t) => t.flags & ts.TypeFlags.BooleanLiteral);
|
|
162
|
-
if (isBooleanUnion) {
|
|
163
|
-
const result = {
|
|
164
|
-
jsonSchema: { type: "boolean" },
|
|
165
|
-
formSpecFieldType: "boolean",
|
|
166
|
-
};
|
|
167
|
-
if (hasNull) {
|
|
168
|
-
result.jsonSchema = { oneOf: [{ type: "boolean" }, { type: "null" }] };
|
|
169
|
-
}
|
|
170
|
-
return result;
|
|
171
|
-
}
|
|
172
|
-
// Check if all types are string literals (enum pattern)
|
|
173
|
-
const allStringLiterals = nonNullTypes.every((t) => t.isStringLiteral());
|
|
174
|
-
if (allStringLiterals && nonNullTypes.length > 0) {
|
|
175
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion -- TypeScript doesn't narrow array types from `every` predicate
|
|
176
|
-
const enumValues = nonNullTypes.map((t) => t.value);
|
|
177
|
-
const result = {
|
|
178
|
-
jsonSchema: { enum: enumValues },
|
|
179
|
-
formSpecFieldType: "enum",
|
|
180
|
-
};
|
|
181
|
-
if (hasNull) {
|
|
182
|
-
result.jsonSchema = { oneOf: [{ enum: enumValues }, { type: "null" }] };
|
|
183
|
-
}
|
|
184
|
-
return result;
|
|
185
|
-
}
|
|
186
|
-
// Check if all types are number literals
|
|
187
|
-
const allNumberLiterals = nonNullTypes.every((t) => t.isNumberLiteral());
|
|
188
|
-
if (allNumberLiterals && nonNullTypes.length > 0) {
|
|
189
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion -- TypeScript doesn't narrow array types from `every` predicate
|
|
190
|
-
const enumValues = nonNullTypes.map((t) => t.value);
|
|
191
|
-
const result = {
|
|
192
|
-
jsonSchema: { enum: enumValues },
|
|
193
|
-
formSpecFieldType: "enum",
|
|
194
|
-
};
|
|
195
|
-
if (hasNull) {
|
|
196
|
-
result.jsonSchema = { oneOf: [{ enum: enumValues }, { type: "null" }] };
|
|
197
|
-
}
|
|
198
|
-
return result;
|
|
199
|
-
}
|
|
200
|
-
// Handle nullable types (T | null or T | undefined) with single non-null type
|
|
201
|
-
if (nonNullTypes.length === 1 && nonNullTypes[0]) {
|
|
202
|
-
const result = convertTypeInternal(nonNullTypes[0], checker, visiting);
|
|
203
|
-
// Make it nullable in JSON Schema
|
|
204
|
-
if (hasNull) {
|
|
205
|
-
result.jsonSchema = { oneOf: [result.jsonSchema, { type: "null" }] };
|
|
206
|
-
}
|
|
207
|
-
return result;
|
|
208
|
-
}
|
|
209
|
-
// General union - use oneOf (filter out undefined which isn't valid in JSON Schema)
|
|
210
|
-
const schemas = nonNullTypes.map((t) => convertTypeInternal(t, checker, visiting).jsonSchema);
|
|
211
|
-
if (hasNull) {
|
|
212
|
-
schemas.push({ type: "null" });
|
|
213
|
-
}
|
|
214
|
-
return {
|
|
215
|
-
jsonSchema: { oneOf: schemas },
|
|
216
|
-
formSpecFieldType: "union",
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Converts an array type to JSON Schema.
|
|
221
|
-
*/
|
|
222
|
-
function convertArrayType(type, checker, visiting) {
|
|
223
|
-
const typeArgs = type.typeArguments;
|
|
224
|
-
const elementType = typeArgs?.[0];
|
|
225
|
-
const itemSchema = elementType
|
|
226
|
-
? convertTypeInternal(elementType, checker, visiting).jsonSchema
|
|
227
|
-
: {};
|
|
228
|
-
return {
|
|
229
|
-
jsonSchema: {
|
|
230
|
-
type: "array",
|
|
231
|
-
items: itemSchema,
|
|
232
|
-
},
|
|
233
|
-
formSpecFieldType: "array",
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Converts an object type to JSON Schema.
|
|
238
|
-
*/
|
|
239
|
-
function convertObjectType(type, checker, visiting) {
|
|
240
|
-
// Circular reference guard
|
|
241
|
-
if (visiting.has(type)) {
|
|
242
|
-
return { jsonSchema: { type: "object" }, formSpecFieldType: "object" };
|
|
243
|
-
}
|
|
244
|
-
visiting.add(type);
|
|
245
|
-
const properties = {};
|
|
246
|
-
const required = [];
|
|
247
|
-
for (const propInfo of getObjectPropertyInfos(type, checker)) {
|
|
248
|
-
const propSchema = convertTypeInternal(propInfo.type, checker, visiting).jsonSchema;
|
|
249
|
-
// Apply decorator/JSDoc constraints from the class declaration if available
|
|
250
|
-
properties[propInfo.name] = propInfo.fieldInfo
|
|
251
|
-
? applyDecoratorsToSchema(propSchema, propInfo.fieldInfo.decorators, propInfo.fieldInfo)
|
|
252
|
-
: propSchema;
|
|
253
|
-
if (!propInfo.optional) {
|
|
254
|
-
required.push(propInfo.name);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
visiting.delete(type);
|
|
258
|
-
return {
|
|
259
|
-
jsonSchema: {
|
|
260
|
-
type: "object",
|
|
261
|
-
properties,
|
|
262
|
-
...(required.length > 0 ? { required } : {}),
|
|
263
|
-
},
|
|
264
|
-
formSpecFieldType: "object",
|
|
265
|
-
};
|
|
266
|
-
}
|
|
267
|
-
/**
|
|
268
|
-
* Creates a FormSpec field definition from a field's type and decorators.
|
|
269
|
-
*
|
|
270
|
-
* @param fieldName - The field name
|
|
271
|
-
* @param type - The TypeScript type
|
|
272
|
-
* @param decorators - Decorators applied to the field
|
|
273
|
-
* @param optional - Whether the field is optional
|
|
274
|
-
* @param checker - TypeScript type checker
|
|
275
|
-
* @returns FormSpec field definition
|
|
276
|
-
*/
|
|
277
|
-
export function createFormSpecField(fieldName, type, decorators, optional, checker, visitedTypes = new Set()) {
|
|
278
|
-
const { formSpecFieldType } = convertType(type, checker);
|
|
279
|
-
const field = {
|
|
280
|
-
_field: formSpecFieldType,
|
|
281
|
-
id: fieldName,
|
|
282
|
-
};
|
|
283
|
-
// Apply optionality
|
|
284
|
-
if (!optional) {
|
|
285
|
-
field.required = true;
|
|
286
|
-
}
|
|
287
|
-
// For object types, recursively add nested fields.
|
|
288
|
-
// Note: visitedTypes guards against circular references independently from
|
|
289
|
-
// the `visiting` set in convertTypeInternal — they protect different recursion
|
|
290
|
-
// paths (FormSpec field generation vs JSON Schema generation).
|
|
291
|
-
if (formSpecFieldType === "object" && type.flags & ts.TypeFlags.Object) {
|
|
292
|
-
if (!visitedTypes.has(type)) {
|
|
293
|
-
visitedTypes.add(type);
|
|
294
|
-
const nestedFields = [];
|
|
295
|
-
for (const propInfo of getObjectPropertyInfos(type, checker)) {
|
|
296
|
-
nestedFields.push(createFormSpecField(propInfo.name, propInfo.type, propInfo.fieldInfo?.decorators ?? [], propInfo.optional, checker, visitedTypes));
|
|
297
|
-
}
|
|
298
|
-
visitedTypes.delete(type);
|
|
299
|
-
if (nestedFields.length > 0) {
|
|
300
|
-
field.fields = nestedFields;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
// Apply decorator values
|
|
305
|
-
for (const dec of decorators) {
|
|
306
|
-
applyDecoratorToField(field, dec);
|
|
307
|
-
}
|
|
308
|
-
return field;
|
|
309
|
-
}
|
|
310
|
-
/**
|
|
311
|
-
* Applies a decorator's values to a FormSpec field.
|
|
312
|
-
*
|
|
313
|
-
* Note: Custom decorator extensions (x-formspec-*) are only emitted in JSON Schema
|
|
314
|
-
* via `applyDecoratorsToSchema`, not here. The FormSpecField interface does not
|
|
315
|
-
* carry extension data — extensions are a schema-level concern.
|
|
316
|
-
*
|
|
317
|
-
* @param field - The FormSpec field to modify
|
|
318
|
-
* @param decorator - The decorator information to apply
|
|
319
|
-
*/
|
|
320
|
-
function applyDecoratorToField(field, decorator) {
|
|
321
|
-
const { args } = decorator;
|
|
322
|
-
const resolved = decorator.resolved;
|
|
323
|
-
// If this is an extended decorator, map it to the built-in it extends
|
|
324
|
-
const effectiveName = resolved?.extendsBuiltin ?? decorator.name;
|
|
325
|
-
switch (effectiveName) {
|
|
326
|
-
case "Field": {
|
|
327
|
-
// Field takes an object with displayName, description, placeholder
|
|
328
|
-
const opts = args[0];
|
|
329
|
-
if (typeof opts === "object" && opts !== null && !Array.isArray(opts)) {
|
|
330
|
-
if (typeof opts["displayName"] === "string") {
|
|
331
|
-
field.label = opts["displayName"];
|
|
332
|
-
}
|
|
333
|
-
if (typeof opts["description"] === "string") {
|
|
334
|
-
field.description = opts["description"];
|
|
335
|
-
}
|
|
336
|
-
if (typeof opts["placeholder"] === "string") {
|
|
337
|
-
field.placeholder = opts["placeholder"];
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
break;
|
|
341
|
-
}
|
|
342
|
-
case "Minimum":
|
|
343
|
-
if (typeof args[0] === "number") {
|
|
344
|
-
field.min = args[0];
|
|
345
|
-
}
|
|
346
|
-
break;
|
|
347
|
-
case "Maximum":
|
|
348
|
-
if (typeof args[0] === "number") {
|
|
349
|
-
field.max = args[0];
|
|
350
|
-
}
|
|
351
|
-
break;
|
|
352
|
-
case "MinLength":
|
|
353
|
-
if (typeof args[0] === "number") {
|
|
354
|
-
field.minLength = args[0];
|
|
355
|
-
}
|
|
356
|
-
break;
|
|
357
|
-
case "MaxLength":
|
|
358
|
-
if (typeof args[0] === "number") {
|
|
359
|
-
field.maxLength = args[0];
|
|
360
|
-
}
|
|
361
|
-
break;
|
|
362
|
-
case "Pattern":
|
|
363
|
-
if (typeof args[0] === "string") {
|
|
364
|
-
field.pattern = args[0];
|
|
365
|
-
}
|
|
366
|
-
break;
|
|
367
|
-
case "EnumOptions":
|
|
368
|
-
if (Array.isArray(args[0])) {
|
|
369
|
-
field.options = args[0];
|
|
370
|
-
}
|
|
371
|
-
break;
|
|
372
|
-
case "ShowWhen":
|
|
373
|
-
if (typeof args[0] === "object" && args[0] !== null) {
|
|
374
|
-
field.showWhen = args[0];
|
|
375
|
-
}
|
|
376
|
-
break;
|
|
377
|
-
case "Group":
|
|
378
|
-
if (typeof args[0] === "string") {
|
|
379
|
-
field.group = args[0];
|
|
380
|
-
}
|
|
381
|
-
break;
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
/**
|
|
385
|
-
* Applies decorator constraints to a JSON Schema.
|
|
386
|
-
*
|
|
387
|
-
* @param schema - The base JSON Schema
|
|
388
|
-
* @param decorators - Decorators to apply
|
|
389
|
-
* @param fieldInfo - Optional field info for deprecated/default values
|
|
390
|
-
* @returns Modified JSON Schema with constraints
|
|
391
|
-
*/
|
|
392
|
-
export function applyDecoratorsToSchema(schema, decorators, fieldInfo) {
|
|
393
|
-
const result = { ...schema };
|
|
394
|
-
for (const dec of decorators) {
|
|
395
|
-
const { args } = dec;
|
|
396
|
-
const resolved = dec.resolved;
|
|
397
|
-
// If this is an extended decorator, map it to the built-in it extends
|
|
398
|
-
const effectiveName = resolved?.extendsBuiltin ?? dec.name;
|
|
399
|
-
switch (effectiveName) {
|
|
400
|
-
case "Field": {
|
|
401
|
-
// Field takes an object: { displayName, description?, placeholder? }
|
|
402
|
-
const opts = args[0];
|
|
403
|
-
if (typeof opts === "object" && opts !== null && !Array.isArray(opts)) {
|
|
404
|
-
if (typeof opts["displayName"] === "string") {
|
|
405
|
-
result.title = opts["displayName"];
|
|
406
|
-
}
|
|
407
|
-
if (typeof opts["description"] === "string") {
|
|
408
|
-
result.description = opts["description"];
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
break;
|
|
412
|
-
}
|
|
413
|
-
case "Minimum":
|
|
414
|
-
if (typeof args[0] === "number") {
|
|
415
|
-
result.minimum = args[0];
|
|
416
|
-
}
|
|
417
|
-
break;
|
|
418
|
-
case "Maximum":
|
|
419
|
-
if (typeof args[0] === "number") {
|
|
420
|
-
result.maximum = args[0];
|
|
421
|
-
}
|
|
422
|
-
break;
|
|
423
|
-
case "ExclusiveMinimum":
|
|
424
|
-
if (typeof args[0] === "number") {
|
|
425
|
-
result.exclusiveMinimum = args[0];
|
|
426
|
-
}
|
|
427
|
-
break;
|
|
428
|
-
case "ExclusiveMaximum":
|
|
429
|
-
if (typeof args[0] === "number") {
|
|
430
|
-
result.exclusiveMaximum = args[0];
|
|
431
|
-
}
|
|
432
|
-
break;
|
|
433
|
-
case "MinLength":
|
|
434
|
-
if (typeof args[0] === "number") {
|
|
435
|
-
result.minLength = args[0];
|
|
436
|
-
}
|
|
437
|
-
break;
|
|
438
|
-
case "MaxLength":
|
|
439
|
-
if (typeof args[0] === "number") {
|
|
440
|
-
result.maxLength = args[0];
|
|
441
|
-
}
|
|
442
|
-
break;
|
|
443
|
-
case "Pattern":
|
|
444
|
-
if (typeof args[0] === "string") {
|
|
445
|
-
result.pattern = args[0];
|
|
446
|
-
}
|
|
447
|
-
break;
|
|
448
|
-
}
|
|
449
|
-
// Emit x-formspec-* for custom decorators with a valid extensionName.
|
|
450
|
-
// Extension names must be lowercase alphanumeric with hyphens (e.g., "title-field", "priority").
|
|
451
|
-
if (resolved?.extensionName && /^[a-z][a-z0-9-]*$/.test(resolved.extensionName)) {
|
|
452
|
-
const key = `x-formspec-${resolved.extensionName}`;
|
|
453
|
-
if (resolved.isMarker) {
|
|
454
|
-
setSchemaExtension(result, key, true);
|
|
455
|
-
}
|
|
456
|
-
else {
|
|
457
|
-
// Parameterized: use first argument as value
|
|
458
|
-
setSchemaExtension(result, key, args[0] ?? true);
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
// Apply deprecated and default from FieldInfo
|
|
463
|
-
if (fieldInfo) {
|
|
464
|
-
// eslint-disable-next-line @typescript-eslint/no-deprecated -- `deprecated` is a FieldInfo flag tracking @deprecated JSDoc, not itself deprecated
|
|
465
|
-
if (fieldInfo.deprecated) {
|
|
466
|
-
result.deprecated = true;
|
|
467
|
-
}
|
|
468
|
-
if (fieldInfo.defaultValue !== undefined) {
|
|
469
|
-
result.default = fieldInfo.defaultValue;
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
return result;
|
|
473
|
-
}
|
|
474
|
-
//# sourceMappingURL=type-converter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"type-converter.js","sourceRoot":"","sources":["../../src/analyzer/type-converter.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjC,OAAO,EAAE,YAAY,EAAE,wBAAwB,EAAkB,MAAM,qBAAqB,CAAC;AAC7F,OAAO,EAAE,kBAAkB,EAA4B,MAAM,yBAAyB,CAAC;AAoCvF;;;;;;;;;;;GAWG;AACH,SAAS,wBAAwB,CAC/B,IAAa,EACb,OAAuB;IAEvB,sEAAsE;IACtE,2EAA2E;IAC3E,MAAM,OAAO,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,CACzD,CAAC,CAAC,EAAkB,EAAE,CAAC,CAAC,EAAE,YAAY,IAAI,IAAI,IAAI,CAAC,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,CAC5E,CAAC;IAEF,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;QACzC,IAAI,CAAC,YAAY;YAAE,SAAS;QAE5B,wBAAwB;QACxB,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,kBAAkB,CAAC,CAAC;QAC3D,IAAI,SAAS,EAAE,CAAC;YACd,MAAM,GAAG,GAAG,IAAI,GAAG,EAAqB,CAAC;YACzC,KAAK,MAAM,MAAM,IAAI,SAAS,CAAC,OAAO,EAAE,CAAC;gBACvC,IAAI,EAAE,CAAC,qBAAqB,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;oBACrE,MAAM,SAAS,GAAG,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;oBAChD,IAAI,SAAS;wBAAE,GAA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EAAE,CAAC;oBAChC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;gBAC3B,CAAC;gBACD,MAAM;QACV,CAAC;QAED,sEAAsE;QACtE,iGAAiG;QACjG,IAAI,QAAQ,EAAE,aAAa,IAAI,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;YAChF,MAAM,GAAG,GAAG,cAAc,QAAQ,CAAC,aAAa,EAAW,CAAC;YAC5D,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC;gBACtB,kBAAkB,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;YACxC,CAAC;iBAAM,CAAC;gBACN,6CAA6C;gBAC7C,kBAAkB,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;IACH,CAAC;IAED,8CAA8C;IAC9C,IAAI,SAAS,EAAE,CAAC;QACd,kJAAkJ;QAClJ,IAAI,SAAS,CAAC,UAAU,EAAE,CAAC;YACzB,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC;QAC3B,CAAC;QACD,IAAI,SAAS,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;YACzC,MAAM,CAAC,OAAO,GAAG,SAAS,CAAC,YAAY,CAAC;QAC1C,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/codegen/index.d.ts
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Code generation for FormSpec type metadata.
|
|
3
|
-
*
|
|
4
|
-
* Generates a TypeScript file that patches decorated classes with
|
|
5
|
-
* their extracted type metadata, enabling runtime schema generation
|
|
6
|
-
* as an alternative to a TypeScript transformer.
|
|
7
|
-
*
|
|
8
|
-
* Usage:
|
|
9
|
-
* formspec codegen ./src/forms.ts -o ./src/__formspec_types__.ts
|
|
10
|
-
*
|
|
11
|
-
* Then in your code:
|
|
12
|
-
* import './__formspec_types__'; // Patches all decorated classes
|
|
13
|
-
* import { UserFormSchema, getUserFormFormSpec } from './__formspec_types__';
|
|
14
|
-
* const spec = getUserFormFormSpec();
|
|
15
|
-
*/
|
|
16
|
-
/**
|
|
17
|
-
* Type metadata format used by `@formspec/decorators`.
|
|
18
|
-
*
|
|
19
|
-
* Represents the runtime type information for a field that TypeScript
|
|
20
|
-
* normally erases at compile time.
|
|
21
|
-
*/
|
|
22
|
-
export interface TypeMetadata {
|
|
23
|
-
/** Base type: "string", "number", "boolean", "enum", "array", "object", "unknown" */
|
|
24
|
-
type: string;
|
|
25
|
-
/** For enum types, the possible literal values */
|
|
26
|
-
values?: unknown[];
|
|
27
|
-
/** For array types, metadata about the array element type */
|
|
28
|
-
itemType?: TypeMetadata;
|
|
29
|
-
/** For object types, metadata about each property */
|
|
30
|
-
properties?: Record<string, TypeMetadata>;
|
|
31
|
-
/** Whether the field accepts null */
|
|
32
|
-
nullable?: boolean;
|
|
33
|
-
/** Whether the field is optional (T | undefined or ?: modifier) */
|
|
34
|
-
optional?: boolean;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Information about a decorated class found during codegen analysis.
|
|
38
|
-
*
|
|
39
|
-
* Used to track which classes need type metadata patches and where
|
|
40
|
-
* they are located in the source tree.
|
|
41
|
-
*/
|
|
42
|
-
export interface DecoratedClassInfo {
|
|
43
|
-
/** Class name as it appears in the source file */
|
|
44
|
-
name: string;
|
|
45
|
-
/** Import path to the source file (relative to output, without extension) */
|
|
46
|
-
sourcePath: string;
|
|
47
|
-
/** Type metadata for all decorated properties in the class */
|
|
48
|
-
typeMetadata: Record<string, TypeMetadata>;
|
|
49
|
-
/** Whether the class is exported from its source file */
|
|
50
|
-
isExported: boolean;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Options for code generation.
|
|
54
|
-
*/
|
|
55
|
-
export interface CodegenOptions {
|
|
56
|
-
/** Source files to analyze (glob patterns supported) */
|
|
57
|
-
files: string[];
|
|
58
|
-
/** Output file path */
|
|
59
|
-
output: string;
|
|
60
|
-
/** Base directory for relative imports */
|
|
61
|
-
baseDir?: string;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Finds all decorated classes in the given source files.
|
|
65
|
-
*/
|
|
66
|
-
export declare function findDecoratedClasses(files: string[], baseDir: string): DecoratedClassInfo[];
|
|
67
|
-
/**
|
|
68
|
-
* Generates the codegen output file content.
|
|
69
|
-
*/
|
|
70
|
-
export declare function generateCodegenOutput(classes: DecoratedClassInfo[], outputPath: string, baseDir: string): string;
|
|
71
|
-
/**
|
|
72
|
-
* Runs the code generation.
|
|
73
|
-
*/
|
|
74
|
-
export declare function runCodegen(options: CodegenOptions): void;
|
|
75
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/codegen/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,qFAAqF;IACrF,IAAI,EAAE,MAAM,CAAC;IACb,kDAAkD;IAClD,MAAM,CAAC,EAAE,OAAO,EAAE,CAAC;IACnB,6DAA6D;IAC7D,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,qDAAqD;IACrD,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAC1C,qCAAqC;IACrC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,mEAAmE;IACnE,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC,kDAAkD;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,6EAA6E;IAC7E,UAAU,EAAE,MAAM,CAAC;IACnB,8DAA8D;IAC9D,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,C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